Add an Editor as course option in new course format

Add an Editor as course option in new course format

by Nicolas Dalpe -
Number of replies: 0
Hi Guys,
We are building a new course format based on Topics. I want to add an editor as a course option and I have the following questions:

Should we add the _editor suffix when we declare the field (with $mform->addElement)?

How do we set the text (text and images) back into the editor when it is displayed in the course setting?

So far, I am setting the editor content with the following code in format_xxx::create_edit_form_elements() but it has 2 problems 1) is this really the best way? and 2) it doesn't apply the filter and keep the media url as @@plugin...@@/. I know I can convert them manually with file_rewrite_pluginfile_urls() and format_text() but is this the best way? Din't Moodle thought about a better way already?

$element= $mform->getElement($texteditors);
$element->setValue(['text' => $editorcontent]);


In what callback should we call file_prepare_standard_editor()?
I am calling file_prepare_standard_editor() in format_xxx::create_edit_form_elements(). I couldn't find a specific callback for course creation and course update. I guessed that when the form is created then the files in the editor should be brought to draft file area. Make sense?


In what callback should we call file_postupdate_standard_filemanager()?
I am calling update_course_format_options() in format_xxx::update_course_format_options(). I think this is where it is supposed to be called. Any suggestion?


We are using Moodle 4.1 latest with the Boost theme.

Thank you in advance for your help
Average of ratings: -