feat: 优化考试记录接口,支持从任务反推科目名称;更新测试用例以验证新逻辑
This commit is contained in:
@@ -140,11 +140,13 @@ export class QuizModel {
|
||||
const recordsSql = `
|
||||
SELECT r.id, r.user_id as userId, r.total_score as totalScore, r.correct_count as correctCount, r.total_count as totalCount,
|
||||
r.score_percentage as scorePercentage, r.status, r.created_at as createdAt,
|
||||
r.subject_id as subjectId, s.name as subjectName,
|
||||
COALESCE(r.subject_id, t.subject_id) as subjectId,
|
||||
COALESCE(s.name, ts.name) as subjectName,
|
||||
r.task_id as taskId, t.name as taskName
|
||||
FROM quiz_records r
|
||||
LEFT JOIN exam_subjects s ON r.subject_id = s.id
|
||||
LEFT JOIN exam_tasks t ON r.task_id = t.id
|
||||
LEFT JOIN exam_subjects s ON r.subject_id = s.id
|
||||
LEFT JOIN exam_subjects ts ON t.subject_id = ts.id
|
||||
WHERE r.user_id = ?
|
||||
ORDER BY r.created_at DESC
|
||||
LIMIT ? OFFSET ?
|
||||
@@ -169,11 +171,16 @@ export class QuizModel {
|
||||
SELECT r.id, r.user_id as userId, u.name as userName, u.phone as userPhone,
|
||||
r.total_score as totalScore, r.correct_count as correctCount, r.total_count as totalCount,
|
||||
r.score_percentage as scorePercentage, r.status,
|
||||
r.created_at as createdAt, r.subject_id as subjectId, s.name as subjectName,
|
||||
r.task_id as taskId
|
||||
r.created_at as createdAt,
|
||||
COALESCE(r.subject_id, t.subject_id) as subjectId,
|
||||
COALESCE(s.name, ts.name) as subjectName,
|
||||
r.task_id as taskId,
|
||||
t.name as taskName
|
||||
FROM quiz_records r
|
||||
JOIN users u ON r.user_id = u.id
|
||||
LEFT JOIN exam_tasks t ON r.task_id = t.id
|
||||
LEFT JOIN exam_subjects s ON r.subject_id = s.id
|
||||
LEFT JOIN exam_subjects ts ON t.subject_id = ts.id
|
||||
ORDER BY r.created_at DESC
|
||||
LIMIT ? OFFSET ?
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user