Ajout initial des fichiers du projet

This commit is contained in:
Rampeur
2025-08-08 10:47:29 +02:00
parent 29635cdf83
commit ffdc93834a
46 changed files with 15499 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
var mongoose = require('mongoose');
var QcmQuestionSchema = new mongoose.Schema({
num: Number,
libelle: String,
choices: [
{ type: mongoose.Schema.Types.ObjectId, ref: 'QcmChoice' }
]
}, {timestamps: true, toJSON: {virtuals: true}});
QcmQuestionSchema.methods.addChoice = function (id) {
if (this.choices.indexOf(id) === -1) {
this.choices.push(id);
}
return this.save();
};
QcmQuestionSchema.methods.removeChoice = function (id) {
this.choices.remove(id);
return this.save();
};
QcmQuestionSchema.methods.toJSONFor = function() {
return {
num: this.num,
libelle: this.libelle,
choices: this.choices.map(choice => choice.toJSONFor())
};
};
mongoose.model('QcmQuestion', QcmQuestionSchema);