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) uid_str = string(uid, base=UID_ENCBASE)
page = parse(Int, forminfo[:page]) page = parse(Int, forminfo[:page])
if page > length(SURVEY) if page > length(SURVEY)
@info SURVEY => INPROGRESS[uid] # Verify the survey is /actually/ complete,
INPROGRESS[uid].completed = now() # and go to response's current page if not.
save!(INPROGRESS[uid], Symbol[]) if INPROGRESS[uid].page > length(SURVEY)
delete!(INPROGRESS, uid) @info SURVEY => INPROGRESS[uid]
completed(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 else
res = html(:surveys, :survey, layout=:base, res = html(:surveys, :survey, layout=:base,
uid=uid_str, survey=SURVEY, uid=uid_str, survey=SURVEY,