fix bug where survey could be completed early

This commit is contained in:
TEC 2022-10-17 00:08:34 +08:00
parent 113423e893
commit 5cf1046c8d
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 12 additions and 5 deletions

View File

@ -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,