create_overview_table($hotpot, $cm, $course, $users, $attempts, $questions, $options, $tables);
$this->print_report($course, $hotpot, $tables, $options);
return true;
}
function create_overview_table(&$hotpot, &$cm, &$course, &$users, &$attempts, &$questions, &$options, &$tables) {
global $CFG;
$strtimeformat = get_string('strftimedatetime');
$is_html = ($options['reportformat']=='htm');
$spacer = $is_html ? ' ' : ' ';
$br = $is_html ? "
\n" : "\n";
// initialize $table
unset($table);
$table->border = 1;
$table->width = 10;
$table->head = array();
$table->align = array();
$table->size = array();
$table->wrap = array();
// picture column, if required
if ($is_html) {
$table->head[] = $spacer;
$table->align[] = 'center';
$table->size[] = 10;
$table->wrap[] = "nowrap";
}
array_push($table->head,
get_string("name"),
hotpot_grade_heading($hotpot, $options),
get_string("attempt", "quiz"),
get_string("time", "quiz"),
get_string("reportstatus", "hotpot"),
get_string("timetaken", "quiz"),
get_string("score", "quiz")
);
array_push($table->align, "left", "center", "center", "left", "center", "center", "center");
array_push($table->wrap, "nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap", "nowrap");
array_push($table->size, "*", "*", "*", "*", "*", "*", "*");
$abandoned = 0;
foreach ($users as $user) {
// shortcut to user info held in first attempt record
$u = &$user->attempts[0];
$picture = '';
$name = fullname($u);
if ($is_html) {
$picture = print_user_picture($u->userid, $course->id, $u->picture, false, true);
$name = ''.$name.'';
}
$grade = isset($user->grade) && $user->grade<>' ' ? $user->grade : $spacer;
$attemptcount = count($user->attempts);
if ($attemptcount>1) {
$text = $name;
$name = NULL;
$name->text = $text;
$name->rowspan = $attemptcount;
$text = $grade;
$grade = NULL;
$grade->text = $text;
$grade->rowspan = $attemptcount;
}
$data = array();
if ($is_html) {
if ($attemptcount>1) {
$text = $picture;
$picture = NULL;
$picture->text = $text;
$picture->rowspan = $attemptcount;
}
$data[] = $picture;
}
array_push($data, $name, $grade);
foreach ($user->attempts as $attempt) {
// increment count of abandoned attempts
// if attempt is marked as finished but has no score
if ($attempt->status==HOTPOT_STATUS_ABANDONED) {
$abandoned++;
}
$attemptnumber = $attempt->attempt;
$starttime = trim(userdate($attempt->timestart, $strtimeformat));
if ($is_html && isset($attempt->score) && (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review)) {
$attemptnumber = ''.$attemptnumber.'';
$starttime = ''.$starttime.'';
}
if ($is_html && has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id))) {
$checkbox = ''.$spacer;
} else {
$checkbox = '';
}
$timetaken = empty($attempt->timefinish) ? $spacer : format_time($attempt->timefinish - $attempt->timestart);
$score = hotpot_format_score($attempt);
if ($is_html && is_numeric($score) && $score==$user->grade) { // best grade
$score = ''.$score.'';
}
array_push($data,
$attemptnumber,
$checkbox.$starttime,
hotpot_format_status($attempt),
$timetaken,
$score
);
$table->data[] = $data;
$data = array();
} // end foreach $attempt
$table->data[] = 'hr';
} // end foreach $user
// remove final 'hr' from data rows
array_pop($table->data);
// add the "delete" form to the table
if ($options['reportformat']=='htm' && has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id))) {
$strdeletecheck = get_string('deleteattemptcheck','quiz');
$table->start = $this->deleteform_javascript();
$table->start .= '