Skip to content

Commit

Permalink
Aftral[premieroctet#111]: moved attributes from homework to resource
Browse files Browse the repository at this point in the history
  • Loading branch information
SeghirOumo committed Sep 4, 2024
1 parent eca915f commit ee09d2e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
3 changes: 3 additions & 0 deletions backend/web/server/plugins/aftral-lms/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions backend/web/server/plugins/aftral-lms/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
19 changes: 17 additions & 2 deletions backend/web/server/plugins/aftral-lms/schemas/BlockSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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() {
Expand Down
15 changes: 0 additions & 15 deletions backend/web/server/plugins/aftral-lms/schemas/HomeworkSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ee09d2e

Please sign in to comment.