Skip to content

Commit

Permalink
MDL-20636 Add support for hints to the calculated* questions.
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed May 19, 2011
1 parent cdece95 commit b130270
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
4 changes: 3 additions & 1 deletion question/type/calculated/edit_calculated_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ protected function definition_inner($mform) {

$this->add_unit_options($mform, $this);
$this->add_unit_fields($mform, $this);
$this->add_interactive_settings();

//hidden elements
// Hidden elements
$mform->addElement('hidden', 'synchronize', '');
$mform->setType('synchronize', PARAM_INT);
$mform->addElement('hidden', 'wizard', 'datasetdefinitions');
Expand Down Expand Up @@ -222,6 +223,7 @@ public function data_preprocessing($question) {
$this->_form->_elements[$this->_form->_elementIndex['listcategory']]->_text = $html2;
$question = (object)((array)$question + $default_values);

$question = $this->data_preprocessing_hints($question);
$question = $this->data_preprocessing_units($question);
$question = $this->data_preprocessing_unit_options($question);

Expand Down
5 changes: 5 additions & 0 deletions question/type/calculated/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public function get_question_options($question) {
$this->get_virtual_qtype()->get_numerical_options($question);
}

$question->hints = $DB->get_records('question_hints',
array('questionid' => $question->id), 'id ASC');

if (isset($question->export_process)&&$question->export_process) {
$question->options->datasets = $this->get_datasets_for_export($question);
}
Expand Down Expand Up @@ -270,6 +273,8 @@ public function save_question_options($question) {
return $result;
}

$this->save_hints($question);

if (isset($question->import_process)&&$question->import_process) {
$this->import_datasets($question);
}
Expand Down
13 changes: 4 additions & 9 deletions question/type/calculatedmulti/edit_calculatedmulti_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,11 @@ protected function definition_inner($mform) {
$mform->setType('multiplier'."[$i]", PARAM_NUMBER);
}

$mform->setType('addunits', 'hidden');
$mform->addElement('header', 'overallfeedbackhdr',
get_string('overallfeedback', 'qtype_multichoice'));
$this->add_combined_feedback_fields(true);
$mform->disabledIf('shownumcorrect', 'single', 'eq', 1);

$this->add_interactive_settings(true, true);

foreach (array('correctfeedback', 'partiallycorrectfeedback',
'incorrectfeedback') as $feedbackname) {
$mform->addElement('editor', $feedbackname,
get_string($feedbackname, 'qtype_multichoice'), null, $this->editoroptions);
$mform->setType($feedbackname, PARAM_RAW);
}
//hidden elements
$mform->addElement('hidden', 'synchronize', '');
$mform->setType('synchronize', PARAM_INT);
Expand Down
3 changes: 3 additions & 0 deletions question/type/calculatedmulti/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ public function save_question_options($question) {
if (!empty($result->notice)) {
return $result;
}

$this->save_hints($question, true);

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ protected function definition_inner($mform) {

$this->add_unit_options($mform, $this);
$this->add_unit_fields($mform, $this);
$this->add_interactive_settings();

$label = "<div class='mdl-align'></div><div class='mdl-align'>" .
get_string('wildcardrole', 'qtype_calculatedsimple') . "</div>";
Expand Down
3 changes: 3 additions & 0 deletions question/type/calculatedsimple/questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ public function save_question_options($question) {
if (!empty($result->notice)) {
return $result;
}

$this->save_hints($question);

return true;
}

Expand Down

0 comments on commit b130270

Please sign in to comment.