From 7c05cd0e1f413c1a81cd3c5297946c1041ec2f29 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Wed, 20 Jun 2012 09:33:32 +0800 Subject: [PATCH 1/4] MDL-32769 course: Adding completion summary to course sections --- course/format/renderer.php | 24 ++++++++++++++++++++++-- lang/en/moodle.php | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/course/format/renderer.php b/course/format/renderer.php index 8de249c6286..ddbfcef536c 100644 --- a/course/format/renderer.php +++ b/course/format/renderer.php @@ -296,7 +296,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base { $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 @@ abstract class format_section_renderer_base extends plugin_renderer_base { * 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 @@ abstract class format_section_renderer_base extends plugin_renderer_base { $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 @@ abstract class format_section_renderer_base extends plugin_renderer_base { $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; } diff --git a/lang/en/moodle.php b/lang/en/moodle.php index ba5553ce062..b1699a34649 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -252,6 +252,7 @@ $string['commentsrequirelogin'] = 'You need to login to view the comments'; $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'; From 68b8cc84af58ec4c54b6e9d16b18578a87a4d39f Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Thu, 21 Jun 2012 13:29:46 +0800 Subject: [PATCH 2/4] MDL-32769 course: Do not show a completion status of 0/0 --- course/format/renderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/course/format/renderer.php b/course/format/renderer.php index ddbfcef536c..83a2e4bbc12 100644 --- a/course/format/renderer.php +++ b/course/format/renderer.php @@ -367,7 +367,7 @@ abstract class format_section_renderer_base extends plugin_renderer_base { // Output section completion data if ($completioninfo->is_enabled() != COMPLETION_TRACKING_NONE && isloggedin() && - !isguestuser()) { + !isguestuser() && $total !== 0) { $o.= html_writer::start_tag('span', array('class' => 'activity-count')); $o.= get_string("completionstatus")." $complete / $total"; $o.= html_writer::end_tag('span'); From dce49c1c38f2ef595473fe3396be1690f6644bf8 Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Thu, 21 Jun 2012 16:16:48 +0800 Subject: [PATCH 3/4] MDL-32769 course: Moving the completion status to a new line --- course/format/renderer.php | 7 +++++-- lang/en/moodle.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/course/format/renderer.php b/course/format/renderer.php index 83a2e4bbc12..77caeda7abc 100644 --- a/course/format/renderer.php +++ b/course/format/renderer.php @@ -364,15 +364,18 @@ abstract class format_section_renderer_base extends plugin_renderer_base { $o.= $mod['name'].': '.$mod['count']; $o.= html_writer::end_tag('span'); } + $o.= html_writer::end_tag('div'); // Output section completion data if ($completioninfo->is_enabled() != COMPLETION_TRACKING_NONE && isloggedin() && !isguestuser() && $total !== 0) { + $o.= html_writer::start_tag('div', array('class' => 'section-summary-activities mdl-right')); $o.= html_writer::start_tag('span', array('class' => 'activity-count')); - $o.= get_string("completionstatus")." $complete / $total"; + $o.= get_string("progress")." $complete / $total"; $o.= html_writer::end_tag('span'); + $o.= html_writer::end_tag('div'); } - $o.= html_writer::end_tag('div'); + return $o; } diff --git a/lang/en/moodle.php b/lang/en/moodle.php index b1699a34649..2419f019311 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -252,7 +252,6 @@ $string['commentsrequirelogin'] = 'You need to login to view the comments'; $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'; @@ -1332,6 +1331,7 @@ $string['previoussection'] = 'Previous section'; $string['primaryadminsetup'] = 'Setup administrator account'; $string['profile'] = 'Profile'; $string['profilenotshown'] = 'This profile description will not be shown until this person is enrolled in at least one course.'; +$string['progress'] = 'Progress:'; $string['publicprofile'] = 'Public profile'; $string['publicsitefileswarning'] = 'Note: files placed here can be accessed by anyone'; $string['publicsitefileswarning2'] = 'Note: Files placed here can be accessed by anyone who knows (or can guess) the URL. For security reasons, it is recommended that any backup files are deleted immediately after restoring them.'; From 0e5533b607a8ed2f10a046aa25fc4d49ec2b75e1 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Fri, 22 Jun 2012 10:42:56 +1200 Subject: [PATCH 4/4] MDL-32769 completion: Fixed up display of completion information --- course/format/renderer.php | 19 ++++++++++--------- lang/en/completion.php | 1 + lang/en/moodle.php | 1 - 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/course/format/renderer.php b/course/format/renderer.php index 77caeda7abc..b7c0e21a5a6 100644 --- a/course/format/renderer.php +++ b/course/format/renderer.php @@ -315,7 +315,6 @@ abstract class format_section_renderer_base extends plugin_renderer_base { * @return string HTML to output. */ private function section_activity_summary($section, $course, $mods) { - $completioninfo = new completion_info($course); if (empty($section->sequence)) { return ''; } @@ -324,6 +323,8 @@ abstract class format_section_renderer_base extends plugin_renderer_base { $sectionmods = array(); $total = 0; $complete = 0; + $cancomplete = isloggedin() && !isguestuser(); + $completioninfo = new completion_info($course); $modsequence = explode(',', $section->sequence); foreach ($modsequence as $cmid) { $thismod = $mods[$cmid]; @@ -340,10 +341,9 @@ abstract class format_section_renderer_base extends plugin_renderer_base { $sectionmods[$thismod->modname]['name'] = $thismod->modplural; $sectionmods[$thismod->modname]['count'] = 1; } - if ($completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE && isloggedin() && - !isguestuser() && $thismod->uservisible) { + if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) { $total++; - $completiondata = $completioninfo->get_data($thismod,true); + $completiondata = $completioninfo->get_data($thismod, true); if ($completiondata->completionstate == COMPLETION_COMPLETE) { $complete++; } @@ -367,12 +367,13 @@ abstract class format_section_renderer_base extends plugin_renderer_base { $o.= html_writer::end_tag('div'); // Output section completion data - if ($completioninfo->is_enabled() != COMPLETION_TRACKING_NONE && isloggedin() && - !isguestuser() && $total !== 0) { + if ($total > 0) { + $a = new stdClass; + $a->complete = $complete; + $a->total = $total; + $o.= html_writer::start_tag('div', array('class' => 'section-summary-activities mdl-right')); - $o.= html_writer::start_tag('span', array('class' => 'activity-count')); - $o.= get_string("progress")." $complete / $total"; - $o.= html_writer::end_tag('span'); + $o.= html_writer::tag('span', get_string('progresstotal', 'completion', $a), array('class' => 'activity-count')); $o.= html_writer::end_tag('div'); } diff --git a/lang/en/completion.php b/lang/en/completion.php index f1de5c03037..0683c79b85b 100644 --- a/lang/en/completion.php +++ b/lang/en/completion.php @@ -78,6 +78,7 @@ $string['err_system'] = 'An internal error occurred in the completion system. (S $string['excelcsvdownload'] = 'Download in Excel-compatible format (.csv)'; $string['progress'] = 'Student progress'; $string['progress-title'] = '{$a->user}, {$a->activity}: {$a->state} {$a->date}'; +$string['progresstotal'] = 'Progress: {$a->complete} / {$a->total}'; $string['reportpage'] = 'Showing users {$a->from} to {$a->to} of {$a->total}.'; $string['restoringcompletiondata'] = 'Writing completion data'; $string['saved'] = 'Saved'; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 2419f019311..ba5553ce062 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1331,7 +1331,6 @@ $string['previoussection'] = 'Previous section'; $string['primaryadminsetup'] = 'Setup administrator account'; $string['profile'] = 'Profile'; $string['profilenotshown'] = 'This profile description will not be shown until this person is enrolled in at least one course.'; -$string['progress'] = 'Progress:'; $string['publicprofile'] = 'Public profile'; $string['publicsitefileswarning'] = 'Note: files placed here can be accessed by anyone'; $string['publicsitefileswarning2'] = 'Note: Files placed here can be accessed by anyone who knows (or can guess) the URL. For security reasons, it is recommended that any backup files are deleted immediately after restoring them.';