Commit 23128ced by ichuang

courseware views now goes to default chapter and section if unprovided

  - uses multicourse settings (default_chapter and default_section)
  - it would be nice to use course_settings instead, but that is not
    currently compatible with multicourse
parent 7e25e30a
...@@ -71,6 +71,7 @@ class Settings(object): ...@@ -71,6 +71,7 @@ class Settings(object):
# Load the course settings as a dictionary # Load the course settings as a dictionary
course_settings = {} course_settings = {}
try: try:
# TODO: this doesn't work with multicourse
with open( settings.DATA_DIR + "/course_settings.json") as course_settings_file: with open( settings.DATA_DIR + "/course_settings.json") as course_settings_file:
course_settings_string = course_settings_file.read() course_settings_string = course_settings_file.read()
course_settings = json.loads(course_settings_string) course_settings = json.loads(course_settings_string)
......
...@@ -165,7 +165,8 @@ def get_course(request, course): ...@@ -165,7 +165,8 @@ def get_course(request, course):
if not settings.ENABLE_MULTICOURSE: if not settings.ENABLE_MULTICOURSE:
course = "edx4edx" course = "edx4edx"
elif 'coursename' in request.session: elif 'coursename' in request.session:
course = request.session['coursename'] # use multicourse_settings, so that settings.COURSE_TITLE is set properly
course = multicourse_settings.get_coursename_from_request(request)
else: else:
course = settings.COURSE_DEFAULT course = settings.COURSE_DEFAULT
return course return course
...@@ -287,6 +288,17 @@ def index(request, course=None, chapter=None, section=None, ...@@ -287,6 +288,17 @@ def index(request, course=None, chapter=None, section=None,
# keep track of current course being viewed in django's request.session # keep track of current course being viewed in django's request.session
request.session['coursename'] = course request.session['coursename'] = course
# get default chapter & section from multicourse settings, if not provided
if chapter is None:
defchapter = multicourse_settings.get_course_default_chapter(course)
defsection = multicourse_settings.get_course_default_section(course)
if defchapter and defsection:
# jump there using redirect, so the user gets the right URL in their browser
return redirect('%s/courseware/%s/%s/%s/' % (settings.MITX_ROOT_URL,
get_course(request, course),
defchapter,
defsection))
chapter = clean(chapter) chapter = clean(chapter)
section = clean(section) section = clean(section)
......
...@@ -80,5 +80,11 @@ def get_course_number(coursename): ...@@ -80,5 +80,11 @@ def get_course_number(coursename):
def get_course_github_url(coursename): def get_course_github_url(coursename):
return get_course_property(coursename,'github_url') return get_course_property(coursename,'github_url')
def get_course_default_chapter(coursename):
return get_course_property(coursename,'default_chapter')
def get_course_default_section(coursename):
return get_course_property(coursename,'default_section')
...@@ -42,51 +42,67 @@ MAKO_TEMPLATES['course'] = [DATA_DIR, EDX4EDX_ROOT ] ...@@ -42,51 +42,67 @@ MAKO_TEMPLATES['course'] = [DATA_DIR, EDX4EDX_ROOT ]
MITX_FEATURES['DISPLAY_HISTOGRAMS_TO_STAFF'] = False MITX_FEATURES['DISPLAY_HISTOGRAMS_TO_STAFF'] = False
MITX_FEATURES['DISPLAY_EDIT_LINK'] = True MITX_FEATURES['DISPLAY_EDIT_LINK'] = True
COURSE_SETTINGS = {'6.002_Spring_2012': {'number' : '6.002x', COURSE_SETTINGS = {'6.002_Fall_2012': {'number' : '6.002x',
'title' : 'Circuits and Electronics', 'title' : 'Circuits and Electronics',
'xmlpath': '/6002x/', 'xmlpath': '/6002x-fall-2012/',
'active' : True, 'active' : True,
'default_chapter' : 'Week_1',
'default_section' : 'Administrivia_and_Circuit_Elements',
}, },
'8.02_Spring_2013': {'number' : '8.02x', '8.02_Spring_2013': {'number' : '8.02x',
'title' : 'Electricity & Magnetism', 'title' : 'Electricity & Magnetism',
'xmlpath': '/802x/', 'xmlpath': '/802x/',
'github_url': 'https://github.com/MITx/8.02x', 'github_url': 'https://github.com/MITx/8.02x',
'active' : True, 'active' : True,
'default_chapter' : 'Introduction',
'default_section' : 'Introduction_%28Lewin_2002%29',
}, },
'6.189_Spring_2013': {'number' : '6.189x', '6.189_Spring_2013': {'number' : '6.189x',
'title' : 'IAP Python Programming', 'title' : 'IAP Python Programming',
'xmlpath': '/6.189x/', 'xmlpath': '/6.189x/',
'github_url': 'https://github.com/MITx/6.189x', 'github_url': 'https://github.com/MITx/6.189x',
'active' : True, 'active' : True,
'default_chapter' : 'Week_1',
'default_section' : 'Variables_and_Binding',
}, },
'8.01_Fall_2012': {'number' : '8.01x', '8.01_Fall_2012': {'number' : '8.01x',
'title' : 'Mechanics', 'title' : 'Mechanics',
'xmlpath': '/8.01x/', 'xmlpath': '/8.01x/',
'github_url': 'https://github.com/MITx/8.01x', 'github_url': 'https://github.com/MITx/8.01x',
'active': True, 'active': True,
'default_chapter' : 'MIT_8.011_Spring_2012',
'default_section' : 'Introduction_to_the_course',
}, },
'edx4edx': {'number' : 'edX.01', 'edx4edx': {'number' : 'edX.01',
'title' : 'edx4edx: edX Author Course', 'title' : 'edx4edx: edX Author Course',
'xmlpath': '/edx4edx/', 'xmlpath': '/edx4edx/',
'github_url': 'https://github.com/MITx/edx4edx', 'github_url': 'https://github.com/MITx/edx4edx',
'active' : True, 'active' : True,
'default_chapter' : 'Introduction',
'default_section' : 'edx4edx_Course',
}, },
'7.03x_Fall_2012': {'number' : '7.03x', '7.03x_Fall_2012': {'number' : '7.03x',
'title' : 'Genetics', 'title' : 'Genetics',
'xmlpath': '/7.03x/', 'xmlpath': '/7.03x/',
'github_url': 'https://github.com/MITx/7.03x', 'github_url': 'https://github.com/MITx/7.03x',
'active' : True, 'active' : True,
'default_chapter' : 'Week_2',
'default_section' : 'ps1_question_1',
}, },
'3.091x_Fall_2012': {'number' : '3.091x', '3.091x_Fall_2012': {'number' : '3.091x',
'title' : 'Introduction to Solid State Chemistry', 'title' : 'Introduction to Solid State Chemistry',
'xmlpath': '/3.091x/', 'xmlpath': '/3.091x/',
'github_url': 'https://github.com/MITx/3.091x', 'github_url': 'https://github.com/MITx/3.091x',
'active' : True, 'active' : True,
'default_chapter' : 'Week_1',
'default_section' : 'Problem_Set_1',
}, },
'18.06x_Linear_Algebra': {'number' : '18.06x', '18.06x_Linear_Algebra': {'number' : '18.06x',
'title' : 'Linear Algebra', 'title' : 'Linear Algebra',
'xmlpath': '/18.06x/', 'xmlpath': '/18.06x/',
'github_url': 'https://github.com/MITx/18.06x', 'github_url': 'https://github.com/MITx/18.06x',
'default_chapter' : 'Unit_1',
'default_section' : 'Midterm_1',
'active' : True, 'active' : True,
}, },
'6.00x_Fall_2012': {'number' : '6.00x', '6.00x_Fall_2012': {'number' : '6.00x',
...@@ -94,6 +110,8 @@ COURSE_SETTINGS = {'6.002_Spring_2012': {'number' : '6.002x', ...@@ -94,6 +110,8 @@ COURSE_SETTINGS = {'6.002_Spring_2012': {'number' : '6.002x',
'xmlpath': '/6.00x/', 'xmlpath': '/6.00x/',
'github_url': 'https://github.com/MITx/6.00x', 'github_url': 'https://github.com/MITx/6.00x',
'active' : True, 'active' : True,
'default_chapter' : 'Week_0',
'default_section' : 'Problem_Set_0',
}, },
} }
......
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