MDL-46681 qtype_multichoice: disabled unused options
authorTim Hunt <T.J.Hunt@open.ac.uk>
Thu, 7 Aug 2014 13:20:06 +0000 (14:20 +0100)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Thu, 7 Aug 2014 13:20:06 +0000 (14:20 +0100)
For questions set to 'One answer only', the 'Clear incorrect responses'
and 'Show the number of correct responses' hint options make not sense,
and are not used. Hence we disableIf them.

question/type/multichoice/edit_multichoice_form.php

index fa1f551..b0dc614 100644 (file)
@@ -82,6 +82,13 @@ class qtype_multichoice_edit_form extends question_edit_form {
         return $repeated;
     }
 
+    protected function get_hint_fields($withclearwrong = false, $withshownumpartscorrect = false) {
+        list($repeated, $repeatedoptions) = parent::get_hint_fields($withclearwrong, $withshownumpartscorrect);
+        $repeatedoptions['hintclearwrong']['disabledif'] = array('single', 'eq', 1);
+        $repeatedoptions['hintshownumcorrect']['disabledif'] = array('single', 'eq', 1);
+        return array($repeated, $repeatedoptions);
+    }
+
     protected function data_preprocessing($question) {
         $question = parent::data_preprocessing($question);
         $question = $this->data_preprocessing_answers($question, true);