예제 #1
0
 def test_teacher_compute_total(self):
     """Tests if a teacher can compute the total for a student"""
     teacher = Teacher()
     questions = {
         '1 + 1?': {
             '1': False,
             '2': True,
             '3': False
         },
         'name?': {
             'my name': True,
             'your name': True,
             'no name': False
         }
     }
     teacher.add_class('math')
     teacher.add_class('science')
     teacher.create_quiz('math', 'quiz1', questions)
     teacher.create_quiz('science', 'quiz1', questions)
     student = Student('Sam')
     student.add_class('math')
     student.add_class('science')
     teacher.assign_quiz(student, 'math', 'quiz1')
     student.submit_answer('math', 'quiz1', '1 + 1?', '1')
     student.submit_answer('math', 'quiz1', 'name?',
                           ['my name', 'your name'])
     teacher.assign_quiz(student, 'science', 'quiz1')
     student.submit_answer('science', 'quiz1', '1 + 1?', '1')
     student.submit_answer('science', 'quiz1', 'name?',
                           ['my name', 'your name'])
     teacher.grade(student, student.get_quiz('math', 'quiz1'))
     assert teacher.total(student.get_name(), 'math') == 50
예제 #2
0
 def test_student_answer_quiz(self):
     """Test that a student can answer a quiz"""
     teacher = Teacher()
     questions = {
         '1 + 1?': {
             '1': False,
             '2': True,
             '3': False
         },
         'name?': {
             'my name': True,
             'your name': True,
             'no name': False
         }
     }
     teacher.add_class('math')
     teacher.create_quiz('math', 'quiz1', questions)
     student = Student()
     student.add_class('math')
     teacher.assign_quiz(student, 'math', 'quiz1')
     assert (student.submit_answer('math', 'quiz1', '1 + 1?', '1')
             and student.submit_answer('math', 'quiz1', 'name?',
                                       ['my name', 'your name'])
             and student.quizzes['math_quiz1']['response'] == {
                 '1 + 1?': '1',
                 'name?': ['my name', 'your name']
             })
예제 #3
0
 def test_teacher_create_quiz(self):
     """Tests if a teacher can create a quiz"""
     teacher = Teacher()
     teacher.add_class('math')
     questions = {
         '1 + 1?': {
             '1': False,
             '2': True,
             '3': False
         },
         'name?': {
             'my name': True,
             'your name': True,
             'no name': False
         }
     }
     teacher.create_quiz('math', 'quiz1', questions)
     assert len(teacher.get_quizzes()) == 1
예제 #4
0
 def test_not_teacher_assign_quiz(self):
     """Tests if a teacher can't assign a uuiz to a student that is not in his class"""
     teacher = Teacher()
     questions = {
         '1 + 1?': {
             '1': False,
             '2': True,
             '3': False
         },
         'name?': {
             'my name': True,
             'your name': True,
             'no name': False
         }
     }
     teacher.add_class('math')
     teacher.create_quiz('math', 'quiz1', questions)
     student = Student()
     assert not teacher.assign_quiz(student, 'math', 'quiz1')
예제 #5
0
 def test_teacher_grade_quiz(self):
     """Tests if a teacher quiz can be graded"""
     teacher = Teacher()
     questions = {
         '1 + 1?': {
             '1': False,
             '2': True,
             '3': False
         },
         'name?': {
             'my name': True,
             'your name': True,
             'no name': False
         }
     }
     teacher.add_class('math')
     teacher.create_quiz('math', 'quiz1', questions)
     student = Student()
     student.add_class('math')
     teacher.assign_quiz(student, 'math', 'quiz1')
     student.submit_answer('math', 'quiz1', '1 + 1?', '1')
     student.submit_answer('math', 'quiz1', 'name?',
                           ['my name', 'your name'])
     assert teacher.grade(student, student.get_quiz('math', 'quiz1'))
예제 #6
0
 def test_not_teacher_create_quiz(self):
     """Tests if a teacher cant create a quiz without right answers"""
     teacher = Teacher()
     teacher.add_class('math')
     questions = {'1 + 1?': {'1': False, '2': False, '3': False}}
     assert not teacher.create_quiz('math', 'quiz1', questions)