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;
|
||||
})
|
||||
|
|
|
|||
Reference in a new issue