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"; + + $answer = "\t\n"; + $trbc = ''; + $inputnames=array(); + + while ($ansrow = $ansresult->FetchRow()) + { + $myfname = $ia[1].$ansrow['title']; + $trbc = alternation($trbc , 'row'); + $answertext=answer_replace($ansrow['question']); + $answertextsave=$answertext; + if (strpos($answertext,'|')) + { + $answertext=substr($answertext,0, strpos($answertext,'|')); + } + /* Check if this item has not been answered: the 'notanswered' variable must be an array, + containing a list of unanswered questions, the current question must be in the array, + and there must be no answer available for the item in this session. */ + + if (strpos($answertext,'|')) {$answerwidth=$answerwidth/2;} + + if ((is_array($notanswered)) && (array_search($ia[1], $notanswered) !== FALSE) && ($_SESSION[$myfname] == '') ) { + $answertext = ''.$answertext.''; + } + // Get array_filter stuff + list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname); + $answer .= $htmltbody2; + + $answer .= "\n" + . "\t\n"; + + $answer .= "\t\n"; + } + elseif ($right_exists) + { + $answer .= "\t\n"; + } + + $answer .= "\n"; + $inputnames[]=$myfname; + //IF a MULTIPLE of flexi-redisplay figure, repeat the headings + $fn++; + } + + $answer = $answer_start . $answer . "\t\n
\n$answertext" + . $hiddenfield + . "\n\t\n" + . "\n"; + + if (strpos($answertextsave,'|')) + { + $answertext=substr($answertextsave,strpos($answertextsave,'|')+1); + $answer .= "\t$answertext 
\n"; + } + else { $answer = "\n

".$clang->gT("Error: There are no answer options for this question and/or they don't exist in this language.")."

\n"; $inputnames='';