Ejemplo n.º 1
0
def student_response_rows(course):
    """ Wrapper to return all (header and data) rows for student responses reports for a course """
    header = [
        "Section", "Subsection", "Unit", "Problem", "Order In Course",
        "Location", "Student", "Response", "Timestamp"
    ]
    rows = chain([header], student_responses(course))
    return rows
Ejemplo n.º 2
0
 def test_problem_with_student_answer_and_answers(self):
     section, sub_section, unit, problem = self.create_course_structure()
     submit_and_compare_valid_state = ItemFactory.create(
         parent_location=unit.location,
         category='submit-and-compare',
         display_name=u'test submit_and_compare1',
     )
     submit_and_compare_invalid_state = ItemFactory.create(
         parent_location=unit.location,
         category='submit-and-compare',
         display_name=u'test submit_and_compare2',
     )
     content_library = ItemFactory.create(
         parent_location=unit.location,
         category='library_content',
         display_name=u'test content_library',
     )
     library_problem = ItemFactory.create(
         parent_location=content_library.location,
         category='problem',
     )
     self.create_student()
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=problem.location,
         student=self.student,
         grade=0,
         state=u'{"student_answers":{"problem_id":"student response1"}}',
     )
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=submit_and_compare_valid_state.location,
         student=self.student,
         grade=1,
         state=u'{"student_answer": "student response2"}',
     )
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=submit_and_compare_invalid_state.location,
         student=self.student,
         grade=1,
         state=u'{"answer": {"problem_id": "123"}}',
     )
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=library_problem.location,
         student=self.student,
         grade=0,
         state=u'{"student_answers":{"problem_id":"content library response1"}}',
     )
     course_with_children = modulestore().get_course(self.course.id, depth=4)
     datarows = list(student_responses(course_with_children))
     self.assertEqual(datarows[0][-2], u'problem_id=student response1')
     self.assertEqual(datarows[1][-2], u'student response2')
     self.assertEqual(datarows[2][-2], None)
     self.assertEqual(datarows[3][-2], u'problem_id=content library response1')
Ejemplo n.º 3
0
 def test_problem_with_student_answer_and_answers(self):
     section, sub_section, unit, problem = self.create_course_structure()
     submit_and_compare_valid_state = ItemFactory.create(
         parent_location=unit.location,
         category='submit-and-compare',
         display_name=u'test submit_and_compare1',
     )
     submit_and_compare_invalid_state = ItemFactory.create(
         parent_location=unit.location,
         category='submit-and-compare',
         display_name=u'test submit_and_compare2',
     )
     content_library = ItemFactory.create(
         parent_location=unit.location,
         category='library_content',
         display_name=u'test content_library',
     )
     library_problem = ItemFactory.create(
         parent_location=content_library.location,
         category='problem',
     )
     self.create_student()
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=problem.location,
         student=self.student,
         grade=0,
         state=u'{"student_answers":{"problem_id":"student response1"}}',
     )
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=submit_and_compare_valid_state.location,
         student=self.student,
         grade=1,
         state=u'{"student_answer": "student response2"}',
     )
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=submit_and_compare_invalid_state.location,
         student=self.student,
         grade=1,
         state=u'{"answer": {"problem_id": "123"}}',
     )
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=library_problem.location,
         student=self.student,
         grade=0,
         state=u'{"student_answers":{"problem_id":"content library response1"}}',
     )
     course_with_children = modulestore().get_course(self.course.id, depth=4)
     datarows = list(student_responses(course_with_children))
     self.assertEqual(datarows[0][-1], u'problem_id=student response1')
     self.assertEqual(datarows[1][-1], u'student response2')
     self.assertEqual(datarows[2][-1], None)
     self.assertEqual(datarows[3][-1], u'problem_id=content library response1')
Ejemplo n.º 4
0
 def test_problem_with_no_answer(self):
     section, sub_section, unit, problem = self.create_course_structure()
     self.create_student()
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=problem.location,
         student=self.student,
         grade=0,
         state=u'{"answer": {"problem_id": "123"}}',
     )
     course_with_children = modulestore().get_course(self.course.id, depth=4)
     datarows = list(student_responses(course_with_children))
     self.assertEqual(datarows[0][-2], None)
Ejemplo n.º 5
0
 def test_problem_with_no_answer(self):
     section, sub_section, unit, problem = self.create_course_structure()
     self.create_student()
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=problem.location,
         student=self.student,
         grade=0,
         state=u'{"answer": {"problem_id": "123"}}',
     )
     course_with_children = modulestore().get_course(self.course.id, depth=4)
     datarows = list(student_responses(course_with_children))
     self.assertEqual(datarows[0][-1], None)
Ejemplo n.º 6
0
 def test_invalid_module_state(self):
     section, sub_section, unit, problem = self.create_course_structure()
     self.create_student()
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=problem.location,
         student=self.student,
         grade=0,
         state=u'{"student_answers":{"fake-problem":"No idea"}}}',
     )
     course_with_children = modulestore().get_course(self.course.id, depth=4)
     datarows = list(student_responses(course_with_children))
     # Invalid module state response will be skipped, so datarows should be empty
     self.assertEqual(len(datarows), 0)
Ejemplo n.º 7
0
 def test_invalid_module_state(self):
     section, sub_section, unit, problem = self.create_course_structure()
     self.create_student()
     StudentModuleFactory.create(
         course_id=self.course.id,
         module_state_key=problem.location,
         student=self.student,
         grade=0,
         state=u'{"student_answers":{"fake-problem":"No idea"}}}',
     )
     course_with_children = modulestore().get_course(self.course.id, depth=4)
     datarows = list(student_responses(course_with_children))
     # Invalid module state response will be skipped, so datarows should be empty
     self.assertEqual(len(datarows), 0)
Ejemplo n.º 8
0
 def test_full_course_no_students(self):
     datarows = list(student_responses(self.course))
     self.assertEqual(datarows, [])
Ejemplo n.º 9
0
 def test_empty_course(self):
     self.create_student()
     datarows = list(student_responses(self.course))
     self.assertEqual(datarows, [])
Ejemplo n.º 10
0
 def test_full_course_no_students(self):
     datarows = list(student_responses(self.course))
     self.assertEqual(datarows, [])
Ejemplo n.º 11
0
 def test_empty_course(self):
     self.create_student()
     datarows = list(student_responses(self.course))
     self.assertEqual(datarows, [])
Ejemplo n.º 12
0
def student_response_rows(course):
    """ Wrapper to return all (header and data) rows for student responses reports for a course """
    header = ["Section", "Subsection", "Unit", "Problem", "Order In Course", "Location", "Student", "Response", "Timestamp"]
    rows = chain([header], student_responses(course))
    return rows