Add exercises for utas level.
This commit is contained in:
@@ -1062,6 +1062,26 @@ def replace_exercise_if_exists(all_exams, current_exercise, current_exam, seen_k
|
|||||||
else:
|
else:
|
||||||
seen_keys.add(key)
|
seen_keys.add(key)
|
||||||
|
|
||||||
|
for exam in all_exams:
|
||||||
|
exam_dict = exam.to_dict()
|
||||||
|
if any(
|
||||||
|
exercise["prompt"] == current_exercise["prompt"] and
|
||||||
|
any(exercise["options"][0]["text"] == current_option["text"] for current_option in
|
||||||
|
current_exercise["options"])
|
||||||
|
for exercise in exam_dict.get("exercises", [])[0]["questions"]
|
||||||
|
):
|
||||||
|
return replace_exercise_if_exists(all_exams, generate_single_mc_level_question(), current_exam, seen_keys)
|
||||||
|
return current_exercise, seen_keys
|
||||||
|
|
||||||
|
def replace_exercise_if_exists_utas(all_exams, current_exercise, current_exam, seen_keys):
|
||||||
|
# Extracting relevant fields for comparison
|
||||||
|
key = (current_exercise['prompt'], tuple(sorted(option['text'] for option in current_exercise['options'])))
|
||||||
|
# Check if the key is in the set
|
||||||
|
if key in seen_keys:
|
||||||
|
return replace_exercise_if_exists_utas(all_exams, generate_single_mc_level_question(), current_exam, seen_keys)
|
||||||
|
else:
|
||||||
|
seen_keys.add(key)
|
||||||
|
|
||||||
for exam in all_exams:
|
for exam in all_exams:
|
||||||
if any(
|
if any(
|
||||||
exercise["prompt"] == current_exercise["prompt"] and
|
exercise["prompt"] == current_exercise["prompt"] and
|
||||||
@@ -1069,7 +1089,7 @@ def replace_exercise_if_exists(all_exams, current_exercise, current_exam, seen_k
|
|||||||
current_exercise["options"])
|
current_exercise["options"])
|
||||||
for exercise in exam.get("questions", [])
|
for exercise in exam.get("questions", [])
|
||||||
):
|
):
|
||||||
return replace_exercise_if_exists(all_exams, generate_single_mc_level_question(), current_exam, seen_keys)
|
return replace_exercise_if_exists_utas(all_exams, generate_single_mc_level_question(), current_exam, seen_keys)
|
||||||
return current_exercise, seen_keys
|
return current_exercise, seen_keys
|
||||||
|
|
||||||
|
|
||||||
@@ -1144,7 +1164,7 @@ def gen_multiple_choice_blank_space_utas(quantity: int, start_id: int, all_exams
|
|||||||
else:
|
else:
|
||||||
seen_keys = set()
|
seen_keys = set()
|
||||||
for i in range(len(question["questions"])):
|
for i in range(len(question["questions"])):
|
||||||
question["questions"][i], seen_keys = replace_exercise_if_exists(all_exams, question["questions"][i],
|
question["questions"][i], seen_keys = replace_exercise_if_exists_utas(all_exams, question["questions"][i],
|
||||||
question,
|
question,
|
||||||
seen_keys)
|
seen_keys)
|
||||||
return fix_exercise_ids(question, start_id)
|
return fix_exercise_ids(question, start_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user