mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'MDL-68248-master' of https://github.com/DinhHien0307/moodle
This commit is contained in:
commit
71dbe42c64
@ -210,7 +210,7 @@ These actions only affect your view.
|
||||
|
||||
You can also choose to display the courses in a list, or with summary information, or the default \'card\' view.';
|
||||
$string['tour3_title_displayoptions'] = 'Display options';
|
||||
$string['tour3_content_displayoptions'] = 'Courses may be sorted by course name or by last access date.
|
||||
$string['tour3_content_displayoptions'] = 'Courses may be sorted by course name, course short name or last access date.
|
||||
|
||||
You can also choose to display the courses in a list, with summary information, or the default \'card\' view.';
|
||||
|
||||
|
@ -164,6 +164,7 @@ class main implements renderable, templatable {
|
||||
* @throws \dml_exception
|
||||
*/
|
||||
public function __construct($grouping, $sort, $view, $paging, $customfieldvalue = null) {
|
||||
global $CFG;
|
||||
// Get plugin config.
|
||||
$config = get_config('block_myoverview');
|
||||
|
||||
@ -185,7 +186,18 @@ class main implements renderable, templatable {
|
||||
$this->customfieldvalue = $customfieldvalue;
|
||||
|
||||
// Check and remember the given sorting.
|
||||
$this->sort = $sort ? $sort : BLOCK_MYOVERVIEW_SORTING_TITLE;
|
||||
if ($sort) {
|
||||
$this->sort = $sort;
|
||||
} else if ($CFG->courselistshortnames) {
|
||||
$this->sort = BLOCK_MYOVERVIEW_SORTING_SHORTNAME;
|
||||
} else {
|
||||
$this->sort = BLOCK_MYOVERVIEW_SORTING_TITLE;
|
||||
}
|
||||
// In case sorting remembered is shortname and display extended course names not checked,
|
||||
// we should revert sorting to title.
|
||||
if (!$CFG->courselistshortnames && $sort == BLOCK_MYOVERVIEW_SORTING_SHORTNAME) {
|
||||
$this->sort = BLOCK_MYOVERVIEW_SORTING_TITLE;
|
||||
}
|
||||
|
||||
// Check and remember the given view.
|
||||
$this->view = $view ? $view : BLOCK_MYOVERVIEW_VIEW_CARD;
|
||||
@ -236,7 +248,6 @@ class main implements renderable, templatable {
|
||||
}
|
||||
unset ($displaygroupingselectors, $displaygroupingselectorscount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the most sensible fallback grouping to use (in cases where the stored selection
|
||||
* is no longer available).
|
||||
@ -393,7 +404,7 @@ class main implements renderable, templatable {
|
||||
*
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
global $USER;
|
||||
global $CFG, $USER;
|
||||
|
||||
$nocoursesurl = $output->image_url('courses', 'block_myoverview')->out();
|
||||
|
||||
@ -422,12 +433,18 @@ class main implements renderable, templatable {
|
||||
}
|
||||
$preferences = $this->get_preferences_as_booleans();
|
||||
$availablelayouts = $this->get_formatted_available_layouts_for_export();
|
||||
$sort = '';
|
||||
if ($this->sort == BLOCK_MYOVERVIEW_SORTING_SHORTNAME) {
|
||||
$sort = 'shortname';
|
||||
} else {
|
||||
$sort = $this->sort == BLOCK_MYOVERVIEW_SORTING_TITLE ? 'fullname' : 'ul.timeaccess desc';
|
||||
}
|
||||
|
||||
$defaultvariables = [
|
||||
'totalcoursecount' => count(enrol_get_all_users_courses($USER->id, true)),
|
||||
'nocoursesimg' => $nocoursesurl,
|
||||
'grouping' => $this->grouping,
|
||||
'sort' => $this->sort == BLOCK_MYOVERVIEW_SORTING_TITLE ? 'fullname' : 'ul.timeaccess desc',
|
||||
'sort' => $sort,
|
||||
// If the user preference display option is not available, default to first available layout.
|
||||
'view' => in_array($this->view, $this->layouts) ? $this->view : reset($this->layouts),
|
||||
'paging' => $this->paging,
|
||||
@ -447,6 +464,7 @@ class main implements renderable, templatable {
|
||||
'customfieldvalue' => $this->customfieldvalue,
|
||||
'customfieldvalues' => $customfieldvalues,
|
||||
'selectedcustomfield' => $selectedcustomfield,
|
||||
'showsortbyshortname' => $CFG->courselistshortnames,
|
||||
];
|
||||
return array_merge($defaultvariables, $preferences);
|
||||
|
||||
|
@ -44,6 +44,7 @@ $string['aria:list'] = 'Switch to list view';
|
||||
$string['aria:title'] = 'Sort courses by course name';
|
||||
$string['aria:past'] = 'Show past courses';
|
||||
$string['aria:removefromfavourites'] = 'Remove star for';
|
||||
$string['aria:shortname'] = 'Sort courses by course short name';
|
||||
$string['aria:summary'] = 'Switch to summary view';
|
||||
$string['aria:sortingdropdown'] = 'Sorting drop-down menu';
|
||||
$string['availablegroupings'] = 'Available filters';
|
||||
@ -73,6 +74,7 @@ $string['privacy:metadata:overviewviewpreference'] = 'The Course overview block
|
||||
$string['privacy:metadata:overviewgroupingpreference'] = 'The Course overview block grouping preference.';
|
||||
$string['privacy:metadata:overviewpagingpreference'] = 'The Course overview block paging preference.';
|
||||
$string['removefromfavourites'] = 'Unstar this course';
|
||||
$string['shortname'] = 'Short name';
|
||||
$string['summary'] = 'Summary';
|
||||
$string['title'] = 'Course name';
|
||||
$string['aria:hidecourse'] = 'Remove {$a} from view';
|
||||
|
@ -47,6 +47,7 @@ define('BLOCK_MYOVERVIEW_CUSTOMFIELD_EMPTY', -1);
|
||||
*/
|
||||
define('BLOCK_MYOVERVIEW_SORTING_TITLE', 'title');
|
||||
define('BLOCK_MYOVERVIEW_SORTING_LASTACCESSED', 'lastaccessed');
|
||||
define('BLOCK_MYOVERVIEW_SORTING_SHORTNAME', 'shortname');
|
||||
|
||||
/**
|
||||
* Constants for the user preferences view options
|
||||
@ -104,7 +105,8 @@ function block_myoverview_user_preferences() {
|
||||
'type' => PARAM_ALPHA,
|
||||
'choices' => array(
|
||||
BLOCK_MYOVERVIEW_SORTING_TITLE,
|
||||
BLOCK_MYOVERVIEW_SORTING_LASTACCESSED
|
||||
BLOCK_MYOVERVIEW_SORTING_LASTACCESSED,
|
||||
BLOCK_MYOVERVIEW_SORTING_SHORTNAME
|
||||
)
|
||||
);
|
||||
$preferences['block_myoverview_user_view_preference'] = array(
|
||||
|
@ -33,6 +33,7 @@
|
||||
<span class="d-sm-inline-block" data-active-item-text>
|
||||
{{#title}}{{#str}} title, block_myoverview {{/str}}{{/title}}
|
||||
{{#lastaccessed}}{{#str}} lastaccessed, block_myoverview {{/str}}{{/lastaccessed}}
|
||||
{{#shortname}}{{#str}} shortname, block_myoverview {{/str}}{{/shortname}}
|
||||
</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" data-show-active-item aria-labelledby="sortingdropdown">
|
||||
@ -41,6 +42,13 @@
|
||||
{{#str}} title, block_myoverview {{/str}}
|
||||
</a>
|
||||
</li>
|
||||
{{#showsortbyshortname}}
|
||||
<li>
|
||||
<a class="dropdown-item {{#shortname}}active{{/shortname}}" href="#" data-filter="sort" data-pref="shortname" data-value="shortname" aria-label="{{#str}} aria:shortname, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
|
||||
{{#str}} shortname, block_myoverview {{/str}}
|
||||
</a>
|
||||
</li>
|
||||
{{/showsortbyshortname}}
|
||||
<li>
|
||||
<a class="dropdown-item {{#lastaccessed}}active{{/lastaccessed}}" href="#" data-filter="sort" data-pref="lastaccessed" data-value="ul.timeaccess desc" aria-label="{{#str}} aria:lastaccessed, block_myoverview {{/str}}" aria-controls="courses-view-{{uniqid}}">
|
||||
{{#str}} lastaccessed, block_myoverview {{/str}}
|
||||
@ -48,4 +56,4 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -182,6 +182,20 @@ Feature: The my overview block allows users to easily access their courses
|
||||
Then I should see "Last accessed" in the "Course overview" "block"
|
||||
And "[data-sort='ul.timeaccess desc']" "css_element" in the "Course overview" "block" should be visible
|
||||
|
||||
Scenario: Short name sort persistence
|
||||
Given I log in as "student1"
|
||||
When I click on "sortingdropdown" "button" in the "Course overview" "block"
|
||||
Then I should not see "Short name" in the "Course overview" "block"
|
||||
When the following config values are set as admin:
|
||||
| config | value |
|
||||
| courselistshortnames | 1 |
|
||||
And I reload the page
|
||||
And I click on "sortingdropdown" "button" in the "Course overview" "block"
|
||||
And I click on "Short name" "link" in the "Course overview" "block"
|
||||
And I reload the page
|
||||
Then I should see "Short name" in the "Course overview" "block"
|
||||
And "[data-sort='shortname']" "css_element" in the "Course overview" "block" should be visible
|
||||
|
||||
Scenario: View inprogress courses with hide persistent functionality
|
||||
Given I log in as "student1"
|
||||
And I click on "All (except removed from view)" "button" in the "Course overview" "block"
|
||||
|
@ -72,6 +72,7 @@ class block_myoverview_privacy_testcase extends \core_privacy\tests\provider_tes
|
||||
return array(
|
||||
array('block_myoverview_user_sort_preference', 'lastaccessed', ''),
|
||||
array('block_myoverview_user_sort_preference', 'title', ''),
|
||||
array('block_myoverview_user_sort_preference', 'shortname', ''),
|
||||
array('block_myoverview_user_grouping_preference', 'allincludinghidden', ''),
|
||||
array('block_myoverview_user_grouping_preference', 'all', ''),
|
||||
array('block_myoverview_user_grouping_preference', 'inprogress', ''),
|
||||
@ -104,4 +105,4 @@ class block_myoverview_privacy_testcase extends \core_privacy\tests\provider_tes
|
||||
$blockpreferences->{$name}->description
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user