diff --git a/Dockerfile-repochecker b/Dockerfile-repochecker index 1cb14f26..8f74b1ad 100644 --- a/Dockerfile-repochecker +++ b/Dockerfile-repochecker @@ -23,7 +23,7 @@ RUN go get -d -v ./repochecker && \ ENV GRAMMALECTE_VERSION 2.1.1 -ADD https://grammalecte.net/zip/Grammalecte-fr-v$GRAMMALECTE_VERSION.zip /srv/grammalecte.zip +ADD https://web.archive.org/web/20240926154729if_/https://grammalecte.net/zip/Grammalecte-fr-v$GRAMMALECTE_VERSION.zip /srv/grammalecte.zip RUN mkdir /srv/grammalecte && cd /srv/grammalecte && unzip /srv/grammalecte.zip && sed -i 's/if sys.version_info.major < (3, 7):/if False:/' /srv/grammalecte/grammalecte-server.py diff --git a/qa/api/todo.go b/qa/api/todo.go index 53a40878..37987766 100644 --- a/qa/api/todo.go +++ b/qa/api/todo.go @@ -242,10 +242,13 @@ func deleteQATodo(c *gin.Context) { } type QAAssignWork struct { - Turns int `json:"turns"` - Start int `json:"start"` - TeamPrefix string `json:"team_prefix"` - TeamAssistants string `json:"team_assistants"` + Turns int `json:"turns"` + Start int `json:"start"` + TeamPrefix string `json:"team_prefix"` + TeamAssistants string `json:"team_assistants"` + OnlyExercices bool `json:"only_exercices"` + WithoutStandaloneExercices bool `json:"without_standalone_exercices"` + WithoutThemes bool `json:"without_themes"` } func assignWork(c *gin.Context) { @@ -279,19 +282,80 @@ func assignWork(c *gin.Context) { } } - exercices, err := fic.GetExercices() - if err != nil { - log.Println("Unable to GetExercices: ", err.Error()) - c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to list exercices: %s", err.Error())}) - return + var themes []*fic.Theme + if !uaw.OnlyExercices && !uaw.WithoutThemes { + themes, err = fic.GetThemes() + if err != nil { + log.Println("Unable to GetThemes: ", err.Error()) + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to list themes: %s", err.Error())}) + return + } + } + + var exercices []*fic.Exercice + if uaw.OnlyExercices { + exercices, err = fic.GetExercices() + if err != nil { + log.Println("Unable to GetExercices: ", err.Error()) + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to list exercices: %s", err.Error())}) + return + } + if uaw.WithoutStandaloneExercices || uaw.WithoutThemes { + for i := len(exercices) - 1; i >= 0; i-- { + if (exercices[i].IdTheme == nil && uaw.WithoutStandaloneExercices) || (exercices[i].IdTheme != nil && uaw.WithoutThemes) { + exercices = append(exercices[:i], exercices[i+1:]...) + } + } + } + } else if !uaw.WithoutStandaloneExercices { + exercices, err = (&fic.Theme{URLId: "_", Path: "exercices"}).GetExercices() + if err != nil { + log.Println("Unable to GetStandaloneExercices: ", err.Error()) + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": fmt.Sprintf("Unable to list exercices: %s", err.Error())}) + return + } } // Struct to store reported team (due to owned exercice) var teamIdStack []int64 for i := 0; i < uaw.Turns; i++ { + lasttid := 0 + for tid, theme := range themes { + lasttid = tid + team := teams[(uaw.Start+tid+uaw.Turns*i)%len(teams)] + + if len(teamIdStack) > 0 { + teamIdStack = append(teamIdStack, team.Id) + team, _ = fic.GetTeam(teamIdStack[0]) + teamIdStack = append([]int64{}, teamIdStack[1:]...) + } + + j := 0 + // Find a team not responsible for this exercice + for (strings.Contains(theme.Path, "grp") && strings.Contains(theme.Path, "-grp"+strings.TrimPrefix(team.Name, uaw.TeamPrefix)+"-")) || (!strings.Contains(theme.Path, "grp") && strings.HasPrefix(theme.Path, strings.TrimPrefix(team.Name, uaw.TeamPrefix)+"-")) { + j += 1 + teamIdStack = append(teamIdStack, team.Id) + team = teams[(uaw.Start+tid+uaw.Turns*i+j)%len(teams)] + } + + exercices, err := theme.GetExercices() + if err != nil { + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()}) + return + } + + for _, ex := range exercices { + _, err := team.NewQATodo(ex.Id) + if err != nil { + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()}) + return + } + } + } + for eid, ex := range exercices { - team := teams[(uaw.Start+eid+uaw.Turns*i)%len(teams)] + team := teams[(uaw.Start+lasttid+eid+uaw.Turns*i)%len(teams)] if len(teamIdStack) > 0 { teamIdStack = append(teamIdStack, team.Id) diff --git a/qa/ui/src/routes/teams/+page.svelte b/qa/ui/src/routes/teams/+page.svelte index 3df8bb60..dfefe4c0 100644 --- a/qa/ui/src/routes/teams/+page.svelte +++ b/qa/ui/src/routes/teams/+page.svelte @@ -22,10 +22,12 @@ goto("teams/" + id) } - let start = 0; - let turns = 3; - let team_prefix = ""; - let team_assistants = ""; + let assignForm = { + start: 0, + turns: 3, + team_prefix: "", + team_assistants: "", + } let assignInProgress = false; async function assignExercices() { @@ -33,12 +35,7 @@ const res = await fetch(`api/qa_assign_work`, { method: 'POST', headers: {'Accept': 'application/json'}, - body: JSON.stringify({ - start, - turns, - team_prefix, - team_assistants, - }), + body: JSON.stringify(assignForm), }) if (res.status == 200) { teams.refresh(); @@ -111,23 +108,26 @@
- +

Incrémenter de 1 pour chaque nouveau challenge blanc, cela décale l'attribution des exercices.

- + - + - + + + +