Skip to content

Commit

Permalink
Termine l'évaluation à l'affichage de l'écran de fin
Browse files Browse the repository at this point in the history
  • Loading branch information
etienneCharignon authored and mdomine committed Mar 1, 2021
1 parent 85b7595 commit ff46536
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
5 changes: 2 additions & 3 deletions src/situations/accueil/modeles/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,10 @@ export function creeStore (registreUtilisateur, fetch = window.fetch) {
commit('metsAJourSituations', situations);
});
},
synchroniseCompetencesFortes ({ commit }) {
return fetch(registreUtilisateur.urlEvaluation('competences_fortes'))
termineEvaluation ({ commit }) {
return fetch(registreUtilisateur.urlEvaluation('fin'), { method: 'POST' })
.then((reponse) => {
if (reponse.status === 404) {
commit('deconnecte');
throw reponse;
}
return reponse;
Expand Down
6 changes: 3 additions & 3 deletions src/situations/accueil/vues/fin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default {
},
mounted () {
this.synchroniseCompetencesfortes();
this.termineEvaluation();
},
methods: {
Expand All @@ -155,8 +155,8 @@ export default {
this.afficheDonnerAvis = true;
},
synchroniseCompetencesfortes () {
this.$store.dispatch('synchroniseCompetencesFortes');
termineEvaluation () {
this.$store.dispatch('termineEvaluation');
}
}
};
Expand Down
8 changes: 6 additions & 2 deletions src/situations/commun/infra/registre_utilisateur.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ export default class RegistreUtilisateur extends EventEmitter {
}

urlEvaluation (element = '') {
if (element.length > 0) { element = `/${element}`; }
return `${this.urlServeur}/api/evaluations/${this.idEvaluation()}${element}.json`;
const urlEvaluation = `${this.urlServeur}/api/evaluations/${this.idEvaluation()}`;
if (element.length > 0) {
return `${urlEvaluation}/${element}`;
} else {
return `${urlEvaluation}.json`;
}
}

estConnecte () {
Expand Down
6 changes: 3 additions & 3 deletions tests/situations/accueil/modeles/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ describe("Le store de l'accueil", function () {

it('sait récupérer les deux compétences fortes depuis le serveur', function () {
registreUtilisateur.urlEvaluation = (element) => {
expect(element).to.eql('competences_fortes');
return '/evaluation/1/competences_fortes.json';
expect(element).to.eql('fin');
return '/evaluation/1/fin';
};
const fetch = (url) => Promise.resolve({
json: () => {
return { competences_fortes: ['comprehension_consigne', 'rapidite', 'tri'] };
}
});
const store = creeStore(registreUtilisateur, fetch);
return store.dispatch('synchroniseCompetencesFortes').then(() => {
return store.dispatch('termineEvaluation').then(() => {
const competencesFortesAttendues = ['comprehension_consigne', 'rapidite'];
expect(store.state.competencesFortes).to.eql(competencesFortesAttendues);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/situations/accueil/vues/fin.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('La vue de fin', function () {

it("sait s'afficher", function () {
store.dispatch = (evenement) => {
expect(evenement).to.eql('synchroniseCompetencesFortes');
expect(evenement).to.eql('termineEvaluation');
store.state.competencesFortes = ['rapidite', 'comprehension_consigne'];
return Promise.resolve();
};
Expand Down
4 changes: 2 additions & 2 deletions tests/situations/commun/infra/registre_utilisateur.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ describe('le registre utilisateur', function () {
it("retourne l'url d'un élément d'une évaluation", function () {
const registre = unRegistre(1, 'test', 'http://localhost');
return registre.inscris('test').then(() => {
expect(registre.urlEvaluation('competences_fortes'))
.to.eql('http://localhost/api/evaluations/1/competences_fortes.json');
expect(registre.urlEvaluation('termine'))
.to.eql('http://localhost/api/evaluations/1/termine');
});
});
});

0 comments on commit ff46536

Please sign in to comment.