From 5a5cd650fc843537acda33cb86b84930342ab085 Mon Sep 17 00:00:00 2001 From: Nicolas Connault Date: Fri, 30 Oct 2009 07:27:19 +0000 Subject: [PATCH] MDL-20995 Blog entries correctly displayed in activity reports --- course/report/outline/index.php | 94 ++++++++++++++++++++++++--------- course/reset_form.php | 2 + 2 files changed, 72 insertions(+), 24 deletions(-) diff --git a/course/report/outline/index.php b/course/report/outline/index.php index dd84571740..19ba73e5df 100644 --- a/course/report/outline/index.php +++ b/course/report/outline/index.php @@ -31,6 +31,7 @@ $strlast = get_string('lastaccess'); $strreports = get_string('reports'); $strviews = get_string('views'); + $strrelatedblogentries = get_string('relatedblogentries', 'blog'); $PAGE->set_title($course->shortname .': '. $stractivityreport); $PAGE->set_heading($course->fullname); @@ -43,15 +44,21 @@ print_error('logfilenotavailable'); } - echo '
'.get_string('computedfromlogs', 'admin', userdate($logstart)).'
'; + echo $OUTPUT->container(get_string('computedfromlogs', 'admin', userdate($logstart)), 'loginfo'); + + $outlinetable = new html_table(); + $outlinetable->add_class('generaltable boxaligncenter'); + $outlinetable->cellpadding = 5; + $outlinetable->id = 'outlinetable'; + $outlinetable->head = array($stractivity, $strviews); + + if ($CFG->useblogassociations) { + $outlinetable->head[] = $strrelatedblogentries; + } - echo ''; - echo ''; - echo ''; if ($showlastaccess) { - echo ''; + $outlinetable->head[] = $strlast; } - echo ''; $modinfo = get_fast_modinfo($course); @@ -63,7 +70,6 @@ GROUP BY cm.id"; $views = $DB->get_records_sql($sql, array($course->id)); - $ri = 0; $prevsecctionnum = 0; foreach ($modinfo->sections as $sectionnum=>$section) { foreach ($section as $cmid) { @@ -75,41 +81,81 @@ continue; } if ($prevsecctionnum != $sectionnum) { - echo ''; + + $sectioncell->text = $OUTPUT->heading($sectiontitle . ' ' . $sectionnum, 3); + $sectionrow->cells[] = $sectioncell; + $outlinetable->data[] = $sectionrow; $prevsecctionnum = $sectionnum; } $dimmed = $cm->visible ? '' : 'class="dimmed"'; $modulename = get_string('modulename', $cm->modname); - echo ''; - echo ""; - echo ""; + + $reportrow->cells[] = $numviewscell; + + if ($CFG->useblogassociations) { + $blogcell = new html_table_cell(); + $blogcell->add_class('blog'); + if ($blogcount = blog_get_associated_count($course->id, $cm->id)) { + $blogcell->text = $OUTPUT->link(html_link::make('/blog/index.php?modid='.$cm->id, $blogcount)); + } else { + $blogcell->text = '-'; + } + $reportrow->cells[] = $blogcell; + } + if ($showlastaccess) { - echo ""; + $reportrow->cells[] = $lastaccesscell; } - echo ''; + $outlinetable->data[] = $reportrow; } } - echo '
'.$stractivity.''.$strviews.''.$strlast.'

'; + $sectionrow = new html_table_row(); + $sectionrow->add_class('section'); + $sectioncell = new html_table_cell(); + $sectioncell->colspan = count($outlinetable->head); + + $sectiontitle = ''; switch ($course->format) { - case 'weeks': print_string('week'); break; - case 'topics': print_string('topic'); break; - default: print_string('section'); break; + case 'weeks': $sectiontitle = get_string('week'); break; + case 'topics': $sectiontitle = get_string('topic'); break; + default: $sectiontitle = get_string('section'); break; } - echo ' '.$sectionnum.'

mod_icon_url('icon', $cm->modname) . "\" class=\"icon\" alt=\"$modulename\" />"; - echo "wwwroot/mod/$cm->modname/view.php?id=$cm->id\">".format_string($cm->name).""; + + $reportrow = new html_table_row(); + $activitycell = new html_table_cell(); + $activitycell->add_class('activity'); + + $activityicon = html_image::make($OUTPUT->mod_icon_url('icon', $cm->modname)); + $activityicon->add_class('icon'); + $activityicon->alt = $modulename; + + $activitylink = html_link::make("$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id", format_string($cm->name)); + if (!$cm->visible) { + $activitylink->add_class('dimmed'); + } + + $activitycell->text = $OUTPUT->image($activityicon) . $OUTPUT->link($activitylink); + + $reportrow->cells[] = $activitycell; + + $numviewscell = new html_table_cell(); + $numviewscell->add_class('numviews'); + if (!empty($views[$cm->id]->numviews)) { - echo $views[$cm->id]->numviews; + $numviewscell->text = $views[$cm->id]->numviews; } else { - echo '-'; + $numviewscell->text = '-'; } - echo ""; + $lastaccesscell = new html_table_cell(); + $lastaccesscell->add_class('lastaccess'); + if (isset($views[$cm->id]->lasttime)) { $timeago = format_time(time() - $views[$cm->id]->lasttime); - echo userdate($views[$cm->id]->lasttime)." ($timeago)"; + $lastaccesscell->text = userdate($views[$cm->id]->lasttime)." ($timeago)"; } - echo "
'; + echo $OUTPUT->table($outlinetable); echo $OUTPUT->footer(); diff --git a/course/reset_form.php b/course/reset_form.php index 10da1c9890..88b19793ff 100644 --- a/course/reset_form.php +++ b/course/reset_form.php @@ -14,6 +14,8 @@ class course_reset_form extends moodleform { $mform->addElement('checkbox', 'reset_events', get_string('deleteevents', 'calendar')); $mform->addElement('checkbox', 'reset_logs', get_string('deletelogs')); $mform->addElement('checkbox', 'reset_notes', get_string('deletenotes', 'notes')); + $mform->addElement('checkbox', 'delete_blog_associations', get_string('deleteblogassociations', 'blog')); + $mform->setHelpButton('delete_blog_associations', array('deleteblogassociations', get_string('deleteblogassociations', 'blog'), 'blog')); $mform->addElement('header', 'rolesheader', get_string('roles')); -- 2.39.5