Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ 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()) {
return;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions lang/en/block_progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
39 changes: 33 additions & 6 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ function block_progress_monitorable_modules() {
'defaultAction' => 'viewed'
),
'forum' => array(
'defaultTime' => 'assesstimefinish',
'actions' => array(
'posted_to' => "SELECT id
FROM {forum_posts}
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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';
}

/**
Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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.
Expand Down
75 changes: 75 additions & 0 deletions user_module.js
Original file line number Diff line number Diff line change
@@ -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();
});
};
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';