diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index 1f14e29083..d910d73085 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -41,11 +41,14 @@ def i_press_the_category_delete_icon(step, category): ####### HELPER FUNCTIONS ############## def create_studio_user( uname='robot', - em='robot+studio@edx.org', - password='test'): + email='robot+studio@edx.org', + password='test', + is_staff=False): studio_user = UserFactory.build( username=uname, - email=em) + email=email, + password=password, + is_staff=is_staff) studio_user.set_password(password) studio_user.save() @@ -91,11 +94,12 @@ def fill_in_course_info( def log_into_studio( uname='robot', email='robot+studio@edx.org', - password='test'): - create_studio_user(uname, email) + password='test', + is_staff=False): + create_studio_user(uname=uname, email=email, is_staff=is_staff) world.browser.cookies.delete() world.browser.visit(django_url('/')) - world.browser.is_element_present_by_css('body.no-header', 10) + world.browser.is_element_present_by_css('body.no-header', 10) login_form = world.browser.find_by_css('form#login_form') login_form.find_by_name('email').fill(email) diff --git a/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature new file mode 100644 index 0000000000..d9d7414648 --- /dev/null +++ b/cms/djangoapps/contentstore/features/studio-overview-togglesection.feature @@ -0,0 +1,59 @@ +Feature: Overview Toggle Section + In order to quickly view the details of a course's section or to scan the inventory of sections + As a course author + I want to toggle the visibility of each section's subsection details in the overview listing + + Scenario: The default layout for the overview page is to show sections in expanded view + Given I have a course with multiple sections + When I navigate to the course overview page + Then I see the "Collapse All Sections" link + And all sections are expanded + + Scenario: Expand/collapse for a course with no sections + Given I have a course with no sections + When I navigate to the course overview page + Then I do not see the "Collapse All Sections" link + + Scenario: Collapse link appears after creating first section of a course + Given I have a course with no sections + When I navigate to the course overview page + And I add a section + Then I see the "Collapse All Sections" link + And all sections are expanded + + Scenario: Collapse link is removed after last section of a course is deleted + Given I have a course with 1 section + And I navigate to the course overview page + When I press the "section" delete icon + And I confirm the alert + Then I do not see the "Collapse All Sections" link + + Scenario: Collapsing all sections when all sections are expanded + Given I navigate to the courseware page of a course with multiple sections + And all sections are expanded + When I click the "Collapse All Sections" link + Then I see the "Expand All Sections" link + And all sections are collapsed + + Scenario: Collapsing all sections when 1 or more sections are already collapsed + Given I navigate to the courseware page of a course with multiple sections + And all sections are expanded + When I collapse the first section + And I click the "Collapse All Sections" link + Then I see the "Expand All Sections" link + And all sections are collapsed + + Scenario: Expanding all sections when all sections are collapsed + Given I navigate to the courseware page of a course with multiple sections + And I click the "Collapse All Sections" link + When I click the "Expand All Sections" link + Then I see the "Collapse All Sections" link + And all sections are expanded + + Scenario: Expanding all sections when 1 or more sections are already expanded + Given I navigate to the courseware page of a course with multiple sections + And I click the "Collapse All Sections" link + When I expand the first section + And I click the "Expand All Sections" link + Then I see the "Collapse All Sections" link + And all sections are expanded \ No newline at end of file diff --git a/cms/djangoapps/contentstore/features/studio-overview-togglesection.py b/cms/djangoapps/contentstore/features/studio-overview-togglesection.py new file mode 100644 index 0000000000..010678c0e8 --- /dev/null +++ b/cms/djangoapps/contentstore/features/studio-overview-togglesection.py @@ -0,0 +1,104 @@ +from lettuce import world, step +from terrain.factories import * +from common import * +from nose.tools import assert_true, assert_false, assert_equal + +from logging import getLogger +logger = getLogger(__name__) + +@step(u'I have a course with no sections$') +def have_a_course(step): + clear_courses() + course = CourseFactory.create() + +@step(u'I have a course with 1 section$') +def have_a_course_with_1_section(step): + clear_courses() + course = CourseFactory.create() + section = ItemFactory.create(parent_location=course.location) + subsection1 = ItemFactory.create( + parent_location=section.location, + template = 'i4x://edx/templates/sequential/Empty', + display_name = 'Subsection One',) + +@step(u'I have a course with multiple sections$') +def have_a_course_with_two_sections(step): + clear_courses() + course = CourseFactory.create() + section = ItemFactory.create(parent_location=course.location) + subsection1 = ItemFactory.create( + parent_location=section.location, + template = 'i4x://edx/templates/sequential/Empty', + display_name = 'Subsection One',) + section2 = ItemFactory.create( + parent_location=course.location, + display_name='Section Two',) + subsection2 = ItemFactory.create( + parent_location=section2.location, + template = 'i4x://edx/templates/sequential/Empty', + display_name = 'Subsection Alpha',) + subsection3 = ItemFactory.create( + parent_location=section2.location, + template = 'i4x://edx/templates/sequential/Empty', + display_name = 'Subsection Beta',) + +@step(u'I navigate to the course overview page$') +def navigate_to_the_course_overview_page(step): + log_into_studio(is_staff=True) + course_locator = '.class-name' + css_click(course_locator) + +@step(u'I navigate to the courseware page of a course with multiple sections') +def nav_to_the_courseware_page_of_a_course_with_multiple_sections(step): + step.given('I have a course with multiple sections') + step.given('I navigate to the course overview page') + +@step(u'I add a section') +def i_add_a_section(step): + add_section(name='My New Section That I Just Added') + +@step(u'I click the "([^"]*)" link$') +def i_click_the_text_span(step, text): + span_locator = '.toggle-button-sections span' + assert_true(world.browser.is_element_present_by_css(span_locator, 5)) + # first make sure that the expand/collapse text is the one you expected + assert_equal(world.browser.find_by_css(span_locator).value, text) + css_click(span_locator) + +@step(u'I collapse the first section$') +def i_collapse_a_section(step): + collapse_locator = 'section.courseware-section a.collapse' + css_click(collapse_locator) + +@step(u'I expand the first section$') +def i_expand_a_section(step): + expand_locator = 'section.courseware-section a.expand' + css_click(expand_locator) + +@step(u'I see the "([^"]*)" link$') +def i_see_the_span_with_text(step, text): + span_locator = '.toggle-button-sections span' + assert_true(world.browser.is_element_present_by_css(span_locator, 5)) + assert_equal(world.browser.find_by_css(span_locator).value, text) + assert_true(world.browser.find_by_css(span_locator).visible) + +@step(u'I do not see the "([^"]*)" link$') +def i_do_not_see_the_span_with_text(step, text): + # Note that the span will exist on the page but not be visible + span_locator = '.toggle-button-sections span' + assert_true(world.browser.is_element_present_by_css(span_locator)) + assert_false(world.browser.find_by_css(span_locator).visible) + +@step(u'all sections are expanded$') +def all_sections_are_expanded(step): + subsection_locator = 'div.subsection-list' + subsections = world.browser.find_by_css(subsection_locator) + for s in subsections: + assert_true(s.visible) + +@step(u'all sections are collapsed$') +def all_sections_are_expanded(step): + subsection_locator = 'div.subsection-list' + subsections = world.browser.find_by_css(subsection_locator) + for s in subsections: + assert_false(s.visible) \ No newline at end of file diff --git a/common/lib/xmodule/xmodule/js/fixtures/problem-with-markdown.html b/common/lib/xmodule/xmodule/js/fixtures/problem-with-markdown.html new file mode 100644 index 0000000000..be4fcd5ecc --- /dev/null +++ b/common/lib/xmodule/xmodule/js/fixtures/problem-with-markdown.html @@ -0,0 +1,6 @@ +
+
+ + +
+
\ No newline at end of file diff --git a/common/lib/xmodule/xmodule/js/fixtures/problem-without-markdown.html b/common/lib/xmodule/xmodule/js/fixtures/problem-without-markdown.html new file mode 100644 index 0000000000..06225e99b6 --- /dev/null +++ b/common/lib/xmodule/xmodule/js/fixtures/problem-without-markdown.html @@ -0,0 +1,5 @@ +
+
+ +
+
\ No newline at end of file diff --git a/common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee b/common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee index 3289c5fe7d..55fcb9adbf 100644 --- a/common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee +++ b/common/lib/xmodule/xmodule/js/spec/problem/edit_spec.coffee @@ -1,4 +1,24 @@ describe 'MarkdownEditingDescriptor', -> + describe 'save stores the correct data', -> + it 'saves markdown from markdown editor', -> + loadFixtures 'problem-with-markdown.html' + @descriptor = new MarkdownEditingDescriptor($('.problem-editor')) + saveResult = @descriptor.save() + expect(saveResult.metadata.markdown).toEqual('markdown') + expect(saveResult.data).toEqual('\n

markdown

\n
') + it 'clears markdown when xml editor is selected', -> + loadFixtures 'problem-with-markdown.html' + @descriptor = new MarkdownEditingDescriptor($('.problem-editor')) + @descriptor.createXMLEditor('replace with markdown') + saveResult = @descriptor.save() + expect(saveResult.metadata.markdown).toEqual(null) + expect(saveResult.data).toEqual('replace with markdown') + it 'saves xml from the xml editor', -> + loadFixtures 'problem-without-markdown.html' + @descriptor = new MarkdownEditingDescriptor($('.problem-editor')) + saveResult = @descriptor.save() + expect(saveResult.metadata.markdown).toEqual(null) + expect(saveResult.data).toEqual('xml only') describe 'insertMultipleChoice', -> it 'inserts the template if selection is empty', -> @@ -62,24 +82,20 @@ describe 'MarkdownEditingDescriptor', -> Enter the numerical value of Pi: = 3.14159 +- .02 - + Enter the approximate value of 502*9: = 4518 +- 15% - + Enter the number of fingers on a human hand: = 5 - -
- Explanation - + [Explanation] Pi, or the the ratio between a circle's circumference to its diameter, is an irrational number known to extreme precision. It is value is approximately equal to 3.14. Although you can get an exact value by typing 502*9 into a calculator, the result will be close to 500*10, or 5,000. The grader accepts any response within 15% of the true value, 4518, so that you can use any estimation technique that you like. If you look at your hand, you can count that you have five fingers. -
-
+ [Explanation] """) expect(data).toEqual("""

A numerical response problem accepts a line of text input from the student, and evaluates the input for correctness based on its numerical value.

@@ -104,7 +120,7 @@ describe 'MarkdownEditingDescriptor', -> -
+

Explanation

Pi, or the the ratio between a circle's circumference to its diameter, is an irrational number known to extreme precision. It is value is approximately equal to 3.14.

@@ -112,6 +128,7 @@ describe 'MarkdownEditingDescriptor', ->

Although you can get an exact value by typing 502*9 into a calculator, the result will be close to 500*10, or 5,000. The grader accepts any response within 15% of the true value, 4518, so that you can use any estimation technique that you like.

If you look at your hand, you can count that you have five fingers.

+
""") @@ -128,13 +145,9 @@ describe 'MarkdownEditingDescriptor', -> ( ) Android ( ) The Beatles - -
- Explanation - + [Explanation] The release of the iPod allowed consumers to carry their entire music library with them in a format that did not rely on fragile and energy-intensive spinning disks. -
-
+ [Explanation] """) expect(data).toEqual("""

A multiple choice problem presents radio buttons for student input. Students can only select a single option presented. Multiple Choice questions have been the subject of many areas of research due to the early invention and adoption of bubble sheets.

@@ -154,10 +167,11 @@ describe 'MarkdownEditingDescriptor', -> -
+

Explanation

The release of the iPod allowed consumers to carry their entire music library with them in a format that did not rely on fragile and energy-intensive spinning disks.

+
""") @@ -169,13 +183,9 @@ describe 'MarkdownEditingDescriptor', -> Translation between Option Response and __________ is extremely straightforward: [[(Multiple Choice), String Response, Numerical Response, External Response, Image Response]] - -
- Explanation - + [Explanation] Multiple Choice also allows students to select from a variety of pre-written responses, although the format makes it easier for students to read very long response options. Optionresponse also differs slightly because students are more likely to think of an answer and then search for it rather than relying purely on recognition to answer the question. -
-
+ [Explanation] """) expect(data).toEqual("""

OptionResponse gives a limited set of options for students to respond with, and presents those options in a format that encourages them to search for a specific answer rather than being immediately presented with options from which to recognize the correct answer.

@@ -189,14 +199,15 @@ describe 'MarkdownEditingDescriptor', -> -
+

Explanation

Multiple Choice also allows students to select from a variety of pre-written responses, although the format makes it easier for students to read very long response options. Optionresponse also differs slightly because students are more likely to think of an answer and then search for it rather than relying purely on recognition to answer the question.

+
""") - it 'converts OptionResponse to xml', -> + it 'converts StringResponse to xml', -> data = MarkdownEditingDescriptor.markdownToXml("""A string response problem accepts a line of text input from the student, and evaluates the input for correctness based on an expected answer within each input box. The answer is correct if it matches every character of the expected answer. This can be a problem with international spelling, dates, or anything where the format of the answer is not clear. @@ -204,14 +215,9 @@ describe 'MarkdownEditingDescriptor', -> Which US state has Lansing as its capital? = Michigan - -
- Explanation - + [Explanation] Lansing is the capital of Michigan, although it is not Michgan's largest city, or even the seat of the county in which it resides. - -
-
+ [Explanation] """) expect(data).toEqual("""

A string response problem accepts a line of text input from the student, and evaluates the input for correctness based on an expected answer within each input box.

@@ -224,11 +230,11 @@ describe 'MarkdownEditingDescriptor', -> -
+

Explanation

Lansing is the capital of Michigan, although it is not Michgan's largest city, or even the seat of the county in which it resides.

- +
""") @@ -261,6 +267,11 @@ describe 'MarkdownEditingDescriptor', -> What happens w/ empty correct options? [[()]] + + [Explanation]see[/expLanation] + + [explanation] + orphaned start No p tags in the below