mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-27979 Should be an edit link for each question when previewing or reviewing a quiz.
This commit is contained in:
parent
3552484b91
commit
da72991636
7 changed files with 103 additions and 18 deletions
|
@ -505,6 +505,20 @@ class question_display_options {
|
|||
*/
|
||||
public $history = self::HIDDEN;
|
||||
|
||||
/**
|
||||
* If not empty, then a link to edit the question will be included in
|
||||
* the info box for the question.
|
||||
*
|
||||
* If used, this array must contain an element courseid or cmid.
|
||||
*
|
||||
* It shoudl also contain a parameter returnurl => moodle_url giving a
|
||||
* sensible URL to go back to when the editing form is submitted or cancelled.
|
||||
*
|
||||
* @var array url parameter for the edit link. id => questiosnid will be
|
||||
* added automatically.
|
||||
*/
|
||||
public $editquestionparams = array();
|
||||
|
||||
/**
|
||||
* @var int the context the attempt being output belongs to.
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue