Skip to content

Commit

Permalink
MDL-20636 changes made to renderers, attempt and view
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 63be47d commit 13040e1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion mod/quiz/attempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
$output = $PAGE->get_renderer('mod_quiz');
if (!$attemptobj->is_preview_user() && $messages) {
print_error('attempterror', 'quiz', $attemptobj->view_url(),
$output->print_messages($messages));
$output->access_messages($messages));
}
$accessmanager->do_password_check($attemptobj->is_preview_user());

Expand Down
44 changes: 24 additions & 20 deletions mod/quiz/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private function attempt_form($attemptobj, $page, $slots, $id, $nextpage) {

//Start Form
$output .= html_writer::start_tag('form',
array('action' => s($attemptobj->processattempt_url()), 'method' => 'post',
array('action' => $attemptobj->processattempt_url(), 'method' => 'post',
'enctype' => 'multipart/form-data', 'accept-charset' => 'utf-8',
'id' => 'responseform'));
$output .= html_writer::start_tag('div');
Expand Down Expand Up @@ -309,14 +309,31 @@ private function attempt_form($attemptobj, $page, $slots, $id, $nextpage) {

return $output;
}

/**
* Print each message in an array, surrounded by <p>, </p> tags.
*
* @param array $messages the array of message strings.
* @param bool $return if true, return a string, instead of outputting.
*
* @return mixed, if $return is true, return the string that would have been output, otherwise
* return null.
*/
public function access_messages($messages) {
$output = '';
foreach ($messages as $message) {
$output .= html_writer::tag('p', $message) . "\n";
}
return $output;
}

/*
* Summary Page
*/
public function summary_page($attemptobj, $displayoptions) {
$output = '';
$output .= $this->summary_table($attemptobj, $displayoptions);
$output .= $this->summary_container($attemptobj);
$output .= $this->summary_page_controls($attemptobj);
return $output;
}

Expand Down Expand Up @@ -362,10 +379,10 @@ private function summary_table($attemptobj, $displayoptions) {
return $output;
}

private function summary_container($attemptobj) {
private function summary_page_controls($attemptobj) {
$output = '';
// countdown timer
$output .= $attemptobj->get_timer_html();
$output .= $this->summary_get_timer($attemptobj);

// Finish attempt button.
$output .= $this->container_start('submitbtns mdl-align');
Expand All @@ -390,22 +407,9 @@ private function summary_container($attemptobj) {

return $output;
}

/**
* Print each message in an array, surrounded by <p>, </p> tags.
*
* @param array $messages the array of message strings.
* @param bool $return if true, return a string, instead of outputting.
*
* @return mixed, if $return is true, return the string that would have been output, otherwise
* return null.
*/
public function print_messages($messages) {
$output = '';
foreach ($messages as $message) {
$output .= html_writer::tag('p', $message) . "\n";
}
return $output;

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

Expand Down
6 changes: 3 additions & 3 deletions mod/quiz/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
quiz_get_grading_option_name($quiz->grademethod));
}
echo $OUTPUT->box_start('quizinfo');
$output->print_messages($messages);
$output->access_messages($messages);
echo $OUTPUT->box_end();

// Show number of attempts summary to those who can view reports.
Expand Down Expand Up @@ -368,7 +368,7 @@
if ($canattempt) {
$messages = $accessmanager->prevent_new_attempt($numattempts, $lastfinishedattempt);
if ($messages) {
$output->print_messages($messages);
$output->access_messages($messages);
} else if ($numattempts == 0) {
$buttontext = get_string('attemptquiznow', 'quiz');
} else {
Expand All @@ -386,7 +386,7 @@
if (!$moreattempts) {
$buttontext = '';
} else if ($canattempt && $messages = $accessmanager->prevent_access()) {
$output->print_messages($messages);
$output->access_messages($messages);
$buttontext = '';
}
}
Expand Down

0 comments on commit 13040e1

Please sign in to comment.