MDL-27979 Should be an edit link for each question when previewing or reviewing a quiz.

This commit is contained in:
Tim Hunt 2011-06-22 21:07:40 +01:00
parent 3552484b91
commit da72991636
7 changed files with 103 additions and 18 deletions

View file

@ -113,6 +113,7 @@ class core_question_renderer extends plugin_renderer_base {
$output .= $this->status($qa, $behaviouroutput, $options);
$output .= $this->mark_summary($qa, $options);
$output .= $this->question_flag($qa, $options->flags);
$output .= $this->edit_question_link($qa, $options);
return $output;
}
@ -254,6 +255,28 @@ class core_question_renderer extends plugin_renderer_base {
'" alt="' . get_string('flagthisquestion', 'question') . '" />';
}
protected function edit_question_link(question_attempt $qa,
question_display_options $options) {
global $CFG;
if (empty($options->editquestionparams)) {
return '';
}
$params = $options->editquestionparams;
if ($params['returnurl'] instanceof moodle_url) {
$params['returnurl'] = str_replace($CFG->wwwroot, '',
$params['returnurl']->out(false));
}
$params['id'] = $qa->get_question()->id;
$editurl = new moodle_url('/question/question.php', $params);
return html_writer::tag('div', html_writer::link(
$editurl, $this->pix_icon('i/edit', get_string('edit')) .
get_string('editquestion', 'question')),
array('class' => 'editquestion'));
}
/**
* Generate the display of the formulation part of the question. This is the
* area that contains the quetsion text, and the controls for students to