MDL-64749 Question gapselect: Replace 'Choose...' with blank
authorM Kassaei <m.kassaei@open.ac.uk>
Wed, 20 Feb 2019 11:06:51 +0000 (11:06 +0000)
committerM Kassaei <m.kassaei@open.ac.uk>
Wed, 20 Feb 2019 11:06:51 +0000 (11:06 +0000)
question/type/gapselect/renderer.php
question/type/gapselect/tests/walkthrough_test.php

index 76d459d..9fd591a 100644 (file)
@@ -71,17 +71,9 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_
             }
         }
 
-        // If the text is short use non-breaking space.
-        $choose = '&nbsp;';
-        foreach ($selectoptions as $key => $text) {
-            if (strlen(get_string('choosedots')) / 2 <= strlen($text)) {
-                $choose = get_string('choosedots');
-                break;
-            }
-        }
-
+        // Use non-breaking space instead of 'Choose...'.
         $selecthtml = html_writer::select($selectoptions, $qa->get_qt_field_name($fieldname),
-                $value, $choose, $attributes) . ' ' . $feedbackimage;
+                        $value, '&nbsp;', $attributes) . ' ' . $feedbackimage;
         return html_writer::tag('span', $selecthtml, array('class' => 'control '.$groupclass));
     }
 
index 5e21fef..ba9ea8e 100644 (file)
@@ -60,9 +60,9 @@ class qtype_gapselect_walkthrough_test extends qbehaviour_walkthrough_test_base
         // Also note the ' ' in the p2 example below is a nbsp (used when names are short).
         $this->check_output_contains_selectoptions(
                 $this->get_contains_select_expectation('p1',
-                        ['' => get_string('choosedots'), '1' => 'quick', '2' => 'slow'], null, true),
+                        ['0' => '&nbsp;', '1' => 'quick', '2' => 'slow'], null, true),
                 $this->get_contains_select_expectation('p2',
-                        ['' => ' ', '1' => 'fox', '2' => 'dog'], null, true),
+                        ['0' => '&nbsp;', '1' => 'fox', '2' => 'dog'], null, true),
                 $this->get_contains_select_expectation('p3',
                         ['1' => 'lazy', '2' => 'assiduous'], null, true));