Merge branch 'MDL-76257-master' of https://github.com/juancs/moodle

This commit is contained in:
Jun Pataleta 2023-03-17 11:02:13 +08:00 committed by Sara Arjona
commit 52d8364819
2 changed files with 41 additions and 1 deletions

View File

@ -878,7 +878,7 @@ function prepare_new_moduleinfo_data($course, $modulename, $section) {
if (plugin_supports('mod', $data->modulename, FEATURE_MOD_INTRO, true)) {
$draftid_editor = file_get_submitted_draft_itemid('introeditor');
file_prepare_draft_area($draftid_editor, null, null, null, null, array('subdirs'=>true));
$data->introeditor = array('text'=>'', 'format'=>FORMAT_HTML, 'itemid'=>$draftid_editor); // TODO: add better default
$data->introeditor = array('text' => '', 'format' => editors_get_preferred_format(), 'itemid' => $draftid_editor);
}
if (plugin_supports('mod', $data->modulename, FEATURE_ADVANCED_GRADING, false)

View File

@ -47,3 +47,43 @@ Feature: Add activities to courses
And I add a "Database" to section "3" and I fill the form with:
| Name | Test name |
Then I should see "Required"
@javascript
Scenario: The activity description should use the user's preferred editor on creation
Given the following "user preferences" exist:
| user | preference | value |
| admin | htmleditor | textarea |
And I am logged in as admin
And I am on "Course 1" course homepage with editing mode on
When I add a "Database" to section "3"
Then I should see "Moodle auto-format" in the "#menuintroeditorformat > option[selected]" "css_element"
@javascript
Scenario: The activity description should preserve the format used once edited (markdown version)
Given the following "activities" exist:
| activity | name | intro | introformat | course |
| assign | A4 | Desc 4 | 4 | Course 1 |
And the following "user preferences" exist:
| user | preference | value |
| admin | htmleditor | textarea |
And I am logged in as admin
And I am on "Course 1" course homepage with editing mode on
And I open "A4" actions menu
When I click on "Edit settings" "link" in the "A4" activity
Then I should see "Markdown format" in the "#menuintroeditorformat > option[selected]" "css_element"
And I should not see "Plain text format" in the "#menuintroeditorformat > option[selected]" "css_element"
@javascript
Scenario: The activity description should preserve the format used once edited (plain text version)
Given the following "activities" exist:
| activity | name | intro | introformat | course |
| assign | A2 | Desc 2 | 2 | Course 1 |
And the following "user preferences" exist:
| user | preference | value |
| admin | htmleditor | textarea |
And I am logged in as admin
And I am on "Course 1" course homepage with editing mode on
And I open "A2" actions menu
When I click on "Edit settings" "link" in the "A2" activity
Then I should see "Plain text format" in the "#menuintroeditorformat > option[selected]" "css_element"
And I should not see "Markdown format" in the "#menuintroeditorformat > option[selected]" "css_element"