frontend: public part now validate through blake2b.js flags and MCQs
This commit is contained in:
parent
8ac2776cca
commit
5c742834ea
5 changed files with 2675 additions and 37 deletions
|
@ -266,25 +266,61 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
|
||||
$scope.ssubmit = function() {
|
||||
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) {
|
||||
resp["flags"][kid] = flag.value;
|
||||
if (flag.found == null) {
|
||||
if (flag.soluce !== undefined) {
|
||||
if (check === undefined) check = true;
|
||||
|
||||
if (flag.value && flag.soluce == b2sum(flag.value))
|
||||
flag.found = new Date();
|
||||
check &= flag.found;
|
||||
} else {
|
||||
resp["flags"][kid] = flag.value;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($scope.my.exercices[$rootScope.current_exercice].mcqs && Object.keys($scope.my.exercices[$rootScope.current_exercice].mcqs).length)
|
||||
{
|
||||
var soluce = "";
|
||||
resp["mcqs"] = {};
|
||||
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;
|
||||
})
|
||||
if (mcq.solved == null) {
|
||||
angular.forEach(mcq.choices, function(choice, cid) {
|
||||
if (mcq.soluce !== undefined) {
|
||||
if (check === undefined) check = true;
|
||||
|
||||
soluce += choice.value ? "t" : "f";
|
||||
} else {
|
||||
if (choice.value) resp["mcqs"][cid] = choice.value;
|
||||
}
|
||||
});
|
||||
if (mcq.soluce !== undefined) {
|
||||
if (mcq.soluce == b2sum(soluce))
|
||||
mcq.solved = new Date();
|
||||
check &= mcq.solved;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (check !== undefined)
|
||||
{
|
||||
$scope.my.exercices[$rootScope.current_exercice].tries += 1;
|
||||
$scope.my.exercices[$rootScope.current_exercice].solved_time = new Date();
|
||||
|
||||
if (check) {
|
||||
$scope.my.exercices[$rootScope.current_exercice].solved = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$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;
|
||||
|
|
Reference in a new issue