示例#1
0
 def setUpTestData(cls):
     cls.question_1 = QuestionFactory(answer_correct="a")
     cls.quiz_1 = QuizFactory(name="quiz 1")
     cls.quiz_2 = QuizFactory(name="quiz 2")
     cls.quiz_3 = QuizFactory(name="quiz 2")
     cls.quiz_relationship = QuizRelationship.objects.create(
         from_quiz=cls.quiz_1, to_quiz=cls.quiz_2, status="suivant")
示例#2
0
 def test_published_quiz_can_have_not_validated_questions(self):
     self.question_validated = QuestionFactory(answer_correct="a")
     self.question_not_validated = QuestionFactory(
         answer_correct="a",
         validation_status=constants.QUESTION_VALIDATION_STATUS_IN_PROGRESS,
     )
     self.quiz_published = QuizFactory(name="quiz published", publish=True)
     self.quiz_not_published = QuizFactory(name="quiz not published")
     # pass
     # self.quiz_not_published.questions.set(
     #     [self.question_validated, self.question_not_validated]
     # )
     QuizQuestion.objects.create(quiz=self.quiz_not_published,
                                 question=self.question_validated)
     QuizQuestion.objects.create(quiz=self.quiz_not_published,
                                 question=self.question_not_validated)
     # pass # used to be fail
     # self.quiz_published.questions.set(
     #     [self.question_validated, self.question_not_validated]
     # )
     QuizQuestion.objects.create(quiz=self.quiz_published,
                                 question=self.question_validated)
     QuizQuestion.objects.create(quiz=self.quiz_published,
                                 question=self.question_not_validated)
     self.assertEqual(len(self.quiz_published.questions_not_validated_list),
                      1)
示例#3
0
 def setUpTestData(cls):
     # quiz_1
     cls.quiz_1 = QuizFactory(name="quiz 1")
     QuizAnswerEvent.objects.create(quiz_id=cls.quiz_1.id, answer_success_count=1)
     QuizAnswerEvent.objects.create(quiz_id=cls.quiz_1.id, answer_success_count=2)
     QuizAnswerEvent.objects.create(quiz_id=cls.quiz_1.id, answer_success_count=3)
     QuizFeedbackEvent.objects.create(quiz_id=cls.quiz_1.id, choice="like")
     QuizFeedbackEvent.objects.create(quiz_id=cls.quiz_1.id, choice="dislike")
     QuizFeedbackEvent.objects.create(quiz_id=cls.quiz_1.id, choice="like")
     # quiz_2
     cls.quiz_2 = QuizFactory(name="quiz 2")
     QuizAnswerEvent.objects.create(quiz_id=cls.quiz_2.id, answer_success_count=1)
     QuizFeedbackEvent.objects.create(quiz_id=cls.quiz_2.id, choice="like")
示例#4
0
 def setUpTestData(cls):
     Configuration.objects.create(
         daily_stat_last_aggregated=timezone.make_aware(datetime(
             2020, 5, 1)))
     cls.question_1 = QuestionFactory(answer_correct="a")
     cls.question_1.agg_stats.answer_count = 2
     cls.question_1.agg_stats.save()
     QuestionAnswerEvent.objects.create(question_id=cls.question_1.id,
                                        choice="a",
                                        source="question")
     QuestionAnswerEvent.objects.create(question_id=cls.question_1.id,
                                        choice="b",
                                        source="question")
     QuestionAnswerEvent.objects.create(question_id=cls.question_1.id,
                                        choice="c",
                                        source="quiz")
     QuestionFeedbackEvent.objects.create(question_id=cls.question_1.id,
                                          choice="like",
                                          source="question")
     QuestionFeedbackEvent.objects.create(question_id=cls.question_1.id,
                                          choice="dislike",
                                          source="question")
     QuestionFeedbackEvent.objects.create(question_id=cls.question_1.id,
                                          choice="like",
                                          source="quiz")
     cls.quiz_1 = QuizFactory(name="quiz 1")
     QuizAnswerEvent.objects.create(quiz_id=cls.quiz_1.id,
                                    answer_success_count=1)
     DailyStat.objects.create(
         date="2020-04-30",
         question_answer_count=10,
         question_feedback_count=5,
         quiz_answer_count=2,
         hour_split=constants.DEFAULT_DAILY_STAT_HOUR_SPLIT,
     )
     with freeze_time("2020-04-30 12:30:00"):
         QuestionAnswerEvent.objects.create(question_id=cls.question_1.id,
                                            choice="a",
                                            source="question")
         QuestionAnswerEvent.objects.create(question_id=cls.question_1.id,
                                            choice="b",
                                            source="question")
         QuestionAnswerEvent.objects.create(question_id=cls.question_1.id,
                                            choice="c",
                                            source="quiz")
         QuestionFeedbackEvent.objects.create(question_id=cls.question_1.id,
                                              choice="like",
                                              source="question")
         QuestionFeedbackEvent.objects.create(question_id=cls.question_1.id,
                                              choice="dislike",
                                              source="question")
         QuestionFeedbackEvent.objects.create(question_id=cls.question_1.id,
                                              choice="like",
                                              source="quiz")
         QuizAnswerEvent.objects.create(quiz_id=cls.quiz_1.id,
                                        answer_success_count=1)
示例#5
0
 def setUpTestData(cls):
     cls.question_1 = QuestionFactory(answer_correct="a")
     cls.quiz_1 = QuizFactory(name="quiz 1")
     # cls.quiz_1.questions.set([cls.question_1.id])
     QuizQuestion.objects.create(quiz=cls.quiz_1, question=cls.question_1)
     QuestionAnswerEvent.objects.create(question_id=cls.question_1.id,
                                        choice="a",
                                        source="question")
     QuizAnswerEvent.objects.create(quiz_id=cls.quiz_1.id,
                                    answer_success_count=1)
     QuizFeedbackEvent.objects.create(quiz_id=cls.quiz_1.id,
                                      choice="dislike")
示例#6
0
 def setUpTestData(cls):
     cls.category_1 = CategoryFactory(name="Cat 1")
     cls.tag_1 = TagFactory(name="Tag 1")
     cls.tag_2 = TagFactory(name="Tag 2")
     cls.question_1 = QuestionFactory(
         text="Q 1",
         category=cls.category_1,
         author="author 1",
         validation_status=constants.QUESTION_VALIDATION_STATUS_IN_PROGRESS,
     )
     cls.question_2 = QuestionFactory(
         text="Q 2", category=cls.category_1, answer_correct="a", author="author 2",
     )
     cls.question_2.tags.set([cls.tag_2, cls.tag_1])
     cls.question_3 = QuestionFactory(
         text="Q 3", category=cls.category_1, author="author 3"
     )
     cls.question_3.tags.add(cls.tag_2)
     cls.question_3.save()
     cls.quiz_1 = QuizFactory(name="quiz 1", publish=False)
     QuizQuestion.objects.create(quiz=cls.quiz_1, question=cls.question_1)
     cls.quiz_2 = QuizFactory(name="quiz 2", publish=True)
     QuizQuestion.objects.create(quiz=cls.quiz_2, question=cls.question_2, order=2)
     QuizQuestion.objects.create(quiz=cls.quiz_2, question=cls.question_3, order=1)
示例#7
0
 def test_published_quiz_must_have_at_least_one_question(self):
     self.quiz_not_published = QuizFactory(name="quiz not published")
     self.quiz_not_published.publish = True
     self.assertRaises(ValidationError,
                       self.quiz_not_published.save,
                       update_fields=["publish"])