diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 3a6fcbfb45..f3e0fd342c 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -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 diff --git a/lms/djangoapps/multicourse/multicourse_settings.py b/lms/djangoapps/multicourse/multicourse_settings.py index 05b05c8ec9..924d8448e6 100644 --- a/lms/djangoapps/multicourse/multicourse_settings.py +++ b/lms/djangoapps/multicourse/multicourse_settings.py @@ -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') diff --git a/lms/envs/dev_ike.py b/lms/envs/dev_ike.py index e9f4b82860..675ca8366a 100644 --- a/lms/envs/dev_ike.py +++ b/lms/envs/dev_ike.py @@ -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, }, } diff --git a/lms/templates/staff_problem_info.html b/lms/templates/staff_problem_info.html index 24450c797a..54c7e45e2a 100644 --- a/lms/templates/staff_problem_info.html +++ b/lms/templates/staff_problem_info.html @@ -1,6 +1,9 @@
${xml | h}
+%if edit_link: +
Edit
+% endif %if render_histogram:
%endif