Aus Date und Time wurde DateTime gemacht und kleine Bugs behoben

This commit is contained in:
2023-11-01 13:11:50 +01:00
parent 224a99dec6
commit c0f392938c
7 changed files with 62 additions and 63 deletions

View File

@ -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

View File

@ -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)
}