Skip to content

Commit

Permalink
MDL-20636 code checked
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Lennard authored and timhunt committed May 9, 2011
1 parent 7886376 commit cbe8754
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 37 deletions.
77 changes: 44 additions & 33 deletions mod/quiz/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private function attempt_form($attemptobj, $page, $slots, $id, $nextpage) {

return $output;
}

/**
* Print each message in an array, surrounded by <p>, </p> tags.
*
Expand Down Expand Up @@ -409,15 +409,15 @@ private function summary_page_controls($attemptobj) {

return $output;
}
private function summary_get_timer($attemptobj){

private function summary_get_timer($attemptobj) {
return $attemptobj->get_timer_html();
}

/*
* View Page
*/
public function view_page($course, $quiz, $cm, $context, $viewobj){
public function view_page($course, $quiz, $cm, $context, $viewobj) {
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $viewobj);
$output .= $this->view_table($quiz, $context, $viewobj);
Expand All @@ -426,14 +426,15 @@ public function view_page($course, $quiz, $cm, $context, $viewobj){
$output .= $this->view_attempt_button($course, $quiz, $cm, $context, $viewobj);
return $output;
}
private function view_information($quiz, $cm, $context, $viewobj){

private function view_information($quiz, $cm, $context, $viewobj) {
global $CFG;
$output = '';
// Print quiz name and description
$output .= $this->heading(format_string($quiz->name));
if (trim(strip_tags($quiz->intro))) {
$output .= $this->box(format_module_intro('quiz', $quiz, $cm->id), 'generalbox', 'intro');
$output .= $this->box(format_module_intro('quiz', $quiz, $cm->id), 'generalbox',
'intro');
}

// Display information about this quiz.
Expand Down Expand Up @@ -472,7 +473,7 @@ private function view_information($quiz, $cm, $context, $viewobj){
return $output;
}

private function view_table($quiz, $context, $viewobj){
private function view_table($quiz, $context, $viewobj) {
$output = '';
if ($viewobj->attempts) {
$output .= $this->heading(get_string('summaryofattempts', 'quiz'));
Expand Down Expand Up @@ -523,7 +524,7 @@ private function view_table($quiz, $context, $viewobj){
foreach ($viewobj->attempts as $attempt) {
$attemptoptions = quiz_get_review_options($quiz, $attempt, $context);
$row = array();

// Add the attempt number, making it a link, if appropriate.
if ($viewobj->attemptcolumn) {
if ($attempt->preview) {
Expand Down Expand Up @@ -566,19 +567,22 @@ private function view_table($quiz, $context, $viewobj){
$attempt->timefinish > 0) {
$formattedgrade = quiz_format_grade($quiz, $attemptgrade);
// highlight the highest grade if appropriate
if ($viewobj->overallstats && !$attempt->preview && $viewobj->numattempts > 1 && !is_null($viewobj->mygrade) &&
$attemptgrade == $viewobj->mygrade && $quiz->grademethod == QUIZ_GRADEHIGHEST) {
if ($viewobj->overallstats && !$attempt->preview
&& $viewobj->numattempts > 1 && !is_null($viewobj->mygrade)
&& $attemptgrade == $viewobj->mygrade
&& $quiz->grademethod == QUIZ_GRADEHIGHEST) {
$table->rowclasses[$attempt->attempt] = 'bestrow';
}

$row[] = $formattedgrade;
} else {
$row[] = '';
}
}

if ($viewobj->canreviewmine) {
$row[] = $viewobj->accessmanager->make_review_link($attempt, $viewobj->canpreview, $attemptoptions);
$row[] = $viewobj->accessmanager->make_review_link($attempt,
$viewobj->canpreview, $attemptoptions);
}

if ($viewobj->feedbackcolumn && $attempt->timefinish > 0) {
Expand All @@ -604,7 +608,7 @@ private function view_table($quiz, $context, $viewobj){
return $output;
}

private function view_best_score($viewobj){
private function view_best_score($viewobj) {
$output = '';
// Print information about the student's best score for this quiz if possible.
if (!$viewobj->moreattempts) {
Expand All @@ -613,11 +617,11 @@ private function view_best_score($viewobj){
return $output;
}

private function view_result_info($quiz, $context, $cm, $viewobj){
private function view_result_info($quiz, $context, $cm, $viewobj) {
$output = '';
if ($viewobj->numattempts && $viewobj->gradecolumn && !is_null($viewobj->mygrade)) {
$resultinfo = '';

if ($viewobj->overallstats) {
if ($viewobj->moreattempts) {
$a = new stdClass();
Expand All @@ -630,83 +634,90 @@ private function view_result_info($quiz, $context, $cm, $viewobj){
$a->grade = quiz_format_grade($quiz, $viewobj->mygrade);
$a->maxgrade = quiz_format_grade($quiz, $quiz->grade);
$a = get_string('outofshort', 'quiz', $a);
$resultinfo .= $this->heading(get_string('yourfinalgradeis', 'quiz', $a), 2, 'main');
$resultinfo .= $this->heading(get_string('yourfinalgradeis', 'quiz', $a), 2,
'main');
}
}

if ($viewobj->mygradeoverridden) {
$resultinfo .= '<p class="overriddennotice">' .
get_string('overriddennotice', 'grades') . "</p>\n";
}
if ($viewobj->gradebookfeedback) {
$resultinfo .= $this->heading(get_string('comment', 'quiz'), 3, 'main');
$resultinfo .= '<p class="quizteacherfeedback">'.$viewobj->gradebookfeedback."</p>\n";
$resultinfo .= '<p class="quizteacherfeedback">'.$viewobj->gradebookfeedback.
"</p>\n";
}
if ($viewobj->feedbackcolumn) {
$resultinfo .= $this->heading(get_string('overallfeedback', 'quiz'), 3, 'main');
$resultinfo .= '<p class="quizgradefeedback">' .
quiz_feedback_for_grade($viewobj->mygrade, $quiz, $context, $cm) . "</p>\n";
quiz_feedback_for_grade($viewobj->mygrade, $quiz, $context, $cm)."</p>\n";
}

if ($resultinfo) {
$output .= $this->box($resultinfo, 'generalbox', 'feedback');
}
}
return $output;
}

private function view_attempt_button($course, $quiz, $cm, $context, $viewobj){
private function view_attempt_button($course, $quiz, $cm, $context, $viewobj) {
$output = '';
// Determine if we should be showing a start/continue attempt button,
// or a button to go back to the course page.
$output .= $this->box_start('quizattempt');
$buttontext = ''; // This will be set something if as start/continue attempt button should appear.
// This will be set something if as start/continue attempt button should appear.
$buttontext = '';
if (!quiz_clean_layout($quiz->questions, true)) {
$output .= quiz_no_questions_message($quiz, $cm, $context);
$buttontext = '';

} else {
if ($viewobj->unfinished) {
if ($viewobj->canattempt) {
$buttontext = get_string('continueattemptquiz', 'quiz');
} else if ($viewobj->canpreview) {
$buttontext = get_string('continuepreview', 'quiz');
}

} else {
if ($viewobj->canattempt) {
$messages = $viewobj->accessmanager->prevent_new_attempt($viewobj->numattempts, $viewobj->lastfinishedattempt);
$messages = $viewobj->accessmanager->prevent_new_attempt($viewobj->numattempts,
$viewobj->lastfinishedattempt);
if ($messages) {
$this->access_messages($messages);
} else if ($viewobj->numattempts == 0) {
$buttontext = get_string('attemptquiznow', 'quiz');
} else {
$buttontext = get_string('reattemptquiz', 'quiz');
}

} else if ($viewobj->canpreview) {
$buttontext = get_string('previewquiznow', 'quiz');
}
}

// If, so far, we think a button should be printed, so check if they will be
// allowed to access it.
if ($buttontext) {
if (!$viewobj->moreattempts) {
$buttontext = '';
} else if ($viewobj->canattempt && $messages = $viewobj->accessmanager->prevent_access()) {
} else if ($viewobj->canattempt
&& $messages = $viewobj->accessmanager->prevent_access()) {
$this->access_messages($messages);
$buttontext = '';
}
}
}

// Now actually print the appropriate button.
if ($buttontext) {
$output .= $viewobj->accessmanager->print_start_attempt_button($viewobj->canpreview, $buttontext, $viewobj->unfinished);
$output .= $viewobj->accessmanager->print_start_attempt_button($viewobj->canpreview,
$buttontext, $viewobj->unfinished);
} else if ($buttontext === '') {
$output .= $this->single_button(new moodle_url('/course/view.php', array('id' => $course->id)),
get_string('backtocourse', 'quiz'), 'get', array('class' => 'continuebutton'));
$output .= $this->single_button(new moodle_url('/course/view.php',
array('id' => $course->id)), get_string('backtocourse', 'quiz'), 'get',
array('class' => 'continuebutton'));
}
$output .= $this->box_end();

Expand Down
12 changes: 8 additions & 4 deletions mod/quiz/review.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
}

// Save the flag states, if they are being changed.
if ($options->flags == question_display_options::EDITABLE && optional_param('savingflags', false, PARAM_BOOL)) {
if ($options->flags == question_display_options::EDITABLE && optional_param('savingflags', false,
PARAM_BOOL)) {
require_sesskey();
$attemptobj->save_question_flags();
redirect($attemptobj->review_url(0, $page, $showall));
Expand All @@ -100,9 +101,11 @@
// Set up the page header
$headtags = $attemptobj->get_html_head_contributions($page, $showall);
if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
$accessmanager->setup_secure_page($attemptobj->get_course()->shortname.': '.format_string($attemptobj->get_quiz_name()), $headtags);
$accessmanager->setup_secure_page($attemptobj->get_course()->shortname.': '.
format_string($attemptobj->get_quiz_name()), $headtags);
} else if ($accessmanager->safebrowser_required($attemptobj->is_preview_user())) {
$PAGE->set_title($attemptobj->get_course()->shortname . ': '.format_string($attemptobj->get_quiz_name()));
$PAGE->set_title($attemptobj->get_course()->shortname . ': '.
format_string($attemptobj->get_quiz_name()));
$PAGE->set_heading($attemptobj->get_course()->fullname);
$PAGE->set_cacheable(false);
} else {
Expand Down Expand Up @@ -149,7 +152,8 @@
);
}
if ($attemptobj->has_capability('mod/quiz:viewreports')) {
$attemptlist = $attemptobj->links_to_other_attempts($attemptobj->review_url(0, $page, $showall));
$attemptlist = $attemptobj->links_to_other_attempts($attemptobj->review_url(0, $page,
$showall));
if ($attemptlist) {
$summarydata['attemptlist'] = array(
'title' => get_string('attempts', 'quiz'),
Expand Down

0 comments on commit cbe8754

Please sign in to comment.