From 89fc6765503906c71305a949d8e6beeb9b1261f6 Mon Sep 17 00:00:00 2001 From: phgkfux43 <3469266505@qq.com> Date: Sat, 26 Apr 2025 22:38:56 +0800 Subject: [PATCH] ADD file via upload --- Result.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Result.js diff --git a/Result.js b/Result.js new file mode 100644 index 0000000..fc19f27 --- /dev/null +++ b/Result.js @@ -0,0 +1,49 @@ +const mongoose = require('mongoose'); + +const answerSchema = new mongoose.Schema({ + questionId: { + type: mongoose.Schema.Types.ObjectId, + required: true + }, + userAnswer: mongoose.Schema.Types.Mixed, + isCorrect: { + type: Boolean, + required: true + }, + score: { + type: Number, + required: true + } +}); + +const resultSchema = new mongoose.Schema({ + exam: { + type: mongoose.Schema.Types.ObjectId, + ref: 'Exam', + required: true + }, + user: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + required: true + }, + answers: [answerSchema], + totalScore: { + type: Number, + required: true + }, + maxScore: { + type: Number, + required: true + }, + timeTaken: { // 用时(秒) + type: Number, + required: true + }, + submittedAt: { + type: Date, + default: Date.now + } +}); + +module.exports = mongoose.model('Result', resultSchema); \ No newline at end of file