コード例 #1
0
 def get_question(self):
     """
     Selects a question at random
     """
     sample = {'$sample': {'size': 1}}
     result = Question.objects(course=self.course).aggregate(sample)
     document = next(result, None)
     return Question.objects.get(uuid=document['_id']) if document else None
コード例 #2
0
 def get_question(self):
     """
     Selects the closest question to the student's current ability level
     """
     if not self.level:
         self._fetch_level()
     # TODO: Avoid repetition
     question = Question.objects(
         course=self.course,
         level__gte=self.level).order_by('level').first()
     if not question:
         question = Question.objects.order_by('-level').first()
     return question
コード例 #3
0
ファイル: questions.py プロジェクト: flexthink/quizzical
 def delete(self, question_uuid):
     """
     DELETE handler
     """
     Question.objects(uuid=question_uuid).delete()
コード例 #4
0
ファイル: questions.py プロジェクト: flexthink/quizzical
 def get(self, question_uuid):
     """
     GET handler
     """
     return Question.objects(uuid=question_uuid).first()
コード例 #5
0
 def get(self, course_uuid):
     """
     Retrieves the list of questions for the course
     """
     return list(Question.objects(course=course_uuid).all())