handle justified MCQ in interface and submission

This commit is contained in:
nemunaire 2018-11-28 06:39:38 +01:00
commit 3dcb233c3f
4 changed files with 63 additions and 10 deletions

View file

@ -256,8 +256,12 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
angular.forEach(mcq["choices"], function(choice,cid) {
this[cid] = {
label: choice,
value: false
value: mcq["checks_solved"] !== undefined && mcq["checks_solved"][cid] !== undefined && mcq["checks_solved"][cid] > 0
};
if (mcq["checks_solved"] !== undefined) {
this[cid].disabled = true;
this[cid].solved = mcq["checks_solved"][cid] !== undefined && mcq["checks_solved"][cid] >= 2;
}
}, mcq["choices"]);
}, $scope.mcqs);
}
@ -265,12 +269,11 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
waitMy();
$scope.ssubmit = function() {
var resp = {}
var resp = {"flags":{}}
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) {
@ -291,6 +294,7 @@ 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) {
@ -298,7 +302,15 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
soluce += choice.value ? "t" : "f";
} else {
if (choice.value) resp["mcqs"][cid] = choice.value;
if (choice.value) {
resp["mcqs"][cid] = choice.value;
if (mcq.justify !== undefined) {
if (choice.justify)
resp["flags"][mcq.justify[nid++]] = choice.justify;
else if (!choice.solved)
nid++;
}
}
}
});
if (mcq.soluce !== undefined) {