Skip to content
Snippets Groups Projects
Commit b59b8087 authored by ichuang's avatar ichuang
Browse files

add edit link to module pages with filenames (html & problem)

uses new 'github_url' dict key in multicourse_settings
this replaces the previous "quickedit" functionality
parent 9cea3f97
No related merge requests found
......@@ -247,10 +247,24 @@ def render_x_module(user, request, module_xml, student_module_cache, position=No
render_histogram = len(histogram) > 0
staff_context = {'xml': etree.tostring(module_xml),
'module_id': module_id,
'edit_link': False,
'histogram': json.dumps(histogram),
'render_histogram': render_histogram}
content += render_to_string("staff_problem_info.html", staff_context)
# the following if block is for summer 2012 edX course development; it will change when the CMS comes online
if settings.MITX_FEATURES.get('DISPLAY_EDIT_LINK') and settings.DEBUG and module_xml.get('filename') is not None:
coursename = multicourse_settings.get_coursename_from_request(request)
github_url = multicourse_settings.get_course_github_url(coursename)
fn = module_xml.get('filename')
if module_xml.tag=='problem': fn = 'problems/' + fn # grrr
edit_link = (github_url + '/tree/master/' + fn) if github_url is not None else None
if module_xml.tag=='problem': edit_link += '.xml' # grrr
staff_context = {'edit_link': edit_link,
'xml': '', # etree.tostring(module_xml),
'render_histogram': False}
content += render_to_string("staff_problem_info.html", staff_context)
context = {'content': content, 'type': module_type}
return context
......
......@@ -77,5 +77,8 @@ def get_course_title(coursename):
def get_course_number(coursename):
return get_course_property(coursename,'number')
def get_course_github_url(coursename):
return get_course_property(coursename,'github_url')
......@@ -29,6 +29,7 @@ QUICKEDIT = True
#MITX_FEATURES['USE_DJANGO_PIPELINE'] = False
MITX_FEATURES['DISPLAY_HISTOGRAMS_TO_STAFF'] = False
MITX_FEATURES['DISPLAY_EDIT_LINK'] = True
COURSE_SETTINGS = {'6.002_Spring_2012': {'number' : '6.002x',
'title' : 'Circuits and Electronics',
......@@ -38,31 +39,37 @@ COURSE_SETTINGS = {'6.002_Spring_2012': {'number' : '6.002x',
'8.02_Spring_2013': {'number' : '8.02x',
'title' : 'Electricity & Magnetism',
'xmlpath': '/802x/',
'active' : True,
'github_url': 'https://github.com/MITx/8.02x',
'active' : True,
},
'6.189_Spring_2013': {'number' : '6.189x',
'title' : 'IAP Python Programming',
'xmlpath': '/6.189x/',
'active' : True,
'github_url': 'https://github.com/MITx/6.189x',
'active' : True,
},
'8.01_Fall_2012': {'number' : '8.01x',
'title' : 'Mechanics',
'xmlpath': '/8.01x/',
'github_url': 'https://github.com/MITx/8.01x',
'active': True,
},
'edx4edx': {'number' : 'edX.01',
'title' : 'edx4edx: edX Author Course',
'xmlpath': '/edx4edx/',
'github_url': 'https://github.com/MITx/edx4edx',
'active' : True,
},
'7.03x_Fall_2012': {'number' : '7.03x',
'title' : 'Genetics',
'xmlpath': '/7.03x/',
'github_url': 'https://github.com/MITx/7.03x',
'active' : True,
},
'18.06x_Linear_Algebra': {'number' : '18.06x',
'title' : 'Linear Algebra',
'xmlpath': '/18.06x/',
'github_url': 'https://github.com/MITx/18.06x',
'active' : True,
},
}
......
<div class="staff_info">
${xml | h}
</div>
%if edit_link:
<div><a href="${edit_link}">Edit</a></div>
% endif
%if render_histogram:
<div id="histogram_${module_id}" class="histogram" data-histogram="${histogram}"></div>
%endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment