New field for exercice to display a text after exercice validation
This commit is contained in:
parent
87471acf98
commit
21697f01ca
9 changed files with 43 additions and 18 deletions
|
@ -148,6 +148,10 @@ func partUpdateExercice(exercice fic.Exercice, body []byte) (interface{}, error)
|
|||
exercice.Headline = ue.Headline
|
||||
}
|
||||
|
||||
if len(ue.Finished) > 0 {
|
||||
exercice.Finished = ue.Finished
|
||||
}
|
||||
|
||||
if len(ue.Overview) > 0 {
|
||||
exercice.Overview = ue.Overview
|
||||
}
|
||||
|
@ -203,7 +207,7 @@ func createExercice(theme fic.Theme, body []byte) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
return theme.AddExercice(ue.Title, ue.URLId, ue.Path, ue.Statement, ue.Overview, ue.Headline, depend, ue.Gain, ue.VideoURI)
|
||||
return theme.AddExercice(ue.Title, ue.URLId, ue.Path, ue.Statement, ue.Overview, ue.Headline, depend, ue.Gain, ue.VideoURI, ue.Finished)
|
||||
}
|
||||
|
||||
type uploadedHint struct {
|
||||
|
|
|
@ -1044,7 +1044,7 @@ angular.module("FICApp")
|
|||
$scope.exercice = Exercice.get({ exerciceId: $routeParams.exerciceId });
|
||||
}
|
||||
$scope.exercices = Exercice.query();
|
||||
$scope.fields = ["title", "urlid", "statement", "headline", "overview", "depend", "gain", "coefficient", "videoURI", "issue", "issuekind"];
|
||||
$scope.fields = ["title", "urlid", "statement", "headline", "overview", "finished", "depend", "gain", "coefficient", "videoURI", "issue", "issuekind"];
|
||||
|
||||
$scope.showTags = false;
|
||||
$scope.toggleTags = function(val) {
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
<div class="form-group row" ng-repeat="field in fields">
|
||||
<label for="{{ field }}" class="col-sm-1 col-form-label-sm">{{ field | capitalize }}</label>
|
||||
<div class="col-sm-11">
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="exercice[field]" ng-if="field != 'statement' && field != 'issue' && field != 'issuekind' && field != 'overview' && field != 'depend' && field != 'gain' && field != 'coefficient'">
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="exercice[field]" ng-if="field != 'statement' && field != 'issue' && field != 'issuekind' && field != 'overview' && field != 'finished' && field != 'depend' && field != 'gain' && field != 'coefficient'">
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="exercice[field]" ng-if="field == 'gain'" integer>
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="exercice[field]" ng-if="field == 'coefficient'" float>
|
||||
<textarea class="form-control form-control-sm" id="{{field}}" ng-model="exercice[field]" ng-if="field == 'statement' || field == 'overview' || field == 'issue'"></textarea>
|
||||
<textarea class="form-control form-control-sm" id="{{field}}" ng-model="exercice[field]" ng-if="field == 'statement' || field == 'overview' || field == 'finished' || field == 'issue'"></textarea>
|
||||
<select class="form-control form-control-sm" id="{{field}}" ng-model="exercice[field]" ng-options="ex.id as ex.title group by ex.path.split('/')[0] for ex in exercices" ng-if="field == 'depend'">
|
||||
<option value="">Aucune</option>
|
||||
</select>
|
||||
|
|
|
@ -10,6 +10,7 @@ Tous les textes doivent utiliser l'encodage UTF8.
|
|||
* Un dossier par challenge : `CHID-Titre du challenge` (avec `CHID` l'identifiant numérique du challenge, typiquement son numéro d'ordre), contenant :
|
||||
+ `overview.txt` une présentation rapide du challenge (~1-2 phrases d'accroche), compréhensible par un décideur, petit schéma à l'appui si besoin
|
||||
+ `statement.txt` contenant le scénario du challenge, tel qu'il sera affiché sur le site, à destination des participants
|
||||
+ `finished.txt` (facultatif) contenant un texte affiché au participant ayant validé l'exercice : par exemple pour donner plus d'informations sur les vulnérabilités rencontrées
|
||||
+ `challenge.txt` définitions des paramètres de votre challenge (au format [toml](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md)) :
|
||||
- `gain = 42` : nombre de points que rapporte cet exercice ;
|
||||
- `tags = ["Android", "RAT", "ROM"]` : mots-clefs de l'exercice ;
|
||||
|
|
|
@ -71,6 +71,15 @@ func SyncExercices(i Importer, theme fic.Theme) []string {
|
|||
continue
|
||||
}
|
||||
|
||||
var finished string
|
||||
if i.exists(path.Join(theme.Path, edir, "finished.txt")) {
|
||||
finished, err = getFileContent(i, path.Join(theme.Path, edir, "finished.txt"))
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: statement.txt: %s", edir, err))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// Handle score gain
|
||||
var gain int64
|
||||
var depend *fic.Exercice
|
||||
|
@ -117,19 +126,21 @@ func SyncExercices(i Importer, theme fic.Theme) []string {
|
|||
statement = ProcessMarkdown(i, statement, edir)
|
||||
overview = ProcessMarkdown(i, overview, edir)
|
||||
headline = string(blackfriday.Run([]byte(headline)))
|
||||
finished = ProcessMarkdown(i, finished, edir)
|
||||
|
||||
e, err := theme.GetExerciceByTitle(ename)
|
||||
if err != nil {
|
||||
if e, err = theme.AddExercice(ename, fic.ToURLid(ename), path.Join(theme.Path, edir), statement, overview, headline, depend, gain, videoURI); err != nil {
|
||||
if e, err = theme.AddExercice(ename, fic.ToURLid(ename), path.Join(theme.Path, edir), statement, overview, headline, depend, gain, videoURI, finished); err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: error on exercice add: %s", edir, err))
|
||||
continue
|
||||
}
|
||||
} else if e.Title != ename || e.URLId == "" || e.Statement != statement || e.Overview != overview || e.Headline != headline || e.Gain != gain || e.VideoURI != videoURI {
|
||||
} else if e.Title != ename || e.URLId == "" || e.Statement != statement || e.Overview != overview || e.Headline != headline || e.Gain != gain || e.VideoURI != videoURI || e.Finished != finished {
|
||||
e.Title = ename
|
||||
e.URLId = fic.ToURLid(ename)
|
||||
e.Statement = statement
|
||||
e.Overview = overview
|
||||
e.Headline = headline
|
||||
e.Finished = finished
|
||||
e.Gain = gain
|
||||
e.VideoURI = videoURI
|
||||
if _, err := e.Update(); err != nil {
|
||||
|
|
Reference in a new issue