add markers to exams (move away from group based to content based permissions)

This commit is contained in:
Ross
2024-08-05 10:45:38 +01:00
parent cff5a46e4c
commit e46f843284
33 changed files with 299 additions and 23 deletions
+13 -13
View File
@@ -176,7 +176,6 @@ def test_exams(db, client):
active_exams_cid = client.get(active_exams_url)
print(cid_user)
assert active_exams_cid.status_code == 200
assert len(json.loads(active_exams_cid.content)["exams"]) == 1
@@ -202,7 +201,6 @@ def test_exams(db, client):
assert exam_metadata["name"] == "Cid Exam"
assert exam_metadata["exam_active"] == True
assert exam_metadata["exam_mode"] == True
print(f"{exam_metadata=}")
res = client.get(exam_metadata["url"])
assert res.status_code == 200
@@ -224,7 +222,6 @@ def test_exams(db, client):
)
for q in exam_json["question_requests"]:
print("check question:", q)
# check redirects to the json file work
# TODO: sort out testing of the saved JSON files
try:
@@ -258,8 +255,6 @@ def test_exams(db, client):
assert question_json_res.redirect_chain[1][0].endswith(f"{q}.json")
print(cid_user, testing_cid_user)
if testing_cid_user:
question_json_unbased_res = client.get(
reverse(
@@ -281,7 +276,6 @@ def test_exams(db, client):
"sk": q,
},
)
print(test)
question_json_unbased_res = client.get(
reverse(
@@ -516,8 +510,6 @@ def test_exams(db, client):
assert len(answer_lis) == len(valid_answers_by_question)
pprint(valid_answers_by_question)
print(cid_user)
for n in range(
len(valid_answers_by_question)
@@ -526,7 +518,6 @@ def test_exams(db, client):
#n = str(n + 1) # questions are not zero indexed (lists are)
for qidn, section_title in sections:
print(n, qidn)
answer = valid_answers_by_question[n][qidn]
li = lis.find("li", attrs={"data-qidn": qidn})
@@ -558,6 +549,19 @@ def test_exams(db, client):
assert "Not answered" in str(answer_lis[-1])
assert str(answer_lis[-1]).count("Not answered") == 5
## Load the mark overview page
#mark_overview_res = client.get(reverse(
# f"{exam.app_name}:mark_overview",
# kwargs={"pk": exam.pk},
# ))
#print(mark_overview_res.content)
#mark_overview_soup = BeautifulSoup(mark_overview_res.content, "html.parser")
#to_mark = mark_overview_soup.find("ul", {"id": "question-mark-list"}).find_all("li")
#assert len(to_mark) == 5
# Publish the results!
exam.publish_results = True
exam.save()
@@ -594,8 +598,6 @@ def test_exams(db, client):
assert answer["ans"] in str(li) # Check that the saved answer is shown
print(cid_exam_scores_soup.find("div", {"class": "score-overview"}))
# For long cases an unmarked answers is given a score of 4
# Each user needs marking individually
assert (
@@ -609,10 +611,8 @@ def test_exams(db, client):
# For longs this needs to be done for each user
question: Question
for question in exam.exam_questions.all():
print(question)
answers = question.get_unmarked_user_answers()
print(answers)
for answer in answers:
answer.score = UserAnswer.ScoreOptions.EIGHT
answer.save()