I have created a xblock, now I want to set this xblock as default xblock as an advanced component for every newly created course automatically.
Thanks.
I have created a xblock, now I want to set this xblock as default xblock as an advanced component for every newly created course automatically.
Thanks.
the right way to solve this problem is to edit the CourseFields
class under common/lib/xmodule/xmodule/course_module.py
file. You will find that there is a class variable called advanced_modules
with type List
. you can just do something like this
advanced_modules = List(
display_name=_("Advanced Module List"),
default=[], # this is where you add default values
help=_("Enter the names of the advanced components to use in your course."),
scope=Scope.settings
)
You need to add your XBlock to the list of advanced components. In your CMS settings file, add:
ADVANCED_COMPONENT_TYPES.append('your_xblock')
Setup default advanced component
edit the following file
cms/djangoapps/contentstore/views/components.py
Add the following line to function ‘get_component_templates()’ After
if isinstance(course_advanced_keys, list):
Add
course_advanced_keys.append('your_xblock')