// initialize loop values\r
$q = 0;\r
$tags = 'data,gap-fill';\r
+ $question_record = "$tags,question-record";\r
\r
// loop through text and gaps\r
do {\r
$text = $this->parent->xml_value($tags, "[0]['#'][$q]");\r
$gap = '';\r
- if (($question="[$q]['#']") && $this->parent->xml_value("$tags,question-record", $question)) {\r
+ if (($question="[$q]['#']") && $this->parent->xml_value($question_record, $question)) {\r
$gap .= '<span class="GapSpan" id="GapSpan'.$q.'">';\r
if ($this->v6_use_DropDownList()) {\r
$gap .= '<select id="Gap'.$q.'"><option value=""></option>'.$dropdownlist.'</select>';\r
} else {\r
- $gap .= '<input type="text" id="Gap'.$q.'" onfocus="TrackFocus('.$q.')" onblur="LeaveGap()" class="GapBox" size="6"></input>';\r
+ // minimum gap size\r
+ $gapsize = 6;\r
+\r
+ // increase gap size to length of longest answer for this gap\r
+ $a = 0;\r
+ while (($answer=$question."['answer'][$a]['#']") && $this->parent->xml_value($question_record, $answer)) {\r
+ $answertext = $this->parent->xml_value($question_record, $answer."['text'][0]['#']");\r
+ $answertext = preg_replace('|&[#a-zA-Z0-9]+;|', 'x', $answertext);\r
+ $gapsize = max($gapsize, strlen($answertext));\r
+ $a++;\r
+ }\r
+\r
+ $gap .= '<input type="text" id="Gap'.$q.'" onfocus="TrackFocus('.$q.')" onblur="LeaveGap()" class="GapBox" size="'.$gapsize.'"></input>';\r
}\r
if ($includeclues) {\r
- $clue = $this->parent->xml_value("$tags,question-record", $question."['clue'][0]['#']");\r
+ $clue = $this->parent->xml_value($question_record, $question."['clue'][0]['#']");\r
if (strlen($clue)) {\r
$gap .= '<button style="line-height: 1.0" class="FuncButton" onfocus="FuncBtnOver(this)" onmouseover="FuncBtnOver(this)" onblur="FuncBtnOut(this)" onmouseout="FuncBtnOut(this)" onmousedown="FuncBtnDown(this)" onmouseup="FuncBtnOut(this)" onclick="ShowClue('.$q.')">'.$cluecaption.'</button>';\r
}\r