Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
10eb7e45
Commit
10eb7e45
authored
Mar 14, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add in some docs
parent
a717dffd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
cms/djangoapps/contentstore/utils.py
+8
-0
cms/djangoapps/contentstore/views.py
+11
-3
cms/djangoapps/models/settings/course_metadata.py
+2
-0
No files found.
cms/djangoapps/contentstore/utils.py
View file @
10eb7e45
...
...
@@ -161,9 +161,17 @@ def update_item(location, value):
get_modulestore
(
location
)
.
update_item
(
location
,
value
)
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
)
changed
=
False
#Check to see if open ended panel is defined in the course
if
OPEN_ENDED_PANEL
not
in
course_tabs
:
#Add panel to the tabs if it is not defined
course_tabs
.
append
(
OPEN_ENDED_PANEL
)
changed
=
True
return
changed
,
course_tabs
...
...
cms/djangoapps/contentstore/views.py
View file @
10eb7e45
...
...
@@ -297,7 +297,7 @@ def edit_unit(request, location):
# in ADVANCED_COMPONENT_TYPES that should be enabled for the course.
course_metadata
=
CourseMetadata
.
fetch
(
course
.
location
)
course_advanced_keys
=
course_metadata
.
get
(
ADVANCED_COMPONENT_POLICY_KEY
,
[])
# Set component types according to course policy file
component_types
=
list
(
COMPONENT_TYPES
)
if
isinstance
(
course_advanced_keys
,
list
):
...
...
@@ -310,7 +310,6 @@ def edit_unit(request, location):
templates
=
modulestore
()
.
get_items
(
Location
(
'i4x'
,
'edx'
,
'templates'
))
for
template
in
templates
:
category
=
template
.
location
.
category
if
category
in
course_advanced_keys
:
category
=
ADVANCED_COMPONENT_CATEGORY
...
...
@@ -1332,15 +1331,24 @@ def course_advanced_updates(request, org, course, name):
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
request_body
=
json
.
loads
(
request
.
body
)
#Whether or not to filter the tabs key out of the settings metadata
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
:
#Check to see if the user instantiated any open ended components
for
oe_type
in
OPEN_ENDED_COMPONENT_TYPES
:
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
)
#Add an open ended tab to the course if needed
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
:
request_body
.
update
({
'tabs'
:
new_tabs
})
filter_tabs
=
False
#Indicate that tabs should not be filtered out of the metadata
filter_tabs
=
False
break
response_json
=
json
.
dumps
(
CourseMetadata
.
update_from_json
(
location
,
request_body
,
filter_tabs
=
filter_tabs
))
return
HttpResponse
(
response_json
,
mimetype
=
"application/json"
)
...
...
cms/djangoapps/models/settings/course_metadata.py
View file @
10eb7e45
...
...
@@ -41,7 +41,9 @@ class CourseMetadata(object):
dirty
=
False
#Copy the filtered list to avoid permanently changing the class attribute
filtered_list
=
copy
.
copy
(
cls
.
FILTERED_LIST
)
#Don't filter on the tab attribute if filter_tabs is False
if
not
filter_tabs
:
filtered_list
.
remove
(
"tabs"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment