2016-01-23 11:29:19 +00:00
|
|
|
angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
2016-01-16 21:40:59 +00:00
|
|
|
.config(function($routeProvider, $locationProvider) {
|
|
|
|
$routeProvider
|
2016-12-04 18:07:52 +00:00
|
|
|
.when("/rules", {
|
|
|
|
controller: "HomeController",
|
|
|
|
templateUrl: "views/rules.html"
|
|
|
|
})
|
2016-01-16 21:40:59 +00:00
|
|
|
.when("/edit", {
|
|
|
|
controller: "MyTeamController",
|
|
|
|
templateUrl: "views/team-edit.html"
|
|
|
|
})
|
2020-01-24 19:04:46 +00:00
|
|
|
.when("/issue/:eid", {
|
2020-01-20 14:56:02 +00:00
|
|
|
controller: "IssueController",
|
|
|
|
templateUrl: "views/issue.html"
|
|
|
|
})
|
2020-01-24 19:04:46 +00:00
|
|
|
.when("/issues", {
|
|
|
|
controller: "IssueController",
|
|
|
|
templateUrl: "views/issue.html"
|
|
|
|
})
|
|
|
|
.when("/issues/:iid", {
|
2020-01-20 14:56:02 +00:00
|
|
|
controller: "IssueController",
|
|
|
|
templateUrl: "views/issue.html"
|
|
|
|
})
|
2016-01-16 21:40:59 +00:00
|
|
|
.when("/rank", {
|
2016-01-21 04:00:15 +00:00
|
|
|
controller: "RankController",
|
|
|
|
templateUrl: "views/rank.html"
|
2016-01-16 21:40:59 +00:00
|
|
|
})
|
2017-12-21 21:18:18 +00:00
|
|
|
.when("/register", {
|
|
|
|
controller: "RegisterController",
|
|
|
|
templateUrl: "views/register.html"
|
|
|
|
})
|
2017-04-02 18:29:15 +00:00
|
|
|
.when("/videos", {
|
|
|
|
controller: "VideosController",
|
|
|
|
templateUrl: "views/videos.html"
|
|
|
|
})
|
2018-11-21 02:10:35 +00:00
|
|
|
.when("/tags/:tag", {
|
|
|
|
controller: "TagController",
|
|
|
|
templateUrl: "views/tag.html"
|
|
|
|
})
|
2016-01-16 21:40:59 +00:00
|
|
|
.when("/:theme", {
|
2016-01-21 00:38:43 +00:00
|
|
|
controller: "ExerciceController",
|
2016-01-16 21:40:59 +00:00
|
|
|
templateUrl: "views/theme.html"
|
|
|
|
})
|
|
|
|
.when("/:theme/:exercice", {
|
|
|
|
controller: "ExerciceController",
|
2020-01-16 16:15:34 +00:00
|
|
|
templateUrl: function(e) {
|
|
|
|
if (e.theme == "BlueMoney" && e.exercice == "JackSpearrow")
|
|
|
|
return "views/defi-SE.html"
|
|
|
|
else
|
|
|
|
return "views/defi.html";
|
|
|
|
}
|
2016-01-16 21:40:59 +00:00
|
|
|
})
|
2016-01-21 00:38:43 +00:00
|
|
|
.when("/", {
|
2016-01-16 21:40:59 +00:00
|
|
|
controller: "HomeController",
|
|
|
|
templateUrl: "views/home.html"
|
2016-01-21 00:38:43 +00:00
|
|
|
})
|
|
|
|
.otherwise({
|
|
|
|
redirectTo: "/"
|
2016-01-16 21:40:59 +00:00
|
|
|
});
|
|
|
|
$locationProvider.html5Mode(true);
|
|
|
|
})
|
2018-12-01 15:14:34 +00:00
|
|
|
.run(function($rootScope) {
|
2016-01-21 00:38:43 +00:00
|
|
|
$rootScope.current_theme = 0;
|
|
|
|
$rootScope.current_exercice = 0;
|
2018-11-25 04:48:44 +00:00
|
|
|
$rootScope.current_tag = undefined;
|
2018-12-01 17:15:03 +00:00
|
|
|
$rootScope.notify_field = 0;
|
2020-01-23 15:03:31 +00:00
|
|
|
$rootScope.issues_known_responses = 0;
|
2018-12-01 17:15:03 +00:00
|
|
|
|
2019-01-19 07:04:54 +00:00
|
|
|
if ('Notification' in window)
|
|
|
|
Notification.requestPermission(function(result) {
|
|
|
|
if (result == "granted") {
|
|
|
|
if (localStorage && localStorage.notification)
|
|
|
|
$rootScope.notify_field = localStorage.notification;
|
|
|
|
else
|
|
|
|
$rootScope.notify_field = 63;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
$rootScope.notify_field = 0;
|
|
|
|
});
|
2018-12-01 15:14:34 +00:00
|
|
|
})
|
|
|
|
.controller("DataController", function($sce, $scope, $http, $rootScope, $interval, $location) {
|
2016-01-21 00:38:43 +00:00
|
|
|
var actMenu = function() {
|
|
|
|
if ($scope.my && $scope.themes) {
|
2018-11-25 04:01:26 +00:00
|
|
|
var tags = {};
|
2016-01-21 00:38:43 +00:00
|
|
|
angular.forEach($scope.themes, function(theme, key) {
|
|
|
|
$scope.themes[key].exercice_solved = 0;
|
2018-11-27 18:59:47 +00:00
|
|
|
var last_exercice = null;
|
2016-01-21 00:38:43 +00:00
|
|
|
angular.forEach(theme.exercices, function(exercice, k) {
|
2018-11-27 18:59:47 +00:00
|
|
|
if (last_exercice != null)
|
|
|
|
last_exercice.next = k;
|
|
|
|
last_exercice = exercice;
|
|
|
|
|
2017-12-14 02:20:38 +00:00
|
|
|
if ($scope.my.exercices && $scope.my.exercices[k] && $scope.my.exercices[k].solved) {
|
2016-01-21 00:38:43 +00:00
|
|
|
$scope.themes[key].exercice_solved++;
|
|
|
|
}
|
2018-11-25 04:01:26 +00:00
|
|
|
angular.forEach(exercice.tags, function(tag) {
|
|
|
|
if (!tags[tag])
|
|
|
|
tags[tag] = {count: 1, solved: 0};
|
|
|
|
else
|
|
|
|
tags[tag].count += 1;
|
|
|
|
if ($scope.my.exercices && $scope.my.exercices[k] && $scope.my.exercices[k].solved)
|
|
|
|
tags[tag].solved += 1;
|
|
|
|
});
|
2016-01-21 00:38:43 +00:00
|
|
|
});
|
|
|
|
});
|
2018-11-25 04:01:26 +00:00
|
|
|
$scope.tags = tags;
|
2018-12-04 19:11:21 +00:00
|
|
|
$scope.tagsl = Object.keys(tags).sort();
|
2016-01-21 00:38:43 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-01 15:14:34 +00:00
|
|
|
|
|
|
|
var refreshSettingsInterval
|
|
|
|
var refreshSettings = function() {
|
|
|
|
if (refreshSettingsInterval)
|
|
|
|
$interval.cancel(refreshSettingsInterval);
|
|
|
|
refreshSettingsInterval = $interval(refreshSettings, Math.floor(Math.random() * 24000) + 32000);
|
|
|
|
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("settings.json").then(function(response) {
|
2019-01-17 12:03:15 +00:00
|
|
|
var time = $rootScope.recvTime(response);
|
2019-02-18 17:00:54 +00:00
|
|
|
if (response.data.start)
|
|
|
|
response.data.start = new Date(response.data.start);
|
|
|
|
if (response.data.end)
|
|
|
|
response.data.end = new Date(response.data.end);
|
|
|
|
if (response.data.generation)
|
|
|
|
response.data.generation = new Date(response.data.generation);
|
|
|
|
if (response.data.activateTime)
|
|
|
|
response.data.activateTime = new Date(response.data.activateTime);
|
|
|
|
if ($rootScope.settings === undefined || response.data.activateTime === undefined || response.data.activateTime <= new Date(Date.now() + (time.cu - time.he))) {
|
2019-01-17 12:03:15 +00:00
|
|
|
$rootScope.settings = response.data;
|
2019-01-19 07:04:10 +00:00
|
|
|
if (response.data.eventKindness && refreshEventsInterval) {
|
|
|
|
$interval.cancel(refreshEventsInterval);
|
|
|
|
refreshEventsInterval = null;
|
|
|
|
}
|
|
|
|
else if (!response.data.eventKindness && !refreshEventsInterval) {
|
|
|
|
refreshEvents();
|
|
|
|
}
|
|
|
|
}
|
2019-01-17 12:03:15 +00:00
|
|
|
else
|
|
|
|
$rootScope.settings.activateTime = response.data.activateTime;
|
2018-12-01 15:14:34 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-23 15:03:31 +00:00
|
|
|
var refreshIssuesInterval
|
|
|
|
var refreshIssues = function() {
|
|
|
|
if (refreshIssuesInterval)
|
|
|
|
$interval.cancel(refreshIssuesInterval);
|
|
|
|
refreshIssuesInterval = $interval(refreshIssues, Math.floor(Math.random() * 24000) + 32000);
|
|
|
|
|
|
|
|
$http.get("issues.json").then(function(response) {
|
2020-01-24 19:04:46 +00:00
|
|
|
$rootScope.issues_idx = {};
|
2020-01-23 15:03:31 +00:00
|
|
|
$rootScope.issues_nb_responses = 0;
|
|
|
|
$rootScope.issues_need_info = 0;
|
|
|
|
$rootScope.issues = response.data;
|
|
|
|
$rootScope.issues.forEach(function(issue) {
|
2020-01-24 19:04:46 +00:00
|
|
|
$rootScope.issues_idx[issue.id] = issue;
|
2020-01-23 15:03:31 +00:00
|
|
|
$rootScope.issues_nb_responses += issue.texts.length;
|
|
|
|
if (issue.state == 'need-info') $rootScope.issues_need_info++;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-01 15:14:34 +00:00
|
|
|
var refreshThemesInterval
|
|
|
|
var refreshThemes = function() {
|
|
|
|
if (refreshThemesInterval)
|
|
|
|
$interval.cancel(refreshThemesInterval);
|
|
|
|
refreshThemesInterval = $interval(refreshThemes, Math.floor(Math.random() * 24000) + 32000);
|
|
|
|
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("themes.json").then(function(response) {
|
2018-12-01 15:14:34 +00:00
|
|
|
$scope.themes = response.data;
|
|
|
|
$scope.max_gain = 0;
|
|
|
|
$scope.max_solved = 0;
|
|
|
|
$scope.themesUrl = {};
|
|
|
|
$scope.exercicesUrl = {};
|
|
|
|
angular.forEach(response.data, function(theme, key) {
|
|
|
|
$scope.themesUrl[theme.urlid] = key;
|
|
|
|
this[key].exercice_count = Object.keys(theme.exercices).length;
|
|
|
|
this[key].exercice_coeff_max = 0;
|
|
|
|
this[key].gain = 0;
|
|
|
|
this[key].solved = 0;
|
|
|
|
angular.forEach(theme.exercices, function(ex, k) {
|
2018-12-05 14:22:35 +00:00
|
|
|
$scope.exercicesUrl[theme.urlid + "/" + ex.urlid] = k;
|
2018-12-01 15:14:34 +00:00
|
|
|
this.gain += ex.gain;
|
|
|
|
this.solved += ex.solved;
|
|
|
|
this.exercice_coeff_max = Math.max(this.exercice_coeff_max, ex.curcoeff);
|
|
|
|
}, theme);
|
|
|
|
$scope.max_gain += theme.gain;
|
|
|
|
$scope.max_solved = Math.max($scope.max_solved, theme.solved);
|
|
|
|
}, response.data);
|
2016-01-21 00:38:43 +00:00
|
|
|
actMenu();
|
2018-12-01 15:14:34 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var refreshTeamsInterval;
|
|
|
|
$rootScope.refreshTeams = function() {
|
|
|
|
if (refreshTeamsInterval)
|
|
|
|
$interval.cancel(refreshTeamsInterval);
|
|
|
|
refreshTeamsInterval = $interval($rootScope.refreshTeams, Math.floor(Math.random() * 24000) + 32000);
|
|
|
|
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("teams.json").then(function(response) {
|
2018-12-01 15:14:34 +00:00
|
|
|
var teams = response.data;
|
|
|
|
$scope.teams_count = Object.keys(teams).length
|
|
|
|
$scope.teams = teams;
|
|
|
|
|
|
|
|
$scope.rank = [];
|
|
|
|
angular.forEach($scope.teams, function(team, tid) {
|
|
|
|
team.id = tid;
|
|
|
|
this.push(team);
|
|
|
|
}, $scope.rank);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-01 17:15:03 +00:00
|
|
|
var refreshEventsInterval;
|
|
|
|
var eventsLastRefresh;
|
|
|
|
var eventsLastTreated;
|
|
|
|
var refreshEvents = function() {
|
|
|
|
if (refreshEventsInterval)
|
|
|
|
$interval.cancel(refreshEventsInterval);
|
|
|
|
var refreshRate = 1200;
|
|
|
|
if ($rootScope.notify_field == 0 && eventsLastTreated)
|
|
|
|
refreshRate = 30000;
|
2019-01-25 07:29:39 +00:00
|
|
|
if ($scope.my && !$scope.my.team_id)
|
|
|
|
return;
|
2018-12-01 17:15:03 +00:00
|
|
|
refreshEventsInterval = $interval(refreshEvents, Math.floor(Math.random() * refreshRate * 2) + refreshRate);
|
|
|
|
|
|
|
|
if (!eventsLastTreated) {
|
|
|
|
eventsLastTreated = $rootScope.getSrvTime();
|
|
|
|
if (!eventsLastTreated)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("events.json").then(function(response) {
|
2018-12-01 17:15:03 +00:00
|
|
|
if (eventsLastRefresh != undefined && eventsLastRefresh == response.headers()["last-modified"])
|
|
|
|
return;
|
|
|
|
eventsLastRefresh = response.headers()["last-modified"];
|
|
|
|
|
|
|
|
var maxTimeSeen = eventsLastTreated;
|
|
|
|
for (var i = response.data.length - 1; i >= 0; i--) {
|
|
|
|
var event = response.data[i];
|
|
|
|
|
|
|
|
event.time = new Date(event.time);
|
|
|
|
if (event.time <= eventsLastTreated)
|
|
|
|
continue;
|
|
|
|
else if (event.time > maxTimeSeen)
|
|
|
|
maxTimeSeen = event.time;
|
|
|
|
|
2019-01-19 07:04:54 +00:00
|
|
|
// Determine the kind of event
|
|
|
|
var kind = 1;
|
|
|
|
|
|
|
|
if (event.txt.match(/<\/strong> qui vient de nous rejoindre/)) {
|
|
|
|
kind = 64;
|
|
|
|
} else {
|
|
|
|
var res = event.txt.match(/(\w+) le <strong>\d+<sup>e<\/sup><\/strong> défi [^&]+/)
|
|
|
|
if (res) {
|
|
|
|
if (res[1] == "résolu")
|
|
|
|
kind = 8;
|
|
|
|
else if (res[1] == "pour")
|
|
|
|
kind = 16;
|
|
|
|
else if (res[1] == "tente")
|
|
|
|
kind = 32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (kind != 1) {
|
|
|
|
if ($scope.my && $scope.my.name && event.txt.indexOf($scope.my.name) >= 0)
|
|
|
|
kind |= 2;
|
|
|
|
else
|
|
|
|
kind |= 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((kind & $rootScope.notify_field) == kind) {
|
2019-01-17 18:50:16 +00:00
|
|
|
var notification = new Notification("Challenge forensic", {body: event.txt.replace(/&#(\d+);/g, function(match, dec) {return String.fromCharCode(dec);}).replace(/(<([^>]+)>)/ig,""), badge: "/img/icon-" + event.kind + ".ico", icon: "/img/icon-" + event.kind + ".ico"});
|
2018-12-01 17:15:03 +00:00
|
|
|
notification.onclick = function(ev) {
|
2019-02-04 16:38:12 +00:00
|
|
|
$location.url("edit");
|
2018-12-01 17:15:03 +00:00
|
|
|
};
|
|
|
|
setTimeout(notification.close.bind(notification), 4000);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (maxTimeSeen > eventsLastTreated)
|
|
|
|
eventsLastTreated = maxTimeSeen;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-01 15:14:34 +00:00
|
|
|
var refreshMyInterval;
|
|
|
|
var refreshMy = function() {
|
|
|
|
if (refreshMyInterval)
|
|
|
|
$interval.cancel(refreshMyInterval);
|
|
|
|
refreshMyInterval = $interval(refreshMy, Math.floor(Math.random() * 24000) + 24000);
|
|
|
|
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("my.json").then(function(response) {
|
2018-12-02 00:24:38 +00:00
|
|
|
$rootScope.recvMy(response.data);
|
|
|
|
}, function(response) {
|
|
|
|
if (!$scope.my && response.status == 404) {
|
2019-02-04 16:38:12 +00:00
|
|
|
$location.url("register");
|
2018-12-02 00:24:38 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
$rootScope.recvMy = function(data) {
|
|
|
|
if (data.team_id == 0) {
|
|
|
|
angular.forEach(data.exercices, function(exercice, eid) {
|
2017-11-12 21:14:03 +00:00
|
|
|
angular.forEach(exercice.hints, function(hint, hid) {
|
2018-12-01 15:14:34 +00:00
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].hints[hid] && $scope.my.exercices[eid].hints[hid].hidden !== undefined)
|
2018-12-02 00:24:38 +00:00
|
|
|
data.exercices[eid].hints[hid].hidden = $scope.my.exercices[eid].hints[hid].hidden;
|
2018-12-01 15:14:34 +00:00
|
|
|
else
|
2018-12-02 00:24:38 +00:00
|
|
|
data.exercices[eid].hints[hid].hidden = true;
|
2017-11-12 21:14:03 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2018-12-02 00:24:38 +00:00
|
|
|
angular.forEach(data.exercices, function(exercice, eid) {
|
2019-01-18 03:41:17 +00:00
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].submitted)
|
|
|
|
data.exercices[eid].timeouted = true;
|
2019-01-25 06:26:52 +00:00
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].solved !== undefined)
|
|
|
|
data.exercices[eid].solved = $scope.my.exercices[eid].solved;
|
2019-02-03 20:01:17 +00:00
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].solved_time !== undefined && data.exercices[eid].solved_time === undefined)
|
|
|
|
data.exercices[eid].solved_time = $scope.my.exercices[eid].solved_time;
|
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].tries !== undefined && data.exercices[eid].tries === undefined)
|
|
|
|
data.exercices[eid].tries = $scope.my.exercices[eid].tries;
|
2018-12-02 00:04:25 +00:00
|
|
|
angular.forEach(exercice.flags, function(flag, fid) {
|
2019-01-25 06:26:52 +00:00
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].flags && $scope.my.exercices[eid].flags[fid] && $scope.my.exercices[eid].flags[fid].found !== undefined)
|
|
|
|
data.exercices[eid].flags[fid].found = $scope.my.exercices[eid].flags[fid].found;
|
2019-01-18 03:23:18 +00:00
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].flags && $scope.my.exercices[eid].flags[fid] && $scope.my.exercices[eid].flags[fid].value !== undefined)
|
2018-12-02 00:24:38 +00:00
|
|
|
data.exercices[eid].flags[fid].value = $scope.my.exercices[eid].flags[fid].value;
|
2019-01-18 03:23:18 +00:00
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].flags && $scope.my.exercices[eid].flags[fid] && $scope.my.exercices[eid].flags[fid].values !== undefined)
|
2018-12-04 17:34:38 +00:00
|
|
|
data.exercices[eid].flags[fid].values = $scope.my.exercices[eid].flags[fid].values;
|
2019-11-25 16:45:41 +00:00
|
|
|
else if (data.exercices[eid].flags[fid].nb_lines)
|
|
|
|
data.exercices[eid].flags[fid].values = Array(data.exercices[eid].flags[fid].nb_lines);
|
2018-12-04 17:34:38 +00:00
|
|
|
else
|
|
|
|
data.exercices[eid].flags[fid].values = [""];
|
2018-12-02 00:04:25 +00:00
|
|
|
});
|
2019-01-25 06:26:52 +00:00
|
|
|
angular.forEach(exercice.mcqs, function(mcq, mid) {
|
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].mcqs && $scope.my.exercices[eid].mcqs[mid] && $scope.my.exercices[eid].mcqs[mid].solved !== undefined)
|
|
|
|
data.exercices[eid].mcqs[mid].solved = $scope.my.exercices[eid].mcqs[mid].solved;
|
|
|
|
});
|
2018-12-02 00:04:25 +00:00
|
|
|
});
|
2018-12-02 00:24:38 +00:00
|
|
|
angular.forEach(data.exercices, function(exercice, eid) {
|
2018-12-02 00:04:25 +00:00
|
|
|
angular.forEach(exercice.mcqs, function(mcq, mid) {
|
|
|
|
angular.forEach(mcq.choices, function(choice, cid) {
|
2018-12-02 03:52:15 +00:00
|
|
|
if (!(choice instanceof Object))
|
|
|
|
this[cid] = {
|
|
|
|
label: choice,
|
|
|
|
};
|
|
|
|
|
2019-01-17 21:30:39 +00:00
|
|
|
this[cid].disabled = mcq.solved || mcq.part_solved || (this[cid].justification && this[cid].justification.solved);
|
2018-12-02 03:52:15 +00:00
|
|
|
|
|
|
|
if (!this[cid].disabled)
|
|
|
|
this[cid].value = $scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].mcqs[mid] && $scope.my.exercices[eid].mcqs[mid].choices[cid] && $scope.my.exercices[eid].mcqs[mid].choices[cid].value
|
2018-12-02 00:04:25 +00:00
|
|
|
|
2019-01-17 21:30:39 +00:00
|
|
|
if (mcq.justify) {
|
|
|
|
if (!this[cid].justification)
|
|
|
|
this[cid].justification = {};
|
|
|
|
|
|
|
|
if (!this[cid].justification.label) {
|
|
|
|
this[cid].justification.label = "Flag correspondant";
|
|
|
|
this[cid].justification.help2 = "Trouvez et validez les choix du QCM pour avoir des indications supplémentaires";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].mcqs[mid] && $scope.my.exercices[eid].mcqs[mid].choices[cid] && $scope.my.exercices[eid].mcqs[mid].choices[cid].justification) {
|
|
|
|
if ($scope.my.exercices[eid].mcqs[mid].choices[cid].justification.value !== undefined)
|
|
|
|
data.exercices[eid].mcqs[mid].choices[cid].justification.value = $scope.my.exercices[eid].mcqs[mid].choices[cid].justification.value;
|
|
|
|
if ($scope.my.exercices[eid].mcqs[mid].choices[cid].justification.values !== undefined)
|
|
|
|
data.exercices[eid].mcqs[mid].choices[cid].justification.values = $scope.my.exercices[eid].mcqs[mid].choices[cid].justification.values;
|
|
|
|
else
|
|
|
|
data.exercices[eid].mcqs[mid].choices[cid].justification.values = [""];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
data.exercices[eid].mcqs[mid].choices[cid].justification.values = [""];
|
2018-12-02 00:04:25 +00:00
|
|
|
}
|
|
|
|
}, mcq.choices);
|
|
|
|
});
|
|
|
|
});
|
2018-12-01 15:14:34 +00:00
|
|
|
$scope.my = data;
|
|
|
|
angular.forEach($scope.my.exercices, function(exercice, eid) {
|
|
|
|
exercice.solved = exercice.solved_rank > 0;
|
|
|
|
if (exercice.video_uri) {
|
|
|
|
exercice.video_uri = $sce.trustAsResourceUrl(exercice.video_uri);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
actMenu();
|
|
|
|
}
|
|
|
|
|
2019-01-17 12:03:15 +00:00
|
|
|
$rootScope.refresh = function(justMy, justSettings) {
|
2018-12-01 15:14:34 +00:00
|
|
|
if (!justMy) {
|
|
|
|
refreshSettings();
|
|
|
|
refreshThemes();
|
|
|
|
$rootScope.refreshTeams();
|
2018-12-01 17:15:03 +00:00
|
|
|
refreshEvents();
|
2020-01-23 15:03:31 +00:00
|
|
|
refreshIssues();
|
2018-12-01 15:14:34 +00:00
|
|
|
}
|
2019-01-17 12:03:15 +00:00
|
|
|
else if (justSettings) {
|
|
|
|
refreshSettings();
|
|
|
|
}
|
2018-12-01 15:14:34 +00:00
|
|
|
refreshMy();
|
2016-01-21 00:38:43 +00:00
|
|
|
}
|
2020-01-24 19:04:46 +00:00
|
|
|
$rootScope.refreshIssues = refreshIssues;
|
2016-01-23 11:29:19 +00:00
|
|
|
$rootScope.refresh();
|
2016-01-21 00:38:43 +00:00
|
|
|
})
|
2016-12-09 10:55:58 +00:00
|
|
|
.controller("ExerciceController", function($scope, $routeParams, $http, $rootScope, $timeout) {
|
2018-11-25 01:02:06 +00:00
|
|
|
if (window.scrollY > 112)
|
|
|
|
window.scrollTo(window.scrollX, 112);
|
|
|
|
|
2018-11-25 04:48:44 +00:00
|
|
|
$rootScope.current_tag = undefined;
|
|
|
|
|
2018-11-21 04:36:52 +00:00
|
|
|
$scope.$watch("themesUrl", function(themesUrl) {
|
|
|
|
if (themesUrl != undefined)
|
|
|
|
$rootScope.current_theme = themesUrl[$routeParams.theme];
|
|
|
|
})
|
2016-01-21 00:38:43 +00:00
|
|
|
|
|
|
|
if ($routeParams.exercice) {
|
2018-11-21 04:36:52 +00:00
|
|
|
$scope.$watch("exercicesUrl", function(exercicesUrl) {
|
|
|
|
if (exercicesUrl != undefined)
|
2018-12-05 14:22:35 +00:00
|
|
|
$rootScope.current_exercice = exercicesUrl[$routeParams.theme + "/" + $routeParams.exercice];
|
2018-11-21 04:36:52 +00:00
|
|
|
})
|
2019-01-20 23:35:07 +00:00
|
|
|
$scope.$watchGroup(["themes", "current_theme", "current_exercice"], function(newValues) {
|
|
|
|
var themes = newValues[0];
|
|
|
|
var current_theme = newValues[1];
|
|
|
|
var current_exercice = newValues[2];
|
|
|
|
if (themes != undefined && themes[current_theme] != undefined && themes[current_theme].exercices != undefined && themes[current_theme].exercices[current_exercice] != undefined)
|
|
|
|
$rootScope.title = themes[current_theme].name + " > " + themes[current_theme].exercices[current_exercice].title;
|
|
|
|
});
|
2016-01-21 00:38:43 +00:00
|
|
|
} else {
|
2018-11-25 02:08:07 +00:00
|
|
|
$rootScope.current_exercice = 0;
|
2019-01-20 23:35:07 +00:00
|
|
|
$scope.$watchGroup(["themes", "current_theme"], function(newValues) {
|
|
|
|
var themes = newValues[0];
|
|
|
|
var current_theme = newValues[1];
|
|
|
|
if (themes != undefined && themes[current_theme] != undefined)
|
|
|
|
$rootScope.title = themes[current_theme].name;
|
|
|
|
});
|
2016-01-21 00:38:43 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 15:14:34 +00:00
|
|
|
var cbh;
|
2016-12-09 10:55:58 +00:00
|
|
|
$scope.hsubmit = function(hint) {
|
|
|
|
hint.submitted = true;
|
2018-12-01 15:13:53 +00:00
|
|
|
$scope.hinterror = null;
|
2019-02-04 16:38:12 +00:00
|
|
|
$http({ url: "openhint/" + $rootScope.current_exercice, method: "POST", data: { id: hint.id } }).then(function(response) {
|
2016-12-09 10:55:58 +00:00
|
|
|
var checkDiffHint = function() {
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("my.json").then(function(response) {
|
2017-12-14 02:20:38 +00:00
|
|
|
var my = response.data;
|
2016-12-09 10:55:58 +00:00
|
|
|
angular.forEach(my.exercices[$rootScope.current_exercice].hints, function(h,hid){
|
|
|
|
if (hint.id == h.id) {
|
|
|
|
if (hint.content != h.content) {
|
2018-12-01 15:14:34 +00:00
|
|
|
$rootScope.recvMy(my);
|
2016-12-09 10:55:58 +00:00
|
|
|
} else {
|
2018-12-01 15:14:34 +00:00
|
|
|
if (cbh)
|
|
|
|
$timeout.cancel(cbh);
|
|
|
|
cbh = $timeout(checkDiffHint, 750);
|
2016-12-09 10:55:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
checkDiffHint();
|
2018-12-01 15:14:34 +00:00
|
|
|
}, function(response) {
|
2018-12-01 15:13:53 +00:00
|
|
|
$scope.hinterror = response.data.errmsg;
|
2016-12-09 10:55:58 +00:00
|
|
|
hint.submitted = false;
|
|
|
|
});
|
|
|
|
};
|
2016-01-23 11:29:19 +00:00
|
|
|
})
|
|
|
|
.controller("SubmissionController", function($scope, $http, $rootScope, $timeout) {
|
2018-12-01 23:43:11 +00:00
|
|
|
$scope.sberr = null;
|
2016-01-23 11:29:19 +00:00
|
|
|
|
2018-12-01 15:14:34 +00:00
|
|
|
var cbs;
|
|
|
|
var cbd;
|
|
|
|
|
2016-01-23 11:29:19 +00:00
|
|
|
$scope.ssubmit = function() {
|
2018-11-28 06:39:50 +00:00
|
|
|
var resp = {}
|
2018-11-28 03:15:14 +00:00
|
|
|
var check = undefined
|
2018-12-01 23:43:11 +00:00
|
|
|
$scope.sberr = null;
|
2016-01-23 11:29:19 +00:00
|
|
|
|
2018-11-28 01:27:51 +00:00
|
|
|
if ($scope.my.exercices[$rootScope.current_exercice].flags && Object.keys($scope.my.exercices[$rootScope.current_exercice].flags).length)
|
2017-12-16 01:12:44 +00:00
|
|
|
{
|
2018-11-28 06:39:50 +00:00
|
|
|
resp["flags"] = {};
|
2018-11-28 01:27:51 +00:00
|
|
|
angular.forEach($scope.my.exercices[$rootScope.current_exercice].flags, function(flag,kid) {
|
2019-01-25 06:26:52 +00:00
|
|
|
if (check === undefined) check = true;
|
|
|
|
|
|
|
|
check &= treatFlagKey(flag) || flag.found;
|
|
|
|
if (flag.soluce === undefined) {
|
|
|
|
check = undefined;
|
|
|
|
if (flag.found == null) {
|
|
|
|
resp["flags"][kid] = flag.value;
|
|
|
|
}
|
2018-11-28 03:15:14 +00:00
|
|
|
}
|
2017-12-16 01:12:44 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-11-28 01:27:51 +00:00
|
|
|
if ($scope.my.exercices[$rootScope.current_exercice].mcqs && Object.keys($scope.my.exercices[$rootScope.current_exercice].mcqs).length)
|
2017-12-16 01:12:44 +00:00
|
|
|
{
|
|
|
|
resp["mcqs"] = {};
|
2018-11-28 01:27:51 +00:00
|
|
|
angular.forEach($scope.my.exercices[$rootScope.current_exercice].mcqs, function(mcq) {
|
2019-01-25 06:26:52 +00:00
|
|
|
var soluce = "";
|
2018-11-28 03:15:14 +00:00
|
|
|
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 {
|
2018-11-28 05:39:38 +00:00
|
|
|
if (choice.value) {
|
|
|
|
resp["mcqs"][cid] = choice.value;
|
2019-01-17 21:30:39 +00:00
|
|
|
if (choice.justification !== undefined) {
|
2018-11-28 06:39:50 +00:00
|
|
|
if (resp["justifications"] == undefined)
|
|
|
|
resp["justifications"] = {};
|
2019-01-17 21:30:39 +00:00
|
|
|
treatFlagKey(choice.justification);
|
|
|
|
resp["justifications"][cid] = choice.justification.value;
|
2018-11-28 05:39:38 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-28 03:15:14 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (mcq.soluce !== undefined) {
|
|
|
|
if (mcq.soluce == b2sum(soluce))
|
|
|
|
mcq.solved = new Date();
|
|
|
|
check &= mcq.solved;
|
|
|
|
}
|
|
|
|
}
|
2017-12-16 01:12:44 +00:00
|
|
|
});
|
|
|
|
}
|
2016-01-23 11:29:19 +00:00
|
|
|
|
2018-11-28 03:15:14 +00:00
|
|
|
if (check !== undefined)
|
|
|
|
{
|
2019-02-03 20:00:41 +00:00
|
|
|
if (!$scope.my.exercices[$rootScope.current_exercice].tries)
|
|
|
|
$scope.my.exercices[$rootScope.current_exercice].tries = 0;
|
2018-11-28 03:15:14 +00:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
2019-02-04 16:38:12 +00:00
|
|
|
$http({ url: "submit/" + $rootScope.current_exercice, method: "POST", data: resp }).then(function(response) {
|
2018-12-01 23:43:11 +00:00
|
|
|
$scope.messageClass = {"text-success": true};
|
|
|
|
$scope.message = response.data.errmsg;
|
|
|
|
$scope.sberr = null;
|
2016-01-24 13:32:46 +00:00
|
|
|
|
|
|
|
angular.forEach($scope.flags, function(flag,kid) {
|
|
|
|
flag.value = "";
|
|
|
|
});
|
2016-01-21 00:38:43 +00:00
|
|
|
|
2016-01-23 11:29:19 +00:00
|
|
|
var checkDiff = function() {
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("my.json").then(function(response) {
|
2017-12-14 02:20:38 +00:00
|
|
|
var my = response.data;
|
2017-12-16 01:12:44 +00:00
|
|
|
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) {
|
2019-01-19 23:17:52 +00:00
|
|
|
$scope.my.exercices[$rootScope.current_exercice].submitted = false;
|
2018-12-01 15:14:34 +00:00
|
|
|
$rootScope.recvMy(my);
|
|
|
|
$rootScope.refreshTeams();
|
2016-01-21 00:38:43 +00:00
|
|
|
} else {
|
2018-12-01 15:14:34 +00:00
|
|
|
if (cbd)
|
|
|
|
$timeout.cancel(cbd);
|
|
|
|
cbd = $timeout(checkDiff, 750);
|
2016-01-21 00:38:43 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2016-01-23 12:19:59 +00:00
|
|
|
checkDiff();
|
2018-12-01 23:43:11 +00:00
|
|
|
}, function(response) {
|
|
|
|
if (response.status >= 500) {
|
2016-01-21 00:38:43 +00:00
|
|
|
$scope.my.exercices[$rootScope.current_exercice].submitted = false;
|
|
|
|
}
|
2018-12-01 23:43:11 +00:00
|
|
|
$scope.messageClass = {"text-danger": true};
|
|
|
|
$scope.sberr = "Oups !";
|
|
|
|
$scope.message = response.data.errmsg;
|
2016-01-21 00:38:43 +00:00
|
|
|
});
|
2019-01-18 03:41:17 +00:00
|
|
|
$scope.my.exercices[$rootScope.current_exercice].timeouted = false;
|
2016-01-21 00:38:43 +00:00
|
|
|
$scope.my.exercices[$rootScope.current_exercice].submitted = true;
|
|
|
|
};
|
2018-12-02 22:18:32 +00:00
|
|
|
|
|
|
|
$scope.wantchoices = function(kid) {
|
|
|
|
$scope.my.exercices[$rootScope.current_exercice].flags[kid].wcsubmitted = true;
|
2019-02-04 16:38:12 +00:00
|
|
|
$http({ url: "wantchoices/" + $rootScope.current_exercice, method: "POST", data: { id: Math.floor(kid) } }).then(function(response) {
|
2018-12-02 22:18:32 +00:00
|
|
|
var checkDiffWC = function() {
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("my.json").then(function(response) {
|
2018-12-02 22:18:32 +00:00
|
|
|
var my = response.data;
|
|
|
|
if (my.exercices[$rootScope.current_exercice].flags[kid].choices)
|
|
|
|
$rootScope.recvMy(my);
|
|
|
|
else {
|
|
|
|
if (cbd)
|
|
|
|
$timeout.cancel(cbd);
|
|
|
|
cbd = $timeout(checkDiffWC, 750);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
checkDiffWC();
|
|
|
|
}, function(response) {
|
|
|
|
$scope.messageClass = {"text-danger": true};
|
|
|
|
$scope.sberr = "Oups !";
|
|
|
|
$scope.message = response.data.errmsg;
|
|
|
|
$scope.my.exercices[$rootScope.current_exercice].flags[kid].wcsubmitted = false;
|
|
|
|
});
|
|
|
|
}
|
2016-01-16 21:40:59 +00:00
|
|
|
})
|
2020-01-20 14:56:02 +00:00
|
|
|
.controller("IssueController", function($scope, $http, $rootScope, $routeParams) {
|
|
|
|
$rootScope.current_tag = undefined;
|
|
|
|
$rootScope.current_exercice = $routeParams.eid;
|
2020-01-23 15:03:31 +00:00
|
|
|
$rootScope.issues_known_responses = $rootScope.issues_nb_responses;
|
2020-01-20 14:56:02 +00:00
|
|
|
|
|
|
|
$scope.issue = {
|
2020-01-24 19:04:46 +00:00
|
|
|
id: parseInt($routeParams.iid, 10),
|
2020-01-20 14:56:02 +00:00
|
|
|
id_exercice: parseInt($routeParams.eid, 10),
|
|
|
|
subject: "",
|
|
|
|
description: "",
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.isubmit = function() {
|
|
|
|
$rootScope.sberr = "";
|
2020-01-24 19:04:46 +00:00
|
|
|
if (!$scope.issue.id && $scope.issue.subject.length < 3) {
|
2020-01-20 14:56:02 +00:00
|
|
|
$rootScope.messageClass = {"text-danger": true};
|
2020-01-24 19:04:46 +00:00
|
|
|
$rootScope.sberr = "L'objet de votre rapport d'anomalie est trop court !";
|
2020-01-20 14:56:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$http({
|
|
|
|
url: "submit/issue",
|
|
|
|
method: "POST",
|
|
|
|
data: $scope.issue
|
|
|
|
}).then(function(response) {
|
|
|
|
$rootScope.messageClass = {"text-success": true};
|
|
|
|
$rootScope.message = response.data.errmsg;
|
|
|
|
$scope.issue.subject = "";
|
|
|
|
$scope.issue.description = "";
|
2020-01-24 19:04:46 +00:00
|
|
|
setTimeout($rootScope.refreshIssues, 1750);
|
2020-01-20 14:56:02 +00:00
|
|
|
}, function(response) {
|
|
|
|
$rootScope.messageClass = {"text-danger": true};
|
|
|
|
$rootScope.message = response.data.errmsg;
|
|
|
|
if (response.status != 402) {
|
|
|
|
$rootScope.sberr = "Une erreur est survenue lors de l'envoi. Veuillez réessayer dans quelques instants.";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
})
|
2019-01-19 07:04:54 +00:00
|
|
|
.controller("MyTeamController", function($scope, $http, $rootScope, $timeout, $location) {
|
2016-01-16 21:40:59 +00:00
|
|
|
$rootScope.current_theme = 0;
|
|
|
|
$rootScope.current_exercice = 0;
|
2018-11-25 04:48:44 +00:00
|
|
|
$rootScope.current_tag = undefined;
|
2016-01-24 13:23:04 +00:00
|
|
|
if ($scope.my) {
|
|
|
|
$rootScope.title = $scope.my.name;
|
|
|
|
$rootScope.authors = $scope.my.members.map(function (cur) {
|
|
|
|
return cur.firstname.capitalize() + " " + cur.lastname.capitalize();
|
|
|
|
}).join(", ");
|
|
|
|
}
|
|
|
|
$rootScope.message = "";
|
|
|
|
$rootScope.sberr = "";
|
|
|
|
|
2019-01-19 07:04:54 +00:00
|
|
|
$scope.notify = {
|
|
|
|
info: ($rootScope.notify_field & 1) != 1,
|
|
|
|
team: ($rootScope.notify_field & 2) != 2,
|
|
|
|
others: ($rootScope.notify_field & 4) != 4,
|
|
|
|
solve: ($rootScope.notify_field & 8) != 8,
|
|
|
|
hint: ($rootScope.notify_field & 16) != 16,
|
|
|
|
tries: ($rootScope.notify_field & 32) != 32,
|
|
|
|
rename: ($rootScope.notify_field & 64) != 64,
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.alternotify = function() {
|
|
|
|
$rootScope.notify_field =
|
|
|
|
($scope.notify.info?0:1) |
|
|
|
|
($scope.notify.team?0:2) |
|
|
|
|
($scope.notify.others?0:4) |
|
|
|
|
($scope.notify.solve?0:8) |
|
|
|
|
($scope.notify.hint?0:16) |
|
|
|
|
($scope.notify.tries?0:32) |
|
|
|
|
($scope.notify.rename?0:64);
|
|
|
|
if ($rootScope.notify_field != 0)
|
|
|
|
localStorage.notification = $rootScope.notify_field;
|
|
|
|
else
|
|
|
|
delete localStorage.notification;
|
2019-02-04 16:38:12 +00:00
|
|
|
$location.url(".");
|
2019-01-19 07:04:54 +00:00
|
|
|
}
|
|
|
|
|
2018-12-01 15:14:34 +00:00
|
|
|
var cbt;
|
|
|
|
|
2016-01-24 13:23:04 +00:00
|
|
|
$scope.tsubmit = function() {
|
|
|
|
$rootScope.sberr = "";
|
2019-01-17 18:13:46 +00:00
|
|
|
if ($scope.my.newName.length < 1) {
|
2016-01-24 13:23:04 +00:00
|
|
|
$rootScope.messageClass = {"text-danger": true};
|
|
|
|
$rootScope.sberr = "Nom d'équipe invalide: pas d'entrée.";
|
|
|
|
return false;
|
|
|
|
}
|
2019-01-17 18:13:46 +00:00
|
|
|
else if ($scope.my.newName.length > 32) {
|
2016-01-24 13:23:04 +00:00
|
|
|
$rootScope.messageClass = {"text-danger": true};
|
|
|
|
$rootScope.sberr = "Nom d'équipe invalide: pas plus de 32 caractères.";
|
|
|
|
return false;
|
|
|
|
}
|
2019-01-17 18:13:46 +00:00
|
|
|
else if (!$scope.my.newName.match(/^[A-Za-z0-9 àéèêëîïôùûü_-]+$/)) {
|
2016-01-24 13:23:04 +00:00
|
|
|
$rootScope.messageClass = {"text-danger": true};
|
|
|
|
$rootScope.sberr = "Nom d'équipe invalide: seuls les caractères alpha-numériques sont autorisés.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$http({
|
2019-02-04 16:38:12 +00:00
|
|
|
url: "submit/name",
|
2016-01-24 13:23:04 +00:00
|
|
|
method: "POST",
|
2019-01-17 18:13:46 +00:00
|
|
|
data: {newName: $scope.my.newName}
|
2018-12-01 15:14:34 +00:00
|
|
|
}).then(function(response) {
|
2016-01-24 13:23:04 +00:00
|
|
|
$rootScope.messageClass = {"text-success": true};
|
2017-12-14 02:20:38 +00:00
|
|
|
$rootScope.message = response.data.errmsg;
|
2016-01-24 13:23:04 +00:00
|
|
|
|
|
|
|
var checkDiff = function() {
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("my.json").then(function(response) {
|
2017-12-14 02:20:38 +00:00
|
|
|
if ($scope.my.name != response.data.name) {
|
2019-01-17 18:13:46 +00:00
|
|
|
$scope.my.newName = undefined;
|
2016-01-24 13:23:04 +00:00
|
|
|
$rootScope.message = "";
|
2018-12-01 15:14:34 +00:00
|
|
|
$rootScope.recvMy(response.data);
|
|
|
|
$rootScope.refreshTeams();
|
2016-01-24 13:23:04 +00:00
|
|
|
} else {
|
2018-12-01 15:14:34 +00:00
|
|
|
if (cbt)
|
|
|
|
$timeout.cancel(cbt);
|
|
|
|
cbt = $timeout(checkDiff, 750);
|
2016-01-24 13:23:04 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
checkDiff();
|
2018-12-01 15:14:34 +00:00
|
|
|
}, function(response) {
|
2016-01-24 13:23:04 +00:00
|
|
|
$rootScope.messageClass = {"text-danger": true};
|
2017-12-14 02:20:38 +00:00
|
|
|
$rootScope.message = response.data.errmsg;
|
2018-12-01 15:14:34 +00:00
|
|
|
if (response.status != 402) {
|
2016-01-24 13:23:04 +00:00
|
|
|
$rootScope.sberr = "Une erreur est survenue lors de l'envoi. Veuillez réessayer dans quelques instants.";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
2016-01-16 21:40:59 +00:00
|
|
|
})
|
2018-12-02 01:12:53 +00:00
|
|
|
.controller("RegisterController", function($scope, $rootScope, $location, $http, $interval) {
|
2017-12-21 21:18:18 +00:00
|
|
|
$rootScope.current_theme = 0;
|
|
|
|
$rootScope.current_exercice = 0;
|
2018-11-25 04:48:44 +00:00
|
|
|
$rootScope.current_tag = undefined;
|
2017-12-21 21:18:18 +00:00
|
|
|
$rootScope.title = "Bienvenue au challenge forensic !";
|
|
|
|
$rootScope.authors = null;
|
|
|
|
|
2019-02-04 17:14:46 +00:00
|
|
|
$scope.form = {"teamName": "", "jTeam": 0, "members": [{}]};
|
2017-12-21 21:18:18 +00:00
|
|
|
|
|
|
|
$scope.AddMember = function() {
|
2018-12-02 01:12:53 +00:00
|
|
|
$scope.form.members.push({});
|
2017-12-21 21:18:18 +00:00
|
|
|
}
|
|
|
|
$scope.RemoveMember = function(k) {
|
2018-12-02 01:12:53 +00:00
|
|
|
$scope.form.members.splice(k, 1);
|
2017-12-21 21:18:18 +00:00
|
|
|
}
|
|
|
|
$scope.Validate = function() {
|
2018-12-02 01:12:53 +00:00
|
|
|
if ($scope.form.teamName.length <= 3) {
|
2017-12-21 21:18:18 +00:00
|
|
|
$('#teamName').addClass("is-invalid")
|
|
|
|
return;
|
|
|
|
} else {
|
2019-02-04 17:14:46 +00:00
|
|
|
$('#teamName').removeClass("is-invalid")
|
2017-12-21 21:18:18 +00:00
|
|
|
$('#vldBtn').removeClass("input-group-btn");
|
|
|
|
$('#vldBtn').css("display", "none");
|
2019-02-04 17:14:46 +00:00
|
|
|
$('#jvldBtn').css("display", "none");
|
|
|
|
$scope.partR = true;
|
|
|
|
$scope.partJ = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$scope.JValidate = function() {
|
|
|
|
if (!$scope.teams[$scope.form.jTeam]) {
|
|
|
|
$('#jTeam').addClass("is-invalid")
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
$('#jTeam').removeClass("is-invalid")
|
|
|
|
$('#jvldBtn').removeClass("input-group-btn");
|
|
|
|
$('#jvldBtn').css("display", "none");
|
|
|
|
$('#vldBtn').css("display", "none");
|
|
|
|
$scope.partR = false;
|
|
|
|
$scope.partJ = true;
|
2017-12-21 21:18:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-04 17:14:46 +00:00
|
|
|
var commonsubmit = function(registration) {
|
2017-12-21 21:18:18 +00:00
|
|
|
// Remove empty members
|
2018-12-02 01:12:53 +00:00
|
|
|
$scope.form.members = $scope.form.members.filter(function(m) {
|
2017-12-21 21:18:18 +00:00
|
|
|
return ((m.lastname != undefined && m.lastname != "") || (m.firstname != undefined && m.firstname != "") || (m.nickname != undefined && m.nickname != ""));
|
|
|
|
});
|
|
|
|
|
2018-12-02 01:12:53 +00:00
|
|
|
if ($scope.form.members.length == 0) {
|
2017-12-21 21:18:18 +00:00
|
|
|
$scope.messageClass = {"text-danger": true};
|
|
|
|
$scope.message = "Veuillez ajouter au moins un membre dans votre équipe !";
|
|
|
|
|
2018-12-02 01:12:53 +00:00
|
|
|
$scope.form.members.push({});
|
2017-12-21 21:18:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-04 17:14:46 +00:00
|
|
|
$scope.form.jTeam = parseInt($scope.form.jTeam);
|
|
|
|
|
2017-12-21 21:18:18 +00:00
|
|
|
$http({
|
2019-02-04 16:38:12 +00:00
|
|
|
url: "registration",
|
2017-12-21 21:18:18 +00:00
|
|
|
method: "POST",
|
2018-12-02 01:12:53 +00:00
|
|
|
data: $scope.form
|
|
|
|
}).then(function(response) {
|
2017-12-21 21:18:18 +00:00
|
|
|
$scope.messageClass = {"text-success": true};
|
|
|
|
$scope.message = response.data.errmsg;
|
|
|
|
|
2018-12-02 01:12:53 +00:00
|
|
|
$interval(function(){
|
2019-02-04 16:38:12 +00:00
|
|
|
$http.get("my.json").then(function(response) {
|
2018-12-02 01:12:53 +00:00
|
|
|
$rootScope.refresh();
|
|
|
|
});
|
|
|
|
}, 1500);
|
|
|
|
|
2017-12-21 21:18:18 +00:00
|
|
|
}, function(response) {
|
|
|
|
$scope.messageClass = {"text-danger": true};
|
|
|
|
if (response.data && response.data.errmsg)
|
|
|
|
$scope.message = response.data.errmsg;
|
|
|
|
else
|
|
|
|
$scope.message = "Une erreur est survenue lors de l'inscription de l'équipe. Veuillez réessayer dans quelques instants.";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-04 17:14:46 +00:00
|
|
|
$scope.rsubmit = function() {
|
|
|
|
if (!$scope.partR)
|
|
|
|
return $scope.Validate();
|
|
|
|
else
|
|
|
|
return commonsubmit(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.jsubmit = function() {
|
|
|
|
if (!$scope.partJ)
|
|
|
|
return $scope.JValidate();
|
|
|
|
else
|
|
|
|
return commonsubmit(false);
|
|
|
|
}
|
|
|
|
|
2018-12-02 01:12:53 +00:00
|
|
|
$scope.$watch("my", function(my){
|
|
|
|
if (my)
|
2019-02-04 16:38:12 +00:00
|
|
|
$location.url(".");
|
2018-12-02 01:12:53 +00:00
|
|
|
});
|
2017-12-21 21:18:18 +00:00
|
|
|
})
|
2018-12-08 19:22:41 +00:00
|
|
|
.controller("TagController", function($scope, $rootScope, $routeParams, $location) {
|
2018-11-21 02:10:35 +00:00
|
|
|
$rootScope.current_theme = 0;
|
|
|
|
$rootScope.current_exercice = 0;
|
2018-11-25 04:48:44 +00:00
|
|
|
$rootScope.current_tag = $routeParams.tag;
|
2018-11-21 02:10:35 +00:00
|
|
|
$rootScope.title = "Challenges " + $routeParams.tag;
|
|
|
|
$rootScope.authors = "";
|
|
|
|
|
|
|
|
$scope.tag = $routeParams.tag;
|
|
|
|
$scope.exercices = [];
|
|
|
|
|
|
|
|
$scope.$watch("themes", function(themes) {
|
|
|
|
$scope.exercices = [];
|
|
|
|
angular.forEach(themes, function(theme, tid) {
|
|
|
|
angular.forEach(theme.exercices, function(exercice, eid) {
|
|
|
|
if (exercice.tags.indexOf($scope.tag) >= 0)
|
|
|
|
$scope.exercices.push({"exercice": exercice, "theme": theme, "eid": eid, "tid": tid});
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2018-12-08 19:22:41 +00:00
|
|
|
|
|
|
|
$scope.goDefi = function() {
|
2019-02-04 16:38:12 +00:00
|
|
|
$location.url(this.ex.theme.urlid + "/" + this.ex.exercice.urlid);
|
2018-12-08 19:22:41 +00:00
|
|
|
}
|
|
|
|
|
2018-11-21 02:10:35 +00:00
|
|
|
})
|
2016-01-21 00:38:43 +00:00
|
|
|
.controller("RankController", function($scope, $rootScope) {
|
|
|
|
$rootScope.current_theme = 0;
|
|
|
|
$rootScope.current_exercice = 0;
|
2018-11-25 04:48:44 +00:00
|
|
|
$rootScope.current_tag = undefined;
|
2016-01-21 00:38:43 +00:00
|
|
|
$rootScope.title = "Classement général";
|
2016-01-24 13:32:46 +00:00
|
|
|
$rootScope.authors = "";
|
2016-01-21 00:38:43 +00:00
|
|
|
|
|
|
|
$scope.fields = ["rank", "name", "score"];
|
|
|
|
$scope.rankOrder = "rank";
|
|
|
|
$scope.reverse = false;
|
|
|
|
$scope.order = function(fld) {
|
|
|
|
if ($scope.rankOrder == fld) {
|
|
|
|
$scope.reverse = !$scope.reverse;
|
|
|
|
} else {
|
|
|
|
$scope.rankOrder = fld;
|
2017-01-14 14:01:18 +00:00
|
|
|
$scope.reverse = (fld == "score");
|
2016-01-21 00:38:43 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
})
|
2017-04-02 18:29:15 +00:00
|
|
|
.controller("VideosController", function($scope, $rootScope) {
|
|
|
|
$rootScope.current_theme = 0;
|
|
|
|
$rootScope.current_exercice = 0;
|
2018-11-25 04:48:44 +00:00
|
|
|
$rootScope.current_tag = undefined;
|
2017-04-02 18:29:15 +00:00
|
|
|
$rootScope.title = "Vidéos de résolution";
|
|
|
|
$rootScope.authors = "";
|
|
|
|
})
|
2018-12-08 19:22:41 +00:00
|
|
|
.controller("HomeController", function($scope, $rootScope, $location) {
|
2016-01-16 21:40:59 +00:00
|
|
|
$rootScope.current_theme = 0;
|
|
|
|
$rootScope.current_exercice = 0;
|
2018-11-25 04:48:44 +00:00
|
|
|
$rootScope.current_tag = undefined;
|
2018-11-25 01:02:06 +00:00
|
|
|
$rootScope.title = "Bienvenue au challenge forensic de l'ÉPITA !";
|
2016-01-24 13:32:46 +00:00
|
|
|
$rootScope.authors = "";
|
2018-12-08 19:22:41 +00:00
|
|
|
|
|
|
|
$scope.goTheme = function() {
|
2019-02-04 16:38:12 +00:00
|
|
|
$location.url(this.theme.urlid);
|
2018-12-08 19:22:41 +00:00
|
|
|
}
|
2016-01-16 21:40:59 +00:00
|
|
|
});
|
2016-01-21 00:38:43 +00:00
|
|
|
|
|
|
|
function sready() {
|
|
|
|
if ($("#solution").val().length) {
|
|
|
|
$("#sbmt").removeClass("disabled");
|
|
|
|
} else {
|
|
|
|
$("#sbmt").addClass("disabled");
|
|
|
|
}
|
|
|
|
};
|