MDL-10374 - Quiz layout improvements, selectively merged from OU-moodle.

This commit is contained in:
tjhunt 2007-07-06 16:37:06 +00:00
parent d1818f3283
commit 99a1bf3d9c
9 changed files with 147 additions and 106 deletions

View file

@ -467,7 +467,6 @@
</script> </script>
<?php <?php
quiz_print_navigation_panel($page, $numpages); quiz_print_navigation_panel($page, $numpages);
echo "<br />\n";
} }
/// Print all the questions /// Print all the questions
@ -479,9 +478,6 @@
foreach ($pagequestions as $i) { foreach ($pagequestions as $i) {
$options = quiz_get_renderoptions($quiz->review, $states[$i]); $options = quiz_get_renderoptions($quiz->review, $states[$i]);
// Print the question // Print the question
if ($i > 0) {
echo "<br />\n";
}
print_question($questions[$i], $states[$i], $number, $quiz, $options); print_question($questions[$i], $states[$i], $number, $quiz, $options);
save_question_session($questions[$i], $states[$i]); save_question_session($questions[$i], $states[$i]);
$number += $questions[$i]->length; $number += $questions[$i]->length;
@ -503,9 +499,7 @@
// Print the navigation panel if required // Print the navigation panel if required
if ($numpages > 1) { if ($numpages > 1) {
echo "<br />\n";
quiz_print_navigation_panel($page, $numpages); quiz_print_navigation_panel($page, $numpages);
echo '<br />';
} }
// Finish the form // Finish the form

View file

@ -1,6 +1,6 @@
<?php defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');?> <?php defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');?>
<div class="boxaligncenter"> <div class="controls">
<?php <?php
if (!empty($popup)) { if (!empty($popup)) {
?> ?>

View file

@ -148,6 +148,22 @@
} else { } else {
print_heading(format_string($quiz->name)); 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 /// Print infobox
@ -167,14 +183,16 @@
} else { } else {
$timetaken = get_string('unfinished', 'quiz'); $timetaken = get_string('unfinished', 'quiz');
} }
echo '<table class="generaltable generalbox quizreviewsummary"><tbody>';
$table->align = array("right", "left");
if ($attempt->userid <> $USER->id) { if ($attempt->userid <> $USER->id) {
$student = get_record('user', 'id', $attempt->userid); $student = get_record('user', 'id', $attempt->userid);
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true); $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.'&amp;course='.$course->id.'">'.fullname($student, true).'</a>'); echo '<tr><th scope="row" class="cell">', $picture, '</th><td class="cell"><a href="', $CFG->wwwroot,
'/user/view.php?id=', $student->id, '&amp;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 // print list of attempts
$attemptlist = ''; $attemptlist = '';
foreach ($attempts as $at) { foreach ($attempts as $at) {
@ -182,16 +200,20 @@
? '<strong>'.$at->attempt.'</strong>, ' ? '<strong>'.$at->attempt.'</strong>, '
: '<a href="review.php?attempt='.$at->id.($showall?'&amp;showall=true':'').'">'.$at->attempt.'</a>, '; : '<a href="review.php?attempt='.$at->id.($showall?'&amp;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) { if ($attempt->timefinish) {
$table->data[] = array("$strtimecompleted:", userdate($attempt->timefinish)); echo '<tr><th scope="row" class="cell">', $strtimecompleted, '</th><td class="cell">',
$table->data[] = array("$strtimetaken:", $timetaken); userdate($attempt->timefinish), '</td></tr>';
echo '<tr><th scope="row" class="cell">', $strtimetaken, '</th><td class="cell">',
$timetaken, '</td></tr>';
} }
if (!empty($overtime)) { 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 the student is allowed to see their score
if ($options->scores) { if ($options->scores) {
@ -206,30 +228,17 @@
$a->grade = $grade; $a->grade = $grade;
$a->maxgrade = $quiz->grade; $a->maxgrade = $quiz->grade;
$rawscore = round($attempt->sumgrades, $CFG->quiz_decimalpoints); $rawscore = round($attempt->sumgrades, $CFG->quiz_decimalpoints);
$table->data[] = array("$strscore:", "$rawscore/$quiz->sumgrades ($percentage %)"); echo '<tr><th scope="row" class="cell">', $strscore, '</th><td class="cell">',
$table->data[] = array("$strgrade:", get_string('outof', 'quiz', $a)); "$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) { if ($options->overallfeedback && $feedback) {
$table->data[] = array(get_string('feedback', 'quiz'), $feedback); echo '<tr><th scope="row" class="cell">', get_string('feedback', 'quiz'), '</th><td class="cell">',
} $feedback, '</td></tr>';
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 '</tbody></table>';
/// Print the navigation panel if required /// Print the navigation panel if required
$numpages = quiz_number_of_pages($attempt->layout); $numpages = quiz_number_of_pages($attempt->layout);
@ -255,9 +264,6 @@
$options->validation = QUESTION_EVENTVALIDATE === $states[$i]->event; $options->validation = QUESTION_EVENTVALIDATE === $states[$i]->event;
$options->history = ($isteacher and !$attempt->preview) ? 'all' : 'graded'; $options->history = ($isteacher and !$attempt->preview) ? 'all' : 'graded';
// Print the question // Print the question
if ($i > 0) {
echo "<br />\n";
}
print_question($questions[$i], $states[$i], $number, $quiz, $options); print_question($questions[$i], $states[$i], $number, $quiz, $options);
$number += $questions[$i]->length; $number += $questions[$i]->length;
} }

View file

@ -175,6 +175,8 @@
// Print table with existing attempts // Print table with existing attempts
if ($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. // 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); list($someoptions, $alloptions) = quiz_get_combined_reviewoptions($quiz, $attempts, $context);
@ -186,17 +188,18 @@
$overallfeedback = $feedbackcolumn && $alloptions->overallfeedback; $overallfeedback = $feedbackcolumn && $alloptions->overallfeedback;
// prepare table header // prepare table header
$table->class = 'generaltable quizattemptsummary';
$table->head = array($strattempt, $strtimecompleted); $table->head = array($strattempt, $strtimecompleted);
$table->align = array("center", "left"); $table->align = array("center", "left");
$table->size = array("", ""); $table->size = array("", "");
if ($markcolumn) { if ($markcolumn) {
$table->head[] = "$strmarks / $quiz->sumgrades"; $table->head[] = "$strmarks / $quiz->sumgrades";
$table->align[] = 'right'; $table->align[] = 'center';
$table->size[] = ''; $table->size[] = '';
} }
if ($gradecolumn) { if ($gradecolumn) {
$table->head[] = "$strgrade / $quiz->grade"; $table->head[] = "$strgrade / $quiz->grade";
$table->align[] = 'right'; $table->align[] = 'center';
$table->size[] = ''; $table->size[] = '';
} }
if ($feedbackcolumn) { if ($feedbackcolumn) {
@ -216,7 +219,7 @@
$row = array(); $row = array();
// Add the attempt number, making it a link, if appropriate. // 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 // prepare strings for time taken and date completed
$timetaken = ''; $timetaken = '';
@ -253,11 +256,10 @@
if ($gradecolumn) { if ($gradecolumn) {
if ($attemptoptions->scores) { if ($attemptoptions->scores) {
$formattedgrade = $attemptgrade;
// highlight the highest grade if appropriate // highlight the highest grade if appropriate
if ($overallstats && !is_null($mygrade) && $attemptgrade == $mygrade && $quiz->grademethod == QUIZ_GRADEHIGHEST) { if ($overallstats && $numattempts > 1 && !is_null($mygrade) && $attemptgrade == $mygrade && $quiz->grademethod == QUIZ_GRADEHIGHEST) {
$formattedgrade = "<span class='highlight'>$attemptgrade</span>"; $table->rowclass[$attempt->attempt] = 'bestrow';
} else {
$formattedgrade = $attemptgrade;
} }
$row[] = make_review_link($formattedgrade, $quiz, $attempt); $row[] = make_review_link($formattedgrade, $quiz, $attempt);
@ -278,7 +280,7 @@
$row[] = $timetaken; $row[] = $timetaken;
} }
$table->data[] = $row; $table->data[$attempt->attempt] = $row;
} // End of loop over attempts. } // End of loop over attempts.
print_table($table); print_table($table);
} }

View file

@ -16,11 +16,13 @@
<?php } ?> <?php } ?>
</div> </div>
<div class="content"> <div class="content">
<?php $this->print_question_formulation_and_controls($question, $state, $cmoptions, $options); ?> <?php $this->print_question_formulation_and_controls($question, $state, $cmoptions, $options);
<div class="grading"> if ($generalfeedback) { ?>
<?php $this->print_question_grading_details($question, $state, $cmoptions, $options); ?> <div class="generalfeedback">
</div> <?php echo $generalfeedback ?>
<?php if ($comment) { ?> </div>
<?php }
if ($comment) { ?>
<div class="comment"> <div class="comment">
<?php <?php
echo get_string('comment', 'quiz').': '; echo get_string('comment', 'quiz').': ';
@ -28,12 +30,10 @@
?> ?>
</div> </div>
<?php } <?php }
echo $commentlink; echo $commentlink; ?>
if ($generalfeedback) { ?> <div class="grading">
<div class="generalfeedback"> <?php $this->print_question_grading_details($question, $state, $cmoptions, $options); ?>
<?php echo $generalfeedback ?> </div><?php
</div>
<?php }
if ($history) { ?> if ($history) { ?>
<div class="history"> <div class="history">
<?php <?php

View file

@ -12,11 +12,11 @@
</div> </div>
<div class="answer"> <div class="answer">
<span <?php echo 'class="'.$trueclass.'"'; ?>> <span <?php echo 'class="r0 '.$trueclass.'"'; ?>>
<?php echo $radiotrue ?> <?php echo $radiotrue ?>
<?php echo $truefeedbackimg; ?> <?php echo $truefeedbackimg; ?>
</span> </span>
<span <?php echo 'class="'.$falseclass.'"'; ?>> <span <?php echo 'class="r1 '.$falseclass.'"'; ?>>
<?php echo $radiofalse ?> <?php echo $radiofalse ?>
<?php echo $falsefeedbackimg; ?> <?php echo $falsefeedbackimg; ?>
</span> </span>

View file

@ -761,8 +761,7 @@ table.message_search_results td {
} }
.calculated .answer, .calculated .answer,
.numerical .answer, .numerical .answer,
.shortanswer .answer, .shortanswer .answer {
.truefalse .answer {
background-color: #EEE; background-color: #EEE;
} }
.que .feedback { .que .feedback {
@ -963,13 +962,16 @@ table.message_search_results td {
*** Modules: Quiz *** Modules: Quiz
***/ ***/
/* body#mod-quiz-report table#attempts td { table.quizattemptsummary .bestrow td {
border-color: #dddddd; background-color: #e8e8e8;
} }
body#mod-quiz-report table#attempts .r1 {
background-color: #eeeeee; table.quizreviewsummary th.cell {
background: #f0f0f0;
}
table.quizreviewsummary td.cell {
background: #fafafa;
} }
*/
/*** /***
*** Modules: Resource *** Modules: Resource

View file

@ -47,4 +47,8 @@ form.mform input {
form.mform textarea { form.mform textarea {
margin-left: -10px; margin-left: -10px;
} }
.que .info {
margin-left: 0.6em;
}

View file

@ -2418,22 +2418,27 @@ body#message-messages {
.que { .que {
text-align: left; text-align: left;
margin: 10px auto 15px auto; margin: 0 auto 1.8em auto;
border: 1px solid; border: 1px solid;
clear: both; clear: both;
} }
.que .info { .que .info {
float: left; float: left;
margin: 5px 0 5px 5px; margin: 0.5em 0 0.5em 1.2em;
width: 8%; width: 8%;
} }
.que .grade {
margin-top: 0.5em;
}
.que .content { .que .content {
float: left; float: left;
margin: 5px 0 5px 5px; margin: 0.5em 1.2em 0.5em 0;
width: 88%; width: 85%;
}
.que.description .info {
display: none;
}
.que.description .content {
margin-left: 1.2em;
float: none;
width: auto;
} }
.que .qtext { .que .qtext {
margin-bottom: 1.5em; margin-bottom: 1.5em;
@ -2492,19 +2497,15 @@ body#message-messages {
} }
.calculated .answer, .calculated .answer,
.numerical .answer, .numerical .answer,
.shortanswer .answer, .shortanswer .answer {
.truefalse .answer { padding: 0.3em;
padding: 0.3em 0 0.3em 0.3em; width: auto;
}
.calculated .answer input,
.numerical .answer input,
.shortanswer .answer input {
width: 85%;
} }
.truefalse .answer span { .truefalse .answer span {
float: left; float: left;
clear: left; clear: left;
padding: 0.2em 0; padding: 0.3em;
width: 100%;
} }
.que .grading, .que .grading,
.que .comment, .que .comment,
@ -2513,6 +2514,9 @@ body#message-messages {
.que .history { .que .history {
margin-top: 0.5em; margin-top: 0.5em;
} }
.que .grade {
margin-top: 0.5em;
}
.importerror { .importerror {
margin-top: 10px; margin-top: 10px;
@ -3343,10 +3347,57 @@ body#mod-forum-search .introcontent {
*** Modules: Quiz *** Modules: Quiz
***/ ***/
#mod-quiz-view .quizinfo {
text-align: center;
}
#mod-quiz-view #page .quizgradefeedback,
#mod-quiz-view #page .quizattempt
{
text-align: center;
}
#mod-quiz-attempt #page { #mod-quiz-attempt #page {
text-align: center; text-align: center;
} }
#mod-quiz-attempt .pagingbar {
margin: 1.5em auto;
}
body#question-preview .quemodname,
body#question-preview .controls
{
text-align: center;
}
body#question-preview .quemodname, body#question-preview .controls {
text-align: center;
}
#mod-quiz-review #page .controls {
text-align: center;
margin: 1.5em auto;
}
#mod-quiz-review .pagingbar {
margin: 1.5em auto;
}
#mod-quiz-review .pagingbar {
margin: 1.5em auto;
}
table.quizreviewsummary {
margin-bottom: 1.8em;
width: 100%;
}
table.quizreviewsummary tr {
}
table.quizreviewsummary th.cell {
padding: 1px 0.5em 1px 1em;
font-weight: bold;
text-align: right;
width: 10em;
}
table.quizreviewsummary td.cell {
padding: 1px 1em 1px 0.5em;
}
#mod-quiz-edit #page .controls, #mod-quiz-edit #page .controls,
#mod-quiz-edit #page .attemptsnotice #mod-quiz-edit #page .attemptsnotice
{ {
@ -3358,11 +3409,10 @@ body#mod-forum-search .introcontent {
#mod-quiz-edit #showbreaks { #mod-quiz-edit #showbreaks {
margin-top: 0.7em; margin-top: 0.7em;
} }
body#question-preview .quemodname, .quizquestionlistcontrols {
body#question-preview .controls
{
text-align: center; text-align: center;
} }
body#mod-quiz-report table#attempts, body#mod-quiz-report table#attempts,
body#mod-quiz-report table#commands, body#mod-quiz-report table#commands,
body#mod-quiz-report table#itemanalysis body#mod-quiz-report table#itemanalysis
@ -3404,23 +3454,6 @@ body#mod-quiz-report table#attempts .picture {
body#mod-quiz-report .controls { body#mod-quiz-report .controls {
text-align: center; text-align: center;
} }
#mod-quiz-review #page .controls {
text-align: center;
}
#mod-quiz-view .quizinfo {
text-align: center;
}
#mod-quiz-view #page .quizgradefeedback,
#mod-quiz-view #page .quizattempt
{
text-align: center;
}
.quizquestionlistcontrols {
text-align: center;
}
body#question-preview .quemodname, body#question-preview .controls {
text-align: center;
}
/*** /***
*** Modules: Resource *** Modules: Resource