mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-73343 block_myoverview: Add link to create course for empty content
This commit is contained in:
parent
0c63990e4f
commit
615027ea75
2
blocks/myoverview/amd/build/view.min.js
vendored
2
blocks/myoverview/amd/build/view.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -456,8 +456,10 @@ const setCourseFavouriteState = (courseId, status) => {
|
||||
*/
|
||||
const noCoursesRender = root => {
|
||||
const nocoursesimg = root.find(SELECTORS.courseView.region).attr('data-nocoursesimg');
|
||||
const newcourseurl = root.find(SELECTORS.courseView.region).attr('data-newcourseurl');
|
||||
return Templates.render(TEMPLATES.NOCOURSES, {
|
||||
nocoursesimg: nocoursesimg
|
||||
nocoursesimg: nocoursesimg,
|
||||
newcourseurl: newcourseurl
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -410,6 +410,12 @@ class main implements renderable, templatable {
|
||||
|
||||
$nocoursesurl = $output->image_url('courses', 'block_myoverview')->out();
|
||||
|
||||
$newcourseurl = '';
|
||||
$coursecat = \core_course_category::user_top();
|
||||
if ($coursecat->can_create_course()) {
|
||||
$newcourseurl = new \moodle_url('/course/edit.php', ['category' => $coursecat->id]);
|
||||
}
|
||||
|
||||
$customfieldvalues = $this->get_customfield_values_for_export();
|
||||
$selectedcustomfield = '';
|
||||
if ($this->grouping == BLOCK_MYOVERVIEW_GROUPING_CUSTOMFIELD) {
|
||||
@ -445,6 +451,7 @@ class main implements renderable, templatable {
|
||||
$defaultvariables = [
|
||||
'totalcoursecount' => count(enrol_get_all_users_courses($USER->id, true)),
|
||||
'nocoursesimg' => $nocoursesurl,
|
||||
'newcourseurl' => $newcourseurl,
|
||||
'grouping' => $this->grouping,
|
||||
'sort' => $sort,
|
||||
// If the user preference display option is not available, default to first available layout.
|
||||
|
@ -22,6 +22,7 @@
|
||||
Example context (json):
|
||||
{
|
||||
"nocoursesimg": "https://moodlesite/theme/image.php/boost/block_myoverview/1535727318/courses",
|
||||
"newcourseurl": "https://moodlesite/course/edit.php",
|
||||
"grouping": "all",
|
||||
"sort": "fullname",
|
||||
"view": "card"
|
||||
@ -38,7 +39,8 @@
|
||||
data-paging="{{paging}}"
|
||||
data-nocoursesimg="{{nocoursesimg}}"
|
||||
data-totalcoursecount="{{totalcoursecount}}"
|
||||
data-displaycategories="{{displaycategories}}">
|
||||
data-displaycategories="{{displaycategories}}"
|
||||
data-newcourseurl="{{newcourseurl}}">
|
||||
<div data-region="course-view-content">
|
||||
{{> block_myoverview/placeholders }}
|
||||
</div>
|
||||
|
@ -0,0 +1,28 @@
|
||||
@block @block_myoverview @javascript
|
||||
Feature: If there is no course yet, users with capabilities have a link to create new course
|
||||
In order to create a course quickly
|
||||
As a course creator
|
||||
I can follow a link to create new course from my overview block
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email | idnumber |
|
||||
| creator1 | Course creator | X | creator1@example.com | CC1 |
|
||||
| teacher1 | Teacher | X | teacher1@example.com | T1 |
|
||||
And the following "system role assigns" exist:
|
||||
| user | course | role |
|
||||
| creator1 | Acceptance test site | coursecreator |
|
||||
| teacher1 | Acceptance test site | editingteacher |
|
||||
|
||||
Scenario: Course creators can see a link to new course form from my overview block
|
||||
Given I am on the "My courses" page logged in as "creator1"
|
||||
And I should see "No courses"
|
||||
And I should see "Create new course" in the "region-main" "region"
|
||||
And I should not see "Add a new course"
|
||||
When I click on "Create new course" "link" in the "region-main" "region"
|
||||
Then I should see "Add a new course"
|
||||
|
||||
Scenario: Teachers don't see any link to create new course at my overview block
|
||||
Given I am on the "My courses" page logged in as "teacher1"
|
||||
When I should see "No courses"
|
||||
Then I should not see "Create new course"
|
@ -21,7 +21,8 @@
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"nocoursesimgurl": "https://moodlesite/theme/image.php/boost/block_recentlyaccessedcourses/1535727318/courses"
|
||||
"nocoursesimgurl": "https://moodlesite/theme/image.php/boost/block_recentlyaccessedcourses/1535727318/courses",
|
||||
"newcourseurl": "https://moodlesite/course/edit.php"
|
||||
}
|
||||
}}
|
||||
<div class="text-xs-center text-center mt-3" data-region="empty-message">
|
||||
@ -30,4 +31,7 @@
|
||||
alt="{{$nocoursestring}}{{#str}} nocourses, core {{/str}}{{/nocoursestring}}"
|
||||
role="presentation">
|
||||
<p class="text-muted mt-3">{{$nocoursestring}}{{#str}} nocourses, core {{/str}}{{/nocoursestring}}</p>
|
||||
{{#newcourseurl}}
|
||||
<a href="{{{newcourseurl}}}" class="nocourseslink">{{#str}} createnewcourse, core {{/str}}</a>
|
||||
{{/newcourseurl}}
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user