mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-19430 My Moodle: Polished course_over view code of netspot
This commit is contained in:
parent
83ea0cc17e
commit
37b5e8fee8
23 changed files with 462 additions and 381 deletions
|
@ -1,33 +0,0 @@
|
||||||
My Course Overview Block for Moodle 2
|
|
||||||
|
|
||||||
== Main feautres ==
|
|
||||||
|
|
||||||
Provides a user configurable list of the courses a user is enrolled in on their My Moodle page.
|
|
||||||
|
|
||||||
The user can set the number of courses to have visible.
|
|
||||||
|
|
||||||
Courses can be reordered in editing mode via drag and drop (with appropriate fallback when ajax disabled for the user).
|
|
||||||
|
|
||||||
Each course can be expanded to show a list of activity icons alerting the user to updated modules or modules requiring attention.
|
|
||||||
|
|
||||||
Optionally can display the shortnames of child courses under the heading of the course (site-wide option).
|
|
||||||
|
|
||||||
Optionally can display a welcome area above the courses that welcomes the user and alerts them of any pending messages.
|
|
||||||
|
|
||||||
== Installing and configuring ==
|
|
||||||
|
|
||||||
Place the code for the block under /blocks/my_course_overview and install the block via the Moodle upgrade process.
|
|
||||||
|
|
||||||
== Credits ==
|
|
||||||
|
|
||||||
Coding: NetSpot (http://www.netspot.com.au)
|
|
||||||
|
|
||||||
Jointly Funded and Designed by:
|
|
||||||
- Flinders University (http://www.flinders.edu.au)
|
|
||||||
- University of Canberra (http://www.canberra.edu.au)
|
|
||||||
|
|
||||||
== See also ==
|
|
||||||
|
|
||||||
[https://github.com/netspotau/moodle-block_my_course_overview Github page]
|
|
||||||
|
|
||||||
[[Category: Contributed code]]
|
|
|
@ -17,25 +17,29 @@
|
||||||
/**
|
/**
|
||||||
* Course overview block
|
* Course overview block
|
||||||
*
|
*
|
||||||
* @package block
|
* @package block_course_overview
|
||||||
* @subpackage course_overview
|
|
||||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
require_once($CFG->dirroot.'/blocks/course_overview/locallib.php');
|
require_once($CFG->dirroot.'/blocks/course_overview/locallib.php');
|
||||||
|
/**
|
||||||
|
* Course overview block
|
||||||
|
*
|
||||||
|
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
class block_course_overview extends block_base {
|
class block_course_overview extends block_base {
|
||||||
/**
|
/**
|
||||||
* block initializations
|
* Block initialization
|
||||||
*/
|
*/
|
||||||
public function init() {
|
public function init() {
|
||||||
$this->title = get_string('displaytitle', 'block_course_overview');
|
$this->title = get_string('pluginname', 'block_course_overview');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* block contents
|
* Return contents of course_overview block
|
||||||
*
|
*
|
||||||
* @return object
|
* @return stdClass contents of block
|
||||||
*/
|
*/
|
||||||
public function get_content() {
|
public function get_content() {
|
||||||
global $USER, $CFG, $DB;
|
global $USER, $CFG, $DB;
|
||||||
|
@ -53,34 +57,34 @@ class block_course_overview extends block_base {
|
||||||
|
|
||||||
$content = array();
|
$content = array();
|
||||||
|
|
||||||
$moving = optional_param('course_moveid', 0, PARAM_INT);
|
$updatemynumber = optional_param('mynumber', -1, PARAM_INT);
|
||||||
$updatemynumber = optional_param('mynumber', null, PARAM_INT);
|
if ($updatemynumber >= 0) {
|
||||||
if (!is_null($updatemynumber)) {
|
|
||||||
block_course_overview_update_mynumber($updatemynumber);
|
block_course_overview_update_mynumber($updatemynumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
profile_load_custom_fields($USER);
|
profile_load_custom_fields($USER);
|
||||||
list($courses_sorted, $courses_total) = block_course_overview_get_sorted_courses();
|
list($sortedcourses, $sitecourses, $totalcourses) = block_course_overview_get_sorted_courses();
|
||||||
$overviews = block_course_overview_get_overviews($courses_sorted);
|
$overviews = block_course_overview_get_overviews($sitecourses);
|
||||||
|
|
||||||
$renderer = $this->page->get_renderer('block_course_overview');
|
$renderer = $this->page->get_renderer('block_course_overview');
|
||||||
if (!isset($config->showwelcomearea) || $config->showwelcomearea) {
|
if (!empty($config->showwelcomearea)) {
|
||||||
$this->content->text = $renderer->welcome_area();
|
require_once($CFG->dirroot.'/message/lib.php');
|
||||||
|
$msgcount = message_count_unread_messages();
|
||||||
|
$this->content->text = $renderer->welcome_area($msgcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
//number of sites to display
|
// Number of sites to display.
|
||||||
if ($this->page->user_is_editing()) {
|
if ($this->page->user_is_editing() && empty($config->forcedefaultmaxcourses)) {
|
||||||
$count = count(enrol_get_my_courses('id'));
|
$this->content->text .= $renderer->editing_bar_head($totalcourses);
|
||||||
$this->content->text .= $renderer->editing_bar_head($count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($courses_sorted)) {
|
if (empty($sortedcourses)) {
|
||||||
$this->content->text .= get_string('nocourses','my');
|
$this->content->text .= get_string('nocourses','my');
|
||||||
} else {
|
} else {
|
||||||
//for each course, build category cache
|
// For each course, build category cache.
|
||||||
$this->content->text .= $renderer->course_overview($courses_sorted, $overviews, $moving);
|
$this->content->text .= $renderer->course_overview($sortedcourses, $overviews);
|
||||||
$this->content->text .= $renderer->hidden_courses($courses_total - count($courses_sorted));
|
$this->content->text .= $renderer->hidden_courses($totalcourses - count($sortedcourses));
|
||||||
if ($this->page->user_is_editing() && ajaxenabled() && !$moving) {
|
if ($this->page->user_is_editing() && ajaxenabled()) {
|
||||||
$this->page->requires->js_init_call('M.block_course_overview.add_handles');
|
$this->page->requires->js_init_call('M.block_course_overview.add_handles');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +93,7 @@ class block_course_overview extends block_base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allow the block to have a configuration page
|
* Allow the block to have a configuration page
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
@ -98,7 +102,7 @@ class block_course_overview extends block_base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* locations where block can be displayed
|
* Locations where block can be displayed
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -106,12 +110,14 @@ class block_course_overview extends block_base {
|
||||||
return array('my-index' => true);
|
return array('my-index' => true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function instance_can_be_hidden() {
|
/**
|
||||||
return false;
|
* Sets block header to be hidden or visible
|
||||||
}
|
*
|
||||||
|
* @return bool if true then header will be visible.
|
||||||
|
*/
|
||||||
public function hide_header() {
|
public function hide_header() {
|
||||||
return true;
|
// Hide header if welcome area is show.
|
||||||
|
$config = get_config('block_course_overview');
|
||||||
|
return !empty($config->showwelcomearea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
function xmldb_block_course_overview_install() {
|
|
||||||
global $DB;
|
|
||||||
|
|
||||||
//setup user info fields
|
|
||||||
if (!$DB->get_record('user_info_field', array('shortname' => 'mynumber'))) {
|
|
||||||
$field = new stdClass();
|
|
||||||
$field->shortname = 'mynumber';
|
|
||||||
$field->name = 'Number of courses on My Moodle';
|
|
||||||
$field->datatype = 'text';
|
|
||||||
$field->visible = 1;
|
|
||||||
$field->categoryid = 1;
|
|
||||||
|
|
||||||
$DB->insert_record('user_info_field', $field);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$DB->get_record('user_info_field', array('shortname' => 'myorder'))) {
|
|
||||||
$field = new stdClass();
|
|
||||||
$field->shortname = 'myorder';
|
|
||||||
$field->name = 'Order of courses on My Moodle';
|
|
||||||
$field->datatype = 'text';
|
|
||||||
$field->visible = 0;
|
|
||||||
$field->categoryid = 1;
|
|
||||||
|
|
||||||
$DB->insert_record('user_info_field', $field);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
function xmldb_block_course_overview_upgrade($oldversion) {
|
|
||||||
global $DB;
|
|
||||||
if ($oldversion < 2012062800) {
|
|
||||||
//setup user info fields
|
|
||||||
if (!$DB->get_record('user_info_field', array('shortname' => 'mynumber'))) {
|
|
||||||
$field = new stdClass();
|
|
||||||
$field->shortname = 'mynumber';
|
|
||||||
$field->name = 'Number of courses on My Moodle';
|
|
||||||
$field->datatype = 'text';
|
|
||||||
$field->visible = 1;
|
|
||||||
$field->categoryid = 1;
|
|
||||||
|
|
||||||
$DB->insert_record('user_info_field', $field);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$DB->get_record('user_info_field', array('shortname' => 'myorder'))) {
|
|
||||||
$field = new stdClass();
|
|
||||||
$field->shortname = 'myorder';
|
|
||||||
$field->name = 'Order of courses on My Moodle';
|
|
||||||
$field->datatype = 'text';
|
|
||||||
$field->visible = 0;
|
|
||||||
$field->categoryid = 1;
|
|
||||||
|
|
||||||
$DB->insert_record('user_info_field', $field);
|
|
||||||
}
|
|
||||||
upgrade_block_savepoint(true, 2012062800, 'course_overview');
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
|
@ -1,15 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lang strings for course_overview block
|
||||||
|
*
|
||||||
|
* @package block_course_overview
|
||||||
|
* @copyright 2012 Adam Olley <adam.olley@netspot.com.au>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
$string['pluginname'] = 'Course overview';
|
$string['pluginname'] = 'Course overview';
|
||||||
$string['activity_assignment'] = 'You have assignments that need attention';
|
|
||||||
$string['activity_forum'] = 'There are new forum posts';
|
|
||||||
$string['activity_quiz'] = 'You have quizzes that are due';
|
|
||||||
$string['activityoverview'] = 'You have {$a}s that need attention';
|
$string['activityoverview'] = 'You have {$a}s that need attention';
|
||||||
$string['alwaysshowall'] = 'Always Show All';
|
$string['alwaysshowall'] = 'Always Show All';
|
||||||
$string['collapseall'] = 'Collapse All Course Lists';
|
$string['collapseall'] = 'Collapse All Course Lists';
|
||||||
$string['configotherexpanded'] = 'If enabled, Other Courses will be expanded by default unless overriden by user preferences.';
|
$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['configpreservestates'] = 'If enabled, the collapsed/expanded states set by the user are stored and used on each load.';
|
||||||
$string['displaytitle'] = 'learnonline: 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['hiddencoursecount'] = 'You have {$a} hidden course';
|
||||||
$string['hiddencoursecountplural'] = 'You have {$a} hidden courses';
|
$string['hiddencoursecountplural'] = 'You have {$a} hidden courses';
|
||||||
$string['movecoursehere'] = 'Move course here';
|
$string['movecoursehere'] = 'Move course here';
|
||||||
|
@ -18,11 +40,14 @@ $string['otherexpanded'] = 'Other Courses Expanded';
|
||||||
$string['preservestates'] = 'Preserve Expanded States';
|
$string['preservestates'] = 'Preserve Expanded States';
|
||||||
$string['message'] = 'message';
|
$string['message'] = 'message';
|
||||||
$string['messages'] = 'messages';
|
$string['messages'] = 'messages';
|
||||||
|
$string['shortnameprefix'] = 'Includes {$a}';
|
||||||
|
$string['shortnamesufixsingular'] = ' (and {$a} other)';
|
||||||
|
$string['shortnamesufixprural'] = ' (and {$a} others)';
|
||||||
$string['showchildren'] = 'Show Children';
|
$string['showchildren'] = 'Show Children';
|
||||||
$string['showchildren_desc'] = 'Should child courses be listed underneath the main course title?';
|
$string['showchildrendesc'] = 'Should child courses be listed underneath the main course title?';
|
||||||
$string['showwelcomearea'] = 'Show welcome area';
|
$string['showwelcomearea'] = 'Show welcome area';
|
||||||
$string['showwelcomearea_desc'] = 'Show the welcome area above the course list?';
|
$string['showwelcomeareadesc'] = 'Show the welcome area above the course list?';
|
||||||
$string['view_edit_profile'] = '(View and edit your profile.)';
|
$string['view_edit_profile'] = '(View and edit your profile.)';
|
||||||
$string['welcome'] = 'Welcome {$a}';
|
$string['welcome'] = 'Welcome {$a}';
|
||||||
$string['you_have_messages'] = 'You have {$a} unread ';
|
$string['youhavemessages'] = 'You have {$a} unread ';
|
||||||
$string['you_have_no_messages'] = 'You have no unread ';
|
$string['youhavenomessages'] = 'You have no unread ';
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This file is part of Moodle - http://moodle.org/
|
// This file is part of Moodle - http://moodle.org/
|
||||||
//
|
//
|
||||||
// Moodle is free software: you can redistribute it and/or modify
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
@ -15,101 +14,116 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper functions for course_overview block
|
||||||
|
*
|
||||||
|
* @package block_course_overview
|
||||||
|
* @copyright 2012 Adam Olley <adam.olley@netspot.com.au>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display overview for courses
|
||||||
|
*
|
||||||
|
* @param array $courses courses for which overview needs to be shown
|
||||||
|
* @return array html overview
|
||||||
|
*/
|
||||||
function block_course_overview_get_overviews($courses) {
|
function block_course_overview_get_overviews($courses) {
|
||||||
global $CFG, $USER, $DB, $OUTPUT;
|
|
||||||
$htmlarray = array();
|
$htmlarray = array();
|
||||||
if ($modules = $DB->get_records('modules')) {
|
if ($modules = get_plugin_list_with_function('mod', 'print_overview')) {
|
||||||
foreach ($modules as $mod) {
|
foreach ($modules as $fname) {
|
||||||
if (file_exists(dirname(__FILE__).'/../../mod/'.$mod->name.'/lib.php')) {
|
|
||||||
include_once(dirname(__FILE__).'/../../mod/'.$mod->name.'/lib.php');
|
|
||||||
$fname = $mod->name.'_print_overview';
|
|
||||||
if (function_exists($fname)) {
|
|
||||||
$fname($courses,$htmlarray);
|
$fname($courses,$htmlarray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return $htmlarray;
|
return $htmlarray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets user preference for maximum courses to be displayed in course_overview block
|
||||||
|
*
|
||||||
|
* @param int $number maximum courses which should be visible
|
||||||
|
*/
|
||||||
function block_course_overview_update_mynumber($number) {
|
function block_course_overview_update_mynumber($number) {
|
||||||
global $DB, $USER;
|
set_user_preference('course_overview_number_of_courses', $number);
|
||||||
if ($field = $DB->get_record('user_info_field', array('shortname' => 'mynumber'))) {
|
|
||||||
if ($data = $DB->get_record('user_info_data', array('fieldid' => $field->id, 'userid' => $USER->id))) {
|
|
||||||
$data->data = $number;
|
|
||||||
$DB->update_record('user_info_data', $data);
|
|
||||||
} else {
|
|
||||||
$data = new stdClass();
|
|
||||||
$data->fieldid = $field->id;
|
|
||||||
$data->userid = $USER->id;
|
|
||||||
$data->data = $number;
|
|
||||||
$DB->insert_record('user_info_data', $data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets user course sorting preference in course_overview block
|
||||||
|
*
|
||||||
|
* @param array $sortorder sort order of course
|
||||||
|
*/
|
||||||
function block_course_overview_update_myorder($sortorder) {
|
function block_course_overview_update_myorder($sortorder) {
|
||||||
global $DB, $USER;
|
set_user_preference('course_overview_course_order', serialize($sortorder));
|
||||||
if ($field = $DB->get_record('user_info_field', array('shortname' => 'myorder'))) {
|
|
||||||
if ($data = $DB->get_record('user_info_data', array('fieldid' => $field->id, 'userid' => $USER->id))) {
|
|
||||||
|
|
||||||
$oldlist = explode(',', $data->data);
|
|
||||||
$newlist = explode(',', $sortorder);
|
|
||||||
foreach ($oldlist as $oldentry) {
|
|
||||||
if (!in_array($oldentry, $newlist)) {
|
|
||||||
$newlist[] = $oldentry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$sortorder = implode(',', $newlist);
|
|
||||||
|
|
||||||
$data->data = $sortorder;
|
|
||||||
$DB->update_record('user_info_data', $data);
|
|
||||||
} else {
|
|
||||||
$data = new stdClass();
|
|
||||||
$data->fieldid = $field->id;
|
|
||||||
$data->userid = $USER->id;
|
|
||||||
$data->data = $sortorder;
|
|
||||||
$DB->insert_record('user_info_data', $data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns shortname of activities in course
|
||||||
|
*
|
||||||
|
* @param int $courseid id of course for which activity shortname is needed
|
||||||
|
* @return string|bool list of child shortname
|
||||||
|
*/
|
||||||
function block_course_overview_get_child_shortnames($courseid) {
|
function block_course_overview_get_child_shortnames($courseid) {
|
||||||
global $COURSE, $DB, $OUTPUT;
|
global $DB;
|
||||||
|
$ctxselect = context_helper::get_preload_record_columns_sql('ctx');
|
||||||
|
$sql = "SELECT c.id, c.shortname, $ctxselect
|
||||||
|
FROM {enrol} e
|
||||||
|
JOIN {course} c ON (c.id = e.customint1)
|
||||||
|
JOIN {context} ctx ON (ctx.instanceid = e.customint1)
|
||||||
|
WHERE e.courseid = :courseid AND e.enrol = :method AND ctx.contextlevel = :contextlevel ORDER BY e.sortorder";
|
||||||
|
$params = array('method' => 'meta', 'courseid' => $courseid, 'contextlevel' => CONTEXT_COURSE);
|
||||||
|
|
||||||
$sql = "SELECT c.shortname
|
|
||||||
FROM {enrol} AS e
|
|
||||||
JOIN {course} AS c ON (c.id = e.customint1)
|
|
||||||
WHERE e.courseid = :courseid AND e.enrol = :method ORDER BY e.sortorder";
|
|
||||||
$params = array('method' => 'meta', 'courseid' => $courseid);
|
|
||||||
if ($results = $DB->get_records_sql($sql, $params)) {
|
if ($results = $DB->get_records_sql($sql, $params)) {
|
||||||
$shortnames = array();
|
$shortnames = array();
|
||||||
|
// Preload the context we will need it to format the category name shortly.
|
||||||
foreach ($results as $res) {
|
foreach ($results as $res) {
|
||||||
$shortnames[] = $res->shortname;
|
context_helper::preload_from_record($res);
|
||||||
|
$context = context_course::instance($res->id);
|
||||||
|
$shortnames[] = format_string($res->shortname, true, $context);
|
||||||
}
|
}
|
||||||
$total = count($shortnames);
|
$total = count($shortnames);
|
||||||
$suffix = '';
|
$suffix = '';
|
||||||
if ($total > 10) {
|
if ($total > 10) {
|
||||||
$shortnames = array_slice($shortnames, 0, 10);
|
$shortnames = array_slice($shortnames, 0, 10);
|
||||||
$diff = $total - count($shortnames);
|
$diff = $total - count($shortnames);
|
||||||
$plural = $diff > 1 ? 's' : '';
|
if ($diff > 1) {
|
||||||
$suffix = " (and $diff other$plural)";
|
$suffix = get_string('shortnamesufixprural', 'block_course_overview', $diff);
|
||||||
|
} else {
|
||||||
|
$suffix = get_string('shortnamesufixsingular', 'block_course_overview', $diff);
|
||||||
}
|
}
|
||||||
$shortnames = 'includes '.implode('; ', $shortnames).$suffix;
|
}
|
||||||
|
$shortnames = get_string('shortnameprefix', 'block_course_overview', implode('; ', $shortnames));
|
||||||
|
$shortnames .= $suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isset($shortnames) ? $shortnames : false;
|
return isset($shortnames) ? $shortnames : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns maximum number of courses which will be displayed in course_overview block
|
||||||
|
*
|
||||||
|
* @return int maximum number of courses
|
||||||
|
*/
|
||||||
|
function block_course_overview_get_max_user_courses() {
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
return $limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return sorted list of user courses
|
||||||
|
*
|
||||||
|
* @return array list of sorted courses and count of courses.
|
||||||
|
*/
|
||||||
function block_course_overview_get_sorted_courses() {
|
function block_course_overview_get_sorted_courses() {
|
||||||
global $USER;
|
global $USER;
|
||||||
|
|
||||||
$limit = 71; //TODO: Make this a block setting
|
$limit = block_course_overview_get_max_user_courses();
|
||||||
if (isset($USER->profile['mynumber']) && intval($USER->profile['mynumber']) > 0) {
|
|
||||||
$limit = intval($USER->profile['mynumber']);
|
|
||||||
} else {
|
|
||||||
$USER->profile['mynumber'] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$courses = enrol_get_my_courses('id, shortname, fullname, modinfo');
|
$courses = enrol_get_my_courses('id, shortname, fullname, modinfo');
|
||||||
$site = get_site();
|
$site = get_site();
|
||||||
|
@ -126,42 +140,54 @@ function block_course_overview_get_sorted_courses() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$order = array();
|
// Get remote courses.
|
||||||
if (isset($USER->profile['myorder'])) {
|
$remotecourses = array();
|
||||||
$order = explode(',', $USER->profile['myorder']);
|
if (is_enabled_auth('mnet')) {
|
||||||
|
$remotecourses = get_my_remotecourses();
|
||||||
|
}
|
||||||
|
// Remote courses will have -ve remoteid as key, so it can be differentiated from normal courses
|
||||||
|
foreach ($remotecourses as $id => $val) {
|
||||||
|
$remoteid = $val->remoteid * -1;
|
||||||
|
$val->id = $remoteid;
|
||||||
|
$courses[$remoteid] = $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
$courses_sorted = array();
|
$order = array();
|
||||||
|
if (!is_null($usersortorder = get_user_preferences('course_overview_course_order'))) {
|
||||||
|
$order = unserialize($usersortorder);
|
||||||
|
}
|
||||||
|
|
||||||
//unsorted courses top of the list
|
$sortedcourses = array();
|
||||||
|
$counter = 0;
|
||||||
|
// Get courses in sort order into list.
|
||||||
|
foreach ($order as $key => $cid) {
|
||||||
|
if (($counter >= $limit) && ($limit != 0)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure user is still enroled.
|
||||||
|
if (isset($courses[$cid])) {
|
||||||
|
$sortedcourses[$cid] = $courses[$cid];
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Append unsorted courses if limit allows
|
||||||
foreach ($courses as $c) {
|
foreach ($courses as $c) {
|
||||||
if (count($courses_sorted) >= $limit) {
|
if (($limit != 0) && ($counter >= $limit)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!in_array($c->id, $order)) {
|
if (!in_array($c->id, $order)) {
|
||||||
$courses_sorted[$c->id] = $c;
|
$sortedcourses[$c->id] = $c;
|
||||||
|
$counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get courses in sort order into list
|
// From list extract site courses for overview
|
||||||
foreach ($order as $o) {
|
$sitecourses = array();
|
||||||
if (count($courses_sorted) >= $limit) {
|
foreach ($sortedcourses as $key => $course) {
|
||||||
break;
|
if ($course->id > 0) {
|
||||||
}
|
$sitecourses[$key] = $course;
|
||||||
if (isset($courses[intval($o)])) {
|
|
||||||
$courses_sorted[$o] = $courses[$o];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return array($sortedcourses, $sitecourses, count($courses));
|
||||||
//append the remaining courses onto the end of the list
|
|
||||||
foreach ($courses as $c) {
|
|
||||||
if (count($courses_sorted) >= $limit) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!isset($courses_sorted[$c->id])) {
|
|
||||||
$courses_sorted[$c->id] = $c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return array($courses_sorted, count($courses));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This file is part of Moodle - http://moodle.org/
|
// This file is part of Moodle - http://moodle.org/
|
||||||
//
|
//
|
||||||
// Moodle is free software: you can redistribute it and/or modify
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
@ -15,44 +14,60 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move/order course functionality for course_overview block.
|
||||||
|
*
|
||||||
|
* @package block_course_overview
|
||||||
|
* @copyright 2012 Adam Olley <adam.olley@netspot.com.au>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
require_once(dirname(__FILE__) . '/../../config.php');
|
require_once(dirname(__FILE__) . '/../../config.php');
|
||||||
require_once(dirname(__FILE__) . '/locallib.php');
|
require_once(dirname(__FILE__) . '/locallib.php');
|
||||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
|
||||||
|
|
||||||
|
require_sesskey();
|
||||||
require_login();
|
require_login();
|
||||||
|
|
||||||
$source = required_param('source', PARAM_INT);
|
$source = required_param('source', PARAM_INT);
|
||||||
$target = required_param('target', PARAM_INT);
|
$move = required_param('move', PARAM_INT);
|
||||||
|
|
||||||
profile_load_custom_fields($USER);
|
list($courses_sorted, $sitecourses, $coursecount) = block_course_overview_get_sorted_courses();
|
||||||
|
|
||||||
//get current sortorder
|
|
||||||
$sortorder = array();
|
|
||||||
if (isset($USER->profile['myorder'])) {
|
|
||||||
$mysortorder = explode(',', $USER->profile['myorder']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$courses_sorted = block_course_overview_get_sorted_courses();
|
|
||||||
$sortorder = array_keys($courses_sorted);
|
$sortorder = array_keys($courses_sorted);
|
||||||
|
// Now resort based on new weight for chosen course.
|
||||||
//now resort based on new weight for chosen course
|
|
||||||
$neworder = array();
|
$neworder = array();
|
||||||
reset($sortorder);
|
|
||||||
foreach ($sortorder as $key => $value) {
|
|
||||||
if ($value == $source) {
|
|
||||||
unset($sortorder[$key]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for ($i = 0; $i <= count($sortorder) + 1; $i++) {
|
|
||||||
if ($i == $target) {
|
|
||||||
$neworder[] = $source;
|
|
||||||
}
|
|
||||||
if (isset($sortorder[$i])) {
|
|
||||||
$neworder[] = $sortorder[$i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$neworder = implode(',', $neworder);
|
|
||||||
block_course_overview_update_myorder($neworder);
|
|
||||||
|
|
||||||
|
$sourcekey = array_search($source, $sortorder);
|
||||||
|
if ($sourcekey === false) {
|
||||||
|
print_error("invalidcourseid", null, null, $source);
|
||||||
|
}
|
||||||
|
|
||||||
|
$destination = $sourcekey + $move;
|
||||||
|
if ($destination < 0) {
|
||||||
|
print_error("listcantmoveup");
|
||||||
|
} else if ($destination >= count($courses_sorted)) {
|
||||||
|
print_error("listcantmovedown");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create neworder list for courses.
|
||||||
|
unset($sortorder[$sourcekey]);
|
||||||
|
if ($move == -1) {
|
||||||
|
if ($destination > 0) {
|
||||||
|
$neworder = array_slice($sortorder, 0, $destination, true);
|
||||||
|
}
|
||||||
|
$neworder[] = $source;
|
||||||
|
$remaningcourses = array_slice($sortorder, $destination);
|
||||||
|
foreach ($remaningcourses as $courseid) {
|
||||||
|
$neworder[] = $courseid;
|
||||||
|
}
|
||||||
|
} else if (($move == 1)) {
|
||||||
|
$neworder = array_slice($sortorder, 0, $destination);
|
||||||
|
$neworder[] = $source;
|
||||||
|
if (($destination) < count($courses_sorted)) {
|
||||||
|
$remaningcourses = array_slice($sortorder, $destination);
|
||||||
|
foreach ($remaningcourses as $courseid) {
|
||||||
|
$neworder[] = $courseid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
block_course_overview_update_myorder($neworder);
|
||||||
redirect(new moodle_url('/my/index.php'));
|
redirect(new moodle_url('/my/index.php'));
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3 KiB |
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This file is part of Moodle - http://moodle.org/
|
// This file is part of Moodle - http://moodle.org/
|
||||||
//
|
//
|
||||||
// Moodle is free software: you can redistribute it and/or modify
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
@ -15,54 +14,106 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* course_overview block rendrer
|
||||||
|
*
|
||||||
|
* @package block_course_overview
|
||||||
|
* @copyright 2012 Adam Olley <adam.olley@netspot.com.au>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
defined('MOODLE_INTERNAL') || die;
|
defined('MOODLE_INTERNAL') || die;
|
||||||
|
|
||||||
require_once($CFG->dirroot.'/message/lib.php');
|
/**
|
||||||
|
* Course_overview block rendrer
|
||||||
|
*
|
||||||
|
* @copyright 2012 Adam Olley <adam.olley@netspot.com.au>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
class block_course_overview_renderer extends plugin_renderer_base {
|
class block_course_overview_renderer extends plugin_renderer_base {
|
||||||
|
|
||||||
public function course_overview($courses, $overviews, $moving = 0) {
|
/**
|
||||||
global $OUTPUT;
|
* Construct contents of course_overview block
|
||||||
|
*
|
||||||
|
* @param array $courses list of courses in sorted order
|
||||||
|
* @param array $overviews list of course overviews
|
||||||
|
* @return string html to be displayed in course_overview block
|
||||||
|
*/
|
||||||
|
public function course_overview($courses, $overviews) {
|
||||||
$html = '';
|
$html = '';
|
||||||
$config = get_config('block_course_overview');
|
$config = get_config('block_course_overview');
|
||||||
|
|
||||||
$html .= html_writer::start_tag('div', array('id' => 'course_list'));
|
$html .= html_writer::start_tag('div', array('id' => 'course_list'));
|
||||||
$weight = 0;
|
$courseordernumber = 0;
|
||||||
$keylist = array_keys($courses);
|
$maxcourses = count($courses);
|
||||||
if ($this->page->user_is_editing() && $moving && $keylist[0] != $moving) {
|
// Intialize string/icon etc if user is editing.
|
||||||
$html .= $this->course_move_target($moving, $weight);
|
$url = null;
|
||||||
$weight++;
|
$moveicon = null;
|
||||||
}
|
$moveup[] = null;
|
||||||
foreach ($courses as $course) {
|
$movedown[] = null;
|
||||||
$cursor = ajaxenabled() && !$moving ? ' cursor' : '';
|
|
||||||
$html .= $OUTPUT->box_start('coursebox', "course-{$course->id}");
|
|
||||||
$html .= html_writer::start_tag('div', array('class' => 'course_title'));
|
|
||||||
if ($this->page->user_is_editing()) {
|
if ($this->page->user_is_editing()) {
|
||||||
// Move icon.
|
|
||||||
$icon = ajaxenabled() ? 'i/move_2d' : 't/move';
|
|
||||||
$control = array('url' => new moodle_url('/my/index.php', array('course_moveid' => $course->id)),
|
|
||||||
'icon' => $icon, 'caption' => get_string('move'));
|
|
||||||
if (ajaxenabled()) {
|
if (ajaxenabled()) {
|
||||||
$html .= html_writer::tag('div',
|
$moveicon = html_writer::tag('div',
|
||||||
html_writer::empty_tag('img',
|
html_writer::empty_tag('img',
|
||||||
array('src' => $this->pix_url($control['icon'])->out(false),
|
array('src' => $this->pix_url('i/move_2d')->out(false),
|
||||||
'alt' => $control['caption'], 'class' => 'icon cursor',
|
'alt' => get_string('move'), 'class' => 'cursor',
|
||||||
'title' => $control['caption'])
|
'title' => get_string('move'))
|
||||||
), array('class' => 'move')
|
), array('class' => 'move')
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$html .= html_writer::tag('a',
|
$url = new moodle_url('/blocks/course_overview/move.php', array('sesskey' => sesskey()));
|
||||||
html_writer::empty_tag('img', array('src' => $this->pix_url($control['icon'])->out(false), 'alt' => $control['caption'])),
|
$moveup['str'] = get_string('moveup');
|
||||||
array('class' => 'icon move','title' => $control['caption'], 'href' => $control['url']));
|
$moveup['icon'] = $this->pix_url('t/up');
|
||||||
|
$movedown['str'] = get_string('movedown');
|
||||||
|
$movedown['icon'] = $this->pix_url('t/down');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$link = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $course->fullname);
|
|
||||||
$html .= $OUTPUT->heading($link, 2, 'title');
|
foreach ($courses as $key => $course) {
|
||||||
$html .= $OUTPUT->box('', 'flush');
|
$html .= $this->output->box_start('coursebox', "course-{$course->id}");
|
||||||
|
$html .= html_writer::start_tag('div', array('class' => 'course_title'));
|
||||||
|
// Ajax enabled then add moveicon html
|
||||||
|
if (!is_null($moveicon)) {
|
||||||
|
$html .= $moveicon;
|
||||||
|
} else if (!is_null($url)) {
|
||||||
|
// Add course id to move link
|
||||||
|
$url->param('source', $course->id);
|
||||||
|
$html .= html_writer::start_tag('div', array('class' => 'moveicons'));
|
||||||
|
// Add an arrow to move course up.
|
||||||
|
if ($courseordernumber > 0) {
|
||||||
|
$url->param('move', -1);
|
||||||
|
$html .= html_writer::link($url,
|
||||||
|
html_writer::empty_tag('img', array('src' => $moveup['icon'],
|
||||||
|
'class' => 'up', 'alt' => $moveup['str'])),
|
||||||
|
array('title' => $moveup['str'], 'class' => 'moveup'));
|
||||||
|
} else {
|
||||||
|
// Add a spacer to keep keep down arrow icons at right position.
|
||||||
|
$html .= html_writer::empty_tag('img', array('src' => $this->pix_url('t/spacer'),
|
||||||
|
'class' => 'moveup spacer'));
|
||||||
|
}
|
||||||
|
// Add an arrow to move course down.
|
||||||
|
if ($courseordernumber <= $maxcourses-2) {
|
||||||
|
$url->param('move', 1);
|
||||||
|
$html .= html_writer::link($url, html_writer::empty_tag('img',
|
||||||
|
array('src' => $movedown['icon'], 'class' => 'down', 'alt' => $movedown['str'])),
|
||||||
|
array('title' => $movedown['str'], 'class' => 'movedown'));
|
||||||
|
}
|
||||||
|
$html .= html_writer::end_tag('div');
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes = array('title' => s($course->fullname));
|
||||||
|
if ($course->id > 0) {
|
||||||
|
$link = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), format_string($course->shortname, true, $course->id), $attributes);
|
||||||
|
$html .= $this->output->heading($link, 2, 'title');
|
||||||
|
} else {
|
||||||
|
$html .= $this->output->heading(html_writer::link(
|
||||||
|
new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id='.$course->remoteid)),
|
||||||
|
format_string($course->shortname, true, $course->id), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
|
||||||
|
}
|
||||||
|
$html .= $this->output->box('', 'flush');
|
||||||
$html .= html_writer::end_tag('div');
|
$html .= html_writer::end_tag('div');
|
||||||
|
|
||||||
if (isset($config->showchildren) && $config->showchildren) {
|
if (!empty($config->showchildren) && ($course->id > 0)) {
|
||||||
//list children here
|
// List children here.
|
||||||
if ($children = block_course_overview_get_child_shortnames($course->id)) {
|
if ($children = block_course_overview_get_child_shortnames($course->id)) {
|
||||||
$html .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
|
$html .= html_writer::tag('span', $children, array('class' => 'coursechildren'));
|
||||||
}
|
}
|
||||||
|
@ -72,48 +123,36 @@ class block_course_overview_renderer extends plugin_renderer_base {
|
||||||
$html .= $this->activity_display($course->id, $overviews[$course->id]);
|
$html .= $this->activity_display($course->id, $overviews[$course->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= $OUTPUT->box('', 'flush');
|
$html .= $this->output->box('', 'flush');
|
||||||
$html .= $OUTPUT->box_end();
|
$html .= $this->output->box_end();
|
||||||
|
$courseordernumber++;
|
||||||
if ($this->page->user_is_editing() && $moving && $course->id != $moving) {
|
|
||||||
//check if next is the course we're moving
|
|
||||||
$okay = true;
|
|
||||||
if (isset($keylist[$weight])) {
|
|
||||||
if ($courses[$keylist[$weight]]->id == $moving) {
|
|
||||||
$okay = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($okay) {
|
|
||||||
$html .= $this->course_move_target($moving, $weight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$weight++;
|
|
||||||
}
|
}
|
||||||
$html .= html_writer::end_tag('div');
|
$html .= html_writer::end_tag('div');
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function course_move_target($cid, $weight) {
|
/**
|
||||||
$url = new moodle_url('/blocks/course_overview/move.php', array('source' => $cid, 'target' => $weight));
|
* Coustuct activities overview for a course
|
||||||
return html_writer::tag('a', html_writer::tag('span', get_string('movecoursehere', 'block_course_overview'),
|
*
|
||||||
array('class' => 'accesshide')), array('href' => $url, 'class' => 'coursemovetarget'));
|
* @param int $cid course id
|
||||||
}
|
* @param array $overview overview of activities in course
|
||||||
|
* @return string html of activities overview
|
||||||
|
*/
|
||||||
protected function activity_display($cid, $overview) {
|
protected function activity_display($cid, $overview) {
|
||||||
global $OUTPUT;
|
|
||||||
$output = html_writer::start_tag('div', array('class' => 'activity_info'));
|
$output = html_writer::start_tag('div', array('class' => 'activity_info'));
|
||||||
foreach (array_keys($overview) as $module) {
|
foreach (array_keys($overview) as $module) {
|
||||||
$output .= html_writer::start_tag('div', array('class' => 'activity_overview'));
|
$output .= html_writer::start_tag('div', array('class' => 'activity_overview'));
|
||||||
$url = new moodle_url("/mod/$module/index.php", array('id' => $cid));
|
$url = new moodle_url("/mod/$module/index.php", array('id' => $cid));
|
||||||
$icontext = html_writer::link($url, $OUTPUT->pix_icon('icon', get_string('modulename', $module), 'mod_'.$module, array('class'=>'icon')).' ');
|
$modulename = get_string('modulename', $module);
|
||||||
if (get_string_manager()->string_exists("activity_$module", 'block_course_overview')) {
|
$icontext = html_writer::link($url, $this->output->pix_icon('icon', $modulename, 'mod_'.$module, array('class'=>'icon')).' ');
|
||||||
$icontext .= get_string("activity_$module", 'block_course_overview');
|
if (get_string_manager()->string_exists("activityoverview", $module)) {
|
||||||
|
$icontext .= get_string("activityoverview", $module);
|
||||||
} else {
|
} else {
|
||||||
$icontext .= get_string("activityoverview", 'block_course_overview', $module);
|
$icontext .= get_string("activityoverview", 'block_course_overview', $modulename);
|
||||||
}
|
}
|
||||||
|
|
||||||
//add collapsible region with overview text in it
|
// Add collapsible region with overview text in it.
|
||||||
$output .= $this->collapsible_region($overview[$module], '', 'region_'.$cid.'_'.$module, $icontext, '', true);
|
$output .= $this->collapsible_region($overview[$module], '', 'region_'.$cid.'_'.$module, $icontext, '', true);
|
||||||
|
|
||||||
$output .= html_writer::end_tag('div');
|
$output .= html_writer::end_tag('div');
|
||||||
|
@ -122,35 +161,57 @@ class block_course_overview_renderer extends plugin_renderer_base {
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs header in editing mode
|
||||||
|
*
|
||||||
|
* @param int $max maximum number of courses
|
||||||
|
* @return string html of header bar.
|
||||||
|
*/
|
||||||
public function editing_bar_head($max = 0) {
|
public function editing_bar_head($max = 0) {
|
||||||
global $OUTPUT, $USER;
|
$output = $this->output->box_start('notice');
|
||||||
$output = $OUTPUT->box_start('notice');
|
|
||||||
|
|
||||||
$options = array('0' => get_string('alwaysshowall', 'block_course_overview'));
|
$options = array('0' => get_string('alwaysshowall', 'block_course_overview'));
|
||||||
for ($i = 1; $i <= $max; $i++) {
|
for ($i = 1; $i <= $max; $i++) {
|
||||||
$options[$i] = $i;
|
$options[$i] = $i;
|
||||||
}
|
}
|
||||||
$url = new moodle_url('/my/index.php');
|
$url = new moodle_url('/my/index.php');
|
||||||
$select = new single_select($url, 'mynumber', $options, $USER->profile['mynumber'], array());
|
$select = new single_select($url, 'mynumber', $options, block_course_overview_get_max_user_courses(), array());
|
||||||
$select->set_label(get_string('numtodisplay', 'block_course_overview'));
|
$select->set_label(get_string('numtodisplay', 'block_course_overview'));
|
||||||
$output .= $OUTPUT->render($select);
|
$output .= $this->output->render($select);
|
||||||
|
|
||||||
$output .= $OUTPUT->box_end();
|
$output .= $this->output->box_end();
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show hidden courses count
|
||||||
|
*
|
||||||
|
* @param int $total count of hidden courses
|
||||||
|
* @return string html
|
||||||
|
*/
|
||||||
public function hidden_courses($total) {
|
public function hidden_courses($total) {
|
||||||
global $OUTPUT;
|
|
||||||
if ($total <= 0) {
|
if ($total <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$output = $OUTPUT->box_start('notice');
|
$output = $this->output->box_start('notice');
|
||||||
$plural = $total > 1 ? 'plural' : '';
|
$plural = $total > 1 ? 'plural' : '';
|
||||||
$output .= get_string('hiddencoursecount'.$plural, 'block_course_overview', $total);
|
$output .= get_string('hiddencoursecount'.$plural, 'block_course_overview', $total);
|
||||||
$output .= $OUTPUT->box_end();
|
$output .= $this->output->box_end();
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates collapsable region
|
||||||
|
*
|
||||||
|
* @param string $contents existing contents
|
||||||
|
* @param string $classes class names added to the div that is output.
|
||||||
|
* @param string $id id added to the div that is output. Must not be blank.
|
||||||
|
* @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
|
||||||
|
* @param string $userpref the name of the user preference that stores the user's preferred default state.
|
||||||
|
* (May be blank if you do not wish the state to be persisted.
|
||||||
|
* @param bool $default Initial collapsed state to use if the user_preference it not set.
|
||||||
|
* @return bool if true, return the HTML as a string, rather than printing it.
|
||||||
|
*/
|
||||||
protected function collapsible_region($contents, $classes, $id, $caption, $userpref = '', $default = false) {
|
protected function collapsible_region($contents, $classes, $id, $caption, $userpref = '', $default = false) {
|
||||||
$output = $this->collapsible_region_start($classes, $id, $caption, $userpref, $default);
|
$output = $this->collapsible_region_start($classes, $id, $caption, $userpref, $default);
|
||||||
$output .= $contents;
|
$output .= $contents;
|
||||||
|
@ -169,12 +230,10 @@ class block_course_overview_renderer extends plugin_renderer_base {
|
||||||
* @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
|
* @param string $caption text displayed at the top. Clicking on this will cause the region to expand or contract.
|
||||||
* @param string $userpref the name of the user preference that stores the user's preferred default state.
|
* @param string $userpref the name of the user preference that stores the user's preferred default state.
|
||||||
* (May be blank if you do not wish the state to be persisted.
|
* (May be blank if you do not wish the state to be persisted.
|
||||||
* @param boolean $default Initial collapsed state to use if the user_preference it not set.
|
* @param bool $default Initial collapsed state to use if the user_preference it not set.
|
||||||
* @param boolean $return if true, return the HTML as a string, rather than printing it.
|
* @return bool if true, return the HTML as a string, rather than printing it.
|
||||||
*/
|
*/
|
||||||
protected function collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false) {
|
protected function collapsible_region_start($classes, $id, $caption, $userpref = '', $default = false) {
|
||||||
global $CFG, $PAGE, $OUTPUT;
|
|
||||||
|
|
||||||
// Work out the initial state.
|
// Work out the initial state.
|
||||||
if (!empty($userpref) and is_string($userpref)) {
|
if (!empty($userpref) and is_string($userpref)) {
|
||||||
user_preference_allow_ajax_update($userpref, PARAM_BOOL);
|
user_preference_allow_ajax_update($userpref, PARAM_BOOL);
|
||||||
|
@ -202,38 +261,42 @@ class block_course_overview_renderer extends plugin_renderer_base {
|
||||||
/**
|
/**
|
||||||
* Close a region started with print_collapsible_region_start.
|
* Close a region started with print_collapsible_region_start.
|
||||||
*
|
*
|
||||||
* @param boolean $return if true, return the HTML as a string, rather than printing it.
|
* @return string return the HTML as a string, rather than printing it.
|
||||||
*/
|
*/
|
||||||
protected function collapsible_region_end() {
|
protected function collapsible_region_end() {
|
||||||
$output = '</div></div></div>';
|
$output = '</div></div></div>';
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function welcome_area() {
|
/**
|
||||||
global $OUTPUT, $USER;
|
* Cretes html for welcome area
|
||||||
$output = $OUTPUT->box_start('welcome_area');
|
*
|
||||||
|
* @param int $msgcount number of messages
|
||||||
|
* @return string html string for welcome area.
|
||||||
|
*/
|
||||||
|
public function welcome_area($msgcount) {
|
||||||
|
global $USER;
|
||||||
|
$output = $this->output->box_start('welcome_area');
|
||||||
|
|
||||||
$picture = $OUTPUT->user_picture($USER, array('size' => 75, 'class' => 'welcome_userpicture'));
|
$picture = $this->output->user_picture($USER, array('size' => 75, 'class' => 'welcome_userpicture'));
|
||||||
$output .= html_writer::tag('div', $picture, array('class' => 'profilepicture'));
|
$output .= html_writer::tag('div', $picture, array('class' => 'profilepicture'));
|
||||||
|
|
||||||
$output .= $OUTPUT->box_start('welcome_message');
|
$output .= $this->output->box_start('welcome_message');
|
||||||
$output .= $OUTPUT->heading(get_string('welcome', 'block_course_overview', $USER->firstname));
|
$output .= $this->output->heading(get_string('welcome', 'block_course_overview', $USER->firstname));
|
||||||
|
|
||||||
//messages
|
|
||||||
$count = message_count_unread_messages($USER);
|
|
||||||
$plural = 's';
|
$plural = 's';
|
||||||
if ($count > 0) {
|
if ($msgcount > 0) {
|
||||||
$output .= get_string('you_have_messages', 'block_course_overview', $count);
|
$output .= get_string('youhavemessages', 'block_course_overview', $msgcount);
|
||||||
} else {
|
} else {
|
||||||
$output .= get_string('you_have_no_messages', 'block_course_overview');
|
$output .= get_string('youhavenomessages', 'block_course_overview');
|
||||||
if ($count == 1) {
|
if ($msgcount == 1) {
|
||||||
$plural = '';
|
$plural = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$output .= html_writer::link(new moodle_url('/message/index.php'), get_string('message'.$plural, 'block_course_overview'));
|
$output .= html_writer::link(new moodle_url('/message/index.php'), get_string('message'.$plural, 'block_course_overview'));
|
||||||
$output .= $OUTPUT->box_end();
|
$output .= $this->output->box_end();
|
||||||
$output .= $OUTPUT->box('', 'flush');
|
$output .= $this->output->box('', 'flush');
|
||||||
$output .= $OUTPUT->box_end();
|
$output .= $this->output->box_end();
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This file is part of Moodle - http://moodle.org/
|
// This file is part of Moodle - http://moodle.org/
|
||||||
//
|
//
|
||||||
// Moodle is free software: you can redistribute it and/or modify
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
@ -15,17 +14,21 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save course order in course_overview block
|
||||||
|
*
|
||||||
|
* @package block_course_overview
|
||||||
|
* @copyright 2012 Adam Olley <adam.olley@netspot.com.au>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
define('AJAX_SCRIPT', true);
|
define('AJAX_SCRIPT', true);
|
||||||
|
|
||||||
/** Include config */
|
|
||||||
require_once(dirname(__FILE__) . '/../../config.php');
|
require_once(dirname(__FILE__) . '/../../config.php');
|
||||||
require_once(dirname(__FILE__) . '/locallib.php');
|
require_once(dirname(__FILE__) . '/locallib.php');
|
||||||
|
|
||||||
if (!confirm_sesskey()) {
|
require_sesskey();
|
||||||
throw new moodle_exception('invalidsesskey', 'error');
|
require_login();
|
||||||
}
|
|
||||||
|
|
||||||
$sortorder = required_param('sortorder', PARAM_INT);
|
$sortorder = required_param_array('sortorder', PARAM_INT);
|
||||||
$sortorder = implode(',', $sortorder);
|
|
||||||
|
|
||||||
block_course_overview_update_myorder($sortorder);
|
block_course_overview_update_myorder($sortorder);
|
||||||
|
|
|
@ -1,16 +1,35 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* course_overview block settings
|
||||||
|
*
|
||||||
|
* @package block_course_overview
|
||||||
|
* @copyright 2012 Adam Olley <adam.olley@netspot.com.au>
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
defined('MOODLE_INTERNAL') || die;
|
defined('MOODLE_INTERNAL') || die;
|
||||||
|
|
||||||
if ($ADMIN->fulltree) {
|
if ($ADMIN->fulltree) {
|
||||||
$configs = array();
|
$settings->add(new admin_setting_configtext('block_course_overview/defaultmaxcourses', get_string('defaultmaxcourses', 'block_course_overview'),
|
||||||
$configs[] = new admin_setting_configcheckbox('showchildren', get_string('showchildren', 'block_course_overview'),
|
get_string('defaultmaxcoursesdesc', 'block_course_overview'), 10, PARAM_INT));
|
||||||
get_string('showchildren_desc', 'block_course_overview'), '');
|
$settings->add(new admin_setting_configcheckbox('block_course_overview/forcedefaultmaxcourses', get_string('forcedefaultmaxcourses', 'block_course_overview'),
|
||||||
$configs[] = new admin_setting_configcheckbox('showwelcomearea', get_string('showwelcomearea', 'block_course_overview'),
|
get_string('forcedefaultmaxcoursesdesc', 'block_course_overview'), 1, PARAM_INT));
|
||||||
get_string('showwelcomearea_desc', 'block_course_overview'), 1);
|
$settings->add(new admin_setting_configcheckbox('block_course_overview/showchildren', get_string('showchildren', 'block_course_overview'),
|
||||||
|
get_string('showchildrendesc', 'block_course_overview'), 1, PARAM_INT));
|
||||||
foreach ($configs as $config) {
|
$settings->add(new admin_setting_configcheckbox('block_course_overview/showwelcomearea', get_string('showwelcomearea', 'block_course_overview'),
|
||||||
$config->plugin = 'block_course_overview';
|
get_string('showwelcomeareadesc', 'block_course_overview'), 1, PARAM_INT));
|
||||||
$settings->add($config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
.pagelayout-mydashboard #region-main .region-content .block_course_overview .header,
|
|
||||||
.pagelayout-mydashboard #region-main .region-content .block_course_overview .block_action,
|
|
||||||
.pagelayout-mydashboard #region-main .region-content .block_course_overview .commands {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.block_course_overview .coursechildren {
|
.block_course_overview .coursechildren {
|
||||||
font-size: 12px;
|
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +7,11 @@
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.block_course_overview .coursebox {
|
||||||
|
padding: 15px 0px 10px 10px;
|
||||||
|
width: 98%;
|
||||||
|
}
|
||||||
|
|
||||||
.block_course_overview .profilepicture {
|
.block_course_overview .profilepicture {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
@ -31,9 +29,8 @@
|
||||||
clear: none;
|
clear: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.block_course_overview h2.title {
|
.block_course_overview .content h2.title {
|
||||||
float: left;
|
float: left;
|
||||||
font-size: 1.5em !important;
|
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -43,10 +40,6 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editing .block_course_overview h2.title {
|
|
||||||
left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editing .block_course_overview .coursebox .cursor {
|
.editing .block_course_overview .coursebox .cursor {
|
||||||
cursor: move;
|
cursor: move;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
@ -54,8 +47,21 @@
|
||||||
|
|
||||||
.editing .block_course_overview .move {
|
.editing .block_course_overview .move {
|
||||||
float: left;
|
float: left;
|
||||||
position: absolute;
|
padding: 2px 10px 0px 0px;
|
||||||
width: 20px;
|
}
|
||||||
|
|
||||||
|
.editing .block_course_overview .moveicons {
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editing .block_course_overview .moveup {
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editing .block_course_overview .spacer {
|
||||||
|
float: left;
|
||||||
|
width: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.block_course_overview #course_list {
|
.block_course_overview #course_list {
|
||||||
|
@ -79,5 +85,10 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.block_course_overview .coursemovetarget {display: block;height: 1em;margin-bottom: 1em;border-width: 2px;border-style: dashed;}
|
.block_course_overview .coursemovetarget {
|
||||||
|
display: block;
|
||||||
|
height: 1em;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
border-width: 2px;
|
||||||
|
border-style: dashed;
|
||||||
|
}
|
|
@ -17,8 +17,7 @@
|
||||||
/**
|
/**
|
||||||
* Version details
|
* Version details
|
||||||
*
|
*
|
||||||
* @package block
|
* @package block_course_overview
|
||||||
* @subpackage course_overview
|
|
||||||
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$string['activityoverview'] = 'You have assignments that need attention';
|
||||||
$string['addsubmission'] = 'Add submission';
|
$string['addsubmission'] = 'Add submission';
|
||||||
$string['allowsubmissions'] = 'Allow the user to continue making submissions to this assignment.';
|
$string['allowsubmissions'] = 'Allow the user to continue making submissions to this assignment.';
|
||||||
$string['allowsubmissionsshort'] = 'Allow submission changes';
|
$string['allowsubmissionsshort'] = 'Allow submission changes';
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$string['activityoverview'] = 'You have assignments that need attention';
|
||||||
$string['allowdeleting'] = 'Allow deleting';
|
$string['allowdeleting'] = 'Allow deleting';
|
||||||
$string['allowdeleting_help'] = 'If enabled, students may delete uploaded files at any time before submitting for grading.';
|
$string['allowdeleting_help'] = 'If enabled, students may delete uploaded files at any time before submitting for grading.';
|
||||||
$string['allowmaxfiles'] = 'Maximum number of uploaded files';
|
$string['allowmaxfiles'] = 'Maximum number of uploaded files';
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$string['activityoverview'] = 'You have upcoming chat';
|
||||||
$string['ajax'] = 'Version using Ajax';
|
$string['ajax'] = 'Version using Ajax';
|
||||||
$string['autoscroll'] = 'Auto scroll';
|
$string['autoscroll'] = 'Auto scroll';
|
||||||
$string['beep'] = 'beep';
|
$string['beep'] = 'beep';
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$string['activityoverview'] = 'There are new forum posts';
|
||||||
$string['addanewdiscussion'] = 'Add a new discussion topic';
|
$string['addanewdiscussion'] = 'Add a new discussion topic';
|
||||||
$string['addanewquestion'] = 'Add a new question';
|
$string['addanewquestion'] = 'Add a new question';
|
||||||
$string['addanewtopic'] = 'Add a new topic';
|
$string['addanewtopic'] = 'Add a new topic';
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
$string['accessnoticesheader'] = 'You can preview this quiz, but if this were a real attempt, you would be blocked because:';
|
$string['accessnoticesheader'] = 'You can preview this quiz, but if this were a real attempt, you would be blocked because:';
|
||||||
$string['action'] = 'Action';
|
$string['action'] = 'Action';
|
||||||
|
$string['activityoverview'] = 'You have quizzes that are due';
|
||||||
$string['adaptive'] = 'Adaptive mode';
|
$string['adaptive'] = 'Adaptive mode';
|
||||||
$string['adaptive_help'] = 'If enabled, multiple responses to a question are allowed within the same attempt at the quiz. So for example if a response is marked as incorrect, the student will be allowed to try again immediately. However, depending on the "Apply penalties" setting, a penalty will usually be subtracted for each wrong attempt.';
|
$string['adaptive_help'] = 'If enabled, multiple responses to a question are allowed within the same attempt at the quiz. So for example if a response is marked as incorrect, the student will be allowed to try again immediately. However, depending on the "Apply penalties" setting, a penalty will usually be subtracted for each wrong attempt.';
|
||||||
$string['addaquestion'] = 'Add a question ...';
|
$string['addaquestion'] = 'Add a question ...';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue