frontend: save flag fields between 2 refresh and pages
This commit is contained in:
parent
63a55a8a0b
commit
87b41ab3cc
@ -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);
|
$rootScope.recvMy(response.data);
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
if (!$scope.my && response.status == 404) {
|
if (!$scope.my && response.status == 404) {
|
||||||
@ -298,23 +325,6 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||||||
var cbs;
|
var cbs;
|
||||||
var cbd;
|
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() {
|
$scope.ssubmit = function() {
|
||||||
var resp = {}
|
var resp = {}
|
||||||
var check = undefined
|
var check = undefined
|
||||||
|
Loading…
Reference in New Issue
Block a user