Commit 10eb7e45 by Vik Paruchuri

Add in some docs

parent a717dffd
...@@ -161,9 +161,17 @@ def update_item(location, value): ...@@ -161,9 +161,17 @@ def update_item(location, value):
get_modulestore(location).update_item(location, value) get_modulestore(location).update_item(location, value)
def add_open_ended_panel_tab(course): def add_open_ended_panel_tab(course):
"""
Used to add the open ended panel tab to a course if it does not exist.
@param course: A course object from the modulestore.
@return: Boolean indicating whether or not a tab was added and a list of tabs for the course.
"""
#Copy course tabs
course_tabs = copy.copy(course.tabs) course_tabs = copy.copy(course.tabs)
changed = False changed = False
#Check to see if open ended panel is defined in the course
if OPEN_ENDED_PANEL not in course_tabs: if OPEN_ENDED_PANEL not in course_tabs:
#Add panel to the tabs if it is not defined
course_tabs.append(OPEN_ENDED_PANEL) course_tabs.append(OPEN_ENDED_PANEL)
changed = True changed = True
return changed, course_tabs return changed, course_tabs
......
...@@ -310,7 +310,6 @@ def edit_unit(request, location): ...@@ -310,7 +310,6 @@ def edit_unit(request, location):
templates = modulestore().get_items(Location('i4x', 'edx', 'templates')) templates = modulestore().get_items(Location('i4x', 'edx', 'templates'))
for template in templates: for template in templates:
category = template.location.category category = template.location.category
if category in course_advanced_keys: if category in course_advanced_keys:
category = ADVANCED_COMPONENT_CATEGORY category = ADVANCED_COMPONENT_CATEGORY
...@@ -1332,14 +1331,23 @@ def course_advanced_updates(request, org, course, name): ...@@ -1332,14 +1331,23 @@ def course_advanced_updates(request, org, course, name):
elif real_method == 'POST' or real_method == 'PUT': elif real_method == 'POST' or real_method == 'PUT':
# NOTE: request.POST is messed up because expect_json cloned_request.POST.copy() is creating a defective entry w/ the whole payload as the key # NOTE: request.POST is messed up because expect_json cloned_request.POST.copy() is creating a defective entry w/ the whole payload as the key
request_body = json.loads(request.body) request_body = json.loads(request.body)
#Whether or not to filter the tabs key out of the settings metadata
filter_tabs = True filter_tabs = True
#Check to see if the user instantiated any advanced components. This is a hack to add the open ended panel tab
#to a course automatically if the user has indicated that they want to edit the combinedopenended or peergrading
#module.
if ADVANCED_COMPONENT_POLICY_KEY in request_body: if ADVANCED_COMPONENT_POLICY_KEY in request_body:
#Check to see if the user instantiated any open ended components
for oe_type in OPEN_ENDED_COMPONENT_TYPES: for oe_type in OPEN_ENDED_COMPONENT_TYPES:
if oe_type in request_body[ADVANCED_COMPONENT_POLICY_KEY]: if oe_type in request_body[ADVANCED_COMPONENT_POLICY_KEY]:
#Get the course so that we can scrape current tabs
course_module = modulestore().get_item(location) course_module = modulestore().get_item(location)
#Add an open ended tab to the course if needed
changed, new_tabs = add_open_ended_panel_tab(course_module) changed, new_tabs = add_open_ended_panel_tab(course_module)
#If a tab has been added to the course, then send the metadata along to CourseMetadata.update_from_json
if changed: if changed:
request_body.update({'tabs' : new_tabs}) request_body.update({'tabs' : new_tabs})
#Indicate that tabs should not be filtered out of the metadata
filter_tabs = False filter_tabs = False
break break
response_json = json.dumps(CourseMetadata.update_from_json(location, request_body, filter_tabs=filter_tabs)) response_json = json.dumps(CourseMetadata.update_from_json(location, request_body, filter_tabs=filter_tabs))
......
...@@ -41,7 +41,9 @@ class CourseMetadata(object): ...@@ -41,7 +41,9 @@ class CourseMetadata(object):
dirty = False dirty = False
#Copy the filtered list to avoid permanently changing the class attribute
filtered_list = copy.copy(cls.FILTERED_LIST) filtered_list = copy.copy(cls.FILTERED_LIST)
#Don't filter on the tab attribute if filter_tabs is False
if not filter_tabs: if not filter_tabs:
filtered_list.remove("tabs") filtered_list.remove("tabs")
......
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