How to set the size of HTML input element

Dieser Forumsbeitrag wurde gelöscht.

Anzahl Antworten: 3
Der Inhalt des Forumsbeitrags wurde gelöscht und kann nicht weiter angezeigt werden.
Als Antwort auf gelöscht

Re: How to set the size of HTML input element

von Tim Hunt -
Nutzerbild von Core developers Nutzerbild von Documentation writers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Peer reviewers Nutzerbild von Plugin developers
I have never really understood how browsers turn the size="" attribute into an actual size. As long as there is enough space, I would not worry if it was slightly too big.

P.S. Forum search: You have go to advanced search to specify a forum.
Als Antwort auf Tim Hunt

Dieser Forumsbeitrag wurde gelöscht.

Der Inhalt des Forumsbeitrags wurde gelöscht und kann nicht weiter angezeigt werden.
Als Antwort auf gelöscht

Re: How to set the size of HTML input element

von Joseph Rézeau -
Nutzerbild von Core developers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Plugin developers Nutzerbild von Testers Nutzerbild von Translators

Hi Pierre and Tim,

I was not aware of MDL-3274 which is an old bug recently revived. Further to this discussion (which did not spark a lot of reactions at the timewink) I have added the following to my local version of multianswer/questiontype.php and am quite happy with it. I see no reason to add a random length element as suggested by Pierre in the bug tracker discussion. We must not be paranoidevil about the provided input length "giving away" the answer to the student, just practical that input length should be reasonably long enough to accomodate the longest correct answer (if there are more than one).

case 'shortanswer':
case 'numerical':
// set length of answer input field to length of longest expected answer
$snmaxlen= 0;
foreach ($answers as $snanswer) {
 if (strlen($snanswer->answer) > $snmaxlen){
 $snmaxlen = strlen($snanswer->answer);
 }
}
if ($snmaxlen<6){ $snmaxlen= 6; }

Joseph