From 5cf1046c8d44c3677bfe24d7e5199238eb803b92 Mon Sep 17 00:00:00 2001 From: TEC Date: Mon, 17 Oct 2022 00:08:34 +0800 Subject: [PATCH] fix bug where survey could be completed early --- app/resources/surveys/SurveysController.jl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/resources/surveys/SurveysController.jl b/app/resources/surveys/SurveysController.jl index 9caa6ae..df6a10c 100644 --- a/app/resources/surveys/SurveysController.jl +++ b/app/resources/surveys/SurveysController.jl @@ -80,11 +80,18 @@ function serve(forminfo::Dict) uid_str = string(uid, base=UID_ENCBASE) page = parse(Int, forminfo[:page]) if page > length(SURVEY) - @info SURVEY => INPROGRESS[uid] - INPROGRESS[uid].completed = now() - save!(INPROGRESS[uid], Symbol[]) - delete!(INPROGRESS, uid) - completed(uid) + # Verify the survey is /actually/ complete, + # and go to response's current page if not. + if INPROGRESS[uid].page > length(SURVEY) + @info SURVEY => INPROGRESS[uid] + INPROGRESS[uid].completed = now() + save!(INPROGRESS[uid], Symbol[]) + delete!(INPROGRESS, uid) + completed(uid) + else + forminfo[:page] = string(INPROGRESS[uid].page) + serve(forminfo) + end else res = html(:surveys, :survey, layout=:base, uid=uid_str, survey=SURVEY,