本文整理汇总了Python中xmodule.modulestore.django.editable_modulestore函数的典型用法代码示例。如果您正苦于以下问题:Python editable_modulestore函数的具体用法?Python editable_modulestore怎么用?Python editable_modulestore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了editable_modulestore函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clear_courses
def clear_courses():
# Flush and initialize the module store
# Note that if your test module gets in some weird state
# (though it shouldn't), do this manually
# from the bash shell to drop it:
# $ mongo test_xmodule --eval "db.dropDatabase()"
editable_modulestore().collection.drop()
contentstore().fs_files.drop()
示例2: _create_item
def _create_item(self, category, name, data, metadata, parent_category, parent_name, runtime):
location = self.course.location.replace(category=category, name=name)
editable_modulestore('direct').create_and_save_xmodule(location, data, metadata, runtime)
if parent_name:
# add child to parent in mongo
parent_location = self.course.location.replace(category=parent_category, name=parent_name)
parent = editable_modulestore('direct').get_item(parent_location)
parent.children.append(location.url())
editable_modulestore('direct').update_children(parent_location, parent.children)
示例3: drop_mongo_collections
def drop_mongo_collections(store_name="default"):
"""
If using a Mongo-backed modulestore & contentstore, drop the collections.
"""
# This will return the mongo-backed modulestore
# even if we're using a mixed modulestore
store = editable_modulestore(store_name)
if hasattr(store, "collection"):
connection = store.collection.database.connection
store.collection.drop()
connection.close()
elif hasattr(store, "close_all_connections"):
store.close_all_connections()
elif hasattr(store, "db"):
connection = store.db.connection
connection.drop_database(store.db.name)
connection.close()
if contentstore().fs_files:
db = contentstore().fs_files.database
db.connection.drop_database(db)
db.connection.close()
location_mapper = loc_mapper()
if location_mapper.db:
location_mapper.location_map.drop()
location_mapper.db.connection.close()
示例4: test_translation_static_transcript
def test_translation_static_transcript(self):
"""
Set course static_asset_path and ensure we get redirected to that path
if it isn't found in the contentstore
"""
self.course.static_asset_path = "dummy/static"
self.course.save()
store = editable_modulestore()
store.update_item(self.course, "OEoXaMPEzfM")
# Test youtube style en
request = Request.blank("/translation/en?videoId=12345")
response = self.item.transcript(request=request, dispatch="translation/en")
self.assertEqual(response.status, "307 Temporary Redirect")
self.assertIn(("Location", "/static/dummy/static/subs_12345.srt.sjson"), response.headerlist)
# Test HTML5 video style
self.item.sub = "OEoXaMPEzfM"
request = Request.blank("/translation/en")
response = self.item.transcript(request=request, dispatch="translation/en")
self.assertEqual(response.status, "307 Temporary Redirect")
self.assertIn(("Location", "/static/dummy/static/subs_OEoXaMPEzfM.srt.sjson"), response.headerlist)
# Test different language to ensure we are just ignoring it since we can't
# translate with static fallback
request = Request.blank("/translation/uk")
response = self.item.transcript(request=request, dispatch="translation/uk")
self.assertEqual(response.status, "404 Not Found")
示例5: _create
def _create(cls, target_class, **kwargs):
org = kwargs.pop('org', None)
number = kwargs.pop('number', kwargs.pop('course', None))
display_name = kwargs.pop('display_name', None)
location = Location('i4x', org, number, 'course', Location.clean(display_name))
store = editable_modulestore('direct')
# Write the data to the mongo datastore
new_course = store.create_xmodule(location)
# This metadata code was copied from cms/djangoapps/contentstore/views.py
if display_name is not None:
new_course.display_name = display_name
new_course.start = datetime.datetime.now(UTC).replace(microsecond=0)
# The rest of kwargs become attributes on the course:
for k, v in kwargs.iteritems():
setattr(new_course, k, v)
# Update the data in the mongo datastore
store.save_xmodule(new_course)
return new_course
示例6: setUp
def setUp(self):
self.store = editable_modulestore()
self.factory = RequestFactory()
self.course = CourseFactory.create()
self.course.days_early_for_beta = 5
self.course.enrollment_start = datetime.datetime.now(UTC) + datetime.timedelta(days=3)
self.store.update_item(self.course)
示例7: add_grading_policy
def add_grading_policy(self, grading_policy):
"""
Add a grading policy to the course.
"""
self.course.grading_policy = grading_policy
store = editable_modulestore()
store.update_item(self.course, '**replace_user**')
self.refresh_course()
示例8: add_grading_policy
def add_grading_policy(self, grading_policy):
"""
Add a grading policy to the course.
"""
course_data = {"grading_policy": grading_policy}
store = editable_modulestore("direct")
store.update_item(self.course.location, course_data)
self.refresh_course()
示例9: drop_mongo_collection
def drop_mongo_collection():
"""
If using a Mongo-backed modulestore, drop the collection.
"""
# This will return the mongo-backed modulestore
# even if we're using a mixed modulestore
store = editable_modulestore()
if hasattr(store, 'collection'):
store.collection.drop()
示例10: update_course
def update_course(course):
"""
Updates the version of course in the modulestore
'course' is an instance of CourseDescriptor for which we want
to update metadata.
"""
store = editable_modulestore('direct')
store.update_item(course, '**replace_user**')
updated_course = store.get_instance(course.id, course.location)
return updated_course
示例11: drop_mongo_collections
def drop_mongo_collections():
"""
If using a Mongo-backed modulestore & contentstore, drop the collections.
"""
# This will return the mongo-backed modulestore
# even if we're using a mixed modulestore
store = editable_modulestore()
if hasattr(store, 'collection'):
store.collection.drop()
if contentstore().fs_files:
db = contentstore().fs_files.database
db.connection.drop_database(db)
示例12: update_course
def update_course(course, data):
"""
Updates the version of course in the modulestore
with the metadata in 'data' and returns the updated version.
'course' is an instance of CourseDescriptor for which we want
to update metadata.
'data' is a dictionary with an entry for each CourseField we want to update.
"""
store = editable_modulestore('direct')
store.update_metadata(course.location, data)
updated_course = store.get_instance(course.id, course.location)
return updated_course
示例13: setUp
def setUp(self):
self.store = editable_modulestore()
self.course = CourseFactory.create(org='Stanford', number='456', display_name='NO SHIB')
self.shib_course = CourseFactory.create(org='Stanford', number='123', display_name='Shib Only')
self.shib_course.enrollment_domain = 'shib:https://idp.stanford.edu/'
self.store.update_item(self.shib_course, '**replace_user**')
self.user_w_map = UserFactory.create(email='[email protected]')
self.extauth = ExternalAuthMap(external_id='[email protected]',
external_email='[email protected]',
external_domain='shib:https://idp.stanford.edu/',
external_credentials="",
user=self.user_w_map)
self.user_w_map.save()
self.extauth.save()
self.user_wo_map = UserFactory.create(email='[email protected]')
self.user_wo_map.save()
示例14: initialize_course
def initialize_course(self):
"""Create a course in the store, with a chapter and section."""
self.module_store = editable_modulestore()
# Create the course
self.course = CourseFactory.create(org=TEST_COURSE_ORG,
number=TEST_COURSE_NUMBER,
display_name=TEST_COURSE_NAME)
# Add a chapter to the course
chapter = ItemFactory.create(parent_location=self.course.location,
display_name=TEST_SECTION_NAME)
# add a sequence to the course to which the problems can be added
self.problem_section = ItemFactory.create(parent_location=chapter.location,
category='sequential',
display_name=TEST_SECTION_NAME)
示例15: modulestore
def modulestore(self):
# Delayed import so that we only depend on django if the caller
# hasn't provided their own modulestore
from xmodule.modulestore.django import editable_modulestore
return editable_modulestore('direct')