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
0feba83d
Commit
0feba83d
authored
Nov 07, 2017
by
noraiz-anwar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for testing purpose on sandbox
parent
0edcf26a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
20 deletions
+34
-20
cms/djangoapps/contentstore/management/commands/clone_course.py
+30
-20
cms/djangoapps/contentstore/views/course.py
+4
-0
No files found.
cms/djangoapps/contentstore/management/commands/clone_course.py
View file @
0feba83d
...
...
@@ -9,40 +9,50 @@ from opaque_keys.edx.keys import CourseKey
from
student.roles
import
CourseInstructorRole
,
CourseStaffRole
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
django.contrib.auth.models
import
User
from
xmodule.modulestore.xml_importer
import
import_library_from_xml
from
xmodule.contentstore.django
import
contentstore
from
contentstore.utils
import
add_instructor
,
reverse_library_url
#
# To run from command line: ./manage.py cms clone_course --settings=dev master/300/cough edx/111/foo
#
class
Command
(
BaseCommand
):
"""
C
lone a MongoDB-backed course to another location
C
reate 600 libraries
"""
help
=
'Clone a MongoDB backed course to another location'
def
add_arguments
(
self
,
parser
):
parser
.
add_argument
(
'source_course_id'
,
help
=
'Course ID to copy from'
)
parser
.
add_argument
(
'dest_course_id'
,
help
=
'Course ID to copy to'
)
def
handle
(
self
,
*
args
,
**
options
):
"""
Execute the command
"""
source_course_id
=
CourseKey
.
from_string
(
options
[
'source_course_id'
])
dest_course_id
=
CourseKey
.
from_string
(
options
[
'dest_course_id'
])
dirpath
=
u'library'
LIBRARY_ROOT
=
'library.xml'
root_name
=
LIBRARY_ROOT
import_func
=
import_library_from_xml
mstore
=
modulestore
()
user
=
User
.
objects
.
get
(
username
=
'honor'
)
store
=
modulestore
()
print
(
"Cloning course {0} to {1}"
.
format
(
source_course_id
,
dest_course_id
))
with
mstore
.
bulk_operations
(
dest_course_id
):
if
mstore
.
clone_course
(
source_course_id
,
dest_course_id
,
ModuleStoreEnum
.
UserID
.
mgmt_command
):
print
(
"copying User permissions..."
)
# purposely avoids auth.add_user b/c it doesn't have a caller to authorize
CourseInstructorRole
(
dest_course_id
)
.
add_users
(
*
CourseInstructorRole
(
source_course_id
)
.
users_with_role
()
)
CourseStaffRole
(
dest_course_id
)
.
add_users
(
*
CourseStaffRole
(
source_course_id
)
.
users_with_role
()
for
i
in
range
(
1
,
600
):
with
store
.
default_store
(
ModuleStoreEnum
.
Type
.
split
):
new_lib
=
store
.
create_library
(
org
=
'Arbisoft'
,
library
=
'library{}'
.
format
(
i
),
user_id
=
user
.
id
,
fields
=
{
"display_name"
:
'New Library'
},
)
# Give the user admin ("Instructor") role for this library:
add_instructor
(
new_lib
.
location
.
library_key
,
user
,
user
)
courselike_module
=
modulestore
()
.
get_library
(
new_lib
.
location
.
library_key
)
courselike_items
=
import_func
(
modulestore
(),
user
.
id
,
u'/edx/app/edxapp/edx-platform'
,
[
dirpath
],
load_error_modules
=
False
,
static_content_store
=
contentstore
(),
target_id
=
new_lib
.
location
.
library_key
)
cms/djangoapps/contentstore/views/course.py
View file @
0feba83d
...
...
@@ -502,7 +502,11 @@ def course_listing(request):
org
=
request
.
GET
.
get
(
'org'
,
''
)
if
optimization_enabled
else
None
courses_iter
,
in_process_course_actions
=
get_courses_accessible_to_user
(
request
,
org
)
user
=
request
.
user
start_time
=
time
.
time
()
libraries
=
_accessible_libraries_iter
(
request
.
user
,
org
)
if
LIBRARIES_ENABLED
else
[]
log
.
info
(
'_accessible_libraries_iter completed in [
%
f]'
,
(
time
.
time
()
-
start_time
))
def
format_in_process_course_view
(
uca
):
"""
...
...
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