PageRenderTime 31ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/limesurvey/admin/statistics.php

https://github.com/tacman/citrus
PHP | 1680 lines | 1081 code | 275 blank | 324 comment | 173 complexity | d266707484116d47e06f65a3907e2864 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, LGPL-2.1, LGPL-3.0, GPL-2.0, Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. * LimeSurvey
  4. * Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
  5. * All rights reserved.
  6. * License: GNU/GPL License v2 or later, see LICENSE.php
  7. * LimeSurvey is free software. This version may have been modified pursuant
  8. * to the GNU General Public License, and as distributed it includes or
  9. * is derivative of works licensed under the GNU General Public License or
  10. * other free or open source software licenses.
  11. * See COPYRIGHT.php for copyright notices and details.
  12. *
  13. * $Id: statistics.php 9648 2011-01-07 13:06:39Z c_schmitz $
  14. *
  15. */
  16. /*
  17. * We need this later:
  18. * 1 - Array Dual Scale
  19. * 5 - 5 Point Choice
  20. * A - Array (5 Point Choice)
  21. * B - Array (10 Point Choice)
  22. * C - Array (Yes/No/Uncertain)
  23. * D - Date
  24. * E - Array (Increase, Same, Decrease)
  25. * F - Array (Flexible Labels)
  26. * G - Gender
  27. * H - Array (Flexible Labels) by Column
  28. * I - Language Switch
  29. * K - Multiple Numerical Input
  30. * L - List (Radio)
  31. * M - Multiple choice
  32. * N - Numerical Input
  33. * O - List With Comment
  34. * P - Multiple choice with comments
  35. * Q - Multiple Short Text
  36. * R - Ranking
  37. * S - Short Free Text
  38. * T - Long Free Text
  39. * U - Huge Free Text
  40. * X - Boilerplate Question
  41. * Y - Yes/No
  42. * ! - List (Dropdown)
  43. * : - Array (Flexible Labels) multiple drop down
  44. * ; - Array (Flexible Labels) multiple texts
  45. * | - File Upload
  46. Debugging help:
  47. echo '<script language="javascript" type="text/javascript">alert("HI");</script>';
  48. */
  49. //split up results to extend statistics -> NOT WORKING YET! DO NOT ENABLE THIS!
  50. $showcombinedresults = 0;
  51. /*
  52. * this variable is used in the function shortencode() which cuts off a question/answer title
  53. * after $maxchars and shows the rest as tooltip
  54. */
  55. $maxchars = 50;
  56. //don't call this script directly!
  57. if (isset($_REQUEST['homedir'])) {die('You cannot start this script directly');}
  58. //some includes, the progressbar is used to show a progressbar while generating the graphs
  59. //include_once("login_check.php");
  60. require_once('classes/core/class.progressbar.php');
  61. //we collect all the output within this variable
  62. $statisticsoutput ='';
  63. //output for chosing questions to cross query
  64. $cr_statisticsoutput = '';
  65. // This gets all the 'to be shown questions' from the POST and puts these into an array
  66. $summary=returnglobal('summary');
  67. $statlang=returnglobal('statlang');
  68. //if $summary isn't an array we create one
  69. if (isset($summary) && !is_array($summary)) {
  70. $summary = explode("+", $summary);
  71. }
  72. //no survey ID? -> come and get one
  73. if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
  74. //still no survey ID -> error
  75. if (!$surveyid)
  76. {
  77. //need to have a survey id
  78. $statisticsoutput .= "<center>You have not selected a survey!</center>";
  79. exit;
  80. }
  81. // Set language for questions and answers to base language of this survey
  82. $language = GetBaseLanguageFromSurveyID($surveyid);
  83. //pick the best font file if font setting is 'auto'
  84. if ($chartfontfile=='auto')
  85. {
  86. $chartfontfile='vera.ttf';
  87. if ( $language=='ar')
  88. {
  89. $chartfontfile='KacstOffice.ttf';
  90. }
  91. elseif ($language=='fa' )
  92. {
  93. $chartfontfile='KacstFarsi.ttf';
  94. }
  95. elseif ($language=='el' )
  96. {
  97. $chartfontfile='DejaVuLGCSans.ttf';
  98. }
  99. elseif ($language=='zh-Hant-HK' || $language=='zh-Hant-TW' || $language=='zh-Hans')
  100. {
  101. $chartfontfile='fireflysung.ttf';
  102. }
  103. }
  104. //$statisticsoutput .= "
  105. //<script type='text/javascript'' >
  106. //<!--
  107. //function selectAll(name){
  108. // //var name=name;
  109. //
  110. // alert(name);
  111. //
  112. // temp = document.+name+.elements.length;
  113. //
  114. // for (i=0; i < temp; i++) {
  115. // if(document.+name+.elements[i].checked == 1)
  116. // {document.+name+.elements[i].checked = 0;
  117. // document.+name+.+name+_btn.value = 'Select All'; }
  118. // else {document.+name.elements[i].checked = 1;
  119. // document.+name+.+name+_btn.value = 'Deselect All'; }
  120. // }
  121. //}
  122. ////-->
  123. //</script>";
  124. //hide/show the filter
  125. //filtersettings by default aren't shown when showing the results
  126. $statisticsoutput .= '<script type="text/javascript" src="scripts/statistics.js"></script>';
  127. //headline with all icons for available statistic options
  128. //Get the menubar
  129. $statisticsoutput .= browsemenubar($clang->gT("Quick statistics"))
  130. //we need a form which can pass the selected data later
  131. ."<form method='post' name='formbuilder' action='$scriptname?action=statistics#start'>\n";
  132. //Select public language file
  133. $query = "SELECT datestamp FROM {$dbprefix}surveys WHERE sid=$surveyid";
  134. $result = db_execute_assoc($query) or safe_die("Error selecting language: <br />".$query."<br />".$connect->ErrorMsg());
  135. /*
  136. * check if there is a datestamp available for this survey
  137. * yes -> $datestamp="Y"
  138. * no -> $datestamp="N"
  139. */
  140. while ($row=$result->FetchRow()) {$datestamp=$row['datestamp'];}
  141. // 1: Get list of questions from survey
  142. /*
  143. * We want to have the following data
  144. * a) "questions" -> all table namens, e.g.
  145. * qid
  146. * sid
  147. * gid
  148. * type
  149. * title
  150. * question
  151. * preg
  152. * help
  153. * other
  154. * mandatory
  155. * lid
  156. * lid1
  157. * question_order
  158. * language
  159. *
  160. * b) "groups" -> group_name + group_order *
  161. */
  162. $query = "SELECT questions.*, groups.group_name, groups.group_order\n"
  163. ." FROM ".db_table_name("questions") ." as questions, ".db_table_name("groups")." as groups\n"
  164. ." WHERE groups.gid=questions.gid\n"
  165. ." AND groups.language='".$language."'\n"
  166. ." AND questions.language='".$language."'\n"
  167. ." AND questions.parent_qid=0\n"
  168. ." AND questions.sid=$surveyid";
  169. $result = db_execute_assoc($query) or safe_die("Couldn't do it!<br />$query<br />".$connect->ErrorMsg());
  170. //store all the data in $rows
  171. $rows = $result->GetRows();
  172. //SORT IN NATURAL ORDER!
  173. usort($rows, 'GroupOrderThenQuestionOrder');
  174. //put the question information into the filter array
  175. foreach ($rows as $row)
  176. {
  177. //store some column names in $filters array
  178. $filters[]=array($row['qid'],
  179. $row['gid'],
  180. $row['type'],
  181. $row['title'],
  182. $row['group_name'],
  183. FlattenText($row['question']));
  184. }
  185. //var_dump($filters);
  186. // SHOW ID FIELD
  187. $statisticsoutput .= "<div class='header ui-widget-header'>".$clang->gT("General filters")."</div><div id='statistics_general_filter'>";
  188. $grapherror='';
  189. if (!function_exists("gd_info")) {
  190. $grapherror.='<br />'.$clang->gT('You do not have the GD Library installed. Showing charts requires the GD library to function properly.');
  191. $grapherror.='<br />'.$clang->gT('visit http://us2.php.net/manual/en/ref.image.php for more information').'<br />';
  192. }
  193. elseif (!function_exists("imageftbbox")) {
  194. $grapherror.='<br />'.$clang->gT('You do not have the Freetype Library installed. Showing charts requires the Freetype library to function properly.');
  195. $grapherror.='<br />'.$clang->gT('visit http://us2.php.net/manual/en/ref.image.php for more information').'<br />';
  196. }
  197. if ($grapherror!='')
  198. {
  199. unset($_POST['usegraph']);
  200. }
  201. //pre-selection of filter forms
  202. if (incompleteAnsFilterstate() == "filter")
  203. {
  204. $selecthide="selected='selected'";
  205. $selectshow="";
  206. $selectinc="";
  207. }
  208. elseif (incompleteAnsFilterstate() == "inc")
  209. {
  210. $selecthide="";
  211. $selectshow="";
  212. $selectinc="selected='selected'";
  213. }
  214. else
  215. {
  216. $selecthide="";
  217. $selectshow="selected='selected'";
  218. $selectinc="";
  219. }
  220. $statisticsoutput .="<fieldset style='clear:both;'><legend>".$clang->gT("Data selection")."</legend><ul>";
  221. $statisticsoutput .="<li><label for='filterinc'>".$clang->gT("Include:")."</label><select name='filterinc' id='filterinc'>\n"
  222. ."<option value='show' $selectshow>".$clang->gT("All responses")."</option>\n"
  223. ."<option value='filter' $selecthide>".$clang->gT("Completed responses only")."</option>\n"
  224. ."<option value='incomplete' $selectinc>".$clang->gT("Incomplete responses only")."</option>\n"
  225. ."</select></li>\n"
  226. ."<li><label for='viewsummaryall'>".$clang->gT("View summary of all available fields")."</label>
  227. <input type='checkbox' id='viewsummaryall' name='viewsummaryall' ";
  228. if (isset($_POST['viewsummaryall'])) {$statisticsoutput .= "checked='checked'";}
  229. $statisticsoutput.="/></li>";
  230. $statisticsoutput .="<li id='vertical_slide'";
  231. //if ($selecthide!='')
  232. //{
  233. // $statisticsoutput .= " style='display:none' ";
  234. //}
  235. $statisticsoutput.=" ><label id='noncompletedlbl' for='noncompleted' title='".$clang->gT("Count stats for each question based only on the total number of responses for which the question was displayed")."'>".$clang->gT("Subtotals based on displayed questions")."</label>
  236. <input type='checkbox' id='noncompleted' name='noncompleted' ";
  237. if (isset($_POST['noncompleted'])) {$statisticsoutput .= "checked='checked'";}
  238. $statisticsoutput.=" />\n</li>\n";
  239. $survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
  240. $survlangs [] = GetBaseLanguageFromSurveyID($surveyid);
  241. $language_options="";
  242. foreach ($survlangs as $survlang)
  243. {
  244. $language_options .= "\t<option value=\"{$survlang}\"";
  245. if ($_SESSION['adminlang'] == $survlang)
  246. {
  247. $language_options .= "selected=\"selected\" " ;
  248. }
  249. $language_options .= ">".getLanguageNameFromCode($survlang,true)."</option>\n";
  250. }
  251. $statisticsoutput .="<li><label for='statlang'>".$clang->gT("Statistics report language")."</label>"
  252. . " <select name=\"statlang\" id=\"statlang\">".$language_options."</select>\n";
  253. $statisticsoutput.="\n</ul></fieldset>\n";
  254. $statisticsoutput .= "<fieldset id='left'><legend>".$clang->gT("Response ID")."</legend><ul><li>"
  255. ."<label for='idG'>".$clang->gT("Greater than:")."</label>\n"
  256. ."<input type='text' id='idG' name='idG' size='10' value='";
  257. if (isset($_POST['idG'])){$statisticsoutput .= sanitize_int($_POST['idG']);}
  258. $statisticsoutput .= "' onkeypress=\"return goodchars(event,'0123456789')\" /></li><li><label for='idL'>\n"
  259. .$clang->gT("Less than:")."</label>\n"
  260. ."<input type='text' id='idL' name='idL' size='10' value='";
  261. if (isset($_POST['idL'])) {$statisticsoutput .= sanitize_int($_POST['idL']);}
  262. $statisticsoutput .= "' onkeypress=\"return goodchars(event,'0123456789')\" /></li></ul></fieldset>\n";
  263. $statisticsoutput .= "<input type='hidden' name='summary[]' value='idG' />";
  264. $statisticsoutput .= "<input type='hidden' name='summary[]' value='idL' />";
  265. //if the survey contains timestamps you can filter by timestamp, too
  266. if (isset($datestamp) && $datestamp == "Y") {
  267. $statisticsoutput .= "<fieldset id='right'><legend>".$clang->gT("Submission date")."</legend><ul><li>"
  268. ."<label for='datestampE'>".$clang->gT("Equals:")."</label>\n"
  269. ."<input class='popupdate' id='datestampE' name='datestampE' type='text' value='";
  270. if (isset($_POST['datestampE'])) {$statisticsoutput .= $_POST['datestampE'];}
  271. $statisticsoutput .= "' /></li><li><label for='datestampG'>\n"
  272. ."&nbsp;&nbsp;".$clang->gT("Later than:")."</label>\n"
  273. ."<input class='popupdatetime' id='datestampG' name='datestampG' value='";
  274. if (isset($_POST['datestampG'])) {$statisticsoutput .= $_POST['datestampG'];}
  275. $statisticsoutput .= "' type='text' /></li><li><label for='datestampL'> ".$clang->gT("Earlier than:")."</label><input class='popupdatetime' id='datestampL' name='datestampL' value='";
  276. if (isset($_POST['datestampL'])) {$statisticsoutput .= $_POST['datestampL'];}
  277. $statisticsoutput .= "' type='text' /></li></ul></fieldset>\n";
  278. $statisticsoutput .= "<input type='hidden' name='summary[]' value='datestampE' />";
  279. $statisticsoutput .= "<input type='hidden' name='summary[]' value='datestampG' />";
  280. $statisticsoutput .= "<input type='hidden' name='summary[]' value='datestampL' />";
  281. }
  282. $statisticsoutput .="<fieldset><legend>".$clang->gT("Output options")."</legend><ul>"
  283. ."<li><label for='usegraph'>".$clang->gT("Show graphs")."</label><input type='checkbox' id='usegraph' name='usegraph' ";
  284. if (isset($_POST['usegraph'])) {$statisticsoutput .= "checked='checked'";}
  285. $statisticsoutput .= "/><br />";
  286. if ($grapherror!='')
  287. {
  288. $statisticsoutput.="<span id='grapherror' style='display:none'>$grapherror<hr /></span>";
  289. }
  290. $statisticsoutput.="</li>\n";
  291. //Output selector
  292. $statisticsoutput .= "<li>"
  293. ."<label>"
  294. .$clang->gT("Select output format").":</label>"
  295. ."<input type='radio' name='outputtype' value='html' checked='checked' /><label for='outputtype'>HTML</label> <input type='radio' name='outputtype' value='pdf' /><label for='outputtype'>PDF</label> <input type='radio' onclick='nographs();' name='outputtype' value='xls' /><label for='outputtype'>Excel</label>";
  296. $statisticsoutput .= "</ul></fieldset></div><p>"
  297. ."<input type='submit' value='".$clang->gT("View stats")."' />\n"
  298. ."<input type='button' value='".$clang->gT("Clear")."' onclick=\"window.open('$scriptname?action=statistics&amp;sid=$surveyid', '_top')\" />\n";
  299. //second row below options -> filter settings headline
  300. $statisticsoutput.="<div class='header header_statistics'>"
  301. ."<img src='$imageurl/plus.gif' align='right' id='showfilter' /><img src='$imageurl/minus.gif' align='right' id='hidefilter' />"
  302. .$clang->gT("Response filters")
  303. ."</div>\n";
  304. $filterchoice_state=returnglobal('filterchoice_state');
  305. $statisticsoutput.="<input type='hidden' id='filterchoice_state' name='filterchoice_state' value='{$filterchoice_state}' />\n";
  306. $statisticsoutput .="<table cellspacing='0' cellpadding='0' width='100%' id='filterchoices' ";
  307. if ($filterchoice_state!='')
  308. {
  309. $statisticsoutput .= " style='display:none' ";
  310. }
  311. $statisticsoutput .=">";
  312. /*
  313. * let's go through the filter array which contains
  314. * ['qid'],
  315. ['gid'],
  316. ['type'],
  317. ['title'],
  318. ['group_name'],
  319. ['question'],
  320. ['lid'],
  321. ['lid1']);
  322. */
  323. $currentgroup='';
  324. foreach ($filters as $flt)
  325. {
  326. //is there a previous question type set?
  327. if (!isset($previousquestiontype)) {$previousquestiontype="";}
  328. //does gid equal $currentgroup?
  329. if ($flt[1] != $currentgroup)
  330. {
  331. //If the groupname has changed, start a new row
  332. if ($currentgroup!='')
  333. {
  334. //if we've already drawn a table for a group, and we're changing - close off table
  335. $statisticsoutput .= "<!-- Close filter group --></tr>\n</table></div></td></tr>\n";
  336. }
  337. $statisticsoutput .= "\t\t<tr><td><div class='header ui-widget-header'>\n"
  338. ."<input type=\"checkbox\" id='btn_$flt[1]' onclick=\"selectCheckboxes('grp_$flt[1]', 'summary[]', 'btn_$flt[1]');\" />"
  339. //use current groupname and groupid as heading
  340. ."<font size='1'><strong>$flt[4]</strong> (".$clang->gT("Question group")." $flt[1])</font></div></td></tr>\n\t\t"
  341. ."<tr><td align='center'>\n"
  342. ."<div id='grp_$flt[1]'><table class='filtertable'><tr>\n";
  343. //counter which is used to adapt layout depending on counter #
  344. $counter=0;
  345. }
  346. //we don't want more than 4 questions in a row
  347. //and we need a new row after each multiple/array question
  348. if (isset($counter) && $counter == 4 ||
  349. ($previousquestiontype == "1" ||
  350. $previousquestiontype == "A" ||
  351. $previousquestiontype == "B" ||
  352. $previousquestiontype == "C" ||
  353. $previousquestiontype == "E" ||
  354. $previousquestiontype == "F" ||
  355. $previousquestiontype == "H" ||
  356. $previousquestiontype == "K" ||
  357. $previousquestiontype == "Q" ||
  358. $previousquestiontype == "R" ||
  359. $previousquestiontype == ":" ||
  360. $previousquestiontype == ";"))
  361. {
  362. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>"; $counter=0;
  363. }
  364. /*
  365. * remember: $flt is structured like this
  366. * ['qid'],
  367. ['gid'],
  368. ['type'],
  369. ['title'],
  370. ['group_name'],
  371. ['question'],
  372. ['lid'],
  373. ['lid1']);
  374. */
  375. //SGQ identifier
  376. $myfield = "{$surveyid}X{$flt[1]}X{$flt[0]}";
  377. //full question title
  378. $niceqtext = FlattenText($flt[5]);
  379. /*
  380. * Check question type: This question types will be used (all others are separated in the if clause)
  381. * 5 - 5 Point Choice
  382. G - Gender
  383. I - Language Switch
  384. L - List (Radio)
  385. M - Multiple choice
  386. N - Numerical Input
  387. | - File Upload
  388. O - List With Comment
  389. P - Multiple choice with comments
  390. Y - Yes/No
  391. ! - List (Dropdown) )
  392. */
  393. if ($flt[2]=='M' || $flt[2]=='P' || $flt[2]=='N' || $flt[2]=='L' || $flt[2]=='5'
  394. || $flt[2]=='G' || $flt[2]=='I' || $flt[2]=='O' || $flt[2]=='Y' || $flt[2]=='!') //Have to make an exception for these types!
  395. {
  396. $statisticsoutput .= "\t\t\t\t<td align='center'>";
  397. //Multiple choice:
  398. if ($flt[2] == "M") {$myfield = "M$myfield";}
  399. if ($flt[2] == "P") {$myfield = "P$myfield";}
  400. // File Upload will need special filters in future, hence the special treatment
  401. if ($flt[2] == "|") {$myfield = "|$myfield";}
  402. //numerical input will get special treatment (arihtmetic mean, standard derivation, ...)
  403. if ($flt[2] == "N") {$myfield = "N$myfield";}
  404. $statisticsoutput .= "<input type='checkbox' id='filter$myfield' name='summary[]' value='$myfield'";
  405. /*
  406. * one of these conditions has to be true
  407. * 1. SGQ can be found within the summary array
  408. * 2. M-SGQ can be found within the summary array (M = Multiple choice)
  409. * 3. N-SGQ can be found within the summary array (N = numerical input)
  410. *
  411. * Always remember that we just have very few question types that are checked here
  412. * due to the if ouside this section!
  413. *
  414. * Auto-check the question types mentioned above
  415. */
  416. if (isset($summary) && (array_search("{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
  417. || array_search("M{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
  418. || array_search("P{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE
  419. || array_search("N{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
  420. {$statisticsoutput .= " checked='checked'";}
  421. //show speaker symbol which contains full question text
  422. $statisticsoutput .= " /><label for='filter$myfield'>".showspeaker(FlattenText($flt[5]))
  423. ."</label><br />\n";
  424. //numerical question type -> add some HTML to the output
  425. //if ($flt[2] == "N") {$statisticsoutput .= "</font>";} //removed to correct font error
  426. if ($flt[2] != "N" && $flt[2] != "|") {$statisticsoutput .= "\t\t\t\t<select name='";}
  427. //Multiple choice ("M"/"P") -> add "M" to output
  428. if ($flt[2] == "M" ) {$statisticsoutput .= "M";}
  429. if ($flt[2] == "P" ) {$statisticsoutput .= "P";}
  430. //numerical -> add SGQ to output
  431. if ($flt[2] != "N" && $flt[2] != "|") {$statisticsoutput .= "{$surveyid}X{$flt[1]}X{$flt[0]}[]' multiple='multiple'>\n";}
  432. } //end if -> filter certain question types
  433. $statisticsoutput .= "\t\t\t\t\t<!-- QUESTION TYPE = $flt[2] -->\n";
  434. /////////////////////////////////////////////////////////////////////////////////////////////////
  435. //This section presents the filter list, in various different ways depending on the question type
  436. /////////////////////////////////////////////////////////////////////////////////////////////////
  437. //let's switch through the question type for each question
  438. switch ($flt[2])
  439. {
  440. case "K": // Multiple Numerical
  441. $statisticsoutput .= "\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n";
  442. //get answers
  443. $query = "SELECT title as code, question as answer FROM ".db_table_name("questions")." WHERE parent_qid='$flt[0]' AND language = '{$language}' ORDER BY question_order";
  444. $result = db_execute_num($query) or safe_die ("Couldn't get answers!<br />$query<br />".$connect->ErrorMsg());
  445. //counter is used for layout
  446. $counter2=0;
  447. //go through all the (multiple) answers
  448. while ($row=$result->FetchRow())
  449. {
  450. /*
  451. * filter form for numerical input
  452. * - checkbox
  453. * - greater than
  454. * - less than
  455. */
  456. $myfield1="K".$myfield.$row[0];
  457. $myfield2="K{$myfield}".$row[0]."G";
  458. $myfield3="K{$myfield}".$row[0]."L";
  459. if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n"; $counter2=0;}
  460. //start new TD
  461. $statisticsoutput .= "\t\t\t\t<td align='center' valign='top'>";
  462. //checkbox
  463. $statisticsoutput .= "<input type='checkbox' name='summary[]' value='$myfield1'";
  464. //check SGQA -> do we want to pre-check the checkbox?
  465. if (isset($summary) && (array_search("K{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}", $summary) !== FALSE))
  466. {$statisticsoutput .= " checked='checked'";}
  467. $statisticsoutput .= " />&nbsp;";
  468. //show speaker
  469. $statisticsoutput .= showSpeaker($flt[3]." - ".FlattenText($row[1]))."<br />\n";
  470. //input fields
  471. $statisticsoutput .= "\t\t\t\t\t<font size='1'>".$clang->gT("Number greater than").":</font><br />\n"
  472. ."\t\t\t\t\t<input type='text' name='$myfield2' value='";
  473. if (isset($_POST[$myfield2])){$statisticsoutput .= $_POST[$myfield2];}
  474. //check number input using JS
  475. $statisticsoutput .= "' onkeypress=\"return goodchars(event,'0123456789.,')\" /><br />\n"
  476. ."\t\t\t\t\t<font size='1'>".$clang->gT("Number less than").":</font><br />\n"
  477. ."\t\t\t\t\t<input type='text' name='$myfield3' value='";
  478. if (isset($_POST[$myfield3])) {$statisticsoutput .= $_POST[$myfield3];}
  479. $statisticsoutput .= "' onkeypress=\"return goodchars(event,'0123456789.,')\" /><br />\n";
  480. //we added 1 form -> increase counter
  481. $counter2++;
  482. }
  483. break;
  484. case "Q": // Multiple Short Text
  485. //new section
  486. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  487. //get subqestions
  488. $query = "SELECT title as code, question as answer FROM ".db_table_name("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order";
  489. $result = db_execute_num($query) or safe_die ("Couldn't get answers!<br />$query<br />".$connect->ErrorMsg());
  490. $counter2=0;
  491. //loop through all answers
  492. while ($row = $result->FetchRow())
  493. {
  494. //collecting data for output, for details see above (question type "N")
  495. //we have one input field for each answer
  496. $myfield2 = "Q".$myfield."$row[0]";
  497. if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n"; $counter2=0;}
  498. $statisticsoutput .= "\t\t\t\t<td align='center' valign='top'>";
  499. $statisticsoutput .= "<input type='checkbox' name='summary[]' value='$myfield2'";
  500. if (isset($summary) && (array_search("Q{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}", $summary) !== FALSE))
  501. {$statisticsoutput .= " checked='checked'";}
  502. $statisticsoutput .= " />&nbsp;";
  503. $statisticsoutput .= showSpeaker($flt[3]." - ".FlattenText($row[1]))
  504. ."<br />\n"
  505. ."\t\t\t\t\t<font size='1'>".$clang->gT("Responses containing").":</font><br />\n"
  506. ."\t\t\t\t\t<input type='text' name='$myfield2' value='";
  507. if (isset($_POST[$myfield2]))
  508. {$statisticsoutput .= $_POST[$myfield2];}
  509. $statisticsoutput .= "' />";
  510. $counter2++;
  511. }
  512. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  513. $counter=0;
  514. break;
  515. /*
  516. * all "free text" types (T, U, S) get the same prefix ("T")
  517. */
  518. case "T": // Long free text
  519. case "U": // Huge free text
  520. $myfield2="T$myfield";
  521. $statisticsoutput .= "\t\t\t\t<td align='center' valign='top'>";
  522. $statisticsoutput .= "<input type='checkbox' name='summary[]' value='$myfield2'";
  523. if (isset($summary) && (array_search("T{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
  524. {$statisticsoutput .= " checked='checked'";}
  525. $statisticsoutput .= " />&nbsp;"
  526. ."&nbsp;".showSpeaker($niceqtext)
  527. ."<br />\n"
  528. ."\t\t\t\t\t<font size='1'>".$clang->gT("Responses containing").":</font><br />\n"
  529. ."\t\t\t\t\t<textarea name='$myfield2' rows='3' cols='80'>";
  530. if (isset($_POST[$myfield2])) {$statisticsoutput .= $_POST[$myfield2];}
  531. $statisticsoutput .= "</textarea>";
  532. break;
  533. case "S": // Short free text
  534. $myfield2="T$myfield";
  535. $statisticsoutput .= "\t\t\t\t<td align='center' valign='top'>";
  536. $statisticsoutput .= "<input type='checkbox' name='summary[]' value='$myfield2'";
  537. if (isset($summary) && (array_search("T{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
  538. {$statisticsoutput .= " checked='checked'";}
  539. $statisticsoutput .= " />&nbsp;"
  540. ."&nbsp;".showSpeaker($niceqtext)
  541. ."<br />\n"
  542. ."\t\t\t\t\t<font size='1'>".$clang->gT("Responses containing").":</font><br />\n"
  543. ."\t\t\t\t\t<input type='text' name='$myfield2' value='";
  544. if (isset($_POST[$myfield2])) {$statisticsoutput .= $_POST[$myfield2];}
  545. $statisticsoutput .= "' />";
  546. $statisticsoutput .= "\t\t\t\t</td>\n";
  547. break;
  548. case "N": // Numerical
  549. //textfields for greater and less than X
  550. $myfield2="{$myfield}G";
  551. $myfield3="{$myfield}L";
  552. $statisticsoutput .= "\t\t\t\t\t<font size='1'>".$clang->gT("Number greater than").":</font><br />\n"
  553. ."\t\t\t\t\t<input type='text' name='$myfield2' value='";
  554. if (isset($_POST[$myfield2])){$statisticsoutput .= $_POST[$myfield2];}
  555. $statisticsoutput .= "' onkeypress=\"return goodchars(event,'0123456789.,')\" /><br />\n"
  556. ."\t\t\t\t\t<font size='1'>".$clang->gT("Number less than").":</font><br />\n"
  557. ."\t\t\t\t\t<input type='text' name='$myfield3' value='";
  558. if (isset($_POST[$myfield3])) {$statisticsoutput .= $_POST[$myfield3];}
  559. //only numeriacl input allowed -> check using JS
  560. $statisticsoutput .= "' onkeypress=\"return goodchars(event,'0123456789.,')\" /><br />\n";
  561. //put field names into array
  562. break;
  563. case "|": // File Upload
  564. // Number of files uploaded for greater and less than X
  565. $myfield2 = "{$myfield}G";
  566. $myfield3 = "{$myfield}L";
  567. $statisticsoutput .= "\t\t\t\t\t<font size='1'>".$clang->gT("Number of files greater than").":</font><br />\n"
  568. ."\t\t\t\t\t<input type='text' name='$myfield2' value='";
  569. if (isset($_POST[$myfield2])){$statisticsoutput .= $_POST[$myfield2];}
  570. $statisticsoutput .= "' onkeypress=\"return goodchars(event,'0123456789.,')\" /><br />\n"
  571. ."\t\t\t\t\t<font size='1'>".$clang->gT("Number of files less than").":</font><br />\n"
  572. ."\t\t\t\t\t<input type='text' name='$myfield3' value='";
  573. if (isset($_POST[$myfield3])) {$statisticsoutput .= $_POST[$myfield3];}
  574. //only numeriacl input allowed -> check using JS
  575. $statisticsoutput .= "' onkeypress=\"return goodchars(event,'0123456789.,')\" /><br />\n";
  576. //put field names into array
  577. break;
  578. /*
  579. * DON'T show any statistics for date questions
  580. * because there aren't any statistics implemented yet!
  581. *
  582. * Only filtering by date is possible.
  583. *
  584. * See bug report #2539 and
  585. * feature request #2620
  586. */
  587. case "D": // Date
  588. /*
  589. * - input name
  590. * - date equals
  591. * - date less than
  592. * - date greater than
  593. */
  594. $myfield2="D$myfield";
  595. $myfield3="$myfield2=";
  596. $myfield4="$myfield2<";
  597. $myfield5="$myfield2>";
  598. $statisticsoutput .= "\t\t\t\t<td align='center' valign='top'>";
  599. $statisticsoutput .= "<input type='checkbox' name='summary[]' value='$myfield2'";
  600. if (isset($summary) && (array_search("D{$surveyid}X{$flt[1]}X{$flt[0]}", $summary) !== FALSE))
  601. {$statisticsoutput .= " checked='checked'";}
  602. $statisticsoutput .= " /><strong>";
  603. $statisticsoutput .= showSpeaker($niceqtext)
  604. ."<br />\n"
  605. ."\t\t\t\t\t<font size='1'>".$clang->gT("Date (YYYY-MM-DD) equals").":<br />\n"
  606. ."\t\t\t\t\t<input name='$myfield3' type='text' value='";
  607. if (isset($_POST[$myfield3])) {$statisticsoutput .= $_POST[$myfield3];}
  608. $statisticsoutput .= "' /><br />\n"
  609. ."\t\t\t\t\t&nbsp;&nbsp;".$clang->gT("Date is")." >=<br />\n"
  610. ."\t\t\t\t\t<input name='$myfield4' value='";
  611. if (isset($_POST[$myfield4])) {$statisticsoutput .= $_POST[$myfield4];}
  612. $statisticsoutput .= "' type='text' /> <br />"
  613. .$clang->gT("AND/OR Date is")." <= <br /> <input name='$myfield5' value='";
  614. if (isset($_POST[$myfield5])) {$statisticsoutput .= $_POST[$myfield5];}
  615. $statisticsoutput .= "' type='text' /></font>\n";
  616. break;
  617. case "5": // 5 point choice
  618. //we need a list of 5 entries
  619. for ($i=1; $i<=5; $i++)
  620. {
  621. $statisticsoutput .= "\t\t\t\t\t<option value='$i'";
  622. //pre-select values which were marked before
  623. if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array($i, $_POST[$myfield]))
  624. {$statisticsoutput .= " selected";}
  625. $statisticsoutput .= ">$i</option>\n";
  626. }
  627. //End the select which starts before the CASE statement (around line 411)
  628. $statisticsoutput .="\t\t\t\t</select>\n";
  629. break;
  630. case "G": // Gender
  631. $statisticsoutput .= "\t\t\t\t\t<option value='F'";
  632. //pre-select values which were marked before
  633. if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array("F", $_POST[$myfield])) {$statisticsoutput .= " selected";}
  634. $statisticsoutput .= ">".$clang->gT("Female")."</option>\n";
  635. $statisticsoutput .= "\t\t\t\t\t<option value='M'";
  636. //pre-select values which were marked before
  637. if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array("M", $_POST[$myfield])) {$statisticsoutput .= " selected";}
  638. $statisticsoutput .= ">".$clang->gT("Male")."</option>\n\t\t\t\t</select>\n";
  639. $statisticsoutput .= "\t\t\t\t</td>\n";
  640. break;
  641. case "Y": // Yes\No
  642. $statisticsoutput .= "\t\t\t\t\t<option value='Y'";
  643. //pre-select values which were marked before
  644. if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array("Y", $_POST[$myfield])) {$statisticsoutput .= " selected";}
  645. $statisticsoutput .= ">".$clang->gT("Yes")."</option>\n"
  646. ."\t\t\t\t\t<option value='N'";
  647. //pre-select values which were marked before
  648. if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array("N", $_POST[$myfield])) {$statisticsoutput .= " selected";}
  649. $statisticsoutput .= ">".$clang->gT("No")."</option></select>\n";
  650. break;
  651. case "I": // Language
  652. $survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
  653. $survlangs[] = GetBaseLanguageFromSurveyID($surveyid);
  654. foreach ($survlangs as $availlang)
  655. {
  656. $statisticsoutput .= "\t\t\t\t\t<option value='".$availlang."'";
  657. //pre-select values which were marked before
  658. if (isset($_POST[$myfield]) && is_array($_POST[$myfield]) && in_array($availlang, $_POST[$myfield]))
  659. {$statisticsoutput .= " selected";}
  660. $statisticsoutput .= ">".getLanguageNameFromCode($availlang,false)."</option>\n";
  661. }
  662. break;
  663. //----------------------- ARRAYS --------------------------
  664. case "A": // ARRAY OF 5 POINT CHOICE QUESTIONS
  665. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  666. //get answers
  667. $query = "SELECT title, question FROM ".db_table_name("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order";
  668. $result = db_execute_num($query) or safe_die ("Couldn't get answers!<br />$query<br />".$connect->ErrorMsg());
  669. $counter2=0;
  670. //check all the results
  671. while ($row=$result->FetchRow())
  672. {
  673. $myfield2 = $myfield.$row[0];
  674. $statisticsoutput .= "<!-- $myfield2 - ";
  675. if (isset($_POST[$myfield2])) {$statisticsoutput .= $_POST[$myfield2];}
  676. $statisticsoutput .= " -->\n";
  677. if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n"; $counter2=0;}
  678. $statisticsoutput .= "\t\t\t\t<td align='center'>"
  679. ."<input type='checkbox' name='summary[]' value='$myfield2'";
  680. //pre-check
  681. if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {$statisticsoutput .= " checked='checked'";}
  682. $statisticsoutput .= " />&nbsp;"
  683. .showSpeaker($niceqtext." ".str_replace("'", "`", $row[1])." - # ".$flt[3])
  684. ."<br />\n"
  685. ."\t\t\t\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]' multiple='multiple'>\n";
  686. //there are always exactly 5 values which have to be listed
  687. for ($i=1; $i<=5; $i++)
  688. {
  689. $statisticsoutput .= "\t\t\t\t\t<option value='$i'";
  690. //pre-select
  691. if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array($i, $_POST[$myfield2])) {$statisticsoutput .= " selected";}
  692. if (isset($_POST[$myfield2]) && $_POST[$myfield2] == $i) {$statisticsoutput .= " selected";}
  693. $statisticsoutput .= ">$i</option>\n";
  694. }
  695. $statisticsoutput .= "\t\t\t\t</select>\n\t\t\t\t</td>\n";
  696. $counter2++;
  697. //add this to all the other fields
  698. }
  699. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  700. $counter=0;
  701. break;
  702. //just like above only a different loop
  703. case "B": // ARRAY OF 10 POINT CHOICE QUESTIONS
  704. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  705. $query = "SELECT title, question FROM ".db_table_name("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order";
  706. $result = db_execute_num($query) or safe_die ("Couldn't get answers!<br />$query<br />".$connect->ErrorMsg());
  707. $counter2=0;
  708. while ($row=$result->FetchRow())
  709. {
  710. $myfield2 = $myfield . "$row[0]";
  711. $statisticsoutput .= "<!-- $myfield2 - ";
  712. if (isset($_POST[$myfield2])) {$statisticsoutput .= $_POST[$myfield2];}
  713. $statisticsoutput .= " -->\n";
  714. if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n"; $counter2=0;}
  715. $statisticsoutput .= "\t\t\t\t<td align='center'>"; //heading
  716. $statisticsoutput .= "<input type='checkbox' name='summary[]' value='$myfield2'";
  717. if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {$statisticsoutput .= " checked='checked'";}
  718. $statisticsoutput .= " />&nbsp;"
  719. .showSpeaker($niceqtext." ".str_replace("'", "`", $row[1])." - # ".$flt[3])
  720. ."<br />\n"
  721. ."\t\t\t\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]' multiple='multiple'>\n";
  722. //here wo loop through 10 entries to create a larger output form
  723. for ($i=1; $i<=10; $i++)
  724. {
  725. $statisticsoutput .= "\t\t\t\t\t<option value='$i'";
  726. if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array($i, $_POST[$myfield2])) {$statisticsoutput .= " selected";}
  727. if (isset($_POST[$myfield2]) && $_POST[$myfield2] == $i) {$statisticsoutput .= " selected";}
  728. $statisticsoutput .= ">$i</option>\n";
  729. }
  730. $statisticsoutput .= "\t\t\t\t</select>\n\t\t\t\t</td>\n";
  731. $counter2++;
  732. }
  733. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  734. $counter=0;
  735. break;
  736. case "C": // ARRAY OF YES\No\$clang->gT("Uncertain") QUESTIONS
  737. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  738. //get answers
  739. $query = "SELECT title, question FROM ".db_table_name("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order";
  740. $result = db_execute_num($query) or safe_die ("Couldn't get answers!<br />$query<br />".$connect->ErrorMsg());
  741. $counter2=0;
  742. //loop answers
  743. while ($row=$result->FetchRow())
  744. {
  745. $myfield2 = $myfield . "$row[0]";
  746. $statisticsoutput .= "<!-- $myfield2 - ";
  747. if (isset($_POST[$myfield2])) {$statisticsoutput .= $_POST[$myfield2];}
  748. $statisticsoutput .= " -->\n";
  749. if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n"; $counter2=0;}
  750. $statisticsoutput .= "\t\t\t\t<td align='center'>"
  751. ."<input type='checkbox' name='summary[]' value='$myfield2'";
  752. if (isset($summary) && array_search($myfield2, $summary)!== FALSE)
  753. {$statisticsoutput .= " checked='checked'";}
  754. $statisticsoutput .= " />&nbsp;<strong>"
  755. .showSpeaker($niceqtext." ".str_replace("'", "`", $row[1])." - # ".$flt[3])
  756. ."</strong><br />\n"
  757. ."\t\t\t\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]' multiple='multiple'>\n"
  758. ."\t\t\t\t\t<option value='Y'";
  759. //pre-select "yes"
  760. if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array("Y", $_POST[$myfield2])) {$statisticsoutput .= " selected";}
  761. $statisticsoutput .= ">".$clang->gT("Yes")."</option>\n"
  762. ."\t\t\t\t\t<option value='U'";
  763. //pre-select "uncertain"
  764. if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array("U", $_POST[$myfield2])) {$statisticsoutput .= " selected";}
  765. $statisticsoutput .= ">".$clang->gT("Uncertain")."</option>\n"
  766. ."\t\t\t\t\t<option value='N'";
  767. //pre-select "no"
  768. if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array("N", $_POST[$myfield2])) {$statisticsoutput .= " selected";}
  769. $statisticsoutput .= ">".$clang->gT("No")."</option>\n"
  770. ."\t\t\t\t</select>\n\t\t\t\t</td>\n";
  771. $counter2++;
  772. //add to array
  773. }
  774. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  775. $counter=0;
  776. break;
  777. //similiar to the above one
  778. case "E": // ARRAY OF Increase/Same/Decrease QUESTIONS
  779. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  780. $query = "SELECT title, question FROM ".db_table_name("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' ORDER BY question_order";
  781. $result = db_execute_num($query) or safe_die ("Couldn't get answers!<br />$query<br />".$connect->ErrorMsg());
  782. $counter2=0;
  783. while ($row=$result->FetchRow())
  784. {
  785. $myfield2 = $myfield . "$row[0]";
  786. $statisticsoutput .= "<!-- $myfield2 - ";
  787. if (isset($_POST[$myfield2])) {$statisticsoutput .= $_POST[$myfield2];}
  788. $statisticsoutput .= " -->\n";
  789. if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n"; $counter2=0;}
  790. $statisticsoutput .= "\t\t\t\t<td align='center'>"
  791. ."<input type='checkbox' name='summary[]' value='$myfield2'";
  792. if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {$statisticsoutput .= " checked='checked'";}
  793. $statisticsoutput .= " />&nbsp;<strong>"
  794. .showSpeaker($niceqtext." ".str_replace("'", "`", $row[1])." - # ".$flt[3])
  795. ."</strong><br />\n"
  796. ."\t\t\t\t<select name='{$surveyid}X{$flt[1]}X{$flt[0]}{$row[0]}[]' multiple='multiple'>\n"
  797. ."\t\t\t\t\t<option value='I'";
  798. if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array("I", $_POST[$myfield2])) {$statisticsoutput .= " selected";}
  799. $statisticsoutput .= ">".$clang->gT("Increase")."</option>\n"
  800. ."\t\t\t\t\t<option value='S'";
  801. if (isset($_POST[$myfield]) && is_array($_POST[$myfield2]) && in_array("S", $_POST[$myfield2])) {$statisticsoutput .= " selected";}
  802. $statisticsoutput .= ">".$clang->gT("Same")."</option>\n"
  803. ."\t\t\t\t\t<option value='D'";
  804. if (isset($_POST[$myfield]) && is_array($_POST[$myfield2]) && in_array("D", $_POST[$myfield2])) {$statisticsoutput .= " selected";}
  805. $statisticsoutput .= ">".$clang->gT("Decrease")."</option>\n"
  806. ."\t\t\t\t</select>\n\t\t\t\t</td>\n";
  807. $counter2++;
  808. }
  809. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  810. $counter=0;
  811. break;
  812. case ";": //ARRAY (Multi Flex) (Text)
  813. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  814. $query = "SELECT title, question FROM ".db_table_name("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' AND scale_id=0 ORDER BY question_order";
  815. $result = db_execute_num($query) or die ("Couldn't get answers!<br />$query<br />".$connect->ErrorMsg());
  816. $counter2=0;
  817. while ($row=$result->FetchRow())
  818. {
  819. $fquery = "SELECT title, question FROM ".db_table_name("questions")." WHERE parent_qid='$flt[0]' AND language='{$language}' AND scale_id=1 ORDER BY question_order";
  820. $fresult = db_execute_assoc($fquery);
  821. while ($frow = $fresult->FetchRow())
  822. {
  823. $myfield2 = "T".$myfield . $row[0] . "_" . $frow['title'];
  824. $statisticsoutput .= "<!-- $myfield2 - ";
  825. if (isset($_POST[$myfield2])) {$statisticsoutput .= $_POST[$myfield2];}
  826. $statisticsoutput .= " -->\n";
  827. if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n"; $counter2=0;}
  828. $statisticsoutput .= "\t\t\t\t<td align='center'>"
  829. ."<input type='checkbox' name='summary[]' value='$myfield2'";
  830. if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {$statisticsoutput .= " checked='checked'";}
  831. $statisticsoutput .= " />&nbsp;<strong>"
  832. .showSpeaker($niceqtext." ".str_replace("'", "`", $row[1]." [".$frow['question']."]")." - ".$row[0]."/".$frow['title'])
  833. ."</strong><br />\n";
  834. //$statisticsoutput .= $fquery;
  835. $statisticsoutput .= "\t\t\t\t\t<font size='1'>".$clang->gT("Responses containing").":</font><br />\n";
  836. $statisticsoutput .= "\t\t\t\t<input type='text' name='{$myfield2}' value='";
  837. if(isset($_POST[$myfield2])) {$statisticsoutput .= $_POST[$myfield2];}
  838. $statisticsoutput .= "' />\n\t\t\t\t</td>\n";
  839. $counter2++;
  840. }
  841. }
  842. $statisticsoutput .= "\t\t\t\t<td>\n";
  843. $counter=0;
  844. break;
  845. case ":": //ARRAY (Multi Flex) (Numbers)
  846. $statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  847. $query = "SELECT title, question FROM ".db_table_name("questions")." WHERE parent_qid='$flt[0]' AND language = '{$language}' AND scale_id=0 ORDER BY question_order";
  848. $result = db_execute_num($query) or die ("Couldn't get answers!<br />$query<br />".$connect->ErrorMsg());
  849. $counter2=0;
  850. //Get qidattributes for this question
  851. $qidattributes=getQuestionAttributes($flt[0]);
  852. if (trim($qidattributes['multiflexible_max'])!='' && trim($qidattributes['multiflexible_min']) ==''){
  853. $maxvalue=$qidattributes['multiflexible_max'];
  854. $minvalue=1;
  855. }
  856. if (trim($qidattributes['multiflexible_min'])!='' && trim($qidattributes['multiflexible_max']) ==''){
  857. $minvalue=$qidattributes['multiflexible_min'];
  858. $maxvalue=$qidattributes['multiflexible_min'] + 10;
  859. }
  860. if (trim($qidattributes['multiflexible_min'])=='' && trim($qidattributes['multiflexible_max']) ==''){
  861. $minvalue=1;
  862. $maxvalue=10;
  863. }
  864. if (trim($qidattributes['multiflexible_min']) !='' && trim($qidattributes['multiflexible_max']) !=''){
  865. if($qidattributes['multiflexible_min'] < $qidattributes['multiflexible_max']){
  866. $minvalue=$qidattributes['multiflexible_min'];
  867. $maxvalue=$qidattributes['multiflexible_max'];
  868. }
  869. }
  870. if (trim($qidattributes['multiflexible_step'])!='') {
  871. $stepvalue=$qidattributes['multiflexible_step'];
  872. } else {
  873. $stepvalue=1;
  874. }
  875. if ($qidattributes['multiflexible_checkbox']!=0)
  876. {
  877. $minvalue=0;
  878. $maxvalue=1;
  879. $stepvalue=1;
  880. }
  881. while ($row=$result->FetchRow())
  882. {
  883. $fquery = "SELECT * FROM ".db_table_name("questions")." WHERE parent_qid={$flt[0]} AND language='{$language}' AND scale_id=1 ORDER BY question_order, title";
  884. $fresult = db_execute_assoc($fquery);
  885. while ($frow = $fresult->FetchRow())
  886. {
  887. $myfield2 = $myfield . $row[0] . "_" . $frow['title'];
  888. $statisticsoutput .= "<!-- $myfield2 - ";
  889. if (isset($_POST[$myfield2])) {$statisticsoutput .= $_POST[$myfield2];}
  890. $statisticsoutput .= " -->\n";
  891. if ($counter2 == 4) {$statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n"; $counter2=0;}
  892. $statisticsoutput .= "\t\t\t\t<td align='center'>"
  893. ."<input type='checkbox' name='summary[]' value='$myfield2'";
  894. if (isset($summary) && array_search($myfield2, $summary)!== FALSE) {$statisticsoutput .= " checked='checked'";}
  895. $statisticsoutput .= " />&nbsp;<strong>"
  896. .showSpeaker($niceqtext." ".str_replace("'", "`", $row[1]." [".$frow['question']."]")." - ".$row[0]."/".$frow['title'])
  897. ."</strong><br />\n";
  898. //$statisticsoutput .= $fquery;
  899. $statisticsoutput .= "\t\t\t\t<select name='{$myfield2}[]' multiple='multiple' rows='5' cols='5'>\n";
  900. for($ii=$minvalue; $ii<=$maxvalue; $ii+=$stepvalue)
  901. {
  902. $statisticsoutput .= "\t\t\t\t\t<option value='$ii'";
  903. if (isset($_POST[$myfield2]) && is_array($_POST[$myfield2]) && in_array($frow['code'], $_POST[$myfield2])) {$statisticsoutput .= " selected";}
  904. $statisticsoutput .= ">$ii</option>\n";
  905. }
  906. $statisticsoutput .= "\t\t\t\t</select>\n\t\t\t\t</td>\n";
  907. $counter2++;
  908. }
  909. }
  910. $statisticsoutput .= "\t\t\t\t<td>\n";
  911. $counter=0;
  912. break;
  913. /*
  914. * For question type "F" and "H" you can use labels.
  915. * The only difference is that the labels are applied to column heading
  916. * or rows respectively
  917. */
  918. case "F": // FlEXIBLE ARRAY
  919. case "H": // ARRAY (By Column)
  920. //$statisticsoutput .= "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
  921. //Get answers. We always use the answer code because the label might be too long elsewise
  922. $query =

Large files files are truncated, but you can click here to view the full file