Skip to content

Commit

Permalink
Generate exams only with approved questions(#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeronimoMendes authored May 26, 2022
1 parent fd70ca0 commit 9ced2e5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ def post(self, request):

if (subSubjects): # If there are any subsubjects specified
if year:
questionsQuery += list(Question.objects.filter(year__in=year, subsubject__in=subSubjects))
questionsQuery += list(Question.objects.filter(year__in=year, subsubject__in=subSubjects, accepted=True))
else:
questionsQuery += list(Question.objects.filter(subsubject__in=subSubjects))
questionsQuery += list(Question.objects.filter(subsubject__in=subSubjects, accepted=True))
else: # User wants a random subsubjects exam
if year:
questionsQuery += list(Question.objects.filter(year__in=year))
questionsQuery += list(Question.objects.filter(year__in=year, accepted=True))
else:
questionsQuery += list(Question.objects.all())
questionsQuery += list(Question.objects.filter(accepted=True))

# Selects randomly a set of final questions for the exam
questions = random.sample(list(questionsQuery), QUESTION_PER_EXAM)
Expand Down

0 comments on commit 9ced2e5

Please sign in to comment.