mirror of
https://github.com/moodle/moodle.git
synced 2025-04-29 21:09:52 +02:00
MDL-14857 - Clean up summary table generation code at the top of the quiz review page - This is basically a merge of improvements we made at the OU.
This commit is contained in:
parent
25b05ce567
commit
9c22b42ef7
@ -384,6 +384,8 @@ $string['onlyteachersimport'] = 'Only teachers with editing rights can import qu
|
||||
$string['openclosedatesupdated'] = 'Quiz open and close dates updated';
|
||||
$string['optional'] = 'optional';
|
||||
$string['outof'] = '$a->grade out of a maximum of $a->maxgrade';
|
||||
$string['outofpercent'] = '$a->grade out of a maximum of $a->maxgrade ($a->percent%%)';
|
||||
$string['outofshort'] = '$a->grade/$a->maxgrade';
|
||||
$string['overallfeedback'] = 'Overall feedback';
|
||||
$string['overdue'] = 'Overdue';
|
||||
$string['pagesize'] = 'Attempts shown per page:';
|
||||
|
@ -128,11 +128,9 @@
|
||||
$accessmanager->print_finish_review_link($canpreview);
|
||||
}
|
||||
|
||||
/// Print infobox
|
||||
/// Work out some time-related things.
|
||||
$timelimit = (int)$quiz->timelimit * 60;
|
||||
$overtime = 0;
|
||||
$grade = quiz_rescale_grade($attempt->sumgrades, $quiz);
|
||||
$feedback = quiz_feedback_for_grade($grade, $attempt->quiz);
|
||||
|
||||
if ($attempt->timefinish) {
|
||||
if ($timetaken = ($attempt->timefinish - $attempt->timestart)) {
|
||||
@ -147,39 +145,54 @@
|
||||
} else {
|
||||
$timetaken = get_string('unfinished', 'quiz');
|
||||
}
|
||||
echo '<table class="generaltable generalbox quizreviewsummary"><tbody>';
|
||||
|
||||
/// Print summary table about the whole attempt.
|
||||
/// First we assemble all the rows that are appopriate to the current situation in
|
||||
/// an array, then later we only output the table if there are any rows to show.
|
||||
$rows = array();
|
||||
if ($attempt->userid <> $USER->id) {
|
||||
$student = get_record('user', 'id', $attempt->userid);
|
||||
$picture = print_user_picture($student, $course->id, $student->picture, false, true);
|
||||
echo '<tr><th scope="row" class="cell">', $picture, '</th><td class="cell"><a href="', $CFG->wwwroot,
|
||||
'/user/view.php?id=', $student->id, '&course='.$course->id.'">',
|
||||
fullname($student, true), '</a></td></tr>';
|
||||
$rows[] = '<tr><th scope="row" class="cell">' . $picture . '</th><td class="cell"><a href="' .
|
||||
$CFG->wwwroot . '/user/view.php?id=' . $student->id . '&course=' . $course->id . '">' .
|
||||
fullname($student, true) . '</a></td></tr>';
|
||||
}
|
||||
if (has_capability('mod/quiz:grade', $context) and
|
||||
if (has_capability('mod/quiz:viewreports', $context) &&
|
||||
count($attempts = get_records_select('quiz_attempts', "quiz = '$quiz->id' AND userid = '$attempt->userid'", 'attempt ASC')) > 1) {
|
||||
// print list of attempts
|
||||
$attemptlist = '';
|
||||
foreach ($attempts as $at) {
|
||||
$attemptlist .= ($at->id == $attempt->id)
|
||||
? '<strong>'.$at->attempt.'</strong>, '
|
||||
: '<a href="review.php?attempt='.$at->id.($showall?'&showall=true':'').'">'.$at->attempt.'</a>, ';
|
||||
/// List of all this user's attempts for people who can see reports.
|
||||
$urloptions = '';
|
||||
if ($showall) {
|
||||
$urloptions .= '&showall=true';
|
||||
} else if ($page > 0) {
|
||||
$urloptions .= '&page=' . $page;
|
||||
}
|
||||
echo '<tr><th scope="row" class="cell">', get_string('attempts', 'quiz'), '</th><td class="cell">',
|
||||
trim($attemptlist, ' ,'), '</td></tr>';
|
||||
$attemptlist = array();
|
||||
foreach ($attempts as $at) {
|
||||
if ($at->id == $attempt->id) {
|
||||
$attemptlist[] = '<strong>' . $at->attempt . '</strong>';
|
||||
} else {
|
||||
$attemptlist[] = '<a href="review.php?attempt=' . $at->id . $urloptions . ' ">' . $at->attempt . '</a>';
|
||||
}
|
||||
}
|
||||
$rows[] = '<tr><th scope="row" class="cell">' . get_string('attempts', 'quiz') .
|
||||
'</th><td class="cell">' . implode(', ', $attemptlist) . '</td></tr>';
|
||||
}
|
||||
|
||||
echo '<tr><th scope="row" class="cell">', get_string('startedon', 'quiz'), '</th><td class="cell">',
|
||||
userdate($attempt->timestart), '</td></tr>';
|
||||
/// Timing information.
|
||||
$rows[] = '<tr><th scope="row" class="cell">' . get_string('startedon', 'quiz') .
|
||||
'</th><td class="cell">' . userdate($attempt->timestart) . '</td></tr>';
|
||||
if ($attempt->timefinish) {
|
||||
echo '<tr><th scope="row" class="cell">', get_string('completedon', 'quiz'), '</th><td class="cell">',
|
||||
userdate($attempt->timefinish), '</td></tr>';
|
||||
echo '<tr><th scope="row" class="cell">', get_string('timetaken', 'quiz'), '</th><td class="cell">',
|
||||
$timetaken, '</td></tr>';
|
||||
$rows[] = '<tr><th scope="row" class="cell">' . get_string('completedon', 'quiz') . '</th><td class="cell">' .
|
||||
userdate($attempt->timefinish) . '</td></tr>';
|
||||
$rows[] = '<tr><th scope="row" class="cell">' . get_string('timetaken', 'quiz') . '</th><td class="cell">' .
|
||||
$timetaken . '</td></tr>';
|
||||
}
|
||||
if (!empty($overtime)) {
|
||||
echo '<tr><th scope="row" class="cell">', get_string('overdue', 'quiz'), '</th><td class="cell">',$overtime, '</td></tr>';
|
||||
$rows[] = '<tr><th scope="row" class="cell">' . get_string('overdue', 'quiz') . '</th><td class="cell">' . $overtime . '</td></tr>';
|
||||
}
|
||||
//if the student is allowed to see their score
|
||||
|
||||
/// Show scores (if the user is allowed to see scores at the moment).
|
||||
$grade = quiz_rescale_grade($attempt->sumgrades, $quiz);
|
||||
if ($options->scores) {
|
||||
if ($quiz->grade and $quiz->sumgrades) {
|
||||
if($overtime) {
|
||||
@ -187,22 +200,38 @@
|
||||
$result->grade = "0.0";
|
||||
}
|
||||
|
||||
/// Show raw marks only if they are different from the grade (like on the view page.
|
||||
if ($quiz->grade != $quiz->sumgrades) {
|
||||
$a = new stdClass;
|
||||
$a->grade = round($attempt->sumgrades, $CFG->quiz_decimalpoints);
|
||||
$a->maxgrade = $quiz->sumgrades;
|
||||
$rows[] = '<tr><th scope="row" class="cell">' . get_string('marks', 'quiz') . '</th><td class="cell">' .
|
||||
get_string('outofshort', 'quiz', $a) . '</td></tr>';
|
||||
}
|
||||
|
||||
/// Now the scaled grade.
|
||||
$a = new stdClass;
|
||||
$percentage = round(($attempt->sumgrades/$quiz->sumgrades)*100, 0);
|
||||
$a->grade = $grade;
|
||||
$a->grade = '<b>' . $grade . '</b>';
|
||||
$a->maxgrade = $quiz->grade;
|
||||
$rawscore = round($attempt->sumgrades, $CFG->quiz_decimalpoints);
|
||||
echo '<tr><th scope="row" class="cell">', get_string('score', 'quiz'), '</th><td class="cell">',
|
||||
"$rawscore/$quiz->sumgrades ($percentage%)", '</td></tr>';
|
||||
echo '<tr><th scope="row" class="cell">', get_string('grade'), '</th><td class="cell">',
|
||||
get_string('outof', 'quiz', $a), '</td></tr>';
|
||||
$a->percent = '<b>' . round(($attempt->sumgrades/$quiz->sumgrades)*100, 0) . '</b>';
|
||||
$rows[] = '<tr><th scope="row" class="cell">' . get_string('grade') . '</th><td class="cell">' .
|
||||
get_string('outofpercent', 'quiz', $a) . '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
/// Feedback if there is any, and the user is allowed to see it now.
|
||||
$feedback = quiz_feedback_for_grade($grade, $attempt->quiz);
|
||||
if ($options->overallfeedback && $feedback) {
|
||||
echo '<tr><th scope="row" class="cell">', get_string('feedback', 'quiz'), '</th><td class="cell">',
|
||||
$feedback, '</td></tr>';
|
||||
$rows[] = '<tr><th scope="row" class="cell">' . get_string('feedback', 'quiz') .
|
||||
'</th><td class="cell">' . $feedback . '</td></tr>';
|
||||
}
|
||||
|
||||
/// Now output the summary table, if there are any rows to be shown.
|
||||
if (!empty($rows)) {
|
||||
echo '<table class="generaltable generalbox quizreviewsummary"><tbody>', "\n";
|
||||
echo implode("\n", $rows);
|
||||
echo "\n</tbody></table>\n";
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
|
||||
/// Print the navigation panel if required
|
||||
$numpages = quiz_number_of_pages($attempt->layout);
|
||||
|
@ -172,14 +172,6 @@
|
||||
|
||||
print_heading(get_string('summaryofattempts', 'quiz'));
|
||||
|
||||
// Get some strings.
|
||||
$strattempt = get_string("attempt", "quiz");
|
||||
$strtimetaken = get_string("timetaken", "quiz");
|
||||
$strtimecompleted = get_string("timecompleted", "quiz");
|
||||
$strgrade = get_string("grade");
|
||||
$strmarks = get_string('marks', 'quiz');
|
||||
$strfeedback = get_string('feedback', 'quiz');
|
||||
|
||||
// Work out which columns we need, taking account what data is available in each attempt.
|
||||
list($someoptions, $alloptions) = quiz_get_combined_reviewoptions($quiz, $attempts, $context);
|
||||
|
||||
@ -192,26 +184,26 @@
|
||||
|
||||
// Prepare table header
|
||||
$table->class = 'generaltable quizattemptsummary';
|
||||
$table->head = array($strattempt, $strtimecompleted);
|
||||
$table->align = array("center", "left");
|
||||
$table->size = array("", "");
|
||||
$table->head = array(get_string('attempt', 'quiz'), get_string('timecompleted', 'quiz'));
|
||||
$table->align = array('center', 'left');
|
||||
$table->size = array('', '');
|
||||
if ($markcolumn) {
|
||||
$table->head[] = "$strmarks / $quiz->sumgrades";
|
||||
$table->head[] = get_string('marks', 'quiz') . " / $quiz->sumgrades";
|
||||
$table->align[] = 'center';
|
||||
$table->size[] = '';
|
||||
}
|
||||
if ($gradecolumn) {
|
||||
$table->head[] = "$strgrade / $quiz->grade";
|
||||
$table->head[] = get_string('grade') . " / $quiz->grade";
|
||||
$table->align[] = 'center';
|
||||
$table->size[] = '';
|
||||
}
|
||||
if ($feedbackcolumn) {
|
||||
$table->head[] = $strfeedback;
|
||||
$table->head[] = get_string('feedback', 'quiz');
|
||||
$table->align[] = 'left';
|
||||
$table->size[] = '';
|
||||
}
|
||||
if (isset($quiz->showtimetaken)) {
|
||||
$table->head[] = $strtimetaken;
|
||||
$table->head[] = get_string('timetaken', 'quiz');
|
||||
$table->align[] = 'left';
|
||||
$table->size[] = '';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user