MDL-47494 gapselect: Replace "Choose... " with non-breaking space when appropriate, #14429

This commit is contained in:
M Kassaei
2015-02-20 13:51:30 +00:00
committed by Tim Hunt
parent 4dc37d690e
commit 3cb75b2b15
+13 -3
View File
@@ -45,7 +45,8 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_
$value = $qa->get_last_qt_var($question->field($place));
$attributes = array(
'id' => $this->box_id($qa, 'p' . $place),
'id' => $this->box_id($qa, 'p' . $place),
'class' => 'place' . $place,
);
$groupclass = 'group' . $group;
@@ -65,13 +66,22 @@ class qtype_gapselect_renderer extends qtype_elements_embedded_in_question_text_
if (array_key_exists($fieldname, $response)) {
$fraction = (int) ($response[$fieldname] ==
$question->get_right_choice_for($place));
$attributes['class'] = $this->feedback_class($fraction);
$attributes['class'] .= ' ' . $this->feedback_class($fraction);
$feedbackimage = $this->feedback_image($fraction);
}
}
// If the text is short use non-breaking space.
$choose = ' ';
foreach ($selectoptions as $key => $text) {
if (strlen(get_string('choosedots')) / 2 <= strlen($text)) {
$choose = get_string('choosedots');
break;
}
}
$selecthtml = html_writer::select($selectoptions, $qa->get_qt_field_name($fieldname),
$value, get_string('choosedots'), $attributes) . ' ' . $feedbackimage;
$value, $choose, $attributes) . ' ' . $feedbackimage;
return html_writer::tag('span', $selecthtml, array('class' => 'control '.$groupclass));
}