Aus Date und Time wurde DateTime gemacht und kleine Bugs behoben
This commit is contained in:
parent
224a99dec6
commit
c0f392938c
@ -18,10 +18,9 @@ CREATE TABLE instructors (
|
||||
|
||||
CREATE TABLE briefings (
|
||||
id INT AUTO_INCREMENT,
|
||||
date DATE NOT NULL,
|
||||
time TIME NOT NULL,
|
||||
datetime DATETIME NOT NULL,
|
||||
location VARCHAR(32) NOT NULL,
|
||||
document_name VARCHAR(16) NOT NULL,
|
||||
document VARCHAR(16) NOT NULL,
|
||||
as_of DATE NOT NULL,
|
||||
instructor_id INT NOT NULL,
|
||||
|
||||
@ -65,22 +64,22 @@ CREATE TABLE given_answers (
|
||||
INSERT INTO instructors
|
||||
(id, first_name, last_name)
|
||||
VALUES
|
||||
( '123456', 'Jason', 'Streifling' ),
|
||||
( '123457', 'Tim', 'Taler' ),
|
||||
( '123458', 'Georg', 'aus dem Jungel' );
|
||||
|
||||
INSERT INTO briefings (
|
||||
date, time, location, document_name, as_of, instructor_id
|
||||
) VALUES
|
||||
( '2023-10-16', '17:00:00', 'Werk Langenhagen', 'ICS-2021-LGH', '2021-02-01', '123456' ),
|
||||
( '2023-10-16', '17:05:00', 'Werk Langenhagen', 'ICS-2021-LGH', '2021-02-01', '123457' );
|
||||
|
||||
INSERT INTO participants (
|
||||
first_name, last_name, company
|
||||
) VALUES
|
||||
( 'Peter', 'Enis', 'Körber' ),
|
||||
( 'Dürüm', 'Döner', 'MP Technic' );
|
||||
( '100000', 'Jason', 'Streifling' ),
|
||||
( '100001', 'Peter', 'Enis' );
|
||||
|
||||
--INSERT INTO briefings (
|
||||
-- datetime, location, document, as_of, instructor_id
|
||||
--) VALUES
|
||||
-- ( '2023-10-16 17:00:00', 'Werk Langenhagen', 'ICL-1901-LGH', '2021-02-01', '100000' ),
|
||||
-- ( '2023-10-16 17:05:00', 'Werk Langenhagen', 'ICL-1901-LGH', '2021-02-01', '100001' );
|
||||
--
|
||||
--INSERT INTO participants (
|
||||
-- first_name, last_name, company
|
||||
--) VALUES
|
||||
-- ( 'Max', 'Mustermann', 'ABC GmbH' ),
|
||||
-- ( 'Gustav', 'Gans', 'ABC GmbH' ),
|
||||
-- ( 'Klara', 'Kakerlake', 'DEF KG' );
|
||||
--
|
||||
INSERT INTO questions (
|
||||
question, answer_1, answer_2, answer_3, answer_4, correct_answer
|
||||
) VALUES
|
||||
@ -88,15 +87,19 @@ INSERT INTO questions (
|
||||
( 'Was ist 1+2?', '1', '2', '3', '4', '3' ),
|
||||
( 'Was ist 2+2?', '1', '2', '3', '4', '4' ),
|
||||
( 'Was ist 0+1?', '1', '2', '3', '4', '1' );
|
||||
|
||||
INSERT INTO given_answers (
|
||||
briefing_id, participant_id, question_id, given_answer
|
||||
) VALUES
|
||||
( '1', '1', '1', '2' ),
|
||||
( '1', '1', '2', '3' ),
|
||||
( '1', '1', '3', '3' ),
|
||||
( '1', '1', '4', '1' ),
|
||||
( '2', '2', '1', '2' ),
|
||||
( '2', '2', '2', '3' ),
|
||||
( '2', '2', '3', '4' ),
|
||||
( '2', '2', '4', '1' );
|
||||
--
|
||||
--INSERT INTO given_answers (
|
||||
-- briefing_id, participant_id, question_id, given_answer
|
||||
--) VALUES
|
||||
-- ( '1', '1', '1', '2' ),
|
||||
-- ( '1', '1', '2', '3' ),
|
||||
-- ( '1', '1', '3', '3' ),
|
||||
-- ( '1', '1', '4', '1' ),
|
||||
-- ( '1', '2', '1', '2' ),
|
||||
-- ( '1', '2', '2', '3' ),
|
||||
-- ( '1', '2', '3', '3' ),
|
||||
-- ( '1', '2', '4', '1' ),
|
||||
-- ( '2', '3', '1', '2' ),
|
||||
-- ( '2', '3', '2', '3' ),
|
||||
-- ( '2', '3', '3', '4' ),
|
||||
-- ( '2', '3', '4', '1' );
|
||||
|
@ -21,10 +21,9 @@ type Participant struct {
|
||||
|
||||
type Briefing struct {
|
||||
ID int64
|
||||
Date string
|
||||
Time string
|
||||
DateTime string
|
||||
Location string
|
||||
DocumentName string
|
||||
Document string
|
||||
AsOf string
|
||||
InstructorID int64
|
||||
}
|
||||
@ -51,10 +50,9 @@ type GivenAnswer struct {
|
||||
type OverviewTableData struct {
|
||||
InstructorFirstName string
|
||||
InstructorLastName string
|
||||
BriefingDate string
|
||||
BriefingTime string
|
||||
BriefingDateTime string
|
||||
BriefingLocation string
|
||||
BriefingDocumentName string
|
||||
BriefingDocument string
|
||||
BriefingAsOf string
|
||||
ParticipantFirstName string
|
||||
ParticipantLastName string
|
||||
|
@ -33,12 +33,12 @@ func OpenDB(dbName string) (*DB, error) {
|
||||
func (db *DB) WriteBriefing(b *Briefing) error {
|
||||
query := `
|
||||
INSERT INTO briefings
|
||||
(date, time, location, document_name, as_of, instructor_id)
|
||||
(datetime, location, document, as_of, instructor_id)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?)
|
||||
(?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
result, err := db.Exec(query, b.Date, b.Time, b.Location, b.DocumentName, b.AsOf, b.InstructorID)
|
||||
result, err := db.Exec(query, b.DateTime, b.Location, b.Document, b.AsOf, b.InstructorID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error: *DB.writeBriefing: db.Exec(): %v", err)
|
||||
}
|
||||
@ -95,10 +95,9 @@ func (db *DB) GetAllOverviewTableData() ([]OverviewTableData, error) {
|
||||
SELECT
|
||||
i.first_name,
|
||||
i.last_name,
|
||||
b.date,
|
||||
b.time,
|
||||
b.datetime,
|
||||
b.location,
|
||||
b.document_name,
|
||||
b.document,
|
||||
b.as_of,
|
||||
p.first_name,
|
||||
p.last_name,
|
||||
@ -132,10 +131,9 @@ func (db *DB) GetAllOverviewTableData() ([]OverviewTableData, error) {
|
||||
err := rows.Scan(
|
||||
&otd.InstructorFirstName,
|
||||
&otd.InstructorLastName,
|
||||
&otd.BriefingDate,
|
||||
&otd.BriefingTime,
|
||||
&otd.BriefingDateTime,
|
||||
&otd.BriefingLocation,
|
||||
&otd.BriefingDocumentName,
|
||||
&otd.BriefingDocument,
|
||||
&otd.BriefingAsOf,
|
||||
&otd.ParticipantFirstName,
|
||||
&otd.ParticipantLastName,
|
||||
@ -156,10 +154,9 @@ func (db *DB) GetOverviewTableDataByName(n string) ([]OverviewTableData, error)
|
||||
SELECT
|
||||
i.first_name,
|
||||
i.last_name,
|
||||
b.date,
|
||||
b.time,
|
||||
b.datetime,
|
||||
b.location,
|
||||
b.document_name,
|
||||
b.document,
|
||||
b.as_of,
|
||||
p.first_name,
|
||||
p.last_name,
|
||||
@ -199,10 +196,9 @@ func (db *DB) GetOverviewTableDataByName(n string) ([]OverviewTableData, error)
|
||||
err := rows.Scan(
|
||||
&otd.InstructorFirstName,
|
||||
&otd.InstructorLastName,
|
||||
&otd.BriefingDate,
|
||||
&otd.BriefingTime,
|
||||
&otd.BriefingDateTime,
|
||||
&otd.BriefingLocation,
|
||||
&otd.BriefingDocumentName,
|
||||
&otd.BriefingDocument,
|
||||
&otd.BriefingAsOf,
|
||||
&otd.ParticipantFirstName,
|
||||
&otd.ParticipantLastName,
|
||||
@ -281,8 +277,12 @@ func (db *DB) GetQuestions(nums []string) ([]Question, error) {
|
||||
questions := make([]Question, 0)
|
||||
for rows.Next() {
|
||||
q := Question{Answers: make([]Answer, 4)}
|
||||
q.Answers[0].ID = 1
|
||||
q.Answers[1].ID = 2
|
||||
q.Answers[2].ID = 3
|
||||
q.Answers[3].ID = 4
|
||||
|
||||
if err := rows.Scan(&q.ID, &q.Text, &q.Answers[0], &q.Answers[1], &q.Answers[2], &q.Answers[3], &q.Correct); err != nil {
|
||||
if err := rows.Scan(&q.ID, &q.Text, &q.Answers[0].Text, &q.Answers[1].Text, &q.Answers[2].Text, &q.Answers[3].Text, &q.Correct); err != nil {
|
||||
return nil, fmt.Errorf("error: *DB.GetQuestions: rows.Scan(): %v", err)
|
||||
}
|
||||
|
||||
|
@ -92,12 +92,9 @@ func (s *Session) HandleNewParticipant(cp chan<- *BriefingParticipant) http.Hand
|
||||
|
||||
func (s *Session) HandleBriefingForm(db *data.DB) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
now := time.Now()
|
||||
|
||||
s.Date = now.Format("2006-01-02")
|
||||
s.Time = now.Format("15:04:05")
|
||||
s.DateTime = time.Now().Format("2006-01-02 15:04:05")
|
||||
s.Location = r.PostFormValue("location")
|
||||
s.DocumentName = r.PostFormValue("document")
|
||||
s.Document = r.PostFormValue("document")
|
||||
s.AsOf = r.PostFormValue("as-of")
|
||||
|
||||
err := db.WriteBriefing(s.Briefing)
|
||||
|
@ -60,6 +60,8 @@ func makeHTMLQuestions(sq []data.Question, givenAnswers []int) []resultQuestion
|
||||
questions[i].Answers = make([]resultAnswer, len(q.Answers))
|
||||
|
||||
for j := range q.Answers {
|
||||
questions[i].Answers[j].Text = q.Answers[j].Text
|
||||
|
||||
if j+1 == q.Correct {
|
||||
questions[i].Answers[j].Correct = true
|
||||
} else {
|
||||
|
@ -4,7 +4,7 @@
|
||||
{{end}}
|
||||
|
||||
{{define "retry"}}
|
||||
<button hx-post="/allow-retry/{{.SessionID}}/{{.Login}}/" type="button">Wiederholen erlauben</button>
|
||||
<button hx-post="/allow-retry/{{.SessionID}}/{{.Login}}/" hx-swap="delete" type="button">Wiederholen erlauben</button>
|
||||
{{end}}
|
||||
|
||||
{{define "participant"}}
|
||||
@ -18,6 +18,7 @@
|
||||
{{if lt .NoIncorrect 0}}
|
||||
{{template "refresh" .}}
|
||||
{{else if gt .NoIncorrect 0}}
|
||||
<p>{{.NoIncorrect}} Fehler</p>
|
||||
{{template "retry" .}}
|
||||
{{template "refresh" .}}
|
||||
{{else}}
|
||||
|
@ -3,10 +3,9 @@
|
||||
<tr>
|
||||
<td>{{.InstructorFirstName}}</td>
|
||||
<td>{{.InstructorLastName}}</td>
|
||||
<td>{{.BriefingDate}}</td>
|
||||
<td>{{.BriefingTime}}</td>
|
||||
<td>{{.BriefingDateTime}}</td>
|
||||
<td>{{.BriefingLocation}}</td>
|
||||
<td>{{.BriefingDocumentName}}</td>
|
||||
<td>{{.BriefingDocument}}</td>
|
||||
<td>{{.BriefingAsOf}}</td>
|
||||
<td>{{.ParticipantFirstName}}</td>
|
||||
<td>{{.ParticipantLastName}}</td>
|
||||
@ -32,8 +31,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2">Unterweiser</th>
|
||||
<th>Datum</th>
|
||||
<th>Uhrzeit</th>
|
||||
<th>Datum & Uhrzeit</th>
|
||||
<th>Ort</th>
|
||||
<th>Dokument</th>
|
||||
<th>Stand</th>
|
||||
|
Loading…
x
Reference in New Issue
Block a user