forked from hangshuo652/aurak
fix: 修复10个TS类型错误 - ForbiddenException导入、sort字段、user.name、question.content、lines类型、status比较
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
NotFoundException,
|
||||
Inject,
|
||||
forwardRef,
|
||||
ForbiddenException,
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository, DeepPartial, In } from 'typeorm';
|
||||
|
||||
@@ -34,7 +34,7 @@ export class ExportService {
|
||||
|
||||
const questions = await this.questionRepository.find({
|
||||
where: { sessionId },
|
||||
order: { order: 'ASC' },
|
||||
order: { createdAt: 'ASC' },
|
||||
});
|
||||
|
||||
const answers = await this.answerRepository.find({
|
||||
@@ -46,7 +46,7 @@ export class ExportService {
|
||||
const summarySheet = [
|
||||
['评估报告'],
|
||||
['评估ID', session.id],
|
||||
['用户', session.user?.name || session.userId],
|
||||
['用户', session.user?.displayName || session.user?.username || session.userId],
|
||||
['状态', session.status],
|
||||
['最终分数', session.finalScore || '-'],
|
||||
['原始分数', session.originalScore || '-'],
|
||||
@@ -68,7 +68,7 @@ export class ExportService {
|
||||
const a = answerMap.get(q.id);
|
||||
questionRows.push([
|
||||
(i + 1).toString(),
|
||||
q.content || q.questionText || '',
|
||||
q.questionText || '',
|
||||
a?.userAnswer || '',
|
||||
a?.score?.toString() || '',
|
||||
a?.feedback || '',
|
||||
@@ -122,11 +122,11 @@ export class ExportService {
|
||||
if ((currentLine + ' ' + word).trim().length <= maxWidth) {
|
||||
currentLine = (currentLine + ' ' + word).trim();
|
||||
} else {
|
||||
if (currentLine) lines.push([currentLine]);
|
||||
if (currentLine) lines.push(currentLine);
|
||||
currentLine = word;
|
||||
}
|
||||
}
|
||||
if (currentLine) lines.push([currentLine]);
|
||||
if (currentLine) lines.push(currentLine);
|
||||
}
|
||||
|
||||
return lines.map((l) => [l]);
|
||||
@@ -148,7 +148,7 @@ export class ExportService {
|
||||
|
||||
const questions = await this.questionRepository.find({
|
||||
where: { sessionId },
|
||||
order: { order: 'ASC' },
|
||||
order: { createdAt: 'ASC' },
|
||||
});
|
||||
|
||||
const answers = await this.answerRepository.find({
|
||||
@@ -173,7 +173,7 @@ export class ExportService {
|
||||
lines.push('');
|
||||
|
||||
lines.push(`评估ID: ${session.id}`);
|
||||
lines.push(`用户: ${session.user?.name || session.userId}`);
|
||||
lines.push(`用户: ${session.user?.displayName || session.user?.username || session.userId}`);
|
||||
lines.push(`状态: ${session.status === 'COMPLETED' ? '已完成' : '进行中'}`);
|
||||
lines.push(`最终分数: ${session.finalScore || '-'}`);
|
||||
lines.push(`评估模板: ${session.template?.name || session.templateJson?.name || '-'}`);
|
||||
@@ -202,7 +202,7 @@ export class ExportService {
|
||||
const a = answerMap.get(q.id);
|
||||
lines.push('');
|
||||
lines.push(`第${i + 1}题:`);
|
||||
lines.push(` 题目: ${q.content || q.questionText || '-'}`);
|
||||
lines.push(` 题目: ${q.questionText || '-'}`);
|
||||
lines.push(` 用户回答: ${a?.userAnswer || '-'}`);
|
||||
lines.push(` 得分: ${a?.score ?? '-'}`);
|
||||
lines.push(` 反馈: ${a?.feedback || '-'}`);
|
||||
|
||||
@@ -196,9 +196,9 @@ export class QuestionBankService {
|
||||
if (bank.status === QuestionBankStatus.PUBLISHED) {
|
||||
return bank;
|
||||
}
|
||||
if (bank.status !== QuestionBankStatus.PUBLISHED && bank.status !== QuestionBankStatus.REJECTED) {
|
||||
if (bank.status !== QuestionBankStatus.REJECTED) {
|
||||
throw new ForbiddenException(
|
||||
'Only PUBLISHED or REJECTED status can be re-published',
|
||||
'Only REJECTED status can be re-published',
|
||||
);
|
||||
}
|
||||
bank.status = QuestionBankStatus.PUBLISHED;
|
||||
@@ -424,7 +424,6 @@ export class QuestionBankService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selected.length < count) {
|
||||
const remaining = allItems.filter((i) => !usedIds.has(i.id));
|
||||
|
||||
Reference in New Issue
Block a user