Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

[#575] [FEATURE] Classer les acquis par odre de difficulté décroissante lors de la récupération pour un utilisateur donné - (US-880) #575

Merged
merged 9 commits into from
Nov 7, 2017

Conversation

florianEnoh
Copy link
Contributor

No description provided.

@florianEnoh florianEnoh changed the title [#] [FEATURE] Classer les acquis par odre de difficulté décroissante lors de la récupération pour un utilisateur donné - (US-880) [#575] [FEATURE] Classer les acquis par odre de difficulté décroissante lors de la récupération pour un utilisateur donné - (US-880) Nov 2, 2017
}

function _getCompetenceById(competences, competenceId) {
return _(competences).find((competence) => competence.id === competenceId);
function _getCompetenceById(competences, challenge) {
Copy link
Collaborator

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 ?

Copy link
Contributor Author

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);
Copy link
Collaborator

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 ?

Copy link
Contributor Author

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) {
Copy link
Collaborator

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?

Copy link
Contributor Author

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) {
Copy link
Collaborator

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 "_" ?)

Copy link
Contributor Author

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

@florianEnoh florianEnoh force-pushed the 880-sort-in-desc-three-highests-skills branch from acaca50 to f130278 Compare November 2, 2017 13:52
assessments.forEach((assessment) => {
answersPromises.push(answerRepository.findByAssessment(assessment.id));
});
function _getRightAnswersByAssesments(assessments) {
Copy link
Contributor

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 ?

Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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
Copy link
Contributor

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);
Copy link
Contributor

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) => {
Copy link
Contributor

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) => {
Copy link
Contributor

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();
Copy link
Contributor

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) {
Copy link
Contributor

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);
Copy link
Contributor

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) => {
Copy link
Contributor

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) {
Copy link
Contributor

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);
Copy link
Contributor

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(() => {
Copy link
Contributor

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()

@qcattez qcattez merged commit 7bbb51f into dev Nov 7, 2017
qcattez pushed a commit that referenced this pull request Nov 7, 2017
…croissante lors de la récupération pour un utilisateur donné - (US-880)"
@qcattez qcattez deleted the 880-sort-in-desc-three-highests-skills branch November 7, 2017 16:07
@qcattez
Copy link
Contributor

qcattez commented Nov 7, 2017

@Akhilian Akhilian added this to the v1.28.0 milestone Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants