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
033f5ce7
Commit
033f5ce7
authored
Mar 29, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make process to add open ended tab to studio reversible
parent
b8e6c94d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
4 deletions
+33
-4
cms/djangoapps/contentstore/utils.py
+16
-0
cms/djangoapps/contentstore/views.py
+17
-4
No files found.
cms/djangoapps/contentstore/utils.py
View file @
033f5ce7
...
...
@@ -210,3 +210,19 @@ def add_open_ended_panel_tab(course):
course_tabs
.
append
(
OPEN_ENDED_PANEL
)
changed
=
True
return
changed
,
course_tabs
def
remove_open_ended_panel_tab
(
course
):
"""
Used to remove the open ended panel tab from a course if it exists.
@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
in
course_tabs
:
#Add panel to the tabs if it is not defined
course_tabs
=
[
ct
for
ct
in
course_tabs
if
ct
!=
OPEN_ENDED_PANEL
]
changed
=
True
return
changed
,
course_tabs
cms/djangoapps/contentstore/views.py
View file @
033f5ce7
...
...
@@ -52,7 +52,8 @@ from auth.authz import is_user_in_course_group_role, get_users_in_course_group_b
from
auth.authz
import
get_user_by_email
,
add_user_to_course_group
,
remove_user_from_course_group
from
auth.authz
import
INSTRUCTOR_ROLE_NAME
,
STAFF_ROLE_NAME
,
create_all_course_groups
from
.utils
import
get_course_location_for_item
,
get_lms_link_for_item
,
compute_unit_state
,
\
get_date_display
,
UnitState
,
get_course_for_item
,
get_url_reverse
,
add_open_ended_panel_tab
get_date_display
,
UnitState
,
get_course_for_item
,
get_url_reverse
,
add_open_ended_panel_tab
,
\
remove_open_ended_panel_tab
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
contentstore.course_info_model
import
get_course_updates
,
\
...
...
@@ -1287,13 +1288,14 @@ def course_advanced_updates(request, org, course, name):
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.
#module
, and to remove it if they have removed the open ended elements
.
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
]:
found_oe_type
=
False
#Get the course so that we can scrape current tabs
course_module
=
modulestore
()
.
get_item
(
location
)
for
oe_type
in
OPEN_ENDED_COMPONENT_TYPES
:
if
oe_type
in
request_body
[
ADVANCED_COMPONENT_POLICY_KEY
]:
#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
...
...
@@ -1301,7 +1303,18 @@ def course_advanced_updates(request, org, course, name):
request_body
.
update
({
'tabs'
:
new_tabs
})
#Indicate that tabs should not be filtered out of the metadata
filter_tabs
=
False
#Set this flag to avoid the open ended tab removal code below.
found_oe_type
=
True
break
#If we did not find an open ended module type in the advanced settings,
# we may need to remove the open ended tab from the course.
if
not
found_oe_type
:
#Remove open ended tab to the course if needed
changed
,
new_tabs
=
remove_open_ended_panel_tab
(
course_module
)
if
changed
:
request_body
.
update
({
'tabs'
:
new_tabs
})
#Indicate that tabs should not be filtered out of the metadata
filter_tabs
=
False
response_json
=
json
.
dumps
(
CourseMetadata
.
update_from_json
(
location
,
request_body
,
filter_tabs
=
filter_tabs
))
return
HttpResponse
(
response_json
,
mimetype
=
"application/json"
)
...
...
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