Theme can be optional: exercices can be standalone
This commit is contained in:
parent
3519f7416d
commit
a0bc832910
8 changed files with 81 additions and 39 deletions
|
|
@ -140,7 +140,7 @@ CREATE TABLE IF NOT EXISTS team_members(
|
|||
if _, err := db.Exec(`
|
||||
CREATE TABLE IF NOT EXISTS exercices(
|
||||
id_exercice INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
id_theme INTEGER NOT NULL,
|
||||
id_theme INTEGER NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
authors TEXT NOT NULL,
|
||||
image VARCHAR(255) NOT NULL,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ var ExerciceCurrentCoefficient = 1.0
|
|||
// Exercice represents a challenge inside a Theme.
|
||||
type Exercice struct {
|
||||
Id int64 `json:"id"`
|
||||
IdTheme int64 `json:"id_theme"`
|
||||
IdTheme *int64 `json:"id_theme"`
|
||||
Language string `json:"lang,omitempty"`
|
||||
Title string `json:"title"`
|
||||
Authors string `json:"authors"`
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ type myTeamMCQJustifiedChoice struct {
|
|||
Justification myTeamFlag `json:"justification,omitempty"`
|
||||
}
|
||||
type myTeamExercice struct {
|
||||
ThemeId int64 `json:"theme_id"`
|
||||
ThemeId int64 `json:"theme_id,omitempty"`
|
||||
Disabled bool `json:"disabled,omitempty"`
|
||||
WIP bool `json:"wip,omitempty"`
|
||||
Statement string `json:"statement"`
|
||||
|
|
@ -136,11 +136,11 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||
return ret, err
|
||||
} else if started {
|
||||
for _, e := range exos {
|
||||
if t == nil || ((!e.Disabled || !mapthemes[e.IdTheme].Locked) && t.HasAccess(e)) {
|
||||
if t == nil || ((!e.Disabled || (e.IdTheme != nil && !mapthemes[*e.IdTheme].Locked)) && t.HasAccess(e)) {
|
||||
exercice := myTeamExercice{}
|
||||
exercice.Disabled = e.Disabled
|
||||
exercice.WIP = e.WIP
|
||||
exercice.ThemeId = e.IdTheme
|
||||
exercice.ThemeId = *e.IdTheme
|
||||
|
||||
exercice.Statement = strings.Replace(e.Statement, "$FILES$", FilesDir, -1)
|
||||
|
||||
|
|
|
|||
|
|
@ -393,7 +393,9 @@ func (t *Team) MyIssueFile() (ret []teamIssueFile, err error) {
|
|||
|
||||
if exo, err := claim.GetExercice(); err == nil && exo != nil {
|
||||
exercice = &exo.Title
|
||||
if theme, err := GetTheme(exo.IdTheme); err == nil {
|
||||
if exo.IdTheme == nil {
|
||||
url = path.Join("_", exo.URLId)
|
||||
} else if theme, err := GetTheme(*exo.IdTheme); err == nil {
|
||||
url = path.Join(theme.URLId, exo.URLId)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue