Export themes as array
This commit is contained in:
parent
492ab72dcd
commit
0ddd6c4899
3 changed files with 83 additions and 70 deletions
|
|
@ -41,6 +41,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
.run(function($rootScope, $interval) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.current_exercice_my = 0;
|
||||
$rootScope.time = {};
|
||||
|
||||
$('[data-toggle="popover"]').popover();
|
||||
|
|
@ -170,29 +171,30 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$rootScope.current_exercice = $scope.exercicesUrl[$routeParams.exercice];
|
||||
} else {
|
||||
if ($scope.themes && $scope.my && $scope.themes[$scope.current_theme]) {
|
||||
var exos = Object.keys($scope.themes[$scope.current_theme].exercices);
|
||||
var exos = $scope.themes[$scope.current_theme].exercices;
|
||||
var i = 0;
|
||||
for (; i < exos.length; i++) {
|
||||
if (!$scope.my.exercices || !$scope.my.exercices[exos[i]] || !$scope.my.exercices[exos[i]].solved)
|
||||
if (!$scope.my.exercices || !$scope.my.exercices[exos[i].id] || !$scope.my.exercices[exos[i].id].solved)
|
||||
break;
|
||||
}
|
||||
if (i < exos.length) {
|
||||
$rootScope.current_exercice = exos[i];
|
||||
$rootScope.current_exercice = i;
|
||||
} else {
|
||||
$rootScope.current_exercice = exos[0];
|
||||
$rootScope.current_exercice = 0;
|
||||
}
|
||||
} else {
|
||||
$rootScope.current_exercice = 0;
|
||||
}
|
||||
}
|
||||
$rootScope.current_exercice_my = $scope.themes[$scope.current_theme].exercices[$rootScope.current_exercice].id;
|
||||
|
||||
$scope.hsubmit = function(hint) {
|
||||
hint.submitted = true;
|
||||
$http({ url: "/openhint/" + $rootScope.current_exercice, method: "POST", data: { id: hint.id } }).then(function(response, status, header, config) {
|
||||
$http({ url: "/openhint/" + $rootScope.current_exercice_my, method: "POST", data: { id: hint.id } }).then(function(response, status, header, config) {
|
||||
var checkDiffHint = function() {
|
||||
$http.get("/my.json").then(function(response) {
|
||||
var my = response.data;
|
||||
angular.forEach(my.exercices[$rootScope.current_exercice].hints, function(h,hid){
|
||||
angular.forEach(my.exercices[$rootScope.current_exercice_my].hints, function(h,hid){
|
||||
if (hint.id == h.id) {
|
||||
if (hint.content != h.content) {
|
||||
$rootScope.refresh();
|
||||
|
|
@ -216,24 +218,24 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$rootScope.sberr = "";
|
||||
|
||||
var waitMy = function() {
|
||||
if (!$scope.my || !$scope.my.exercices || !$scope.my.exercices[$rootScope.current_exercice]) {
|
||||
if (!$scope.my || !$scope.my.exercices || !$scope.my.exercices[$rootScope.current_exercice_my]) {
|
||||
$timeout.cancel($scope.cbs);
|
||||
$scope.cbs = $timeout(waitMy, 420);
|
||||
} else {
|
||||
$scope.flags = [];
|
||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice].keys, function(key,kid) {
|
||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice_my].keys, function(key,kid) {
|
||||
var o = {
|
||||
id: kid,
|
||||
name: key,
|
||||
value: ""
|
||||
};
|
||||
if ($scope.my.exercices[$rootScope.current_exercice].solved_matrix != null)
|
||||
o.found = $scope.my.exercices[$rootScope.current_exercice].solved_matrix[kid];
|
||||
if ($scope.my.exercices[$rootScope.current_exercice_my].solved_matrix != null)
|
||||
o.found = $scope.my.exercices[$rootScope.current_exercice_my].solved_matrix[kid];
|
||||
this.push(o);
|
||||
}, $scope.flags);
|
||||
|
||||
$scope.mcqs = [];
|
||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice].mcqs, function(mcq,qid) {
|
||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice_my].mcqs, function(mcq,qid) {
|
||||
var o = {
|
||||
title: mcq.title,
|
||||
kind: mcq.kind,
|
||||
|
|
@ -273,7 +275,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
}
|
||||
|
||||
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: resp }).then(function(response, status, header, config) {
|
||||
$http({ url: "/submit/" + $rootScope.current_exercice_my, method: "POST", data: resp }).then(function(response, status, header, config) {
|
||||
$rootScope.messageClass = {"text-success": true};
|
||||
$rootScope.message = response.data.errmsg;
|
||||
$rootScope.sberr = "";
|
||||
|
|
@ -285,7 +287,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].tries != my.exercices[$rootScope.current_exercice].tries || $scope.my.exercices[$rootScope.current_exercice].solved_time != my.exercices[$rootScope.current_exercice].solved_time) {
|
||||
if ($scope.my.exercices[$rootScope.current_exercice_my].tries != my.exercices[$rootScope.current_exercice_my].tries || $scope.my.exercices[$rootScope.current_exercice_my].solved_time != my.exercices[$rootScope.current_exercice_my].solved_time) {
|
||||
$rootScope.refresh();
|
||||
$scope.my = my;
|
||||
waitMy();
|
||||
|
|
@ -298,7 +300,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
checkDiff();
|
||||
}, function(response, status, header, config) {
|
||||
if (status >= 500) {
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = false;
|
||||
$scope.my.exercices[$rootScope.current_exercice_my].submitted = false;
|
||||
}
|
||||
$rootScope.messageClass = {"text-danger": true};
|
||||
$rootScope.message = response.data.errmsg;
|
||||
|
|
@ -306,12 +308,13 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$rootScope.sberr = "Une erreur est survenue lors de l'envoi. Veuillez réessayer dans quelques instants.";
|
||||
}
|
||||
});
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = true;
|
||||
$scope.my.exercices[$rootScope.current_exercice_my].submitted = true;
|
||||
};
|
||||
})
|
||||
.controller("MyTeamController", function($scope, $http, $rootScope, $timeout) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.current_exercice_my = 0;
|
||||
if ($scope.my) {
|
||||
$rootScope.title = $scope.my.name;
|
||||
$rootScope.authors = $scope.my.members.map(function (cur) {
|
||||
|
|
@ -373,6 +376,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
.controller("RegisterController", function($scope, $rootScope, $location, $http) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.current_exercice_my = 0;
|
||||
$rootScope.title = "Bienvenue au challenge forensic !";
|
||||
$rootScope.authors = null;
|
||||
|
||||
|
|
@ -443,6 +447,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
.controller("RankController", function($scope, $rootScope) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.current_exercice_my = 0;
|
||||
$rootScope.title = "Classement général";
|
||||
$rootScope.authors = "";
|
||||
|
||||
|
|
@ -461,12 +466,14 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
.controller("VideosController", function($scope, $rootScope) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.current_exercice_my = 0;
|
||||
$rootScope.title = "Vidéos de résolution";
|
||||
$rootScope.authors = "";
|
||||
})
|
||||
.controller("HomeController", function($scope, $rootScope) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.current_exercice_my = 0;
|
||||
$rootScope.title = "";
|
||||
$rootScope.authors = "";
|
||||
});
|
||||
|
|
|
|||
Reference in a new issue