diff --git a/admin/printablesurvey.php b/admin/printablesurvey.php index c4ab0e05185..04d481e6a57 100644 --- a/admin/printablesurvey.php +++ b/admin/printablesurvey.php @@ -138,6 +138,7 @@ function try_debug($line) { $surveyname = ""; } + $survey_output = array( 'SITENAME' => $sitename ,'SURVEYNAME' => $surveyname @@ -434,9 +435,9 @@ function star_replace($input) $x=0; $distinctquery="SELECT cqid, method, cfieldname, value FROM ".db_table_name("conditions")." - WHERE ".db_table_name("conditions").".qid={$deqrow['qid']} - AND ".db_table_name("conditions").".scenario={$scenariorow['scenario']} - group by cqid, method + WHERE ".db_table_name("conditions").".qid={$deqrow['qid']} + AND ".db_table_name("conditions").".scenario={$scenariorow['scenario']} + group by cqid, method, cfieldname, value ORDER BY cqid"; $distinctresult=db_execute_assoc($distinctquery); //Loop through each condition for a particular scenario. @@ -643,7 +644,7 @@ function star_replace($input) } // while break; } // switch - + // Now let's complete the answer text with the answer_section $answer_section=""; switch($conrow['type']) @@ -755,20 +756,20 @@ function star_replace($input) ++$total_questions; - + //TIBO map question qid to their q number $mapquestionsNumbers[$deqrow['qid']]=$total_questions; //END OF GETTING CONDITIONS $qid = $deqrow['qid']; $fieldname = "$surveyid"."X"."$gid"."X"."$qid"; - + if(isset($showsgqacode) && $showsgqacode == true) { $deqrow['question'] = $deqrow['question']."
".$clang->gT("ID:")." $fieldname
". - $clang->gT("Question code:")." ".$deqrow['title']; + $clang->gT("Question code:")." ".$deqrow['title']; } - + $question = array( 'QUESTION_NUMBER' => $total_questions // content of the question code field ,'QUESTION_CODE' => $deqrow['title'] @@ -784,7 +785,7 @@ function star_replace($input) ,'QUESTIONHELP' => '' // content of the question help field. ,'ANSWER' => '' // contains formatted HTML answer ); - + if ($deqrow['mandatory'] == 'Y') { @@ -804,7 +805,7 @@ function star_replace($input) { $hh = $deqrow['help']; $question['QUESTIONHELP'] = $hh; - + if(isset($_POST['printableexport'])){$pdf->helptextintopdf($hh);} } @@ -814,7 +815,7 @@ function star_replace($input) $question['QUESTION_CLASS'] .=' breakbefore '; } - + if (isset($qidattributes['maximum_chars']) && $qidattributes['maximum_chars']!='') { $question['QUESTION_CLASS'] ="max-chars-{$qidattributes['maximum_chars']} ".$question['QUESTION_CLASS']; } @@ -1020,7 +1021,7 @@ function star_replace($input) $question['ANSWER'] .= $wrapper['item-start'].input_type_image('checkbox',$mearow['question'])."\n\t\t".$mearow['question'].addsgqacode(" (".$fieldname.$mearow['title'].") ").$wrapper['item-end']; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$mearow['answer']);} // $upto++; - + ++$rowcounter; if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols']) { @@ -1127,7 +1128,7 @@ function star_replace($input) if (isset($qidattributes['slider_layout']) && $qidattributes['slider_layout']==1) { $mearow['question']=explode(':',$mearow['question']); - $mearow['question']=$mearow['question'][0]; + $mearow['question']=$mearow['question'][0]; } $question['ANSWER'] .= "\t
  • \n\t\t".$mearow['question']."\n\t\t".input_type_image('text',$mearow['question'],$width).addsgqacode(" (".$fieldname.$mearow['title'].") ")."\n\t
  • \n"; if(isset($_POST['printableexport'])){$pdf->intopdf($mearow['question'].": ____________________");} @@ -1223,9 +1224,9 @@ function star_replace($input) { $question['ANSWER'] .= "\t\t\n"; $rowclass = alternation($rowclass,'row'); - + //semantic differential question type? - if (strpos($mearow['question'],'|')) + if (strpos($mearow['question'],'|')) { $answertext = substr($mearow['question'],0, strpos($mearow['question'],'|')).addsgqacode(" (".$fieldname.$mearow['title'].")")." "; } @@ -1243,7 +1244,7 @@ function star_replace($input) } $answertext .= $mearow['question']; - + //semantic differential question type? if (strpos($mearow['question'],'|')) { @@ -1327,7 +1328,7 @@ function star_replace($input) $question['ANSWER'] .= "\t\t\t".input_type_image('radio',$clang->gT("Uncertain"))."\n"; $question['ANSWER'] .= "\t\t\t".input_type_image('radio',$clang->gT("No"))."\n"; $question['ANSWER'] .= "\t\t\n"; - + $pdfoutput[$j]=array($mearow['question']," o ".$clang->gT("Yes")," o ".$clang->gT("Uncertain")," o ".$clang->gT("No")); $j++; $rowclass = alternation($rowclass,'row'); @@ -1411,7 +1412,7 @@ function star_replace($input) } $meaquery = "SELECT * FROM ".db_table_name("questions")." WHERE parent_qid={$deqrow['qid']} AND scale_id=0 AND language='{$surveyprintlang}' ORDER BY question_order"; $mearesult = db_execute_assoc($meaquery); - + if ($checkboxlayout === false) { if ($stepvalue > 1) @@ -1433,14 +1434,14 @@ function star_replace($input) $question['ANSWER'] .= "\n\n\t\n\t\t\n\t\t\t\n"; $fquery = "SELECT * FROM ".db_table_name("questions")." WHERE parent_qid={$deqrow['qid']} AND scale_id=1 AND language='{$surveyprintlang}' ORDER BY question_order"; - $fresult = db_execute_assoc($fquery); - + $fresult = db_execute_assoc($fquery); + $fcount = $fresult->RecordCount(); $fwidth = "120"; $i=0; $pdfoutput = array(); $pdfoutput[0][0]=' '; - + //array to temporary store X axis question codes $xaxisarray = array(); while ($frow = $fresult->FetchRow()) @@ -1448,9 +1449,9 @@ function star_replace($input) $question['ANSWER'] .= "\t\t\t\n"; $i++; $pdfoutput[0][$i]=$frow['question']; - + //add current question code - $xaxisarray[$i] = $frow['title']; + $xaxisarray[$i] = $frow['title']; } $question['ANSWER'] .= "\t\t\n\t\n\n\t\n"; $a=1; //Counter for pdfoutput @@ -1512,15 +1513,15 @@ function star_replace($input) $i=0; $pdfoutput=array(); $pdfoutput[0][0]=''; - + //array to temporary store X axis question codes - $xaxisarray = array(); + $xaxisarray = array(); while ($frow = $fresult->FetchRow()) { $question['ANSWER'] .= "\t\t\t\n"; $i++; $pdfoutput[0][$i]=$frow['question']; - + //add current question code $xaxisarray[$i] = $frow['title']; } @@ -1613,17 +1614,17 @@ function star_replace($input) $question['ANSWER'] .= "\t\t\n"; $rowclass = alternation($rowclass,'row'); if (trim($answertext)=='') $answertext=' '; - + //semantic differential question type? - if (strpos($mearow['question'],'|')) + if (strpos($mearow['question'],'|')) { $answertext = substr($mearow['question'],0, strpos($mearow['question'],'|')).addsgqacode(" (".$fieldname.$mearow['title'].")")." "; } else { $answertext=$mearow['question'].addsgqacode(" (".$fieldname.$mearow['title'].")"); - } - + } + if (trim($qidattributes['answer_width'])!='') { $sInsertStyle=' style="width:'.$qidattributes['answer_width'].'%" '; @@ -1633,7 +1634,7 @@ function star_replace($input) $sInsertStyle=''; } $question['ANSWER'] .= "\t\t\t\n"; - + $pdfoutput[$counter][0]=$answertext; for ($i=1; $i<=$fcount; $i++) { @@ -1644,7 +1645,7 @@ function star_replace($input) $counter++; $answertext=$mearow['question']; - + //semantic differential question type? if (strpos($mearow['question'],'|')) { @@ -1696,18 +1697,18 @@ function star_replace($input) $fcount1 = $fresult1->RecordCount(); $fwidth = "120"; $l2=0; - + //array to temporary store second scale question codes - $scale2array = array(); + $scale2array = array(); while ($frow1 = $fresult1->FetchRow()) { $printablesurveyoutput2 .="\t\t\t\n"; $pdfoutput[1][$l2]=$frow['answer']; - + //add current question code $scale2array[$l2] = $frow1['code']; - - $l2++; + + $l2++; } // build header if needed if ($leftheader != '' || $rightheader !='') @@ -1760,7 +1761,7 @@ function star_replace($input) $question['ANSWER'] .= "\t\t\t\n"; } $question['ANSWER'] .= "\t\t\n"; - + //increase subquestion counter $sqcounter++; } @@ -1946,10 +1947,10 @@ function array_filter_help($qidattributes, $surveyprintlang, $surveyid) { /* * $code: Text string containing the reference (column heading) for the current (sub-) question - * + * * Checks if the $showsgqacode setting is enabled at config and adds references to the column headings * to the output so it can be used as a code book for customized SQL queries when analysing data. - * + * * return: adds the text string to the overview */ function addsgqacode($code)
     {$frow['question']}
    {$frow['question']}
    $answertext{$frow1['answer']}$answertext