Skip to content

Commit

Permalink
Showing 2 changed files with 34 additions and 12 deletions.
28 changes: 28 additions & 0 deletions backend/web/server/plugins/cyberleague/schemas/AnswerSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const mongoose = require('mongoose')
const {schemaOptions} = require('../../../utils/schemas')
const { ANSWERS } = require('../consts')

const Schema = mongoose.Schema

const AnswerSchema = new Schema({
score: {
type: Schema.Types.ObjectId,
ref: 'score',
required: [true, `Le score est obligatoire dans la réponse`],
},
question: {
type: Schema.Types.ObjectId,
ref: 'question',
required: [true, `La question est obligatoire dans la réponse`],
},
answer: {
type: String,
enum: Object.keys(ANSWERS),
required: false
}
}, {...schemaOptions})

/* eslint-disable prefer-arrow-callback */
/* eslint-enable prefer-arrow-callback */

module.exports = AnswerSchema
18 changes: 6 additions & 12 deletions backend/web/server/plugins/cyberleague/schemas/ScoreSchema.js
Original file line number Diff line number Diff line change
@@ -11,19 +11,13 @@ const ScoreSchema = new Schema({
ref: 'user',
required: [true, `Le créateur du score est obligatoire`],
},
questions: {
answers: {
type: [{
question: {
type: Schema.Types.ObjectId,
ref: 'question',
required: true
},
answer: {
type: String,
enum: Object.keys(ANSWERS),
required: true
}
}]
type: Schema.Types.ObjectId,
ref: 'answer',
required: true,
}],
default: []
},
global_rate: {
type: Number,

0 comments on commit b3c1c52

Please sign in to comment.