libfic: add new functions to retrieve the Id of some contents from Title, Label, ...
This commit is contained in:
parent
fbae34ee4f
commit
698c2f1a47
4 changed files with 30 additions and 0 deletions
|
|
@ -102,6 +102,15 @@ func (m MCQ) GetId() int64 {
|
|||
return m.Id
|
||||
}
|
||||
|
||||
// RecoverId returns the MCQ identifier as register in DB.
|
||||
func (m MCQ) RecoverId() (Flag, error) {
|
||||
if err := DBQueryRow("SELECT id_mcq FROM exercice_mcq WHERE title LIKE ? AND id_exercice = ?", m.Title, m.IdExercice).Scan(&m.Id); err != nil {
|
||||
return MCQ{}, err
|
||||
} else {
|
||||
return m, err
|
||||
}
|
||||
}
|
||||
|
||||
// Create registers a MCQ into the database and recursively add its entries.
|
||||
func (m MCQ) Create(e Exercice) (Flag, error) {
|
||||
if res, err := DBExec("INSERT INTO exercice_mcq (id_exercice, title) VALUES (?, ?)", e.Id, m.Title); err != nil {
|
||||
|
|
|
|||
Reference in a new issue