From 2c00004d4b699837978c0178c1b67590ba7201e1 Mon Sep 17 00:00:00 2001 From: Douglas Hall Date: Tue, 12 Jan 2016 09:36:35 -0500 Subject: [PATCH 1/4] Updated edx-proctoring requirement to fix PHX-242 --- requirements/edx/github.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/edx/github.txt b/requirements/edx/github.txt index 5809fcbefc..494d6e61e6 100644 --- a/requirements/edx/github.txt +++ b/requirements/edx/github.txt @@ -94,7 +94,7 @@ git+https://github.com/edx/xblock-utils.git@v1.0.0#egg=xblock-utils==v1.0.0 -e git+https://github.com/edx/edx-reverification-block.git@0.0.5#egg=edx-reverification-block==0.0.5 -e git+https://github.com/edx/edx-user-state-client.git@30c0ad4b9f57f8d48d6943eb585ec8a9205f4469#egg=edx-user-state-client git+https://github.com/edx/edx-organizations.git@release-2015-12-08#egg=edx-organizations==0.2.0 -git+https://github.com/edx/edx-proctoring.git@0.12.4#egg=edx-proctoring==0.12.4 +git+https://github.com/edx/edx-proctoring.git@0.12.5#egg=edx-proctoring==0.12.5 git+https://github.com/edx/xblock-lti-consumer.git@v1.0.1#egg=xblock-lti-consumer==1.0.1 # Third Party XBlocks From b4189784da787ab22890e94b53888acb8c33cb90 Mon Sep 17 00:00:00 2001 From: muzaffaryousaf Date: Thu, 7 Jan 2016 17:46:07 +0500 Subject: [PATCH 2/4] Fixed POST bookmarks bug when display_name is None. Added tests & general message to js when parsing fails. TNL-3989 --- .../xmodule/js/src/sequence/display.coffee | 2 +- common/lib/xmodule/xmodule/seq_module.py | 8 ++++++-- .../js/bookmarks/views/bookmark_button.js | 11 ++++++++--- .../bookmarks/bookmarks-list.underscore | 2 +- lms/templates/seq_module.html | 2 +- openedx/core/djangoapps/bookmarks/models.py | 3 +-- .../djangoapps/bookmarks/tests/test_models.py | 18 ++++++++++++++++++ 7 files changed, 36 insertions(+), 10 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/sequence/display.coffee b/common/lib/xmodule/xmodule/js/src/sequence/display.coffee index b5445a4c03..9c098efbcc 100644 --- a/common/lib/xmodule/xmodule/js/src/sequence/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/sequence/display.coffee @@ -119,7 +119,7 @@ class @Sequence sequence_links = @content_container.find('a.seqnav') sequence_links.click @goto - @el.find('.path').html(@el.find('.nav-item.active').data('path')) + @el.find('.path').text(@el.find('.nav-item.active').data('path')) @sr_container.focus(); # @$("a.active").blur() diff --git a/common/lib/xmodule/xmodule/seq_module.py b/common/lib/xmodule/xmodule/seq_module.py index 2c125231bb..2e9c561fcc 100644 --- a/common/lib/xmodule/xmodule/seq_module.py +++ b/common/lib/xmodule/xmodule/seq_module.py @@ -191,7 +191,11 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule): bookmarks_service = self.runtime.service(self, "bookmarks") context["username"] = self.runtime.service(self, "user").get_current_user().opt_attrs['edx-platform.username'] - display_names = [self.get_parent().display_name or '', self.display_name or ''] + parent_module = self.get_parent() + display_names = [ + parent_module.display_name_with_default, + self.display_name_with_default + ] # We do this up here because proctored exam functionality could bypass # rendering after this section. @@ -228,7 +232,7 @@ class SequenceModule(SequenceFields, ProctoringFields, XModule): 'type': child.get_icon_class(), 'id': child.scope_ids.usage_id.to_deprecated_string(), 'bookmarked': is_bookmarked, - 'path': " > ".join(display_names + [child.display_name or '']), + 'path': " > ".join(display_names + [child.display_name_with_default]), } if childinfo['title'] == '': childinfo['title'] = child.display_name_with_default_escaped diff --git a/lms/static/js/bookmarks/views/bookmark_button.js b/lms/static/js/bookmarks/views/bookmark_button.js index 869169ce02..796e491133 100644 --- a/lms/static/js/bookmarks/views/bookmark_button.js +++ b/lms/static/js/bookmarks/views/bookmark_button.js @@ -45,9 +45,14 @@ view.setBookmarkState(true); }, error: function (jqXHR) { - var response = jqXHR.responseText ? JSON.parse(jqXHR.responseText) : ''; - var userMessage = response ? response.user_message : ''; - view.showError(userMessage); + try { + var response = jqXHR.responseText ? JSON.parse(jqXHR.responseText) : ''; + var userMessage = response ? response.user_message : ''; + view.showError(userMessage); + } + catch(err) { + view.showError(); + } } }); }, diff --git a/lms/templates/bookmarks/bookmarks-list.underscore b/lms/templates/bookmarks/bookmarks-list.underscore index a68122e9ad..15d814f39a 100644 --- a/lms/templates/bookmarks/bookmarks-list.underscore +++ b/lms/templates/bookmarks/bookmarks-list.underscore @@ -10,7 +10,7 @@
- +

<%= gettext("Bookmarked on") %> <%= humanFriendlyDate(bookmark.get('created')) %>

diff --git a/lms/templates/seq_module.html b/lms/templates/seq_module.html index ffb351f4b8..cbda9971ee 100644 --- a/lms/templates/seq_module.html +++ b/lms/templates/seq_module.html @@ -19,7 +19,7 @@ data-element="${idx+1}" href="javascript:void(0);" data-page-title="${item['page_title']|h}" - data-path="${item['path']}" + data-path="${item['path']|h}" aria-controls="seq_contents_${idx}" id="tab_${idx}" tabindex="0"> diff --git a/openedx/core/djangoapps/bookmarks/models.py b/openedx/core/djangoapps/bookmarks/models.py index 662afc42e1..df52fbac09 100644 --- a/openedx/core/djangoapps/bookmarks/models.py +++ b/openedx/core/djangoapps/bookmarks/models.py @@ -81,7 +81,7 @@ class Bookmark(TimeStampedModel): xblock_cache = XBlockCache.create({ 'usage_key': usage_key, - 'display_name': block.display_name, + 'display_name': block.display_name_with_default, }) data['_path'] = prepare_path_for_serialization(Bookmark.updated_path(usage_key, xblock_cache)) @@ -238,7 +238,6 @@ class XBlockCache(TimeStampedModel): usage_key = usage_key.replace(course_key=modulestore().fill_in_run(usage_key.course_key)) data['course_key'] = usage_key.course_key - xblock_cache, created = cls.objects.get_or_create(usage_key=usage_key, defaults=data) if not created: diff --git a/openedx/core/djangoapps/bookmarks/tests/test_models.py b/openedx/core/djangoapps/bookmarks/tests/test_models.py index 8ebde4036b..8166c75d64 100644 --- a/openedx/core/djangoapps/bookmarks/tests/test_models.py +++ b/openedx/core/djangoapps/bookmarks/tests/test_models.py @@ -229,6 +229,15 @@ class BookmarkModelTests(BookmarksTestsBase): """ Test the Bookmark model. """ + def setUp(self): + super(BookmarkModelTests, self).setUp() + + self.vertical_4 = ItemFactory.create( + parent_location=self.sequential_2.location, + category='vertical', + display_name=None + ) + def get_bookmark_data(self, block, user=None): """ Returns bookmark data for testing. @@ -297,6 +306,15 @@ class BookmarkModelTests(BookmarksTestsBase): self.assertNotEqual(bookmark, bookmark3) self.assert_bookmark_model_is_valid(bookmark3, bookmark_data_different_user) + def test_create_bookmark_successfully_with_display_name_none(self): + """ + Tests creation of bookmark with display_name None. + """ + bookmark_data = self.get_bookmark_data(self.vertical_4) + bookmark, __ = Bookmark.create(bookmark_data) + bookmark_data['display_name'] = self.vertical_4.display_name_with_default + self.assert_bookmark_model_is_valid(bookmark, bookmark_data) + @ddt.data( (-30, [[PathItem(EXAMPLE_USAGE_KEY_1, '1')]], 1), (30, None, 2), From 0b685d8983a6ea10db68b48b063808f1fd782171 Mon Sep 17 00:00:00 2001 From: "M. Rehan" Date: Sun, 10 Jan 2016 21:32:37 +0500 Subject: [PATCH 3/4] fix for course number display string as none --- .../views/tests/test_course_index.py | 21 +++++++++++++++++++ cms/templates/base.html | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index b9004217cb..c043f90da8 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -289,6 +289,27 @@ class TestCourseIndex(CourseTestCase): response = self.client.get_html(course_outline_url_split) self.assertEqual(response.status_code, 404) + def test_course_outline_with_display_course_number_as_none(self): + """ + Tests course outline when 'display_coursenumber' field is none. + """ + # Change 'display_coursenumber' field to None and update the course. + self.course.display_coursenumber = None + updated_course = self.update_course(self.course, self.user.id) + + # Assert that 'display_coursenumber' field has been changed successfully. + self.assertEqual(updated_course.display_coursenumber, None) + + # Perform GET request on course outline url with the course id. + course_outline_url = reverse_course_url('course_handler', updated_course.id) + response = self.client.get_html(course_outline_url) + + # Assert that response code is 200. + self.assertEqual(response.status_code, 200) + + # Assert that 'display_course_number' is being set to "" (as display_coursenumber was None). + self.assertIn('display_course_number: ""', response.content) + @ddt.ddt class TestCourseOutline(CourseTestCase): diff --git a/cms/templates/base.html b/cms/templates/base.html index 5d46a3c549..9bacefda13 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -85,7 +85,7 @@ from openedx.core.lib.js_utils import ( url_name: "${context_course.location.name | h}", org: "${context_course.location.org | h}", num: "${context_course.location.course | h}", - display_course_number: "${_(context_course.display_coursenumber)}", + display_course_number: "${_(context_course.display_coursenumber) if context_course.display_coursenumber else ''}", revision: "${context_course.location.revision | h}", self_paced: ${escape_json_dumps(context_course.self_paced) | n} }); From 157bd19e20b66fb0c89970914cf321477ce040c2 Mon Sep 17 00:00:00 2001 From: Jesse Zoldak Date: Tue, 12 Jan 2016 10:53:37 -0500 Subject: [PATCH 4/4] Clear out the bok choy DB with reset_db, not flush --- scripts/reset-test-db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/reset-test-db.sh b/scripts/reset-test-db.sh index 181fa4635d..575c578c94 100755 --- a/scripts/reset-test-db.sh +++ b/scripts/reset-test-db.sh @@ -28,7 +28,7 @@ DB_CACHE_DIR="common/test/db_cache" echo "CREATE DATABASE IF NOT EXISTS edxtest;" | mysql -u root # Clear out the test database -./manage.py lms --settings bok_choy flush --traceback --noinput +./manage.py lms --settings bok_choy reset_db --traceback --noinput # If there are cached database schemas/data, load them if [[ -f $DB_CACHE_DIR/bok_choy_schema.sql && -f $DB_CACHE_DIR/bok_choy_migrations_data.sql && -f $DB_CACHE_DIR/bok_choy_data.json ]]; then