Change exported flags format in my.json
This commit is contained in:
parent
d6ae1551ba
commit
195490484c
5 changed files with 44 additions and 55 deletions
|
|
@ -245,7 +245,6 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
};
|
||||
})
|
||||
.controller("SubmissionController", function($scope, $http, $rootScope, $timeout) {
|
||||
$scope.flags = [];
|
||||
$rootScope.sberr = "";
|
||||
|
||||
var waitMy = function() {
|
||||
|
|
@ -253,34 +252,13 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$timeout.cancel($scope.cbs);
|
||||
$scope.cbs = $timeout(waitMy, 420);
|
||||
} else {
|
||||
$scope.flags = [];
|
||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice].keys, function(key,kid) {
|
||||
var o = {
|
||||
id: kid,
|
||||
name: key,
|
||||
help: "#help goes here#not yet implemented#",
|
||||
value: ""
|
||||
};
|
||||
if ($scope.my.exercices[$rootScope.current_exercice].solved_matrix != null)
|
||||
o.found = $scope.my.exercices[$rootScope.current_exercice].solved_matrix[kid];
|
||||
this.push(o);
|
||||
}, $scope.flags);
|
||||
|
||||
$scope.mcqs = [];
|
||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice].mcqs, function(mcq,qid) {
|
||||
var o = {
|
||||
title: mcq.title,
|
||||
kind: mcq.kind,
|
||||
solved: mcq.solved,
|
||||
choices: {}
|
||||
};
|
||||
angular.forEach(mcq["choices"], function(choice,cid) {
|
||||
this[cid] = {
|
||||
label: choice,
|
||||
value: false
|
||||
};
|
||||
}, o["choices"]);
|
||||
this.push(o);
|
||||
}, mcq["choices"]);
|
||||
}, $scope.mcqs);
|
||||
}
|
||||
}
|
||||
|
|
@ -289,18 +267,18 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$scope.ssubmit = function() {
|
||||
var resp = {}
|
||||
|
||||
if ($scope.flags && $scope.flags.length)
|
||||
if ($scope.my.exercices[$rootScope.current_exercice].flags && Object.keys($scope.my.exercices[$rootScope.current_exercice].flags).length)
|
||||
{
|
||||
resp["flags"] = {};
|
||||
angular.forEach($scope.flags, function(flag,kid) {
|
||||
resp["flags"][flag.name] = flag.value;
|
||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice].flags, function(flag,kid) {
|
||||
resp["flags"][kid] = flag.value;
|
||||
});
|
||||
}
|
||||
|
||||
if ($scope.mcqs && $scope.mcqs.length)
|
||||
if ($scope.my.exercices[$rootScope.current_exercice].mcqs && Object.keys($scope.my.exercices[$rootScope.current_exercice].mcqs).length)
|
||||
{
|
||||
resp["mcqs"] = {};
|
||||
angular.forEach($scope.mcqs, function(mcq) {
|
||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice].mcqs, function(mcq) {
|
||||
angular.forEach(mcq.choices, function(choice, cid) {
|
||||
if (choice.value) resp["mcqs"][cid] = choice.value;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<a ng-href="/{{ themes[current_theme].urlid }}/{{ themes[current_theme].exercices[k].urlid }}" ng-if="(k != current_exercice && my.exercices[k])">
|
||||
{{ exercice.title }}
|
||||
<span class="glyphicon glyphicon-gift" aria-hidden="true" ng-if="themes[current_theme].exercices[k].curcoeff > 1.0"></span>
|
||||
<span class="glyphicon glyphicon-ok" aria-hidden="true" ng-if="(my.team_id && my.exercices[k].solved)"></span>
|
||||
<span class="glyphicon glyphicon-ok text-success" aria-hidden="true" ng-if="(my.team_id && my.exercices[k].solved)"></span>
|
||||
</a>
|
||||
<strong ng-if="k == current_exercice" class="text-info">{{ exercice.title }}</strong>
|
||||
</li>
|
||||
|
|
@ -77,16 +77,16 @@
|
|||
</ul>
|
||||
<div class="card-body" ng-if="!my.exercices[current_exercice].submitted || sberr">
|
||||
<form ng-controller="SubmissionController" ng-submit="ssubmit()">
|
||||
<div class="form-group" ng-repeat="key in flags">
|
||||
<label for="sol_{{ key.id }}">{{ key.name }} :</label>
|
||||
<input type="text" class="form-control" id="sol_{{ key.id }}" autocomplete="off" name="sol_{{ key.id }}" ng-model="key.value" ng-if="!key.found">
|
||||
<div class="form-group" ng-repeat="(kid,key) in my.exercices[current_exercice].flags">
|
||||
<label for="sol_{{ kid }}">{{ key.label }} :</label>
|
||||
<input type="text" class="form-control" id="sol_{{ kid }}" autocomplete="off" name="sol_{{ kid }}" ng-model="key.value" ng-if="!key.found">
|
||||
<small class="form-text text-muted" ng-if="key.help.length > 0" ng-bind="key.help"></small>
|
||||
<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true" ng-if="key.found"></span>
|
||||
<span class="glyphicon glyphicon-ok form-control-feedback text-success" aria-hidden="true" ng-if="key.found" title="Flag trouvé à {{ key.found | date:'mediumTime'}}"></span>
|
||||
</div>
|
||||
|
||||
<div class="form-check" ng-repeat="(k,mcq) in mcqs">
|
||||
<p ng-if="mcq.title" ng-bind="mcq.title"></p>
|
||||
<div class="custom-control custom-checkbox" ng-repeat="(cid,choice) in mcq.choices">
|
||||
<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">
|
||||
<label class="custom-control-label" for="mcq_{{k}}_{{cid}}" ng-bind="choice.label"></label>
|
||||
</div>
|
||||
|
|
|
|||
Reference in a new issue