Commit 93db5acc by Calen Pennington

Make display_name defaulting explicit

parent e4dea025
...@@ -135,7 +135,7 @@ def index(request): ...@@ -135,7 +135,7 @@ def index(request):
return render_to_response('index.html', { return render_to_response('index.html', {
'new_course_template': Location('i4x', 'edx', 'templates', 'course', 'Empty'), 'new_course_template': Location('i4x', 'edx', 'templates', 'course', 'Empty'),
'courses': [(course.lms.display_name, 'courses': [(course.display_name,
reverse('course_index', args=[ reverse('course_index', args=[
course.location.org, course.location.org,
course.location.course, course.location.course,
...@@ -319,7 +319,7 @@ def edit_unit(request, location): ...@@ -319,7 +319,7 @@ def edit_unit(request, location):
if category in component_types: if category in component_types:
#This is a hack to create categories for different xmodules #This is a hack to create categories for different xmodules
component_templates[category].append(( component_templates[category].append((
template.lms.display_name, template.display_name_with_default,
template.location.url(), template.location.url(),
hasattr(template, 'markdown') and template.markdown != '', hasattr(template, 'markdown') and template.markdown != '',
template.cms.empty, template.cms.empty,
...@@ -757,7 +757,7 @@ def clone_item(request): ...@@ -757,7 +757,7 @@ def clone_item(request):
# replace the display name with an optional parameter passed in from the caller # replace the display name with an optional parameter passed in from the caller
if display_name is not None: if display_name is not None:
new_item.lms.display_name = display_name new_item.display_name = display_name
get_modulestore(template).update_metadata(new_item.location.url(), own_metadata(new_item)) get_modulestore(template).update_metadata(new_item.location.url(), own_metadata(new_item))
...@@ -978,7 +978,7 @@ def reorder_static_tabs(request): ...@@ -978,7 +978,7 @@ def reorder_static_tabs(request):
for tab in course.tabs: for tab in course.tabs:
if tab['type'] == 'static_tab': if tab['type'] == 'static_tab':
reordered_tabs.append({'type': 'static_tab', reordered_tabs.append({'type': 'static_tab',
'name': tab_items[static_tab_idx].lms.display_name, 'name': tab_items[static_tab_idx].display_name,
'url_slug': tab_items[static_tab_idx].location.name}) 'url_slug': tab_items[static_tab_idx].location.name})
static_tab_idx += 1 static_tab_idx += 1
else: else:
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<%block name="title"></%block> | <%block name="title"></%block> |
% if context_course: % if context_course:
<% ctx_loc = context_course.location %> <% ctx_loc = context_course.location %>
${context_course.display_name} | ${context_course.display_name_with_default} |
% endif % endif
edX Studio edX Studio
</title> </title>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<article class="subsection-body window" data-id="${subsection.location}"> <article class="subsection-body window" data-id="${subsection.location}">
<div class="subsection-name-input"> <div class="subsection-name-input">
<label>Display Name:</label> <label>Display Name:</label>
<input type="text" value="${subsection.lms.display_name | h}" class="subsection-display-name-input" data-metadata-name="display_name"/> <input type="text" value="${subsection.display_name_with_default | h}" class="subsection-display-name-input" data-metadata-name="display_name"/>
</div> </div>
<div class="sortable-unit-list"> <div class="sortable-unit-list">
<label>Units:</label> <label>Units:</label>
...@@ -59,11 +59,11 @@ ...@@ -59,11 +59,11 @@
</div> </div>
% if subsection.lms.start != parent_item.lms.start and subsection.lms.start: % if subsection.lms.start != parent_item.lms.start and subsection.lms.start:
% if parent_start_date is None: % if parent_start_date is None:
<p class="notice">The date above differs from the release date of ${parent_item.lms.display_name}, which is unset. <p class="notice">The date above differs from the release date of ${parent_item.display_name_with_default}, which is unset.
% else: % else:
<p class="notice">The date above differs from the release date of ${parent_item.lms.display_name} – ${parent_start_date.strftime('%m/%d/%Y')} at ${parent_start_date.strftime('%H:%M')}. <p class="notice">The date above differs from the release date of ${parent_item.display_name_with_default} – ${parent_start_date.strftime('%m/%d/%Y')} at ${parent_start_date.strftime('%H:%M')}.
% endif % endif
<a href="#" class="sync-date no-spinner">Sync to ${parent_item.lms.display_name}.</a></p> <a href="#" class="sync-date no-spinner">Sync to ${parent_item.display_name_with_default}.</a></p>
% endif % endif
</div> </div>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<div>${module_type}</div> <div>${module_type}</div>
<div> <div>
% for template in module_templates: % for template in module_templates:
<a class="save" data-template-id="${template.location.url()}">${template.lms.display_name}</a> <a class="save" data-template-id="${template.location.url()}">${template.display_name_with_default}</a>
% endfor % endfor
</div> </div>
</div> </div>
......
...@@ -154,9 +154,9 @@ ...@@ -154,9 +154,9 @@
<div class="item-details" data-id="${section.location}"> <div class="item-details" data-id="${section.location}">
<h3 class="section-name"> <h3 class="section-name">
<span data-tooltip="Edit this section's name" class="section-name-span">${section.lms.display_name}</span> <span data-tooltip="Edit this section's name" class="section-name-span">${section.display_name_with_default}</span>
<form class="section-name-edit" style="display:none"> <form class="section-name-edit" style="display:none">
<input type="text" value="${section.lms.display_name | h}" class="edit-section-name" autocomplete="off"/> <input type="text" value="${section.display_name_with_default | h}" class="edit-section-name" autocomplete="off"/>
<input type="submit" class="save-button edit-section-name-save" value="Save" /> <input type="submit" class="save-button edit-section-name-save" value="Save" />
<input type="button" class="cancel-button edit-section-name-cancel" value="Cancel" /> <input type="button" class="cancel-button edit-section-name-cancel" value="Cancel" />
</form> </form>
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
<a href="#" data-tooltip="Expand/collapse this subsection" class="expand-collapse-icon expand"></a> <a href="#" data-tooltip="Expand/collapse this subsection" class="expand-collapse-icon expand"></a>
<a href="${reverse('edit_subsection', args=[subsection.location])}"> <a href="${reverse('edit_subsection', args=[subsection.location])}">
<span class="folder-icon"></span> <span class="folder-icon"></span>
<span class="subsection-name"><span class="subsection-name-value">${subsection.lms.display_name}</span></span> <span class="subsection-name"><span class="subsection-name-value">${subsection.display_name_with_default}</span></span>
</a> </a>
</div> </div>
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
</div> </div>
<div class="main-column"> <div class="main-column">
<article class="unit-body window"> <article class="unit-body window">
<p class="unit-name-input"><label>Display Name:</label><input type="text" value="${unit.lms.display_name | h}" class="unit-display-name-input" /></p> <p class="unit-name-input"><label>Display Name:</label><input type="text" value="${unit.display_name_with_default | h}" class="unit-display-name-input" /></p>
<ol class="components"> <ol class="components">
% for id in components: % for id in components:
<li class="component" data-id="${id}"/> <li class="component" data-id="${id}"/>
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
% if release_date is not None: % if release_date is not None:
on <strong>${release_date}</strong> on <strong>${release_date}</strong>
% endif % endif
with the subsection <a href="${reverse('edit_subsection', kwargs={'location': subsection.location})}">"${subsection.lms.display_name}"</a></p> with the subsection <a href="${reverse('edit_subsection', kwargs={'location': subsection.location})}">"${subsection.display_name_with_default}"</a></p>
</div> </div>
<div class="row unit-actions"> <div class="row unit-actions">
<a href="#" class="delete-draft delete-button">Delete Draft</a> <a href="#" class="delete-draft delete-button">Delete Draft</a>
...@@ -168,12 +168,12 @@ ...@@ -168,12 +168,12 @@
<div><input type="text" class="url" value="/courseware/${section.url_name}/${subsection.url_name}" disabled /></div> <div><input type="text" class="url" value="/courseware/${section.url_name}/${subsection.url_name}" disabled /></div>
<ol> <ol>
<li> <li>
<a href="#" class="section-item">${section.lms.display_name}</a> <a href="#" class="section-item">${section.display_name_with_default}</a>
<ol> <ol>
<li> <li>
<a href="${reverse('edit_subsection', args=[subsection.location])}" class="section-item"> <a href="${reverse('edit_subsection', args=[subsection.location])}" class="section-item">
<span class="folder-icon"></span> <span class="folder-icon"></span>
<span class="subsection-name"><span class="subsection-name-value">${subsection.lms.display_name}</span></span> <span class="subsection-name"><span class="subsection-name-value">${subsection.display_name_with_default}</span></span>
</a> </a>
${units.enum_units(subsection, actions=False, selected=unit.location)} ${units.enum_units(subsection, actions=False, selected=unit.location)}
</li> </li>
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
<h2 class="sr">Current Course:</h2> <h2 class="sr">Current Course:</h2>
<a href="${reverse('course_index', kwargs=dict(org=ctx_loc.org, course=ctx_loc.course, name=ctx_loc.name))}"> <a href="${reverse('course_index', kwargs=dict(org=ctx_loc.org, course=ctx_loc.course, name=ctx_loc.name))}">
<span class="course-org">${ctx_loc.org}</span><span class="course-number">${ctx_loc.course}</span> <span class="course-org">${ctx_loc.org}</span><span class="course-number">${ctx_loc.course}</span>
<span class="course-title" title="${context_course.lms.display_name}">${context_course.lms.display_name}</span> <span class="course-title" title="${context_course.display_name_with_default}">${context_course.display_name_with_default}</span>
</a> </a>
</div> </div>
<nav class="nav-course primary nav-dropdown" role="navigation"> <nav class="nav-course primary nav-dropdown" role="navigation">
<h2 class="sr">${context_course.lms.display_name}'s Navigation:</h2> <h2 class="sr">${context_course.display_name_with_default}'s Navigation:</h2>
<ol> <ol>
<li class="nav-item nav-course-courseware"> <li class="nav-item nav-course-courseware">
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<a href="#" class="module-edit" <a href="#" class="module-edit"
data-id="${child.location.url()}" data-id="${child.location.url()}"
data-type="${child.js_module_name}" data-type="${child.js_module_name}"
data-preview-type="${child.module_class.js_module_name}">${child.lms.display_name}</a> data-preview-type="${child.module_class.js_module_name}">${child.display_name_with_default}</a>
<a href="#" class="draggable">handle</a> <a href="#" class="draggable">handle</a>
</li> </li>
%endfor %endfor
......
...@@ -22,7 +22,7 @@ This def will enumerate through a passed in subsection and list all of the units ...@@ -22,7 +22,7 @@ This def will enumerate through a passed in subsection and list all of the units
<div class="section-item ${selected_class}"> <div class="section-item ${selected_class}">
<a href="${reverse('edit_unit', args=[unit.location])}" class="${unit_state}-item"> <a href="${reverse('edit_unit', args=[unit.location])}" class="${unit_state}-item">
<span class="${unit.category}-icon"></span> <span class="${unit.category}-icon"></span>
<span class="unit-name">${unit.lms.display_name}</span> <span class="unit-name">${unit.display_name_with_default}</span>
</a> </a>
% if actions: % if actions:
<div class="item-actions"> <div class="item-actions">
......
...@@ -317,7 +317,7 @@ def change_enrollment(request): ...@@ -317,7 +317,7 @@ def change_enrollment(request):
if not has_access(user, course, 'enroll'): if not has_access(user, course, 'enroll'):
return {'success': False, return {'success': False,
'error': 'enrollment in {} not allowed at this time' '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("/") org, course_num, run = course_id.split("/")
statsd.increment("common.student.enrollment", statsd.increment("common.student.enrollment",
......
...@@ -82,7 +82,7 @@ class XModuleCourseFactory(Factory): ...@@ -82,7 +82,7 @@ class XModuleCourseFactory(Factory):
# This metadata code was copied from cms/djangoapps/contentstore/views.py # This metadata code was copied from cms/djangoapps/contentstore/views.py
if display_name is not None: 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.data_dir = uuid4().hex
new_course.lms.start = gmtime() new_course.lms.start = gmtime()
...@@ -145,7 +145,7 @@ class XModuleItemFactory(Factory): ...@@ -145,7 +145,7 @@ class XModuleItemFactory(Factory):
# replace the display name with an optional parameter passed in from the caller # replace the display name with an optional parameter passed in from the caller
if display_name is not None: 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) store.update_metadata(new_item.location.url(), new_item.own_metadata)
......
...@@ -33,7 +33,7 @@ def wrap_xmodule(get_html, module, template, context=None): ...@@ -33,7 +33,7 @@ def wrap_xmodule(get_html, module, template, context=None):
def _get_html(): def _get_html():
context.update({ context.update({
'content': get_html(), 'content': get_html(),
'display_name': module.lms.display_name, 'display_name': module.display_name,
'class_': module.__class__.__name__, 'class_': module.__class__.__name__,
'module_name': module.js_module_name 'module_name': module.js_module_name
}) })
......
...@@ -103,7 +103,7 @@ class AnnotatableModule(XModule): ...@@ -103,7 +103,7 @@ class AnnotatableModule(XModule):
def get_html(self): def get_html(self):
""" Renders parameters to template. """ """ Renders parameters to template. """
context = { context = {
'display_name': self.display_name, 'display_name': self.display_name_with_default,
'element_id': self.element_id, 'element_id': self.element_id,
'instructions_html': self.instructions, 'instructions_html': self.instructions,
'content_html': self._render_content() 'content_html': self._render_content()
......
...@@ -367,7 +367,7 @@ class CapaModule(XModule): ...@@ -367,7 +367,7 @@ class CapaModule(XModule):
else: else:
check_button = False check_button = False
content = {'name': self.display_name, content = {'name': self.display_name_with_default,
'html': html, 'html': html,
'weight': self.descriptor.weight, 'weight': self.descriptor.weight,
} }
......
...@@ -497,7 +497,7 @@ class MongoModuleStore(ModuleStoreBase): ...@@ -497,7 +497,7 @@ class MongoModuleStore(ModuleStoreBase):
existing_tabs = course.tabs or [] existing_tabs = course.tabs or []
existing_tabs.append({ existing_tabs.append({
'type': 'static_tab', 'type': 'static_tab',
'name': item.lms.display_name, 'name': item.display_name,
'url_slug': item.location.name 'url_slug': item.location.name
}) })
course.tabs = existing_tabs course.tabs = existing_tabs
......
...@@ -41,7 +41,7 @@ class XModuleCourseFactory(Factory): ...@@ -41,7 +41,7 @@ class XModuleCourseFactory(Factory):
# This metadata code was copied from cms/djangoapps/contentstore/views.py # This metadata code was copied from cms/djangoapps/contentstore/views.py
if display_name is not None: if display_name is not None:
new_course.lms.display_name = display_name new_course.display_name = display_name
new_course.start = gmtime() new_course.start = gmtime()
...@@ -101,7 +101,7 @@ class XModuleItemFactory(Factory): ...@@ -101,7 +101,7 @@ class XModuleItemFactory(Factory):
# replace the display name with an optional parameter passed in from the caller # replace the display name with an optional parameter passed in from the caller
if display_name is not None: 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)) store.update_metadata(new_item.location.url(), own_metadata(new_item))
......
...@@ -473,7 +473,7 @@ class XMLModuleStore(ModuleStoreBase): ...@@ -473,7 +473,7 @@ class XMLModuleStore(ModuleStoreBase):
if category == "static_tab": if category == "static_tab":
for tab in course_descriptor.tabs or []: for tab in course_descriptor.tabs or []:
if tab.get('url_slug') == slug: if tab.get('url_slug') == slug:
module.lms.display_name = tab['name'] module.display_name = tab['name']
module.data_dir = course_dir module.data_dir = course_dir
self.modules[course_descriptor.id][module.location] = module self.modules[course_descriptor.id][module.location] = module
except Exception, e: except Exception, e:
......
...@@ -18,14 +18,6 @@ log = logging.getLogger(__name__) ...@@ -18,14 +18,6 @@ log = logging.getLogger(__name__)
class_priority = ['video', 'problem'] 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): class SequenceModule(XModule):
''' Layout module which lays out content in a temporal sequence ''' Layout module which lays out content in a temporal sequence
''' '''
...@@ -89,9 +81,9 @@ class SequenceModule(XModule): ...@@ -89,9 +81,9 @@ class SequenceModule(XModule):
childinfo = { childinfo = {
'content': child.get_html(), 'content': child.get_html(),
'title': "\n".join( 'title': "\n".join(
display_name(grand_child) grand_child.display_name
for grand_child in child.get_children() 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_status': Progress.to_js_status_str(progress),
'progress_detail': Progress.to_js_detail_str(progress), 'progress_detail': Progress.to_js_detail_str(progress),
...@@ -99,7 +91,7 @@ class SequenceModule(XModule): ...@@ -99,7 +91,7 @@ class SequenceModule(XModule):
'id': child.id, 'id': child.id,
} }
if childinfo['title'] == '': if childinfo['title'] == '':
childinfo['title'] = display_name(child) childinfo['title'] = child.display_name_with_default
contents.append(childinfo) contents.append(childinfo)
params = {'items': contents, params = {'items': contents,
......
...@@ -243,8 +243,8 @@ class ImportTestCase(BaseCourseTestCase): ...@@ -243,8 +243,8 @@ class ImportTestCase(BaseCourseTestCase):
toy_ch = toy.get_children()[0] toy_ch = toy.get_children()[0]
two_toys_ch = two_toys.get_children()[0] two_toys_ch = two_toys.get_children()[0]
self.assertEqual(toy_ch.lms.display_name, "Overview") self.assertEqual(toy_ch.display_name, "Overview")
self.assertEqual(two_toys_ch.lms.display_name, "Two Toy Overview") self.assertEqual(two_toys_ch.display_name, "Two Toy Overview")
# Also check that the grading policy loaded # Also check that the grading policy loaded
self.assertEqual(two_toys.grade_cutoffs['C'], 0.5999) self.assertEqual(two_toys.grade_cutoffs['C'], 0.5999)
...@@ -303,7 +303,7 @@ class ImportTestCase(BaseCourseTestCase): ...@@ -303,7 +303,7 @@ class ImportTestCase(BaseCourseTestCase):
cloc = course.location cloc = course.location
loc = Location(cloc.tag, cloc.org, cloc.course, 'html', 'secret:toylab') loc = Location(cloc.tag, cloc.org, cloc.course, 'html', 'secret:toylab')
html = modulestore.get_instance(course_id, loc) 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): def test_url_name_mangling(self):
""" """
......
...@@ -142,7 +142,7 @@ class VideoModule(XModule): ...@@ -142,7 +142,7 @@ class VideoModule(XModule):
'position': self.position, 'position': self.position,
'source': self.source, 'source': self.source,
'track': self.track, 'track': self.track,
'display_name': self.display_name, 'display_name': self.display_name_with_default,
'caption_asset_path': caption_asset_path, 'caption_asset_path': caption_asset_path,
'show_captions': self.show_captions, 'show_captions': self.show_captions,
'start': self.start_time, 'start': self.start_time,
......
...@@ -137,7 +137,7 @@ class VideoAlphaModule(XModule): ...@@ -137,7 +137,7 @@ class VideoAlphaModule(XModule):
'sub': self.sub, 'sub': self.sub,
'sources': self.sources, 'sources': self.sources,
'track': self.track, '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 # TODO (cpennington): This won't work when we move to data that isn't on the filesystem
'data_dir': getattr(self, 'data_dir', None), 'data_dir': getattr(self, 'data_dir', None),
'caption_asset_path': caption_asset_path, 'caption_asset_path': caption_asset_path,
......
...@@ -9,7 +9,7 @@ from pkg_resources import resource_listdir, resource_string, resource_isdir ...@@ -9,7 +9,7 @@ from pkg_resources import resource_listdir, resource_string, resource_isdir
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from xblock.core import XBlock from xblock.core import XBlock, Scope, String
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -99,6 +99,12 @@ class XModule(HTMLSnippet, XBlock): ...@@ -99,6 +99,12 @@ class XModule(HTMLSnippet, XBlock):
# in the module # in the module
icon_class = 'other' 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): def __init__(self, system, location, descriptor, model_data):
''' '''
Construct a new xmodule Construct a new xmodule
...@@ -123,6 +129,17 @@ class XModule(HTMLSnippet, XBlock): ...@@ -123,6 +129,17 @@ class XModule(HTMLSnippet, XBlock):
self._model_data = model_data self._model_data = model_data
self._loaded_children = None 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): def get_children(self):
''' '''
Return module instances for all the children of this module. Return module instances for all the children of this module.
...@@ -335,6 +352,12 @@ class XModuleDescriptor(HTMLSnippet, ResourceTemplates, XBlock): ...@@ -335,6 +352,12 @@ class XModuleDescriptor(HTMLSnippet, ResourceTemplates, XBlock):
FoldIt, which posts grade-changing updates through a separate API. 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 =================== # ============================= STRUCTURAL MANIPULATION ===================
def __init__(self, def __init__(self,
system, system,
...@@ -365,6 +388,17 @@ class XModuleDescriptor(HTMLSnippet, ResourceTemplates, XBlock): ...@@ -365,6 +388,17 @@ class XModuleDescriptor(HTMLSnippet, ResourceTemplates, XBlock):
self._child_instances = None 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): def get_required_module_descriptors(self):
"""Returns a list of XModuleDescritpor instances upon which this module depends, but are """Returns a list of XModuleDescritpor instances upon which this module depends, but are
not children of this module""" not children of this module"""
......
...@@ -95,7 +95,7 @@ def course_wiki_redirect(request, course_id): ...@@ -95,7 +95,7 @@ def course_wiki_redirect(request, course_id):
root, root,
course_slug, course_slug,
title=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_message="Course page automatically created.",
user=None, user=None,
ip_address=None, ip_address=None,
......
...@@ -178,9 +178,7 @@ def get_course_about_section(course, section_key): ...@@ -178,9 +178,7 @@ def get_course_about_section(course, section_key):
key=section_key, url=course.location.url())) key=section_key, url=course.location.url()))
return None return None
elif section_key == "title": elif section_key == "title":
if course.display_name is None: return course.display_name_with_default
return course.url_name
return course.display_name
elif section_key == "university": elif section_key == "university":
return course.location.org return course.location.org
elif section_key == "number": elif section_key == "number":
......
...@@ -81,8 +81,8 @@ def get_courseware_with_tabs(course_id): ...@@ -81,8 +81,8 @@ def get_courseware_with_tabs(course_id):
course = get_course_by_id(course_id) course = get_course_by_id(course_id)
chapters = [chapter for chapter in course.get_children() if not chapter.lms.hide_from_toc] chapters = [chapter for chapter in course.get_children() if not chapter.lms.hide_from_toc]
courseware = [{'chapter_name': c.display_name, courseware = [{'chapter_name': c.display_name_with_default,
'sections': [{'section_name': s.display_name, 'sections': [{'section_name': s.display_name_with_default,
'clickable_tab_count': len(s.get_children()) if (type(s) == seq_module.SequenceDescriptor) else 0, '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, 'tabs': [{'children_count': len(t.get_children()) if (type(t) == vertical_module.VerticalDescriptor) else 0,
'class': t.__class__.__name__} 'class': t.__class__.__name__}
......
...@@ -115,7 +115,7 @@ def answer_distributions(request, course): ...@@ -115,7 +115,7 @@ def answer_distributions(request, course):
for problem_id in capa_module.lcp.student_answers: for problem_id in capa_module.lcp.student_answers:
# Answer can be a list or some other unhashable element. Convert to string. # Answer can be a list or some other unhashable element. Convert to string.
answer = str(capa_module.lcp.student_answers[problem_id]) 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 counts[key][answer] += 1
return counts return counts
...@@ -153,7 +153,7 @@ def grade(student, request, course, model_data_cache=None, keep_raw_scores=False ...@@ -153,7 +153,7 @@ def grade(student, request, course, model_data_cache=None, keep_raw_scores=False
format_scores = [] format_scores = []
for section in sections: for section in sections:
section_descriptor = section['section_descriptor'] section_descriptor = section['section_descriptor']
section_name = section_descriptor.lms.display_name section_name = section_descriptor.display_name_with_default
should_grade_section = False 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% # 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 ...@@ -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 #We simply cannot grade a problem that is 12/0, because we might need it as a percentage
graded = False 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) section_total, graded_total = graders.aggregate_scores(scores, section_name)
if keep_raw_scores: if keep_raw_scores:
...@@ -311,15 +311,15 @@ def progress_summary(student, request, course, model_data_cache): ...@@ -311,15 +311,15 @@ def progress_summary(student, request, course, model_data_cache):
continue continue
scores.append(Score(correct, total, graded, scores.append(Score(correct, total, graded,
module_descriptor.lms.display_name)) module_descriptor.display_name_with_default))
scores.reverse() scores.reverse()
section_total, graded_total = graders.aggregate_scores( 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 format = section_module.lms.format
sections.append({ sections.append({
'display_name': section_module.lms.display_name, 'display_name': section_module.display_name_with_default,
'url_name': section_module.url_name, 'url_name': section_module.url_name,
'scores': scores, 'scores': scores,
'section_total': section_total, 'section_total': section_total,
...@@ -328,8 +328,8 @@ def progress_summary(student, request, course, model_data_cache): ...@@ -328,8 +328,8 @@ def progress_summary(student, request, course, model_data_cache):
'graded': graded, 'graded': graded,
}) })
chapters.append({'course': course.lms.display_name, chapters.append({'course': course.display_name_with_default,
'display_name': chapter_module.lms.display_name, 'display_name': chapter_module.display_name_with_default,
'url_name': chapter_module.url_name, 'url_name': chapter_module.url_name,
'sections': sections}) 'sections': sections})
......
...@@ -101,7 +101,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, model_ ...@@ -101,7 +101,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, model_
section.url_name == active_section) section.url_name == active_section)
if not section.lms.hide_from_toc: 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, 'url_name': section.url_name,
'format': section.lms.format, 'format': section.lms.format,
'due': section.lms.due, 'due': section.lms.due,
...@@ -109,7 +109,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, model_ ...@@ -109,7 +109,7 @@ def toc_for_course(user, request, course, active_chapter, active_section, model_
'graded': section.lms.graded, '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, 'url_name': chapter.url_name,
'sections': sections, 'sections': sections,
'active': chapter.url_name == active_chapter}) 'active': chapter.url_name == active_chapter})
......
...@@ -282,7 +282,7 @@ def index(request, course_id, chapter=None, section=None, ...@@ -282,7 +282,7 @@ def index(request, course_id, chapter=None, section=None,
context = { context = {
'csrf': csrf(request)['csrf_token'], 'csrf': csrf(request)['csrf_token'],
'accordion': render_accordion(request, course, chapter, section, model_data_cache), '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, 'course': course,
'init': '', 'init': '',
'content': '', 'content': '',
......
...@@ -128,7 +128,7 @@ def manage_modulestores(request, reload_dir=None, commit_id=None): ...@@ -128,7 +128,7 @@ def manage_modulestores(request, reload_dir=None, commit_id=None):
for cdir, course in def_ms.courses.items(): for cdir, course in def_ms.courses.items():
html += '<hr width="100%"/>' html += '<hr width="100%"/>'
html += '<h2>Course: %s (%s)</h2>' % (course.display_name, cdir) html += '<h2>Course: %s (%s)</h2>' % (course.display_name_with_default, cdir)
html += '<p>commit_id=%s</p>' % get_commit_id(course) html += '<p>commit_id=%s</p>' % get_commit_id(course)
......
...@@ -10,7 +10,7 @@ def _message(reqm, message): ...@@ -10,7 +10,7 @@ def _message(reqm, message):
return message.format(link="<a href={url}>{url_name}</a>".format( return message.format(link="<a href={url}>{url_name}</a>".format(
url = reverse('jump_to', kwargs=dict(course_id=get_course_id(reqm), url = reverse('jump_to', kwargs=dict(course_id=get_course_id(reqm),
location=reqm.location.url())), location=reqm.location.url())),
url_name = reqm.display_name)) url_name = reqm.display_name_with_default))
%> %>
% if message: % if message:
% for reqm in module.required_modules: % for reqm in module.required_modules:
......
<h2>${chapter_module.lms.display_name}</h2> <h2>${chapter_module.display_name_with_default}</h2>
<p>You were most recently in <a href="${prev_section_url}">${prev_section.lms.display_name}</a>. If you're done with that, choose another section on the left.</p> <p>You were most recently in <a href="${prev_section_url}">${prev_section.display_name_with_default}</a>. If you're done with that, choose another section on the left.</p>
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
% endif % endif
</p> </p>
<h2 class="university">${get_course_about_section(course, 'university')}</h2> <h2 class="university">${get_course_about_section(course, 'university')}</h2>
<h3><a href="${course_target}">${course.number} ${course.lms.display_name}</a></h3> <h3><a href="${course_target}">${course.number} ${course.display_name_with_default}</a></h3>
</hgroup> </hgroup>
<% <%
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<div class="sidebar"></div> <div class="sidebar"></div>
<div class="discussion-column"> <div class="discussion-column">
<div class="discussion-article blank-slate"> <div class="discussion-article blank-slate">
<h1>${course.lms.display_name} Discussion</h1> <h1>${course.display_name_with_default} Discussion</h1>
</div> </div>
</div> </div>
......
...@@ -41,7 +41,7 @@ site_status_msg = get_site_status_msg(course_id) ...@@ -41,7 +41,7 @@ site_status_msg = get_site_status_msg(course_id)
<h1 class="logo"><a href="${reverse('root')}"><img src="${static.url(branding.get_logo_url(request.META.get('HTTP_HOST')))}"/></a></h1> <h1 class="logo"><a href="${reverse('root')}"><img src="${static.url(branding.get_logo_url(request.META.get('HTTP_HOST')))}"/></a></h1>
% if course: % if course:
<h2><span class="provider">${course.org}:</span> ${course.number} ${course.lms.display_name}</h2> <h2><span class="provider">${course.org}:</span> ${course.number} ${course.display_name_with_default}</h2>
% endif % endif
<ol class="left find-courses-button"> <ol class="left find-courses-button">
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<section class="introduction"> <section class="introduction">
<header> <header>
<hgroup> <hgroup>
<h2><a href="${reverse('dashboard')}">${get_course_about_section(course, 'university')} ${course.number} ${course.lms.display_name}</a></h2> <h2><a href="${reverse('dashboard')}">${get_course_about_section(course, 'university')} ${course.number} ${course.display_name_with_default}</a></h2>
% if registration: % if registration:
<h1>Your Pearson VUE Proctored Exam Registration</h1> <h1>Your Pearson VUE Proctored Exam Registration</h1>
...@@ -457,7 +457,7 @@ ...@@ -457,7 +457,7 @@
% if exam_info is not None: % if exam_info is not None:
<ul> <ul>
<li> <li>
<span class="label">Exam Name:</span> <span class="value">${exam_info.display_name}</span> <span class="label">Exam Name:</span> <span class="value">${exam_info.display_name_with_default}</span>
</li> </li>
<li> <li>
<span class="label">First Eligible Appointment Date:</span> <span class="value">${exam_info.first_eligible_appointment_date_text}</span> <span class="label">First Eligible Appointment Date:</span> <span class="value">${exam_info.first_eligible_appointment_date_text}</span>
......
...@@ -27,11 +27,6 @@ class LmsNamespace(Namespace): ...@@ -27,11 +27,6 @@ class LmsNamespace(Namespace):
default='', 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) 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='') due = String(help="Date that this problem is due by", scope=Scope.settings, default='')
source_file = String(help="DO NOT USE", scope=Scope.settings) source_file = String(help="DO NOT USE", scope=Scope.settings)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment