libfic: add function to get exercice by title
This commit is contained in:
parent
2c25d917b3
commit
5fbeefd97b
1 changed files with 9 additions and 0 deletions
|
@ -36,6 +36,15 @@ func (t Theme) GetExercice(id int) (Exercice, error) {
|
|||
return e, nil
|
||||
}
|
||||
|
||||
func (t Theme) GetExerciceByTitle(title string) (Exercice, error) {
|
||||
var e Exercice
|
||||
if err := DBQueryRow("SELECT id_exercice, title, path, statement, depend, gain, coefficient_cur, video_uri FROM exercices WHERE id_theme = ? AND title = ?", t.Id, title).Scan(&e.Id, &e.Title, &e.Path, &e.Statement, &e.Depend, &e.Gain, &e.Coefficient, &e.VideoURI); err != nil {
|
||||
return Exercice{}, err
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
func GetExercices() ([]Exercice, error) {
|
||||
if rows, err := DBQuery("SELECT id_exercice, title, path, statement, depend, gain, coefficient_cur, video_uri FROM exercices"); err != nil {
|
||||
return nil, err
|
||||
|
|
Reference in a new issue