Utilise a new field to send justifications instead of too complex guessing crap

This commit is contained in:
nemunaire 2018-11-28 07:39:50 +01:00
parent 69a866bbbf
commit d40922629b
6 changed files with 69 additions and 24 deletions

View file

@ -268,11 +268,12 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
});
$scope.ssubmit = function() {
var resp = {"flags":{}}
var resp = {}
var check = undefined
if ($scope.my.exercices[$rootScope.current_exercice].flags && Object.keys($scope.my.exercices[$rootScope.current_exercice].flags).length)
{
resp["flags"] = {};
angular.forEach($scope.my.exercices[$rootScope.current_exercice].flags, function(flag,kid) {
if (flag.found == null) {
if (flag.soluce !== undefined) {
@ -293,7 +294,6 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
var soluce = "";
resp["mcqs"] = {};
angular.forEach($scope.my.exercices[$rootScope.current_exercice].mcqs, function(mcq) {
var nid = 0;
if (mcq.solved == null) {
angular.forEach(mcq.choices, function(choice, cid) {
if (mcq.soluce !== undefined) {
@ -304,10 +304,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
if (choice.value) {
resp["mcqs"][cid] = choice.value;
if (mcq.justify !== undefined) {
if (resp["justifications"] == undefined)
resp["justifications"] = {};
if (choice.justify)
resp["flags"][mcq.justify[nid++]] = choice.justify;
else if (!choice.solved)
nid++;
resp["justifications"][cid] = choice.justify;
}
}
}