diff --git a/qanda.php b/qanda.php index 7d08087b33b..487ddd2245c 100644 --- a/qanda.php +++ b/qanda.php @@ -572,6 +572,15 @@ function do_list_radio($ia) global $dbprefix, $dropdowns, $dropdownthreshold, $lwcdropdowns; global $shownoanswer; $answer=""; + $qidattributes=getQuestionAttributes($ia[0]); + if ($displaycols=arraySearchByKey("display_columns", $qidattributes, "attribute", 1)) + { + $dcols=$displaycols['value']; + } + else + { + $dcols=0; + } if (isset($defexists)) {unset ($defexists);} $query = "SELECT other FROM {$dbprefix}questions WHERE qid=".$ia[0]; $result = mysql_query($query); @@ -579,11 +588,26 @@ function do_list_radio($ia) $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] ORDER BY sortorder, answer"; $ansresult = mysql_query($ansquery) or die("Couldn't get answers
$ansquery
".mysql_error()); $anscount = mysql_num_rows($ansresult); - $answer .= "\n\t\t\t\t\t\n" - . "\t\t\t\t\t\t\n" - . "\t\t\t\t\t\t\t
\n"; + $divider=""; + $maxrows=0; + if ($dcols >0 && $anscount > $dcols) //Break into columns + { + $denominator=$dcols; //Change this to set the number of columns + $width=sprintf("%0d", 100/$denominator); + $maxrows=ceil(100*($anscount/$dcols)/100); //Always rounds up to nearest whole number + $answer .= "\n \n
"; + $divider=" "; + } + else + { + $answer .= "\n\t\t\t\t\t\n" + . "\t\t\t\t\t\t\n" + . "\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\n" @@ -962,10 +991,10 @@ function do_multiplechoice($ia) $maxrows=0; if ($dcols >0 && $anscount > $dcols) //Break into columns { - $denominator=$dcols; //Change this to set the number of columns - $width=sprintf("%0d", 100/$denominator); - $maxrows=sprintf("%0d", $anscount/$denominator)+1; - $answer .= "
\n"; + } + $rowcounter=0; while ($ansrow = mysql_fetch_array($ansresult)) { + $rowcounter++; $answer .= "\t\t\t\t\t\t\t\t
\n"; $inputnames[]=$thisfieldname; + if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } if ($ia[6] != "Y" && $shownoanswer == 1) { + $rowcounter++; $answer .= "\t\t\t\t\t\t "._NOANSWER."\n"; + if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } $answer .= "\t\t\t\t\t\t\t
\n
"; + + $width=sprintf("%0d", 100/$dcols); + $maxrows=ceil(100*($anscount/$dcols)/100); //Always rounds up to nearest whole number + $answer .= "\n \n \n" - . "\t\t\t\t\t\n" - . "\t\t\t\t\n" + $answer .= "\t\t\t\t\t\n"; + if ($dcols <1) + { //This just makes a single column look a bit nicer + $answer .= "\t\t\t\t\t\n"; + } + $answer .= "\t\t\t\t\n" . "\t\t\t
"; $divider=" "; } $fn = 1; @@ -999,9 +1028,12 @@ function do_multiplechoice($ia) $anscount++; if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } - $answer .= "\t\t\t\t\t 
 
\n"; return array($answer, $inputnames); } @@ -1120,14 +1152,43 @@ function do_numerical($ia) function do_shortfreetext($ia) { - $answer = "\t\t\t\n"; + $qidattributes=getQuestionAttributes($ia[0]); + if ($maxchars=arraySearchByKey("maximum_chars", $qidattributes, "attribute", 1)) + { + $maxsize=$maxchars['value']; + } + else + { + $maxsize=255; + } + $answer = "\t\t\t\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_longfreetext($ia) { - $answer = "\n"; $inputnames[]=$ia[1]; @@ -1136,7 +1197,25 @@ function do_longfreetext($ia) function do_hugefreetext($ia) { - $answer = "\n"; $inputnames[]=$ia[1];