MDL-20636 changes made to renderers, attempt and view
This commit is contained in:
@@ -79,7 +79,7 @@ $messages = $accessmanager->prevent_access();
|
||||
$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());
|
||||
|
||||
|
||||
+24
-20
@@ -267,7 +267,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
|
||||
//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');
|
||||
@@ -309,6 +309,23 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
|
||||
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
|
||||
@@ -316,7 +333,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -362,10 +379,10 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
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');
|
||||
@@ -390,22 +407,9 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -101,7 +101,7 @@ if ($quiz->attempts != 1) {
|
||||
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.
|
||||
@@ -368,7 +368,7 @@ if (!quiz_clean_layout($quiz->questions, true)) {
|
||||
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 {
|
||||
@@ -386,7 +386,7 @@ if (!quiz_clean_layout($quiz->questions, true)) {
|
||||
if (!$moreattempts) {
|
||||
$buttontext = '';
|
||||
} else if ($canattempt && $messages = $accessmanager->prevent_access()) {
|
||||
$output->print_messages($messages);
|
||||
$output->access_messages($messages);
|
||||
$buttontext = '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user