Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-20636 changes made to renderers, attempt and view

  • Loading branch information...
commit 13040e14529d2ee5f4313371789f9f51eb95fc97 1 parent 63be47d
Dean Lennard authored timhunt committed
2  mod/quiz/attempt.php
@@ -79,7 +79,7 @@
79 79 $output = $PAGE->get_renderer('mod_quiz');
80 80 if (!$attemptobj->is_preview_user() && $messages) {
81 81 print_error('attempterror', 'quiz', $attemptobj->view_url(),
82   - $output->print_messages($messages));
  82 + $output->access_messages($messages));
83 83 }
84 84 $accessmanager->do_password_check($attemptobj->is_preview_user());
85 85
44 mod/quiz/renderer.php
@@ -267,7 +267,7 @@ private function attempt_form($attemptobj, $page, $slots, $id, $nextpage) {
267 267
268 268 //Start Form
269 269 $output .= html_writer::start_tag('form',
270   - array('action' => s($attemptobj->processattempt_url()), 'method' => 'post',
  270 + array('action' => $attemptobj->processattempt_url(), 'method' => 'post',
271 271 'enctype' => 'multipart/form-data', 'accept-charset' => 'utf-8',
272 272 'id' => 'responseform'));
273 273 $output .= html_writer::start_tag('div');
@@ -309,6 +309,23 @@ private function attempt_form($attemptobj, $page, $slots, $id, $nextpage) {
309 309
310 310 return $output;
311 311 }
  312 +
  313 + /**
  314 + * Print each message in an array, surrounded by <p>, </p> tags.
  315 + *
  316 + * @param array $messages the array of message strings.
  317 + * @param bool $return if true, return a string, instead of outputting.
  318 + *
  319 + * @return mixed, if $return is true, return the string that would have been output, otherwise
  320 + * return null.
  321 + */
  322 + public function access_messages($messages) {
  323 + $output = '';
  324 + foreach ($messages as $message) {
  325 + $output .= html_writer::tag('p', $message) . "\n";
  326 + }
  327 + return $output;
  328 + }
312 329
313 330 /*
314 331 * Summary Page
@@ -316,7 +333,7 @@ private function attempt_form($attemptobj, $page, $slots, $id, $nextpage) {
316 333 public function summary_page($attemptobj, $displayoptions) {
317 334 $output = '';
318 335 $output .= $this->summary_table($attemptobj, $displayoptions);
319   - $output .= $this->summary_container($attemptobj);
  336 + $output .= $this->summary_page_controls($attemptobj);
320 337 return $output;
321 338 }
322 339
@@ -362,10 +379,10 @@ private function summary_table($attemptobj, $displayoptions) {
362 379 return $output;
363 380 }
364 381
365   - private function summary_container($attemptobj) {
  382 + private function summary_page_controls($attemptobj) {
366 383 $output = '';
367 384 // countdown timer
368   - $output .= $attemptobj->get_timer_html();
  385 + $output .= $this->summary_get_timer($attemptobj);
369 386
370 387 // Finish attempt button.
371 388 $output .= $this->container_start('submitbtns mdl-align');
@@ -390,22 +407,9 @@ private function summary_container($attemptobj) {
390 407
391 408 return $output;
392 409 }
393   -
394   - /**
395   - * Print each message in an array, surrounded by <p>, </p> tags.
396   - *
397   - * @param array $messages the array of message strings.
398   - * @param bool $return if true, return a string, instead of outputting.
399   - *
400   - * @return mixed, if $return is true, return the string that would have been output, otherwise
401   - * return null.
402   - */
403   - public function print_messages($messages) {
404   - $output = '';
405   - foreach ($messages as $message) {
406   - $output .= html_writer::tag('p', $message) . "\n";
407   - }
408   - return $output;
  410 +
  411 + private function summary_get_timer($attemptobj){
  412 + return $attemptobj->get_timer_html();
409 413 }
410 414 }
411 415
6 mod/quiz/view.php
@@ -101,7 +101,7 @@
101 101 quiz_get_grading_option_name($quiz->grademethod));
102 102 }
103 103 echo $OUTPUT->box_start('quizinfo');
104   -$output->print_messages($messages);
  104 +$output->access_messages($messages);
105 105 echo $OUTPUT->box_end();
106 106
107 107 // Show number of attempts summary to those who can view reports.
@@ -368,7 +368,7 @@
368 368 if ($canattempt) {
369 369 $messages = $accessmanager->prevent_new_attempt($numattempts, $lastfinishedattempt);
370 370 if ($messages) {
371   - $output->print_messages($messages);
  371 + $output->access_messages($messages);
372 372 } else if ($numattempts == 0) {
373 373 $buttontext = get_string('attemptquiznow', 'quiz');
374 374 } else {
@@ -386,7 +386,7 @@
386 386 if (!$moreattempts) {
387 387 $buttontext = '';
388 388 } else if ($canattempt && $messages = $accessmanager->prevent_access()) {
389   - $output->print_messages($messages);
  389 + $output->access_messages($messages);
390 390 $buttontext = '';
391 391 }
392 392 }

0 comments on commit 13040e1

Please sign in to comment.
Something went wrong with that request. Please try again.