-
Notifications
You must be signed in to change notification settings - Fork 20
[#575] [FEATURE] Classer les acquis par odre de difficulté décroissante lors de la récupération pour un utilisateur donné - (US-880) #575
Conversation
} | ||
|
||
function _getCompetenceById(competences, competenceId) { | ||
return _(competences).find((competence) => competence.id === competenceId); | ||
function _getCompetenceById(competences, challenge) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A renommer peut être ? getCompetenceByChallengeCompetenceId ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'aime pas quand tu as raison 👍
function _getCompetenceById(competences, competenceId) { | ||
return _(competences).find((competence) => competence.id === competenceId); | ||
function _getCompetenceById(competences, challenge) { | ||
return competences.find((competence) => challenge && competence.id === challenge.competence); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ne retourne rien si pas de challenge. Utilité de vérifié la présence d'un challenge pour chaque compétences ? Le faire avant (dans la fonction) ou à l'appel de la fonction ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return take(sortedSkills, 3); | ||
} | ||
|
||
function _sortCompetencesSkillsInDesc(competences) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renommer pour préciser qu'il ne prend que les 3 plus grand : _sortAndExtractThreeMostDifficultsCompetencesSkills?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
return challenges.find((challenge) => challenge.id === answer.challengeId); | ||
} | ||
|
||
function addSkillsToCompetence(competence, challenge) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas trouvé de test dessus
Fonction utilisé que dans ce fichier ? (manque un "_" ?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oui c'est une coquille
acaca50
to
f130278
Compare
assessments.forEach((assessment) => { | ||
answersPromises.push(answerRepository.findByAssessment(assessment.id)); | ||
}); | ||
function _getRightAnswersByAssesments(assessments) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Du coup ça devient _findRightAnswersByAssesments(assessments)
c'est ça ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Et on peut remplacer Right
par Correct
} | ||
|
||
function _getCompetenceById(competences, competenceId) { | ||
return _(competences).find((competence) => competence.id === competenceId); | ||
function _getCompetenceByChallengeCompetenceId(competences, challenge) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vu ce que vous passez en paramètre, c'est plutôt _getCompetenceByChallenge(competences, challenge)
.then(answers => resolve(answers.models)) | ||
.catch(reject); | ||
}); | ||
getRightAnswersByAssessment(assessmentId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ça devient findCorrectAnswersByAssessment
du coup
.where({ challengeId, assessmentId }) | ||
.fetch() | ||
); | ||
return Answer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 pour le refacto ;)
} | ||
|
||
function _getRelatedChallengeById(challenges, answer) { | ||
return challenges.find((challenge) => challenge.id === answer.challengeId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il vaut mieux utiliser le get de l'object Bookshelf que d'accéder directement à l'attribut : answer.get('challengeId')
}); | ||
} | ||
.then(([challenges, competences, answers]) => { | ||
answers.map((answer) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On peut remplacer map
par forEach
challengeRepository.list(), competenceRepository.list(), answersByAssessments | ||
]); | ||
function _sortThreeMostDifficultSkillsInDesc(skills) { | ||
const skillsWithExtractedLevel = skills.map((skill) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Du coup en utilisant le modèle de JJ embarquant déjà la notion de difficulty
, pas besoin de créer cet objet ?
@@ -87,7 +90,9 @@ describe('Unit | Repository | AnswerRepository', function() { | |||
}); | |||
|
|||
after(function(done) { | |||
knex('answers').delete().then(() => {done();}); | |||
knex('answers').delete().then(() => { | |||
done(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
inutile, on peut return knex('answers').delete()
return challenges.find((challenge) => challenge.id === answer.challengeId); | ||
} | ||
|
||
function _addSkillsToCompetence(competence, challenge) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pour moi, cette fonction privée n'est pas super utile.
Je met une proposition plus bas.
answers.map((answer) => { | ||
const challenge = _getRelatedChallengeById(challenges, answer); | ||
const competence = _getCompetenceByChallengeCompetenceId(competences, challenge); | ||
_addSkillsToCompetence(competence, challenge); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
answers.forEach((answer) => {
const challenge = _getRelatedChallengeById(challenges, answer);
const competence = _getCompetenceByChallengeCompetenceId(competences, challenge);
if (challenge && competence) {
challenge.knowledgeTags.forEach((skill) => {
competence.addSkill(new Skill(skill));
});
}
});
challengeRepository.list(), competenceRepository.list(), answersByAssessments | ||
]); | ||
function _sortThreeMostDifficultSkillsInDesc(skills) { | ||
const skillsWithExtractedLevel = skills.map((skill) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cette notion de difficulty devrait être porté par l'objet Skill.
return take(sortedSkills, 3); | ||
} | ||
|
||
function _sortAndExtractThreeMostDifficultsCompetencesSkills(competences) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ce que fait cette fonction _sortAndExtractThreeMostDifficultsCompetencesSkills
, c'est _limitSkillsToTheThreeHighest
. Pour la moi, la notion de sort est presque anecdotique.
|
||
function _sortAndExtractThreeMostDifficultsCompetencesSkills(competences) { | ||
competences.forEach((competence) => { | ||
competence.skills = _sortThreeMostDifficultSkillsInDesc(competence.skills); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Du coup, on peux rename ici aussi.
@@ -39,7 +40,9 @@ describe('Unit | Repository | AnswerRepository', function() { | |||
}); | |||
|
|||
after(function(done) { | |||
knex('answers').delete().then(() => {done();}); | |||
knex('answers').delete().then(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On peux enlever les done()
…croissante lors de la récupération pour un utilisateur donné - (US-880)"
No description provided.