Merge branch 'MDL-72287-master' of https://github.com/mihailges/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2021-12-09 23:14:32 +01:00
commit 71746122a5
17 changed files with 125 additions and 37 deletions

View File

@ -60,14 +60,16 @@ Feature: Award badges
And I press "Save"
And I press "Enable access"
And I press "Continue"
And I follow "Manage badges"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
And I follow "Recipients (0)"
And I press "Award badge"
# Award course badge 1 to student 1.
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I follow "Manage badges"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
And I follow "Recipients (1)"
Then I should see "Recipients (1)"
@ -185,7 +187,8 @@ Feature: Award badges
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I follow "Manage badges"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
Then I should see "Recipients (2)"
And I log out
@ -286,7 +289,8 @@ Feature: Award badges
# Award course badge 1 to student 1.
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I follow "Manage badges"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 1"
And I follow "Recipients (1)"
Then I should see "Recipients (1)"
@ -311,7 +315,8 @@ Feature: Award badges
# Award course badge 2 to student 2.
And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
When I press "Award badge"
And I follow "Manage badges"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge 2"
And I follow "Recipients (1)"
Then I should see "Recipients (1)"
@ -352,7 +357,8 @@ Feature: Award badges
And I press "Award badge"
And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
When I press "Award badge"
And I follow "Manage badges"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
Then I should see "Recipients (2)"
And I follow "Recipients (2)"
@ -361,6 +367,7 @@ Feature: Award badges
And I press "Revoke badge"
And I set the field "existingrecipients[]" to "Student 1 (student1@example.com)"
When I press "Revoke badge"
And I follow "Manage badges"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
Then I should see "Recipients (0)"

View File

@ -69,7 +69,8 @@ Feature: Award badges with separate groups
# Non-editing teacher can award the badge
And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
And I press "Award badge"
And I follow "Manage badges"
And I am on "Course 1" course homepage
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I should see "Recipients (1)"
And I log out

View File

@ -71,7 +71,7 @@ if (isset($userid) && empty($courseid) && empty($modid)) {
}
$PAGE->set_context($context);
if (isset($userid) && $USER->id == $userid) {
if (isset($userid) && $USER->id == $userid && !$PAGE->has_secondary_navigation()) {
$blognode = $PAGE->navigation->find('siteblog', null);
if ($blognode) {
$blognode->make_inactive();
@ -153,6 +153,9 @@ if ($usernode && $courseid != SITEID) {
if ($courseid != SITEID) {
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
if (!empty($user)) {
$headerinfo = array('heading' => fullname($user), 'user' => $user);
echo $OUTPUT->context_header($headerinfo, 2);

View File

@ -28,7 +28,7 @@ Feature: Course activity controls works as expected
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow the breadcrumb <targetpage>
When I click on <targetpage> "link" in the "region-main" "region"
And I add the "Recent activity" block
And I open the action menu in "Recent activity" "block"
And I click on "Delete Recent activity block" "link"
@ -76,12 +76,12 @@ Feature: Course activity controls works as expected
Examples:
| courseformat | coursedisplay | targetpage | should_see_other_sections | should_see_other_sections_following_block_sections_links | belowpage |
| topics | 0 | "C1" | should | should | "Topic 2" |
| topics | 0 | "General" | should | should | "Topic 2" |
| topics | 1 | "Topic 1" | should not | should not | "Topic 2" |
| topics | 1 | "C1" | should | should not | "Topic 2" |
| weeks | 0 | "C1" | should | should | "8 January - 14 January" |
| topics | 1 | "General" | should | should not | "Topic 2" |
| weeks | 0 | "General" | should | should | "8 January - 14 January" |
| weeks | 1 | "1 January - 7 January" | should not | should not | "8 January - 14 January" |
| weeks | 1 | "C1" | should | should not | "8 January - 14 January" |
| weeks | 1 | "General" | should | should not | "8 January - 14 January" |
Scenario Outline: General activities course controls using topics and weeks formats, and paged mode and not paged mode works as expected
Given the following "users" exist:
@ -99,7 +99,7 @@ Feature: Course activity controls works as expected
| forum | Test forum name 2 | Test forum description 2 | C1 | 0002 | 1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
When I follow the breadcrumb <targetpage>
When I click on <targetpage> "link" in the "region-main" "region"
And I add the "Recent activity" block
And I open the action menu in "Recent activity" "block"
And I click on "Delete Recent activity block" "link"
@ -135,9 +135,9 @@ Feature: Course activity controls works as expected
Examples:
| courseformat | coursedisplay | targetpage | should_see_other_sections | should_see_other_sections_following_block_sections_links | belowpage |
| topics | 0 | "C1" | should | should | "Topic 2" |
| topics | 0 | "General" | should | should | "Topic 2" |
| topics | 1 | "Topic 1" | should not | should not | "Topic 2" |
| topics | 1 | "C1" | should | should not | "Topic 2" |
| weeks | 0 | "C1" | should | should | "8 January - 14 January" |
| topics | 1 | "General" | should | should not | "Topic 2" |
| weeks | 0 | "General" | should | should | "8 January - 14 January" |
| weeks | 1 | "1 January - 7 January" | should not | should not | "8 January - 14 January" |
| weeks | 1 | "C1" | should | should not | "8 January - 14 January" |
| weeks | 1 | "General" | should | should not | "8 January - 14 January" |

View File

@ -15,6 +15,8 @@ Feature: Edit course settings
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following config values are set as admin:
| courselistshortnames | 1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage
When I navigate to "Settings" in current page administration
@ -23,10 +25,12 @@ Feature: Edit course settings
| Course short name | Edited course shortname |
| Course summary | Edited course summary |
And I press "Save and display"
And I am on site homepage
Then I should not see "Course 1"
And I should not see "C1"
And I should see "Edited course fullname"
And I should see "Edited course shortname"
And I am on "Edited course fullname" course homepage
And I navigate to "Settings" in current page administration
And the field "Course full name" matches value "Edited course fullname"
And the field "Course short name" matches value "Edited course shortname"

View File

@ -55,7 +55,14 @@ if ($mode === 'coursecompletions' or $mode === 'coursecompletion') {
$coursecontext = context_course::instance($course->id);
$personalcontext = context_user::instance($user->id);
$PAGE->set_context($personalcontext);
if ($id == SITEID) {
$PAGE->set_context($personalcontext);
$PAGE->set_heading(fullname($user));
} else {
$PAGE->set_context($coursecontext);
$PAGE->set_secondary_active_tab('participants');
$PAGE->set_heading($course->fullname);
}
$PAGE->set_url('/course/user.php', array('id'=>$id, 'user'=>$user->id, 'mode'=>$mode));
@ -125,7 +132,6 @@ $stractivityreport = get_string("activityreport");
$PAGE->navigation->extend_for_user($user);
$PAGE->navigation->set_userid_for_parent_checks($user->id); // see MDL-25805 for reasons and for full commit reference for reversal when fixed.
$PAGE->set_title("$course->shortname: $stractivityreport ($mode)");
$PAGE->set_heading(fullname($user));
switch ($mode) {
case "grade":
@ -166,6 +172,19 @@ switch ($mode) {
}
echo $OUTPUT->header();
if ($course->id !== SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $user->id, 'course' => $course->id]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
$userheading = array(
'heading' => fullname($user, has_capability('moodle/site:viewfullnames', $PAGE->context)),
'user' => $user,
'usercontext' => $personalcontext,
);
echo $OUTPUT->context_header($userheading, 2);
echo $OUTPUT->heading(get_string('grades', 'moodle'), 2, 'main mt-4 mb-4');
}
if (empty($CFG->grade_profilereport) or !file_exists($CFG->dirroot.'/grade/report/'.$CFG->grade_profilereport.'/lib.php')) {
$CFG->grade_profilereport = 'user';
}
@ -179,7 +198,6 @@ switch ($mode) {
}
break;
break;
default:
// It's unlikely to reach this piece of code, as the mode is never empty and it sets mode as grade in most of the cases.
// Display the page header to avoid breaking the navigation. A course/user.php review will be done in MDL-49939.

View File

@ -204,6 +204,7 @@ $string['discussionsstartedby'] = 'Discussions started by {$a}';
$string['discussionstartedby'] = 'Discussion started by {$a}';
$string['discussionsstartedbyrecent'] = 'Discussions recently started by {$a}';
$string['discussionsstartedbyuserincourse'] = 'Discussions started by {$a->fullname} in {$a->coursename}';
$string['discussionsstartedincourse'] = 'Discussions started in {$a}';
$string['discussionunpin'] = 'Unpin';
$string['discussionunsubscribed'] = 'You are now unsubscribed from this discussion.';
$string['discussthistopic'] = 'Discuss this topic';
@ -525,6 +526,7 @@ $string['posts'] = 'Posts';
$string['postsfrom'] = 'Posts from';
$string['postsmadebyuser'] = 'Posts made by {$a}';
$string['postsmadebyuserincourse'] = 'Posts made by {$a->fullname} in {$a->coursename}';
$string['postsmadeincourse'] = 'Posts made in {$a}';
$string['poststo'] = 'Posts to';
$string['posttoforum'] = 'Post to forum';
$string['postupdated'] = 'Your post was updated';

View File

@ -40,7 +40,7 @@ Feature: The forum search allows users to perform advanced searches for forum po
Scenario: Perform an advanced search using any term
Given I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search"
And I should see "Advanced search"
And I should see "Please enter search terms into one or more of the following fields"
And I set the field "words" to "subject"
When I press "Search"
Then I should see "My subject"
@ -49,7 +49,7 @@ Feature: The forum search allows users to perform advanced searches for forum po
Scenario: Perform an advanced search avoiding words
Given I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search"
And I should see "Advanced search"
And I should see "Please enter search terms into one or more of the following fields"
And I set the field "words" to "My"
And I set the field "notwords" to "subjective"
When I press "Search"
@ -62,7 +62,7 @@ Feature: The forum search allows users to perform advanced searches for forum po
| postgres |
And I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search"
And I should see "Advanced search"
And I should see "Please enter search terms into one or more of the following fields"
And I set the field "fullwords" to "subject"
When I press "Search"
Then I should see "My subject"
@ -71,7 +71,7 @@ Feature: The forum search allows users to perform advanced searches for forum po
Scenario: Perform an advanced search matching the subject
Given I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search"
And I should see "Advanced search"
And I should see "Please enter search terms into one or more of the following fields"
And I set the field "subject" to "subjective"
When I press "Search"
Then I should not see "My message"
@ -86,7 +86,7 @@ Feature: The forum search allows users to perform advanced searches for forum po
And I log out
When I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search"
And I should see "Advanced search"
And I should see "Please enter search terms into one or more of the following fields"
And I set the field "user" to "TWO"
And I press "Search"
Then I should see "Teacher TWO"
@ -95,7 +95,7 @@ Feature: The forum search allows users to perform advanced searches for forum po
Scenario: Perform an advanced search with multiple words
Given I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search"
And I should see "Advanced search"
And I should see "Please enter search terms into one or more of the following fields"
And I set the field "subject" to "your subjective"
When I press "Search"
Then I should not see "My message"
@ -112,7 +112,7 @@ Feature: The forum search allows users to perform advanced searches for forum po
And I log out
And I am on the "Announcements" "forum activity" page logged in as student1
And I press "Search"
And I should see "Advanced search"
And I should see "Please enter search terms into one or more of the following fields"
And I set the field "Is tagged with" to "SearchedTag"
When I press "Search"
Then I should see "My subject"
@ -124,7 +124,7 @@ Feature: The forum search allows users to perform advanced searches for forum po
And I click on "Your subjective" action menu
And I follow "Star this discussion"
And I press "Search"
And I should see "Advanced search"
And I should see "Please enter search terms into one or more of the following fields"
And I set the field "starredonly" to "1"
When I press "Search"
Then I should not see "My message"
@ -136,7 +136,7 @@ Feature: The forum search allows users to perform advanced searches for forum po
And I click on "Your subjective" action menu
And I follow "Star this discussion"
And I press "Search"
And I should see "Advanced search"
And I should see "Please enter search terms into one or more of the following fields"
And I set the field "words" to "message"
And I set the field "starredonly" to "1"
When I press "Search"

View File

@ -217,6 +217,7 @@ if (empty($result->posts)) {
// Display a page letting the user know that there's nothing to display;
$PAGE->set_title($pagetitle);
if ($isspecificcourse) {
$PAGE->set_secondary_active_tab('participants');
$PAGE->set_heading($pageheading);
} else if ($canviewuser) {
$PAGE->set_heading(fullname($user));
@ -224,6 +225,10 @@ if (empty($result->posts)) {
$PAGE->set_heading($SITE->fullname);
}
echo $OUTPUT->header();
if (isset($courseid) && $courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
}
if (!$isspecificcourse) {
echo $OUTPUT->heading($pagetitle);
} else {
@ -309,9 +314,15 @@ if (isset($courseid) && $courseid != SITEID) {
$navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid, 'mode' => 'discussions')));
}
$PAGE->set_secondary_active_tab('participants');
}
echo $OUTPUT->header();
if (isset($courseid) && $courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
}
echo html_writer::start_tag('div', array('class' => 'user-content'));
if ($isspecificcourse) {
@ -321,6 +332,10 @@ if ($isspecificcourse) {
'usercontext' => $usercontext
);
echo $OUTPUT->context_header($userheading, 2);
$coursename = format_string($course->fullname, true, array('context' => $coursecontext));
$heading = $mode === 'posts' ? get_string('postsmadeincourse', 'mod_forum', $coursename) :
get_string('discussionsstartedincourse', 'mod_forum', $coursename);
echo $OUTPUT->heading($heading, 2, 'main mt-4 mb-4');
} else {
echo $OUTPUT->heading($inpageheading);
}

View File

@ -25,7 +25,9 @@ Feature: Content bank link in the activity settings form
And I add a "H5P" to section "1"
Then I should see "Use the content bank (opens in new window) to manage your H5P files"
And I click on "content bank (opens in new window)" "link" in the "General" "fieldset"
And I should see "C1" in the "page-navbar" "region"
And I switch to the browser tab opened by the app
And I should see "Content bank" in the "page-header" "region"
And I should see "filltheblanks.h5p" in the "page-content" "region"
And I close all opened windows
@javascript

View File

@ -127,6 +127,9 @@ if ($course->id == SITEID) {
echo $OUTPUT->header();
if ($course->id != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
$headerinfo = array('heading' => fullname($user), 'user' => $user);
echo $OUTPUT->context_header($headerinfo, 2);
}

View File

@ -44,7 +44,7 @@ Feature: User can view activity log.
And I follow "Ann, Jill, Grainne, Beauchamp"
When I follow "Today's logs"
And I should see "Assignment: Test assignment name"
And I follow "Ann, Jill, Grainne, Beauchamp"
And I click on "Back" "button"
And I follow "All logs"
Then I should see "Assignment: Test assignment name"

View File

@ -104,12 +104,20 @@ $event->trigger();
echo $OUTPUT->header();
if ($courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
$userheading = array(
'heading' => fullname($user, has_capability('moodle/site:viewfullnames', $PAGE->context)),
'user' => $user,
'usercontext' => $personalcontext,
);
echo $OUTPUT->context_header($userheading, 2);
if ($mode === 'today') {
echo $OUTPUT->heading(get_string('todaylogs', 'moodle'), 2, 'main mt-4 mb-4');
} else {
echo $OUTPUT->heading(get_string('alllogs', 'moodle'), 2, 'main mt-4 mb-4');
}
}
// Time to filter records from.

View File

@ -91,12 +91,19 @@ $event->trigger();
echo $OUTPUT->header();
if ($courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
echo $OUTPUT->context_header(
array(
'heading' => fullname($user),
'user' => $user,
'usercontext' => $personalcontext
), 2);
if ($mode === 'outline') {
echo $OUTPUT->heading(get_string('outlinereport', 'moodle'), 2, 'main mt-4 mb-4');
} else {
echo $OUTPUT->heading(get_string('completereport', 'moodle'), 2, 'main mt-4 mb-4');
}
}
$modinfo = get_fast_modinfo($course, $user->id);

View File

@ -73,12 +73,16 @@ $PAGE->set_title("$course->shortname: $stractivityreport");
$PAGE->set_heading($pageheading);
echo $OUTPUT->header();
if ($courseid != SITEID) {
$backurl = new moodle_url('/user/view.php', ['id' => $userid, 'course' => $courseid]);
echo $OUTPUT->single_button($backurl, get_string('back'), 'get', ['class' => 'mb-3']);
echo $OUTPUT->context_header(
array(
'heading' => $userfullname,
'user' => $user,
'usercontext' => $personalcontext
), 2);
echo $OUTPUT->heading(get_string('statistics', 'moodle'), 2, 'main mt-4 mb-4');
}
// Trigger a user report viewed event.

View File

@ -27,14 +27,17 @@ class boostnavbar implements \renderable {
/** @var array The individual items of the navbar. */
protected $items = [];
/** @var moodle_page The current moodle page. */
protected $page;
/**
* Takes a navbar object and picks the necessary parts for display.
*
* @param \navbar $navbar The navigation bar.
* @param \moodle_page $page The current moodle page.
*/
public function __construct(\navbar $navbar) {
foreach ($navbar->get_items() as $item) {
public function __construct(\moodle_page $page) {
$this->page = $page;
foreach ($this->page->navbar->get_items() as $item) {
$this->items[] = $item;
}
$this->prepare_nodes_for_boost();
@ -46,9 +49,20 @@ class boostnavbar implements \renderable {
protected function prepare_nodes_for_boost(): void {
global $PAGE;
// Don't show the navigation if we are in the course context.
if ($this->page->context->contextlevel == CONTEXT_COURSE) {
$this->clear_items();
return;
}
$this->remove('myhome'); // Dashboard.
$this->remove('home');
// Remove 'My courses' if we are in the module context.
if ($this->page->context->contextlevel == CONTEXT_MODULE) {
$this->remove('mycourses');
}
if (!is_null($this->get_item('root'))) { // We are in site administration.
// Remove the 'Site administration' navbar node as it already exists in the primary navigation menu.
$this->remove('root');

View File

@ -53,7 +53,7 @@ class core_renderer extends \core_renderer {
* @return string the HTML for the navbar.
*/
public function navbar(): string {
$newnav = new \theme_boost\boostnavbar($this->page->navbar);
$newnav = new \theme_boost\boostnavbar($this->page);
return $this->render_from_template('core/navbar', $newnav);
}