Skip to content

Commit

Permalink
Merge branch 'MDL-76257-400' of https://github.com/juancs/moodle into…
Browse files Browse the repository at this point in the history
… MOODLE_400_STABLE
  • Loading branch information
junpataleta committed Mar 17, 2023
2 parents 6b7b12c + 45d7645 commit c0373ed
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion course/modlib.php
Expand Up @@ -853,7 +853,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)
Expand Down
40 changes: 40 additions & 0 deletions course/tests/behat/add_activities.feature
Expand Up @@ -53,3 +53,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"

0 comments on commit c0373ed

Please sign in to comment.