diff --git a/block_completion_progress.php b/block_completion_progress.php index ff08391..2683790 100644 --- a/block_completion_progress.php +++ b/block_completion_progress.php @@ -203,10 +203,9 @@ class block_completion_progress extends block_base { if ($this->page->user_is_editing() && $this->content->text == '') { $this->content->text = get_string('no_blocks', 'block_completion_progress'); } - } - // Gather content for block on regular course. - else { + } else { + // Gather content for block on regular course. // Check if user is in group for block. if ( @@ -217,15 +216,23 @@ class block_completion_progress extends block_base { return $this->content; } - // Check if completion is enabled. - $completion = new completion_info($COURSE); - if (!$CFG->enablecompletion || !$completion->is_enabled()) { + // Check if completion is enabled at site level. + if (!$CFG->enablecompletion) { if (has_capability('moodle/block:edit', $this->context)) { $this->content->text .= get_string('completion_not_enabled', 'block_completion_progress'); } return $this->content; } + // Check if completion is enabled at course level. + $completion = new completion_info($COURSE); + if (!$completion->is_enabled()) { + if (has_capability('moodle/block:edit', $this->context)) { + $this->content->text .= get_string('completion_not_enabled_course', 'block_completion_progress'); + } + return $this->content; + } + // Check if any activities/resources have been created. $activities = block_completion_progress_get_activities($COURSE->id, $this->config); $activities = block_completion_progress_filter_visibility($activities, $USER->id, $COURSE->id); diff --git a/edit_form.php b/edit_form.php index 396d095..5927367 100644 --- a/edit_form.php +++ b/edit_form.php @@ -57,7 +57,7 @@ class block_completion_progress_edit_form extends block_edit_form { ); $orderbylabel = get_string('config_orderby', 'block_completion_progress'); $mform->addElement('select', 'config_orderby', $orderbylabel, $orderingoptions); - $mform->setDefault('config_orderby', DEFAULT_ORDERBY); + $mform->setDefault('config_orderby', DEFAULT_COMPLETIONPROGRESS_ORDERBY); $mform->addHelpButton('config_orderby', 'how_ordering_works', 'block_completion_progress'); // Check if all elements have an expect completion by time set. @@ -69,9 +69,8 @@ class block_completion_progress_edit_form extends block_edit_form { } if (!$allwithexpected) { $warningstring = get_string('not_all_expected_set', 'block_completion_progress', $expectedbystring); - $expectedwarning = HTML_WRITER::tag('div', $warningstring, array('class' => 'error')); + $expectedwarning = HTML_WRITER::tag('div', $warningstring, array('class' => 'warning')); $mform->addElement('static', $expectedwarning, '', $expectedwarning); - $mform->disabledif($expectedwarning, 'config_orderby', 'neq', 'orderbytime'); } // Control how long bars wrap/scroll. @@ -82,7 +81,7 @@ class block_completion_progress_edit_form extends block_edit_form { ); $longbarslabel = get_string('config_longbars', 'block_completion_progress'); $mform->addElement('select', 'config_longbars', $longbarslabel, $longbaroptions); - $defaultlongbars = get_config('block_completion_progress', 'defaultlongbars') ?: DEFAULT_LONGBARS; + $defaultlongbars = get_config('block_completion_progress', 'defaultlongbars') ?: DEFAULT_COMPLETIONPROGRESS_LONGBARS; $mform->setDefault('config_longbars', $defaultlongbars); $mform->addHelpButton('config_longbars', 'how_longbars_works', 'block_completion_progress'); @@ -91,13 +90,13 @@ class block_completion_progress_edit_form extends block_edit_form { get_string('config_icons', 'block_completion_progress').' '. $OUTPUT->pix_icon('tick', '', 'block_completion_progress', array('class' => 'iconOnConfig')).' '. $OUTPUT->pix_icon('cross', '', 'block_completion_progress', array('class' => 'iconOnConfig'))); - $mform->setDefault('config_progressBarIcons', DEFAULT_PROGRESSBARICONS); + $mform->setDefault('config_progressBarIcons', DEFAULT_COMPLETIONPROGRESS_PROGRESSBARICONS); $mform->addHelpButton('config_progressBarIcons', 'why_use_icons', 'block_completion_progress'); // Allow progress percentage to be turned on for students. $mform->addElement('selectyesno', 'config_showpercentage', get_string('config_percentage', 'block_completion_progress')); - $mform->setDefault('config_showpercentage', DEFAULT_SHOWPERCENTAGE); + $mform->setDefault('config_showpercentage', DEFAULT_COMPLETIONPROGRESS_SHOWPERCENTAGE); $mform->addHelpButton('config_showpercentage', 'why_show_precentage', 'block_completion_progress'); // Allow the block to be visible to a single group. diff --git a/lang/en/block_completion_progress.php b/lang/en/block_completion_progress.php index cb3ba9f..8befed3 100644 --- a/lang/en/block_completion_progress.php +++ b/lang/en/block_completion_progress.php @@ -22,129 +22,75 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -// Stings for the Config page. +$string['completed_colour'] = '#73A839'; +$string['completed_colour_descr'] = 'HTML Colour code for elements that have been completed'; +$string['completed_colour_title'] = 'Completed colour'; +$string['completion_not_enabled'] = 'Completion tracking is not enabled on this site.'; +$string['completion_not_enabled_course'] = 'Completion tracking is not enabled in this course.'; +$string['completion_progress:addinstance'] = 'Add a new Completion Progress block'; +$string['completion_progress:myaddinstance'] = 'Add a Completion Progress block to My home page'; +$string['completion_progress:overview'] = 'View course overview of Completion Progress for all students'; +$string['completion_progress:showbar'] = 'Show the bar in the Completion Progress block'; +$string['config_activitiesincluded'] = 'Activities included'; +$string['config_activitycompletion'] = 'All activities with completion set'; $string['config_default_title'] = 'Completion Progress'; $string['config_group'] = 'Visible only to group'; $string['config_header_monitored'] = 'Monitored'; $string['config_icons'] = 'Use icons in bar'; $string['config_longbars'] = 'How to present long bars'; +$string['config_orderby'] = 'Order bar by'; +$string['config_orderby_course_order'] = 'Ordering in course'; +$string['config_orderby_due_time'] = 'Time using "{$a}" date'; $string['config_percentage'] = 'Show percentage to students'; $string['config_scroll'] = 'Scroll'; +$string['config_selectactivities'] = 'Select activities'; +$string['config_selectedactivities'] = 'Selected activities'; $string['config_squeeze'] = 'Squeeze'; $string['config_title'] = 'Alternate title'; -$string['config_orderby'] = 'Order bar by'; -$string['config_orderby_due_time'] = '"{$a}" date'; -$string['config_orderby_course_order'] = 'Ordering in course'; $string['config_wrap'] = 'Wrap'; -$string['config_activitycompletion'] = 'All activities with completion set'; -$string['config_selectedactivities'] = 'Selected activities'; -$string['config_activitiesincluded'] = 'Activities included'; -$string['config_selectactivities'] = 'Select activities'; - -// Help strings. -$string['why_set_the_title'] = 'Why you might want to set the block instance title?'; -$string['why_set_the_title_help'] = ' -

There can be multiple instances of the Completion Progress block. You may use different Completion Progress blocks to monitor different sets of activities or resources. For instance you could track progress in assignments in one block and quizzes in another. For this reason you can override the default title and set a more appropriate block title for each instance.

-'; -$string['why_use_icons'] = 'Why you might want to use icons?'; -$string['why_use_icons_help'] = ' -

You may wish to add tick and cross icons in the Completion Progress to make this block more visually accessible for students with colour-blindness.

-

It may also make the meaning of the block clearer if you believe colours are not intuitive, either for cultural or personal reasons.

-'; -$string['why_show_precentage'] = 'Why show a progress percentage to students?'; -$string['why_show_precentage_help'] = ' -

It is possible to show an overall percentage of progress to students.

-

This is calculated as the number of items complete divided by the total number of items in the bar.

-

The progress percentage appears until the student mouses over an item in the bar.

-'; -$string['how_ordering_works'] = 'How ordering works'; -$string['how_ordering_works_help'] = ' -

There are two ways items in the Completion Progress can be ordered.

- -'; +$string['coursenametoshow'] = 'Course name to show on Dashboard'; +$string['defaultlongbars'] = 'Default presentation for long bars'; +$string['fullname'] = 'Full course name'; +$string['futureNotCompleted_colour'] = '#025187'; +$string['futureNotCompleted_colour_descr'] = 'HTML colour code for future elements that have not yet been completed'; +$string['futureNotCompleted_colour_title'] = 'Future not-completed colour'; +$string['how_activitiesincluded_works'] = 'How including activities works'; +$string['how_activitiesincluded_works_help'] = '

By default, all activities with Activity completion settings set are included in the bar.

You can also manually select activities to be included.

'; $string['how_group_works'] = 'How visible group works'; -$string['how_group_works_help'] = ' -

Selecting a group will limit the display of the this block to that group only.

-'; +$string['how_group_works_help'] = '

Selecting a group will limit the display of the this block to that group only.

'; $string['how_longbars_works'] = 'How long bars are presented'; -$string['how_longbars_works_help'] = ' -

When bars exceed a set length, how they can be presented in one of the following ways.

- -

Note that when the bar is wrapped, the NOW indicator will not be shown.

-'; -$string['how_activitiesincluded_works'] = 'How including activities works'; -$string['how_activitiesincluded_works_help'] = ' -

By default, all activities with Activity completion settings set are included in the bar.

-

You can also manually select activities to be included.

-'; +$string['how_longbars_works_help'] = '

When bars exceed a set length, how they can be presented in one of the following ways.

Note that when the bar is wrapped, the NOW indicator will not be shown.

'; +$string['how_ordering_works'] = 'How ordering works'; +$string['how_ordering_works_help'] = '

There are two ways to order activities in the Completion Progress block.

'; $string['how_selectactivities_works'] = 'How including activities works'; -$string['how_selectactivities_works_help'] = ' -

To manually select activities to be include in the bar, ensure that "'.$string['config_activitiesincluded'].'" is set to "'.$string['config_selectedactivities'].'".

-

Only activities with activity completion settings set can be included.

-

Hold the CTRL key to select multiple items.

-'; - - -// Other terms. -$string['completion_not_enabled'] = 'Completion tracking is not enabled.'; +$string['how_selectactivities_works_help'] = '

To manually select activities to be include in the bar, ensure that "'.$string['config_activitiesincluded'].'" is set to "'.$string['config_selectedactivities'].'".

Only activities with activity completion settings set can be included.

Hold the CTRL key to select multiple activities.

'; +$string['lastonline'] = 'Last in course'; $string['mouse_over_prompt'] = 'Mouse over or touch bar for info.'; -$string['no_activities_config_message'] = ' -There are no activities or resources with activity completion set or no activities or resources have been selected. -Set activity completion on activities and resources then configure this block. -'; +$string['no_activities_config_message'] = 'There are no activities or resources with activity completion set or no activities or resources have been selected. Set activity completion on activities and resources then configure this block.'; $string['no_activities_message'] = 'No activities or resources are being monitored. Use config to set up monitoring.'; -$string['no_visible_activities_message'] = 'None of the monitored events are currently visible.'; +$string['no_blocks'] = 'No Completion Progress blocks are set up for your courses.'; +$string['no_visible_activities_message'] = 'None of the monitored activities are currently visible.'; +$string['not_all_expected_set'] = 'Not all activities with completion have an "{$a}" date set.'; +$string['notCompleted_colour'] = '#C71C22'; +$string['notCompleted_colour_descr'] = 'HTML colour code for current elements that have not yet been completed'; +$string['notCompleted_colour_title'] = 'Not-completed colour'; $string['now_indicator'] = 'NOW'; +$string['overview'] = 'Overview of students'; $string['pluginname'] = 'Completion Progress'; +$string['progress'] = 'Progress'; +$string['progressbar'] = 'Completion Progress'; +$string['shortname'] = 'Short course name'; $string['showallinfo'] = 'Show all info'; -$string['time_expected'] = 'Expected'; -$string['not_all_expected_set'] = 'Not all activities with completion have an "{$a}" date set.'; +$string['showinactive'] = 'Show inactive students in Overview'; $string['submitted'] = 'Submitted'; - -// Global setting strings -// Default colours that may have different cultural meanings. -// Note that these defaults can be overridden by the block's global settings. -$string['attempted_colour'] = '#73A839'; $string['submittednotcomplete_colour'] = '#FFCC00'; -$string['notAttempted_colour'] = '#C71C22'; -$string['futureNotAttempted_colour'] = '#025187'; -$string['attempted_colour_title'] = 'Attempted colour'; -$string['attempted_colour_descr'] = 'HTML Colour code for elements that have been attempted'; -$string['submittednotcomplete_colour_title'] = 'Submitted but not complete colour'; $string['submittednotcomplete_colour_descr'] = 'HTML colour code for elements that have been submitted, but are not yet complete'; -$string['notattempted_colour_title'] = 'Not-attempted colour'; -$string['notattempted_colour_descr'] = 'HTML colour code for current elements that have not yet been attempted'; -$string['futurenotattempted_colour_title'] = 'Future Not-attempted colour'; -$string['futurenotattempted_colour_descr'] = 'HTML colour code for future elements that have not yet been attemted'; -$string['coursenametoshow'] = 'Course name to show on Dashboard'; -$string['shortname'] = 'Short course name'; -$string['fullname'] = 'Full course name'; -$string['showinactive'] = 'Show inactive students in Overview'; +$string['submittednotcomplete_colour_title'] = 'Submitted but not complete colour'; +$string['time_expected'] = 'Expected'; +$string['why_set_the_title'] = 'Why you might want to set the block instance title?'; +$string['why_set_the_title_help'] = '

There can be multiple instances of the Completion Progress block. You may use different Completion Progress blocks to monitor different sets of activities or resources. For instance you could track progress in assignments in one block and quizzes in another. For this reason you can override the default title and set a more appropriate block title for each instance.

'; +$string['why_show_precentage'] = 'Why show a progress percentage to students?'; +$string['why_show_precentage_help'] = '

It is possible to show an overall percentage of progress to students.

This is calculated as the number of activities completed divided by the total number of activities in the bar.

The progress percentage appears until the student mouses over an item in the bar.

'; +$string['why_use_icons'] = 'Why you might want to use icons?'; +$string['why_use_icons_help'] = '

You may wish to add tick and cross icons in the Completion Progress to make this block more visually accessible for students with colour-blindness.

It may also make the meaning of the block clearer if you believe colours are not intuitive, either for cultural or personal reasons.

'; $string['wrapafter'] = 'When wrapping, limit rows to'; -$string['defaultlongbars'] = 'Default presentation for long bars'; - -// Overview page strings. -$string['lastonline'] = 'Last in course'; -$string['overview'] = 'Overview of students'; -$string['progress'] = 'Progress'; -$string['progressbar'] = 'Completion Progress'; - -// For capabilities. -$string['completion_progress:overview'] = 'View course overview of Completion Progresss for all students'; -$string['completion_progress:addinstance'] = 'Add a new Completion Progress block'; -$string['completion_progress:myaddinstance'] = 'Add a Completion Progress block to My home page'; -$string['completion_progress:showbar'] = 'Show the bar in the Completion Progress block'; - -// For My home page. -$string['no_blocks'] = "No Completion Progress blocks are set up for your courses."; diff --git a/lib.php b/lib.php index 2428b26..f381418 100644 --- a/lib.php +++ b/lib.php @@ -120,6 +120,7 @@ function block_completion_progress_course_submissions($courseid) { $submissions[] = $mapping; } } + return $submissions; } @@ -129,10 +130,8 @@ function block_completion_progress_course_submissions($courseid) { * @return array URLs and associated capabilities, per activity */ function block_completion_progress_modules_with_alternate_links() { - return array( + $alternatelinks = array( 'assign' => array( - // The following can be used when MDL-52133 is resolved - // 'url' => '/mod/assign/view.php?id=:cmid&action=grade&userid=:userid&rownum=0', 'url' => '/mod/assign/view.php?id=:cmid&action=grading', 'capability' => 'mod/assign:grade', ), @@ -150,6 +149,12 @@ function block_completion_progress_modules_with_alternate_links() { 'capability' => 'mod/quiz:viewreports', ), ); + + if ($CFG->version > 2015111604) { + $alternatelinks['assign']['url'] = '/mod/assign/view.php?id=:cmid&action=grade&userid=:userid'; + } + + return $alternatelinks; } /** @@ -164,7 +169,6 @@ function block_completion_progress_get_activities($courseid, $config = null, $fo $modinfo = get_fast_modinfo($courseid, -1); $sections = $modinfo->get_sections(); $activities = array(); - foreach ($modinfo->instances as $module => $instances) { $modulename = get_string('pluginname', $module); foreach ($instances as $index => $cm) { @@ -184,7 +188,7 @@ function block_completion_progress_get_activities($courseid, $config = null, $fo 'expected' => $cm->completionexpected, 'section' => $cm->sectionnum, 'position' => array_search($cm->id, $sections[$cm->sectionnum]), - 'url' => $cm->url->out(), + 'url' => method_exists($cm->url, 'out') ? $cm->url->out() : '', 'context' => $cm->context, 'icon' => $cm->get_icon_url(), 'available' => $cm->available, @@ -342,10 +346,10 @@ function block_completion_progress_bar($activities, $completions, $config, $user // Get colours and use defaults if they are not set in global settings. $colournames = array( - 'attempted_colour' => 'attempted_colour', + 'completed_colour' => 'completed_colour', 'submittednotcomplete_colour' => 'submittednotcomplete_colour', - 'notattempted_colour' => 'notAttempted_colour', - 'futurenotattempted_colour' => 'futureNotAttempted_colour' + 'notCompleted_colour' => 'notCompleted_colour', + 'futureNotCompleted_colour' => 'futureNotCompleted_colour' ); $colours = array(); foreach ($colournames as $name => $stringkey) { @@ -457,23 +461,23 @@ function block_completion_progress_bar($activities, $completions, $config, $user $cellcontent = $OUTPUT->pix_icon('blank', '', 'block_completion_progress'); } else if ($complete === true) { - $celloptions['style'] .= $colours['attempted_colour'].';'; + $celloptions['style'] .= $colours['completed_colour'].';'; $cellcontent = $OUTPUT->pix_icon($useicons == 1 ? 'tick' : 'blank', '', 'block_completion_progress'); } else if ( (!isset($config->orderby) || $config->orderby == 'orderbytime') && (isset($activity['expected']) && $activity['expected'] > 0 && $activity['expected'] < $now) ) { - $celloptions['style'] .= $colours['notattempted_colour'].';'; + $celloptions['style'] .= $colours['notCompleted_colour'].';'; $cellcontent = $OUTPUT->pix_icon($useicons == 1 ? 'cross' : 'blank', '', 'block_completion_progress'); } else { - $celloptions['style'] .= $colours['futurenotattempted_colour'].';'; + $celloptions['style'] .= $colours['futureNotCompleted_colour'].';'; $cellcontent = $OUTPUT->pix_icon('blank', '', 'block_completion_progress'); } if (!empty($activity['available']) || $simple) { $celloptions['onclick'] = 'document.location=\''.$activity['link'].'\';'; - } else { + } else if (!empty($activity['link'])) { $celloptions['style'] .= 'cursor: not-allowed;'; } if ($longbars != 'wrap' && $counter == 1) { @@ -523,7 +527,7 @@ function block_completion_progress_bar($activities, $completions, $config, $user $text .= html_writer::empty_tag('img', array('src' => $activity['icon'], 'class' => 'moduleIcon', 'alt' => '', 'role' => 'presentation')); $text .= s($activity['name']); - if (!empty($activity['available']) || $simple) { + if (!empty($activity['link']) && (!empty($activity['available']) || $simple)) { $content .= $OUTPUT->action_link($activity['link'], $text); } else { $content .= $text; diff --git a/overview.php b/overview.php index 8331edd..591eb48 100644 --- a/overview.php +++ b/overview.php @@ -28,10 +28,10 @@ require_once(dirname(__FILE__) . '/../../config.php'); require_once($CFG->dirroot.'/blocks/completion_progress/lib.php'); require_once($CFG->libdir.'/tablelib.php'); -define('USER_SMALL_CLASS', 20); // Below this is considered small. -define('USER_LARGE_CLASS', 200); // Above this is considered large. -define('DEFAULT_PAGE_SIZE', 20); -define('SHOW_ALL_PAGE_SIZE', 5000); +const USER_SMALL_CLASS = 20; // Below this is considered small. +const USER_LARGE_CLASS = 200; // Above this is considered large. +const DEFAULT_PAGE_SIZE = 20; +const SHOW_ALL_PAGE_SIZE = 5000; // Gather form data. $id = required_param('instanceid', PARAM_INT); diff --git a/settings.php b/settings.php index 0866833..13b33fa 100644 --- a/settings.php +++ b/settings.php @@ -59,10 +59,10 @@ if ($ADMIN->fulltree) { $options) ); - $settings->add(new admin_setting_configcolourpicker('block_completion_progress/attempted_colour', - get_string('attempted_colour_title', 'block_completion_progress'), - get_string('attempted_colour_descr', 'block_completion_progress'), - get_string('attempted_colour', 'block_completion_progress'), + $settings->add(new admin_setting_configcolourpicker('block_completion_progress/completed_colour', + get_string('completed_colour_title', 'block_completion_progress'), + get_string('completed_colour_descr', 'block_completion_progress'), + get_string('completed_colour', 'block_completion_progress'), null ) ); @@ -73,17 +73,17 @@ if ($ADMIN->fulltree) { null ) ); - $settings->add(new admin_setting_configcolourpicker('block_completion_progress/notattempted_colour', - get_string('notattempted_colour_title', 'block_completion_progress'), - get_string('notattempted_colour_descr', 'block_completion_progress'), - get_string('notAttempted_colour', 'block_completion_progress'), + $settings->add(new admin_setting_configcolourpicker('block_completion_progress/notCompleted_colour', + get_string('notCompleted_colour_title', 'block_completion_progress'), + get_string('notCompleted_colour_descr', 'block_completion_progress'), + get_string('notCompleted_colour', 'block_completion_progress'), null ) ); - $settings->add(new admin_setting_configcolourpicker('block_completion_progress/futurenotattempted_colour', - get_string('futurenotattempted_colour_title', 'block_completion_progress'), - get_string('futurenotattempted_colour_descr', 'block_completion_progress'), - get_string('futureNotAttempted_colour', 'block_completion_progress'), + $settings->add(new admin_setting_configcolourpicker('block_completion_progress/futureNotCompleted_colour', + get_string('futureNotCompleted_colour_title', 'block_completion_progress'), + get_string('futureNotCompleted_colour_descr', 'block_completion_progress'), + get_string('futureNotCompleted_colour', 'block_completion_progress'), null ) ); diff --git a/version.php b/version.php index 11d7aeb..83f6ac7 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2016050100; +$plugin->version = 2016051400; $plugin->requires = 2014051200; // Moodle 2.7. -$plugin->maturity = MATURITY_BETA; +$plugin->maturity = MATURITY_RC; $plugin->release = 'Version for Moodle 2.7 onwards'; $plugin->component = 'block_completion_progress';