示例#1
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>'
        )
示例#2
0
文件: gst.py 项目: jswope00/griffinx
    def setup_gst(self, step):
        r'that I have a course with a Graphical Slider Tool$'

        i_am_registered_for_the_course(step, self.COURSE_NUM)

        world.scenario_dict['GST'] = world.ItemFactory(
            parent_location=world.scenario_dict['SECTION'].location,
            category='graphical_slider_tool',
            display_name="Test GST",
            data=DEFAULT_DATA)
示例#3
0
    def define_component(self, step, count):
        r"""that a course has an annotatable component with (?P<count>\d+) annotations$"""

        count = int(count)
        coursenum = 'test_course'
        i_am_registered_for_the_course(step, coursenum)

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

        world.scenario_dict['ANNOTATABLE'] = world.ItemFactory(
            parent_location=world.scenario_dict['ANNOTATION_VERTICAL'].location,
            category='annotatable',
            display_name="Test Annotation Module",
            data=DATA_TEMPLATE.format("\n".join(ANNOTATION_TEMPLATE.format(i) for i in xrange(count)))
        )
        self.annotations_count = count
示例#4
0
    def add_problems(self, step, count):
        r"""the course has (?P<count>\d+) annotatation problems$"""
        count = int(count)

        for i in xrange(count):
            world.scenario_dict.setdefault('PROBLEMS', []).append(
                world.ItemFactory(
                    parent_location=world.scenario_dict['ANNOTATION_VERTICAL'].
                    location,
                    category='problem',
                    display_name="Test Annotation Problem {}".format(i),
                    data=PROBLEM_TEMPLATE.format(
                        number=i,
                        options="\n".join(
                            OPTION_TEMPLATE.format(
                                number=k, correctness=_correctness(k, i))
                            for k in xrange(count)))))