Aus Date und Time wurde DateTime gemacht und kleine Bugs behoben
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user