Noch ein Bisschen aufgeräumt

This commit is contained in:
2023-10-19 15:22:45 +02:00
parent 39d8108521
commit 5019432b24
3 changed files with 46 additions and 100 deletions

View File

@ -7,19 +7,18 @@ import (
"html/template"
"net/http"
"strconv"
"strings"
"time"
"streifling.com/jason/sicherheitsunterweisung/packages/data"
"streifling.com/jason/sicherheitsunterweisung/packages/types"
)
type questionData struct {
ID int64
Q types.Question
I int
J int
}
// type questionData struct {
// ID int64
// Q types.Question
// I int
// J int
// }
func DisplayTable(db *data.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
@ -48,7 +47,7 @@ func DisplayInstructorForm() http.HandlerFunc {
}
func generateUUID() (string, error) {
bs := make([]byte, 2)
bs := make([]byte, 4)
if _, err := rand.Read(bs); err != nil {
return "", fmt.Errorf("GenerateUUID: rand.Read(bs): %v\n", err)
@ -71,7 +70,7 @@ func AddParticipant(sl *[]string) http.HandlerFunc {
// TODO: Hier weiter machen, irgendwie die b.ID herausgeben,
// am besten hier auch die p.IDs rausgeben, damit diese später verknüpft werden können
func SubmitBriefingForm(sb *[]*types.Briefing) http.HandlerFunc {
func SubmitBriefingForm(db *data.DB, sl *[]string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
now := time.Now()
briefing := new(types.Briefing)
@ -86,7 +85,8 @@ func SubmitBriefingForm(sb *[]*types.Briefing) http.HandlerFunc {
briefing.DocumentName = r.PostFormValue("document") // TODO: in HTML einfügen
briefing.AsOf = r.PostFormValue("state") // TODO: Umbenennen
// briefing.InstructorID = r.PostFormValue("instructor-id") // TODO: aus Dropdown holen
(*sb) = append(*sb, briefing)
db.WriteBriefing(briefing)
}
}
@ -105,7 +105,7 @@ func newParticipant(l string) (*types.Participant, error) {
var err error
p := new(types.Participant)
p.ID, err = strconv.ParseInt(strings.Split(l, "-")[0], 10, 64)
p.ID, err = strconv.ParseInt(l, 10, 64)
if err != nil {
return nil, fmt.Errorf("newParticipant: strconv.Atoi(idString): %v\n", err)
}