From: gbateson Date: Sat, 18 Mar 2006 23:47:56 +0000 (+0000) Subject: increase gap size for long answers in JCloze X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d95bcfff8dc89c8874d99916a6977b1b5297c485;p=moodle.git increase gap size for long answers in JCloze --- diff --git a/mod/hotpot/template/v6.php b/mod/hotpot/template/v6.php index e639cc5269..75d93f75a3 100644 --- a/mod/hotpot/template/v6.php +++ b/mod/hotpot/template/v6.php @@ -866,20 +866,33 @@ class hotpot_xml_quiz_template extends hotpot_xml_template_default { // initialize loop values $q = 0; $tags = 'data,gap-fill'; + $question_record = "$tags,question-record"; // loop through text and gaps do { $text = $this->parent->xml_value($tags, "[0]['#'][$q]"); $gap = ''; - if (($question="[$q]['#']") && $this->parent->xml_value("$tags,question-record", $question)) { + if (($question="[$q]['#']") && $this->parent->xml_value($question_record, $question)) { $gap .= ''; if ($this->v6_use_DropDownList()) { $gap .= ''; } else { - $gap .= ''; + // minimum gap size + $gapsize = 6; + + // increase gap size to length of longest answer for this gap + $a = 0; + while (($answer=$question."['answer'][$a]['#']") && $this->parent->xml_value($question_record, $answer)) { + $answertext = $this->parent->xml_value($question_record, $answer."['text'][0]['#']"); + $answertext = preg_replace('|&[#a-zA-Z0-9]+;|', 'x', $answertext); + $gapsize = max($gapsize, strlen($answertext)); + $a++; + } + + $gap .= ''; } if ($includeclues) { - $clue = $this->parent->xml_value("$tags,question-record", $question."['clue'][0]['#']"); + $clue = $this->parent->xml_value($question_record, $question."['clue'][0]['#']"); if (strlen($clue)) { $gap .= ''; }