From dc89a4b3d5a7528e7779b927b5692cd86886a36e Mon Sep 17 00:00:00 2001 From: cahrens Date: Mon, 18 Mar 2013 21:25:44 -0400 Subject: [PATCH] Beginning of Selenium test, updates to work with master. --- .../contentstore/features/checklists.feature | 13 +++++++ .../contentstore/features/checklists.py | 35 +++++++++++++++++++ cms/djangoapps/contentstore/views.py | 16 ++++----- .../models/settings/course_metadata.py | 2 +- cms/static/client_templates/checklist.html | 9 ++++- common/lib/xmodule/xmodule/course_module.py | 2 +- 6 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 cms/djangoapps/contentstore/features/checklists.feature create mode 100644 cms/djangoapps/contentstore/features/checklists.py diff --git a/cms/djangoapps/contentstore/features/checklists.feature b/cms/djangoapps/contentstore/features/checklists.feature new file mode 100644 index 0000000000..86f75e7f2a --- /dev/null +++ b/cms/djangoapps/contentstore/features/checklists.feature @@ -0,0 +1,13 @@ +Feature: Course checklists + + Scenario: A course author sees checklists defined by edX + Given I have opened a new course in Studio + When I select Checklists from the Tools menu + Then I see the four default edX checklists + + + Scenario: A course author can mark tasks as complete + Given I have opened a new course in Studio + When I select Checklists from the Tools menu + Then I can select tasks in a checklist + And They are still selected after I reload the page \ No newline at end of file diff --git a/cms/djangoapps/contentstore/features/checklists.py b/cms/djangoapps/contentstore/features/checklists.py new file mode 100644 index 0000000000..ffb4cb7f00 --- /dev/null +++ b/cms/djangoapps/contentstore/features/checklists.py @@ -0,0 +1,35 @@ +from lettuce import world, step +from common import * +from terrain.steps import reload_the_page + +############### ACTIONS #################### +@step('I select Checklists from the Tools menu$') +def i_select_checklists(step): + expand_icon_css = 'li.nav-course-tools i.icon-expand' + if world.browser.is_element_present_by_css(expand_icon_css): + css_click(expand_icon_css) + link_css = 'li.nav-course-tools-checklists a' + css_click(link_css) + + +@step('I see the four default edX checklists$') +def i_see_default_checklists(step): + checklists = css_find('.checklist-title') + assert_equal(4, len(checklists)) + assert_true(checklists[0].text.endswith('Getting Started With Studio')) + assert_true(checklists[1].text.endswith('Draft a Rough Course Outline')) + assert_true(checklists[2].text.endswith("Explore edX\'s Support Tools")) + assert_true(checklists[3].text.endswith('Draft your Course Introduction')) + + +@step('I can select tasks in a checklist$') +def i_can_select_tasks(step): + # Use the 2nd checklist as a reference + assert_equal('0', css_find('#course-checklist1 .status-count').first.text) + assert_equal('7', css_find('#course-checklist1 .status-amount').first.text) + # TODO: check progress bar, select several items and check how things change + + +@step('They are still selected after I reload the page$') +def tasks_still_selected_after_reload(step): + reload_the_page(step) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 1e441c5eb3..64cf22882b 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -1299,12 +1299,11 @@ def get_checklists(request, org, course, name): template_module = modulestore.get_item(new_course_template) # If course was created before checklists were introduced, copy them over from the template. - key = "checklists" - if not key in course_module.metadata: - course_module.metadata[key] = template_module.metadata[key] - modulestore.update_metadata(location, course_module.metadata) + if not course_module.checklists: + course_module.checklists = template_module.checklists + modulestore.update_metadata(location, own_metadata(course_module)) - checklists = course_module.metadata[key] + checklists = course_module.checklists return render_to_response('checklists.html', { 'context_course': course_module, @@ -1318,17 +1317,16 @@ def update_checklist(request, org, course, name, checklist_index=None): location = get_location_and_verify_access(request, org, course, name) modulestore = get_modulestore(location) course_module = modulestore.get_item(location) - key = "checklists" real_method = get_request_method(request) if checklist_index is not None and (real_method == 'POST' or real_method == 'PUT'): modified_checklist = json.loads(request.body) - (course_module.metadata[key])[int(checklist_index)] = modified_checklist - modulestore.update_metadata(location, course_module.metadata) + course_module.checklists[int(checklist_index)] = modified_checklist + modulestore.update_metadata(location, own_metadata(course_module)) return HttpResponse(json.dumps(modified_checklist), mimetype="application/json") elif request.method == 'GET': # TODO: Would we ever get in this condition? Any point in having this code? - return HttpResponse(json.dumps(course_module.metadata[key]), mimetype="application/json") + return HttpResponse(json.dumps(course_module.checklists), mimetype="application/json") @login_required diff --git a/cms/djangoapps/models/settings/course_metadata.py b/cms/djangoapps/models/settings/course_metadata.py index ed11a6d7a4..63025d8abe 100644 --- a/cms/djangoapps/models/settings/course_metadata.py +++ b/cms/djangoapps/models/settings/course_metadata.py @@ -10,7 +10,7 @@ class CourseMetadata(object): For CRUD operations on metadata fields which do not have specific editors on the other pages including any user generated ones. The objects have no predefined attrs but instead are obj encodings of the editable metadata. ''' - FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start', 'end', 'enrollment_start', 'enrollment_end', 'tabs', 'graceperiod'] + FILTERED_LIST = XModuleDescriptor.system_metadata_fields + ['start', 'end', 'enrollment_start', 'enrollment_end', 'tabs', 'graceperiod', 'checklists'] @classmethod def fetch(cls, course_location): diff --git a/cms/static/client_templates/checklist.html b/cms/static/client_templates/checklist.html index d3e6d9d820..c741dad340 100644 --- a/cms/static/client_templates/checklist.html +++ b/cms/static/client_templates/checklist.html @@ -1,4 +1,11 @@ -
+<% var allChecked = itemsChecked == items.length; %> +
+ class="course-checklist is-completed" + <% } else { %> + class="course-checklist" + <% } %> + id="<%= 'course-checklist' + checklistIndex %>"> <% var widthPercentage = 'width:' + percentChecked + '%;'; %> <%= percentChecked %>% of checklist completed diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 7c47e0887a..d43dd54179 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -179,7 +179,7 @@ class CourseFields(object): allow_anonymous_to_peers = Boolean(scope=Scope.settings, default=False) advanced_modules = List(help="Beta modules used in your course", scope=Scope.settings) has_children = True - + checklists=List(scope=Scope.settings) info_sidebar_name = String(scope=Scope.settings, default='Course Handouts') # An extra property is used rather than the wiki_slug/number because