Example #1
0
def _view_problem(step, problem_type, problem_settings=None):
    i_am_registered_for_the_course(step, 'model_course')

    # Ensure that the course has this problem type
    add_problem_to_course(world.scenario_dict['COURSE'].number, problem_type, problem_settings)

    # Go to the one section in the factory-created course
    # which should be loaded with the correct problem
    visit_scenario_item('SECTION')
def view_problem(step, problem_type):
    i_am_registered_for_the_course(step, 'model_course')

    # Ensure that the course has this problem type
    add_problem_to_course('model_course', problem_type)

    # Go to the one section in the factory-created course
    # which should be loaded with the correct problem
    chapter_name = TEST_SECTION_NAME.replace(" ", "_")
    section_name = chapter_name
    url = django_url('/courses/edx/model_course/Test_Course/courseware/%s/%s' %
                     (chapter_name, section_name))

    world.browser.visit(url)
Example #3
0
def view_problem(step, problem_type):
    i_am_registered_for_the_course(step, 'model_course')

    # Ensure that the course has this problem type
    add_problem_to_course('model_course', problem_type)

    # Go to the one section in the factory-created course
    # which should be loaded with the correct problem
    chapter_name = TEST_SECTION_NAME.replace(" ", "_")
    section_name = chapter_name
    url = django_url('/courses/edx/model_course/Test_Course/courseware/%s/%s' %
                    (chapter_name, section_name))

    world.browser.visit(url)
Example #4
0
def view_problem(step, problem_type):
    i_am_registered_for_the_course(step, 'model_course')

    # Ensure that the course has this problem type
    add_problem_to_course('model_course', problem_type)

    # Go to the one section in the factory-created course
    # which should be loaded with the correct problem
    chapter_name = world.scenario_dict['SECTION'].display_name.replace(" ", "_")
    section_name = chapter_name
    url = django_url('/courses/%s/%s/%s/courseware/%s/%s' %
                    (world.scenario_dict['COURSE'].org, world.scenario_dict['COURSE'].number, world.scenario_dict['COURSE'].display_name.replace(' ', '_'),
                        chapter_name, section_name,))
    world.browser.visit(url)
Example #5
0
    def setup_conditional(self, step, condition_type, condition, cond_value):
        r'that a course has a Conditional conditioned on (?P<condition_type>\w+) (?P<condition>\w+)=(?P<cond_value>\w+)$'

        i_am_registered_for_the_course(step, self.COURSE_NUM)

        world.scenario_dict['VERTICAL'] = world.ItemFactory(
            parent_location=world.scenario_dict['SECTION'].location,
            category='vertical',
            display_name="Test Vertical",
        )

        world.scenario_dict['WRAPPER'] = world.ItemFactory(
            parent_location=world.scenario_dict['VERTICAL'].location,
            category='wrapper',
            display_name="Test Poll Wrapper")

        if condition_type == 'problem':
            world.scenario_dict['CONDITION_SOURCE'] = add_problem_to_course(
                self.COURSE_NUM, 'string')
        elif condition_type == 'poll':
            world.scenario_dict['CONDITION_SOURCE'] = world.ItemFactory(
                parent_location=world.scenario_dict['WRAPPER'].location,
                category='poll_question',
                display_name='Conditional Poll',
                data={
                    'question':
                    'Is this a good poll?',
                    'answers': [{
                        'id': 'yes',
                        'text': 'Yes, of course'
                    }, {
                        'id': 'no',
                        'text': 'Of course not!'
                    }],
                })
        else:
            raise Exception(
                "Unknown condition type: {!r}".format(condition_type))

        metadata = {
            'xml_attributes': {
                'sources':
                world.scenario_dict['CONDITION_SOURCE'].location.url()
            }
        }
        metadata['xml_attributes'][condition] = cond_value

        world.scenario_dict['CONDITIONAL'] = world.ItemFactory(
            parent_location=world.scenario_dict['WRAPPER'].location,
            category='conditional',
            display_name="Test Conditional",
            metadata=metadata)

        world.ItemFactory(
            parent_location=world.scenario_dict['CONDITIONAL'].location,
            category='html',
            display_name='Conditional Contents',
            data='<html><div class="hidden-contents">Hidden Contents</p></html>'
        )
Example #6
0
    def setup_conditional(self, step, condition_type, condition, cond_value):
        r'that a course has a Conditional conditioned on (?P<condition_type>\w+) (?P<condition>\w+)=(?P<cond_value>\w+)$'

        i_am_registered_for_the_course(step, self.COURSE_NUM)

        world.scenario_dict['VERTICAL'] = world.ItemFactory(
            parent_location=world.scenario_dict['SECTION'].location,
            category='vertical',
            display_name="Test Vertical",
        )

        world.scenario_dict['WRAPPER'] = world.ItemFactory(
            parent_location=world.scenario_dict['VERTICAL'].location,
            category='wrapper',
            display_name="Test Poll Wrapper"
        )

        if condition_type == 'problem':
            world.scenario_dict['CONDITION_SOURCE'] = add_problem_to_course(self.COURSE_NUM, 'string')
        elif condition_type == 'poll':
            world.scenario_dict['CONDITION_SOURCE'] = world.ItemFactory(
                parent_location=world.scenario_dict['WRAPPER'].location,
                category='poll_question',
                display_name='Conditional Poll',
                data={
                    'question': 'Is this a good poll?',
                    'answers': [
                        {'id': 'yes', 'text': 'Yes, of course'},
                        {'id': 'no', 'text': 'Of course not!'}
                    ],
                }
            )
        else:
            raise Exception("Unknown condition type: {!r}".format(condition_type))

        metadata = {
            'xml_attributes': {
                condition: cond_value
            }
        }

        world.scenario_dict['CONDITIONAL'] = world.ItemFactory(
            parent_location=world.scenario_dict['WRAPPER'].location,
            category='conditional',
            display_name="Test Conditional",
            metadata=metadata,
            sources_list=[world.scenario_dict['CONDITION_SOURCE'].location],
        )

        world.ItemFactory(
            parent_location=world.scenario_dict['CONDITIONAL'].location,
            category='html',
            display_name='Conditional Contents',
            data='<html><div class="hidden-contents">Hidden Contents</p></html>'
        )

        publish(world.scenario_dict['VERTICAL'].location)
Example #7
0
def view_problem(step, problem_type):
    i_am_registered_for_the_course(step, 'model_course')

    # Ensure that the course has this problem type
    add_problem_to_course('model_course', problem_type)

    # Go to the one section in the factory-created course
    # which should be loaded with the correct problem
    chapter_name = world.scenario_dict['SECTION'].display_name.replace(
        " ", "_")
    section_name = chapter_name
    url = django_url('/courses/%s/%s/%s/courseware/%s/%s' % (
        world.scenario_dict['COURSE'].org,
        world.scenario_dict['COURSE'].number,
        world.scenario_dict['COURSE'].display_name.replace(' ', '_'),
        chapter_name,
        section_name,
    ))
    world.browser.visit(url)
def view_problem_with_show_answer(step, problem_type, answer):
    i_am_registered_for_the_course(step, "model_course")

    # Ensure that the course has this problem type
    add_problem_to_course("model_course", problem_type, {"showanswer": answer})

    # Go to the one section in the factory-created course
    # which should be loaded with the correct problem
    chapter_name = world.scenario_dict["SECTION"].display_name.replace(" ", "_")
    section_name = chapter_name
    url = django_url(
        "/courses/%s/%s/%s/courseware/%s/%s"
        % (
            world.scenario_dict["COURSE"].org,
            world.scenario_dict["COURSE"].number,
            world.scenario_dict["COURSE"].display_name.replace(" ", "_"),
            chapter_name,
            section_name,
        )
    )
    world.browser.visit(url)
Example #9
0
    def setup_conditional(self, step, condition_type, condition, cond_value):
        r"that a course has a Conditional conditioned on (?P<condition_type>\w+) (?P<condition>\w+)=(?P<cond_value>\w+)$"

        i_am_registered_for_the_course(step, self.COURSE_NUM)

        world.scenario_dict["VERTICAL"] = world.ItemFactory(
            parent_location=world.scenario_dict["SECTION"].location, category="vertical", display_name="Test Vertical"
        )

        world.scenario_dict["WRAPPER"] = world.ItemFactory(
            parent_location=world.scenario_dict["VERTICAL"].location,
            category="wrapper",
            display_name="Test Poll Wrapper",
        )

        if condition_type == "problem":
            world.scenario_dict["CONDITION_SOURCE"] = add_problem_to_course(self.COURSE_NUM, "string")
        elif condition_type == "poll":
            world.scenario_dict["CONDITION_SOURCE"] = world.ItemFactory(
                parent_location=world.scenario_dict["WRAPPER"].location,
                category="poll_question",
                display_name="Conditional Poll",
                data={
                    "question": "Is this a good poll?",
                    "answers": [{"id": "yes", "text": "Yes, of course"}, {"id": "no", "text": "Of course not!"}],
                },
            )
        else:
            raise Exception("Unknown condition type: {!r}".format(condition_type))

        metadata = {"xml_attributes": {condition: cond_value}}

        world.scenario_dict["CONDITIONAL"] = world.ItemFactory(
            parent_location=world.scenario_dict["WRAPPER"].location,
            category="conditional",
            display_name="Test Conditional",
            metadata=metadata,
            sources_list=[world.scenario_dict["CONDITION_SOURCE"].location],
        )

        world.ItemFactory(
            parent_location=world.scenario_dict["CONDITIONAL"].location,
            category="html",
            display_name="Conditional Contents",
            data='<html><div class="hidden-contents">Hidden Contents</p></html>',
        )