def _install_course_fixture(self): """ Install the course fixture that has been defined """ if self.assets: self.course_fixture.add_asset(self.assets) chapter_sequential = XBlockFixtureDesc('sequential', 'Test Section') chapter_sequential.add_children(*self._add_course_verticals()) chapter = XBlockFixtureDesc('chapter', 'Test Chapter').add_children(chapter_sequential) self.course_fixture.add_children(chapter) self.course_fixture.install() if len(self.youtube_configuration) > 0: YouTubeStubConfig.configure(self.youtube_configuration)
def _create_single_vertical(self, vertical_contents, vertical_index): """ Create a single course vertical of type XBlockFixtureDesc with category `vertical`. A single course vertical can contain single or multiple video modules. :param vertical_contents: a list of items for the vertical to contain :param vertical_index: index for the vertical display name :return: XBlockFixtureDesc """ xblock_course_vertical = XBlockFixtureDesc('vertical', u'Test Vertical-{0}'.format(vertical_index)) for video in vertical_contents: xblock_course_vertical.add_children( XBlockFixtureDesc('video', video['display_name'], metadata=video.get('metadata'))) return xblock_course_vertical
class TestCourseBadExport(BadExportMixin, StudioCourseTest): """ Verify exporting a bad course causes an error. """ ready_method = 'wait_for_component_menu' def setUp(self): # pylint: disable=arguments-differ super(TestCourseBadExport, self).setUp() self.export_page = ExportCoursePage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'], ) self.edit_page = ContainerPage(self.browser, self.unit.locator) self.export_page.visit() def populate_course_fixture(self, course_fixture): """ Populate the course with a unit that has a bad problem. """ self.unit = XBlockFixtureDesc('vertical', 'Unit') course_fixture.add_children( XBlockFixtureDesc('chapter', 'Main Section').add_children( XBlockFixtureDesc('sequential', 'Subsection').add_children( self.unit.add_children( XBlockFixtureDesc("problem", "Bad Problem", data='<') ) ) ) )
class TestCourseBadExport(BadExportMixin, StudioCourseTest): """ Verify exporting a bad course causes an error. """ ready_method = "wait_for_component_menu" def setUp(self): # pylint: disable=arguments-differ super(TestCourseBadExport, self).setUp() self.export_page = ExportCoursePage( self.browser, self.course_info["org"], self.course_info["number"], self.course_info["run"] ) self.edit_page = ContainerPage(self.browser, self.unit.locator) self.export_page.visit() def populate_course_fixture(self, course_fixture): """ Populate the course with a unit that has a bad problem. """ self.unit = XBlockFixtureDesc("vertical", "Unit") course_fixture.add_children( XBlockFixtureDesc("chapter", "Main Section").add_children( XBlockFixtureDesc("sequential", "Subsection").add_children( self.unit.add_children(XBlockFixtureDesc("problem", "Bad Problem", data="<")) ) ) )
def populate_course_fixture(self, course_fixture): """ Create a course with a single chapter. That chapter has a single section. That section has a single vertical. That vertical has a single video element. """ video_block = XBlockFixtureDesc('video', "Test Video") vertical = XBlockFixtureDesc('vertical', "Test Vertical") vertical.add_children(video_block) sequential = XBlockFixtureDesc('sequential', "Test Section") sequential.add_children(vertical) chapter = XBlockFixtureDesc('chapter', "Test Chapter") chapter.add_children(sequential) self.course_fixture.add_children(chapter)
def populate_course_fixture(self, course_fixture): """ Populate the course with a unit that has a bad problem. """ self.unit = XBlockFixtureDesc("vertical", "Unit") course_fixture.add_children( XBlockFixtureDesc("chapter", "Main Section").add_children( XBlockFixtureDesc("sequential", "Subsection").add_children( self.unit.add_children(XBlockFixtureDesc("problem", "Bad Problem", data="<")) ) ) )
def populate_course_fixture(self, course_fixture): """ Populate the course with a unit that has a bad problem. """ self.unit = XBlockFixtureDesc('vertical', 'Unit') course_fixture.add_children( XBlockFixtureDesc('chapter', 'Main Section').add_children( XBlockFixtureDesc('sequential', 'Subsection').add_children( self.unit.add_children( XBlockFixtureDesc("problem", "Bad Problem", data='<') ) ) ) )
def get_problem(self): """ Create a multiple choice problem """ xml = dedent(""" <problem> <multiplechoiceresponse> <label>What is height of eiffel tower without the antenna?.</label> <choicegroup type="MultipleChoice"> <choice correct="false">324 meters<choicehint>Antenna is 24 meters high</choicehint></choice> <choice correct="true">300 meters</choice> <choice correct="false">224 meters</choice> <choice correct="false">400 meters</choice> </choicegroup> </multiplechoiceresponse> </problem> """) return XBlockFixtureDesc('problem', 'HEIGHT OF EIFFEL TOWER', data=xml)
def get_problem(self): """ Problem with extended hint features. """ xml = dedent(""" <problem> <p>question text</p> <stringresponse answer="A"> <stringequalhint answer="C"><a href="#">aa bb</a> cc</stringequalhint> <textline size="20"/> </stringresponse> <demandhint> <hint>aa <a href="#">bb</a> cc</hint> <hint><a href="#">dd ee</a> ff</hint> </demandhint> </problem> """) return XBlockFixtureDesc('problem', 'PROBLEM HTML HINT TEST', data=xml)
def get_problem(self): """ Problem with extended hint features. """ xml = dedent(""" <problem> <p>question text</p> <stringresponse answer="A"> <stringequalhint answer="B">hint</stringequalhint> <textline size="20"/> </stringresponse> <demandhint> <hint>demand-hint1</hint> <hint>demand-hint2</hint> </demandhint> </problem> """) return XBlockFixtureDesc('problem', 'TITLE', data=xml)
def get_problem(self): """ Problem structure """ xml = dedent(""" <problem> <label>Which of the following countries has the largest population?</label> <multiplechoiceresponse> <choicegroup type="MultipleChoice"> <choice correct="false">Brazil <choicehint>timely feedback -- explain why an almost correct answer is wrong</choicehint></choice> <choice correct="false">Germany</choice> <choice correct="true">Indonesia</choice> <choice correct="false">Russia</choice> </choicegroup> </multiplechoiceresponse> </problem> """) return XBlockFixtureDesc('problem', 'TEST PROBLEM', data=xml)
def get_problem(self): """MathExpressionInput problem XML.""" xml = dedent(r""" <problem> <script type="loncapa/python"> derivative = "n*x^(n-1)" </script> <formularesponse type="ci" samples="x,n@1,2:3,4#10" answer="$derivative"> <label>Let \( x\) be a variable, and let \( n\) be an arbitrary constant. What is the derivative of \( x^n\)?</label> <description>Enter the equation</description> <responseparam type="tolerance" default="0.00001"/> <formulaequationinput size="40"/> </formularesponse> </problem>""") return XBlockFixtureDesc('problem', 'MATHEXPRESSIONINPUT PROBLEM', data=xml)
def get_problem(self): """ Create a problem with question and description. """ xml = dedent(""" <problem> <choiceresponse> <label>Eggplant is a _____?</label> <description>{}</description> <description>{}</description> <checkboxgroup> <choice correct="true">vegetable</choice> <choice correct="false">fruit</choice> </checkboxgroup> </choiceresponse> </problem> """.format(*self.descriptions)) return XBlockFixtureDesc('problem', 'Label with Description', data=xml)
def get_problem(self): """ Create a problem with partial credit. """ xml = dedent(""" <problem> <p>The answer is 1. Partial credit for -1.</p> <numericalresponse answer="1" partial_credit="list"> <label>How many miles away from Earth is the sun? Use scientific notation to answer.</label> <formulaequationinput/> <responseparam type="tolerance" default="0.01" /> <responseparam partial_answers="-1" /> </numericalresponse> </problem> """) return XBlockFixtureDesc('problem', 'PARTIAL CREDIT TEST PROBLEM', data=xml)
def populate_course_fixture(self, course_fixture): """ Populate the children of the test course fixture. """ self.group_a_problem = 'GROUP A CONTENT' self.group_b_problem = 'GROUP B CONTENT' self.group_verified_problem = 'GROUP VERIFIED CONTENT' self.group_audit_problem = 'GROUP AUDIT CONTENT' self.group_a_and_b_problem = 'GROUP A AND B CONTENT' self.visible_to_all_problem = 'VISIBLE TO ALL CONTENT' course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection').add_children( XBlockFixtureDesc( 'vertical', 'Test Unit').add_children( XBlockFixtureDesc('problem', self.group_a_problem, data='<problem></problem>'), XBlockFixtureDesc('problem', self.group_b_problem, data='<problem></problem>'), XBlockFixtureDesc('problem', self.group_verified_problem, data='<problem></problem>'), XBlockFixtureDesc('problem', self.group_audit_problem, data='<problem></problem>'), XBlockFixtureDesc('problem', self.group_a_and_b_problem, data='<problem></problem>'), XBlockFixtureDesc( 'problem', self.visible_to_all_problem, data='<problem></problem>')))))
def test_cannot_delete_used_content_group(self): """ Scenario: Ensure that the user cannot delete used content group. Given I have a course with 1 Content Group And I go to the Group Configuration page When I try to delete the Content Group with name "New Content Group" Then I see the delete button is disabled. """ self.course_fixture._update_xblock( self.course_fixture._course_location, { "metadata": { u"user_partitions": [ create_user_partition_json(0, 'Configuration alpha,', 'Content Group Partition', [Group("0", 'alpha')], scheme="cohort") ], }, }) problem_data = dedent(""" <problem markdown="Simple Problem" max_attempts="" weight=""> <p>Choose Yes.</p> <choiceresponse> <checkboxgroup> <choice correct="true">Yes</choice> </checkboxgroup> </choiceresponse> </problem> """) vertical = self.course_fixture.get_nested_xblocks( category="vertical")[0] self.course_fixture.create_xblock( vertical.locator, XBlockFixtureDesc('problem', "VISIBLE TO ALPHA", data=problem_data, metadata={"group_access": { 0: [0] }}), ) self.group_configurations_page.visit() config = self.group_configurations_page.content_groups[0] self.assertTrue(config.delete_button_is_disabled)
def get_problem(self): """ Create a problem with a <clarification> """ xml = dedent(""" <problem markdown="null"> <text> <p> Given the data in Table 7 <clarification>Table 7: "Example PV Installation Costs", Page 171 of Roberts textbook</clarification>, compute the ROI <clarification>Return on Investment <strong>(per year)</strong></clarification> over 20 years. </p> <numericalresponse answer="6.5"> <textline label="Enter the annual ROI" trailing_text="%" /> </numericalresponse> </text> </problem> """) return XBlockFixtureDesc('problem', 'TOOLTIP TEST PROBLEM', data=xml)
def get_problem(self): """ creating the formula response problem, with reset button enabled. """ xml = dedent(""" <problem> <formularesponse type="ci" samples="R_1,R_2,R_3@1,2,3:3,4,5#10" answer="R_1*R_2/R_3"> <p>You can use this template as a guide to the OLX markup to use for math expression problems. Edit this component to replace the example with your own assessment.</p> <label>Add the question text, or prompt, here. This text is required. Example: Write an expression for the product of R_1, R_2, and the inverse of R_3.</label> <description>You can add an optional tip or note related to the prompt like this. Example: To test this example, the correct answer is R_1*R_2/R_3</description> <responseparam type="tolerance" default="0.00001"/> <formulaequationinput size="40"/> </formularesponse> </problem> """) return XBlockFixtureDesc('problem', 'TEST PROBLEM', data=xml, metadata={'show_reset_button': True})
def get_problem(self): """ TextInput problem XML. """ xml = dedent(""" <problem> <stringresponse answer="fight" type="ci"> <label>who wishes to _____ must first count the cost.</label> <description>Appear weak when you are strong, and strong when you are weak.</description> <description>In the midst of chaos, there is also opportunity.</description> <textline size="40"/> </stringresponse> <stringresponse answer="force" type="ci"> <label>A leader leads by example not by _____.</label> <description>The supreme art of war is to subdue the enemy without fighting.</description> <description>Great results, can be achieved with small forces.</description> <textline size="40"/> </stringresponse> </problem>""") return XBlockFixtureDesc('problem', 'TEXTINPUT PROBLEM', data=xml)
def get_problem(self): """ Create a problem with a <MathJax> in body and hint """ xml = dedent(r""" <problem> <p>Check mathjax has rendered [mathjax]E=mc^2[/mathjax]</p> <multiplechoiceresponse> <choicegroup label="Answer this?" type="MultipleChoice"> <choice correct="true">Choice1 <choicehint>Correct choice message</choicehint></choice> <choice correct="false">Choice2<choicehint>Wrong choice message</choicehint></choice> </choicegroup> </multiplechoiceresponse> <demandhint> <hint>mathjax should work1 \(E=mc^2\) </hint> <hint>mathjax should work2 [mathjax]E=mc^2[/mathjax]</hint> </demandhint> </problem> """) return XBlockFixtureDesc('problem', 'MATHJAX TEST PROBLEM', data=xml)
def get_problem(self): """ Problem structure. """ xml = dedent(""" <problem> <optionresponse> <p>You can use this template as a guide to the simple editor markdown and OLX markup to use for dropdown problems. Edit this component to replace this template with your own assessment.</p> <label>Which of the following is a fruit</label> <description>Choose wisely</description> <optioninput> <option correct="False">radish</option> <option correct="True">appple</option> <option correct="False">carrot</option> </optioninput> </optionresponse> </problem> """) return XBlockFixtureDesc('problem', 'Problem A11Y TEST', data=xml)
def test_cannot_delete_used_group_configuration(self): """ Scenario: Ensure that the user cannot delete unused group configuration. Given I have a course with group configuration that is used in the Content Experiment When I go to the Group Configuration page Then I do not see delete button and I see a note about that When I edit the Group Configuration Then I do not see delete button and I see the note about that """ # Create a new group configurations self.course_fixture._update_xblock( self.course_fixture._course_location, { "metadata": { u"user_partitions": [ create_user_partition_json( 0, "Name", "Description.", [Group("0", "Group A"), Group("1", "Group B")]) ], }, }) vertical = self.course_fixture.get_nested_xblocks( category="vertical")[0] self.course_fixture.create_xblock( vertical.locator, XBlockFixtureDesc('split_test', 'Test Content Experiment', metadata={'user_partition_id': 0})) # Go to the Group Configuration Page and click unit anchor self.page.visit() config = self.page.experiment_group_configurations[0] self.assertTrue(config.delete_button_is_disabled) self.assertIn('Cannot delete when in use by an experiment', config.delete_note) config.edit() self.assertTrue(config.delete_button_is_disabled) self.assertIn('Cannot delete when in use by an experiment', config.delete_note)
def setup_fixtures(self): course_fix = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Unit').add_children( XBlockFixtureDesc('acid_parent', 'Acid Parent Block').add_children( XBlockFixtureDesc('acid', 'First Acid Child', metadata={'name': 'first'}), XBlockFixtureDesc('acid', 'Second Acid Child', metadata={'name': 'second'}), XBlockFixtureDesc('html', 'Html Child', data="<html>Contents</html>"), ) ) ) ) ).install()
def populate_course_fixture(self, course_fixture): """ Populate the children of the test course fixture. """ self.group_a_html = 'GROUPACONTENT' self.group_b_html = 'GROUPBCONTENT' self.group_a_and_b_html = 'GROUPAANDBCONTENT' self.visible_to_all_html = 'VISIBLETOALLCONTENT' course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Unit').add_children( XBlockFixtureDesc('html', self.group_a_html, data='<html>GROUPACONTENT</html>'), XBlockFixtureDesc('html', self.group_b_html, data='<html>GROUPBCONTENT</html>'), XBlockFixtureDesc('html', self.group_a_and_b_html, data='<html>GROUPAANDBCONTENT</html>'), XBlockFixtureDesc('html', self.visible_to_all_html, data='<html>VISIBLETOALLCONTENT</html>') ) ) ) )
def populate_course_fixture(self, course_fixture): """ Populates test course with chapter, sequential, and 3 problems. One problem is visible to all, one problem is visible only to Group "alpha", and one problem is visible only to Group "beta". """ problem_data = dedent(""" <problem markdown="Simple Problem" max_attempts="" weight=""> <p>Choose Yes.</p> <choiceresponse> <checkboxgroup> <choice correct="true">Yes</choice> </checkboxgroup> </choiceresponse> </problem> """) self.alpha_text = "VISIBLE TO ALPHA" self.beta_text = "VISIBLE TO BETA" self.everyone_text = "VISIBLE TO EVERYONE" course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection').add_children( XBlockFixtureDesc( 'vertical', 'Test Unit').add_children( XBlockFixtureDesc( 'problem', self.alpha_text, data=problem_data, metadata={"group_access": { 0: [0] }}), XBlockFixtureDesc( 'problem', self.beta_text, data=problem_data, metadata={"group_access": { 0: [1] }}), XBlockFixtureDesc('problem', self.everyone_text, data=problem_data)))))
def get_problem(self): """ Create a matlab problem for the test. """ problem_data = dedent(""" <problem markdown="null"> <text> <p> Write MATLAB code to create the following row vector and store it in a variable named <code>V</code>. </p> <table id="a0000000466" class="equation" width="100%" cellspacing="0" cellpadding="7" style="table-layout:auto"> <tr> <td class="equation">[1 1 2 3 5 8 13]</td> </tr> </table> <p> <coderesponse queuename="matlab"> <matlabinput rows="10" cols="40" mode="" tabsize="4"> <plot_payload> </plot_payload> </matlabinput> <codeparam> <initial_display/> <answer_display> </answer_display> <grader_payload> </grader_payload> </codeparam> </coderesponse> </p> </text> </problem> """) return XBlockFixtureDesc('problem', 'Test Matlab Problem', data=problem_data)
def setup_sequential(self, metadata): """ Setup a sequential with DnD problem, alongwith the metadata provided. This method will allow to customize the sequential, such as changing the due date for individual tests. """ problem = self.get_problem() sequential = self.get_sequential(metadata=metadata) self.course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( sequential.add_children(problem) ) ).install() # Auto-auth register for the course. AutoAuthPage( self.browser, username=self.username, email=self.email, password=self.password, course_id=self.course_id, staff=True ).visit()
def setUp(self): super(AnnotatableProblemTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) # Install a course with two annotations and two annotations problems. course_fix = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ) self.annotation_count = 2 course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children( XBlockFixtureDesc('vertical', 'Test Annotation Vertical').add_children( XBlockFixtureDesc('annotatable', 'Test Annotation Module', data=self.DATA_TEMPLATE.format("\n".join( self.ANNOTATION_TEMPLATE.format(i) for i in xrange(self.annotation_count) ))), XBlockFixtureDesc('problem', 'Test Annotation Problem 0', data=self.PROBLEM_TEMPLATE.format(number=0, options="\n".join( self.OPTION_TEMPLATE.format( number=k, correctness=_correctness(k, 0)) for k in xrange(self.annotation_count) ))), XBlockFixtureDesc('problem', 'Test Annotation Problem 1', data=self.PROBLEM_TEMPLATE.format(number=1, options="\n".join( self.OPTION_TEMPLATE.format( number=k, correctness=_correctness(k, 1)) for k in xrange(self.annotation_count) ))) ) ) ) ).install() # Auto-auth register for the course. AutoAuthPage(self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=False).visit()
def setUp(self): """ Create the search page and courses to search. """ # create test file in which index for this test will live with open(self.TEST_INDEX_FILENAME, "w+") as index_file: json.dump({}, index_file) super(DashboardSearchTest, self).setUp() self.dashboard = DashboardSearchPage(self.browser) self.courses = { 'A': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_A', 'display_name': 'Test Course A ' }, 'B': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_B', 'display_name': 'Test Course B ' }, 'C': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_C', 'display_name': 'Test Course C ' } } # generate course fixtures and outline pages self.studio_course_outlines = {} self.course_fixtures = {} for key, course_info in six.iteritems(self.courses): studio_course_outline = StudioCourseOutlinePage( self.browser, course_info['org'], course_info['number'], course_info['run'] ) course_fix = CourseFixture( course_info['org'], course_info['number'], course_info['run'], course_info['display_name'] ) course_fix.add_children( XBlockFixtureDesc('chapter', 'Section 1').add_children( XBlockFixtureDesc('sequential', 'Subsection 1').add_children( XBlockFixtureDesc('problem', 'Test Problem') ) ) ).add_children( XBlockFixtureDesc('chapter', 'Section 2').add_children( XBlockFixtureDesc('sequential', 'Subsection 2') ) ).install() self.studio_course_outlines[key] = studio_course_outline self.course_fixtures[key] = course_fix
def setUp(self): """ Setup course """ super(LmsPerformanceTest, self).setUp() # Install a course with sections/problems, tabs, updates, and handouts course_fix = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) course_fix.add_update( CourseUpdateDesc(date='January 29, 2014', content='Test course update1')) course_fix.add_update( CourseUpdateDesc(date='January 30, 2014', content='Test course update2')) course_fix.add_update( CourseUpdateDesc(date='January 31, 2014', content='Test course update3')) course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection 1').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 1', data=load_data_str('multiple_choice.xml')), XBlockFixtureDesc( 'problem', 'Test Problem 2', data=load_data_str('formula_problem.xml')), XBlockFixtureDesc('html', 'Test HTML', data="<html>Html child text</html>"), )), XBlockFixtureDesc('chapter', 'Test Section 2').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection 2').add_children( XBlockFixtureDesc( 'html', 'Html Child', data="<html>Html child text</html>"))), XBlockFixtureDesc('chapter', 'Test Section 3').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 3').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 3')))).install() AutoAuthPage(self.browser, username=self.username, email=self.email, course_id=self.course_id).visit()
def setUp(self): super(VisibleToStaffOnlyTest, self).setUp() course_fix = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Subsection With Locked Unit'). add_children( XBlockFixtureDesc( 'vertical', 'Locked Unit', metadata={ 'visible_to_staff_only': True }).add_children( XBlockFixtureDesc( 'html', 'Html Child in locked unit', data="<html>Visible only to staff</html>"), ), XBlockFixtureDesc( 'vertical', 'Unlocked Unit').add_children( XBlockFixtureDesc( 'html', 'Html Child in unlocked unit', data="<html>Visible only to all</html>"), )), XBlockFixtureDesc( 'sequential', 'Unlocked Subsection').add_children( XBlockFixtureDesc( 'vertical', 'Test Unit').add_children( XBlockFixtureDesc( 'html', 'Html Child in visible unit', data="<html>Visible to all</html>"), )), XBlockFixtureDesc( 'sequential', 'Locked Subsection', metadata={ 'visible_to_staff_only': True }).add_children( XBlockFixtureDesc( 'vertical', 'Test Unit').add_children( XBlockFixtureDesc( 'html', 'Html Child in locked subsection', data="<html>Visible only to staff</html>")) ))).install() self.course_home_page = CourseHomePage(self.browser, self.course_id) self.courseware_page = CoursewarePage(self.browser, self.course_id)
def get_sequential(self): """ Allow any class in the inheritance chain to customize subsection metadata.""" return XBlockFixtureDesc('sequential', 'Test Subsection', metadata=getattr(self, 'sequential_metadata', {}))
def get_sequential(self): """ Subclasses can override this to add a sequential with metadata """ return XBlockFixtureDesc('sequential', 'Test Subsection', metadata={'due': "2016-10-01T00"})
def populate_course_fixture(self, course_fixture): """ Create a course with a single chapter. That chapter has a single section. That section has a single vertical. That vertical has a single video element. """ video_block = XBlockFixtureDesc('video', "Test Video") vertical = XBlockFixtureDesc('vertical', "Test Vertical") vertical.add_children(video_block) sequential = XBlockFixtureDesc('sequential', "Test Section") sequential.add_children(vertical) chapter = XBlockFixtureDesc('chapter', "Test Chapter") chapter.add_children(sequential) self.course_fixture.add_children(chapter)
def get_sequential(self): """ Subclasses can override this to add a sequential with metadata """ return XBlockFixtureDesc('sequential', 'Test Subsection')
def setUp(self): super(CoursewareMultipleVerticalsTest, self).setUp() self.courseware_page = CoursewarePage(self.browser, self.course_id) self.course_outline = CourseOutlinePage(self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) # Install a course with sections/problems, tabs, updates, and handouts course_fix = CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']) course_fix.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection 1,1').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 1', data='<problem>problem 1 dummy body</problem>'), XBlockFixtureDesc( 'html', 'html 1', data="<html>html 1 dummy body</html>"), XBlockFixtureDesc( 'problem', 'Test Problem 2', data="<problem>problem 2 dummy body</problem>"), XBlockFixtureDesc( 'html', 'html 2', data="<html>html 2 dummy body</html>"), ), XBlockFixtureDesc( 'sequential', 'Test Subsection 1,2').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 3', data='<problem>problem 3 dummy body</problem>'), ), XBlockFixtureDesc( 'sequential', 'Test HIDDEN Subsection', metadata={ 'visible_to_staff_only': True }).add_children( XBlockFixtureDesc( 'problem', 'Test HIDDEN Problem', data='<problem>hidden problem</problem>'), ), ), XBlockFixtureDesc('chapter', 'Test Section 2').add_children( XBlockFixtureDesc( 'sequential', 'Test Subsection 2,1').add_children( XBlockFixtureDesc( 'problem', 'Test Problem 4', data='<problem>problem 4 dummy body</problem>'), ), ), XBlockFixtureDesc( 'chapter', 'Test HIDDEN Section', metadata={ 'visible_to_staff_only': True }).add_children( XBlockFixtureDesc('sequential', 'Test HIDDEN Subsection'), ), ).install() # Auto-auth register for the course. AutoAuthPage(self.browser, username=self.USERNAME, email=self.EMAIL, course_id=self.course_id, staff=False).visit() self.courseware_page.visit() self.course_nav = CourseNavPage(self.browser)
def install_course_fixture(self, block_type='problem'): """ Install a course fixture """ course_fixture = CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'], ) vertical = XBlockFixtureDesc('vertical', 'Test Unit') # populate the course fixture with the right conditional modules course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section').add_children( XBlockFixtureDesc('sequential', 'Test Subsection').add_children(vertical))) course_fixture.install() # Construct conditional block source_block = None conditional_attr = None conditional_value = None if block_type == 'problem': problem_factory = StringResponseXMLFactory() problem_xml = problem_factory.build_xml( question_text='The answer is "correct string"', case_sensitive=False, answer='correct string', ), problem = XBlockFixtureDesc('problem', 'Test Problem', data=problem_xml[0]) source_block = problem conditional_attr = 'attempted' conditional_value = 'True' elif block_type == 'poll': poll = XBlockFixtureDesc( 'poll_question', 'Conditional Poll', question='Is this a good poll?', answers=[{ 'id': 'yes', 'text': POLL_ANSWER }, { 'id': 'no', 'text': 'Of course not!' }], ) conditional_attr = 'poll_answer' conditional_value = 'yes' source_block = poll else: raise NotImplementedError() course_fixture.create_xblock(vertical.locator, source_block) # create conditional conditional = XBlockFixtureDesc('conditional', 'Test Conditional', sources_list=[source_block.locator], conditional_attr=conditional_attr, conditional_value=conditional_value) result_block = XBlockFixtureDesc( 'html', 'Conditional Contents', data='<html><div class="hidden-contents">Hidden Contents</p></html>' ) course_fixture.create_xblock(vertical.locator, conditional) course_fixture.create_xblock(conditional.locator, result_block)