Der Umstieg auf Sessions ist weitgehend geglückt

This commit is contained in:
2023-10-28 08:01:34 +02:00
parent aded71394d
commit 5049db064c
11 changed files with 396 additions and 225 deletions

View File

@ -1,10 +1,10 @@
{{ define "add-buttons" }}
<div id="briefing-buttons">
<button type="button" hx-post="/add-participant-{{ .SessionID }}/" hx-target="#briefing-buttons" hx-swap="outerHTML">
<button type="button" hx-post="/new-participant/{{ .SessionID }}/" hx-target="#briefing-buttons" hx-swap="outerHTML">
Neuer Teilnehmer
</button>
<button type="submit" hx-post="/submit-form-{{ .SessionID }}/" hx-target="#content" hx-swap="innerHTML">
<button type="submit" hx-post="/submit-form/{{ .SessionID }}/" hx-target="#content" hx-swap="innerHTML">
Fertig
</button>
</div>
@ -17,28 +17,19 @@
{{ define "content" }}
<form>
<div id="instructor">
<label for="instructor">Unterweiser</label>
<select id="instructor" name="instructor">
{{ range .Options }}
<option value="{{ .ID }}">{{ .String }}</option>
{{ end }}
</select>
</div>
<div id="location">
<div>
<label for="location">Ort</label>
<input type="text" name="location" id="location" />
<input id="location" name="location" required type="text" />
</div>
<div id="document-name">
<label for="document-name">Dokument</label>
<input type="text" name="document-name" id="document-name" />
<div>
<label for="document">Dokument</label>
<input id="document" name="document" required type="text" />
</div>
<div id="state">
<div>
<label for="as-of">Stand vom</label>
<input type="date" name="as-of" id="as-of" />
<input id="as-of" name="as-of" required type="date" />
</div>
{{ template "add-buttons" . }}

View File

@ -1,16 +1,17 @@
{{ define "content" }}
<h2>Login</h2>
<h2>Anmeldung</h2>
<form>
<label for="login-input">Code</label>
<input type="text" name="login" id="login-input" />
<input autocomplete="off" id="login-input" name="login" placeholder="Code" required type="text" />
<button type="submit" hx-post="/external-login/" hx-target="#content">
Anmelden
</button>
<div>
<button type="submit" hx-post="/internal-login/" hx-target="#content">
Intern
</button>
<button type="submit" hx-post="/internal-login/" hx-target="#content">
Intern
</button>
<button type="submit" hx-post="/external-login/" hx-target="#content">
Gast
</button>
</div>
</form>
{{ end }}

View File

@ -1,15 +1,15 @@
{{ define "content" }}
<form id="participant-{{ . }}">
<label for="participant-first-input-{{ . }}">Vorname</label>
<input type="text" name="participant-first-{{ . }}" id="participant-first-input-{{ . }}" />
<form>
<label for="first-{{ .Login }}">Vorname</label>
<input type="text" name="first-{{ .Login }}" id="first-{{ .Login }}" />
<label for="participant-last-input-{{ . }}">Nachname</label>
<input type="text" name="participant-last-{{ . }}" id="participant-last-input-{{ . }}" />
<label for="last-{{ .Login }}">Nachname</label>
<input type="text" name="last-{{ .Login }}" id="last-{{ .Login }}" />
<label for="participant-company-input-{{ . }}">Firma</label>
<input type="text" name="participant-company-{{ . }}" id="participant-company-input-{{ . }}" />
<label for="company-{{ .Login }}">Firma</label>
<input type="text" name="company-{{ .Login }}" id="company-{{ .Login }}" />
<button type="button" hx-post="/display-question-{{ . }}-0/" hx-target="#content">
<button type="button" hx-post="/submit-participant/{{ .SessionID }}/{{ .Login }}/" hx-target="#content">
Fertig
</button>
</form>

View File

@ -1,21 +1,21 @@
{{ define "answers" }}
{{ range .Q.Answers }}
{{define "answers"}}
{{range .Question.Answers}}
<div>
<input type="radio" name="answer" id="answer-{{ .ID }}" value="{{ .ID }}" />
<label for="answer-{{ .ID }}">{{ .Text }}</label>
<input type="radio" name="answer" id="answer-{{.ID}}" value="{{.ID}}" />
<label for="answer-{{.ID}}">{{.Text}}</label>
</div>
{{ end }}
{{ end }}
{{end}}
{{end}}
{{ define "content" }}
<h2>Frage {{ .I }}</h2>
<p>{{ .Q.Text }}</p>
{{define "content"}}
<h2>Frage {{.QuestionID}}</h2>
<p>{{.Question.Text}}</p>
<form>
{{ template "answers" . }}
{{template "answers" .}}
<button type="submit" hx-post="/display-question-{{ .ID }}-{{ .J }}/" hx-target="#content" hx-swap="innerHTML">
<button hx-post="/submit-answer/{{.SessionID}}/{{.Login}}/{{.QuestionID}}/" hx-target="#content" type="submit">
Weiter
</button>
</form>
{{ end }}
{{end}}

View File

@ -1,11 +1,18 @@
{{ define "passed" }}
{{ end }}
{{define "answers"}}
{{range .Answers}}
<p class="{{if and .Chosen .Correct}} correct {{else if and .Chosen (not .Correct)}} incorrect {{end}}">
{{.Text}}
</p>
{{end}}
{{end}}
{{ define "failed" }}
{{ end }}
{{ define "content" }}
{{ q := range .Participant.Questions }}
<p>{{ . }}{{ q.Text }}</p>
{{ end }}
{{ end }}
{{define "content"}}
<p>{{.Incorrect}} Fehler</p>
{{range .Questions}}
<p>{{.Text}}</p>
{{template "answers" .}}
{{end}}
{{if gt .Incorrect 0}}
<button hx-post="/retry/{{.SessionID}}/{{.Login}}/" hx-target="#content" type="submit">Wiederholen</button>
{{end}}
{{end}}