Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-32769 course: Adding completion summary to course sections

  • Loading branch information...
commit 7c05cd0e1f413c1a81cd3c5297946c1041ec2f29 1 parent f4a9bf6
@ankitagarwal ankitagarwal authored
Showing with 23 additions and 2 deletions.
  1. +22 −2 course/format/renderer.php
  2. +1 −0  lang/en/moodle.php
View
24 course/format/renderer.php
@@ -296,7 +296,7 @@ protected function section_summary($section, $course, $mods) {
$o.= html_writer::start_tag('div', array('class' => 'summarytext'));
$o.= $this->format_summary_text($section);
$o.= html_writer::end_tag('div');
- $o.= $this->section_activity_summary($section, $mods);
+ $o.= $this->section_activity_summary($section, $course, $mods);
$o.= $this->section_availability_message($section);
@@ -310,16 +310,20 @@ protected function section_summary($section, $course, $mods) {
* Generate a summary of the activites in a section
*
* @param stdClass $section The course_section entry from DB
+ * @param stdClass $course the course record from DB
* @param array $mods course modules indexed by id (from get_all_mods)
* @return string HTML to output.
*/
- private function section_activity_summary($section, $mods) {
+ private function section_activity_summary($section, $course, $mods) {
+ $completioninfo = new completion_info($course);
if (empty($section->sequence)) {
return '';
}
// Generate array with count of activities in this section:
$sectionmods = array();
+ $total = 0;
+ $complete = 0;
$modsequence = explode(',', $section->sequence);
foreach ($modsequence as $cmid) {
$thismod = $mods[$cmid];
@@ -336,6 +340,14 @@ private function section_activity_summary($section, $mods) {
$sectionmods[$thismod->modname]['name'] = $thismod->modplural;
$sectionmods[$thismod->modname]['count'] = 1;
}
+ if ($completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE && isloggedin() &&
+ !isguestuser() && $thismod->uservisible) {
+ $total++;
+ $completiondata = $completioninfo->get_data($thismod,true);
+ if ($completiondata->completionstate == COMPLETION_COMPLETE) {
+ $complete++;
+ }
+ }
}
}
@@ -352,6 +364,14 @@ private function section_activity_summary($section, $mods) {
$o.= $mod['name'].': '.$mod['count'];
$o.= html_writer::end_tag('span');
}
+
+ // Output section completion data
+ if ($completioninfo->is_enabled() != COMPLETION_TRACKING_NONE && isloggedin() &&
+ !isguestuser()) {
+ $o.= html_writer::start_tag('span', array('class' => 'activity-count'));
+ $o.= get_string("completionstatus")." $complete / $total";
+ $o.= html_writer::end_tag('span');
+ }
$o.= html_writer::end_tag('div');
return $o;
}
View
1  lang/en/moodle.php
@@ -252,6 +252,7 @@
$string['comparelanguage'] = 'Compare and edit current language';
$string['complete'] = 'Complete';
$string['completereport'] = 'Complete report';
+$string['completionstatus'] = 'Completion status:';
$string['configuration'] = 'Configuration';
$string['confirm'] = 'Confirm';
$string['confirmed'] = 'Your registration has been confirmed';
Please sign in to comment.
Something went wrong with that request. Please try again.