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

[#342] [FEATURE] Affichage de la zone de correction pour les challenges QROCM-ind (US-385) #342

Merged
merged 94 commits into from
Apr 11, 2017
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
c0342dd
first commit
MBrandone Feb 15, 2017
612c342
create component
MBrandone Feb 15, 2017
ea29e7e
ajout test intégration sur comparison window
MBrandone Feb 17, 2017
ebc6e03
continuer sur box de comparaison pour QROC
MBrandone Feb 17, 2017
8bf8be5
implem QROC sans les tests
MBrandone Feb 20, 2017
6216a7b
make previous tests pass
MBrandone Feb 20, 2017
a797d6e
add unit test on component qroc-answer-comparison-box
MBrandone Feb 20, 2017
7f8ad88
add integration test on qroc-answer-comparison-box
MBrandone Feb 21, 2017
0a42aea
refacto jerem
MBrandone Feb 21, 2017
999dc20
refacto
MBrandone Feb 21, 2017
dfb2377
add acceptance tests
MBrandone Feb 21, 2017
c3ca82f
add acceptance tests1
MBrandone Feb 21, 2017
bd0b947
Merge branch 'dev' into 323-compare-answers-solutions-QROC-QROCm
MBrandone Feb 21, 2017
5ca838a
rename pour qroc-solution-panel and create qrocm solution panel
MBrandone Feb 21, 2017
7791deb
Fix tests
MBrandone Feb 22, 2017
6773a54
Merge branch 'dev' into 323-compare-answers-solutions-QROC-QROCm
MBrandone Feb 22, 2017
26f8d3b
back-up for qrocm-ind
MBrandone Feb 22, 2017
4cda34c
commit to change branch
MBrandone Feb 23, 2017
8141f56
rename component
MBrandone Feb 23, 2017
51a85c2
wip regex labels treatments
MBrandone Feb 23, 2017
fd0c048
create component qrocm-ind and first computed property
MBrandone Feb 23, 2017
92bf347
labelstodiplay done with test, reflexion on answers to dispay
MBrandone Feb 24, 2017
7ac9ff2
wip
MBrandone Feb 24, 2017
c9075f4
wip reflexion comment organiser les donner à envoyer hbs
MBrandone Feb 24, 2017
66dd96b
computed property to formate the data, done and tested
MBrandone Feb 27, 2017
b4db391
computed property done with bug
MBrandone Feb 28, 2017
91157b6
no bug anymore, wip on dataToDisplay
MBrandone Feb 28, 2017
2de0240
tentative avec proposalsAsBlock
MBrandone Mar 6, 2017
e8312e3
utilise le proposal block, reste à derterminer comment on connait la …
MBrandone Mar 6, 2017
44f4b9b
succeed parse des label avec ${} \o/
MBrandone Mar 7, 2017
a4696f1
basic front done mais retour du bug avec pas de grisement derrière la…
MBrandone Mar 7, 2017
2731782
tentative de resolution de bug
MBrandone Mar 8, 2017
3a6fcbb
add unit test to computed property and about to start the html/css
MBrandone Mar 8, 2017
b2147b2
refacto computed property to facilitate css of right/wrong/no Asnwer …
MBrandone Mar 8, 2017
b8c62b1
front done, il manque juste un alignement de la bonne reponse en dess…
MBrandone Mar 8, 2017
b9d812d
alignement reponse/solution done
MBrandone Mar 8, 2017
b908c40
display only one solution on front and start integration test skull
MBrandone Mar 8, 2017
ee5a90b
delete a log
MBrandone Mar 8, 2017
a45e008
integration tests done
MBrandone Mar 10, 2017
3c7887c
refacto real unit test
MBrandone Mar 10, 2017
5114f4e
finish unit test
MBrandone Mar 10, 2017
06c421d
Merge branch 'dev' into 385-compare-answers-solutions-qrocm-ind
MBrandone Mar 10, 2017
0fa0f86
fix regression sur qroc (affiche la reponse meme quand c'est bon)
MBrandone Mar 13, 2017
cfbe72b
add unit test
MBrandone Mar 13, 2017
76177b9
fix bug for qrocm passed answer and refacto computed property
MBrandone Mar 14, 2017
a530689
delete .only in test
MBrandone Mar 14, 2017
3679ce7
merge de dev
MBrandone Mar 14, 2017
467c2fe
fix make tests pass
MBrandone Mar 14, 2017
9087b70
delete comment
MBrandone Mar 15, 2017
da73ffd
computed properties of qrocm-ind passed to utils, need to be refacto
MBrandone Mar 17, 2017
d575d55
delete comment
MBrandone Mar 17, 2017
8fbb709
delete comment
MBrandone Mar 17, 2017
7864fc7
refacto
MBrandone Mar 17, 2017
f389810
Merge branch 'dev' into 385-compare-answers-solutions-qrocm-ind
MBrandone Mar 17, 2017
4d7fc92
end of the merge
MBrandone Mar 17, 2017
2d73406
Try to fix circle.yml for bower
MBrandone Mar 17, 2017
d32dca7
refacto 1
MBrandone Mar 17, 2017
5836978
adds from tech review
MBrandone Mar 20, 2017
ae3cd28
regler bug benjamin sur la review app et ajout de test
MBrandone Mar 20, 2017
0af95dd
delete .only
MBrandone Mar 20, 2017
44d83aa
click sur zone grisé fait sortir de la modale + test
MBrandone Mar 21, 2017
d3fc56a
Merge branch 'dev' into 385-compare-answers-solutions-qrocm-ind
MBrandone Mar 22, 2017
1ea846e
test to save resultDetails done
MBrandone Mar 22, 2017
b1c4b55
ajout de la propriété enabledTreatments dans le serializer airtable d…
MBrandone Mar 27, 2017
a031e02
refacto solution-service-qrocm-ind
MBrandone Mar 28, 2017
838acee
Fucking code
MBrandone Mar 28, 2017
a6ebc9b
Fucking code
MBrandone Mar 28, 2017
d25e2d6
aaaaaaaah resolved test :)
MBrandone Mar 28, 2017
c036cd5
Merge branch '385-compare-answers-solutions-qrocm-ind' of github.com:…
MBrandone Mar 29, 2017
15a711b
make tests pass after pull
MBrandone Mar 29, 2017
e1f4f57
Merge branch 'dev' into 385-compare-answers-solutions-qrocm-ind
MBrandone Mar 29, 2017
158a88b
refacto tests
MBrandone Mar 29, 2017
14fc4dd
Fix the fucking tests
MBrandone Mar 29, 2017
5c5919b
add save of resultDetails in dataBase
MBrandone Mar 30, 2017
a0e5228
resolve api answer serializer, implement fronts
MBrandone Mar 31, 2017
81d2fa2
debut refacto, le nouveau answersAsObjects ne fonctionne pas comme on…
MBrandone Mar 31, 2017
3cf4838
Fix the build
jbuget Apr 5, 2017
5765b0e
Oops
jbuget Apr 5, 2017
5e36208
Refactor solution-services-x
jbuget Apr 5, 2017
20582b6
Some refactoring
jbuget Apr 5, 2017
ed99da6
Continue to refactor
jbuget Apr 5, 2017
b3fd0db
Continue to refactor
jbuget Apr 5, 2017
4cb25aa
Continue to refactor
jbuget Apr 5, 2017
8ab9f23
Rename solution-service#match into #revalidate
jbuget Apr 5, 2017
42654c7
Merge branch 'dev' into 385-compare-answers-solutions-qrocm-ind
jbuget Apr 5, 2017
dd5e94c
Take into account code review remarks
jbuget Apr 6, 2017
8f45602
Merge branch 'dev' into 385-compare-answers-solutions-qrocm-ind
jbuget Apr 6, 2017
34b5e98
delete comment and rename en camelCase
MBrandone Apr 10, 2017
6afd649
refacto sur nom de variables test api
MBrandone Apr 10, 2017
2d2dbb5
continuing refacto
MBrandone Apr 10, 2017
3c6e74b
refacto with pierre and florian dans qrocm ind solution panel
MBrandone Apr 10, 2017
759b68d
gestion du cas où le challenge QROCM-ind est passé (null\n est enregi…
MBrandone Apr 11, 2017
30c3f28
fix when resultdetailsYaml is null
MBrandone Apr 11, 2017
1ab8cba
last change from jeremy review (!= to !==)
MBrandone Apr 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const TABLE_NAME = 'answers';

exports.up = function(knex, Promise) {
return Promise.all([
knex.schema.table(TABLE_NAME, function(table){
table.text('resultDetails');
})
]);
};

exports.down = function(knex, Promise) {
return Promise.all([
knex.schema.table(TABLE_NAME, function(table){
table.dropColumn('resultDetails');
})
]);
};
15 changes: 10 additions & 5 deletions api/lib/application/answers/answer-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ const answerSerializer = require('../../infrastructure/serializers/jsonapi/answe
const solutionRepository = require('../../infrastructure/repositories/solution-repository');
const answerRepository = require('../../infrastructure/repositories/answer-repository');
const solutionService = require('../../domain/services/solution-service');
const jsYaml = require('js-yaml');

function _updateExistingAnswer(existingAnswer, newAnswer, reply) {
solutionRepository
.get(existingAnswer.get('challengeId'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je pense qu'une méthode plus explicite en Newspaper dans le style : findSolutionByChallengeId.
Parce qu'on ne sait pas trop ce qu'il fait sans avoir lu la suite

.then((solution) => {
const answerCorrectness = solutionService.match(newAnswer, solution);
const answerCorrectness = solutionService.validate(newAnswer, solution);
new Answer({ id: existingAnswer.id })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je trouve que la méthode est longue, elle est dense.
Peut-être la sortir ?

.save({
result: answerCorrectness,
result: answerCorrectness.result,
resultDetails: jsYaml.safeDump(answerCorrectness.resultDetails),
value: newAnswer.get('value'),
timeout: newAnswer.get('timeout'),
challengeId: existingAnswer.get('challengeId'),
assessmentId: existingAnswer.get('assessmentId')
}, { method: 'update' })
.then((updatedAnswer) => reply(answerSerializer.serialize(updatedAnswer)).code(200))
.then((updatedAnswer) => {
return reply(answerSerializer.serialize(updatedAnswer)).code(200);
})
.catch((err) => reply(Boom.badImplementation(err)));
});
}
Expand All @@ -27,8 +31,9 @@ function _saveNewAnswer(newAnswer, reply) {
solutionRepository
.get(newAnswer.get('challengeId'))
.then((solution) => {
const answerCorrectness = solutionService.match(newAnswer, solution);
newAnswer.set('result', answerCorrectness);
const answerValidation = solutionService.validate(newAnswer, solution);
newAnswer.set('result', answerValidation.result);
newAnswer.set('resultDetails', jsYaml.safeDump(answerValidation.resultDetails));
newAnswer.set('timeout', newAnswer.get('timeout'));
newAnswer.set('elapsedTime', newAnswer.get('elapsedTime'));
newAnswer.save()
Expand Down
1 change: 0 additions & 1 deletion api/lib/domain/services/solution-service-qcm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const _ = require('../../infrastructure/utils/lodash-utils');


module.exports = {

match (answer, solution) {
Expand Down
44 changes: 19 additions & 25 deletions api/lib/domain/services/solution-service-qroc.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,47 @@
const utils = require('./solution-service-utils');
const deactivationsService = require('./deactivations-service');
const _ = require('../../infrastructure/utils/lodash-utils');
const { t1, t2, applyPreTreatments } = require('./validation-treatments');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t1, t2 what ???

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on n'a pas le choix c'est le vocabulaire métier, malheureusement. et pourtant je me suis battu contre...


function _applyPreTreatmentsToSolutions(solution) {
return _.chain(solution)
.split('\n')
.reject(_.isEmpty)
.value();
return _.chain(solution)
.split('\n')
.reject(_.isEmpty)
.value();
}

function _applyTreatmentsToSolutions(solution, deactivations) {
const pretreatedSolutions = _applyPreTreatmentsToSolutions(solution);
return _.map(pretreatedSolutions, (pretreatedSolution) => {
return _.map(pretreatedSolutions, (pretreatedSolution) => {

if (deactivationsService.isDefault(deactivations)) {
return utils._treatmentT2(utils._treatmentT1(pretreatedSolution));
return t2(t1(pretreatedSolution));
}
else if (deactivationsService.hasOnlyT1(deactivations)) {
return utils._treatmentT2(pretreatedSolution);
return t2(pretreatedSolution);
}
else if (deactivationsService.hasOnlyT2(deactivations)) {
return utils._treatmentT1(pretreatedSolution);
return t1(pretreatedSolution);
}
else if (deactivationsService.hasOnlyT3(deactivations)) {
return utils._treatmentT2(utils._treatmentT1(pretreatedSolution));
return t2(t1(pretreatedSolution));
}
else if (deactivationsService.hasOnlyT1T2(deactivations)) {
return pretreatedSolution;
}
else if (deactivationsService.hasOnlyT1T3(deactivations)) {
return utils._treatmentT2(pretreatedSolution);
return t2(pretreatedSolution);
}
else if (deactivationsService.hasOnlyT2T3(deactivations)) {
return utils._treatmentT1(pretreatedSolution);
return t1(pretreatedSolution);
}
else if (deactivationsService.hasT1T2T3(deactivations)) {
return pretreatedSolution;
}

});
}

// remove unbreakable space
function _applyAnswerTreatment(strArg) {
return strArg.replace(/\u00A0/g, ' ');
}


function _calculateResult(validations, deactivations) {
function _formatResult(validations, deactivations) {

if (deactivationsService.isDefault(deactivations)) {
if (validations.t1t2t3Ratio <= 0.25) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t1t2t3Ratio ??? une issue peut-être?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ça fait partie des bouts de code qu'on a préféré ne pas toucher car sinon c'était encore 2 semaines dans la vue.

Expand Down Expand Up @@ -97,24 +91,24 @@ function _calculateResult(validations, deactivations) {
}
return 'ko';
}

}


module.exports = {

match (answer, solution, deactivations) {

if (_.isNotString(answer) || _.isNotString(solution) || _.isEmpty(solution)) {
// Input checking
if (!_.isString(answer)
|| !_.isString(solution)
|| _.isEmpty(solution)) {
return 'ko';
}

const treatedAnswer = _applyAnswerTreatment(answer);
const treatedAnswer = applyPreTreatments(answer);
const treatedSolutions = _applyTreatmentsToSolutions(solution, deactivations);

const validations = utils.treatmentT1T2T3(treatedAnswer, treatedSolutions);

return _calculateResult(validations, deactivations);

return _formatResult(validations, deactivations);
}
};
37 changes: 14 additions & 23 deletions api/lib/domain/services/solution-service-qrocm-dep.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
/*eslint no-console: ["error", { allow: ["warn", "error"] }] */
const jsYaml = require('js-yaml');
const _ = require('../../infrastructure/utils/lodash-utils');
const utils = require('./solution-service-utils');
const deactivationsService = require('./deactivations-service');

const { t1, t2, applyPreTreatments } = require('./validation-treatments');

function _applyTreatmentsToSolutions(solutions, deactivations) {
return _.mapValues(solutions, (validSolutions) => {
return _.map(validSolutions, (validSolution) => {
const pretreatedSolution = validSolution.toString();

if (deactivationsService.isDefault(deactivations)) {
return utils._treatmentT2(utils._treatmentT1(pretreatedSolution));
return t2(t1(pretreatedSolution));
}
else if (deactivationsService.hasOnlyT1(deactivations)) {
return utils._treatmentT2(pretreatedSolution);
return t2(pretreatedSolution);
}
else if (deactivationsService.hasOnlyT2(deactivations)) {
return utils._treatmentT1(pretreatedSolution);
return t1(pretreatedSolution);
}
else if (deactivationsService.hasOnlyT3(deactivations)) {
return utils._treatmentT2(utils._treatmentT1(pretreatedSolution));
return t2(t1(pretreatedSolution));
}
else if (deactivationsService.hasOnlyT1T2(deactivations)) {
return pretreatedSolution;
}
else if (deactivationsService.hasOnlyT1T3(deactivations)) {
return utils._treatmentT2(pretreatedSolution);
return t2(pretreatedSolution);
}
else if (deactivationsService.hasT1T2T3(deactivations)) {
return pretreatedSolution;
Expand All @@ -35,13 +34,11 @@ function _applyTreatmentsToSolutions(solutions, deactivations) {
});
}


function _applyTreatmentsToAnswers(answers) {
return _.mapValues(answers, _.toString);
}


function _calculateValidation(answers, solutions) {
function _compareAnswersAndSolutions(answers, solutions) {

const validations = {};

Expand Down Expand Up @@ -104,7 +101,7 @@ function _goodAnswer(allValidations, deactivations) {
}
}

function _calculateResult(scoring, validations, deactivations) {
function _formatResult(scoring, validations, deactivations) {
let result = 'ok';

const numberOfGoodAnswers = _numberOfGoodAnswers(validations, deactivations);
Expand All @@ -129,39 +126,33 @@ function _calculateResult(scoring, validations, deactivations) {
return result;
}

function _applyPreTreatmentsToAnswer(yamlAnswer) {
return yamlAnswer.replace(/\u00A0/g, ' ');
}

module.exports = {

match(yamlAnswer, yamlSolution, yamlScoring, deactivations) {

// Validate inputs
if (_.isNotString(yamlAnswer)
|| _.isNotString(yamlSolution)
// Input checking
if (!_.isString(yamlAnswer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi avez-vous enlevé la vérification sur la solution ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

car c'est pris en compte dans la condition d'après (cdf. le code de la méthode dans Lodash, et le fait que si tu retires la ligne ça ne plante pas les tests)

|| _.isEmpty(yamlAnswer)
|| !_.includes(yamlSolution, '\n')) {
return 'ko';
}

// Pre-Treatments
const preTreatedAnswers = _applyPreTreatmentsToAnswer(yamlAnswer);
const preTreatedAnswers = applyPreTreatments(yamlAnswer);

// remove unbreakable spaces
// Convert Yaml to JS objects
const answers = jsYaml.safeLoad(preTreatedAnswers);
const solutions = jsYaml.safeLoad(yamlSolution);
const scoring = jsYaml.safeLoad(_.ensureString(yamlScoring));


// Treatments
const treatedSolutions = _applyTreatmentsToSolutions(solutions, deactivations);
const treatedAnswers = _applyTreatmentsToAnswers(answers);

// Comparisons
const fullValidations = _calculateValidation(treatedAnswers, treatedSolutions);
const fullValidations = _compareAnswersAndSolutions(treatedAnswers, treatedSolutions);

return _calculateResult(scoring, fullValidations, deactivations);
return _formatResult(scoring, fullValidations, deactivations);
}

};
Loading