frontend: expose UCQ choices
This commit is contained in:
parent
c9152c90e6
commit
01368dd6f4
|
@ -83,7 +83,8 @@
|
|||
<form ng-controller="SubmissionController" ng-submit="ssubmit()">
|
||||
<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">
|
||||
<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>
|
||||
<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>
|
||||
|
|
|
@ -33,6 +33,7 @@ type myTeamFlag struct {
|
|||
Help string `json:"help,omitempty"`
|
||||
Solved *time.Time `json:"found,omitempty"`
|
||||
Soluce string `json:"soluce,omitempty"`
|
||||
Choices map[string]string `json:"choices,omitempty"`
|
||||
}
|
||||
type myTeamExercice struct {
|
||||
ThemeId int `json:"theme_id"`
|
||||
|
@ -173,7 +174,18 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user