Пример #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_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'))