frontend: expose UCQ choices
This commit is contained in:
parent
c9152c90e6
commit
01368dd6f4
2 changed files with 15 additions and 2 deletions
|
@ -83,7 +83,8 @@
|
||||||
<form ng-controller="SubmissionController" ng-submit="ssubmit()">
|
<form ng-controller="SubmissionController" ng-submit="ssubmit()">
|
||||||
<div class="form-group" ng-repeat="(kid,key) in my.exercices[current_exercice].flags">
|
<div class="form-group" ng-repeat="(kid,key) in my.exercices[current_exercice].flags">
|
||||||
<label for="sol_{{ kid }}">{{ key.label }} :</label>
|
<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">
|
<input type="text" class="form-control" id="sol_{{ kid }}" autocomplete="off" name="sol_{{ kid }}" ng-model="key.value" ng-if="!key.found && !key.choices">
|
||||||
|
<select class="custom-select" id="sol_{{ kid }}" name="sol_{{ kid }}" ng-model="key.value" ng-if="!key.found && key.choices" ng-options="l as v for (l, v) in key.choices"></select>
|
||||||
<small class="form-text text-muted" ng-if="!key.found && 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>
|
<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>
|
</div>
|
||||||
|
|
|
@ -33,6 +33,7 @@ type myTeamFlag struct {
|
||||||
Help string `json:"help,omitempty"`
|
Help string `json:"help,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"`
|
||||||
}
|
}
|
||||||
type myTeamExercice struct {
|
type myTeamExercice struct {
|
||||||
ThemeId int `json:"theme_id"`
|
ThemeId int `json:"theme_id"`
|
||||||
|
@ -173,7 +174,18 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
flag.Label = k.Label
|
flag.Label = k.Label
|
||||||
flag.Help = k.Help
|
|
||||||
|
if flag.Solved == nil {
|
||||||
|
flag.Help = k.Help
|
||||||
|
if choices, err := k.GetChoices(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
flag.Choices = map[string]string{}
|
||||||
|
for _, c := range choices {
|
||||||
|
flag.Choices[c.Value] = c.Label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exercice.Flags[k.Id] = flag
|
exercice.Flags[k.Id] = flag
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue