Exemplo n.º 1
0
/**
 * Print single activity item prepared by {@see hotpot_get_recent_mod_activity()}
 *
 * This function is called from: {@link course/recent.php}
 *
 * @param object $activity an object created by {@link get_recent_mod_activity()}
 * @param integer $courseid id in the "course" table
 * @param boolean $detail
 *         true : print a link to the hotpot activity
 *         false : do no print a link to the hotpot activity
 * @param xxx $modnames
 * @param xxx $viewfullnames
 * @return no return value is required
 */
function hotpot_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames)
{
    global $CFG, $OUTPUT;
    require_once $CFG->dirroot . '/mod/hotpot/locallib.php';
    static $dateformat = null;
    if (is_null($dateformat)) {
        $dateformat = get_string('strftimerecentfull');
    }
    $table = new html_table();
    $table->cellpadding = 3;
    $table->cellspacing = 0;
    if ($detail) {
        $row = new html_table_row();
        $cell = new html_table_cell(' ', array('width' => 15));
        $row->cells[] = $cell;
        // activity icon and link to activity
        $src = $OUTPUT->pix_url('icon', $activity->type);
        $img = html_writer::tag('img', array('src' => $src, 'class' => 'icon', $alt => $activity->name));
        // link to activity
        $href = new moodle_url('/mod/hotpot/view.php', array('id' => $activity->cmid));
        $link = html_writer::link($href, $activity->name);
        $cell = new html_table_cell("{$img} {$link}");
        $cell->colspan = 6;
        $row->cells[] = $cell;
        $table->data[] = new html_table_row(array(new html_table_cell(' ', array('width' => 15)), new html_table_cell("{$img} {$link}")));
        $table->data[] = $row;
    }
    $row = new html_table_row();
    // set rowspan to (number of attempts) + 1
    $rowspan = count($activity->attempts) + 1;
    $cell = new html_table_cell(' ', array('width' => 15));
    $cell->rowspan = $rowspan;
    $row->cells[] = $cell;
    $picture = $OUTPUT->user_picture($activity->user, array('courseid' => $courseid));
    $cell = new html_table_cell($picture, array('width' => 35, 'valign' => 'top', 'class' => 'forumpostpicture'));
    $cell->rowspan = $rowspan;
    $row->cells[] = $cell;
    $href = new moodle_url('/user/view.php', array('id' => $activity->user->userid, 'course' => $courseid));
    $cell = new html_table_cell(html_writer::link($href, $activity->user->fullname));
    $cell->colspan = 5;
    $row->cells[] = $cell;
    $table->data[] = $row;
    foreach ($activity->attempts as $attempt) {
        if ($attempt->duration) {
            $duration = '(' . hotpot::format_time($attempt->duration) . ')';
        } else {
            $duration = ' ';
        }
        $href = new moodle_url('/mod/hotpot/review.php', array('id' => $attempt->id));
        $link = html_writer::link($href, userdate($attempt->timemodified, $dateformat));
        $table->data[] = new html_table_row(array(new html_table_cell($attempt->attempt), new html_table_cell($attempt->score . '%'), new html_table_cell(hotpot::format_status($attempt->status, true)), new html_table_cell($link), new html_table_cell($duration)));
    }
    echo html_writer::table($table);
}