feat: 完善中文心理测评平台
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
const correctAnswers: Record<number, string> = {
|
||||
1: 'B',
|
||||
2: 'A',
|
||||
3: 'B',
|
||||
4: 'A',
|
||||
5: 'B',
|
||||
6: 'B',
|
||||
7: 'B',
|
||||
};
|
||||
|
||||
export function calculateCRTResults(answers: string[]) {
|
||||
const items = answers.map((answer, index) => {
|
||||
const questionId = index + 1;
|
||||
return {
|
||||
questionId,
|
||||
selected: answer,
|
||||
correct: correctAnswers[questionId],
|
||||
isCorrect: answer === correctAnswers[questionId],
|
||||
};
|
||||
});
|
||||
|
||||
const score = items.filter((item) => item.isCorrect).length;
|
||||
|
||||
return {
|
||||
score,
|
||||
total: Object.keys(correctAnswers).length,
|
||||
items,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user