You have not selected a survey!";
exit;
}
?>
'formbuilder','#'=>'start'));?>
/>
' multiple='multiple'>
\n\t\n";
$counter2=0;
//go through all the (multiple) answers
foreach($result[$key1] as $row1)
{
$row1 = array_values($row1);
foreach($row1 as $row)
{
$row = array_values($row);
/*
* filter form for numerical input
* - checkbox
* - greater than
* - less than
*/
$myfield1="K".$myfield.$row[0];
$myfield2="K{$myfield}".$row[0]."G";
$myfield3="K{$myfield}".$row[0]."L";
if ($counter2 == 4) { echo "\t \n\t\n"; $counter2=0;}
//start new TD
echo "\t";
//checkbox
echo " do we want to pre-check the checkbox?
if (isset($summary) && (array_search("K{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}", $summary) !== FALSE))
{echo " checked='checked'";}
echo " /> ";
//show speaker
echo _showSpeaker($flt[3]." - ".flattenText($row[1],true))." \n";?>
eT("Number greater than");?>:
"return goodchars(event,'0123456789.,')"));?>
eT("Number less than");?>:
"return goodchars(event,'0123456789.,')"));?>
increase counter
$counter2++;
}
}
break;
case "Q": // Multiple Short Text
//new section
echo "\t \n\t\n";
//get subqestions
$result[$key1] = Question::model()->getQuestionsForStatistics('title as code, question as answer', "parent_qid='$flt[0]' AND language = '{$language}'", 'question_order');
$counter2=0;
//loop through all answers
foreach($result[$key1] as $row)
{
$row = array_values($row);
//collecting data for output, for details see above (question type "N")
//we have one input field for each answer
$myfield2 = "Q".$myfield."$row[0]";
if ($counter2 == 4) {echo "\t \n\t\n"; $counter2=0;}
echo "\t";
echo " ";
echo _showSpeaker($flt[3]." - ".flattenText($row[1],true))
." \n"
."\t".$clang->gT("Responses containing").": \n";
echo CHtml::textField($myfield2,isset($_POST[$myfield2])?$_POST[$myfield2]:'',array())
."\t \n";
$counter2++;
}
echo "\t \n\t\n";
$counter=0;
break;
/*
* all "free text" types (T, U, S) get the same prefix ("T")
*/
case "T": // Long free text
case "U": // Huge free text
$myfield2="T$myfield";
echo "\t\n";
echo "\t "
." "._showSpeaker($niceqtext)
." \n"
."\t".$clang->gT("Responses containing").": \n"
.CHtml::textArea($myfield2,isset($_POST[$myfield2])?$_POST[$myfield2]:'',array('rows'=>'3','cols'=>'80'))
."\t \n";
break;
case "S": // Short free text
$myfield2="T$myfield";
echo "\t";
echo " "
." "._showSpeaker($niceqtext)
." \n"
."\t".$clang->gT("Responses containing").": \n"
.CHtml::textField($myfield2,isset($_POST[$myfield2])?$_POST[$myfield2]:'',array())
."\t \n";
break;
case "N": // Numerical
//textfields for greater and less than X
$myfield2="{$myfield}G";
$myfield3="{$myfield}L";
echo "\t".$clang->gT("Number greater than").": \n"
.CHtml::textField($myfield2,isset($_POST[$myfield2])?$_POST[$myfield2]:'',array( 'onkeypress'=>"return goodchars(event,'0123456789.,')" ))
."\t \n"
."\t".$clang->gT("Number less than").": \n"
.CHtml::textField($myfield3,isset($_POST[$myfield3])?$_POST[$myfield3]:'',array( 'onkeypress'=>"return goodchars(event,'0123456789.,')" ))
."\t \n";
//put field names into array
break;
case "|": // File Upload
// Number of files uploaded for greater and less than X
$myfield2 = "{$myfield}G";
$myfield3 = "{$myfield}L";
echo "\t".$clang->gT("Number of files greater than").": \n"
.CHtml::textField($myfield2,isset($_POST[$myfield2])?$_POST[$myfield2]:'',array( 'onkeypress'=>"return goodchars(event,'0123456789.,')" ))
." \n"
."\t".$clang->gT("Number of files less than").": \n"
.CHtml::textField($myfield3,isset($_POST[$myfield3])?$_POST[$myfield3]:'',array( 'onkeypress'=>"return goodchars(event,'0123456789.,')" ))
." \n";
break;
/*
* DON'T show any statistics for date questions
* because there aren't any statistics implemented yet!
*
* Only filtering by date is possible.
*
* See bug report #2539 and
* feature request #2620
*/
case "D": // Date
/*
* - input name
* - date equals
* - date less than
* - date greater than
*/
$myfield2="D$myfield";
$myfield3=$myfield2."eq";
$myfield4=$myfield2."less";
$myfield5=$myfield2."more";
echo "\t";
echo "";
echo _showSpeaker($niceqtext)
." \n"
."\t".$clang->gT("Date (YYYY-MM-DD) equals").": \n"
.CHtml::textField($myfield3,isset($_POST[$myfield3])?$_POST[$myfield3]:'',array() )
." \n"
."\t ".$clang->gT("Date is")." >= \n"
.CHtml::textField($myfield4,isset($_POST[$myfield4])?$_POST[$myfield4]:'',array() )
." "
.$clang->gT("AND/OR Date is")." <= "
.CHtml::textField($myfield5,isset($_POST[$myfield5])?$_POST[$myfield5]:'',array() )
." \n";
break;
case "5": // 5 point choice
//we need a list of 5 entries
for ($i=1; $i<=5; $i++)
{
echo "\t$i \n";
}
//End the select which starts before the CASE statement (around line 411)
echo"\t\n";
break;
case "G": // Gender
echo "\t".$clang->gT("Female")." \n";
echo "\t".$clang->gT("Male")." \n\t\n";
echo "\t \n";
break;
case "Y": // Yes\No
echo "\t".$clang->gT("Yes")." \n"
."\t".$clang->gT("No")." \n";
break;
case "I": // Language
$survlangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
$survlangs[] = Survey::model()->findByPk($surveyid)->language;
foreach ($survlangs as $availlang)
{
echo "\t".getLanguageNameFromCode($availlang,false)." \n";
}
break;
//----------------------- ARRAYS --------------------------
case "A": // ARRAY OF 5 POINT CHOICE QUESTIONS
echo "\t \n\t\n";
//get answers
$result[$key1] = Question::model()->getQuestionsForStatistics('title, question', "parent_qid='$flt[0]' AND language = '{$language}'", 'question_order');
$counter2=0;
//check all the results
foreach($result[$key1] as $row)
{
$row = array_values($row);
$myfield2 = $myfield.$row[0];
echo "\n";
if ($counter2 == 4) {echo "\t \n\t\n"; $counter2=0;}
echo "\t"
." "
._showSpeaker($niceqtext." ".str_replace("'", "`", $row[1])." - # ".$flt[3])
." \n"
."\t\n";
//there are always exactly 5 values which have to be listed
for ($i=1; $i<=5; $i++)
{
echo "\t$i \n";
}
echo "\t \n\t \n";
$counter2++;
//add this to all the other fields
}
echo "\t \n\t\n";
$counter=0;
break;
//just like above only a different loop
case "B": // ARRAY OF 10 POINT CHOICE QUESTIONS
echo "\t \n\t\n";
$counter2=0;
foreach($result[$key1] as $row)
{
$row=array_values($row);
$myfield2 = $myfield . "$row[0]";
echo "\n";
if ($counter2 == 4) {echo "\t \n\t\n"; $counter2=0;}
echo "\t"; //heading
echo " "
._showSpeaker($niceqtext." ".str_replace("'", "`", $row[1])." - # ".$flt[3])
." \n"
."\t\n";
//here wo loop through 10 entries to create a larger output form
for ($i=1; $i<=10; $i++)
{
echo "\t$i \n";
}
echo "\t \n\t \n";
$counter2++;
}
echo "\t \n\t\n";
$counter=0;
break;
case "C": // ARRAY OF YES\No\$clang->gT("Uncertain") QUESTIONS
echo "\t \n\t\n";
$counter2=0;
//loop answers
foreach($result[$key1] as $row)
{
$row=array_values($row);
$myfield2 = $myfield . "$row[0]";
echo "\n";
if ($counter2 == 4) {echo "\t \n\t\n"; $counter2=0;}
echo "\t"
." "
._showSpeaker($niceqtext." ".str_replace("'", "`", $row[1])." - # ".$flt[3])
." \n"
."\t\n"
."\t".$clang->gT("Yes")." \n"
."\t".$clang->gT("Uncertain")." \n"
."\t".$clang->gT("No")." \n"
."\t \n\t \n";
$counter2++;
//add to array
}
echo "\t \n\t\n";
$counter=0;
break;
//similiar to the above one
case "E": // ARRAY OF Increase/Same/Decrease QUESTIONS
echo "\t \n\t\n";
$counter2=0;
foreach($result[$key1] as $row)
{
$row=array_values($row);
$myfield2 = $myfield . "$row[0]";
echo "\n";
if ($counter2 == 4) {echo "\t \n\t\n"; $counter2=0;}
echo "\t"
." "
._showSpeaker($niceqtext." ".str_replace("'", "`", $row[1])." - # ".$flt[3])
." \n"
."\t\n"
."\t".$clang->gT("Increase")." \n"
."\t".$clang->gT("Same")." \n"
."\t".$clang->gT("Decrease")." \n"
."\t \n\t \n";
$counter2++;
}
echo "\t \n\t\n";
$counter=0;
break;
case ";": //ARRAY (Multi Flex) (Text)
echo "\t \n\t\n";
$counter2=0;
foreach($result[$key1] as $key => $row)
{
$row = array_values($row);
$fresult = $fresults[$key1][$key];
foreach($fresult as $frow)
{
$myfield2 = "T".$myfield . $row[0] . "_" . $frow['title'];
echo "\n";
if ($counter2 == 4) {echo "\t \n\t\n"; $counter2=0;}
echo "\t"
." "
._showSpeaker($niceqtext." ".str_replace("'", "`", $row[1]." [".$frow['question']."]")." - ".$row[0]."/".$frow['title'])
." \n";
//echo $fquery;
echo "\t".$clang->gT("Responses containing").": \n"
.CHtml::textField($myfield2,isset($_POST[$myfield2])?$_POST[$myfield2]:'',array() )
." \n";
$counter2++;
}
}
echo "\t\n";
$counter=0;
break;
case ":": //ARRAY (Multi Flex) (Numbers)
echo "\t \n\t\n";
$counter2=0;
//Get qidattributes for this question
$qidattributes=getQuestionAttributeValues($flt[0]);
if (trim($qidattributes['multiflexible_max'])!='' && trim($qidattributes['multiflexible_min']) ==''){
$maxvalue=$qidattributes['multiflexible_max'];
$minvalue=1;
}
if (trim($qidattributes['multiflexible_min'])!='' && trim($qidattributes['multiflexible_max']) ==''){
$minvalue=$qidattributes['multiflexible_min'];
$maxvalue=$qidattributes['multiflexible_min'] + 10;
}
if (trim($qidattributes['multiflexible_min'])=='' && trim($qidattributes['multiflexible_max']) ==''){
$minvalue=1;
$maxvalue=10;
}
if (trim($qidattributes['multiflexible_min']) !='' && trim($qidattributes['multiflexible_max']) !=''){
if($qidattributes['multiflexible_min'] < $qidattributes['multiflexible_max']){
$minvalue=$qidattributes['multiflexible_min'];
$maxvalue=$qidattributes['multiflexible_max'];
}
}
if (trim($qidattributes['multiflexible_step'])!='') {
$stepvalue=$qidattributes['multiflexible_step'];
} else {
$stepvalue=1;
}
if ($qidattributes['multiflexible_checkbox']!=0)
{
$minvalue=0;
$maxvalue=1;
$stepvalue=1;
}
foreach($result[$key1] as $row)
{
$row = array_values($row);
$fresult = Question::model()->getQuestionsForStatistics('*', "parent_qid='$flt[0]' AND language = '{$language}' AND scale_id = 1", 'question_order, title');
foreach($fresult as $frow)
{
$myfield2 = $myfield . $row[0] . "_" . $frow['title'];
echo "\n";
if ($counter2 == 4) {echo "\t \n\t\n"; $counter2=0;}
echo "\t"
." "
._showSpeaker($niceqtext." ".str_replace("'", "`", $row[1]." [".$frow['question']."]")." - ".$row[0]."/".$frow['title'])
." \n";
//echo $fquery;
echo "\t\n";
for($ii=$minvalue; $ii<=$maxvalue; $ii+=$stepvalue)
{
echo "\t$ii \n";
}
echo "\t \n\t \n";
$counter2++;
}
}
echo "\t\n";
$counter=0;
break;
/*
* For question type "F" and "H" you can use labels.
* The only difference is that the labels are applied to column heading
* or rows respectively
*/
case "F": // FlEXIBLE ARRAY
case "H": // ARRAY (By Column)
//echo "\t \n\t\n";
//Get answers. We always use the answer code because the label might be too long elsewise
$counter2=0;
//check all the answers
foreach($result[$key1] as $key=>$row)
{
$row=array_values($row);
$myfield2 = $myfield . "$row[0]";
echo "\n";
if ($counter2 == 4)
{
echo "\t \n\t\n";
$counter2=0;
}
echo "\t"
." "
._showSpeaker($niceqtext." ".str_replace("'", "`", $row[1])." - # ".$flt[3])
." \n";
/*
* when hoovering the speaker symbol we show the whole question
*
* flt[6] is the label ID
*
* table "labels" contains
* - lid
* - code
* - title
* - sortorder
* - language
*/
$fresult = $fresults[$key1];
//for debugging only:
//echo $fquery;
//creating form
echo "\t\n";
//loop through all possible answers
foreach($fresult as $frow)
{
echo "\t({$frow['code']}) ".flattenText($frow['answer'],true)." \n";
}
echo "\t \n\t \n";
$counter2++;
//add fields to main array
}
//echo "\t\n";
$counter=0;
break;
case "R": //RANKING
echo "\t \n\t\n";
//get some answers
//get number of answers
$count = count($result[$key1]);
//lets put the answer code and text into the answers array
foreach($result[$key1] as $row)
{
$answers[]=array($row['code'], $row['answer']);
}
$counter2=0;
//loop through all answers. if there are 3 items to rate there will be 3 statistics
for ($i=1; $i<=$count; $i++)
{
//adjust layout depending on counter
if ($counter2 == 4) {echo "\t \n\t\n"; $counter2=0;}
//myfield is the SGQ identifier
//myfield2 is just used as comment in HTML like "R40X34X1721-1"
$myfield2 = "R" . $myfield . $i . "-" . strlen($i);
$myfield3 = $myfield . $i;
echo "\n"
."\t"
." "
._showSpeaker($niceqtext." ".str_replace("'", "`", $trow[1])." - # ".$flt[3])
." \n"
."\t\n";
//output lists of ranking items
foreach ($answers as $ans)
{
echo "\t".flattenText($ans[1])." \n";
}
echo "\t \n\t \n";
$counter2++;
//add averything to main array
}
echo "\t \n\t\n";
//Link to rankwinner script - awaiting completion - probably never gonna happen. Mystery creator.
// echo "\t \n\t\n"
// .""
// ." "
// ." \n\t\n";
$counter=0;
unset($answers);
break;
//Boilerplate questions are only used to put some text between other questions -> no analysis needed
case "X": //This is a boilerplate question and it has no business in this script
echo "\t ";
break;
case "1": // MULTI SCALE
echo "\t \n\t\n";
//special dual scale counter
$counter2=0;
//loop through answers
foreach($result[$key1] as $row)
{
$row=array_values($row);
//----------------- LABEL 1 ---------------------
//myfield2 = answer code.
$myfield2 = $myfield . "$row[0]#0";
//3 lines of debugging output
echo "\n";
//some layout adaptions -> new line after 4 entries
if ($counter2 == 4)
{
echo "\t \n\t\n";
$counter2=0;
}
//output checkbox and question/label text
echo "\t";
echo " "
._showSpeaker($niceqtext." [".str_replace("'", "`", $row[1])."] - ".$clang->gT("Label").": ".$labeltitle)
." \n";
/* get labels
* table "labels" contains
* - lid
* - code
* - title
* - sortorder
* - language
*/
$fresult = Answer::model()->getQuestionsForStatistics('*', "qid='$flt[0]' AND language = '{$language}' AND scale_id = 0", 'sortorder, code');
//this is for debugging only
//echo $fquery;
echo "\t\n";
//list answers
foreach($fresult as $frow)
{
echo "\t({$frow['code']}) ".flattenText($frow['answer'],true)." \n";
}
echo "\t \n\t \n";
$counter2++;
//----------------- LABEL 2 ---------------------
//myfield2 = answer code
$myfield2 = $myfield . "$row[0]#1";
//3 lines of debugging output
echo "\n";
//some layout adaptions -> new line after 4 entries
if ($counter2 == 4)
{
echo "\t \n\t\n";
$counter2=0;
}
//output checkbox and question/label text
echo "\t";
echo " "
._showSpeaker($niceqtext." [".str_replace("'", "`", $row[1])."] - ".$clang->gT("Label").": ".$labeltitle2)
." \n";
$fresult = Answer::model()->getQuestionsForStatistics('*', "qid='$flt[0]' AND language = '$language' AND scale_id = 1", 'sortorder, code');
//this is for debugging only
//echo $fquery;
echo "\t\n";
//list answers
foreach($fresult as $frow)
{
echo "\t({$frow['code']}) ".flattenText($frow['answer'],true)." \n";
}
echo "\t \n\t \n";
$counter2++;
} //end WHILE -> loop through all answers
echo "\t\n";
$counter=0;
break;
case "P": //P - Multiple choice with comments
case "M": //M - Multiple choice
//loop through answers
foreach($result[$key1] as $row)
{
$row=array_values($row);
echo "\t'.flattenText($row[1],true)." \n";
}
echo "\t\n\t \n";
break;
/*
* This question types use the default settings:
* L - List (Radio)
O - List With Comment
P - Multiple choice with comments
! - List (Dropdown)
*/
default:
//loop through answers
foreach($result[$key1] as $row)
{
$row=array_values($row);
echo "\t'.flattenText($row[1],true)." \n";
}
echo "\t\n\t\n";
break;
} //end switch -> check question types and create filter forms
$currentgroup=$flt[1];
if (!isset($counter))
{
$counter=0;
}
$counter++;
$previousquestiontype = $flt[2];
?>