start testing
This commit is contained in:
+1
-43
@@ -509,44 +509,7 @@ class RapidView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
||||
filterset_class = RapidFilter
|
||||
|
||||
|
||||
def loadJsonAnswer(answer, user=None):
|
||||
eid = int(answer["eid"].split("/")[1])
|
||||
uid = False
|
||||
|
||||
try:
|
||||
cid = int(answer["cid"])
|
||||
except ValueError:
|
||||
if answer["cid"].startswith("u-"):
|
||||
cid = False
|
||||
uid = int(answer["cid"][2:])
|
||||
|
||||
print(f"{uid=}")
|
||||
print(f"{uid=}")
|
||||
if not uid == user.id:
|
||||
return False, JsonResponse(
|
||||
{"success": False, "error": "user / uid mismatch"}
|
||||
)
|
||||
|
||||
else:
|
||||
return False, JsonResponse(
|
||||
{"success": False, "error": "cid or eid or answers not defined"}
|
||||
)
|
||||
|
||||
#uid = int(answer["uid"])
|
||||
|
||||
if not uid:
|
||||
# As access is not restricted make sure the data appears valid
|
||||
if (not isinstance(cid, int)) or (
|
||||
not isinstance(eid, int) or (not isinstance(answer["ans"], str))
|
||||
):
|
||||
return False, JsonResponse(
|
||||
{"success": False, "error": "cid or eid or answers not defined"}
|
||||
)
|
||||
|
||||
## The model should catch invalid data but this should be less intensive
|
||||
#max_int = 999999999999999999999
|
||||
#if cid > max_int or eid > max_int:
|
||||
# return False, JsonResponse({"success": False, "error": "invalid cid"})
|
||||
def loadJsonAnswer(answer, cid, eid, uid):
|
||||
|
||||
exam = get_object_or_404(Exam, pk=eid)
|
||||
|
||||
@@ -555,11 +518,6 @@ def loadJsonAnswer(answer, user=None):
|
||||
{"success": False, "error": "invalid cid / passcode"}
|
||||
)
|
||||
|
||||
# if not exam.active:
|
||||
# return False, JsonResponse(
|
||||
# {"success": False, "error": "No active exam: {}".format(eid)}
|
||||
# )
|
||||
|
||||
if uid:
|
||||
exiting_answers = CidUserAnswer.objects.filter(
|
||||
question__id=answer["qid"], exam__id=eid, user__id=uid
|
||||
|
||||
Reference in New Issue
Block a user