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 (flag.found == null && flag.soluce !== undefined) {
|
||||||
if (check === undefined) check = true;
|
if (flag.value && flag.soluce) {
|
||||||
|
if (flag.ignore_case)
|
||||||
if (flag.value && flag.soluce == b2sum(flag.value))
|
flag.value = flag.value.toLowerCase();
|
||||||
flag.found = new Date();
|
if (flag.validator_regexp) {
|
||||||
check &= flag.found;
|
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.soluce == b2sum(flag.value))
|
||||||
|
flag.found = new Date();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flag.found !== undefined && flag.found !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||||
@ -329,7 +338,11 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||||||
angular.forEach(data.exercices, function(exercice, eid) {
|
angular.forEach(data.exercices, function(exercice, eid) {
|
||||||
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].submitted)
|
if ($scope.my && $scope.my.exercices[eid] && $scope.my.exercices[eid].submitted)
|
||||||
data.exercices[eid].timeouted = true;
|
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) {
|
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)
|
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;
|
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)
|
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
|
else
|
||||||
data.exercices[eid].flags[fid].values = [""];
|
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(data.exercices, function(exercice, eid) {
|
||||||
angular.forEach(exercice.mcqs, function(mcq, mid) {
|
angular.forEach(exercice.mcqs, function(mcq, mid) {
|
||||||
@ -474,18 +491,23 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||||||
{
|
{
|
||||||
resp["flags"] = {};
|
resp["flags"] = {};
|
||||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice].flags, function(flag,kid) {
|
angular.forEach($scope.my.exercices[$rootScope.current_exercice].flags, function(flag,kid) {
|
||||||
treatFlagKey(flag);
|
if (check === undefined) check = true;
|
||||||
if (flag.found == null && flag.soluce === undefined) {
|
|
||||||
|
check &= treatFlagKey(flag) || flag.found;
|
||||||
|
if (flag.soluce === undefined) {
|
||||||
|
check = undefined;
|
||||||
|
if (flag.found == null) {
|
||||||
resp["flags"][kid] = flag.value;
|
resp["flags"][kid] = flag.value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.my.exercices[$rootScope.current_exercice].mcqs && Object.keys($scope.my.exercices[$rootScope.current_exercice].mcqs).length)
|
if ($scope.my.exercices[$rootScope.current_exercice].mcqs && Object.keys($scope.my.exercices[$rootScope.current_exercice].mcqs).length)
|
||||||
{
|
{
|
||||||
var soluce = "";
|
|
||||||
resp["mcqs"] = {};
|
resp["mcqs"] = {};
|
||||||
angular.forEach($scope.my.exercices[$rootScope.current_exercice].mcqs, function(mcq) {
|
angular.forEach($scope.my.exercices[$rootScope.current_exercice].mcqs, function(mcq) {
|
||||||
|
var soluce = "";
|
||||||
if (mcq.solved == null) {
|
if (mcq.solved == null) {
|
||||||
angular.forEach(mcq.choices, function(choice, cid) {
|
angular.forEach(mcq.choices, function(choice, cid) {
|
||||||
if (mcq.soluce !== undefined) {
|
if (mcq.soluce !== undefined) {
|
||||||
|
@ -119,9 +119,12 @@
|
|||||||
<span class="glyphicon glyphicon-flag" aria-hidden="true"></span> Défi réussi !
|
<span class="glyphicon glyphicon-flag" aria-hidden="true"></span> Défi réussi !
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<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> !
|
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>
|
||||||
|
<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">
|
<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>
|
<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">
|
<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"`
|
Help string `json:"help,omitempty"`
|
||||||
Separator string `json:"separator,omitempty"`
|
Separator string `json:"separator,omitempty"`
|
||||||
IgnoreOrder bool `json:"ignore_order,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"`
|
Solved *time.Time `json:"found,omitempty"`
|
||||||
Soluce string `json:"soluce,omitempty"`
|
Soluce string `json:"soluce,omitempty"`
|
||||||
Choices map[string]string `json:"choices,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
|
// Retrieve solved state or solution for public iface
|
||||||
if t == nil {
|
if t == nil {
|
||||||
|
flag.IgnoreCase = k.IgnoreCase
|
||||||
|
flag.ValidatorRe = k.ValidatorRegexp
|
||||||
flag.Soluce = hex.EncodeToString(k.Checksum)
|
flag.Soluce = hex.EncodeToString(k.Checksum)
|
||||||
} else if PartialValidation {
|
} else if PartialValidation {
|
||||||
flag.Solved = t.HasPartiallySolved(k)
|
flag.Solved = t.HasPartiallySolved(k)
|
||||||
|
Loading…
Reference in New Issue
Block a user