Skip to content

Commit

Permalink
MDL-20995 Blog entries correctly displayed in activity reports
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Oct 30, 2009
1 parent 730d28c commit 5a5cd65
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 24 deletions.
94 changes: 70 additions & 24 deletions course/report/outline/index.php
Expand Up @@ -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);
Expand All @@ -43,15 +44,21 @@
print_error('logfilenotavailable');
}

echo '<div class="loginfo">'.get_string('computedfromlogs', 'admin', userdate($logstart)).'</div>';
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 '<table id="outlinetable" class="generaltable boxaligncenter" cellpadding="5"><tr>';
echo '<th class="header c0" scope="col">'.$stractivity.'</th>';
echo '<th class="header c1" scope="col">'.$strviews.'</th>';
if ($showlastaccess) {
echo '<th class="header c2" scope="col">'.$strlast.'</th>';
$outlinetable->head[] = $strlast;
}
echo '</tr>';

$modinfo = get_fast_modinfo($course);

Expand All @@ -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) {
Expand All @@ -75,41 +81,81 @@
continue;
}
if ($prevsecctionnum != $sectionnum) {
echo '<tr class="r'.$ri++.' section"><td colspan="3"><h3>';
$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.'</h3></td></tr>';

$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 '<tr class="r'.$ri++.'">';
echo "<td class=\"cell c0 actvity\"><img src=\"" . $OUTPUT->mod_icon_url('icon', $cm->modname) . "\" class=\"icon\" alt=\"$modulename\" />";
echo "<a $dimmed title=\"$modulename\" href=\"$CFG->wwwroot/mod/$cm->modname/view.php?id=$cm->id\">".format_string($cm->name)."</a></td>";
echo "<td class=\"cell c1 numviews\">";

$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 "</td>";

$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 "<td class=\"cell c2 lastaccess\">";
$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 "</td>";
$reportrow->cells[] = $lastaccesscell;
}
echo '</tr>';
$outlinetable->data[] = $reportrow;
}
}
echo '</table>';
echo $OUTPUT->table($outlinetable);

echo $OUTPUT->footer();

Expand Down
2 changes: 2 additions & 0 deletions course/reset_form.php
Expand Up @@ -14,6 +14,8 @@ function definition (){
$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'));
Expand Down

0 comments on commit 5a5cd65

Please sign in to comment.