From 38165efd18ef1a84a23e6ef6bbe5978691c4d0c4 Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Tue, 20 Aug 2013 12:42:36 -0400 Subject: [PATCH 1/2] Fix failing grade label being editable but not saved. --- .../js/views/settings/settings_grading_view.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cms/static/js/views/settings/settings_grading_view.js b/cms/static/js/views/settings/settings_grading_view.js index 8c2af25f8c..b6fac04899 100644 --- a/cms/static/js/views/settings/settings_grading_view.js +++ b/cms/static/js/views/settings/settings_grading_view.js @@ -8,7 +8,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({ // Leaving change in as fallback for older browsers "change input" : "updateModel", "change textarea" : "updateModel", - "input span[contenteditable]" : "updateDesignation", + "input span[contenteditable=true]" : "updateDesignation", "click .settings-extra header" : "showSettingsExtras", "click .new-grade-button" : "addNewGrade", "click .remove-button" : "removeGrade", @@ -20,7 +20,7 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({ initialize : function() { // load template for grading view var self = this; - this.gradeCutoffTemplate = _.template('
  • ' + + this.gradeCutoffTemplate = _.template('
  • ' + '<%= descriptor %>' + '' + '<% if (removable) {%>remove<% ;} %>' + @@ -168,9 +168,12 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({ }, this); // add fail which is not in data - var failBar = this.gradeCutoffTemplate({ descriptor : this.failLabel(), - width : nextWidth, removable : false}); - $(failBar).find("span[contenteditable=true]").attr("contenteditable", false); + var failBar = $(this.gradeCutoffTemplate({ + descriptor : this.failLabel(), + width : nextWidth, + removable : false + })); + failBar.find("span[contenteditable=true]").attr("contenteditable", false); gradelist.append(failBar); gradelist.children().last().resizable({ handles: "e", From 533e0da1011d4af888c55c7b2935b42ecbac2fd0 Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Tue, 20 Aug 2013 13:34:41 -0400 Subject: [PATCH 2/2] Add acceptance test for noneditable failing grade range. --- .../contentstore/features/grading.feature | 6 ++++++ cms/djangoapps/contentstore/features/grading.py | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/cms/djangoapps/contentstore/features/grading.feature b/cms/djangoapps/contentstore/features/grading.feature index 4b5cacc159..0e0ce561ee 100644 --- a/cms/djangoapps/contentstore/features/grading.feature +++ b/cms/djangoapps/contentstore/features/grading.feature @@ -93,3 +93,9 @@ Feature: Course Grading And I press the "Save" notification button And I reload the page Then I see the highest grade range is "Good" + + Scenario: User cannot edit failing grade range name + Given I have opened a new course in Studio + And I have populated the course + And I am viewing the grading settings + Then I cannot edit the "Fail" grade range diff --git a/cms/djangoapps/contentstore/features/grading.py b/cms/djangoapps/contentstore/features/grading.py index 40cba61edc..bedab86bd9 100644 --- a/cms/djangoapps/contentstore/features/grading.py +++ b/cms/djangoapps/contentstore/features/grading.py @@ -4,6 +4,7 @@ from lettuce import world, step from common import * from terrain.steps import reload_the_page +from selenium.common.exceptions import InvalidElementStateException @step(u'I am viewing the grading settings') @@ -130,6 +131,18 @@ def i_see_highest_grade_range(_step, range_name): grade = world.css_find(range_css).first assert grade.value == range_name + +@step(u'I cannot edit the "Fail" grade range$') +def cannot_edit_fail(_step): + range_css = 'span.letter-grade' + ranges = world.css_find(range_css) + assert len(ranges) == 2 + try: + ranges.last.value = 'Failure' + assert False, "Should not be able to edit failing range" + except InvalidElementStateException: + pass # We should get this exception on failing to edit the element + def get_type_index(name): name_id = '#course-grading-assignment-name' all_types = world.css_find(name_id)