Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now works with font-awesome move icons rather than old images. #3

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
52b0db7
Now works with font-awesome move icons rather than old images. Preven…
thepurpleblob Aug 28, 2017
d36e82e
small formatting tidy
thepurpleblob Sep 11, 2017
7c1372c
Fixing up the behat tests so they now work as an optional plugin. Fix…
thepurpleblob Oct 13, 2017
e973639
Sorting functions changed from YUI to JQuery AMD
thepurpleblob Nov 9, 2017
7ef01a3
renderer moved into classes directory
thepurpleblob Nov 9, 2017
1f53908
change to jquery/amd and new features
thepurpleblob Nov 21, 2017
7d639b1
Working version for more testing
thepurpleblob Nov 23, 2017
e2f2a6b
Working version of "facelift"
thepurpleblob Nov 28, 2017
1aec534
adding grunted js
thepurpleblob Nov 28, 2017
8477c32
CHANGES updated and old renderer deleted
thepurpleblob Nov 28, 2017
b9a08fc
move.php no longer used
thepurpleblob Nov 28, 2017
2cabba1
improving the layout of block
thepurpleblob Nov 30, 2017
ca01549
courselist in a fluid container to use up all the space
thepurpleblob Dec 1, 2017
a30b23e
Version 3.3.4
thepurpleblob Dec 4, 2017
f7892e3
small tweaks so it looks better on Boostrapbase (and child) themes
thepurpleblob Dec 5, 2017
386a10e
Improve layout for Bootstrapbase themes. Show correct icons for favs …
thepurpleblob Dec 8, 2017
ae61fcd
Improve Bootstrap 2 layout and show hidden courses as dimmed. Fixes #…
thepurpleblob Jan 25, 2018
da428f7
Add Privacy API support and some small css fixes
thepurpleblob May 30, 2018
b8ae54d
Added setting to select which tab is displayed by default. Closes #17
thepurpleblob Jul 3, 2018
458aefe
Do not generate list of enrolled courses twice. Fixes #13
thepurpleblob Jul 3, 2018
f7cf20d
New instances now set themselves up in the content region rather than…
thepurpleblob Jul 3, 2018
6847f1c
new version 3.5.1
thepurpleblob Jul 3, 2018
44c92b8
updated changes
thepurpleblob Jul 3, 2018
b73b08d
updated changes
thepurpleblob Jul 3, 2018
97a1f3d
adding missing language strings and bumping version. Fixes #19
thepurpleblob Jul 4, 2018
f20e7c5
Implement pagination on block course list
Feb 13, 2019
8235db9
Adding pagination. Thanks Belinda O"Mahoney
thepurpleblob Feb 14, 2019
a6b5809
Add course sort order "Course id desc"
Feb 21, 2019
a389f94
Send correct tab name when editing course order
Mar 17, 2019
b14ca57
Merge pull request #37 from bel-omahoney/send-correct-tab-name
thepurpleblob May 23, 2019
19a5016
Merge pull request #36 from bel-omahoney/add-sort-course-id-desc
thepurpleblob May 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
## 3.5.4 ##

* Missing language strings in settings page

## 3.5.3 ##

* New instances load in the 'content' area of the Dashboard automagically.
* New option to select default tab
* Performance improvements. User's course list is only loaded once for both tabs.

## 3.3.6 ##

* Now displays hidden courses (to Teachers et al) as 'dimmed'
* Layout a bit better on legacy Bootstrap 2 themes (e.g. Clean).

## 3.3.5 ##

* Some support for bootstrapbase themes added
* favourites shown with correct 'star' in course list

## 3.3.4 ##

* Layout of courses improved using Bootstrap grids
* Option to keep favourites in 'normal' course list added to block settings
* Option to have a fixed sort order for courses tab
* Code tidied up somewhat

## 3.3.3 ##

* All javascript changed from YUI to jquery amd modules
* Rendering now using mustache templates
* Course overviews displayed by clicking icon
* Favourites tab added
* Limit on courses displayed and child course display dropped.
* print_overview() still in use (for now)

## 3.3.1 ##

* Debugging messages raised by using deprecated `print_overview()` are not
Expand Down
1 change: 1 addition & 0 deletions amd/build/edit.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions amd/build/popup.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions amd/src/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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/>.

/**
* A javascript module to allow drag-and-drop control of course order
*
* @module block_course_overview
* @class block
* @package block_course_overview
* @copyright 2017 Howard Miller <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define(['jquery', 'jqueryui'], function($, UI) {

return {
init: function() {

// Change non-js links to be inactive.
$(".courseovbox a").removeAttr("href");

// Make the course list sort.
$(".tab-pane .course-list").sortable({
update: function(event, ui) {
var kids = $(".tab-pane.active .course-list").children();
var sortorder = [];
$.each(kids, function(index, value) {
var id = value.getAttribute('id');
sortorder[index] = id.substring(7);
});

// Send new sortorder.
var activetab = $(".block_course_overview .nav-item.active a").data("tabname");
if (!activetab) {
var activetab = $(".block_course_overview .nav-tabs .active").data("tabname");
}
var data = {
sesskey : M.cfg.sesskey,
tab : activetab,
sortorder : sortorder
};
$.post(
M.cfg.wwwroot + '/blocks/course_overview/save.php',
data
);
}
});
}
};
});
54 changes: 54 additions & 0 deletions amd/src/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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/>.

/**
* A javascript module to popup activity overviews
*
* @module block_course_overview
* @class block
* @package block_course_overview
* @copyright 2017 Howard Miller <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define(['jquery', 'jqueryui', 'core/config'], function($, UI, mdlconfig) {

return {
init: function() {

// Dialogues on activity icons.
$(".dialogue").dialog({
autoOpen: false,
minWidth: 400,
classes: {
'ui-dialog': 'course-overview-dialog'
},
closeText: '',
modal: true
});

// Opens the appropriate dialog.
$(".overview-icon").click(function () {

// Takes the ID of appropriate dialogue.
var id = $(this).data('id');

// Open dialogue.
$(id).dialog("open");
});

}
};
});
98 changes: 76 additions & 22 deletions block_course_overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
* @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');

defined('MOODLE_INTERNAL') || die();

/**
* Course overview block
Expand All @@ -48,10 +49,12 @@ public function init() {
* @return stdClass contents of block
*/
public function get_content() {
global $USER, $CFG, $DB;
global $USER, $CFG, $DB, $SESSION;

require_once($CFG->dirroot.'/blocks/course_overview/locallib.php');
require_once($CFG->dirroot.'/user/profile/lib.php');

if($this->content !== NULL) {
if ($this->content !== null) {
return $this->content;
}

Expand All @@ -63,37 +66,74 @@ public function get_content() {

$content = array();

$isediting = $this->page->user_is_editing();

$updatemynumber = optional_param('mynumber', -1, PARAM_INT);
if ($updatemynumber >= 0 && optional_param('sesskey', '', PARAM_RAW) && confirm_sesskey()) {
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);
// Check if favourite added/removed.
$favourite = optional_param('favourite', 0, PARAM_INT);
if ($favourite) {
block_course_overview_add_favourite($favourite);
}
$unfavourite = optional_param('unfavourite', 0, PARAM_INT);
if ($unfavourite) {
block_course_overview_remove_favourite($unfavourite);
}

$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);
// Check if sortorder updated.
$soparam = optional_param('sortorder', -1, PARAM_INT);
if ($soparam == -1) {
$sortorder = block_course_overview_get_sortorder();
} else {
$sortorder = $soparam;
block_course_overview_update_sortorder($sortorder);
}

// Number of sites to display.
if ($this->page->user_is_editing() && empty($config->forcedefaultmaxcourses)) {
$this->content->text .= $renderer->editing_bar_head($totalcourses);
// Check if number of courses to display was updated.
$usersetmaxcourses = optional_param('usersetmaxcourses', null, PARAM_INT);
if ( $usersetmaxcourses === null ) {
$usersetmaxcourses = block_course_overview_get_usersetmaxcourses();
} else {
block_course_overview_update_usersetmaxcourses($usersetmaxcourses);
}

if (empty($sortedcourses)) {
$this->content->text .= get_string('nocourses','my');
// Get data for favourites and course tab.
$tabs = array();
$ftab = new stdClass;
$ftab->tab = 'favourites';
list($ftab->sortedcourses, $ftab->sitecourses, $ftab->totalcourses) = block_course_overview_get_sorted_courses(true);
$ftab->overviews = block_course_overview_get_overviews($ftab->sortedcourses);
$ctab = new stdClass;
$ctab->tab = 'courses';
list($ctab->sortedcourses, $ctab->sitecourses, $ctab->totalcourses)
= block_course_overview_get_sorted_courses(false, $config->keepfavourites, array_keys($ftab->sortedcourses));
$ctab->overviews = block_course_overview_get_overviews($ctab->sortedcourses);
$tabs = array(
'favourites' => $ftab,
'courses' => $ctab,
);

// Get list of favourites.
$favourites = array_keys($ftab->sortedcourses);

// Default tab. One with something in it or selected default.
if (($config->defaulttab == BLOCKS_COURSE_OVERVIEW_DEFAULT_FAVOURITES) && $ftab->totalcourses) {
$tab = 'favourites';
} else {
// For each course, build category cache.
$this->content->text .= $renderer->course_overview($sortedcourses, $overviews);
$this->content->text .= $renderer->hidden_courses($totalcourses - count($sortedcourses));
$tab = 'courses';
}

$renderer = $this->page->get_renderer('block_course_overview');

// Render block.
$main = new block_course_overview\output\main(
$config, $tabs, $isediting, $tab, $sortorder, $favourites, $usersetmaxcourses);
$this->content->text .= $renderer->render($main);
return $this->content;
}

Expand Down Expand Up @@ -121,8 +161,22 @@ public function applicable_formats() {
* @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);
return false;
}

/**
* Do any additional initialization you may need at the time a new block instance is created
* @return boolean
*/
public function instance_create() {
global $DB;

// Bodge? Modify our own instance to make the default region the
// content area, not the side bar.
$instance = $this->instance;
$instance->defaultregion = 'content';
$DB->update_record('block_instances', $instance);

return true;
}
}
Loading