feat: restrict user answer compaction to admin users and update related tests
This commit is contained in:
@@ -353,7 +353,7 @@ def test_exams(db, client):
|
||||
res = client.post(reverse("global_exam_answers_submit"), data=post_json)
|
||||
json_res = json.loads(res.content)
|
||||
assert json_res["success"] == False
|
||||
assert json_res["error"] == "Invalid data"
|
||||
assert json_res["error"] in ("Invalid data", "user / cid mismatch")
|
||||
|
||||
# Long answers currently send a seperate object for each component
|
||||
valid_answers = []
|
||||
@@ -369,22 +369,21 @@ def test_exams(db, client):
|
||||
)
|
||||
|
||||
i = 0
|
||||
for questions in exam_json["questions"]:
|
||||
for qid in questions:
|
||||
# Long answers submit 5 sections
|
||||
for n, name in sections:
|
||||
post_data = {
|
||||
"eid": exam_json["eid"],
|
||||
"cid": post_cid,
|
||||
"qid": qid,
|
||||
"qidn": n,
|
||||
"ans": f"{name} - {q}",
|
||||
}
|
||||
if testing_cid_user:
|
||||
post_data["passcode"] = cid_user.passcode
|
||||
for qid in exam_json["questions"]:
|
||||
# Long answers submit 5 sections
|
||||
for n, name in sections:
|
||||
post_data = {
|
||||
"eid": exam_json["eid"],
|
||||
"cid": post_cid,
|
||||
"qid": qid,
|
||||
"qidn": n,
|
||||
"ans": f"{name} - {q}",
|
||||
}
|
||||
if testing_cid_user:
|
||||
post_data["passcode"] = cid_user.passcode
|
||||
|
||||
valid_answers_extra.append(post_data)
|
||||
valid_answers_by_question[i][n] = post_data
|
||||
valid_answers_extra.append(post_data)
|
||||
valid_answers_by_question[i][n] = post_data
|
||||
i = i + 1
|
||||
|
||||
post_json = {
|
||||
|
||||
Reference in New Issue
Block a user