Skip to content

Commit

Permalink
Merge branch 'MDL-35792_23' of git://github.com/timhunt/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_23_STABLE
  • Loading branch information
stronk7 committed Jan 7, 2013
2 parents 7db20e0 + 5b8d952 commit 0858993
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
3 changes: 3 additions & 0 deletions lang/en/question.php
Expand Up @@ -306,6 +306,8 @@
$string['cannotpreview'] = 'You can\'t preview these questions!';
$string['category'] = 'Category';
$string['changeoptions'] = 'Change options';
$string['attemptoptions'] = 'Attempt options';
$string['displayoptions'] = 'Display options';
$string['check'] = 'Check';
$string['clearwrongparts'] = 'Clear incorrect responses';
$string['closepreview'] = 'Close preview';
Expand Down Expand Up @@ -384,6 +386,7 @@
$string['responsehistory'] = 'Response history';
$string['restart'] = 'Start again';
$string['restartwiththeseoptions'] = 'Start again with these options';
$string['updatedisplayoptions'] = 'Update display options';
$string['rightanswer'] = 'Right answer';
$string['rightanswer_help'] = 'an automatically generated summary of the correct response. This can be limited, so you may wish to consider explaining the correct solution in the general feedback for the question, and turning this option off.';
$string['saved'] = 'Saved: {$a}';
Expand Down
6 changes: 4 additions & 2 deletions question/preview.php
Expand Up @@ -124,7 +124,7 @@
$options->maxmark = $quba->get_question_max_mark($slot);

// Create the settings form, and initialise the fields.
$optionsform = new preview_options_form(question_preview_form_url($question->id, $context),
$optionsform = new preview_options_form(question_preview_form_url($question->id, $context, $previewid),
array('quba' => $quba, 'maxvariant' => $maxvariant));
$optionsform->set_data($options);

Expand All @@ -135,7 +135,9 @@
if (!isset($newoptions->variant)) {
$newoptions->variant = $options->variant;
}
restart_preview($previewid, $question->id, $newoptions, $context);
if (isset($newoptions->saverestart)) {
restart_preview($previewid, $question->id, $newoptions, $context);
}
}

// Prepare a URL that is used in various places.
Expand Down
20 changes: 14 additions & 6 deletions question/previewlib.php
Expand Up @@ -44,7 +44,7 @@ public function definition() {
question_display_options::VISIBLE => get_string('shown', 'question'),
);

$mform->addElement('header', 'optionsheader', get_string('changeoptions', 'question'));
$mform->addElement('header', 'optionsheader', get_string('attemptoptions', 'question'));

$behaviours = question_engine::get_behaviour_options(
$this->_customdata['quba']->get_preferred_behaviour());
Expand All @@ -56,6 +56,11 @@ public function definition() {
array('size' => '5'));
$mform->setType('maxmark', PARAM_FLOAT);

$mform->addElement('submit', 'saverestart',
get_string('restartwiththeseoptions', 'question'));

$mform->addElement('header', 'optionsheader', get_string('displayoptions', 'question'));

if ($this->_customdata['maxvariant'] > 1) {
$variants = range(1, $this->_customdata['maxvariant']);
$mform->addElement('select', 'variant', get_string('questionvariant', 'question'),
Expand Down Expand Up @@ -88,8 +93,8 @@ public function definition() {
$mform->addElement('select', 'history',
get_string('responsehistory', 'question'), $hiddenofvisible);

$mform->addElement('submit', 'submit',
get_string('restartwiththeseoptions', 'question'));
$mform->addElement('submit', 'saveupdate',
get_string('updatedisplayoptions', 'question'));
}
}

Expand Down Expand Up @@ -286,10 +291,10 @@ function question_preview_action_url($questionid, $qubaid,
/**
* The the URL to use for actions relating to this preview.
* @param int $questionid the question being previewed.
* @param int $qubaid the id of the question usage for this preview.
* @param question_preview_options $options the options in use.
* @param context $context the current moodle context.
* @param int $previewid optional previewid to sign post saved previewed answers.
*/
function question_preview_form_url($questionid, $context) {
function question_preview_form_url($questionid, $context, $previewid = null) {
$params = array(
'id' => $questionid,
);
Expand All @@ -298,6 +303,9 @@ function question_preview_form_url($questionid, $context) {
} else if ($context->contextlevel == CONTEXT_COURSE) {
$params['courseid'] = $context->instanceid;
}
if ($previewid) {
$params['previewid'] = $previewid;
}
return new moodle_url('/question/preview.php', $params);
}

Expand Down

0 comments on commit 0858993

Please sign in to comment.