From 31bccddc49eb91b74dcd6cf0049d514e965694e6 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Tue, 6 Jun 2023 15:44:09 +0200 Subject: [PATCH] qa: Add a new field to retrieve passed time on exercice --- qa/api/qa.go | 4 ++ qa/ui/src/lib/components/QANewItem.svelte | 58 ++++++++++++++++++----- qa/ui/src/lib/qa.js | 1 + 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/qa/api/qa.go b/qa/api/qa.go index 54541f4a..da03ec14 100644 --- a/qa/api/qa.go +++ b/qa/api/qa.go @@ -109,6 +109,10 @@ func createExerciceQA(c *gin.Context) { tmp := time.Now() uq.Subject = "RAS" uq.Solved = &tmp + } else if uq.State == "timer" { + tmp := time.Now() + uq.Subject = fmt.Sprintf("Temps passé équipe #%d (%s)", teamid, ficteam) + uq.Solved = &tmp } else { c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "Subject not filled"}) return diff --git a/qa/ui/src/lib/components/QANewItem.svelte b/qa/ui/src/lib/components/QANewItem.svelte index 4a4d6300..5ce4f0fd 100644 --- a/qa/ui/src/lib/components/QANewItem.svelte +++ b/qa/ui/src/lib/components/QANewItem.svelte @@ -19,12 +19,19 @@ function saveQuery() { newQuery.id_exercice = exercice.id; creationInProgress = true; + const myContent = newQuery.content; + if (!newQuery.content) newQuery.content = ""; + if (newQuery.difficulty) + newQuery.content = "Difficulté : " + newQuery.difficulty + "\n" + newQuery.content; + if (newQuery.timecount) + newQuery.content = "Temps passé : " + newQuery.timecount + "\n" + newQuery.content; newQuery.save().then((res) => { dispatch("new-query"); newQuery = new QAQuery(); creationInProgress = false; }).catch((err) => { creationInProgress = false; + newQuery.content = myContent; ToastsStore.addErrorToast({ msg: err, }) @@ -49,18 +56,47 @@ -
- -
- + {#if newQuery.state == "timer"} +
+ +
+ +
-
+
+ +
+ +
+
+ {:else} +
+ +
+ +
+
+ {/if}
diff --git a/qa/ui/src/lib/qa.js b/qa/ui/src/lib/qa.js index 17f8f2eb..58cf404d 100644 --- a/qa/ui/src/lib/qa.js +++ b/qa/ui/src/lib/qa.js @@ -1,5 +1,6 @@ export const QAStates = { "ok": "OK", + "timer": "Temps passé", "orthograph": "Orthographe et grammaire", "issue-statement": "Pas compris", "issue-flag": "Problème de flag",