question id * $ia[1] => fieldname * $ia[2] => title * $ia[3] => question text * $ia[4] => type -- text, radio, select, array, etc * $ia[5] => group id * $ia[6] => mandatory Y || N * $ia[7] => conditions ?? * * $conditions element structure * $condition[n][0] => question id * $condition[n][1] => question with value to evaluate * $condition[n][2] => internal field name of element [1] * $condition[n][3] => value to be evaluated on answers labeled. *NEW* tittle of questions to evaluate. * $condition[n][4] => type of question * $condition[n][5] => equal to [2], but concatenated in this time (why the same value 2 times?) * $condition[n][6] => method used to evaluate *NEW* */ function retrieveConditionInfo($ia) { //This function returns an array containing all related conditions //for a question - the array contains the fields from the conditions table global $dbprefix, $connect; if ($ia[7] == "Y") { //DEVELOP CONDITIONS ARRAY FOR THIS QUESTION $cquery = "SELECT {$dbprefix}conditions.qid, " ."{$dbprefix}conditions.cqid, " ."{$dbprefix}conditions.cfieldname, " ."{$dbprefix}conditions.value, " ."{$dbprefix}questions.type, " ."{$dbprefix}questions.sid, " ."{$dbprefix}questions.gid, " ."{$dbprefix}conditions.method " ."FROM {$dbprefix}conditions, " ."{$dbprefix}questions " ."WHERE {$dbprefix}conditions.cqid={$dbprefix}questions.qid " ."AND {$dbprefix}conditions.qid=$ia[0] " ."AND {$dbprefix}questions.language='".$_SESSION['s_lang']."' " ."ORDER BY {$dbprefix}conditions.cqid, " ."{$dbprefix}conditions.cfieldname"; $cresult = db_execute_assoc($cquery) or safe_die ("OOPS
$cquery
".$connect->ErrorMsg()); //Checked while ($crow = $cresult->FetchRow()) { $conditions[] = array ($crow['qid'], $crow['cqid'], $crow['cfieldname'], $crow['value'], $crow['type'], $crow['sid']."X".$crow['gid']."X".$crow['cqid'], $crow['method']); } return $conditions; } else { return null; } } function create_mandatorylist($ia) { //Checks current question and returns required mandatory arrays if required if ($ia[6] == "Y") { switch($ia[4]) { case "R": $thismandatory=setman_ranking($ia); break; case "M": $thismandatory=setman_questionandcode($ia); break; case "J": case "P": case "Q": case "K": case "A": case "B": case "C": case "E": case "F": case "H": $thismandatory=setman_questionandcode($ia); break; case "1": $thismandatory=setman_questionandcode_multiscale($ia); break; case "X": //Do nothing - boilerplate questions CANNOT be mandatory break; default: $thismandatory=setman_normal($ia); } if ($ia[7] != "Y" && isset($thismandatory)) //Question is not conditional - addto mandatory arrays { $mandatory=$thismandatory; } if ($ia[7] == "Y" && isset($thismandatory)) //Question IS conditional - add to conmandatory arrays { $conmandatory=$thismandatory; } } if (isset($mandatory)) { return array($mandatory, null); } elseif (isset($conmandatory)) { return array(null, $conmandatory); } else { return array(null, null); } } function setman_normal($ia) { $mandatorys[]=$ia[1]; $mandatoryfns[]=$ia[1]; return array($mandatorys, $mandatoryfns); } function setman_ranking($ia) { global $dbprefix, $connect; $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid={$ia[0]} AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; $ansresult = $connect->Execute($ansquery); //Checked $anscount = $ansresult->RecordCount(); for ($i=1; $i<=$anscount; $i++) { $mandatorys[]=$ia[1].$i; $mandatoryfns[]=$ia[1]; } return array($mandatorys, $mandatoryfns); } function setman_questionandcode($ia) { global $dbprefix, $connect; $qquery = "SELECT other FROM {$dbprefix}questions WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."'"; $qresult = db_execute_assoc($qquery); //Checked while ($qrow = $qresult->FetchRow()) {$other = $qrow['other'];} $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid={$ia[0]} AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; $ansresult = db_execute_assoc($ansquery); //Checked while ($ansrow = $ansresult->FetchRow()) { $mandatorys[]=$ia[1].$ansrow['code']; $mandatoryfns[]=$ia[1]; } if ($other == "Y" and ($ia[4]=="!" or $ia[4]=="L" or $ia[4]=="M" or $ia[4]=="P")) { $mandatorys[]=$ia[1]."other"; $mandatoryfns[]=$ia[1]; } return array($mandatorys, $mandatoryfns); } function setman_questionandcode_multiscale($ia) { global $dbprefix, $connect; $qquery = "SELECT other FROM {$dbprefix}questions WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."'"; $qresult = db_execute_assoc($qquery); //Checked while ($qrow = $qresult->FetchRow()) {$other = $qrow['other'];} $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid={$ia[0]} AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; $ansresult = db_execute_assoc($ansquery); //Checked $lquery = "SELECT q.qid FROM {$dbprefix}labels l, {$dbprefix}questions q WHERE l.lid = q.lid AND q.qid=".$ia[0]." AND l.language='".$_SESSION['s_lang']."' AND q.language='".$_SESSION['s_lang']."'"; $labelsresult = db_execute_assoc($lquery); //Checked $labelscount = $labelsresult->RowCount(); $lquery1 = "SELECT q.qid FROM {$dbprefix}labels l, {$dbprefix}questions q WHERE l.lid = q.lid1 AND q.qid=".$ia[0]." AND l.language='".$_SESSION['s_lang']."' AND q.language='".$_SESSION['s_lang']."'"; $labelsresult1 = db_execute_assoc($lquery1); //Checked $labelscount1 = $labelsresult1->RowCount(); while ($ansrow = $ansresult->FetchRow()) { if ($labelscount > 0) { $mandatorys[]=$ia[1].$ansrow['code']."#0"; $mandatoryfns[]=$ia[1]; } else { $mandatorys[]=$ia[1].$ansrow['code']; $mandatoryfns[]=$ia[1]; } // second label set if ($labelscount1 > 0) { $mandatorys[]=$ia[1].$ansrow['code']."#1"; $mandatoryfns[]=$ia[1]; } else { $mandatorys[]=$ia[1].$ansrow['code']; $mandatoryfns[]=$ia[1]; } } if ($other == "Y" and ($ia[4]=="!" or $ia[4]=="L" or $ia[4]=="M" or $ia[4]=="P" or $ia[4]=="1")) { $mandatorys[]=$ia[1]."other"; $mandatoryfns[]=$ia[1]; } return array($mandatorys, $mandatoryfns); } function retrieveAnswers($ia, $notanswered=null, $notvalidated=null) { //This function returns an array containing the "question/answer" html display //and a list of the question/answer fieldnames associated. It is called from //question.php, group.php or survey.php //globalise required config variables global $dbprefix, $shownoanswer, $clang; //These are from the config-defaults.php file //----- global $thissurvey, $gl; //These are set by index.php global $connect; //DISPLAY $display = $ia[7]; //QUESTION NAME $name = $ia[0]; $qtitle=$ia[3]; //Replace INSERTANS statements with previously provided answers; while (strpos($qtitle, "{INSERTANS:") !== false) { $replace=substr($qtitle, strpos($qtitle, "{INSERTANS:"), strpos($qtitle, "}", strpos($qtitle, "{INSERTANS:"))-strpos($qtitle, "{INSERTANS:")+1); $replace2=substr($replace, 11, strpos($replace, "}", strpos($replace, "{INSERTANS:"))-11); $replace3=retrieve_Answer($replace2); $qtitle=str_replace($replace, $replace3, $qtitle); } //while //GET HELP $hquery="SELECT help FROM {$dbprefix}questions WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."'"; $hresult=db_execute_num($hquery) or safe_die($connect->ErrorMsg()); //Checked $help=""; while ($hrow=$hresult->FetchRow()) {$help=$hrow[0];} //A bit of housekeeping to stop PHP Notices $answer = ""; if (!isset($_SESSION[$ia[1]])) {$_SESSION[$ia[1]] = "";} $qidattributes=getQuestionAttributes($ia[0]); //echo "
";print_r($qidattributes);echo "
"; //Create the question/answer html switch ($ia[4]) { case "X": //BOILERPLATE QUESTION $values=do_boilerplate($ia); break; case "5": //5 POINT CHOICE radio-buttons $values=do_5pointchoice($ia); break; case "D": //DATE $values=do_date($ia); break; case "Z": //LIST Flexible drop-down/radio-button list $values=do_list_flexible_radio($ia); if (!$displaycols=arraySearchByKey("hide_tip", $qidattributes, "attribute", 1)) { $qtitle .= "
\n" . $clang->gT("Choose one of the following answers").""; } break; case "L": //LIST drop-down/radio-button list $values=do_list_radio($ia); if (!$displaycols=arraySearchByKey("hide_tip", $qidattributes, "attribute", 1)) { $qtitle .= "
\n" . $clang->gT("Choose one of the following answers").""; } break; case "W": //List - dropdown $values=do_list_flexible_dropdown($ia); if (!$displaycols=arraySearchByKey("hide_tip", $qidattributes, "attribute", 1)) { $qtitle .= "
\n" . $clang->gT("Choose one of the following answers").""; } break; case "!": //List - dropdown $values=do_list_dropdown($ia); if (!$displaycols=arraySearchByKey("hide_tip", $qidattributes, "attribute", 1)) { $qtitle .= "
\n" . $clang->gT("Choose one of the following answers").""; } break; case "O": //LIST WITH COMMENT drop-down/radio-button list + textarea $values=do_listwithcomment($ia); if (count($values[1]) > 1 && !$displaycols=arraySearchByKey("hide_tip", $qidattributes, "attribute", 1)) { $qtitle .= "
\n" . $clang->gT("Choose one of the following answers").""; } break; case "R": //RANKING STYLE $values=do_ranking($ia); break; case "M": //MULTIPLE OPTIONS checkbox $values=do_multiplechoice($ia); if (count($values[1]) > 1 && !$displaycols=arraySearchByKey("hide_tip", $qidattributes, "attribute", 1)) { if (!$maxansw=arraySearchByKey("max_answers", $qidattributes, "attribute", 1)) { $qtitle .= "
\n" . $clang->gT("Check any that apply").""; } else { $qtitle .= "
\n" . $clang->gT("Check at most")." ".$maxansw['value']." ".$clang->gT("answers").""; } } break; case "I": //Language Question $values=do_language($ia); if (count($values[1]) > 1) { $qtitle .= "
\n" . $clang->gT("Choose your language").""; } break; case "P": //MULTIPLE OPTIONS WITH COMMENTS checkbox + text $values=do_multiplechoice_withcomments($ia); if (count($values[1]) > 1 && !$displaycols=arraySearchByKey("hide_tip", $qidattributes, "attribute", 1)) { if (!$maxansw=arraySearchByKey("max_answers", $qidattributes, "attribute", 1)) { $qtitle .= "
\n" . $clang->gT("Check any that apply").""; } else { $qtitle .= "
\n" . $clang->gT("Check at most")." ".$maxansw['value']." ".$clang->gT("answers").""; } } break; case "Q": //MULTIPLE SHORT TEXT $values=do_multipleshorttext($ia); break; case "K": //MULTIPLE NUMERICAL QUESTION $values=do_multiplenumeric($ia); break; case "N": //NUMERICAL QUESTION TYPE $values=do_numerical($ia); break; case "S": //SHORT FREE TEXT $values=do_shortfreetext($ia); break; case "T": //LONG FREE TEXT $values=do_longfreetext($ia); break; case "U": //HUGE FREE TEXT $values=do_hugefreetext($ia); break; case "Y": //YES/NO radio-buttons $values=do_yesno($ia); break; case "G": //GENDER drop-down list $values=do_gender($ia); break; case "A": //ARRAY (5 POINT CHOICE) radio-buttons $values=do_array_5point($ia); break; case "B": //ARRAY (10 POINT CHOICE) radio-buttons $values=do_array_10point($ia); break; case "C": //ARRAY (YES/UNCERTAIN/NO) radio-buttons $values=do_array_yesnouncertain($ia); break; case "E": //ARRAY (Increase/Same/Decrease) radio-buttons $values=do_array_increasesamedecrease($ia); break; case "F": //ARRAY (Flexible) - Row Format $values=do_array_flexible($ia); break; case "H": //ARRAY (Flexible) - Column Format $values=do_array_flexiblecolumns($ia); break; // case "^": //SLIDER CONTROL // $values=do_slider($ia); // break; case "1": //Array (Flexible Labels) dual scale $values=do_array_flexible_dual($ia); break; } //End Switch if (isset($values)) //Break apart $values array returned from switch { //$answer is the html code to be printed //$inputnames is an array containing the names of each input field list($answer, $inputnames)=$values; } $answer .= "\n\t\t\t'.$clang->gT('*').''.$qtitle; } //If this question is mandatory but wasn't answered in the last page //add a message HIGHLIGHTING the question $qtitle .= mandatory_message($ia); $qtitle .= validation_message($ia); $qanda=array($qtitle, $answer, $help, $display, $name, $ia[2], $gl[0], $ia[1]); //New Return return array($qanda, $inputnames); } function validation_message($ia) { //This function checks to see if this question requires validation and //that validation has not been met. global $notvalidated, $dbprefix, $connect, $clang; $qtitle=""; if (isset($notvalidated) && is_array($notvalidated)) //ADD WARNINGS TO QUESTIONS IF THEY ARE NOT VALID { global $validationpopup, $popup; if (in_array($ia[1], $notvalidated)) { $help=""; $helpselect="SELECT help\n" ."FROM {$dbprefix}questions\n" ."WHERE qid={$ia[0]} AND language='".$_SESSION['s_lang']."'"; $helpresult=db_execute_assoc($helpselect) or safe_die("$helpselect
".$connect->ErrorMsg()); //Checked while ($helprow=$helpresult->FetchRow()) { $help=" (".$helprow['help'].")"; } $qtitle .= "
".$clang->gT("This question must be answered correctly")." $help

\n"; } } return $qtitle; } function mandatory_message($ia) { //This function checks to see if this question is mandatory and //is being re-displayed because it wasn't answered. It returns global $notanswered, $clang, $dbprefix; $qtitle=""; if (isset($notanswered) && is_array($notanswered)) //ADD WARNINGS TO QUESTIONS IF THEY WERE MANDATORY BUT NOT ANSWERED { global $mandatorypopup, $popup; if (in_array($ia[1], $notanswered)) { $qtitle .= "
".$clang->gT("This question is mandatory")."."; switch($ia[4]) { case "A": case "B": case "C": case "Q": case "K": case "F": case "J": case "H": $qtitle .= "
\n".$clang->gT("Please complete all parts")."."; break; case "1": $qtitle .= "
\n".$clang->gT("Please check the items")."."; case "R": $qtitle .= "
\n".$clang->gT("Please rank all items")."."; break; case "M": case "P": $qtitle .= " ".$clang->gT("Please check at least one item")."."; $qquery = "SELECT other FROM {$dbprefix}questions WHERE qid=".$ia[0]; $qresult = db_execute_assoc($qquery); //Checked $qrow = $qresult->FetchRow(); if ($qrow['other']=='Y') { $qtitle .= "
\n".$clang->gT("If you choose 'Other:' you must provide a description."); } break; } // end switch $qtitle .= "

\n"; } } return $qtitle; } function mandatory_popup($ia, $notanswered=null) { //This sets the mandatory popup message to show if required //Called from question.php, group.php or survey.php if ($notanswered === null) {unset($notanswered);} if (isset($notanswered) && is_array($notanswered)) //ADD WARNINGS TO QUESTIONS IF THEY WERE MANDATORY BUT NOT ANSWERED { global $mandatorypopup, $popup, $clang; //POPUP WARNING if (!isset($mandatorypopup) && ($ia[4] == "T" || $ia[4] == "S" || $ia[4] == "U")) { $popup="\n"; $mandatorypopup="Y"; }else { $popup="\n"; $mandatorypopup="Y"; } return array($mandatorypopup, $popup); } else { return false; } } function validation_popup($ia, $notvalidated=null) { //This sets the validation popup message to show if required //Called from question.php, group.php or survey.php if ($notvalidated === null) {unset($notvalidated);} $qtitle=""; if (isset($notvalidated) && is_array($notvalidated)) //ADD WARNINGS TO QUESTIONS IF THEY ARE NOT VALID { global $validationpopup, $vpopup, $clang; //POPUP WARNING if (!isset($validationpopup)) { $vpopup = "\n"; $validationpopup="Y"; } return array($validationpopup, $vpopup); } else { return false; } } //QUESTION METHODS function do_boilerplate($ia) { $answer=""; $inputnames[]=""; return array($answer, $inputnames); } function do_5pointchoice($ia) { global $shownoanswer, $clang; $answer=""; for ($fp=1; $fp<=5; $fp++) { $answer .= "\t\t\tgT("No answer")."\n"; } $answer .= "\t\t\t\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_date($ia) { global $clang; $qidattributes=getQuestionAttributes($ia[0]); if (arraySearchByKey("dropdown_dates", $qidattributes, "attribute", 1)) { if (!empty($_SESSION[$ia[1]])) { list($currentyear, $currentmonth, $currentdate) = explode("-", $_SESSION[$ia[1]]); } else { $currentdate=""; $currentmonth=""; $currentyear=""; } $answer = keycontroljs(); $answer .= "\t\t\t\n"; $answer .= "\t\t\t\n"; $answer .= "\t\t\t\n"; $answer .= "\n"; $answer .= "\n"; } else { $answer = keycontroljs() . "\t\t\t\n" . "\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t
\n" . "\t\t\t\t\t\t".$clang->gT("Format: YYYY-MM-DD")."
\n" . "\t\t\t\t\t\t".$clang->gT("(eg: 2003-12-25 for Christmas day)")."\n" . "\t\t\t\t\t
\n"; // Here we do setup the date javascript $answer .= "\n"; } $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_language($ia) { global $dbprefix, $surveyid, $clang; $answerlangs = GetAdditionalLanguagesFromSurveyID($surveyid); $answerlangs [] = GetBaseLanguageFromSurveyID($surveyid); $answer = "\n\t\t\t\t\t\n"; $answer .= "\t\t\t\t\t\n"; $inputnames[]=$ia[1]; $answer .= "\n\t\t\t"; return array($answer, $inputnames); } function do_list_dropdown($ia) { global $dbprefix, $dropdownthreshold, $lwcdropdowns, $connect; global $shownoanswer, $clang; $qidattributes=getQuestionAttributes($ia[0]); if ($othertexts=arraySearchByKey("other_replace_text", $qidattributes, "attribute", 1)) { $othertext=$othertexts['value']; } else { $othertext=$clang->gT("Other"); } $answer=""; if (isset($defexists)) {unset ($defexists);} $query = "SELECT other FROM {$dbprefix}questions WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."' "; $result = db_execute_assoc($query); //Checked while($row = $result->FetchRow()) {$other = $row['other'];} if (arraySearchByKey("random_order", $qidattributes, "attribute", 1)) { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; } $ansresult = db_execute_assoc($ansquery) or safe_die("Couldn't get answers
$ansquery
".$connect->ErrorMsg()); //Checked while ($ansrow = $ansresult->FetchRow()) { $answer .= "\t\t\t\t\t\t\n".$answer; } if (isset($other) && $other=="Y") { $answer .= "\t\t\t\t\t\t\n";} $answer .= "\t\t\t\t\t\n"; $answer .= "\t\t\t\t\t\n"; $sselect = "\n\t\t\t\t\t END BUG FIX // --> START NEW FEATURE - SAVE $answer .= " />"; // --> END NEW FEATURE - SAVE } $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_list_flexible_dropdown($ia) { global $dbprefix, $dropdownthreshold, $lwcdropdowns, $connect; global $shownoanswer, $clang; $qidattributes=getQuestionAttributes($ia[0]); if ($othertexts=arraySearchByKey("other_replace_text", $qidattributes, "attribute", 1)) { $othertext=$othertexts['value']; } else { $othertext=$clang->gT("Other"); } $answer=""; $qquery = "SELECT other, lid FROM {$dbprefix}questions WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."'"; $qresult = db_execute_assoc($qquery); //Checked while($row = $qresult->FetchRow()) {$other = $row['other']; $lid=$row['lid'];} $filter=""; if ($code_filter=arraySearchByKey("code_filter", $qidattributes, "attribute", 1)) { $filter=$code_filter['value']; if(in_array($filter, $_SESSION['insertarray'])) { $filter=trim($_SESSION[$filter]); } } $filter .= "%"; if (arraySearchByKey("random_order", $qidattributes, "attribute", 1)) { $ansquery = "SELECT * FROM {$dbprefix}labels WHERE lid=$lid AND code LIKE '$filter' AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}labels WHERE lid=$lid AND code LIKE '$filter' AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, code"; } $ansresult = db_execute_assoc($ansquery) or safe_die("Couldn't get answers
$ansquery
".$connect->ErrorMsg());//Checked if (labelset_exists($lid,$_SESSION['s_lang'])) { while ($ansrow = $ansresult->FetchRow()) { $answer .= "\t\t\t\t\t\t\n".$answer; } if (isset($other) && $other=="Y") { $answer .= "\t\t\t\t\t\t\n";} $answer .= "\t\t\t\t\t\n"; } else { $answer .= ""; } $answer .= "\t\t\t\t\t\n"; $sselect = "\n\t\t\t\t\t"; // --> END NEW FEATURE - SAVE } $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_list_radio($ia) { global $dbprefix, $dropdownthreshold, $lwcdropdowns, $connect, $clang; global $shownoanswer; $answer=""; $qidattributes=getQuestionAttributes($ia[0]); if ($displaycols=arraySearchByKey("display_columns", $qidattributes, "attribute", 1)) { $dcols=$displaycols['value']; } else { $dcols=0; } if ($othertexts=arraySearchByKey("other_replace_text", $qidattributes, "attribute", 1)) { $othertext=$othertexts['value']; } else { $othertext=$clang->gT("Other"); } if (isset($defexists)) {unset ($defexists);} $query = "SELECT other FROM {$dbprefix}questions WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."' "; $result = db_execute_assoc($query); //Checked while($row = $result->FetchRow()) {$other = $row['other'];} if (arraySearchByKey("random_order", $qidattributes, "attribute", 1)) { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; } $ansresult = db_execute_assoc($ansquery) or safe_die("Couldn't get answers
$ansquery
".$connect->ErrorMsg()); //Checked $anscount = $ansresult->RecordCount(); if (isset($other) && $other=="Y") {$anscount++;} //Count up for the Other answer if ($ia[6] != "Y" && $shownoanswer == 1) {$anscount++;} //Count up if "No answer" is showing $divider=""; $maxrows=0; if ($dcols >0 && $anscount >= $dcols) //Break into columns { $denominator=$dcols; //Change this to set the number of columns $width=sprintf("%0d", 100/$denominator); $maxrows=ceil(100*($anscount/$dcols)/100); //Always rounds up to nearest whole number $answer .= "\n \n
"; $divider=" "; } else { $answer .= "\n\t\t\t\t\t\n" . "\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\n" . "\t\t\t\t\t
\n"; } $rowcounter=0; while ($ansrow = $ansresult->FetchRow()) { $rowcounter++; $answer .= "\t\t\t\t\t\t\t\t START NEW FEATURE - SAVE $answer .= " onclick=\"checkconditions(this.value, this.name, this.type); document.limesurvey.move.value = '"; if (isset($_SESSION['step']) && $_SESSION['step'] && ($_SESSION['step'] == $_SESSION['totalsteps'])) $answer .= "movesubmit"; else $answer .= "movenext"; $answer .= "'; document.limesurvey.submit();\" />
\n"; // --> END NEW FEATURE - SAVE if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } if (isset($other) && $other=="Y") { $rowcounter++; $answer .= "\t\t\t\t\t\t\t\t
START NEW FEATURE - SAVE $answer .= " onclick='checkconditions(this.value, this.name, this.type)' />\n"; // --> END NEW FEATURE - SAVE $answer .= "
\n"; // --> END NEW FEATURE - SAVE $inputnames[]=$thisfieldname; if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } if ($ia[6] != "Y" && $shownoanswer == 1) { $rowcounter++; $answer .= "\t\t\t\t\t\t START NEW FEATURE - SAVE $answer .=" onclick='checkconditions(this.value, this.name, this.type)' />" . "\n"; // --> END NEW FEATURE - SAVE if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } $answer .= "\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t
\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_list_flexible_radio($ia) { global $dbprefix, $dropdownthreshold, $lwcdropdowns, $connect; global $shownoanswer, $clang; $answer=""; $qidattributes=getQuestionAttributes($ia[0]); if ($othertexts=arraySearchByKey("other_replace_text", $qidattributes, "attribute", 1)) { $othertext=$othertexts['value']; } else { $othertext=$clang->gT("Other"); } if ($displaycols=arraySearchByKey("display_columns", $qidattributes, "attribute", 1)) { $dcols=$displaycols['value']; } else { $dcols=0; } if (isset($defexists)) {unset ($defexists);} $query = "SELECT other, lid FROM {$dbprefix}questions WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."'"; $result = db_execute_assoc($query); //Checked while($row = $result->FetchRow()) {$other = $row['other']; $lid = $row['lid'];} $filter=""; if ($code_filter=arraySearchByKey("code_filter", $qidattributes, "attribute", 1)) { $filter=$code_filter['value']; if(in_array($filter, $_SESSION['insertarray'])) { $filter=trim($_SESSION[$filter]); } } $filter .= "%"; if (arraySearchByKey("random_order", $qidattributes, "attribute", 1)) { $ansquery = "SELECT * FROM {$dbprefix}labels WHERE lid=$lid AND code LIKE '$filter' AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}labels WHERE lid=$lid AND code LIKE '$filter' AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, code"; } $ansresult = db_execute_assoc($ansquery) or safe_die("Couldn't get answers
$ansquery
".$connect->ErrorMsg()); //Checked $anscount = $ansresult->RecordCount(); if ((isset($other) && $other=="Y") || ($ia[6] != "Y" && $shownoanswer == 1)) {$anscount++;} //Count $divider=""; $maxrows=0; if ($dcols >0 && $anscount >= $dcols) //Break into columns { $denominator=$dcols; //Change this to set the number of columns $width=sprintf("%0d", 100/$denominator); $maxrows=ceil(100*($anscount/$dcols)/100); //Always rounds up to nearest whole number $answer .= "\n \n \n"; } $choicelist = "\t\t\t\t\t\t\n"; $answer .= "\t\t\t
"; $divider=" "; } else { $answer .= "\n\t\t\t\t\t\n" . "\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\n" . "\t\t\t\t\t
\n"; } $rowcounter=0; if (labelset_exists($lid,$_SESSION['s_lang'])) { while ($ansrow = $ansresult->FetchRow()) { $rowcounter++; $answer .= "\t\t\t\t\t\t\t\t START NEW FEATURE - SAVE $answer .= " onclick=\"checkconditions(this.value, this.name, this.type); document.limesurvey.move.value = '"; if (isset($_SESSION['step']) && $_SESSION['step'] && ($_SESSION['step'] == $_SESSION['totalsteps'])) $answer .= "movesubmit"; else $answer .= "movenext"; $answer .= "'; document.limesurvey.submit();\" />
\n"; // --> END NEW FEATURE - SAVE if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } } else { $answer .= $clang->gT('Error: The labelset used for this question is not available in this language.')."
"; } if (isset($other) && $other=="Y") { $rowcounter++; $answer .= "\t\t\t\t\t\t\t\t START NEW FEATURE - SAVE $answer .= " onclick='checkconditions(this.value, this.name, this.type)' />\n"; // --> END NEW FEATURE - SAVE $answer .= "
\n"; // --> END NEW FEATURE - SAVE $inputnames[]=$thisfieldname; if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } if ($ia[6] != "Y" && $shownoanswer == 1) { $rowcounter++; $answer .= "\t\t\t\t\t\t ".$clang->gT("No answer")."\n"; if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } $answer .= "\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t
\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_listwithcomment($ia) { global $maxoptionsize, $dbprefix, $dropdownthreshold, $lwcdropdowns; global $shownoanswer, $clang; $answer=""; $qidattributes=getQuestionAttributes($ia[0]); if (!isset($maxoptionsize)) {$maxoptionsize=35;} if (arraySearchByKey("random_order", $qidattributes, "attribute", 1)) { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; } $ansresult = db_execute_assoc($ansquery); //Checked $anscount = $ansresult->RecordCount(); if ($lwcdropdowns == "R" && $anscount <= $dropdownthreshold) { $answer .= "\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n" . "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n"; $fname2 = $ia[1]."comment"; if ($anscount > 8) {$tarows = $anscount/1.2;} else {$tarows = 4;} // --> START NEW FEATURE - SAVE // --> START ORIGINAL // $answer .= "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t
".$clang->gT("Please choose one of the following").":
\n"; while ($ansrow=$ansresult->FetchRow()) { $answer .= "\t\t\t\t\t\tgT("No answer")."\n"; } $answer .= "\t\t\t\t\t\n" // . "\t\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t
\n"; $inputnames[]=$ia[1]; $inputnames[]=$ia[1]."comment"; } else //Dropdown list { // --> START NEW FEATURE - SAVE $answer .= "\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n"; $fname2 = $ia[1]."comment"; if ($anscount > 8) {$tarows = $anscount/1.2;} else {$tarows = 4;} if ($tarows > 15) {$tarows=15;} $maxoptionsize=$maxoptionsize*0.72; if ($maxoptionsize < 33) {$maxoptionsize=33;} if ($maxoptionsize > 70) {$maxoptionsize=70;} $answer .= "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t
\n" . "\t\t\t\t\t\n" . "\t\t\t\t\t
\n"; // --> START NEW FEATURE - SAVE $answer .= "\t\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t
\n"; $inputnames[]=$ia[1]; $inputnames[]=$ia[1]."comment"; } return array($answer, $inputnames); } function do_ranking($ia) { global $dbprefix, $imagefiles, $clang; $qidattributes=getQuestionAttributes($ia[0]); $answer=""; if (arraySearchByKey("random_order", $qidattributes, "attribute", 1)) { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; } $ansresult = db_execute_assoc($ansquery); //Checked $anscount = $ansresult->RecordCount(); $answer .= "\t\t\t\n"; unset($answers); //unset($inputnames); unset($chosen); $ranklist=""; while ($ansrow = $ansresult->FetchRow()) { $answers[] = array($ansrow['code'], $ansrow['answer']); } $existing=0; for ($i=1; $i<=$anscount; $i++) { $myfname=$ia[1].$i; if (isset($_SESSION[$myfname]) && $_SESSION[$myfname]) { $existing++; } } for ($i=1; $i<=$anscount; $i++) { $myfname = $ia[1].$i; if (isset($_SESSION[$myfname]) && $_SESSION[$myfname]) { foreach ($answers as $ans) { if ($ans[0] == $_SESSION[$myfname]) { $thiscode=$ans[0]; $thistext=$ans[1]; } } } $ranklist .= "\t\t\t\t\t\t\t
 \n"; $ranklist .= "\t\t\t\t\t\t\n"; $ranklist .= "\t\t\t\t\t\t".$clang->gT("Remove this item")."
\n"; $inputnames[]=$myfname; $ranklist .= "
\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n"; if (isset($maxselectlength) && $maxselectlength > 60) { $ranklist = str_replace("\n" . "\t\t\t\t\t\t\t
\n" . "\t\t\t\t\t\t".$clang->gT("Click on an item in the list on the left, starting with your") . "\t\t\t\t\t\t".$clang->gT("highest ranking item, moving through to your lowest ranking item.") . "\t\t\t\t\t
\n" . "\t\t\t\t\t\t  
\n" . " ".$choicelist . "\t\t\t\t\t 
\n" . "\t\t\t\t\t\t\t\n"; } else { $answer .= "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t
".$clang->gT("Your Ranking").":
\n" . "\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\n"; } $answer .= $ranklist . "\t\t\t\t\t\t\t
".$clang->gT("Your Ranking").":
\n" . "\t\t\t\t\t
\n" . "\t\t\t\t\t\t".$clang->gT("Click on the scissors next to each item on the right") . "\t\t\t\t\t\t".$clang->gT("to remove the last entry in your ranked list")."" . "\t\t\t\t\t
\n"; return array($answer, $inputnames); } function do_multiplechoice($ia) { global $dbprefix, $clang, $connect; $qidattributes=getQuestionAttributes($ia[0]); if ($othertexts=arraySearchByKey("other_replace_text", $qidattributes, "attribute", 1)) { $othertext=$othertexts['value']; } else { $othertext=$clang->gT("Other"); } if ($displaycols=arraySearchByKey("display_columns", $qidattributes, "attribute", 1)) { $dcols=$displaycols['value']; } else { $dcols=0; } // Check if the max_answers attribute is set $maxansw=0; $callmaxanswscriptcheckbox = ""; $callmaxanswscriptother = ""; $maxanswscript = ""; if ($excludeothers=arraySearchByKey("exclude_all_others", $qidattributes, "attribute", 1)) { $excludeallothers=$excludeothers['value']; $excludeallotherscript = " \n"; } } } elseif ($ansrow['default_value'] == 'Y') { $answer .= " checked='checked'"; } // --> START NEW FEATURE - SAVE $answer .= " onclick='"; if($ansrow['code'] == $excludeallothers) { $answer .= "excludeAllOthers$ia[1](this.id, \"yes\");"; // was "this.id" } elseif ($excludeallothers != "") { $excludeallotherscripton .= "thiselt=document.getElementById('answer$ia[1]{$ansrow['code']}');\n" . "\t\tthiselt.checked='';\n" . "\t\tthiselt.disabled='true';\n" . "\t\tif (doconditioncheck == 'yes') {\n" . "\t\t\tcheckconditions(thiselt.value, thiselt.name, thiselt.type);\n" . "\t\t}\n"; $excludeallotherscriptoff.= "document.getElementById('answer$ia[1]{$ansrow['code']}').disabled='';\n"; } $answer .= $callmaxanswscriptcheckbox."checkconditions(this.value, this.name, this.type)' />
\n"; // --> END NEW FEATURE - SAVE if ($maxansw > 0) {$maxanswscript .= "\t\t\t\t\tif (document.getElementById('answer".$myfname."').checked) { count += 1; }\n";} $fn++; $answer .= "\t\t\t\t\n"; $inputnames[]=$myfname; if ($rowcounter==$maxrows) {$answer .= $divider; $rowcounter=0;} } if ($other == "Y") { $rowcounter++; $myfname = $ia[1]."other"; if($excludeallothers != "") { $excludeallotherscripton .= "thiselt=document.getElementById('$ia[1]othercbox');\n" . "\t\tthiselt.checked='';\n" . "\t\tthiselt.disabled='true';\n"; $excludeallotherscripton .= "thiselt=document.getElementById('answer$ia[1]other');\n" . "\t\tthiselt.value='';\n" . "\t\tthiselt.disabled='true';\n" . "\t\tif (doconditioncheck == 'yes') {\n" . "\t\t\tcheckconditions(thiselt.value, thiselt.name, thiselt.type);\n" . "\t\t}\n"; $excludeallotherscriptoff .="document.getElementById('answer$ia[1]other').disabled='';\n"; $excludeallotherscriptoff .="document.getElementById('$ia[1]othercbox').disabled='';\n"; } $answer .= "\t\t\t\t\t\t"; $answer .= "\t\t\t\t\t\t START NEW FEATURE - SAVE $answer .= " onkeypress='document.getElementById(\"{$myfname}cbox\").checked=true;' ".$callmaxanswscriptother."/>\n" . "\t\t\t\t\n"; if ( $maxansw > 0 ) { $maxanswscript .= "\t\t\t\t\tif (count > max)\n" . "\t\t\t\t\t\t{\n" . "\t\t\t\t\t\talert('".$clang->gT("Please choose at most","js")." ' + max + ' ".$clang->gT("answer(s) for question","js")." \"".trim(javascript_escape($ia[3],true,true))."\"');\n" . "\t\t\t\t\t\tif (me.type == 'checkbox') {me.checked = false;}\n" . "\t\t\t\t\t\tif (me.type == 'text') {\n" . "\t\t\t\t\t\t\tme.value = '';\n" . "\t\t\t\t\t\t\tif (document.getElementById(me.name + 'cbox') ){\n" . "\t\t\t\t\t\t\t\t document.getElementById(me.name + 'cbox').checked = false;\n" . "\t\t\t\t\t\t\t}\n" . "\t\t\t\t\t\t}" . "\t\t\t\t\t\treturn max;\n" . "\t\t\t\t\t\t}\n" . "\t\t\t\t\t}\n" . "\t\t\t//-->\n" . "\t\t\t\n"; $answer = $maxanswscript . $answer; } if ($excludeallothers != "") { $excludeallotherscript .= " if (document.getElementById(value).checked) { $excludeallotherscripton } else { $excludeallotherscriptoff } } //--> "; $answer = $excludeallotherscript . $answer; } $answer .= $postrow; return array($answer, $inputnames); } function do_multiplechoice_withcomments($ia) { global $dbprefix, $clang; $qidattributes=getQuestionAttributes($ia[0]); if ($othertexts=arraySearchByKey("other_replace_text", $qidattributes, "attribute", 1)) { $othertext=$othertexts['value']; } else { $othertext=$clang->gT("Other"); } // Check if the max_answers attribute is set $maxansw=0; $callmaxanswscriptcheckbox = ""; $callmaxanswscriptother = ""; $maxanswscript = ""; if ($maxanswattr=arraySearchByKey("max_answers", $qidattributes, "attribute", 1)) { $maxansw=$maxanswattr['value']; $callmaxanswscriptcheckbox = "limitmaxansw_{$ia[0]}(this);"; $callmaxanswscriptother = "onkeyup='limitmaxansw_{$ia[0]}(this)'"; $maxanswscript = "\t\t\t\n"; $answer = $maxanswscript . $answer; } return array($answer, $inputnames); } function do_multipleshorttext($ia) { global $dbprefix, $clang; $qidattributes=getQuestionAttributes($ia[0]); if (arraySearchByKey("numbers_only", $qidattributes, "attribute", 1)) { $numbersonly = "onkeypress=\"return goodchars(event,'0123456789.')\""; } else { $numbersonly = ""; } if ($maxchars=arraySearchByKey("maximum_chars", $qidattributes, "attribute", 1)) { $maxsize=$maxchars['value']; } else { $maxsize=255; } if ($prefix=arraySearchByKey("prefix", $qidattributes, "attribute", 1)) { $prefix = $prefix['value']; } else { $prefix = ""; } if ($suffix=arraySearchByKey("suffix", $qidattributes, "attribute", 1)) { $suffix = $suffix['value']; } else { $suffix = ""; } if (arraySearchByKey("random_order", $qidattributes, "attribute", 1)) { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; } $ansresult = db_execute_assoc($ansquery); //Checked $anscount = $ansresult->RecordCount()*2; //$answer .= "\t\t\t\t\t\n"; $fn = 1; $answer = keycontroljs(); $answer .= "\t\t\t\t\t\t\n"; if ($anscount==0) { $inputnames=array(); $answer.="\n"; } else { while ($ansrow = $ansresult->FetchRow()) { $myfname = $ia[1].$ansrow['code']; $answer .= "\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\n"; // --> END NEW FEATURE - SAVE $fn++; $inputnames[]=$myfname; } } $answer .= "\t\t\t\t\t\t
".$clang->gT("Error: This question has no answers.")."
\n" . "\t\t\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\t\t$prefix$suffix\n" . "\t\t\t\t\t\t\t\t
\n"; return array($answer, $inputnames); } function do_multiplenumeric($ia) { global $dbprefix, $clang; $qidattributes=getQuestionAttributes($ia[0]); //Must turn on the "numbers only javascript" $numbersonly = "onkeypress=\"return goodchars(event,'0123456789.')\""; if ($maxchars=arraySearchByKey("maximum_chars", $qidattributes, "attribute", 1)) { $maxsize=$maxchars['value']; } else { $maxsize=255; } if ($equalvalue=arraySearchByKey("equals_num_value", $qidattributes, "attribute", 1)) { $equals_num_value=$equalvalue['value']; $numbersonlyonblur[]="calculateValue".$ia[1]."(3)"; $calculateValue[]=3; } else { $equals_num_value[]=0; } if ($minvalue=arraySearchByKey("min_num_value", $qidattributes, "attribute", 1)) { $min_num_value=$minvalue['value']; $numbersonlyonblur[]="calculateValue".$ia[1]."(2)"; $calculateValue[]=2; } else { $min_num_value=0; } if ($maxvalue=arraySearchByKey("max_num_value", $qidattributes, "attribute", 1)) { $max_num_value = $maxvalue['value']; $numbersonlyonblur[]="calculateValue".$ia[1]."(1)"; $calculateValue[]=1; } else { $max_num_value = 0; } if ($prefix=arraySearchByKey("prefix", $qidattributes, "attribute", 1)) { $prefix = $prefix['value']; } else { $prefix = ""; } if ($suffix=arraySearchByKey("suffix", $qidattributes, "attribute", 1)) { $suffix = $suffix['value']; } else { $suffix = ""; } if(!empty($numbersonlyonblur)) { $numbersonly .= " onblur=\"".implode(";", $numbersonlyonblur)."\""; } if ($maxchars=arraySearchByKey("text_input_width", $qidattributes, "attribute", 1)) { $tiwidth=$maxchars['value']; } else { $tiwidth=10; } if ($hidetip=arraySearchByKey("hide_tip", $qidattributes, "attribute", 1)) { $hidetip=$hidetip['value']; } else { $hidetip=0; } if (arraySearchByKey("random_order", $qidattributes, "attribute", 1)) { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; } $ansresult = db_execute_assoc($ansquery); //Checked $anscount = $ansresult->RecordCount()*2; //$answer .= "\t\t\t\t\t\n"; $fn = 1; $answer = keycontroljs(); $answer .= "\t\t\t\t\t\t\n"; if ($anscount==0) { $inputnames=array(); $answer.="\n"; } else { while ($ansrow = $ansresult->FetchRow()) { $myfname = $ia[1].$ansrow['code']; $answer .= "\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\n"; // --> END NEW FEATURE - SAVE $fn++; $inputnames[]=$myfname; } if($hidetip == 0) { $answer .= "
\t\t\t".$clang->gT("Only numbers may be entered in these fields")."\n"; } if ($maxvalue) { $answer .= "\t\t\t
".$clang->gT("Total of all entries must not exceed ").$max_num_value."
\n"; } if ($equalvalue) { $answer .= "\t\t\t
".$clang->gT("Total of all entries must equal ").$equals_num_value."
\n"; } if ($minvalue) { $answer .= "\t\t\t
".$clang->gT("Total of all entries must be at least ").$min_num_value."
\n"; } if ($maxvalue || $equalvalue || $minvalue) { $answer .= "\t\t\t\t\t\t\n"; } } $answer .= "\t\t\t\t\t\t
".$clang->gT("Error: This question has no answers.")."
\n" . "\t\t\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\t\n" . "\t\t\t\t\t\t\t\t\t$prefix$suffix\n" . "\t\t\t\t\t\t\t\t
\n"; $answer .= "\n"; if ($equalvalue) { $answer .= "\n"; } $answer .= "
".$clang->gT("Total: ")."$prefix$suffix
".$clang->gT("Remaining: ")."$prefix$suffix
\n"; if ($maxvalue || $equalvalue || $minvalue) { //Do value validation $answer .= "\n"; $answer .= "\n"; $answer .= "\n"; } return array($answer, $inputnames); } function do_numerical($ia) { global $clang; $qidattributes=getQuestionAttributes($ia[0]); if ($prefix=arraySearchByKey("prefix", $qidattributes, "attribute", 1)) { $prefix = $prefix['value']; } else { $prefix = ""; } if ($suffix=arraySearchByKey("suffix", $qidattributes, "attribute", 1)) { $suffix = $suffix['value']; } else { $suffix = ""; } if ($maxchars=arraySearchByKey("maximum_chars", $qidattributes, "attribute", 1)) { $maxsize=$maxchars['value']; if ($maxsize>20) {$maxsize=20;} } else { $maxsize=20; // The field length for numerical fields is 20 } if ($maxchars=arraySearchByKey("text_input_width", $qidattributes, "attribute", 1)) { $tiwidth=$maxchars['value']; } else { $tiwidth=10; } // --> START NEW FEATURE - SAVE $answer = keycontroljs() . "\t\t\t$prefix$suffix
\n" . "\t\t\t".$clang->gT("Only numbers may be entered in this field")."\n"; // --> END NEW FEATURE - SAVE $inputnames[]=$ia[1]; $mandatory=null; return array($answer, $inputnames, $mandatory); } function do_shortfreetext($ia) { $qidattributes=getQuestionAttributes($ia[0]); if ($maxchars=arraySearchByKey("maximum_chars", $qidattributes, "attribute", 1)) { $maxsize=$maxchars['value']; } else { $maxsize=255; } if ($maxchars=arraySearchByKey("text_input_width", $qidattributes, "attribute", 1)) { $tiwidth=$maxchars['value']; } else { $tiwidth=50; } if ($prefix=arraySearchByKey("prefix", $qidattributes, "attribute", 1)) { $prefix = $prefix['value']; } else { $prefix = ""; } if ($suffix=arraySearchByKey("suffix", $qidattributes, "attribute", 1)) { $suffix = $suffix['value']; } else { $suffix = ""; } // --> START NEW FEATURE - SAVE $answer = "\t\t\t$prefix$suffix\n"; // --> END NEW FEATURE - SAVE $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_longfreetext($ia) { $qidattributes=getQuestionAttributes($ia[0]); if ($maxchars=arraySearchByKey("maximum_chars", $qidattributes, "attribute", 1)) { $maxsize=$maxchars['value']; } else { $maxsize=65525; } // --> START ENHANCEMENT - DISPLAY ROWS if ($displayrows=arraySearchByKey("display_rows", $qidattributes, "attribute", 1)) { $drows=$displayrows['value']; } else { $drows=5; } // <-- END ENHANCEMENT - DISPLAY ROWS // --> START ENHANCEMENT - TEXT INPUT WIDTH if ($maxchars=arraySearchByKey("text_input_width", $qidattributes, "attribute", 1)) { $tiwidth=$maxchars['value']; } else { $tiwidth=40; } // <-- END ENHANCEMENT - TEXT INPUT WIDTH $answer = "\n"; // --> START ENHANCEMENT - DISPLAY ROWS // --> START ENHANCEMENT - TEXT INPUT WIDTH // --> START NEW FEATURE - SAVE $answer .= "\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_hugefreetext($ia) { $qidattributes=getQuestionAttributes($ia[0]); if ($maxchars=arraySearchByKey("maximum_chars", $qidattributes, "attribute", 1)) { $maxsize=$maxchars['value']; } else { $maxsize=65525; } // --> START ENHANCEMENT - DISPLAY ROWS if ($displayrows=arraySearchByKey("display_rows", $qidattributes, "attribute", 1)) { $drows=$displayrows['value']; } else { $drows=30; } // <-- END ENHANCEMENT - DISPLAY ROWS // --> START ENHANCEMENT - TEXT INPUT WIDTH if ($maxchars=arraySearchByKey("text_input_width", $qidattributes, "attribute", 1)) { $tiwidth=$maxchars['value']; } else { $tiwidth=70; } // <-- END ENHANCEMENT - TEXT INPUT WIDTH $answer = "\n"; // --> START ENHANCEMENT - DISPLAY ROWS // --> START ENHANCEMENT - TEXT INPUT WIDTH // --> START NEW FEATURE - SAVE $answer .= "\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_yesno($ia) { global $shownoanswer, $clang; $answer = "\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t
\n" . "\t\t\t\t\t\t START NEW FEATURE - SAVE $answer .= " onclick='checkconditions(this.value, this.name, this.type)' />
\n" . "\t\t\t\t\t\t END NEW FEATURE - SAVE if ($_SESSION[$ia[1]] == "N") {$answer .= " checked='checked'";} // --> START NEW FEATURE - SAVE $answer .= " onclick='checkconditions(this.value, this.name, this.type)' />
\n"; // --> END NEW FEATURE - SAVE if ($ia[6] != "Y" && $shownoanswer == 1) { $answer .= "\t\t\t\t\t\t START NEW FEATURE - SAVE $answer .= " onclick='checkconditions(this.value, this.name, this.type)' />
\n"; // --> END NEW FEATURE - SAVE } $answer .= "\t\t\t\t\n" . "\t\t\t\t\t
\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_gender($ia) { global $shownoanswer, $clang; $qidattributes=getQuestionAttributes($ia[0]); if ($displaycols=arraySearchByKey("display_columns", $qidattributes, "attribute", 1)) { $dcols=$displaycols['value']; } else { $dcols=0; } $answer = "\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t
\n" . "\t\t\t\t\t\t START NEW FEATURE - SAVE $answer .= " onclick='checkconditions(this.value, this.name, this.type)' />" . "\n"; if ($dcols > 1 ) //Break into columns - don't need any detailed calculations becauase there's only ever 2 possible columns { $answer .= "\n\n"; } else { $answer .= "
\n"; } $answer .= "\t\t\t\t\t\t END NEW FEATURE - SAVE if ($_SESSION[$ia[1]] == "M") {$answer .= " checked='checked'";} // --> START NEW FEATURE - SAVE $answer .= " onclick='checkconditions(this.value, this.name, this.type)' />\n"; // --> END NEW FEATURE - SAVE if ($ia[6] != "Y" && $shownoanswer == 1) { if ($dcols > 2) { $answer .= "\n
\n"; } elseif ($dcols > 1) { $answer .= "\n
\n"; } else { $answer .= "
"; } $answer .= "\t\t\t\t\t\t START NEW FEATURE - SAVE $answer .= " onclick='checkconditions(this.value, this.name, this.type)' />\n"; // --> END NEW FEATURE - SAVE } $answer .= "\t\t\t\t\n" . "\t\t\t\t\t
\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_array_5point($ia) { global $dbprefix, $shownoanswer, $notanswered, $thissurvey, $clang; $ansquery = "SELECT answer FROM {$dbprefix}answers WHERE qid=".$ia[0]." AND answer like '%|%'"; $ansresult = db_execute_assoc($ansquery); //Checked if ($ansresult->RecordCount()>0) {$right_exists=true;} 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 $qidattributes=getQuestionAttributes($ia[0]); if ($answerwidth=arraySearchByKey("answer_width", $qidattributes, "attribute", 1)) { $answerwidth=$answerwidth['value']; } else { $answerwidth=20; } if (arraySearchByKey("random_order", $qidattributes, "attribute", 1)) { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."' ORDER BY sortorder, answer"; } $ansresult = db_execute_assoc($ansquery); //Checked $anscount = $ansresult->RecordCount(); $fn = 1; $answer = "\t\t\t\n" . "\t\t\t\t\n" . "\t\t\t\t\t\n"; for ($xc=1; $xc<=5; $xc++) { $answer .= "\t\t\t\t\t\n"; } if ($right_exists) {$answer .= "";} if ($ia[6] != "Y" && $shownoanswer == 1) //Question is not mandatory { $answer .= "\t\t\t\t\t\n"; } $answer .= "\t\t\t\t\n"; while ($ansrow = $ansresult->FetchRow()) { $myfname = $ia[1].$ansrow['code']; $answertext=answer_replace($ansrow['answer']); 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 ((is_array($notanswered)) && (array_search($ia[1], $notanswered) !== FALSE) && ($_SESSION[$myfname] == "") ) { $answertext = "{$answertext}"; } if (!isset($trbc) || $trbc == "array1" || !$trbc) {$trbc = "array2";} else {$trbc = "array1";} $htmltbody2 = ""; if (($htmltbody=arraySearchByKey("array_filter", $qidattributes, "attribute", 1) && $thissurvey['format'] == "G" && getArrayFiltersOutGroup($ia[0]) == false) || ($htmltbody=arraySearchByKey("array_filter", $qidattributes, "attribute", 1) && $thissurvey['format'] == "A")) { $htmltbody2 = ""; } else if (($htmltbody=arraySearchByKey("array_filter", $qidattributes, "attribute", 1) && $thissurvey['format'] == "S") || ($htmltbody=arraySearchByKey("array_filter", $qidattributes, "attribute", 1) && $thissurvey['format'] == "G" && getArrayFiltersOutGroup($ia[0]) == true)) { $selected = getArrayFiltersForQuestion($ia[0]); if (!in_array($ansrow['code'],$selected)) { $htmltbody2 = ""; $_SESSION[$myfname] = ""; } else { $htmltbody2 = ""; } } $answer .= "\t\t\t\t$htmltbody2\n" . "\t\t\t\t\t\n"; for ($i=1; $i<=5; $i++) { $answer .= "\t\t\t\t\t
$xc ".$clang->gT("No answer")."
$answertext\n" . "\t\t\t\t