oef/templates/responses_add_update.html.tpl

62 lines
1.9 KiB
Smarty
Raw Normal View History

2019-11-18 17:04:07 +01:00
{{ define "content" }}
2019-12-18 10:46:39 +01:00
{{$isAdmin := .Claims|isAdmin}}
{{$isParticipant := .Claims|isParticipant}}
{{$update := .Options.Get "update"}}
<div class="container">
{{if $isAdmin}}
2019-11-18 17:04:07 +01:00
{{if $update}}
{{template "breadcrumb" toSlice "Prove" (all "Response") (.Data|string) (.Data.ID|show "Response") "Aggiorna" "current"}}
2019-11-18 17:04:07 +01:00
{{else}}
{{template "breadcrumb" toSlice "Prove" (all "Response") "Aggiungi" "current"}}
2019-11-18 17:04:07 +01:00
{{end}}
{{end}}
{{template "add_update_header" dict "update" $update "addTitle" "Rispondi al questionario" "updateTitle" (printf "Aggiorna le tue risposte %s" (.Data|string))}}
{{$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}}>
2019-12-18 09:47:37 +01:00
{{range $id,$question := .Data.Questions}}
2019-11-18 17:04:07 +01:00
<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 $answer.Correct}}text-success{{end}}" for="answer_{{$answer.ID}}">
2019-11-18 17:04:07 +01:00
{{$answer}}
</label>
</div>
{{end}}
</div>
{{end}}
2019-12-18 10:46:39 +01:00
{{if $isAdmin}}
2019-11-18 17:04:07 +01:00
{{$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 }}