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
ff525bea
Commit
ff525bea
authored
Aug 21, 2014
by
Ben McMorran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix field serialization
parent
bb90c307
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
cms/djangoapps/contentstore/tasks.py
+11
-1
cms/djangoapps/contentstore/views/course.py
+3
-1
No files found.
cms/djangoapps/contentstore/tasks.py
View file @
ff525bea
...
...
@@ -4,7 +4,9 @@ This file contains celery tasks for contentstore views
from
celery.task
import
task
from
django.contrib.auth.models
import
User
import
json
from
xmodule.modulestore.django
import
modulestore
from
xmodule.course_module
import
CourseFields
from
xmodule.modulestore.exceptions
import
DuplicateCourseError
,
ItemNotFoundError
from
course_action_state.models
import
CourseRerunState
...
...
@@ -18,9 +20,10 @@ def rerun_course(source_course_key_string, destination_course_key_string, user_i
Reruns a course in a new celery task.
"""
try
:
# deserialize the
keys
# deserialize the
payload
source_course_key
=
CourseKey
.
from_string
(
source_course_key_string
)
destination_course_key
=
CourseKey
.
from_string
(
destination_course_key_string
)
fields
=
deserialize_fields
(
fields
)
# use the split modulestore as the store for the rerun course,
# as the Mongo modulestore doesn't support multiple runs of the same course.
...
...
@@ -53,3 +56,10 @@ def rerun_course(source_course_key_string, destination_course_key_string, user_i
pass
return
"exception: "
+
unicode
(
exc
)
def
deserialize_fields
(
json_fields
):
fields
=
json
.
loads
(
json_fields
)
for
field_name
,
value
in
fields
.
iteritems
():
fields
[
field_name
]
=
getattr
(
CourseFields
,
field_name
)
.
from_json
(
value
)
return
fields
cms/djangoapps/contentstore/views/course.py
View file @
ff525bea
...
...
@@ -23,6 +23,7 @@ from xmodule.modulestore.django import modulestore
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.tabs
import
PDFTextbookTabs
from
xmodule.partitions.partitions
import
UserPartition
,
Group
from
xmodule.modulestore
import
EdxJSONEncoder
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
DuplicateCourseError
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.locations
import
Location
...
...
@@ -614,7 +615,8 @@ def _rerun_course(request, org, number, run, fields):
CourseRerunState
.
objects
.
initiated
(
source_course_key
,
destination_course_key
,
request
.
user
,
fields
[
'display_name'
])
# Rerun the course as a new celery task
rerun_course
.
delay
(
unicode
(
source_course_key
),
unicode
(
destination_course_key
),
request
.
user
.
id
,
fields
)
json_fields
=
json
.
dumps
(
fields
,
cls
=
EdxJSONEncoder
)
rerun_course
.
delay
(
unicode
(
source_course_key
),
unicode
(
destination_course_key
),
request
.
user
.
id
,
json_fields
)
# Return course listing page
return
JsonResponse
({
...
...
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