Sessions vollständig implementiert

This commit is contained in:
2023-10-30 11:38:56 +01:00
parent 33cbf4b215
commit ba53bba0f6
13 changed files with 257 additions and 162 deletions

View File

@ -4,8 +4,8 @@
Neuer Teilnehmer
</button>
<button type="submit" hx-post="/submit-form/{{.SessionID}}/" hx-target="#content" hx-swap="innerHTML">
Fertig
<button type="submit" hx-post="/submit-form/{{.SessionID}}/" hx-target="#content">
Weiter
</button>
</div>
{{end}}
@ -19,17 +19,17 @@
<form>
<div>
<label for="location">Ort</label>
<input id="location" name="location" required type="text" />
<input id="location" name="location" required type="text" value="Werk Langenhagen" />
</div>
<div>
<label for="document">Dokument</label>
<input id="document" name="document" required type="text" />
<input id="document" name="document" required type="text" value="ICL-1901-LGH" />
</div>
<div>
<label for="as-of">Stand vom</label>
<input id="as-of" name="as-of" required type="date" />
<input id="as-of" name="as-of" required type="date" value="2021-02-01" />
</div>
{{template "add-buttons" .}}

View File

@ -7,12 +7,13 @@
{{end}}
{{define "content"}}
<p>{{.Incorrect}} Fehler</p>
<p>{{.BriefingParticipant.NoIncorrect}} Fehler</p>
{{if gt .BriefingParticipant.NoIncorrect 0}}
<p>Bitte nachschulen lassen und anschließend wiederholen.</p>
<button hx-post="/retry/{{.SessionID}}/{{.Login}}/" hx-target="#content" type="submit">Wiederholen</button>
{{end}}
{{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}}

35
templates/summary.html Normal file
View File

@ -0,0 +1,35 @@
{{define "refresh"}}
<button hx-post="/refresh-summary/{{.SessionID}}/{{.Login}}/" hx-target="#id-{{.Login}}"
type="button">Aktualisieren</button>
{{end}}
{{define "retry"}}
<button hx-post="/allow-retry/{{.SessionID}}/{{.Login}}/" type="button">Wiederholen erlauben</button>
{{end}}
{{define "participant"}}
<div id="id-{{.Login}}">
<h2>{{.Login}}</h2>
{{if not .LastName}}
{{template "refresh" .}}
{{else}}
<p>{{.FirstName}} {{.LastName}}</p>
<p>{{.Company}}</p>
{{if lt .NoIncorrect 0}}
{{template "refresh" .}}
{{else if gt .NoIncorrect 0}}
{{template "retry" .}}
{{template "refresh" .}}
{{else}}
<p>{{.NoIncorrect}} Fehler</p>
{{end}}
{{end}}
</div>
{{end}}
{{define "content"}}
<button hx-post="/briefing-done/{{.SessionID}}/" hx-target="#content" type="button">Beenden</button>
{{range .ParticipantsData}}
{{template "participant" .}}
{{end}}
{{end}}

View File

@ -18,11 +18,11 @@
{{define "content"}}
<form>
<label for="search-input">Suche</label>
<input type="text" name="search" id="search-input" hx-post="/search/" hx-target="#results">
<input type="text" name="search" id="search-input" hx-post="/search/{{.SessionID}}/" hx-target="#results">
</form>
<form>
<button type="submit" hx-post="/new-briefing/{{.SessionID}}" hx-target="#content">
<button type="submit" hx-post="/new-briefing/{{.SessionID}}/" hx-target="#content">
Neue Unterweisung
</button>
</form>