Exemple #1
0
    def test_problem_with_student_answer_and_answers(self):
        self.course = get_course(CourseKey.from_string('edX/graded/2012_Fall'))
        problem_location = Location('edX', 'graded', '2012_Fall', 'problem', 'H1P2')

        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"}}',
        )

        submit_and_compare_location = Location('edX', 'graded', '2012_Fall', 'problem', 'H1P3')
        StudentModuleFactory.create(
            course_id=self.course.id,
            module_state_key=submit_and_compare_location,
            student=self.student,
            grade=0,
            state=u'{"student_answer": "student response2"}',
        )

        submit_and_compare_location = Location("edX", "graded", "2012_Fall", "problem", 'H1P0')
        StudentModuleFactory.create(
            course_id=self.course.id,
            module_state_key=submit_and_compare_location,
            student=self.student,
            grade=0,
            state=u'{"answer": {"problem_id": "123"}}',
        )

        datarows = list(student_responses(self.course))
        self.assertEqual(datarows[0][-1], u'problem_id=student response1')
        self.assertEqual(datarows[1][-1], u'student response2')
Exemple #2
0
    def test_problem_with_no_answer(self):
        self.course = get_course(CourseKey.from_string('edX/graded/2012_Fall'))
        problem_location = Location('edX', 'graded', '2012_Fall', 'problem', 'H1P2')

        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"}}',
        )

        datarows = list(student_responses(self.course))
        self.assertEqual(datarows[0][-1], None)
Exemple #3
0
    def test_invalid_module_state(self):
        self.course = get_course(CourseKey.from_string('edX/graded/2012_Fall'))
        self.problem_location = Location("edX", "graded", "2012_Fall", "problem", "H1P2")

        self.create_student()
        StudentModuleFactory.create(
            course_id=self.course.id,
            module_state_key=self.problem_location,
            student=self.student,
            grade=0,
            state=u'{"student_answers":{"fake-problem":"No idea"}}}'
        )

        datarows = list(student_responses(self.course))
        #Invalid module state response will be skipped, so datarows should be empty
        self.assertEqual(len(datarows), 0)
Exemple #4
0
    def test_full_course_no_students(self):
        self.course = get_course(CourseKey.from_string('edX/graded/2012_Fall'))

        datarows = list(student_responses(self.course))
        self.assertEqual(datarows, [])
Exemple #5
0
    def test_empty_course(self):
        self.course = CourseFactory.create()
        self.create_student()

        datarows = list(student_responses(self.course))
        self.assertEqual(datarows, [])
    def test_problem_with_student_answer_and_answers(self):
        self.course = CourseFactory.create(
            display_name=u'test course',
        )
        section = ItemFactory.create(
            parent_location=self.course.location,
            category='chapter',
            display_name=u'test section',
        )
        sub_section = ItemFactory.create(
            parent_location=section.location,
            category='sequential',
            display_name=u'test subsection',
        )
        unit = ItemFactory.create(
            parent_location=sub_section.location,
            category="vertical",
            metadata={'graded': True, 'format': 'Homework'},
            display_name=u'test unit',
        )
        problem = ItemFactory.create(
            parent_location=unit.location,
            category='problem',
            display_name=u'test problem',
        )
        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')