mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-10374 - Quiz layout improvements, selectively merged from OU-moodle.
This commit is contained in:
parent
d1818f3283
commit
99a1bf3d9c
9 changed files with 147 additions and 106 deletions
|
@ -467,7 +467,6 @@
|
|||
</script>
|
||||
<?php
|
||||
quiz_print_navigation_panel($page, $numpages);
|
||||
echo "<br />\n";
|
||||
}
|
||||
|
||||
/// Print all the questions
|
||||
|
@ -479,9 +478,6 @@
|
|||
foreach ($pagequestions as $i) {
|
||||
$options = quiz_get_renderoptions($quiz->review, $states[$i]);
|
||||
// Print the question
|
||||
if ($i > 0) {
|
||||
echo "<br />\n";
|
||||
}
|
||||
print_question($questions[$i], $states[$i], $number, $quiz, $options);
|
||||
save_question_session($questions[$i], $states[$i]);
|
||||
$number += $questions[$i]->length;
|
||||
|
@ -503,9 +499,7 @@
|
|||
|
||||
// Print the navigation panel if required
|
||||
if ($numpages > 1) {
|
||||
echo "<br />\n";
|
||||
quiz_print_navigation_panel($page, $numpages);
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
// Finish the form
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');?>
|
||||
|
||||
<div class="boxaligncenter">
|
||||
<div class="controls">
|
||||
<?php
|
||||
if (!empty($popup)) {
|
||||
?>
|
||||
|
|
|
@ -148,6 +148,22 @@
|
|||
} else {
|
||||
print_heading(format_string($quiz->name));
|
||||
}
|
||||
if ($isteacher and $attempt->userid == $USER->id) {
|
||||
// the teacher is at the end of a preview. Print button to start new preview
|
||||
unset($buttonoptions);
|
||||
$buttonoptions['q'] = $quiz->id;
|
||||
$buttonoptions['forcenew'] = true;
|
||||
echo '<div class="controls">';
|
||||
print_single_button($CFG->wwwroot.'/mod/quiz/attempt.php', $buttonoptions, get_string('startagain', 'quiz'));
|
||||
echo '</div>';
|
||||
} else { // print number of the attempt
|
||||
print_heading(get_string('reviewofattempt', 'quiz', $attempt->attempt));
|
||||
}
|
||||
|
||||
// print javascript button to close the window, if necessary
|
||||
if (!$isteacher) {
|
||||
include('attempt_close_js.php');
|
||||
}
|
||||
|
||||
/// Print infobox
|
||||
|
||||
|
@ -167,14 +183,16 @@
|
|||
} else {
|
||||
$timetaken = get_string('unfinished', 'quiz');
|
||||
}
|
||||
|
||||
$table->align = array("right", "left");
|
||||
echo '<table class="generaltable generalbox quizreviewsummary"><tbody>';
|
||||
if ($attempt->userid <> $USER->id) {
|
||||
$student = get_record('user', 'id', $attempt->userid);
|
||||
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true);
|
||||
$table->data[] = array($picture, '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&course='.$course->id.'">'.fullname($student, true).'</a>');
|
||||
$student = get_record('user', 'id', $attempt->userid);
|
||||
$picture = print_user_picture($student->id, $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>';
|
||||
}
|
||||
if (has_capability('mod/quiz:grade', $context) and count($attempts = get_records_select('quiz_attempts', "quiz = '$quiz->id' AND userid = '$attempt->userid'", 'attempt ASC')) > 1) {
|
||||
if (has_capability('mod/quiz:grade', $context) and
|
||||
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) {
|
||||
|
@ -182,16 +200,20 @@
|
|||
? '<strong>'.$at->attempt.'</strong>, '
|
||||
: '<a href="review.php?attempt='.$at->id.($showall?'&showall=true':'').'">'.$at->attempt.'</a>, ';
|
||||
}
|
||||
$table->data[] = array(get_string('attempts', 'quiz').':', trim($attemptlist, ' ,'));
|
||||
echo '<tr><th scope="row" class="cell">', get_string('attempts', 'quiz'), '</th><td class="cell">',
|
||||
trim($attemptlist, ' ,'), '</td></tr>';
|
||||
}
|
||||
|
||||
$table->data[] = array(get_string('startedon', 'quiz').':', userdate($attempt->timestart));
|
||||
echo '<tr><th scope="row" class="cell">', get_string('startedon', 'quiz'), '</th><td class="cell">',
|
||||
userdate($attempt->timestart), '</td></tr>';
|
||||
if ($attempt->timefinish) {
|
||||
$table->data[] = array("$strtimecompleted:", userdate($attempt->timefinish));
|
||||
$table->data[] = array("$strtimetaken:", $timetaken);
|
||||
echo '<tr><th scope="row" class="cell">', $strtimecompleted, '</th><td class="cell">',
|
||||
userdate($attempt->timefinish), '</td></tr>';
|
||||
echo '<tr><th scope="row" class="cell">', $strtimetaken, '</th><td class="cell">',
|
||||
$timetaken, '</td></tr>';
|
||||
}
|
||||
if (!empty($overtime)) {
|
||||
$table->data[] = array("$stroverdue:", $overtime);
|
||||
echo '<tr><th scope="row" class="cell">', $stroverdue, '</th><td class="cell">',$overtime, '</td></tr>';
|
||||
}
|
||||
//if the student is allowed to see their score
|
||||
if ($options->scores) {
|
||||
|
@ -206,30 +228,17 @@
|
|||
$a->grade = $grade;
|
||||
$a->maxgrade = $quiz->grade;
|
||||
$rawscore = round($attempt->sumgrades, $CFG->quiz_decimalpoints);
|
||||
$table->data[] = array("$strscore:", "$rawscore/$quiz->sumgrades ($percentage %)");
|
||||
$table->data[] = array("$strgrade:", get_string('outof', 'quiz', $a));
|
||||
echo '<tr><th scope="row" class="cell">', $strscore, '</th><td class="cell">',
|
||||
"$rawscore/$quiz->sumgrades ($percentage %)", '</td></tr>';
|
||||
echo '<tr><th scope="row" class="cell">', $strgrade, '</th><td class="cell">',
|
||||
get_string('outof', 'quiz', $a), '</td></tr>';
|
||||
}
|
||||
}
|
||||
if ($options->overallfeedback && $feedback) {
|
||||
$table->data[] = array(get_string('feedback', 'quiz'), $feedback);
|
||||
}
|
||||
if ($isteacher and $attempt->userid == $USER->id) {
|
||||
// the teacher is at the end of a preview. Print button to start new preview
|
||||
unset($buttonoptions);
|
||||
$buttonoptions['q'] = $quiz->id;
|
||||
$buttonoptions['forcenew'] = true;
|
||||
echo '<div class="controls">';
|
||||
print_single_button($CFG->wwwroot.'/mod/quiz/attempt.php', $buttonoptions, get_string('startagain', 'quiz'));
|
||||
echo '</div>';
|
||||
} else { // print number of the attempt
|
||||
print_heading(get_string('reviewofattempt', 'quiz', $attempt->attempt));
|
||||
}
|
||||
print_table($table);
|
||||
|
||||
// print javascript button to close the window, if necessary
|
||||
if (!$isteacher) {
|
||||
include('attempt_close_js.php');
|
||||
echo '<tr><th scope="row" class="cell">', get_string('feedback', 'quiz'), '</th><td class="cell">',
|
||||
$feedback, '</td></tr>';
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
|
||||
/// Print the navigation panel if required
|
||||
$numpages = quiz_number_of_pages($attempt->layout);
|
||||
|
@ -255,9 +264,6 @@
|
|||
$options->validation = QUESTION_EVENTVALIDATE === $states[$i]->event;
|
||||
$options->history = ($isteacher and !$attempt->preview) ? 'all' : 'graded';
|
||||
// Print the question
|
||||
if ($i > 0) {
|
||||
echo "<br />\n";
|
||||
}
|
||||
print_question($questions[$i], $states[$i], $number, $quiz, $options);
|
||||
$number += $questions[$i]->length;
|
||||
}
|
||||
|
|
|
@ -175,6 +175,8 @@
|
|||
// Print table with existing attempts
|
||||
if ($attempts) {
|
||||
|
||||
print_heading('Summary of your previous attempts');
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -186,17 +188,18 @@
|
|||
$overallfeedback = $feedbackcolumn && $alloptions->overallfeedback;
|
||||
|
||||
// prepare table header
|
||||
$table->class = 'generaltable quizattemptsummary';
|
||||
$table->head = array($strattempt, $strtimecompleted);
|
||||
$table->align = array("center", "left");
|
||||
$table->size = array("", "");
|
||||
if ($markcolumn) {
|
||||
$table->head[] = "$strmarks / $quiz->sumgrades";
|
||||
$table->align[] = 'right';
|
||||
$table->align[] = 'center';
|
||||
$table->size[] = '';
|
||||
}
|
||||
if ($gradecolumn) {
|
||||
$table->head[] = "$strgrade / $quiz->grade";
|
||||
$table->align[] = 'right';
|
||||
$table->align[] = 'center';
|
||||
$table->size[] = '';
|
||||
}
|
||||
if ($feedbackcolumn) {
|
||||
|
@ -216,7 +219,7 @@
|
|||
$row = array();
|
||||
|
||||
// Add the attempt number, making it a link, if appropriate.
|
||||
$row[] = make_review_link('#' . $attempt->attempt, $quiz, $attempt);
|
||||
$row[] = make_review_link($attempt->attempt, $quiz, $attempt);
|
||||
|
||||
// prepare strings for time taken and date completed
|
||||
$timetaken = '';
|
||||
|
@ -253,11 +256,10 @@
|
|||
|
||||
if ($gradecolumn) {
|
||||
if ($attemptoptions->scores) {
|
||||
$formattedgrade = $attemptgrade;
|
||||
// highlight the highest grade if appropriate
|
||||
if ($overallstats && !is_null($mygrade) && $attemptgrade == $mygrade && $quiz->grademethod == QUIZ_GRADEHIGHEST) {
|
||||
$formattedgrade = "<span class='highlight'>$attemptgrade</span>";
|
||||
} else {
|
||||
$formattedgrade = $attemptgrade;
|
||||
if ($overallstats && $numattempts > 1 && !is_null($mygrade) && $attemptgrade == $mygrade && $quiz->grademethod == QUIZ_GRADEHIGHEST) {
|
||||
$table->rowclass[$attempt->attempt] = 'bestrow';
|
||||
}
|
||||
|
||||
$row[] = make_review_link($formattedgrade, $quiz, $attempt);
|
||||
|
@ -278,7 +280,7 @@
|
|||
$row[] = $timetaken;
|
||||
}
|
||||
|
||||
$table->data[] = $row;
|
||||
$table->data[$attempt->attempt] = $row;
|
||||
} // End of loop over attempts.
|
||||
print_table($table);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue