def assertViewIsValid(self, course_id, problem_id, problem_part_id):
        # Mock the answer distribution and retrieve the view
        rv = utils.get_presenter_answer_distribution(course_id, problem_part_id)
        with patch(self.presenter_method, return_value=rv):
            response = self.client.get(self.path(course_id=course_id, problem_id=problem_id,
                                                 problem_part_id=problem_part_id))

        context = response.context

        # Ensure we get a valid HTTP status
        self.assertEqual(response.status_code, 200)
        self.assertValidContext(response.context)

        self.assertListEqual(context['questions'], rv.questions)
        self.assertDictContainsSubset(
            {
                'page_title': 'Performance: Problem Submissions',
                'problem_id': problem_id,
                'problem_part_id': problem_part_id,
                'view_live_url': '{}/{}/jump_to/{}'.format(settings.LMS_COURSE_SHORTCUT_BASE_URL, course_id,
                                                           problem_id),
                'active_question': rv.active_question,
                'questions': rv.questions
            }, context)
        self.assertDictContainsSubset(
            {
                'isRandom': rv.is_random,
                'answerType': rv.answer_type,
                'answerDistribution': rv.answer_distribution,
                'answerDistributionLimited': rv.answer_distribution_limited,
            }, json.loads(context['page_data'])['course'])

        self.assertPrimaryNav(response.context, course_id)
        self.assertSecondaryNavs(response.context, course_id)
    def assertViewIsValid(self, course_id, problem_id, problem_part_id):
        # Retrieve a mock assignment ID
        assignment_id = self.factory.assignments[0][u'id']

        # Mock the answer distribution and retrieve the view
        rv = utils.get_presenter_answer_distribution(course_id,
                                                     problem_part_id)
        with patch(self.presenter_method, return_value=rv):
            response = self.client.get(
                self.path(course_id=course_id,
                          assignment_id=assignment_id,
                          problem_id=problem_id,
                          problem_part_id=problem_part_id))

        context = response.context

        # Ensure we get a valid HTTP status
        self.assertEqual(response.status_code, 200)
        self.assertValidContext(response.context)

        self.assertListEqual(context['questions'], rv.questions)
        self.assertDictContainsSubset(
            {
                'page_title':
                'Performance: Problem Submissions',
                'problem_id':
                problem_id,
                'problem_part_id':
                problem_part_id,
                'view_live_url':
                '{}/{}/jump_to/{}'.format(
                    settings.LMS_COURSE_SHORTCUT_BASE_URL, course_id,
                    problem_id),
                'active_question':
                rv.active_question,
                'questions':
                rv.questions
            }, context)
        self.assertDictContainsSubset(
            {
                'isRandom': rv.is_random,
                'answerType': rv.answer_type,
                'answerDistribution': rv.answer_distribution,
                'answerDistributionLimited': rv.answer_distribution_limited,
            },
            json.loads(context['page_data'])['course'])

        self.assertPrimaryNav(response.context, course_id)
        self.assertSecondaryNavs(response.context, course_id)
Beispiel #3
0
    def assertViewIsValid(self, course_id, problem_id, problem_part_id):
        rv = utils.get_presenter_answer_distribution(course_id,
                                                     problem_part_id)
        with mock.patch(self.presenter_method, return_value=rv):
            response = self.client.get(
                self.path(course_id=course_id,
                          content_id=problem_id,
                          problem_part_id=problem_part_id))

        context = response.context

        # Ensure we get a valid HTTP status
        self.assertEqual(response.status_code, 200)

        self.assertListEqual(context['questions'], rv.questions)
        self.assertDictContainsSubset(
            {
                'page_title':
                'Performance: Problem Submissions',
                'problem_id':
                problem_id,
                'problem_part_id':
                problem_part_id,
                'view_live_url':
                'a/url/{}/jump_to/{}'.format(course_id, problem_id),
                'active_question':
                rv.active_question,
            }, context)

        self.assertDictContainsSubset(
            {
                'isRandom': rv.is_random,
                'answerType': rv.answer_type,
                'answerDistribution': rv.answer_distribution,
                'answerDistributionLimited': rv.answer_distribution_limited,
            },
            json.loads(context['page_data'])['course'])
Beispiel #4
0
    def assertViewIsValid(self, course_id, problem_id, problem_part_id):
        # Mock the answer distribution and retrieve the view
        rv = utils.get_presenter_answer_distribution(course_id,
                                                     problem_part_id)
        with patch(self.presenter_method, return_value=rv):
            response = self.client.get(self.path(course_id=course_id))

        context = response.context

        self.assertEqual(response.status_code, 200)
        self.assertValidContext(response.context)
        self.assertPrimaryNav(response.context['primary_nav_item'], course_id)
        self.assertSecondaryNavs(response.context['secondary_nav_items'],
                                 course_id)

        self.assertListEqual(context['questions'], rv.questions)
        self.assertDictContainsSubset(
            {
                'problem_id':
                problem_id,
                'view_live_url':
                '{}/{}/jump_to/{}'.format(
                    settings.LMS_COURSE_SHORTCUT_BASE_URL, course_id,
                    problem_id),
                'active_question':
                rv.active_question,
                'questions':
                rv.questions
            }, context)
        self.assertDictContainsSubset(
            {
                'isRandom': rv.is_random,
                'answerType': rv.answer_type,
                'answerDistribution': rv.answer_distribution,
                'answerDistributionLimited': rv.answer_distribution_limited,
            },
            json.loads(context['page_data'])['course'])