From eba53585bd7fefa63e5ae39b9a83228995ef23ee Mon Sep 17 00:00:00 2001 From: pichetp Date: Sat, 26 Jan 2008 14:30:29 +0000 Subject: [PATCH] adjusting input display to answer length MDL-3274 --- question/type/multianswer/questiontype.php | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php index ad6f7b6a9c..6cb0c61aa5 100644 --- a/question/type/multianswer/questiontype.php +++ b/question/type/multianswer/questiontype.php @@ -315,8 +315,39 @@ class embedded_cloze_qtype extends default_questiontype { switch ($wrapped->qtype) { case 'shortanswer': case 'numerical': + $size = 1 ; + foreach ($answers as $answer) { + if (strlen(trim($answer->answer)) > $size ){ + $size = strlen(trim($answer->answer)); + } + } + if (strlen(trim($response))> $size ){ + $size = strlen(trim($response))+1; + } + $size = $size + rand(0,$size*0.15); + $size > 60 ? $size = 60 : $size = $size; + $styleinfo = "size=\".$size\""; + /** + * Uncomment the following lines if you want to limit for small sizes. + * Results may vary with browsers see MDL-3274 + */ + /* + if ($size < 2) { + $styleinfo = 'style="width: 1.1em;"'; + } + if ($size == 2) { + $styleinfo = 'style="width: 1.9em;"'; + } + if ($size == 3) { + $styleinfo = 'style="width: 2.3em;"'; + } + if ($size == 4) { + $styleinfo = 'style="width: 2.8em;"'; + } + */ + echo " "; + type=\"text\" value=\"".s($response, true)."\" ".$styleinfo." /> "; if (!empty($feedback) && !empty($USER->screenreader)) { echo "pixpath/i/feedback.gif\" alt=\"$feedback\" />"; } -- 2.39.5