diff --git a/frontend/static/js/challenge.js b/frontend/static/js/challenge.js index 788945c1..084af961 100644 --- a/frontend/static/js/challenge.js +++ b/frontend/static/js/challenge.js @@ -216,6 +216,33 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"]) }); }); } + angular.forEach(response.data.exercices, function(exercice, eid) { + angular.forEach(exercice.flags, function(flag, fid) { + if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].flags[fid] && $scope.my.exercices[eid].flags[fid].value !== undefined) + response.data.exercices[eid].flags[fid].value = $scope.my.exercices[eid].flags[fid].value; + }); + }); + angular.forEach(response.data.exercices, function(exercice, eid) { + angular.forEach(exercice.mcqs, function(mcq, mid) { + angular.forEach(mcq.choices, function(choice, cid) { + this[cid] = { + label: choice, + value: mcq["checks_solved"] !== undefined && mcq["checks_solved"][cid] !== undefined && mcq["checks_solved"][cid] > 0 + }; + if (mcq["checks_solved"] !== undefined) { + this[cid].disabled = mcq["checks_solved"][cid] === undefined || mcq["checks_solved"][cid] >= 0; + this[cid].solved = mcq["checks_solved"][cid] !== undefined && mcq["checks_solved"][cid] >= 2; + } + + if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].mcqs[mid] && $scope.my.exercices[eid].mcqs[mid].choices[cid]) { + if ($scope.my.exercices[eid].mcqs[mid].choices[cid].value !== undefined) + this[cid].value = $scope.my.exercices[eid].mcqs[mid].choices[cid].value; + if ($scope.my.exercices[eid].mcqs[mid].choices[cid].justify !== undefined) + this[cid].justify = $scope.my.exercices[eid].mcqs[mid].choices[cid].justify; + } + }, mcq.choices); + }); + }); $rootScope.recvMy(response.data); }, function(response) { if (!$scope.my && response.status == 404) { @@ -298,23 +325,6 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"]) var cbs; var cbd; - $scope.$watch("my", function(my) { - if (my && my.exercices && my.exercices[$rootScope.current_exercice]) { - angular.forEach(my.exercices[$rootScope.current_exercice].mcqs, function(mcq,qid) { - angular.forEach(mcq["choices"], function(choice,cid) { - this[cid] = { - label: choice, - value: mcq["checks_solved"] !== undefined && mcq["checks_solved"][cid] !== undefined && mcq["checks_solved"][cid] > 0 - }; - if (mcq["checks_solved"] !== undefined) { - this[cid].disabled = mcq["checks_solved"][cid] === undefined || mcq["checks_solved"][cid] >= 0; - this[cid].solved = mcq["checks_solved"][cid] !== undefined && mcq["checks_solved"][cid] >= 2; - } - }, mcq["choices"]); - }, $scope.mcqs); - } - }); - $scope.ssubmit = function() { var resp = {} var check = undefined