diff --git a/surveys.go b/surveys.go index ec3eb6d..fd3181e 100644 --- a/surveys.go +++ b/surveys.go @@ -80,34 +80,7 @@ func declareAPIAuthSurveysRoutes(router *gin.RouterGroup) { } s := c.MustGet("survey").(*Survey) - if u.IsAdmin { - questions, err := s.GetQuestions() - if err != nil { - log.Println("Unable to getQuestions:", err) - c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "Unable to retrieve questions. Please try again later."}) - return - } - - itemCount := 0 - itemCorrected := 0 - for _, q := range questions { - res, err := q.GetResponses() - if err != nil { - log.Printf("Unable to GetResponses(qid=%d): %s", q.Id, err.Error()) - c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": "An error occurs during responses retrieval."}) - return - } - - for _, r := range res { - itemCount += 1 - if r.TimeScored != nil && (r.TimeReported == nil || r.TimeScored.After(*r.TimeReported)) { - itemCorrected += 1 - } - } - } - - c.JSON(http.StatusOK, map[string]int{"count": itemCount, "corrected": itemCorrected}) - } else if s.Promo == u.Promo && s.Shown { + if (s.Promo == u.Promo && s.Shown) || (u != nil && u.IsAdmin) { score, err := s.GetScore(u) if err != nil { log.Printf("Unable to GetScore(uid=%d;sid=%d): %s", u.Id, s.Id, err.Error()) diff --git a/ui/src/lib/components/CorrectionResponseFooter.svelte b/ui/src/lib/components/CorrectionResponseFooter.svelte index 84d765a..68af856 100644 --- a/ui/src/lib/components/CorrectionResponseFooter.svelte +++ b/ui/src/lib/components/CorrectionResponseFooter.svelte @@ -38,37 +38,14 @@ for (const t of templates) { if (my_tpls[t.id] === undefined && cts[t.id.toString()]) { my_tpls[t.id] = cts[t.id.toString()][response.id_user] !== undefined; - - // Hack to autocorrect only if this has already been checked previously - if (autoCorrectionInProgress && cts[t.id.toString()][response.id_user] !== undefined) { - autoCorrectionInProgress = false; - } } } } } - - let element = null; - let scrollY = 0; - let autoCorrectionInProgress = true; - $: { - if (element && scrollY > element.offsetParent.offsetTop - 500 && !my_correction) { - let tmp = false; - [tmp, autoCorrectionInProgress] = [autoCorrectionInProgress, true]; - if (!tmp) { - autoCorrection(response.id_user, my_tpls).then((r) => { - my_correction = r; - autoCorrectionInProgress = false; - }) - } - } - } -
@@ -92,7 +69,6 @@ >