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
|
|
@ -138,5 +138,6 @@
|
|||
<script src="/js/i18n/angular-locale_fr-fr.js"></script>
|
||||
<script src="/js/challenge.js"></script>
|
||||
<script src="/js/common.js"></script>
|
||||
<script src="/js/blake2b.js" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
2594
frontend/static/js/blake2b.js
Normal file
2594
frontend/static/js/blake2b.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -67,12 +67,12 @@
|
|||
</div>
|
||||
|
||||
<div class="col-xl mb-5">
|
||||
<div class="card border-danger" ng-if="my.team_id && my.exercices[current_exercice] && !(my.exercices[current_exercice].solved)">
|
||||
<div class="card border-danger" ng-if="my.exercices[current_exercice] && !(my.exercices[current_exercice].solved)">
|
||||
<div class="card-header bg-danger text-white">
|
||||
<span class="glyphicon glyphicon-flag" aria-hidden="true"></span> Faire son rapport
|
||||
</div>
|
||||
<ul class="list-group" ng-if="(my.exercices[current_exercice].tries || my.exercices[current_exercice].submitted || sberr)">
|
||||
<li class="list-group-item text-warning" ng-if="my.exercices[current_exercice].tries"><ng-pluralize count="my.exercices[current_exercice].tries" when="{'one': '{} tentative effectuée', 'other': '{} tentatives effectuées'}"></ng-pluralize>. Dernière solution envoyée à {{ my.exercices[current_exercice].solved_time | date:"mediumTime" }}. <span ng-if="my.exercices[current_exercice].solve_dist"><ng-pluralize count="my.exercices[current_exercice].solve_dist" when="{'one': '{} réponse erronée', 'other': '{} réponses erronées'}"></ng-pluralize>.</span></li>
|
||||
<li class="list-group-item text-warning" ng-if="my.exercices[current_exercice].solved_time && my.exercices[current_exercice].tries"><ng-pluralize count="my.exercices[current_exercice].tries" when="{'one': '{} tentative effectuée', 'other': '{} tentatives effectuées'}"></ng-pluralize>. Dernière solution envoyée à {{ my.exercices[current_exercice].solved_time | date:"mediumTime" }}. <span ng-if="my.exercices[current_exercice].solve_dist"><ng-pluralize count="my.exercices[current_exercice].solve_dist" when="{'one': '{} réponse erronée', 'other': '{} réponses erronées'}"></ng-pluralize>.</span></li>
|
||||
<li class="list-group-item" ng-class="messageClass" ng-if="my.exercices[current_exercice].submitted || sberr"><strong ng-if="!sberr">Votre solution a bien été envoyée !</strong><strong ng-if="sberr">{{ sberr }}</strong> {{ message }}</li>
|
||||
</ul>
|
||||
<div class="card-body" ng-if="!my.exercices[current_exercice].submitted || sberr">
|
||||
|
|
@ -80,7 +80,7 @@
|
|||
<div class="form-group" ng-repeat="(kid,key) in my.exercices[current_exercice].flags">
|
||||
<label for="sol_{{ kid }}">{{ key.label }} :</label>
|
||||
<input type="text" class="form-control" id="sol_{{ kid }}" autocomplete="off" name="sol_{{ kid }}" ng-model="key.value" ng-if="!key.found">
|
||||
<small class="form-text text-muted" ng-if="key.help.length > 0" ng-bind="key.help"></small>
|
||||
<small class="form-text text-muted" ng-if="!key.found && key.help.length > 0" ng-bind="key.help"></small>
|
||||
<span class="glyphicon glyphicon-ok form-control-feedback text-success" aria-hidden="true" ng-if="key.found" title="Flag trouvé à {{ key.found | date:'mediumTime'}}"></span>
|
||||
</div>
|
||||
|
||||
|
|
@ -100,7 +100,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card border-success" ng-if="(my.team_id && my.exercices[current_exercice].solved)">
|
||||
<div class="card border-success" ng-if="my.exercices[current_exercice].solved">
|
||||
<div class="card-header bg-success text-white">
|
||||
<span class="glyphicon glyphicon-flag" aria-hidden="true"></span> Challenge réussi !
|
||||
</div>
|
||||
|
|
@ -112,20 +112,13 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card border-success" ng-if="(!my.team_id && my.exercices[current_exercice].keys)">
|
||||
<div class="card border-success mt-2" ng-if="my.exercices[current_exercice].video_uri">
|
||||
<div class="card-header bg-success text-white">
|
||||
<span class="glyphicon glyphicon-flag" aria-hidden="true"></span> Solution du challenge
|
||||
<span class="glyphicon glyphicon-blackboard" aria-hidden="true"></span> Solution du challenge
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>
|
||||
Vérifiez les clefs que vous trouvez en comparant leur <a href="https://blake2.net/">BLAKE2b</a> :
|
||||
</p>
|
||||
<dl class="dl-horizontal" ng-repeat="key in my.exercices[current_exercice].keys">
|
||||
<dt title="{{ key.slice(128) }}">{{ key.slice(128) }}</dt>
|
||||
<dd><samp class="cksum">{{ key.slice(0, 128) }}</samp></dd>
|
||||
</dl>
|
||||
<div class="embed-responsive embed-responsive-16by9">
|
||||
<iframe type="text/html" ng-if="my.exercices[current_exercice].video_uri" ng-src="{{ my.exercices[current_exercice].video_uri }}" class="embed-responsive-item">
|
||||
<iframe type="text/html" ng-src="{{ my.exercices[current_exercice].video_uri }}" class="embed-responsive-item">
|
||||
Regardez la vidéo de résolution de cet exercice : <a ng-href="{{ my.exercices[current_exercice].video_uri }}">{{ my.exercices[current_exercice].video_uri }}</a>.
|
||||
</iframe>
|
||||
</div>
|
||||
|
|
|
|||
Reference in a new issue