Merge branch 'MDL-77135-master' of https://github.com/aanabit/moodle
This commit is contained in:
@@ -504,7 +504,11 @@ class main implements renderable, templatable {
|
||||
'post',
|
||||
\single_button::BUTTON_PRIMARY
|
||||
);
|
||||
return $this->generate_zero_state_data($nocoursesimg, [$button], 'request');
|
||||
return $this->generate_zero_state_data(
|
||||
$nocoursesimg,
|
||||
[$button],
|
||||
['title' => 'zero_request_title', 'intro' => 'zero_request_intro']
|
||||
);
|
||||
}
|
||||
|
||||
$totalcourses = $DB->count_records_select('course', 'category > 0');
|
||||
@@ -526,7 +530,11 @@ class main implements renderable, templatable {
|
||||
\single_button::BUTTON_PRIMARY
|
||||
);
|
||||
$buttons[] = $createbutton->export_for_template($output);
|
||||
return $this->generate_zero_state_data($nocoursesimg, $buttons, 'nocourses');
|
||||
return $this->generate_zero_state_data(
|
||||
$nocoursesimg,
|
||||
$buttons,
|
||||
['title' => 'zero_nocourses_title', 'intro' => 'zero_nocourses_intro']
|
||||
);
|
||||
}
|
||||
|
||||
if ($categorytocreate = \core_course_category::get_nearest_editable_subcategory($coursecat, ['create'])) {
|
||||
@@ -544,13 +552,25 @@ class main implements renderable, templatable {
|
||||
get_string('managecourses')
|
||||
);
|
||||
$buttons[] = $managebutton->export_for_template($output);
|
||||
return $this->generate_zero_state_data($nocoursesimg, array_reverse($buttons), 'createcourses');
|
||||
return $this->generate_zero_state_data(
|
||||
$nocoursesimg,
|
||||
array_reverse($buttons),
|
||||
['title' => 'zero_default_title', 'intro' => 'zero_createcourses_intro']
|
||||
);
|
||||
}
|
||||
return $this->generate_zero_state_data($nocoursesimg, $buttons, 'nomanagecourses');
|
||||
return $this->generate_zero_state_data(
|
||||
$nocoursesimg,
|
||||
$buttons,
|
||||
['title' => 'zero_default_title', 'intro' => 'zero_nomanagecourses_intro']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->generate_zero_state_data($nocoursesimg, [], 'nopermission');
|
||||
return $this->generate_zero_state_data(
|
||||
$nocoursesimg,
|
||||
[],
|
||||
['title' => 'zero_default_title', 'intro' => 'zero_nopermission_intro']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -558,10 +578,10 @@ class main implements renderable, templatable {
|
||||
*
|
||||
* @param \moodle_url $imageurl The URL to the image to show
|
||||
* @param \single_button[] $buttons
|
||||
* @param string $scenario the scenario name (used to get title and intro strings)
|
||||
* @param array $strings Title and intro strings for the zero state if needed.
|
||||
* @return array Context variables for the template
|
||||
*/
|
||||
private function generate_zero_state_data(\moodle_url $imageurl, array $buttons, string $scenario) {
|
||||
private function generate_zero_state_data(\moodle_url $imageurl, array $buttons, array $strings) {
|
||||
global $CFG;
|
||||
// Documentation data.
|
||||
$dochref = new \moodle_url($CFG->docroot, ['lang' => current_language()]);
|
||||
@@ -576,8 +596,8 @@ class main implements renderable, templatable {
|
||||
];
|
||||
return [
|
||||
'nocoursesimg' => $imageurl->out(),
|
||||
'title' => get_string("zero_{$scenario}_title", 'block_myoverview'),
|
||||
'intro' => get_string("zero_{$scenario}_intro", 'block_myoverview', $docparams),
|
||||
'title' => ($strings['title']) ? get_string($strings['title'], 'block_myoverview') : '',
|
||||
'intro' => ($strings['intro']) ? get_string($strings['intro'], 'block_myoverview', $docparams) : '',
|
||||
'buttons' => $buttons,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -88,15 +88,13 @@ $string['sortbylastaccessed'] = 'Sort by last accessed';
|
||||
$string['sortbyshortname'] = 'Sort by short name';
|
||||
$string['privacy:request:preference:set'] = 'The value of the setting \'{$a->name}\' was \'{$a->value}\'';
|
||||
$string['viewquickstart'] = 'View Quickstart guide';
|
||||
$string['zero_nopermission_title'] = 'You\'re not enroled in any course';
|
||||
$string['zero_default_title'] = 'You\'re not enrolled in any course';
|
||||
$string['zero_nopermission_intro'] = 'Once you enrol in a course, it will appear here.';
|
||||
$string['zero_request_title'] = 'Request your first course';
|
||||
$string['zero_request_intro'] = 'Need help getting started? Check out the <a href="{$a->dochref}" title="{$a->doctitle}" target="{$a->doctarget}">Moodle documentation</a> or take your first steps with our <a href="{$a->quickhref}" title="{$a->quicktitle}" target="{$a->quicktarget}">Quickstart guide</a>.';
|
||||
$string['zero_nocourses_title'] = 'Create your first course';
|
||||
$string['zero_nocourses_intro'] = 'Need help getting started? Check out the <a href="{$a->dochref}" title="{$a->doctitle}" target="{$a->doctarget}">Moodle documentation</a> or take your first steps with our Quickstart guide.';
|
||||
$string['zero_createcourses_title'] = 'You\'re not enroled in any course';
|
||||
$string['zero_createcourses_intro'] = 'Once you enrol in a course, it will appear here. To view all courses on this site, go to Manage courses.';
|
||||
$string['zero_nomanagecourses_title'] = 'You\'re not enroled in any course';
|
||||
$string['zero_nomanagecourses_intro'] = 'Once you enrol in a course, it will appear here.';
|
||||
|
||||
// Deprecated since Moodle 4.0.
|
||||
|
||||
@@ -35,7 +35,7 @@ Feature: My overview block pagination
|
||||
|
||||
Scenario: The pagination controls should be hidden if I am not enrolled in any courses
|
||||
When I am on the "My courses" page logged in as "student1"
|
||||
Then I should see "You're not enroled in any course" in the "Course overview" "block"
|
||||
Then I should see "You're not enrolled in any course" in the "Course overview" "block"
|
||||
And I should not see "Show" in the "Course overview" "block"
|
||||
And ".block_myoverview .dropdown-menu.show" "css_element" should not be visible
|
||||
And ".block_myoverview [data-control='next']" "css_element" should not be visible
|
||||
|
||||
@@ -40,7 +40,7 @@ Feature: My overview block searching
|
||||
|
||||
Scenario: There is no search if I am not enrolled in any course
|
||||
When I am on the "My courses" page logged in as "student2"
|
||||
Then I should see "You're not enroled in any course" in the "Course overview" "block"
|
||||
Then I should see "You're not enrolled in any course" in the "Course overview" "block"
|
||||
And "Search courses" "field" should not exist in the "Course overview" "block"
|
||||
And I log out
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Feature: Zero state on my overview block
|
||||
|
||||
Scenario: Users with no permissions don't see any CTA
|
||||
Given I am on the "My courses" page logged in as "user"
|
||||
When I should see "You're not enroled in any course"
|
||||
When I should see "You're not enrolled in any course"
|
||||
Then I should see "Once you enrol in a course, it will appear here"
|
||||
And I should not see "Create course"
|
||||
And I should not see "Request a course"
|
||||
@@ -46,7 +46,7 @@ Feature: Zero state on my overview block
|
||||
| fullname | Course 1 |
|
||||
| shortname | C1 |
|
||||
When I am on the "My courses" page logged in as "manager"
|
||||
Then I should see "You're not enroled in any course"
|
||||
Then I should see "You're not enrolled in any course"
|
||||
Then I should see "To view all courses on this site, go to Manage courses."
|
||||
And "Manage courses" "button" should exist
|
||||
And "Create course" "button" should exist
|
||||
@@ -64,7 +64,7 @@ Feature: Zero state on my overview block
|
||||
| fullname | Course 1 |
|
||||
| shortname | C1 |
|
||||
When I am on the "My courses" page logged in as "manager"
|
||||
Then I should see "You're not enroled in any course"
|
||||
Then I should see "You're not enrolled in any course"
|
||||
Then I should not see "To view all courses on this sie, go to Manage courses"
|
||||
And "Manage courses" "button" should not exist
|
||||
And "Create course" "button" should exist
|
||||
|
||||
Reference in New Issue
Block a user