@easydriver/scores-computation
v2.6.0
Published
This package exports functions to calculate the results of an exam.
Downloads
14
Readme
edt-scores-calculation
This package exports functions to calculate the results of an exam.
Usage
The package expose a factory which can be used to customize the compute functions.
Normally the default configuration is adequate to compute exams scores for the EDT project.
const scoreComputer = require('@easydriver/scores-computation')()
// `me` is a User object
const exam = await Exam.findOne({ user: me._id }).lean()
const corpus = await ExamContent.findOne({ _id: exam.examContent }).lean()
// If you want the objective and the subjective scores
const scores = scoreComputer.compute({
questions: corpus.content,
answers: exam.answers,
})
// If you want only one of the two
const objectiveScores = scoreComputer.computeObjective({
questions: corpus.content,
answers: exam.answers,
})
const subjectiveScores = scoreComputer.computeSubjective({
questions: corpus.content,
answers: exam.answers,
})
## Score object
TODO
## Statistics
The scoreComputer
allows to compute the scores but also to generate some statistics about corpus. By calling the method getStatistics
you can retrieve these statistics.
:warning: By default the scoresComputer's methods will not collect stats. You must turn on the collect by setting the option
collectStats
totrue
const scoresComputer = require('@easydriver/scores-computation')({ collectStats: true })
Here is an example with commentary to understand the generated stats :
{
// `calls` key contains function call counters
"calls": {
"compute": 86,
"computeObjective": 86,
"computeSubjective": 86
},
// `questions` key contains per question statistics
"questions": {
"5c5c093de7471c378ad4dc98": {
"answeredCnt": 27, // Indicates how many times this question has been answered
"successRate": 0.666, // Indicates the success rate of this question
"partialSuccessRate": 0.333, // Indicates the proportion of incomplete response
// ---> only usefull for multiple choice question
"responseTime": { // Statistics about reponse time (in millisecondes)
"min": 1787,
"max": 40124,
"average": 17161
},
"answerDistribution": { // For each possible answer, indicates how many times the answer is
"0": 0, // picked by the user
"1": 0,
"2": 0,
"3": 0,
"4": 0.7407407407407407, // Ex: picked in 74% of cases
"5": 0, // Ex: never picked
"6": 0.8148148148148148,
"7": 0.9259259259259259,
"8": 0.8148148148148148
}
},
// ...
}
}