mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Merge branch 'wip-mdl-42261' of git://github.com/rajeshtaneja/moodle
This commit is contained in:
commit
e36f72414d
@ -30,6 +30,11 @@ require_once($CFG->dirroot.'/blocks/course_overview/locallib.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class block_course_overview extends block_base {
|
||||
/**
|
||||
* If this is passed as mynumber then showallcourses, irrespective of limit by user.
|
||||
*/
|
||||
const SHOW_ALL_COURSES = -2;
|
||||
|
||||
/**
|
||||
* Block initialization
|
||||
*/
|
||||
@ -64,7 +69,9 @@ class block_course_overview extends block_base {
|
||||
}
|
||||
|
||||
profile_load_custom_fields($USER);
|
||||
list($sortedcourses, $sitecourses, $totalcourses) = block_course_overview_get_sorted_courses();
|
||||
|
||||
$showallcourses = ($updatemynumber === self::SHOW_ALL_COURSES);
|
||||
list($sortedcourses, $sitecourses, $totalcourses) = block_course_overview_get_sorted_courses($showallcourses);
|
||||
$overviews = block_course_overview_get_overviews($sitecourses);
|
||||
|
||||
$renderer = $this->page->get_renderer('block_course_overview');
|
||||
|
@ -23,19 +23,21 @@
|
||||
*/
|
||||
|
||||
$string['activityoverview'] = 'You have {$a}s that need attention';
|
||||
$string['alwaysshowall'] = 'Always Show All';
|
||||
$string['collapseall'] = 'Collapse All Course Lists';
|
||||
$string['configotherexpanded'] = 'If enabled, Other Courses will be expanded by default unless overriden by user preferences.';
|
||||
$string['alwaysshowall'] = 'Always show all';
|
||||
$string['collapseall'] = 'Collapse all course lists';
|
||||
$string['configotherexpanded'] = 'If enabled, other courses will be expanded by default unless overriden by user preferences.';
|
||||
$string['configpreservestates'] = 'If enabled, the collapsed/expanded states set by the user are stored and used on each load.';
|
||||
$string['course_overview:addinstance'] = 'Add a new course overview block';
|
||||
$string['course_overview:myaddinstance'] = 'Add a new course overview block to My home';
|
||||
$string['defaultmaxcourses'] = 'Default maximum courses';
|
||||
$string['defaultmaxcoursesdesc'] = 'Maximum courses which should be displayed on course overview block, 0 will show all courses';
|
||||
$string['expandall'] = 'Expand All Course Lists';
|
||||
$string['expandall'] = 'Expand all course lists';
|
||||
$string['forcedefaultmaxcourses'] = 'Force maximum courses';
|
||||
$string['forcedefaultmaxcoursesdesc'] = 'If set then user will not be able to change his/her personal setting';
|
||||
$string['hiddencoursecount'] = 'You have {$a} hidden course';
|
||||
$string['hiddencoursecountplural'] = 'You have {$a} hidden courses';
|
||||
$string['hiddencoursecountwithshowall'] = 'You have {$a->coursecount} hidden course ({$a->showalllink})';
|
||||
$string['hiddencoursecountwithshowallplural'] = 'You have {$a->coursecount} hidden courses ({$a->showalllink})';
|
||||
$string['message'] = 'message';
|
||||
$string['messages'] = 'messages';
|
||||
$string['movecourse'] = 'Move course: {$a}';
|
||||
@ -44,13 +46,13 @@ $string['movetofirst'] = 'Move {$a} course to top';
|
||||
$string['moveafterhere'] = 'Move {$a->movingcoursename} course after {$a->currentcoursename}';
|
||||
$string['movingcourse'] = 'You are moving: {$a->fullname} ({$a->cancellink})';
|
||||
$string['numtodisplay'] = 'Number of courses to display: ';
|
||||
$string['otherexpanded'] = 'Other Courses Expanded';
|
||||
$string['otherexpanded'] = 'Other courses expanded';
|
||||
$string['pluginname'] = 'Course overview';
|
||||
$string['preservestates'] = 'Preserve Expanded States';
|
||||
$string['preservestates'] = 'Preserve expanded states';
|
||||
$string['shortnameprefix'] = 'Includes {$a}';
|
||||
$string['shortnamesufixsingular'] = ' (and {$a} other)';
|
||||
$string['shortnamesufixprural'] = ' (and {$a} others)';
|
||||
$string['showchildren'] = 'Show Children';
|
||||
$string['showchildren'] = 'Show children';
|
||||
$string['showchildrendesc'] = 'Should child courses be listed underneath the main course title?';
|
||||
$string['showwelcomearea'] = 'Show welcome area';
|
||||
$string['showwelcomeareadesc'] = 'Show the welcome area above the course list?';
|
||||
|
@ -110,16 +110,21 @@ function block_course_overview_get_child_shortnames($courseid) {
|
||||
/**
|
||||
* Returns maximum number of courses which will be displayed in course_overview block
|
||||
*
|
||||
* @param bool $showallcourses if set true all courses will be visible.
|
||||
* @return int maximum number of courses
|
||||
*/
|
||||
function block_course_overview_get_max_user_courses() {
|
||||
function block_course_overview_get_max_user_courses($showallcourses = false) {
|
||||
// Get block configuration
|
||||
$config = get_config('block_course_overview');
|
||||
$limit = $config->defaultmaxcourses;
|
||||
|
||||
// If max course is not set then try get user preference
|
||||
if (empty($config->forcedefaultmaxcourses)) {
|
||||
$limit = get_user_preferences('course_overview_number_of_courses', $limit);
|
||||
if ($showallcourses) {
|
||||
$limit = 0;
|
||||
} else {
|
||||
$limit = get_user_preferences('course_overview_number_of_courses', $limit);
|
||||
}
|
||||
}
|
||||
return $limit;
|
||||
}
|
||||
@ -127,12 +132,13 @@ function block_course_overview_get_max_user_courses() {
|
||||
/**
|
||||
* Return sorted list of user courses
|
||||
*
|
||||
* @param bool $showallcourses if set true all courses will be visible.
|
||||
* @return array list of sorted courses and count of courses.
|
||||
*/
|
||||
function block_course_overview_get_sorted_courses() {
|
||||
function block_course_overview_get_sorted_courses($showallcourses = false) {
|
||||
global $USER;
|
||||
|
||||
$limit = block_course_overview_get_max_user_courses();
|
||||
$limit = block_course_overview_get_max_user_courses($showallcourses);
|
||||
|
||||
$courses = enrol_get_my_courses();
|
||||
$site = get_site();
|
||||
|
@ -215,7 +215,18 @@ class block_course_overview_renderer extends plugin_renderer_base {
|
||||
}
|
||||
$output = $this->output->box_start('notice');
|
||||
$plural = $total > 1 ? 'plural' : '';
|
||||
$output .= get_string('hiddencoursecount'.$plural, 'block_course_overview', $total);
|
||||
$config = get_config('block_course_overview');
|
||||
// Show view all course link to user if forcedefaultmaxcourses is not empty.
|
||||
if (!empty($config->forcedefaultmaxcourses)) {
|
||||
$output .= get_string('hiddencoursecountwithshowall'.$plural, 'block_course_overview', $total);
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->coursecount = $total;
|
||||
$a->showalllink = html_writer::link(new moodle_url('/my/index.php', array('mynumber' => block_course_overview::SHOW_ALL_COURSES)),
|
||||
get_string('showallcourses'));
|
||||
$output .= get_string('hiddencoursecount'.$withshowall.$plural, 'block_course_overview', $a);
|
||||
}
|
||||
|
||||
$output .= $this->output->box_end();
|
||||
return $output;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user