Hello all,
open edX version: open-release/ironwood.master
On the studio side, I have created one field like Course Overview
and named it to Course Instructor
as I wanted to separate the instructor HTML on the course about page (LMS side).
So, this custom created field is working fine on both LMS and cms side but the issue is while course creation.
open edX is loading overview.yaml
while course creation so that staff users can utilize the HTML structure. I want to achieve the same. I have created instructor.yaml
file and want to load it while course creation.
I have made changes like this in this file:
def create_course(self, org, course, run, user_id, fields=None, runtime=None, **kwargs):
"""
Creates any necessary other things for the course as a side effect and doesn't return
anything useful. The real subclass should call this before it returns the course.
"""
# clone a default 'about' overview module as well
about_location = self.make_course_key(org, course, run).make_usage_key('about', 'overview')
about_descriptor = XBlock.load_class('about')
overview_template = about_descriptor.get_template('overview.yaml')
self.create_item(
user_id,
about_location.course_key,
about_location.block_type,
block_id=about_location.block_id,
definition_data={'data': overview_template.get('data')},
metadata=overview_template.get('metadata'),
runtime=runtime,
continue_version=True,
)
instructor_template = about_descriptor.get_template('instructor.yaml')
self.create_item(
user_id,
about_location.course_key,
about_location.block_type,
block_id=about_location.block_id,
definition_data={'data': instructor_template.get('data')},
metadata=instructor_template.get('metadata'),
runtime=runtime,
continue_version=True,
)
At this point, I know this is wrong but don’t know how to achieve this so I have played like this.
Above is throwing error while course creation but if I refresh the page then able to access the course but my Course Instructor field is empty!
edx.devstack.uni.studio | 2020-07-27 07:28:13,829 ERROR 1231 [django.request] exception.py:135 - Internal Server Error: /course/
edx.devstack.uni.studio | Traceback (most recent call last):
edx.devstack.uni.studio | File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
edx.devstack.uni.studio | response = get_response(request)
edx.devstack.uni.studio | File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
edx.devstack.uni.studio | response = self._get_response(request)
edx.devstack.uni.studio | File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
edx.devstack.uni.studio | response = self.process_exception_by_middleware(e, request)
edx.devstack.uni.studio | File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
edx.devstack.uni.studio | response = wrapped_callback(request, *callback_args, **callback_kwargs)
edx.devstack.uni.studio | File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
edx.devstack.uni.studio | return func(*args, **kwargs)
edx.devstack.uni.studio | File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
edx.devstack.uni.studio | return view_func(request, *args, **kwargs)
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/course.py", line 262, in course_handler
edx.devstack.uni.studio | return _create_or_rerun_course(request)
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/common/djangoapps/util/json_request.py", line 53, in parse_json_into_request
edx.devstack.uni.studio | return view_function(request, *args, **kwargs)
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/course.py", line 839, in _create_or_rerun_course
edx.devstack.uni.studio | new_course = create_new_course(request.user, org, course, run, fields)
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/course.py", line 878, in create_new_course
edx.devstack.uni.studio | new_course = create_new_course_in_store(store_for_new_course, user, org, number, run, fields)
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/cms/djangoapps/contentstore/views/course.py", line 902, in create_new_course_in_store
edx.devstack.uni.studio | fields=fields,
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/mixed.py", line 89, in inner
edx.devstack.uni.studio | retval = func(field_decorator=strip_key_collection, *args, **kwargs)
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/mixed.py", line 664, in create_course
edx.devstack.uni.studio | course = store.create_course(org, course, run, user_id, **kwargs)
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py", line 51, in create_course
edx.devstack.uni.studio | org, course, run, user_id, runtime=item.runtime, **kwargs
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/__init__.py", line 1341, in create_course
edx.devstack.uni.studio | continue_version=True,
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py", line 171, in create_item
edx.devstack.uni.studio | force=force, **kwargs
edx.devstack.uni.studio | File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py", line 1782, in create_item
edx.devstack.uni.studio | raise DuplicateItemError(block_id, self, 'structures')
edx.devstack.uni.studio | DuplicateItemError: <xmodule.modulestore.split_mongo.split_draft.DraftVersioningModuleStore object at 0x7f6e94778450>[structures] already has overview ()
Please provide your help if you have any ideas.
Thanks.