From 1494cbbd85e369f71099aca81536eade6e927fa5 Mon Sep 17 00:00:00 2001 From: ichuang Date: Thu, 10 May 2012 23:16:34 -0400 Subject: [PATCH] Merged root URL prefix from Ike. Errors should be attributed to pmitros. --- djangoapps/courseware/module_render.py | 4 +++- djangoapps/courseware/views.py | 2 +- lib/mitxmako/shortcuts.py | 1 + settings.py | 8 ++++++++ templates/main.html | 2 +- templates/navigation.html | 14 +++++++------- templates/problem.js | 8 ++++---- templates/seq_module.js | 2 +- 8 files changed, 26 insertions(+), 15 deletions(-) diff --git a/djangoapps/courseware/module_render.py b/djangoapps/courseware/module_render.py index 8273d903d0..0abf14af5f 100644 --- a/djangoapps/courseware/module_render.py +++ b/djangoapps/courseware/module_render.py @@ -78,7 +78,7 @@ def render_x_module(user, request, xml_module, module_object_preload): state = smod.state # Create a new instance - ajax_url = '/modx/'+module_type+'/'+module_id+'/' + ajax_url = settings.MITX_ROOT_URL + '/modx/'+module_type+'/'+module_id+'/' system = I4xSystem(track_function = make_track_function(request), render_function = lambda x: render_module(user, request, x, module_object_preload), ajax_url = ajax_url, @@ -102,6 +102,8 @@ def render_x_module(user, request, xml_module, module_object_preload): content = instance.get_html() init_js = instance.get_init_js() destory_js = instance.get_destroy_js() + + # special extra information about each problem, only for users who are staff if user.is_staff: histogram = grade_histogram(module_id) render_histogram = len(histogram) > 0 diff --git a/djangoapps/courseware/views.py b/djangoapps/courseware/views.py index 7770b6359e..b86409feb6 100644 --- a/djangoapps/courseware/views.py +++ b/djangoapps/courseware/views.py @@ -204,7 +204,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): dispatch=dispatch.split('?')[0] - ajax_url = '/modx/'+module+'/'+id+'/' + ajax_url = settings.MITX_ROOT_URL + '/modx/'+module+'/'+id+'/' # Grab the XML corresponding to the request from course.xml xml = content_parser.module_xml(request.user, module, 'id', id) diff --git a/lib/mitxmako/shortcuts.py b/lib/mitxmako/shortcuts.py index ca626b5c85..432acbcba9 100644 --- a/lib/mitxmako/shortcuts.py +++ b/lib/mitxmako/shortcuts.py @@ -27,6 +27,7 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'): # collapse context_instance to a single dictionary for mako context_dictionary = {} context_instance['settings'] = settings + context_instance['MITX_ROOT_URL'] = settings.MITX_ROOT_URL for d in mitxmako.middleware.requestcontext: context_dictionary.update(d) for d in context_instance: diff --git a/settings.py b/settings.py index 6f59f7b27c..ea4e90b4a9 100644 --- a/settings.py +++ b/settings.py @@ -5,6 +5,14 @@ import tempfile import djcelery +MITX_ROOT_URL = '' + +COURSE_NAME = "6.002_Spring_2012" +COURSE_NUMBER = "6.002x" +COURSE_TITLE = "Circuits and Electronics" + +ROOT_URLCONF = 'urls' + # from settings2.askbotsettings import LIVESETTINGS_OPTIONS DEFAULT_GROUPS = [] diff --git a/templates/main.html b/templates/main.html index ddaed79677..014248bcd6 100644 --- a/templates/main.html +++ b/templates/main.html @@ -87,7 +87,7 @@
  • Help
  • % if user.is_authenticated(): -
  • Log out
  • +
  • Log out
  • % endif diff --git a/templates/navigation.html b/templates/navigation.html index 935c81bdbf..f33ee0ec42 100644 --- a/templates/navigation.html +++ b/templates/navigation.html @@ -3,20 +3,20 @@

    MITx

    -

    Circuits and Electronics

    +

    ${ settings.COURSE_TITLE }

    diff --git a/templates/problem.js b/templates/problem.js index a12aabcc0e..e9edaba096 100644 --- a/templates/problem.js +++ b/templates/problem.js @@ -8,7 +8,7 @@ function ${ id }_content_updated() { $.each($("[id^=input_${ id }_]"), function(index,value){ submit_data[value.id]=value.value; }); - postJSON('/modx/problem/${ id }/problem_check', + postJSON('${ MITX_ROOT_URL }/modx/problem/${ id }/problem_check', submit_data, function(json) { switch(json.success) { @@ -30,7 +30,7 @@ function ${ id }_content_updated() { submit_data[value.id]=value.value; }); - postJSON('/modx/problem/${ id }/problem_reset', {'id':'${ id }'}, function(html_as_json) { + postJSON('${ MITX_ROOT_URL }/modx/problem/${ id }/problem_reset', {'id':'${ id }'}, function(html_as_json) { $('#main_${ id }').html(html_as_json); ${ id }_content_updated(); }); @@ -38,7 +38,7 @@ function ${ id }_content_updated() { }); $('#show_${ id }').unbind('click').click(function() { - postJSON('/modx/problem/${ id }/problem_show', {}, function(data) { + postJSON('${ MITX_ROOT_URL }/modx/problem/${ id }/problem_show', {}, function(data) { for (var key in data) { $("#answer_"+key).text(data[key]); } @@ -53,7 +53,7 @@ function ${ id }_content_updated() { $.each($("[id^=input_${ id }_]"), function(index,value) { submit_data[value.id]=value.value; }); - postJSON('/modx/problem/${ id }/problem_save', + postJSON('${ MITX_ROOT_URL }/modx/problem/${ id }/problem_save', submit_data, function(data) { if(data.success) { diff --git a/templates/seq_module.js b/templates/seq_module.js index b4f92db8a1..afa2fffea1 100644 --- a/templates/seq_module.js +++ b/templates/seq_module.js @@ -53,7 +53,7 @@ function disablePrev() { function ${ id }goto(i) { log_event("seq_goto", {'old':${id}loc, 'new':i,'id':'${id}'}); - postJSON('/modx/sequential/${ id }/goto_position', + postJSON('${ MITX_ROOT_URL }/modx/sequential/${ id }/goto_position', {'position' : i }); if (${ id }loc!=-1)