diff --git a/block_progress.php b/block_progress.php index b946349..929ca6e 100755 --- a/block_progress.php +++ b/block_progress.php @@ -70,7 +70,7 @@ public function specialization() { * @return bool */ public function instance_allow_multiple() { - return !block_progress_on_site_page(); + return !block_progress_on_my_page(); } /** @@ -79,7 +79,7 @@ public function instance_allow_multiple() { * @return bool */ public function instance_allow_config() { - return !block_progress_on_site_page(); + return !block_progress_on_my_page(); } /** @@ -119,7 +119,7 @@ public function get_content() { } // Draw the multi-bar content for the Dashboard and Front page. - if (block_progress_on_site_page()) { + if (block_progress_on_my_page()) { $courses = enrol_get_my_courses(); $coursenametoshow = get_config('block_progress', 'coursenametoshow') ?: DEFAULT_COURSENAMETOSHOW; $sql = "SELECT bi.id, diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php new file mode 100644 index 0000000..73ac7bc --- /dev/null +++ b/classes/privacy/provider.php @@ -0,0 +1,43 @@ +. + +/** + * Privacy Subsystem implementation for block_progress. + * + * @package block_progress + * @copyright 2018 Nathan Nguyen + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace block_progress\privacy; + +defined('MOODLE_INTERNAL') || die(); + +/** + * The block_progress plugin does not store any data. + * + */ +class provider implements \core_privacy\local\metadata\null_provider { + /** + * Get the language string identifier with the component's language + * file to explain why this plugin stores no data. + * + * @return string + */ + public static function get_reason() : string { + return 'privacy:metadata'; + } +} diff --git a/edit_form.php b/edit_form.php index c72103d..bb68d02 100644 --- a/edit_form.php +++ b/edit_form.php @@ -39,8 +39,14 @@ protected function specific_definition($mform) { global $CFG, $COURSE, $DB, $OUTPUT, $SCRIPT; $loggingenabled = true; + // Raise the max_execution time to 60 seconds for courses with many modules. + core_php_time_limit::raise(60); + + // Also raise memory limit for courses with many modules. + raise_memory_limit(MEMORY_EXTRA); + // The My home version is not configurable. - if (block_progress_on_site_page()) { + if (block_progress_on_my_page()) { return; } @@ -306,7 +312,7 @@ protected function specific_definition($mform) { ); foreach ($sections as $i => $section) { - if (count($section->sequence) > 0) { + if ($section->sequence != null && (count($section->sequence) > 0)) { // Output the section header. $sectionname = get_string('section').': '.get_section_name($COURSE, $section); diff --git a/lang/en/block_progress.php b/lang/en/block_progress.php index 9dd24bc..2c0c8b6 100755 --- a/lang/en/block_progress.php +++ b/lang/en/block_progress.php @@ -40,8 +40,10 @@ $string['folder'] = 'Folder'; $string['forum'] = 'Forum'; $string['glossary'] = 'Glossary'; +$string['groupaddnewnote'] = 'Add a common note'; $string['hotpot'] = 'Hot Potatoes'; $string['hsuforum'] = 'Advanced Forum'; +$string['hvp'] = 'Interactive Content'; $string['imscp'] = 'IMS Content Package'; $string['journal'] = 'Journal'; $string['lesson'] = 'Lesson'; @@ -251,3 +253,5 @@ // For My home page. $string['no_blocks'] = "No Progress Bar blocks are set up for your courses."; $string['no_courses'] = "You are not enrolled in any courses. Only bars from enrolled courses will be shown."; + +$string['privacy:metadata'] = "Progress block does not store any personal data."; diff --git a/lib.php b/lib.php index f6d62eb..f0b68fb 100755 --- a/lib.php +++ b/lib.php @@ -490,6 +490,7 @@ function block_progress_monitorable_modules() { 'defaultAction' => 'viewed' ), 'forum' => array( + 'defaultTime' => 'assesstimefinish', 'actions' => array( 'posted_to' => "SELECT id FROM {forum_posts} @@ -565,6 +566,27 @@ function block_progress_monitorable_modules() { ), 'defaultAction' => 'posted_to' ), + 'hvp' => array( + 'actions' => array( + 'viewed' => array ( + 'logstore_legacy' => "SELECT id + FROM {log} + WHERE course = :courseid + AND module = 'hvp' + AND action = 'view' + AND cmid = :cmid + AND userid = :userid", + 'sql_internal_reader' => "SELECT id + FROM {log} + WHERE courseid = :courseid + AND component = 'mod_hvp' + AND action = 'viewed' + AND objectid = :eventid + AND userid = :userid", + ), + ), + 'defaultAction' => 'viewed' + ), 'imscp' => array( 'actions' => array( 'viewed' => array ( @@ -1563,6 +1585,11 @@ function block_progress_bar($modules, $config, $events, $userid, $instance, $att 'id' => 'progressBarInfo'.$instance.'-'.$userid.'-info'); $content .= HTML_WRITER::start_tag('div', $divoptions); if (!$simple) { + if (isset($config->showpercentage) && $config->showpercentage == 1) { + $progress = block_progress_percentage($events, $attempts); + $content .= get_string('progress', 'block_progress').': '; + $content .= $progress.'%'.HTML_WRITER::empty_tag('br'); + } $content .= get_string('mouse_over_prompt', 'block_progress'); $content .= ' '; $attributes = array ( @@ -1712,7 +1739,7 @@ function block_progress_filter_visibility($events, $userid, $coursecontext, $cou if ($coursemodule->uservisible != 1 && empty($coursemodule->availableinfo)) { continue; } - } else if (!groups_course_module_visible($coursemodule, $userid)) { + } else if (!$coursemodule->uservisible) { continue; } } @@ -1728,10 +1755,10 @@ function block_progress_filter_visibility($events, $userid, $coursecontext, $cou * * @return bool True when on the My home page. */ -function block_progress_on_site_page() { - global $SCRIPT, $COURSE; +function block_progress_on_my_page() { + global $SCRIPT; - return $SCRIPT === '/my/index.php' || $COURSE->id == 1; + return $SCRIPT === '/my/index.php'; } /** @@ -1744,7 +1771,7 @@ function block_progress_get_course_context($courseid) { if (class_exists('context_course')) { return context_course::instance($courseid); } else { - return get_context_instance(CONTEXT_COURSE, $courseid); + return context_course::instance($courseid); } } @@ -1758,7 +1785,7 @@ function block_progress_get_block_context($blockid) { if (class_exists('context_block')) { return context_block::instance($blockid); } else { - return get_context_instance(CONTEXT_BLOCK, $blockid); + return context_block::instance($blockid); } } diff --git a/overview.php b/overview.php index 85f28d0..6f48999 100644 --- a/overview.php +++ b/overview.php @@ -325,7 +325,7 @@ } if (!empty($CFG->enablenotes) && has_capability('moodle/notes:manage', $context)) { $displaylist['addnote.php'] = get_string('addnewnote', 'notes'); - $displaylist['groupaddnote.php'] = get_string('groupaddnewnote', 'notes'); + $displaylist['groupaddnote.php'] = get_string('groupaddnewnote', 'block_progress'); } echo html_writer::tag('label', get_string("withselectedusers"), array('for' => 'formactionid')); echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), array('id' => 'formactionid')); @@ -339,7 +339,7 @@ } // Organise access to JS for messaging. -$module = array('name' => 'core_user', 'fullpath' => '/user/module.js'); +$module = array('name' => 'core_user', 'fullpath' => '/blocks/progress/user_module.js'); $PAGE->requires->js_init_call('M.core_user.init_participation', null, false, $module); // Organise access to JS for progress bars. diff --git a/user_module.js b/user_module.js new file mode 100755 index 0000000..5a75407 --- /dev/null +++ b/user_module.js @@ -0,0 +1,75 @@ + +M.core_user = {}; + +M.core_user.init_participation = function(Y) { + Y.on('change', function() { + var action = Y.one('#formactionid'); + if (action.get('value') == '') { + return; + } + var ok = false; + Y.all('input.usercheckbox').each(function() { + if (this.get('checked')) { + ok = true; + } + }); + if (!ok) { + // no checkbox selected + return; + } + + if (action.get('value') == 'email') { + var mailto = ''; + Y.all('input.usercheckbox').each(function() { + if (this.get('checked')) { + var email = document.getElementById(this.get('name')+'_email').value; + if (mailto.length > 0) { + mailto = mailto+'; '; + } + mailto = mailto+email; + } + }); + location.href='mailto:?bcc='+mailto; + document.getElementById('formactionid').selectedIndex = 0; + return; + } + + Y.one('#participantsform').submit(); + }, '#formactionid'); + + Y.on('click', function(e) { + // Presence of a show all link indicates we should redirect to + // a page with all users listed and checked, otherwise just check + // those already shown. + var showallink = this.getAttribute('data-showallink'); + if (showallink) { + window.location = showallink; + } + Y.all('input.usercheckbox').each(function() { + this.set('checked', 'checked'); + }); + }, '#checkall, #checkallonpage'); + + Y.on('click', function(e) { + Y.all('input.usercheckbox').each(function() { + this.set('checked', ''); + }); + }, '#checknone'); +}; + +M.core_user.init_tree = function(Y, expand_all, htmlid) { + Y.use('yui2-treeview', function(Y) { + var tree = new Y.YUI2.widget.TreeView(htmlid); + + tree.subscribe("clickEvent", function(node, event) { + // we want normal clicking which redirects to url + return false; + }); + + if (expand_all) { + tree.expandAll(); + } + + tree.render(); + }); +}; diff --git a/version.php b/version.php index 706b9ab..83e230e 100755 --- a/version.php +++ b/version.php @@ -24,8 +24,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$plugin->version = 2016081800; +$plugin->version = 2016081801; $plugin->requires = 2010121000; $plugin->maturity = MATURITY_STABLE; -$plugin->release = 'Version for Moodle 2.0 to 3.1 (final)'; +$plugin->release = 'Version for Moodle 2.0 onwards'; $plugin->component = 'block_progress';