diff --git a/blocks/course_overview/block_course_overview.php b/blocks/course_overview/block_course_overview.php deleted file mode 100644 index ae244ef1082..00000000000 --- a/blocks/course_overview/block_course_overview.php +++ /dev/null @@ -1,128 +0,0 @@ -. - -/** - * Course overview block - * - * @package block_course_overview - * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -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 { - /** - * If this is passed as mynumber then showallcourses, irrespective of limit by user. - */ - const SHOW_ALL_COURSES = -2; - - /** - * Block initialization - */ - public function init() { - $this->title = get_string('pluginname', 'block_course_overview'); - } - - /** - * Return contents of course_overview block - * - * @return stdClass contents of block - */ - public function get_content() { - global $USER, $CFG, $DB; - require_once($CFG->dirroot.'/user/profile/lib.php'); - - if($this->content !== NULL) { - return $this->content; - } - - $config = get_config('block_course_overview'); - - $this->content = new stdClass(); - $this->content->text = ''; - $this->content->footer = ''; - - $content = array(); - - $updatemynumber = optional_param('mynumber', -1, PARAM_INT); - if ($updatemynumber >= 0) { - block_course_overview_update_mynumber($updatemynumber); - } - - profile_load_custom_fields($USER); - - $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'); - if (!empty($config->showwelcomearea)) { - require_once($CFG->dirroot.'/message/lib.php'); - $msgcount = message_count_unread_messages(); - $this->content->text = $renderer->welcome_area($msgcount); - } - - // Number of sites to display. - if ($this->page->user_is_editing() && empty($config->forcedefaultmaxcourses)) { - $this->content->text .= $renderer->editing_bar_head($totalcourses); - } - - if (empty($sortedcourses)) { - $this->content->text .= get_string('nocourses','my'); - } else { - // For each course, build category cache. - $this->content->text .= $renderer->course_overview($sortedcourses, $overviews); - $this->content->text .= $renderer->hidden_courses($totalcourses - count($sortedcourses)); - } - - return $this->content; - } - - /** - * Allow the block to have a configuration page - * - * @return boolean - */ - public function has_config() { - return true; - } - - /** - * Locations where block can be displayed - * - * @return array - */ - public function applicable_formats() { - return array('my' => true); - } - - /** - * Sets block header to be hidden or visible - * - * @return bool if true then header will be visible. - */ - public function hide_header() { - // Hide header if welcome area is show. - $config = get_config('block_course_overview'); - return !empty($config->showwelcomearea); - } -} diff --git a/blocks/course_overview/db/access.php b/blocks/course_overview/db/access.php deleted file mode 100644 index 95abb630e64..00000000000 --- a/blocks/course_overview/db/access.php +++ /dev/null @@ -1,50 +0,0 @@ -. - -/** - * Course overview block caps. - * - * @package block_course_overview - * @copyright Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$capabilities = array( - - 'block/course_overview:myaddinstance' => array( - 'captype' => 'write', - 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - 'user' => CAP_ALLOW - ), - - 'clonepermissionsfrom' => 'moodle/my:manageblocks' - ), - - 'block/course_overview:addinstance' => array( - 'riskbitmask' => RISK_SPAM | RISK_XSS, - - 'captype' => 'write', - 'contextlevel' => CONTEXT_BLOCK, - 'archetypes' => array( - 'manager' => CAP_ALLOW - ), - - 'clonepermissionsfrom' => 'moodle/site:manageblocks' - ) -); diff --git a/blocks/course_overview/lang/en/block_course_overview.php b/blocks/course_overview/lang/en/block_course_overview.php deleted file mode 100644 index d92f3dfdb05..00000000000 --- a/blocks/course_overview/lang/en/block_course_overview.php +++ /dev/null @@ -1,67 +0,0 @@ -. - -/** - * Lang strings for course_overview block - * - * @package block_course_overview - * @copyright 2012 Adam Olley - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$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 overridden 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 Dashboard'; -$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['forcedefaultmaxcourses'] = 'Force maximum courses'; -$string['forcedefaultmaxcoursesdesc'] = 'If set then user will not be able to change his/her personal setting'; -$string['fullpath'] = 'All categories and subcategories'; -$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}'; -$string['movecoursehere'] = 'Move course here'; -$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['none'] = 'None'; -$string['numtodisplay'] = 'Number of courses to display: '; -$string['onlyparentname'] = 'Parent category only'; -$string['otherexpanded'] = 'Other courses expanded'; -$string['pluginname'] = 'Course overview'; -$string['preservestates'] = 'Preserve expanded states'; -$string['shortnameprefix'] = 'Includes {$a}'; -$string['shortnamesufixsingular'] = ' (and {$a} other)'; -$string['shortnamesufixprural'] = ' (and {$a} others)'; -$string['showcategories'] = 'Categories to show'; -$string['showcategoriesdesc'] = 'Should course categories be displayed below each course?'; -$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?'; -$string['view_edit_profile'] = '(View and edit your profile.)'; -$string['welcome'] = 'Welcome {$a}'; -$string['youhavemessages'] = 'You have {$a} unread '; -$string['youhavenomessages'] = 'You have no unread '; diff --git a/blocks/course_overview/locallib.php b/blocks/course_overview/locallib.php deleted file mode 100644 index 06e6896ce3d..00000000000 --- a/blocks/course_overview/locallib.php +++ /dev/null @@ -1,233 +0,0 @@ -. - -/** - * Helper functions for course_overview block - * - * @package block_course_overview - * @copyright 2012 Adam Olley - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -define('BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE', '0'); -define('BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_ONLY_PARENT_NAME', '1'); -define('BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_FULL_PATH', '2'); - -/** - * 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) { - $htmlarray = array(); - if ($modules = get_plugin_list_with_function('mod', 'print_overview')) { - // Split courses list into batches with no more than MAX_MODINFO_CACHE_SIZE courses in one batch. - // Otherwise we exceed the cache limit in get_fast_modinfo() and rebuild it too often. - if (defined('MAX_MODINFO_CACHE_SIZE') && MAX_MODINFO_CACHE_SIZE > 0 && count($courses) > MAX_MODINFO_CACHE_SIZE) { - $batches = array_chunk($courses, MAX_MODINFO_CACHE_SIZE, true); - } else { - $batches = array($courses); - } - foreach ($batches as $courses) { - foreach ($modules as $fname) { - $fname($courses, $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) { - set_user_preference('course_overview_number_of_courses', $number); -} - -/** - * Sets user course sorting preference in course_overview block - * - * @param array $sortorder list of course ids - */ -function block_course_overview_update_myorder($sortorder) { - $value = implode(',', $sortorder); - if (core_text::strlen($value) > 1333) { - // The value won't fit into the user preference. Remove courses in the end of the list (mostly likely user won't even notice). - $value = preg_replace('/,[\d]*$/', '', core_text::substr($value, 0, 1334)); - } - set_user_preference('course_overview_course_sortorder', $value); -} - -/** - * Gets user course sorting preference in course_overview block - * - * @return array list of course ids - */ -function block_course_overview_get_myorder() { - if ($value = get_user_preferences('course_overview_course_sortorder')) { - return explode(',', $value); - } - // If preference was not found, look in the old location and convert if found. - $order = array(); - if ($value = get_user_preferences('course_overview_course_order')) { - $order = unserialize_array($value); - block_course_overview_update_myorder($order); - unset_user_preference('course_overview_course_order'); - } - return $order; -} - -/** - * 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) { - 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); - - if ($results = $DB->get_records_sql($sql, $params)) { - $shortnames = array(); - // Preload the context we will need it to format the category name shortly. - foreach ($results as $res) { - context_helper::preload_from_record($res); - $context = context_course::instance($res->id); - $shortnames[] = format_string($res->shortname, true, $context); - } - $total = count($shortnames); - $suffix = ''; - if ($total > 10) { - $shortnames = array_slice($shortnames, 0, 10); - $diff = $total - count($shortnames); - if ($diff > 1) { - $suffix = get_string('shortnamesufixprural', 'block_course_overview', $diff); - } else { - $suffix = get_string('shortnamesufixsingular', 'block_course_overview', $diff); - } - } - $shortnames = get_string('shortnameprefix', 'block_course_overview', implode('; ', $shortnames)); - $shortnames .= $suffix; - } - - return isset($shortnames) ? $shortnames : false; -} - -/** - * 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($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)) { - if ($showallcourses) { - $limit = 0; - } else { - $limit = get_user_preferences('course_overview_number_of_courses', $limit); - } - } - return $limit; -} - -/** - * 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($showallcourses = false) { - global $USER; - - $limit = block_course_overview_get_max_user_courses($showallcourses); - - $courses = enrol_get_my_courses(); - $site = get_site(); - - if (array_key_exists($site->id,$courses)) { - unset($courses[$site->id]); - } - - foreach ($courses as $c) { - if (isset($USER->lastcourseaccess[$c->id])) { - $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id]; - } else { - $courses[$c->id]->lastaccess = 0; - } - } - - // Get remote courses. - $remotecourses = array(); - 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; - } - - $order = block_course_overview_get_myorder(); - - $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) { - if (($limit != 0) && ($counter >= $limit)) { - break; - } - if (!in_array($c->id, $order)) { - $sortedcourses[$c->id] = $c; - $counter++; - } - } - - // From list extract site courses for overview - $sitecourses = array(); - foreach ($sortedcourses as $key => $course) { - if ($course->id > 0) { - $sitecourses[$key] = $course; - } - } - return array($sortedcourses, $sitecourses, count($courses)); -} diff --git a/blocks/course_overview/module.js b/blocks/course_overview/module.js deleted file mode 100644 index e900df806fe..00000000000 --- a/blocks/course_overview/module.js +++ /dev/null @@ -1,230 +0,0 @@ -M.block_course_overview = {} - -M.block_course_overview.add_handles = function(Y) { - M.block_course_overview.Y = Y; - var MOVEICON = { - pix: "i/move_2d", - component: 'moodle' - }; - - YUI().use('dd-constrain', 'dd-proxy', 'dd-drop', 'dd-plugin', function(Y) { - //Static Vars - var goingUp = false, lastY = 0; - - var list = Y.Node.all('.course_list .coursebox'); - list.each(function(v, k) { - // Replace move link and image with move_2d image. - var imagenode = v.one('.course_title .move a img'); - imagenode.setAttribute('src', M.util.image_url(MOVEICON.pix, MOVEICON.component)); - imagenode.addClass('cursor'); - v.one('.course_title .move a').replace(imagenode); - - var dd = new Y.DD.Drag({ - node: v, - target: { - padding: '0 0 0 20' - } - }).plug(Y.Plugin.DDProxy, { - moveOnEnd: false - }).plug(Y.Plugin.DDConstrained, { - constrain2node: '.course_list' - }); - dd.addHandle('.course_title .move'); - }); - - Y.DD.DDM.on('drag:start', function(e) { - //Get our drag object - var drag = e.target; - //Set some styles here - drag.get('node').setStyle('opacity', '.25'); - drag.get('dragNode').addClass('block_course_overview'); - drag.get('dragNode').set('innerHTML', drag.get('node').get('innerHTML')); - drag.get('dragNode').setStyles({ - opacity: '.5', - borderColor: drag.get('node').getStyle('borderColor'), - backgroundColor: drag.get('node').getStyle('backgroundColor') - }); - }); - - Y.DD.DDM.on('drag:end', function(e) { - var drag = e.target; - //Put our styles back - drag.get('node').setStyles({ - visibility: '', - opacity: '1' - }); - M.block_course_overview.save(Y); - }); - - Y.DD.DDM.on('drag:drag', function(e) { - //Get the last y point - var y = e.target.lastXY[1]; - //is it greater than the lastY var? - if (y < lastY) { - //We are going up - goingUp = true; - } else { - //We are going down. - goingUp = false; - } - //Cache for next check - lastY = y; - }); - - Y.DD.DDM.on('drop:over', function(e) { - //Get a reference to our drag and drop nodes - var drag = e.drag.get('node'), - drop = e.drop.get('node'); - - //Are we dropping on a li node? - if (drop.hasClass('coursebox')) { - //Are we not going up? - if (!goingUp) { - drop = drop.get('nextSibling'); - } - //Add the node to this list - e.drop.get('node').get('parentNode').insertBefore(drag, drop); - //Resize this nodes shim, so we can drop on it later. - e.drop.sizeShim(); - } - }); - - Y.DD.DDM.on('drag:drophit', function(e) { - var drop = e.drop.get('node'), - drag = e.drag.get('node'); - - //if we are not on an li, we must have been dropped on a ul - if (!drop.hasClass('coursebox')) { - if (!drop.contains(drag)) { - drop.appendChild(drag); - } - } - }); - }); -} - -M.block_course_overview.save = function() { - var Y = M.block_course_overview.Y; - var sortorder = Y.one('.course_list').get('children').getAttribute('id'); - for (var i = 0; i < sortorder.length; i++) { - sortorder[i] = sortorder[i].substring(7); - } - var params = { - sesskey : M.cfg.sesskey, - sortorder : sortorder - }; - Y.io(M.cfg.wwwroot+'/blocks/course_overview/save.php', { - method: 'POST', - data: build_querystring(params), - context: this - }); -} - -/** - * Init a collapsible region, see print_collapsible_region in weblib.php - * @param {YUI} Y YUI3 instance with all libraries loaded - * @param {String} id the HTML id for the div. - * @param {String} userpref the user preference that records the state of this box. false if none. - * @param {String} strtooltip - */ -M.block_course_overview.collapsible = function(Y, id, userpref, strtooltip) { - if (userpref) { - M.block_course_overview.userpref = true; - } - Y.use('anim', function(Y) { - new M.block_course_overview.CollapsibleRegion(Y, id, userpref, strtooltip); - }); -}; - -/** - * Object to handle a collapsible region : instantiate and forget styled object - * - * @class - * @constructor - * @param {YUI} Y YUI3 instance with all libraries loaded - * @param {String} id The HTML id for the div. - * @param {String} userpref The user preference that records the state of this box. false if none. - * @param {String} strtooltip - */ -M.block_course_overview.CollapsibleRegion = function(Y, id, userpref, strtooltip) { - // Record the pref name - this.userpref = userpref; - - // Find the divs in the document. - this.div = Y.one('#'+id); - - // Get the caption for the collapsible region - var caption = this.div.one('#'+id + '_caption'); - caption.setAttribute('title', strtooltip); - - // Create a link - var a = Y.Node.create(''); - // Create a local scoped lamba function to move nodes to a new link - var movenode = function(node){ - node.remove(); - a.append(node); - }; - // Apply the lamba function on each of the captions child nodes - caption.get('children').each(movenode, this); - caption.prepend(a); - - // Get the height of the div at this point before we shrink it if required - var height = this.div.get('offsetHeight'); - if (this.div.hasClass('collapsed')) { - // Shrink the div as it is collapsed by default - this.div.setStyle('height', caption.get('offsetHeight')+'px'); - } - - // Create the animation. - var animation = new Y.Anim({ - node: this.div, - duration: 0.3, - easing: Y.Easing.easeBoth, - to: {height:caption.get('offsetHeight')}, - from: {height:height} - }); - - // Handler for the animation finishing. - animation.on('end', function() { - this.div.toggleClass('collapsed'); - }, this); - - // Hook up the event handler. - caption.on('click', function(e, animation) { - e.preventDefault(); - // Animate to the appropriate size. - if (animation.get('running')) { - animation.stop(); - } - animation.set('reverse', this.div.hasClass('collapsed')); - // Update the user preference. - if (this.userpref) { - M.util.set_user_preference(this.userpref, !this.div.hasClass('collapsed')); - } - animation.run(); - }, this, animation); -}; - -M.block_course_overview.userpref = false; - -/** - * The user preference that stores the state of this box. - * @property userpref - * @type String - */ -M.block_course_overview.CollapsibleRegion.prototype.userpref = null; - -/** - * The key divs that make up this - * @property div - * @type Y.Node - */ -M.block_course_overview.CollapsibleRegion.prototype.div = null; - -/** - * The key divs that make up this - * @property icon - * @type Y.Node - */ -M.block_course_overview.CollapsibleRegion.prototype.icon = null; - diff --git a/blocks/course_overview/move.php b/blocks/course_overview/move.php deleted file mode 100644 index b6f042dd7a1..00000000000 --- a/blocks/course_overview/move.php +++ /dev/null @@ -1,60 +0,0 @@ -. - -/** - * Move/order course functionality for course_overview block. - * - * @package block_course_overview - * @copyright 2012 Adam Olley - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -require_once(__DIR__ . '/../../config.php'); -require_once(__DIR__ . '/locallib.php'); - -require_sesskey(); -require_login(); - -$coursetomove = required_param('courseid', PARAM_INT); -$moveto = required_param('moveto', PARAM_INT); - -list($courses, $sitecourses, $coursecount) = block_course_overview_get_sorted_courses(); -$sortedcourses = array_keys($courses); - -$currentcourseindex = array_search($coursetomove, $sortedcourses); -// If coursetomove is not found or moveto < 0 or > count($sortedcourses) then throw error. -if ($currentcourseindex === false) { - print_error("invalidcourseid", null, null, $coursetomove); -} else if (($moveto < 0) || ($moveto >= count($sortedcourses))) { - print_error("invalidaction"); -} - -// If current course index is same as destination index then don't do anything. -if ($currentcourseindex === $moveto) { - redirect(new moodle_url('/my/index.php')); -} - -// Create neworder list for courses. -$neworder = array(); - -unset($sortedcourses[$currentcourseindex]); -$neworder = array_slice($sortedcourses, 0, $moveto, true); -$neworder[] = $coursetomove; -$remaningcourses = array_slice($sortedcourses, $moveto); -foreach ($remaningcourses as $courseid) { - $neworder[] = $courseid; -} -block_course_overview_update_myorder(array_values($neworder)); -redirect(new moodle_url('/my/index.php')); diff --git a/blocks/course_overview/renderer.php b/blocks/course_overview/renderer.php deleted file mode 100644 index 78c8b0ef33a..00000000000 --- a/blocks/course_overview/renderer.php +++ /dev/null @@ -1,348 +0,0 @@ -. - -/** - * course_overview block rendrer - * - * @package block_course_overview - * @copyright 2012 Adam Olley - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -defined('MOODLE_INTERNAL') || die; - -/** - * Course_overview block rendrer - * - * @copyright 2012 Adam Olley - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class block_course_overview_renderer extends plugin_renderer_base { - - /** - * 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 = ''; - $config = get_config('block_course_overview'); - if ($config->showcategories != BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE) { - global $CFG; - require_once($CFG->libdir.'/coursecatlib.php'); - } - $ismovingcourse = false; - $courseordernumber = 0; - $maxcourses = count($courses); - $userediting = false; - // Intialise string/icon etc if user is editing and courses > 1 - if ($this->page->user_is_editing() && (count($courses) > 1)) { - $userediting = true; - $this->page->requires->js_init_call('M.block_course_overview.add_handles'); - - // Check if course is moving - $ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL); - $movingcourseid = optional_param('courseid', 0, PARAM_INT); - } - - // Render first movehere icon. - if ($ismovingcourse) { - // Remove movecourse param from url. - $this->page->ensure_param_not_in_url('movecourse'); - - // Show moving course notice, so user knows what is being moved. - $html .= $this->output->box_start('notice'); - $a = new stdClass(); - $a->fullname = $courses[$movingcourseid]->fullname; - $a->cancellink = html_writer::link($this->page->url, get_string('cancel')); - $html .= get_string('movingcourse', 'block_course_overview', $a); - $html .= $this->output->box_end(); - - $moveurl = new moodle_url('/blocks/course_overview/move.php', - array('sesskey' => sesskey(), 'moveto' => 0, 'courseid' => $movingcourseid)); - // Create move icon, so it can be used. - $name = $courses[$movingcourseid]->fullname; - $movetofirsticon = $this->output->pix_icon('movehere', get_string('movetofirst', 'block_course_overview', $name)); - $moveurl = html_writer::link($moveurl, $movetofirsticon); - $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere')); - } - - foreach ($courses as $key => $course) { - // If moving course, then don't show course which needs to be moved. - if ($ismovingcourse && ($course->id == $movingcourseid)) { - continue; - } - $html .= $this->output->box_start('coursebox', "course-{$course->id}"); - $html .= html_writer::start_tag('div', array('class' => 'course_title')); - // If user is editing, then add move icons. - if ($userediting && !$ismovingcourse) { - $moveicon = $this->output->pix_icon('t/move', get_string('movecourse', 'block_course_overview', $course->fullname)); - $moveurl = new moodle_url($this->page->url, array('sesskey' => sesskey(), 'movecourse' => 1, 'courseid' => $course->id)); - $moveurl = html_writer::link($moveurl, $moveicon); - $html .= html_writer::tag('div', $moveurl, array('class' => 'move')); - - } - - // No need to pass title through s() here as it will be done automatically by html_writer. - $attributes = array('title' => $course->fullname); - if ($course->id > 0) { - if (empty($course->visible)) { - $attributes['class'] = 'dimmed'; - } - $courseurl = new moodle_url('/course/view.php', array('id' => $course->id)); - $coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id); - $link = html_writer::link($courseurl, $coursefullname, $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), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title'); - } - $html .= $this->output->container('', 'flush'); - $html .= html_writer::end_tag('div'); - - if (!empty($config->showchildren) && ($course->id > 0)) { - // List children here. - if ($children = block_course_overview_get_child_shortnames($course->id)) { - $html .= html_writer::tag('span', $children, array('class' => 'coursechildren')); - } - } - - // If user is moving courses, then down't show overview. - if (isset($overviews[$course->id]) && !$ismovingcourse) { - $html .= $this->activity_display($course->id, $overviews[$course->id]); - } - - if ($config->showcategories != BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE) { - // List category parent or categories path here. - $currentcategory = coursecat::get($course->category, IGNORE_MISSING); - if ($currentcategory !== null) { - $html .= html_writer::start_tag('div', array('class' => 'categorypath')); - if ($config->showcategories == BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_FULL_PATH) { - foreach ($currentcategory->get_parents() as $categoryid) { - $category = coursecat::get($categoryid, IGNORE_MISSING); - if ($category !== null) { - $html .= $category->get_formatted_name().' / '; - } - } - } - $html .= $currentcategory->get_formatted_name(); - $html .= html_writer::end_tag('div'); - } - } - - $html .= $this->output->container('', 'flush'); - $html .= $this->output->box_end(); - $courseordernumber++; - if ($ismovingcourse) { - $moveurl = new moodle_url('/blocks/course_overview/move.php', - array('sesskey' => sesskey(), 'moveto' => $courseordernumber, 'courseid' => $movingcourseid)); - $a = new stdClass(); - $a->movingcoursename = $courses[$movingcourseid]->fullname; - $a->currentcoursename = $course->fullname; - $movehereicon = $this->output->pix_icon('movehere', get_string('moveafterhere', 'block_course_overview', $a)); - $moveurl = html_writer::link($moveurl, $movehereicon); - $html .= html_writer::tag('div', $moveurl, array('class' => 'movehere')); - } - } - // Wrap course list in a div and return. - return html_writer::tag('div', $html, array('class' => 'course_list')); - } - - /** - * Coustuct activities overview for a course - * - * @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) { - $output = html_writer::start_tag('div', array('class' => 'activity_info')); - foreach (array_keys($overview) as $module) { - $output .= html_writer::start_tag('div', array('class' => 'activity_overview')); - $url = new moodle_url("/mod/$module/index.php", array('id' => $cid)); - $modulename = get_string('modulename', $module); - $icontext = html_writer::link($url, $this->output->image_icon('icon', $modulename, 'mod_'.$module, array('class'=>'iconlarge'))); - if (get_string_manager()->string_exists("activityoverview", $module)) { - $icontext .= get_string("activityoverview", $module); - } else { - $icontext .= get_string("activityoverview", 'block_course_overview', $modulename); - } - - // Add collapsible region with overview text in it. - $output .= $this->collapsible_region($overview[$module], '', 'region_'.$cid.'_'.$module, $icontext, '', true); - - $output .= html_writer::end_tag('div'); - } - $output .= html_writer::end_tag('div'); - 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) { - $output = $this->output->box_start('notice'); - - $options = array('0' => get_string('alwaysshowall', 'block_course_overview')); - for ($i = 1; $i <= $max; $i++) { - $options[$i] = $i; - } - $url = new moodle_url('/my/index.php'); - $select = new single_select($url, 'mynumber', $options, block_course_overview_get_max_user_courses(), array()); - $select->set_label(get_string('numtodisplay', 'block_course_overview')); - $output .= $this->output->render($select); - - $output .= $this->output->box_end(); - return $output; - } - - /** - * Show hidden courses count - * - * @param int $total count of hidden courses - * @return string html - */ - public function hidden_courses($total) { - if ($total <= 0) { - return; - } - $output = $this->output->box_start('notice'); - $plural = $total > 1 ? 'plural' : ''; - $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('hiddencoursecount'.$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('hiddencoursecountwithshowall'.$plural, 'block_course_overview', $a); - } - - $output .= $this->output->box_end(); - 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) { - $output = $this->collapsible_region_start($classes, $id, $caption, $userpref, $default); - $output .= $contents; - $output .= $this->collapsible_region_end(); - - return $output; - } - - /** - * Print (or return) the start of a collapsible region, that has a caption that can - * be clicked to expand or collapse the region. If JavaScript is off, then the region - * will always be expanded. - * - * @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_start($classes, $id, $caption, $userpref = '', $default = false) { - // Work out the initial state. - if (!empty($userpref) and is_string($userpref)) { - user_preference_allow_ajax_update($userpref, PARAM_BOOL); - $collapsed = get_user_preferences($userpref, $default); - } else { - $collapsed = $default; - $userpref = false; - } - - if ($collapsed) { - $classes .= ' collapsed'; - } - - $output = ''; - $output .= '
'; - $output .= '
'; - $output .= '
'; - $output .= $caption . ' '; - $output .= '
'; - $this->page->requires->js_init_call('M.block_course_overview.collapsible', array($id, $userpref, get_string('clicktohideshow'))); - - return $output; - } - - /** - * Close a region started with print_collapsible_region_start. - * - * @return string return the HTML as a string, rather than printing it. - */ - protected function collapsible_region_end() { - $output = '
'; - return $output; - } - - /** - * Cretes html for welcome area - * - * @param int $msgcount number of messages - * @return string html string for welcome area. - */ - public function welcome_area($msgcount) { - global $CFG, $USER; - $output = $this->output->box_start('welcome_area'); - - $picture = $this->output->user_picture($USER, array('size' => 75, 'class' => 'welcome_userpicture')); - $output .= html_writer::tag('div', $picture, array('class' => 'profilepicture')); - - $output .= $this->output->box_start('welcome_message'); - $output .= $this->output->heading(get_string('welcome', 'block_course_overview', $USER->firstname)); - - if (!empty($CFG->messaging)) { - $plural = 's'; - if ($msgcount > 0) { - $output .= get_string('youhavemessages', 'block_course_overview', $msgcount); - if ($msgcount == 1) { - $plural = ''; - } - } else { - $output .= get_string('youhavenomessages', 'block_course_overview'); - } - $output .= html_writer::link(new moodle_url('/message/index.php'), - get_string('message'.$plural, 'block_course_overview')); - } - $output .= $this->output->box_end(); - $output .= $this->output->container('', 'flush'); - $output .= $this->output->box_end(); - - return $output; - } -} diff --git a/blocks/course_overview/save.php b/blocks/course_overview/save.php deleted file mode 100644 index b4bb175bfa5..00000000000 --- a/blocks/course_overview/save.php +++ /dev/null @@ -1,34 +0,0 @@ -. - -/** - * Save course order in course_overview block - * - * @package block_course_overview - * @copyright 2012 Adam Olley - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -define('AJAX_SCRIPT', true); - -require_once(__DIR__ . '/../../config.php'); -require_once(__DIR__ . '/locallib.php'); - -require_sesskey(); -require_login(); - -$sortorder = required_param_array('sortorder', PARAM_INT); - -block_course_overview_update_myorder($sortorder); diff --git a/blocks/course_overview/settings.php b/blocks/course_overview/settings.php deleted file mode 100644 index d1c42758135..00000000000 --- a/blocks/course_overview/settings.php +++ /dev/null @@ -1,42 +0,0 @@ -. - -/** - * course_overview block settings - * - * @package block_course_overview - * @copyright 2012 Adam Olley - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -defined('MOODLE_INTERNAL') || die; - -if ($ADMIN->fulltree) { - $settings->add(new admin_setting_configtext('block_course_overview/defaultmaxcourses', new lang_string('defaultmaxcourses', 'block_course_overview'), - new lang_string('defaultmaxcoursesdesc', 'block_course_overview'), 10, PARAM_INT)); - $settings->add(new admin_setting_configcheckbox('block_course_overview/forcedefaultmaxcourses', new lang_string('forcedefaultmaxcourses', 'block_course_overview'), - new lang_string('forcedefaultmaxcoursesdesc', 'block_course_overview'), 1, PARAM_INT)); - $settings->add(new admin_setting_configcheckbox('block_course_overview/showchildren', new lang_string('showchildren', 'block_course_overview'), - new lang_string('showchildrendesc', 'block_course_overview'), 1, PARAM_INT)); - $settings->add(new admin_setting_configcheckbox('block_course_overview/showwelcomearea', new lang_string('showwelcomearea', 'block_course_overview'), - new lang_string('showwelcomeareadesc', 'block_course_overview'), 1, PARAM_INT)); - $showcategories = array( - BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE => new lang_string('none', 'block_course_overview'), - BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_ONLY_PARENT_NAME => new lang_string('onlyparentname', 'block_course_overview'), - BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_FULL_PATH => new lang_string('fullpath', 'block_course_overview') - ); - $settings->add(new admin_setting_configselect('block_course_overview/showcategories', new lang_string('showcategories', 'block_course_overview'), - new lang_string('showcategoriesdesc', 'block_course_overview'), BLOCKS_COURSE_OVERVIEW_SHOWCATEGORIES_NONE, $showcategories)); -} diff --git a/blocks/course_overview/styles.css b/blocks/course_overview/styles.css deleted file mode 100644 index 2aab2a35d06..00000000000 --- a/blocks/course_overview/styles.css +++ /dev/null @@ -1,87 +0,0 @@ -.block_course_overview .coursechildren { - font-weight: normal; - font-style: italic; -} - -.block_course_overview .categorypath { - text-align: right; -} - -.block_course_overview .content { - margin: 0 20px; -} - -.block_course_overview .content .notice { - margin: 5px 0; -} - -.block_course_overview .coursebox { - padding: 15px; - width: auto; -} - -.block_course_overview .profilepicture { - float: left; -} - -.block_course_overview .welcome_area { - width: 100%; - padding-bottom: 5px; -} - -.block_course_overview .welcome_message { - float: left; - padding: 10px; - border-collapse: separate; - clear: none; -} - -.block_course_overview .content h2.title { - float: left; - margin: 0 0 .5em 0; - position: relative; -} - -.block_course_overview .course_title { - position: relative; -} - -.editing .block_course_overview .coursebox .cursor { - cursor: move; - margin-bottom: 2px; -} - -.editing .block_course_overview .move { - float: left; - padding: 2px 10px 0 0; -} - -.block_course_overview .course_list { - width: 100%; -} - -.block_course_overview div.flush { - clear: both; -} - -.block_course_overview .activity_info { - clear: both; -} - -.block_course_overview .activity_overview { - padding: 2px; -} - -.block_course_overview .activity_overview img.iconlarge { - vertical-align: text-bottom; - margin-right: 6px; -} - -.block_course_overview .singleselect { - text-align: left; - margin: 0; -} - -.block_course_overview .content .course_list .movehere { - margin-bottom: 15px; -} diff --git a/blocks/course_overview/tests/behat/block_course_overview.feature b/blocks/course_overview/tests/behat/block_course_overview.feature deleted file mode 100644 index 389b6c5353b..00000000000 --- a/blocks/course_overview/tests/behat/block_course_overview.feature +++ /dev/null @@ -1,162 +0,0 @@ -@block @block_course_overview -Feature: View the course overview block on the dashboard and test it's functionality - In order to view the course overview block on the dashboard - As an admin - I can configure the course overview block - - Background: - Given the following "users" exist: - | username | firstname | lastname | email | idnumber | - | student1 | Student | 1 | student1@example.com | S1 | - | teacher1 | Teacher | 1 | teacher1@example.com | T1 | - And the following "categories" exist: - | name | category | idnumber | - | Category 1 | 0 | CAT1 | - | Category 2 | CAT1 | CAT2 | - And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | - | Course 2 | C2 | CAT1 | - | Course 3 | C3 | CAT2 | - - Scenario: View the block by a user without any enrolments - Given I log in as "student1" - Then I should see "No course information to show" in the "Course overview" "block" - - Scenario: View the block by a user with several enrolments - Given the following "course enrolments" exist: - | user | course | role | - | student1 | C1 | student | - | student1 | C2 | student | - When I log in as "student1" - Then I should see "Course 1" in the "Course overview" "block" - And I should see "Course 2" in the "Course overview" "block" - - Scenario: View the block by a user with several enrolments and limit the number of courses. - Given the following "course enrolments" exist: - | user | course | role | - | student1 | C1 | student | - | student1 | C2 | student | - | student1 | C3 | student | - When I log in as "student1" - And I press "Customise this page" - And I select "1" from the "Number of courses to display:" singleselect - Then I should see "Course 1" in the "Course overview" "block" - And I should see "You have 2 hidden courses" - And I should not see "Course 2" in the "Course overview" "block" - And I should not see "Course 3" in the "Course overview" "block" - And I follow "Show all courses" - And I should see "Course 1" in the "Course overview" "block" - And I should see "Course 2" in the "Course overview" "block" - And I should see "Course 3" in the "Course overview" "block" - - Scenario: View the block by a user with several enrolments and an admin set default max courses. - Given the following config values are set as admin: - | defaultmaxcourses | 2 | block_course_overview | - And the following "course enrolments" exist: - | user | course | role | - | student1 | C1 | student | - | student1 | C2 | student | - | student1 | C3 | student | - When I log in as "student1" - Then I should see "Course 1" in the "Course overview" "block" - And I should see "Course 2" in the "Course overview" "block" - And I should see "You have 1 hidden course" - And I press "Customise this page" - And I select "Always show all" from the "Number of courses to display:" singleselect - And I should see "Course 3" in the "Course overview" "block" - And I should not see "You have 1 hidden course" - - Scenario: View the block by a user with several enrolments and an admin enforced maximum displayed courses. - Given the following config values are set as admin: - | defaultmaxcourses | 2 | block_course_overview | - | forcedefaultmaxcourses | 1 | block_course_overview | - And the following "course enrolments" exist: - | user | course | role | - | student1 | C1 | student | - | student1 | C2 | student | - | student1 | C3 | student | - When I log in as "student1" - Then I should see "Course 1" in the "Course overview" "block" - And I should see "Course 2" in the "Course overview" "block" - And I should see "You have 1 hidden course" - And I press "Customise this page" - And I should not see "Always show all" - - Scenario: View the block by a user with the welcome area enabled and messaging disabled. - Given the following config values are set as admin: - | showwelcomearea | 1 | block_course_overview | - | messaging | 0 | | - When I log in as "student1" - Then I should see "Welcome Student" in the "Course overview" "block" - And I should not see "messages" in the "Course overview" "block" - - Scenario: View the block by a user with both the welcome area and messaging enabled. - Given the following config values are set as admin: - | showwelcomearea | 1 | block_course_overview | - When I log in as "student1" - Then I should see "Welcome Student" in the "Course overview" "block" - And I should see "You have no unread messages" in the "Course overview" "block" - And I follow "messages" - And I should see "No messages" - - @javascript - Scenario: View the block by a user with the welcome area and the user having messages. - Given the following config values are set as admin: - | showwelcomearea | 1 | block_course_overview | - And I log in as "student1" - And I should see "Welcome Student" in the "Course overview" "block" - And I should see "You have no unread messages" in the "Course overview" "block" - And I follow "messages" - And I send "This is message 1" message to "Teacher 1" user - And I send "This is message 2" message to "Teacher 1" user - When I log out - And I log in as "teacher1" - Then I should see "Welcome Teacher" in the "Course overview" "block" - And I should see "You have 2 unread messages" in the "Course overview" "block" - - Scenario: View the block by a user with the parent categories displayed. - Given the following config values are set as admin: - | showcategories | Parent category only | block_course_overview | - And the following "course enrolments" exist: - | user | course | role | - | student1 | C1 | student | - | student1 | C2 | student | - | student1 | C3 | student | - When I log in as "student1" - Then I should see "Miscellaneous" in the "Course overview" "block" - And I should see "Category 1" in the "Course overview" "block" - And I should see "Category 2" in the "Course overview" "block" - And I should not see "Category 1 / Category 1" in the "Course overview" "block" - - Scenario: View the block by a user with the full categories displayed. - Given the following config values are set as admin: - | showcategories | 2 | block_course_overview | - And the following "course enrolments" exist: - | user | course | role | - | student1 | C1 | student | - | student1 | C2 | student | - | student1 | C3 | student | - When I log in as "student1" - Then I should see "Miscellaneous" in the "Course overview" "block" - And I should see "Category 1 / Category 2" in the "Course overview" "block" - - @javascript - Scenario: View the block by a user with the show children option enabled. - Given the following config values are set as admin: - | showchildren | 1 | block_course_overview | - And the following "course enrolments" exist: - | user | course | role | - | student1 | C1 | student | - And I log in as "admin" - And I navigate to "Manage enrol plugins" node in "Site administration > Plugins > Enrolments" - And I click on "Enable" "link" in the "Course meta link" "table_row" - And I am on site homepage - And I follow "Course 2" - And I add "Course meta link" enrolment method with: - | Link course | C1 | - And I log out - When I log in as "student1" - Then I should see "Course 1" in the "Course overview" "block" - And I should see "Course 2" in the "Course overview" "block" - And I should see "Includes C1" in the "Course overview" "block" diff --git a/blocks/course_overview/tests/behat/quiz_overview.feature b/blocks/course_overview/tests/behat/quiz_overview.feature deleted file mode 100644 index c91c551fcf1..00000000000 --- a/blocks/course_overview/tests/behat/quiz_overview.feature +++ /dev/null @@ -1,93 +0,0 @@ -@block @block_course_overview @mod_quiz -Feature: View the quiz being due - In order to know what quizzes are due - As a student - I can visit my dashboard - - Background: - Given the following "users" exist: - | username | firstname | lastname | email | - | student1 | Student | 1 | student1@example.com | - | student2 | Student | 2 | student2@example.com | - | teacher1 | Teacher | 1 | teacher1@example.com | - And the following "courses" exist: - | fullname | shortname | - | Course 1 | C1 | - | Course 2 | C2 | - And the following "course enrolments" exist: - | user | course | role | - | student1 | C1 | student | - | student2 | C2 | student | - | teacher1 | C1 | editingteacher | - | teacher1 | C2 | editingteacher | - And the following "activities" exist: - | activity | course | idnumber | name | timeclose | - | quiz | C1 | Q1A | Quiz 1A No deadline | 0 | - | quiz | C1 | Q1B | Quiz 1B Past deadline | 1337 | - | quiz | C1 | Q1C | Quiz 1C Future deadline | 9000000000 | - | quiz | C1 | Q1D | Quiz 1D Future deadline | 9000000000 | - | quiz | C1 | Q1E | Quiz 1E Future deadline | 9000000000 | - | quiz | C2 | Q2A | Quiz 2A Future deadline | 9000000000 | - And the following "question categories" exist: - | contextlevel | reference | name | - | Course | C1 | Test questions | - And the following "questions" exist: - | qtype | name | questiontext | questioncategory | - | truefalse | First question | Answer the first question | Test questions | - And quiz "Quiz 1A No deadline" contains the following questions: - | question | page | - | First question | 1 | - And quiz "Quiz 1B Past deadline" contains the following questions: - | question | page | - | First question | 1 | - And quiz "Quiz 1C Future deadline" contains the following questions: - | question | page | - | First question | 1 | - And quiz "Quiz 1D Future deadline" contains the following questions: - | question | page | - | First question | 1 | - And quiz "Quiz 1E Future deadline" contains the following questions: - | question | page | - | First question | 1 | - And quiz "Quiz 2A Future deadline" contains the following questions: - | question | page | - | First question | 1 | - - Scenario: View my quizzes that are due - Given I log in as "student1" - When I am on homepage - Then I should see "You have quizzes that are due" in the "Course overview" "block" - And I should see "Quiz 1C Future deadline" in the "Course overview" "block" - And I should see "Quiz 1D Future deadline" in the "Course overview" "block" - And I should see "Quiz 1E Future deadline" in the "Course overview" "block" - And I should not see "Quiz 1A No deadline" in the "Course overview" "block" - And I should not see "Quiz 1B Past deadline" in the "Course overview" "block" - And I should not see "Quiz 2A Future deadline" in the "Course overview" "block" - And I log out - And I log in as "student2" - And I should see "You have quizzes that are due" in the "Course overview" "block" - And I should not see "Quiz 1C Future deadline" in the "Course overview" "block" - And I should not see "Quiz 1D Future deadline" in the "Course overview" "block" - And I should not see "Quiz 1E Future deadline" in the "Course overview" "block" - And I should not see "Quiz 1A No deadline" in the "Course overview" "block" - And I should not see "Quiz 1B Past deadline" in the "Course overview" "block" - And I should see "Quiz 2A Future deadline" in the "Course overview" "block" - - Scenario: View my quizzes that are due and never finished - Given I log in as "student1" - And I follow "Course 1" - And I follow "Quiz 1D Future deadline" - And I press "Attempt quiz now" - And I follow "Finish attempt ..." - And I press "Submit all and finish" - And I follow "Course 1" - And I follow "Quiz 1E Future deadline" - And I press "Attempt quiz now" - When I am on homepage - Then I should see "You have quizzes that are due" in the "Course overview" "block" - And I should see "Quiz 1C Future deadline" in the "Course overview" "block" - And I should see "Quiz 1E Future deadline" in the "Course overview" "block" - And I should not see "Quiz 1A No deadline" in the "Course overview" "block" - And I should not see "Quiz 1B Past deadline" in the "Course overview" "block" - And I should not see "Quiz 1D Future deadline" in the "Course overview" "block" - And I should not see "Quiz 2A Future deadline" in the "Course overview" "block" diff --git a/blocks/course_overview/version.php b/blocks/course_overview/version.php deleted file mode 100644 index dec7d909c67..00000000000 --- a/blocks/course_overview/version.php +++ /dev/null @@ -1,29 +0,0 @@ -. - -/** - * Version details - * - * @package block_course_overview - * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX) -$plugin->requires = 2016112900; // Requires this Moodle version -$plugin->component = 'block_course_overview'; // Full name of the plugin (used for diagnostics) diff --git a/blocks/upgrade.txt b/blocks/upgrade.txt index e0de186a947..bff229dd2f7 100644 --- a/blocks/upgrade.txt +++ b/blocks/upgrade.txt @@ -4,6 +4,8 @@ information provided here is intended especially for developers. === 3.3 === * block_manager::get_required_by_theme_block_types() is no longer static. +* The 'Course overview' block has been removed from core as it is being replaced by the 'My overview' block. + The 'Course overview' block will be available in the plugins database. === 3.1 === diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 1a1f3fc7848..d50e04fada7 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1647,6 +1647,7 @@ class core_plugin_manager { $plugins = array( 'qformat' => array('blackboard', 'learnwise'), 'auth' => array('radius'), + 'block' => array('course_overview'), 'enrol' => array('authorize'), 'report' => array('search'), 'repository' => array('alfresco'), @@ -1712,8 +1713,8 @@ class core_plugin_manager { 'activity_modules', 'activity_results', 'admin_bookmarks', 'badges', 'blog_menu', 'blog_recent', 'blog_tags', 'calendar_month', 'calendar_upcoming', 'comments', 'community', - 'completionstatus', 'course_list', 'course_overview', - 'course_summary', 'feedback', 'globalsearch', 'glossary_random', 'html', + 'completionstatus', 'course_list', 'course_summary', + 'feedback', 'globalsearch', 'glossary_random', 'html', 'login', 'lp', 'mentees', 'messages', 'mnet_hosts', 'myoverview', 'myprofile', 'navigation', 'news_items', 'online_users', 'participants', 'private_files', 'quiz_results', 'recent_activity', diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index c86c6cb432e..678b86b9693 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2621,5 +2621,23 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2017040300.04); } + if ($oldversion < 2017040300.05) { + + // If the 'Course overview' block is no longer present, remove it. + // Note - we do not need to completely remove the block context etc because we + // have replaced all occurrences of the 'Course overview' block with the 'My overview' + // block in the upgrade step above. + if (!file_exists($CFG->dirroot . '/blocks/course_overview/block_course_overview.php')) { + // Delete the block from the block table. + $DB->delete_records('block', array('name' => 'course_overview')); + // Remove capabilities. + capabilities_cleanup('block_course_overview'); + // Clean config. + unset_all_config_for_plugin('block_course_overview'); + } + + upgrade_main_savepoint(true, 2017040300.05); + } + return true; } diff --git a/version.php b/version.php index 9589ae0e0fb..75869935df8 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2017040300.04; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2017040300.05; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.