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;
}
}
}

View file

@ -94,7 +94,7 @@
<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" 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">
<input type="text" class="form-control" autocomplete="off" placeholder="Flag correspondant" name="sol_{{ cid }}" ng-model="choice.justify" ng-if="choice.value && mcq.justify && !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>