You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.0 KiB

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);