frontend: polish public version checks
This commit is contained in:
parent
85d326db6b
commit
db22c4af1b
@ -19,12 +19,21 @@ function treatFlagKey(flag) {
|
||||
}
|
||||
|
||||
if (flag.found == null && flag.soluce !== undefined) {
|
||||
if (check === undefined) check = true;
|
||||
if (flag.value && flag.soluce) {
|
||||
if (flag.ignore_case)
|
||||
flag.value = flag.value.toLowerCase();
|
||||
if (flag.validator_regexp) {
|
||||
var re = new RegExp(flag.validator_regexp, flag.ignore_case?'ui':'u');
|
||||
var match = re.exec(flag.value);
|
||||
match.shift();
|
||||
flag.value = match.join("+");
|
||||
}
|
||||
|
||||
if (flag.value && flag.soluce == b2sum(flag.value))
|
||||
flag.found = new Date();
|
||||
check &= flag.found;
|
||||
if (flag.soluce == b2sum(flag.value))
|
||||
flag.found = new Date();
|
||||
}
|
||||
}
|
||||
return flag.found !== undefined && flag.found !== false;
|
||||
}
|
||||
|
||||
angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
@ -329,7 +338,11 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
angular.forEach(data.exercices, function(exercice, eid) {
|
||||
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].submitted)
|
||||
data.exercices[eid].timeouted = true;
|
||||
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].solved !== undefined)
|
||||
data.exercices[eid].solved = $scope.my.exercices[eid].solved;
|
||||
angular.forEach(exercice.flags, function(flag, fid) {
|
||||
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;
|
||||
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)
|
||||
data.exercices[eid].flags[fid].value = $scope.my.exercices[eid].flags[fid].value;
|
||||
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)
|
||||
@ -337,6 +350,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
else
|
||||
data.exercices[eid].flags[fid].values = [""];
|
||||
});
|
||||
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;
|
||||
});
|
||||
});
|
||||
angular.forEach(data.exercices, function(exercice, eid) {
|
||||
angular.forEach(exercice.mcqs, function(mcq, mid) {
|
||||
@ -474,18 +491,23 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
{
|
||||
resp["flags"] = {};
|
||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice].flags, function(flag,kid) {
|
||||
treatFlagKey(flag);
|
||||
if (flag.found == null && flag.soluce === undefined) {
|
||||
resp["flags"][kid] = flag.value;
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
var soluce = "";
|
||||
if (mcq.solved == null) {
|
||||
angular.forEach(mcq.choices, function(choice, cid) {
|
||||
if (mcq.soluce !== undefined) {
|
||||
|
@ -119,9 +119,12 @@
|
||||
<span class="glyphicon glyphicon-flag" aria-hidden="true"></span> Défi réussi !
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text">
|
||||
<p class="card-text" ng-if="my.exercices[current_exercice].solved_rank">
|
||||
Vous êtes la {{ my.exercices[current_exercice].solved_rank }}<sup><ng-pluralize count="my.exercices[current_exercice].solved_rank" when="{'one': 're', 'other': 'e'}"></ng-pluralize></sup> équipe à avoir résolu ce défi à {{ my.exercices[current_exercice].solved_time | date:"mediumTime" }}. Vous avez marqué <ng-pluralize count="my.exercices[current_exercice].gain" when="{'one': '{} point', 'other': '{} points'}"></ng-pluralize> !
|
||||
</p>
|
||||
<p class="card-text" ng-if="!my.exercices[current_exercice].solved_rank">
|
||||
Bravo, vous avez résolu ce défi à {{ my.exercices[current_exercice].solved_time | date:"mediumTime" }}. Vous marquez <ng-pluralize count="my.exercices[current_exercice].gain" when="{'one': '{} point', 'other': '{} points'}"></ng-pluralize> !
|
||||
</p>
|
||||
<hr ng-if="my.exercices[current_exercice].finished">
|
||||
<p class="card-text" ng-if="my.exercices[current_exercice].finished" ng-bind-html="my.exercices[current_exercice].finished"></p>
|
||||
<hr ng-if="my.exercices[current_exercice].finished && themes[current_theme].exercices[current_exercice].next">
|
||||
|
@ -30,6 +30,8 @@ type myTeamFlag struct {
|
||||
Help string `json:"help,omitempty"`
|
||||
Separator string `json:"separator,omitempty"`
|
||||
IgnoreOrder bool `json:"ignore_order,omitempty"`
|
||||
IgnoreCase bool `json:"ignore_case,omitempty"`
|
||||
ValidatorRe *string `json:"validator_regexp,omitempty"`
|
||||
Solved *time.Time `json:"found,omitempty"`
|
||||
Soluce string `json:"soluce,omitempty"`
|
||||
Choices map[string]string `json:"choices,omitempty"`
|
||||
@ -189,6 +191,8 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
||||
|
||||
// Retrieve solved state or solution for public iface
|
||||
if t == nil {
|
||||
flag.IgnoreCase = k.IgnoreCase
|
||||
flag.ValidatorRe = k.ValidatorRegexp
|
||||
flag.Soluce = hex.EncodeToString(k.Checksum)
|
||||
} else if PartialValidation {
|
||||
flag.Solved = t.HasPartiallySolved(k)
|
||||
|
Loading…
Reference in New Issue
Block a user