@@ -39,7 +39,7 @@ This def will enumerate through a passed in subsection and list all of the units
-%def>
+%def>
diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py
index 1e5fbb983d..902ec82677 100644
--- a/common/djangoapps/student/views.py
+++ b/common/djangoapps/student/views.py
@@ -317,7 +317,7 @@ def change_enrollment(request):
if not has_access(user, course, 'enroll'):
return {'success': False,
'error': 'enrollment in {} not allowed at this time'
- .format(course.lms.display_name)}
+ .format(course.display_name_with_default)}
org, course_num, run = course_id.split("/")
statsd.increment("common.student.enrollment",
diff --git a/common/djangoapps/terrain/factories.py b/common/djangoapps/terrain/factories.py
index 3bedcd87aa..67cd8eb3ce 100644
--- a/common/djangoapps/terrain/factories.py
+++ b/common/djangoapps/terrain/factories.py
@@ -82,7 +82,7 @@ class XModuleCourseFactory(Factory):
# This metadata code was copied from cms/djangoapps/contentstore/views.py
if display_name is not None:
- new_course.lms.display_name = display_name
+ new_course.display_name = display_name
new_course.data_dir = uuid4().hex
new_course.lms.start = gmtime()
@@ -145,7 +145,7 @@ class XModuleItemFactory(Factory):
# replace the display name with an optional parameter passed in from the caller
if display_name is not None:
- new_item.lms.display_name = display_name
+ new_item.display_name = display_name
store.update_metadata(new_item.location.url(), new_item.own_metadata)
diff --git a/common/djangoapps/xmodule_modifiers.py b/common/djangoapps/xmodule_modifiers.py
index 06cc232414..d398dfef0d 100644
--- a/common/djangoapps/xmodule_modifiers.py
+++ b/common/djangoapps/xmodule_modifiers.py
@@ -33,7 +33,7 @@ def wrap_xmodule(get_html, module, template, context=None):
def _get_html():
context.update({
'content': get_html(),
- 'display_name': module.lms.display_name,
+ 'display_name': module.display_name,
'class_': module.__class__.__name__,
'module_name': module.js_module_name
})
diff --git a/common/lib/xmodule/xmodule/annotatable_module.py b/common/lib/xmodule/xmodule/annotatable_module.py
index f093b76f52..58ecfb9131 100644
--- a/common/lib/xmodule/xmodule/annotatable_module.py
+++ b/common/lib/xmodule/xmodule/annotatable_module.py
@@ -103,7 +103,7 @@ class AnnotatableModule(XModule):
def get_html(self):
""" Renders parameters to template. """
context = {
- 'display_name': self.display_name,
+ 'display_name': self.display_name_with_default,
'element_id': self.element_id,
'instructions_html': self.instructions,
'content_html': self._render_content()
diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py
index 65b7653155..da366a21cc 100644
--- a/common/lib/xmodule/xmodule/capa_module.py
+++ b/common/lib/xmodule/xmodule/capa_module.py
@@ -367,7 +367,7 @@ class CapaModule(XModule):
else:
check_button = False
- content = {'name': self.display_name,
+ content = {'name': self.display_name_with_default,
'html': html,
'weight': self.descriptor.weight,
}
diff --git a/common/lib/xmodule/xmodule/modulestore/mongo.py b/common/lib/xmodule/xmodule/modulestore/mongo.py
index 73727805e4..00abad27ac 100644
--- a/common/lib/xmodule/xmodule/modulestore/mongo.py
+++ b/common/lib/xmodule/xmodule/modulestore/mongo.py
@@ -497,7 +497,7 @@ class MongoModuleStore(ModuleStoreBase):
existing_tabs = course.tabs or []
existing_tabs.append({
'type': 'static_tab',
- 'name': item.lms.display_name,
+ 'name': item.display_name,
'url_slug': item.location.name
})
course.tabs = existing_tabs
diff --git a/common/lib/xmodule/xmodule/modulestore/tests/factories.py b/common/lib/xmodule/xmodule/modulestore/tests/factories.py
index 3dd05a59dc..10f63d55cb 100644
--- a/common/lib/xmodule/xmodule/modulestore/tests/factories.py
+++ b/common/lib/xmodule/xmodule/modulestore/tests/factories.py
@@ -41,7 +41,7 @@ class XModuleCourseFactory(Factory):
# This metadata code was copied from cms/djangoapps/contentstore/views.py
if display_name is not None:
- new_course.lms.display_name = display_name
+ new_course.display_name = display_name
new_course.start = gmtime()
@@ -101,7 +101,7 @@ class XModuleItemFactory(Factory):
# replace the display name with an optional parameter passed in from the caller
if display_name is not None:
- new_item.lms.display_name = display_name
+ new_item.display_name = display_name
store.update_metadata(new_item.location.url(), own_metadata(new_item))
diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py
index aec1706aad..677f8b7d6a 100644
--- a/common/lib/xmodule/xmodule/modulestore/xml.py
+++ b/common/lib/xmodule/xmodule/modulestore/xml.py
@@ -473,7 +473,7 @@ class XMLModuleStore(ModuleStoreBase):
if category == "static_tab":
for tab in course_descriptor.tabs or []:
if tab.get('url_slug') == slug:
- module.lms.display_name = tab['name']
+ module.display_name = tab['name']
module.data_dir = course_dir
self.modules[course_descriptor.id][module.location] = module
except Exception, e:
diff --git a/common/lib/xmodule/xmodule/seq_module.py b/common/lib/xmodule/xmodule/seq_module.py
index bca7dbfed9..c0f85f4cec 100644
--- a/common/lib/xmodule/xmodule/seq_module.py
+++ b/common/lib/xmodule/xmodule/seq_module.py
@@ -18,14 +18,6 @@ log = logging.getLogger(__name__)
class_priority = ['video', 'problem']
-def display_name(module):
- if hasattr(module, 'display_name'):
- return module.display_name
-
- if hasattr(module, 'lms'):
- return module.lms.display_name
-
-
class SequenceModule(XModule):
''' Layout module which lays out content in a temporal sequence
'''
@@ -89,9 +81,9 @@ class SequenceModule(XModule):
childinfo = {
'content': child.get_html(),
'title': "\n".join(
- display_name(grand_child)
+ grand_child.display_name
for grand_child in child.get_children()
- if display_name(grand_child)
+ if grand_child.display_name is not None
),
'progress_status': Progress.to_js_status_str(progress),
'progress_detail': Progress.to_js_detail_str(progress),
@@ -99,7 +91,7 @@ class SequenceModule(XModule):
'id': child.id,
}
if childinfo['title'] == '':
- childinfo['title'] = display_name(child)
+ childinfo['title'] = child.display_name_with_default
contents.append(childinfo)
params = {'items': contents,
diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py
index 01fad953ea..37b1d35938 100644
--- a/common/lib/xmodule/xmodule/tests/test_import.py
+++ b/common/lib/xmodule/xmodule/tests/test_import.py
@@ -243,8 +243,8 @@ class ImportTestCase(BaseCourseTestCase):
toy_ch = toy.get_children()[0]
two_toys_ch = two_toys.get_children()[0]
- self.assertEqual(toy_ch.lms.display_name, "Overview")
- self.assertEqual(two_toys_ch.lms.display_name, "Two Toy Overview")
+ self.assertEqual(toy_ch.display_name, "Overview")
+ self.assertEqual(two_toys_ch.display_name, "Two Toy Overview")
# Also check that the grading policy loaded
self.assertEqual(two_toys.grade_cutoffs['C'], 0.5999)
@@ -303,7 +303,7 @@ class ImportTestCase(BaseCourseTestCase):
cloc = course.location
loc = Location(cloc.tag, cloc.org, cloc.course, 'html', 'secret:toylab')
html = modulestore.get_instance(course_id, loc)
- self.assertEquals(html.lms.display_name, "Toy lab")
+ self.assertEquals(html.display_name, "Toy lab")
def test_url_name_mangling(self):
"""
diff --git a/common/lib/xmodule/xmodule/video_module.py b/common/lib/xmodule/xmodule/video_module.py
index dc9e9acd92..1396885bfb 100644
--- a/common/lib/xmodule/xmodule/video_module.py
+++ b/common/lib/xmodule/xmodule/video_module.py
@@ -142,7 +142,7 @@ class VideoModule(XModule):
'position': self.position,
'source': self.source,
'track': self.track,
- 'display_name': self.display_name,
+ 'display_name': self.display_name_with_default,
'caption_asset_path': caption_asset_path,
'show_captions': self.show_captions,
'start': self.start_time,
diff --git a/common/lib/xmodule/xmodule/videoalpha_module.py b/common/lib/xmodule/xmodule/videoalpha_module.py
index c98fcec075..c42c06c6be 100644
--- a/common/lib/xmodule/xmodule/videoalpha_module.py
+++ b/common/lib/xmodule/xmodule/videoalpha_module.py
@@ -137,7 +137,7 @@ class VideoAlphaModule(XModule):
'sub': self.sub,
'sources': self.sources,
'track': self.track,
- 'display_name': self.display_name,
+ 'display_name': self.display_name_with_default,
# TODO (cpennington): This won't work when we move to data that isn't on the filesystem
'data_dir': getattr(self, 'data_dir', None),
'caption_asset_path': caption_asset_path,
diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py
index 930ff70e54..fbf8b41c61 100644
--- a/common/lib/xmodule/xmodule/x_module.py
+++ b/common/lib/xmodule/xmodule/x_module.py
@@ -9,7 +9,7 @@ from pkg_resources import resource_listdir, resource_string, resource_isdir
from xmodule.modulestore import Location
from xmodule.modulestore.exceptions import ItemNotFoundError
-from xblock.core import XBlock
+from xblock.core import XBlock, Scope, String
log = logging.getLogger(__name__)
@@ -99,6 +99,12 @@ class XModule(HTMLSnippet, XBlock):
# in the module
icon_class = 'other'
+ display_name = String(
+ help="Display name for this module",
+ scope=Scope.settings,
+ default=None,
+ )
+
def __init__(self, system, location, descriptor, model_data):
'''
Construct a new xmodule
@@ -123,6 +129,17 @@ class XModule(HTMLSnippet, XBlock):
self._model_data = model_data
self._loaded_children = None
+ @property
+ def display_name_with_default(self):
+ '''
+ Return a display name for the module: use display_name if defined in
+ metadata, otherwise convert the url name.
+ '''
+ name = self.display_name
+ if name is None:
+ name = self.url_name.replace('_', ' ')
+ return name
+
def get_children(self):
'''
Return module instances for all the children of this module.
@@ -335,6 +352,12 @@ class XModuleDescriptor(HTMLSnippet, ResourceTemplates, XBlock):
FoldIt, which posts grade-changing updates through a separate API.
"""
+ display_name = String(
+ help="Display name for this module",
+ scope=Scope.settings,
+ default=None,
+ )
+
# ============================= STRUCTURAL MANIPULATION ===================
def __init__(self,
system,
@@ -365,6 +388,17 @@ class XModuleDescriptor(HTMLSnippet, ResourceTemplates, XBlock):
self._child_instances = None
+ @property
+ def display_name_with_default(self):
+ '''
+ Return a display name for the module: use display_name if defined in
+ metadata, otherwise convert the url name.
+ '''
+ name = self.display_name
+ if name is None:
+ name = self.url_name.replace('_', ' ')
+ return name
+
def get_required_module_descriptors(self):
"""Returns a list of XModuleDescritpor instances upon which this module depends, but are
not children of this module"""
diff --git a/lms/djangoapps/course_wiki/views.py b/lms/djangoapps/course_wiki/views.py
index febe101071..6ab106ed70 100644
--- a/lms/djangoapps/course_wiki/views.py
+++ b/lms/djangoapps/course_wiki/views.py
@@ -95,7 +95,7 @@ def course_wiki_redirect(request, course_id):
root,
course_slug,
title=course_slug,
- content="This is the wiki for **{0}**'s _{1}_.".format(course.org, course.lms.display_name),
+ content="This is the wiki for **{0}**'s _{1}_.".format(course.org, course.display_name_with_default),
user_message="Course page automatically created.",
user=None,
ip_address=None,
diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py
index ee1d9ab8f1..63dadc3fff 100644
--- a/lms/djangoapps/courseware/courses.py
+++ b/lms/djangoapps/courseware/courses.py
@@ -178,9 +178,7 @@ def get_course_about_section(course, section_key):
key=section_key, url=course.location.url()))
return None
elif section_key == "title":
- if course.display_name is None:
- return course.url_name
- return course.display_name
+ return course.display_name_with_default
elif section_key == "university":
return course.location.org
elif section_key == "number":
diff --git a/lms/djangoapps/courseware/features/courses.py b/lms/djangoapps/courseware/features/courses.py
index 7d58dde138..eb5143b782 100644
--- a/lms/djangoapps/courseware/features/courses.py
+++ b/lms/djangoapps/courseware/features/courses.py
@@ -81,8 +81,8 @@ def get_courseware_with_tabs(course_id):
course = get_course_by_id(course_id)
chapters = [chapter for chapter in course.get_children() if not chapter.lms.hide_from_toc]
- courseware = [{'chapter_name': c.display_name,
- 'sections': [{'section_name': s.display_name,
+ courseware = [{'chapter_name': c.display_name_with_default,
+ 'sections': [{'section_name': s.display_name_with_default,
'clickable_tab_count': len(s.get_children()) if (type(s) == seq_module.SequenceDescriptor) else 0,
'tabs': [{'children_count': len(t.get_children()) if (type(t) == vertical_module.VerticalDescriptor) else 0,
'class': t.__class__.__name__}
diff --git a/lms/djangoapps/courseware/grades.py b/lms/djangoapps/courseware/grades.py
index 626be0494c..e007a37493 100644
--- a/lms/djangoapps/courseware/grades.py
+++ b/lms/djangoapps/courseware/grades.py
@@ -115,7 +115,7 @@ def answer_distributions(request, course):
for problem_id in capa_module.lcp.student_answers:
# Answer can be a list or some other unhashable element. Convert to string.
answer = str(capa_module.lcp.student_answers[problem_id])
- key = (capa_module.url_name, capa_module.display_name, problem_id)
+ key = (capa_module.url_name, capa_module.display_name_with_default, problem_id)
counts[key][answer] += 1
return counts
@@ -153,7 +153,7 @@ def grade(student, request, course, model_data_cache=None, keep_raw_scores=False
format_scores = []
for section in sections:
section_descriptor = section['section_descriptor']
- section_name = section_descriptor.lms.display_name
+ section_name = section_descriptor.display_name_with_default
should_grade_section = False
# If we haven't seen a single problem in the section, we don't have to grade it at all! We can assume 0%
@@ -195,7 +195,7 @@ def grade(student, request, course, model_data_cache=None, keep_raw_scores=False
#We simply cannot grade a problem that is 12/0, because we might need it as a percentage
graded = False
- scores.append(Score(correct, total, graded, module_descriptor.lms.display_name))
+ scores.append(Score(correct, total, graded, module_descriptor.display_name_with_default))
section_total, graded_total = graders.aggregate_scores(scores, section_name)
if keep_raw_scores:
@@ -311,15 +311,15 @@ def progress_summary(student, request, course, model_data_cache):
continue
scores.append(Score(correct, total, graded,
- module_descriptor.lms.display_name))
+ module_descriptor.display_name_with_default))
scores.reverse()
section_total, graded_total = graders.aggregate_scores(
- scores, section_module.lms.display_name)
+ scores, section_module.display_name_with_default)
format = section_module.lms.format
sections.append({
- 'display_name': section_module.lms.display_name,
+ 'display_name': section_module.display_name_with_default,
'url_name': section_module.url_name,
'scores': scores,
'section_total': section_total,
@@ -328,8 +328,8 @@ def progress_summary(student, request, course, model_data_cache):
'graded': graded,
})
- chapters.append({'course': course.lms.display_name,
- 'display_name': chapter_module.lms.display_name,
+ chapters.append({'course': course.display_name_with_default,
+ 'display_name': chapter_module.display_name_with_default,
'url_name': chapter_module.url_name,
'sections': sections})
diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py
index 063f8d9d62..8a4796ed15 100644
--- a/lms/djangoapps/courseware/module_render.py
+++ b/lms/djangoapps/courseware/module_render.py
@@ -101,7 +101,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, model_
section.url_name == active_section)
if not section.lms.hide_from_toc:
- sections.append({'display_name': section.lms.display_name,
+ sections.append({'display_name': section.display_name_with_default,
'url_name': section.url_name,
'format': section.lms.format,
'due': section.lms.due,
@@ -109,7 +109,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, model_
'graded': section.lms.graded,
})
- chapters.append({'display_name': chapter.lms.display_name,
+ chapters.append({'display_name': chapter.display_name_with_default,
'url_name': chapter.url_name,
'sections': sections,
'active': chapter.url_name == active_chapter})
diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py
index 2278ea67b4..de46563e2f 100644
--- a/lms/djangoapps/courseware/views.py
+++ b/lms/djangoapps/courseware/views.py
@@ -282,7 +282,7 @@ def index(request, course_id, chapter=None, section=None,
context = {
'csrf': csrf(request)['csrf_token'],
'accordion': render_accordion(request, course, chapter, section, model_data_cache),
- 'COURSE_TITLE': course.lms.display_name,
+ 'COURSE_TITLE': course.display_name_with_default,
'course': course,
'init': '',
'content': '',
diff --git a/lms/djangoapps/lms_migration/migrate.py b/lms/djangoapps/lms_migration/migrate.py
index 9cdc783bb9..569129f469 100644
--- a/lms/djangoapps/lms_migration/migrate.py
+++ b/lms/djangoapps/lms_migration/migrate.py
@@ -128,7 +128,7 @@ def manage_modulestores(request, reload_dir=None, commit_id=None):
for cdir, course in def_ms.courses.items():
html += '
'
- html += '
Course: %s (%s)
' % (course.display_name, cdir)
+ html += '
Course: %s (%s)
' % (course.display_name_with_default, cdir)
html += '
commit_id=%s
' % get_commit_id(course)
diff --git a/lms/templates/conditional_module.html b/lms/templates/conditional_module.html
index d76d589903..e9731c3db2 100644
--- a/lms/templates/conditional_module.html
+++ b/lms/templates/conditional_module.html
@@ -10,7 +10,7 @@ def _message(reqm, message):
return message.format(link="
{url_name}".format(
url = reverse('jump_to', kwargs=dict(course_id=get_course_id(reqm),
location=reqm.location.url())),
- url_name = reqm.display_name))
+ url_name = reqm.display_name_with_default))
%>
% if message:
% for reqm in module.required_modules:
diff --git a/lms/templates/courseware/welcome-back.html b/lms/templates/courseware/welcome-back.html
index 389a54aa53..ffd2e36d0a 100644
--- a/lms/templates/courseware/welcome-back.html
+++ b/lms/templates/courseware/welcome-back.html
@@ -1,3 +1,3 @@
-
${chapter_module.lms.display_name}
+
${chapter_module.display_name_with_default}
-
You were most recently in ${prev_section.lms.display_name}. If you're done with that, choose another section on the left.
+
You were most recently in ${prev_section.display_name_with_default}. If you're done with that, choose another section on the left.
diff --git a/lms/templates/dashboard.html b/lms/templates/dashboard.html
index 18a9cac892..d23609801f 100644
--- a/lms/templates/dashboard.html
+++ b/lms/templates/dashboard.html
@@ -216,7 +216,7 @@
% endif
${get_course_about_section(course, 'university')}
-
+
<%
diff --git a/lms/templates/discussion/index.html b/lms/templates/discussion/index.html
index 25d68bf85e..d43f8b945f 100644
--- a/lms/templates/discussion/index.html
+++ b/lms/templates/discussion/index.html
@@ -26,7 +26,7 @@
-
${course.lms.display_name} Discussion
+ ${course.display_name_with_default} Discussion
diff --git a/lms/templates/navigation.html b/lms/templates/navigation.html
index 60988d7068..e4c23e4836 100644
--- a/lms/templates/navigation.html
+++ b/lms/templates/navigation.html
@@ -41,7 +41,7 @@ site_status_msg = get_site_status_msg(course_id)
))})
% if course:
-
${course.org}: ${course.number} ${course.lms.display_name}
+
${course.org}: ${course.number} ${course.display_name_with_default}
% endif
diff --git a/lms/templates/test_center_register.html b/lms/templates/test_center_register.html
index ba72bf3186..c9ea907263 100644
--- a/lms/templates/test_center_register.html
+++ b/lms/templates/test_center_register.html
@@ -93,7 +93,7 @@
-
+
% if registration:
Your Pearson VUE Proctored Exam Registration
@@ -457,7 +457,7 @@
% if exam_info is not None:
-
- Exam Name: ${exam_info.display_name}
+ Exam Name: ${exam_info.display_name_with_default}
-
First Eligible Appointment Date: ${exam_info.first_eligible_appointment_date_text}
diff --git a/lms/xmodule_namespace.py b/lms/xmodule_namespace.py
index ef5afe4608..191859379c 100644
--- a/lms/xmodule_namespace.py
+++ b/lms/xmodule_namespace.py
@@ -27,11 +27,6 @@ class LmsNamespace(Namespace):
default='',
)
- display_name = String(
- help="Display name for this module",
- scope=Scope.settings,
- computed_default=lambda module: module.url_name.replace('_', ' ')
- )
start = Date(help="Start time when this module is visible", scope=Scope.settings)
due = String(help="Date that this problem is due by", scope=Scope.settings, default='')
source_file = String(help="DO NOT USE", scope=Scope.settings)