diff --git a/notes/index.php b/notes/index.php index 585028f4473..03170a07ce8 100644 --- a/notes/index.php +++ b/notes/index.php @@ -176,9 +176,11 @@ if ($courseid != SITEID) { $USER->id ); -} else { // Normal course. - $view = has_capability('moodle/notes:view', context_system::instance()); - note_print_notes('' . $strsitenotes, 0, $view, 0, $userid, NOTES_STATE_SITE, 0); +} else { + // Site course. + $addid = has_capability('moodle/notes:manage', $systemcontext) ? SITEID : 0; + $view = has_capability('moodle/notes:view', $systemcontext); + note_print_notes('' . $strsitenotes, $addid, $view, 0, $userid, NOTES_STATE_SITE, 0); echo ''; if (!empty($userid)) { diff --git a/notes/tests/behat/site_notes.feature b/notes/tests/behat/site_notes.feature new file mode 100644 index 00000000000..2463c1e18f4 --- /dev/null +++ b/notes/tests/behat/site_notes.feature @@ -0,0 +1,16 @@ +@core @core_notes +Feature: Add notes to site users + In order to share information with other users + As an admin + I need to add notes to site user accounts + + Scenario: Add a user site note + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | 1 | student1@example.com | + When I am on the "student1" "user > profile" page logged in as "admin" + And I follow "Notes" + And I follow "Add a new note" + And I set the field "Content" to "Student 1 needs to pick up his game" + And I press "Save changes" + Then I should see "Student 1 needs to pick up his game" in the ".notelist" "css_element"