From ee09d2eaaef8ad9c8e8f4da61983fbd0cd8caa23 Mon Sep 17 00:00:00 2001 From: SeghirOumo Date: Wed, 4 Sep 2024 12:27:00 +0200 Subject: [PATCH] Aftral[#111]: moved attributes from homework to resource --- .../web/server/plugins/aftral-lms/block.js | 3 +++ .../server/plugins/aftral-lms/functions.js | 3 +-- .../plugins/aftral-lms/schemas/BlockSchema.js | 19 +++++++++++++++++-- .../aftral-lms/schemas/HomeworkSchema.js | 15 --------------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/backend/web/server/plugins/aftral-lms/block.js b/backend/web/server/plugins/aftral-lms/block.js index 04a33e6fb9..f20e5d1e50 100644 --- a/backend/web/server/plugins/aftral-lms/block.js +++ b/backend/web/server/plugins/aftral-lms/block.js @@ -27,6 +27,9 @@ const LINKED_ATTRIBUTES_CONVERSION={ success_note_max: lodash.identity, success_scale: v=>v || false, max_attempts: lodash.identity, + note: lodash.identity, + scale: lodash.identity, + correction: lodash.identity, } const LINKED_ATTRIBUTES=Object.keys(LINKED_ATTRIBUTES_CONVERSION) diff --git a/backend/web/server/plugins/aftral-lms/functions.js b/backend/web/server/plugins/aftral-lms/functions.js index 78fd73dbd9..7e977cbde1 100644 --- a/backend/web/server/plugins/aftral-lms/functions.js +++ b/backend/web/server/plugins/aftral-lms/functions.js @@ -104,10 +104,9 @@ BLOCK_MODELS.forEach(model => { declareComputedField({model, field: 'homeworks_submitted_count', type: 'Number', requires: 'session', getterFn: getBlockHomeworksSubmitted}) declareComputedField({model, field: 'homeworks_missing_count', type: 'Number', requires: 'session', getterFn: getBlockHomeworksMissing}) declareComputedField({model, field: 'trainees_count', type: 'Number', requires: 'session', getterFn: getBlockTraineesCount}) + declareEnumField({model, field: 'scale', enumValues: SCALE}) }) -declareEnumField({model: 'homework', field: 'scale', enumValues: SCALE}) - //Program start declareEnumField({model:'program', field: 'status', enumValues: PROGRAM_STATUS}) declareEnumField({model: 'program', field: 'duration_unit', enumValues: DURATION_UNIT}) diff --git a/backend/web/server/plugins/aftral-lms/schemas/BlockSchema.js b/backend/web/server/plugins/aftral-lms/schemas/BlockSchema.js index 05a3828335..514fcc16eb 100644 --- a/backend/web/server/plugins/aftral-lms/schemas/BlockSchema.js +++ b/backend/web/server/plugins/aftral-lms/schemas/BlockSchema.js @@ -3,7 +3,7 @@ const moment = require('moment') const lodash=require('lodash') const {schemaOptions} = require('../../../utils/schemas') const Schema = mongoose.Schema -const {BLOCK_DISCRIMINATOR, BLOCK_STATUS,RESOURCE_TYPE, ACHIEVEMENT_RULE_SUCCESS, RESOURCE_TYPE_SCORM, ACHIEVEMENT_RULE, AVAILABLE_ACHIEVEMENT_RULES}=require('../consts') +const {BLOCK_DISCRIMINATOR, BLOCK_STATUS,RESOURCE_TYPE, ACHIEVEMENT_RULE_SUCCESS, RESOURCE_TYPE_SCORM, ACHIEVEMENT_RULE, AVAILABLE_ACHIEVEMENT_RULES, SCALE}=require('../consts') const { DUMMY_REF } = require('../../../utils/database') const { getAttribute } = require('../block') const { BadRequestError } = require('../../../utils/errors') @@ -233,7 +233,22 @@ const BlockSchema = new Schema({ trainees_count: { type: Number, required: false, - } + }, + // Note or scale is set by the trainer + note: { + type: Number, + required: false, + }, + scale: { + type: String, + enum: Object.keys(SCALE), + required: false, + }, + // Correction par le formateur + correction: { + type: String, + required: false, + }, }, {...schemaOptions, ...BLOCK_DISCRIMINATOR}) BlockSchema.virtual('is_template', DUMMY_REF).get(function() { diff --git a/backend/web/server/plugins/aftral-lms/schemas/HomeworkSchema.js b/backend/web/server/plugins/aftral-lms/schemas/HomeworkSchema.js index d3b9b39573..64c1243c55 100644 --- a/backend/web/server/plugins/aftral-lms/schemas/HomeworkSchema.js +++ b/backend/web/server/plugins/aftral-lms/schemas/HomeworkSchema.js @@ -22,21 +22,6 @@ const HomeworkSchema = new Schema({ type: String, required: false, }, - // Note or scale is set by the trainer - note: { - type: Number, - required: false, - }, - scale: { - type: String, - enum: Object.keys(SCALE), - required: false, - }, - // Correction par le formateur - correction: { - type: String, - required: false, - }, }, {...schemaOptions, ...BLOCK_DISCRIMINATOR}) module.exports = HomeworkSchema