handle justified MCQ in interface and submission
This commit is contained in:
parent
01368dd6f4
commit
3dcb233c3f
4 changed files with 63 additions and 10 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -92,8 +92,10 @@
|
|||
<div class="form-check" ng-repeat="(k,mcq) in my.exercices[current_exercice].mcqs">
|
||||
<p ng-if="mcq.title">{{ mcq.title }} <span class="glyphicon glyphicon-ok form-control-feedback text-success" aria-hidden="true" ng-if="mcq.solved" title="QCM réussi à {{ mcq.solved | date:'mediumTime'}}"></span></p>
|
||||
<div class="custom-control custom-checkbox" ng-repeat="(cid,choice) in mcq.choices" ng-if="!mcq.solved">
|
||||
<input class="custom-control-input" type="checkbox" id="mcq_{{k}}_{{cid}}" name="mcq_{{k}}_{{cid}}" ng-model="choice.value">
|
||||
<input class="custom-control-input" type="checkbox" id="mcq_{{k}}_{{cid}}" name="mcq_{{k}}_{{cid}}" ng-model="choice.value" ng-disabled="choice.disabled">
|
||||
<label class="custom-control-label" for="mcq_{{k}}_{{cid}}" ng-bind="choice.label"></label>
|
||||
<input type="text" class="form-control" autocomplete="off" placeholder="Flag correspondant" name="sol_{{ cid }}" ng-model="choice.justify" ng-if="choice.value && mcq.justify.length && !choice.solved">
|
||||
<span class="glyphicon glyphicon-ok form-control-feedback text-success" aria-hidden="true" ng-if="choice.solved" title="Flag trouvé !"></span>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
|
|
|
|||
Reference in a new issue