def setUp(self):
        """
        Makes a course, which will be the same for all tests.
        Set up mako middleware, which is necessary for template rendering to happen.
        """
        super(HintManagerTest, self).setUp()

        self.course = CourseFactory.create(org="Me", number="19.002", display_name="test_course")
        self.url = "/courses/Me/19.002/test_course/hint_manager"
        self.user = UserFactory.create(username="******", email="*****@*****.**", password="******", is_staff=True)
        self.c = Client()
        self.c.login(username="******", password="******")
        self.course_id = self.course.id
        self.problem_id = self.course_id.make_usage_key("crowdsource_hinter", "crowdsource_hinter_001")
        UserStateSummaryFactory.create(
            field_name="hints",
            usage_id=self.problem_id,
            value=json.dumps({"1.0": {"1": ["Hint 1", 2], "3": ["Hint 3", 12]}, "2.0": {"4": ["Hint 4", 3]}}),
        )
        UserStateSummaryFactory.create(
            field_name="mod_queue", usage_id=self.problem_id, value=json.dumps({"2.0": {"2": ["Hint 2", 1]}})
        )

        UserStateSummaryFactory.create(field_name="hint_pk", usage_id=self.problem_id, value=5)
        # Mock out location_to_problem_name, which ordinarily accesses the modulestore.
        # (I can't figure out how to get fake structures into the modulestore.)
        view.location_to_problem_name = lambda course_id, loc: "Test problem"
    def setUp(self):
        """
        Makes a course, which will be the same for all tests.
        Set up mako middleware, which is necessary for template rendering to happen.
        """
        self.course = CourseFactory.create(org='Me', number='19.002', display_name='test_course')
        self.url = '/courses/Me/19.002/test_course/hint_manager'
        self.user = UserFactory.create(username='******', email='*****@*****.**', password='******', is_staff=True)
        self.c = Client()
        self.c.login(username='******', password='******')
        self.course_id = self.course.id
        self.problem_id = self.course_id.make_usage_key('crowdsource_hinter', 'crowdsource_hinter_001')
        UserStateSummaryFactory.create(
            field_name='hints',
            usage_id=self.problem_id,
            value=json.dumps({
                '1.0': {'1': ['Hint 1', 2], '3': ['Hint 3', 12]},
                '2.0': {'4': ['Hint 4', 3]}
            })
        )
        UserStateSummaryFactory.create(
            field_name='mod_queue',
            usage_id=self.problem_id,
            value=json.dumps({'2.0': {'2': ['Hint 2', 1]}})
        )

        UserStateSummaryFactory.create(
            field_name='hint_pk',
            usage_id=self.problem_id,
            value=5
        )
        # Mock out location_to_problem_name, which ordinarily accesses the modulestore.
        # (I can't figure out how to get fake structures into the modulestore.)
        view.location_to_problem_name = lambda course_id, loc: "Test problem"
    def setUp(self):
        """
        Makes a course, which will be the same for all tests.
        Set up mako middleware, which is necessary for template rendering to happen.
        """
        super(HintManagerTest, self).setUp()

        self.user = UserFactory.create(username='******', email='*****@*****.**', password='******', is_staff=True)
        self.c = Client()
        self.c.login(username='******', password='******')
        UserStateSummaryFactory.create(
            field_name='hints',
            usage_id=self.problem_id,
            value=json.dumps({
                '1.0': {'1': ['Hint 1', 2], '3': ['Hint 3', 12]},
                '2.0': {'4': ['Hint 4', 3]}
            })
        )
        UserStateSummaryFactory.create(
            field_name='mod_queue',
            usage_id=self.problem_id,
            value=json.dumps({'2.0': {'2': ['Hint 2', 1]}})
        )

        UserStateSummaryFactory.create(
            field_name='hint_pk',
            usage_id=self.problem_id,
            value=5
        )
        # Mock out location_to_problem_name, which ordinarily accesses the modulestore.
        # (I can't figure out how to get fake structures into the modulestore.)
        view.location_to_problem_name = lambda course_id, loc: "Test problem"
Beispiel #4
0
    def setUp(self):
        """
        Makes a course, which will be the same for all tests.
        Set up mako middleware, which is necessary for template rendering to happen.
        """
        self.course = CourseFactory.create(org='Me', number='19.002', display_name='test_course')
        self.url = '/courses/Me/19.002/test_course/hint_manager'
        self.user = UserFactory.create(username='******', email='*****@*****.**', password='******', is_staff=True)
        self.c = Client()
        self.c.login(username='******', password='******')
        self.course_id = self.course.id
        self.problem_id = self.course_id.make_usage_key('crowdsource_hinter', 'crowdsource_hinter_001')
        UserStateSummaryFactory.create(field_name='hints',
                              usage_id=self.problem_id,
                              value=json.dumps({'1.0': {'1': ['Hint 1', 2],
                                                        '3': ['Hint 3', 12]},
                                                '2.0': {'4': ['Hint 4', 3]}
                                                }))
        UserStateSummaryFactory.create(field_name='mod_queue',
                              usage_id=self.problem_id,
                              value=json.dumps({'2.0': {'2': ['Hint 2', 1]}}))

        UserStateSummaryFactory.create(field_name='hint_pk',
                              usage_id=self.problem_id,
                              value=5)
        # Mock out location_to_problem_name, which ordinarily accesses the modulestore.
        # (I can't figure out how to get fake structures into the modulestore.)
        view.location_to_problem_name = lambda course_id, loc: "Test problem"
Beispiel #5
0
    def setUp(self):
        """
        Makes a course, which will be the same for all tests.
        Set up mako middleware, which is necessary for template rendering to happen.
        """
        super(HintManagerTest, self).setUp()

        self.user = UserFactory.create(username='******',
                                       email='*****@*****.**',
                                       password='******',
                                       is_staff=True)
        self.c = Client()
        self.c.login(username='******', password='******')
        UserStateSummaryFactory.create(field_name='hints',
                                       usage_id=self.problem_id,
                                       value=json.dumps({
                                           '1.0': {
                                               '1': ['Hint 1', 2],
                                               '3': ['Hint 3', 12]
                                           },
                                           '2.0': {
                                               '4': ['Hint 4', 3]
                                           }
                                       }))
        UserStateSummaryFactory.create(field_name='mod_queue',
                                       usage_id=self.problem_id,
                                       value=json.dumps(
                                           {'2.0': {
                                               '2': ['Hint 2', 1]
                                           }}))

        UserStateSummaryFactory.create(field_name='hint_pk',
                                       usage_id=self.problem_id,
                                       value=5)
        # Mock out location_to_problem_name, which ordinarily accesses the modulestore.
        # (I can't figure out how to get fake structures into the modulestore.)
        view.location_to_problem_name = lambda course_id, loc: "Test problem"