Index: common.php =================================================================== --- common.php (revision 8748) +++ common.php (working copy) @@ -3983,16 +3983,16 @@ "caption"=>$clang->gT('Input box width')); $qattributes["use_dropdown"]=array( - "types"=>"1", + "types"=>"1F", 'category'=>$clang->gT('Other'), 'sortorder'=>100, 'inputtype'=>'singleselect', 'options'=>array(0=>$clang->gT('No'), 1=>$clang->gT('Yes')), 'default'=>0, - "help"=>$clang->gT('Use dual dropdown boxes instead of dual scales'), - "caption"=>$clang->gT('Dual dropdown')); - + "help"=>$clang->gT('Use dropdown boxes instead of scales'), + "caption"=>$clang->gT('Dropdown')); + $qattributes["scale_export"]=array( "types"=>"CEFGHLMOPWYZ1!:", 'category'=>$clang->gT('Other'), Index: qanda.php =================================================================== --- qanda.php (revision 8748) +++ qanda.php (working copy) @@ -5276,8 +5276,17 @@ } $columnswidth=100-$answerwidth; + if ($qidattributes['use_dropdown'] == 1) + { + $useDropdownLayout = true; + } + else + { + $useDropdownLayout = false; + } + $lresult = db_execute_assoc($lquery); //Checked - if ($lresult->RecordCount() > 0) + if ($useDropdownLayout === false && $lresult->RecordCount() > 0) { while ($lrow=$lresult->FetchRow()) { @@ -5453,7 +5462,124 @@ $answer = $answer_start . $answer_cols . $answer_head .$answer . "\t\n\n"; } - else + elseif ($useDropdownLayout === true && $lresult->RecordCount() > 0) + { + while ($lrow=$lresult->FetchRow()) + $labels[]=Array('code' => $lrow['code'], + 'answer' => $lrow['answer']); + $ansquery = "SELECT question FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND question like '%|%' "; + $ansresult = db_execute_assoc($ansquery); //Checked + if ($ansresult->RecordCount()>0) {$right_exists=true;$answerwidth=$answerwidth/2;} else {$right_exists=false;} + // $right_exists is a flag to find out if there are any right hand answer parts. If there arent we can leave out the right td column + if ($qidattributes['random_order']==1) { + $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); + } + else + { + $ansquery = "SELECT * FROM {$dbprefix}questions WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' ORDER BY question_order"; + } + $ansresult = db_execute_assoc($ansquery); //Checked + $anscount = $ansresult->RecordCount(); + $fn=1; + + $numrows = count($labels); + if ($ia[6] != 'Y' && $shownoanswer == 1) + { + ++$numrows; + } + if ($right_exists) + { + ++$numrows; + } + $cellwidth = round( ($columnswidth / $numrows ) , 1 ); + + $answer_start = "\n
| \n$answertext" + . $hiddenfield + . "\n\t | \n"; + + $answer .= "\t\n" + . "\n"; + + if (strpos($answertextsave,'|')) + { + $answertext=substr($answertextsave,strpos($answertextsave,'|')+1); + $answer .= "\t | $answertext | \n"; + } + elseif ($right_exists) + { + $answer .= "\t\n"; + } + + $answer .= " |
|---|
".$clang->gT("Error: There are no answer options for this question and/or they don't exist in this language.")."
\n"; $inputnames='';