2019-12-19 12:12:56 +01:00
|
|
|
{{- define "content" -}}
|
|
|
|
{{- $isAdmin := .Claims|isAdmin -}}
|
|
|
|
{{- $isParticipant := .Claims|isParticipant -}}
|
|
|
|
{{- $update := .Options.Get "update" -}}
|
|
|
|
<div class="container-fluid">
|
|
|
|
{{- if $isAdmin -}}
|
|
|
|
{{- if $update -}}
|
2019-12-18 11:49:52 +01:00
|
|
|
{{template "breadcrumb" toSlice "Prove" (all "Response") (.Data|string) (.Data.ID|show "Response") "Aggiorna" "current"}}
|
2019-12-19 12:12:56 +01:00
|
|
|
{{- else -}}
|
2019-12-18 11:49:52 +01:00
|
|
|
{{template "breadcrumb" toSlice "Prove" (all "Response") "Aggiungi" "current"}}
|
2019-12-19 12:12:56 +01:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if $isAdmin -}}
|
2019-12-19 07:38:10 +01:00
|
|
|
{{template "add_update_header" dict "update" $update "addTitle" "Rispondi al questionario" "updateTitle" (printf "Aggiorna %s" (.Data|string))}}
|
2019-12-19 12:12:56 +01:00
|
|
|
{{- else -}}
|
2019-12-19 07:38:10 +01:00
|
|
|
{{template "add_update_header" dict "update" $update "addTitle" "Rispondi al questionario" "updateTitle" (.Data|string)}}
|
2019-12-19 12:12:56 +01:00
|
|
|
{{- end -}}
|
|
|
|
{{- $form := "form_add_update" -}}
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-2 border-right">
|
|
|
|
<div class="sticky-top sticky-offset">
|
|
|
|
<nav class="nav flex-column">
|
2020-01-09 12:09:47 +01:00
|
|
|
{{- if and $isParticipant .Data.TimeLeft}}
|
|
|
|
<h5 class="mt-1 badge badge-info sticky-top sticky-offset">Tempo rimanente <span id="timeleft">{{.Data.TimeLeft.Minutes|toInt}}</span> min</h5>
|
|
|
|
{{- end -}}
|
2019-12-19 12:12:56 +01:00
|
|
|
{{range $n, $question := .Data.Questions -}}
|
|
|
|
<a class="nav-link" href="#question_{{$n}}">Domanda {{$n|incr}}</a>
|
|
|
|
{{end -}}
|
|
|
|
</nav>
|
2019-11-18 17:04:07 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-12-19 12:12:56 +01:00
|
|
|
<div class="col">
|
|
|
|
<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 -}}
|
2020-01-09 12:09:47 +01:00
|
|
|
<div class="oef-anchor" id="question_{{$id}}"></div>
|
|
|
|
<div class="oef-anchor-selection">
|
2019-12-19 12:12:56 +01:00
|
|
|
<div class="form-group p-3">
|
|
|
|
<p class="lead">{{$id|incr}}. {{$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>
|
|
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
{{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>
|
|
|
|
</div>
|
2019-11-18 17:04:07 +01:00
|
|
|
</div>
|
2019-12-19 12:12:56 +01:00
|
|
|
{{ end -}}
|