frontend: display MCQ in interface

This commit is contained in:
nemunaire 2017-12-16 02:12:44 +01:00
parent 6903c91df2
commit d6012dfffb
3 changed files with 81 additions and 16 deletions

View file

@ -219,18 +219,49 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
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);
}, $scope.mcqs);
}
}
waitMy();
$scope.ssubmit = function() {
var flgs = {}
var resp = {}
angular.forEach($scope.flags, function(flag,kid) {
flgs[flag.name] = flag.value;
});
if ($scope.flags && $scope.flags.length)
{
resp["flags"] = {};
angular.forEach($scope.flags, function(flag,kid) {
resp["flags"][flag.name] = flag.value;
});
}
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: flgs }).then(function(response, status, header, config) {
if ($scope.mcqs && $scope.mcqs.length)
{
resp["mcqs"] = {};
angular.forEach($scope.mcqs, function(mcq) {
angular.forEach(mcq.choices, function(choice, cid) {
if (choice.value) resp["mcqs"][cid] = choice.value;
})
});
}
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: resp }).then(function(response, status, header, config) {
$rootScope.messageClass = {"text-success": true};
$rootScope.message = response.data.errmsg;
$rootScope.sberr = "";
@ -242,7 +273,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
var checkDiff = function() {
$http.get("/my.json").then(function(response) {
var my = response.data;
if ($scope.my.exercices[$rootScope.current_exercice].solved_time != my.exercices[$rootScope.current_exercice].solved_time) {
if ($scope.my.exercices[$rootScope.current_exercice].tries != my.exercices[$rootScope.current_exercice].tries || $scope.my.exercices[$rootScope.current_exercice].solved_time != my.exercices[$rootScope.current_exercice].solved_time) {
$rootScope.refresh();
$scope.my = my;
waitMy();