65 lines
2.1 KiB
Smarty
65 lines
2.1 KiB
Smarty
{{ define "content" }}
|
|
|
|
{{$isAdmin := .Claims|isAdmin}}
|
|
{{$isParticipant := .Claims|isParticipant}}
|
|
{{$update := .Options.Get "update"}}
|
|
|
|
<div class="container">
|
|
{{if $isAdmin}}
|
|
|
|
{{if $update}}
|
|
|
|
{{template "breadcrumb" toSlice "Prove" (all "Response") (.Data|string) (.Data.ID|show "Response") "Aggiorna" "current"}}
|
|
{{else}}
|
|
{{template "breadcrumb" toSlice "Prove" (all "Response") "Aggiungi" "current"}}
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{if $isAdmin}}
|
|
{{template "add_update_header" dict "update" $update "addTitle" "Rispondi al questionario" "updateTitle" (printf "Aggiorna %s" (.Data|string))}}
|
|
{{else}}
|
|
{{template "add_update_header" dict "update" $update "addTitle" "Rispondi al questionario" "updateTitle" (.Data|string)}}
|
|
{{end}}
|
|
{{$form := "form_add_update"}}
|
|
<form
|
|
class="needs-validation"
|
|
action="{{if $update}}{{.Data.ID|update "Response"}}{{else}}{{create "Response"}}{{end}}"
|
|
method="POST"
|
|
role="form"
|
|
id={{$form}}>
|
|
|
|
{{range $id,$question := .Data.Questions}}
|
|
<div class="form-group p-3">
|
|
<p class="lead">{{$question.Text}}</p>
|
|
{{range $answer := $question.Answers}}
|
|
<div class="form-check">
|
|
{{$checked := false}}
|
|
{{if isResponseIn $answer.ID $.Data.AnswersIDs}}
|
|
{{$checked = true}}
|
|
{{end}}
|
|
<input class="form-check-input" type="radio" name="SingleResponses.{{$id}}" id="answer_{{$answer.ID}}" value="{{$answer.ID}}" required {{if $checked}}checked{{end}}>
|
|
<label class="form-check-label {{if and $isAdmin $answer.Correct}}text-success{{end}}" for="answer_{{$answer.ID}}">
|
|
{{$answer}}
|
|
</label>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if $isAdmin}}
|
|
|
|
{{$options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Response" } `}}
|
|
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
|
|
|
|
{{else}}
|
|
|
|
{{$options := ` { saveTitle: "Invia le risposte", model: "Response" } `}}
|
|
{{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
|
|
|
|
{{end}}
|
|
|
|
</form>
|
|
|
|
</div>
|
|
{{ end }}
|