Exemplo n.º 1
0
 def setUp(self):
     self.teacher = create_user(
         first_name=fake.first_name(),
         last_name=fake.last_name(),
         email=fake.email(),
         raw_password='******',
         registered_as='teacher',
     )
     self.course = CourseFactory(teacher=self.teacher.teacher_profile)
     self.assessment = AssessmentFactory(course=self.course)
Exemplo n.º 2
0
    def setUp(self):
        self.teacher = create_user(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            email=fake.email(),
            raw_password='******',
            registered_as='teacher',
        )
        self.user = create_user(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            email=fake.email(),
            registered_as='student',
            raw_password='******',
        )
        self.course = CourseFactory(teacher=self.teacher.teacher_profile)
        self.assessment = AssessmentFactory(course=self.course)

        self.question = AssessmentQuestionFactory(assessment=self.assessment)
        self.choice1_1 = AssessmentChoiceFactory(question=self.question)
        self.choice1_1.is_valid = True
        self.choice1_1.save()

        self.choice1_2 = AssessmentChoiceFactory(question=self.question)
        self.choice1_2.is_valid = False
        self.choice1_2.save()

        self.question2 = AssessmentQuestionFactory(assessment=self.assessment)
        self.choice2_1 = AssessmentChoiceFactory(question=self.question)
        self.choice2_1.is_valid = True
        self.choice2_1.save()

        self.choice2_2 = AssessmentChoiceFactory(question=self.question)
        self.choice2_2.is_valid = False
        self.choice2_2.save()

        self.answer1 = AssessmentAnswer.objects.create(
            student=self.user.student_profile, choice=self.choice1_1)
        self.answer2 = AssessmentAnswer.objects.create(
            student=self.user.student_profile, choice=self.choice2_2)
Exemplo n.º 3
0
 def setUp(self):
     self.factory = APIRequestFactory()
     self.teacher = create_user(
         first_name=fake.first_name(),
         last_name=fake.last_name(),
         email=fake.email(),
         raw_password='******',
         registered_as='teacher',
     )
     self.course = CourseFactory(teacher=self.teacher.teacher_profile)
     self.assessment = AssessmentFactory(course=self.course)
     self.quiz = GroupQuizFactory(assessment=self.assessment)
     self.quiz_question = GroupQuizQuestionFactory(group_quiz=self.quiz)
     self.quiz_question2 = GroupQuizQuestionFactory(group_quiz=self.quiz)
Exemplo n.º 4
0
 def setUp(self):
     self.factory = APIRequestFactory()
     self.teacher = create_user(
         first_name=fake.first_name(),
         last_name=fake.last_name(),
         email=fake.email(),
         raw_password='******',
         registered_as='teacher',
     )
     self.user = create_user(
         first_name=fake.first_name(),
         last_name=fake.last_name(),
         email=fake.email(),
         registered_as='student',
         raw_password='******',
     )
     self.course = CourseFactory(teacher=self.teacher.teacher_profile)
     self.assessment = AssessmentFactory(course=self.course)
     self.quiz = GroupQuizFactory(assessment=self.assessment)
     self.quiz_question = GroupQuizQuestionFactory(group_quiz=self.quiz)
     self.choice = GroupChoiceFactory(quiz_question=self.quiz_question)
     self.choice2 = GroupChoiceFactory(quiz_question=self.quiz_question)
     self.answer = GroupAnswer.objects.create(
         student=self.user.student_profile, choice=self.choice)
Exemplo n.º 5
0
class AssessmentQuestionTestCase(TestCase):
    def setUp(self):
        self.teacher = create_user(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            email=fake.email(),
            raw_password='******',
            registered_as='teacher',
        )
        self.user = create_user(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            email=fake.email(),
            registered_as='student',
            raw_password='******',
        )
        self.course = CourseFactory(teacher=self.teacher.teacher_profile)
        self.assessment = AssessmentFactory(course=self.course)

        self.question = AssessmentQuestionFactory(assessment=self.assessment)
        self.choice1_1 = AssessmentChoiceFactory(question=self.question)
        self.choice1_1.is_valid = True
        self.choice1_1.save()

        self.choice1_2 = AssessmentChoiceFactory(question=self.question)
        self.choice1_2.is_valid = False
        self.choice1_2.save()

        self.question2 = AssessmentQuestionFactory(assessment=self.assessment)
        self.choice2_1 = AssessmentChoiceFactory(question=self.question)
        self.choice2_1.is_valid = True
        self.choice2_1.save()

        self.choice2_2 = AssessmentChoiceFactory(question=self.question)
        self.choice2_2.is_valid = False
        self.choice2_2.save()

        self.answer1 = AssessmentAnswer.objects.create(
            student=self.user.student_profile, choice=self.choice1_1)
        self.answer2 = AssessmentAnswer.objects.create(
            student=self.user.student_profile, choice=self.choice2_2)

    def test_string_representation_returns_title(self):
        self.assertEqual(
            str(self.question),
            f'{self.question.title}',
        )

    def test_creation_question_instance(self):
        self.assertTrue(self.question)
        self.assertEqual(self.question.__class__, AssessmentQuestion)

    def test_check_right_order(self):
        self.assertEqual(self.question.order, 1)
        self.assertEqual(self.question2.order, 2)

    def test_get_student_result(self):
        result = self.assessment.get_student_result(
            self.user.student_profile.id)
        result = result['right_answers']
        self.assertEqual(result, 1)