getConfig('surveyID')]['insertarray'] variable which is built at the commencement of the survey. * See index.php, function "buildsurveysession()" * One $ia array exists for every question in the survey. The $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['insertarray'] * string is an array of $ia arrays. * * $ia[0] => 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 exist for this question * $ia[8] => other questions have conditions which rely on this question (including array_filter and array_filter_exclude attributes) * $ia[9] => incremental question count (used by {QUESTION_NUMBER}) * * $conditions element structure * $condition[n][0] => qid = question id * $condition[n][1] => cqid = question id of the target question, or 0 for TokenAttr leftOperand * $condition[n][2] => field name of element [1] (Except for type M or P) * $condition[n][3] => value to be evaluated on answers labeled. * $condition[n][4] => type of question * $condition[n][5] => SGQ code of element [1] (sub-part of [2]) * $condition[n][6] => method used to evaluate * $condition[n][7] => scenario *NEW BY R.L.J. van den Burg* */ /** * setNoAnswerMode */ function setNoAnswerMode($thissurvey) { if (getGlobalSetting('shownoanswer') > 0 && $thissurvey['shownoanswer'] != 'N') { define('SHOW_NO_ANSWER', 1); } else { define('SHOW_NO_ANSWER', 0); } } /** * 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, survey.php or preview.php * * @param mixed $ia * @return mixed */ function retrieveAnswers($ia) { //globalise required config variables global $thissurvey; //These are set by index.php //$clang = Yii::app()->lang; $clang = Yii::app()->lang; //DISPLAY $display = $ia[7]; //QUESTION NAME $name = $ia[0]; $qtitle=$ia[3]; $inputnames=array(); // TMSW - eliminate this - get from LEM //A bit of housekeeping to stop PHP Notices $answer = ""; if (!isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]])) {$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] = "";} $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); //Create the question/answer html // Previously in limesurvey, it was virtually impossible to control how the start of questions were formatted. // this is an attempt to allow users (or rather system admins) some control over how the starting text is formatted. $number = isset($ia[9]) ? $ia[9] : ''; // TMSW - populate this directly from LEM? - this this is global $question_text = array( 'all' => '' // All has been added for backwards compatibility with templates that use question_start.pstpl (now redundant) ,'text' => $qtitle ,'code' => $ia[2] ,'number' => $number ,'help' => '' ,'mandatory' => '' ,'man_message' => '' ,'valid_message' => '' ,'file_valid_message' => '' ,'class' => '' ,'man_class' => '' ,'input_error_class' => ''// provides a class. ,'essentials' => '' ); 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 'L': //LIST drop-down/radio-button list $values = do_list_radio($ia); if ($aQuestionAttributes['hide_tip']==0) { $qtitle .= "
\n" . $clang->gT('Choose one of the following answers').''; $question_text['help'] = $clang->gT('Choose one of the following answers'); } break; case '!': //List - dropdown $values=do_list_dropdown($ia); if ($aQuestionAttributes['hide_tip']==0) { $qtitle .= "
\n" . $clang->gT('Choose one of the following answers').''; $question_text['help'] = $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 && $aQuestionAttributes['hide_tip']==0) { $qtitle .= "
\n" . $clang->gT('Choose one of the following answers').''; $question_text['help'] = $clang->gT('Choose one of the following answers'); } break; case 'R': //RANKING STYLE $values=do_ranking($ia); if (count($values[1]) > 1 && $aQuestionAttributes['hide_tip']==0) { $question_text['help'] = $clang->gT("Click on an item in the list on the left, starting with your highest ranking item, moving through to your lowest ranking item."); if (trim($aQuestionAttributes['min_answers'])!='') { $qtitle .= "
\n" . sprintf($clang->ngT("Check at least %d item.","Check at least %d items.",$aQuestionAttributes['min_answers']),$aQuestionAttributes['min_answers']).""; $question_text['help'] .=' '.sprintf($clang->ngT("Check at least %d item.","Check at least %d items.",$aQuestionAttributes['min_answers']),$aQuestionAttributes['min_answers']); } } break; case 'M': //Multiple choice checkbox $values=do_multiplechoice($ia); if (count($values[1]) > 1 && $aQuestionAttributes['hide_tip']==0) { $maxansw=trim($aQuestionAttributes['max_answers']); $minansw=trim($aQuestionAttributes['min_answers']); if (!($maxansw || $minansw)) { $qtitle .= "
\n" . $clang->gT('Check any that apply').''; $question_text['help'] = $clang->gT('Check any that apply'); } // else // { // if ($maxansw && $minansw) // { // $qtitle .= "
\n" // . sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw).""; // $question_text['help'] = sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw); // } elseif ($maxansw) // { // $qtitle .= "
\n" // . sprintf($clang->gT("Check at most %d answers"), $maxansw).""; // $question_text['help'] = sprintf($clang->gT("Check at most %d answers"), $maxansw); // } else // { // $qtitle .= "
\n" // . sprintf($clang->ngT("Check at least %d answer","Check at least %d answers",$minansw),$minansw).""; // $question_text['help'] = sprintf($clang->ngT("Check at least %d answer","Check at least %d answers",$minansw),$minansw); // } // } } break; case 'I': //Language Question $values=do_language($ia); if (count($values[1]) > 1) { $qtitle .= "
\n" . $clang->gT('Choose your language').''; $question_text['help'] = $clang->gT('Choose your language'); } break; case 'P': //Multiple choice with comments checkbox + text $values=do_multiplechoice_withcomments($ia); if (count($values[1]) > 1 && $aQuestionAttributes['hide_tip']==0) { $maxansw=trim($aQuestionAttributes["max_answers"]); $minansw=trim($aQuestionAttributes["min_answers"]); if (!($maxansw || $minansw)) { $qtitle .= "
\n" . $clang->gT('Check any that apply').''; $question_text['help'] = $clang->gT('Check any that apply'); } // else // { // if ($maxansw && $minansw) // { // $qtitle .= "
\n" // . sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw).""; // $question_text['help'] = sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw); // } elseif ($maxansw) // { // $qtitle .= "
\n" // . sprintf($clang->gT("Check at most %d answers"), $maxansw).""; // $question_text['help'] = sprintf($clang->gT("Check at most %d answers"), $maxansw); // } else // { // $qtitle .= "
\n" // . sprintf($clang->gT("Check at least %d answers"), $minansw).""; // $question_text['help'] = sprintf($clang->gT("Check at least %d answers"), $minansw); // } // } } break; case '|': //File Upload $values=do_file_upload($ia); 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($ia); break; case 'H': //ARRAY (Flexible) - Column Format $values=do_arraycolumns($ia); break; case ':': //ARRAY (Multi Flexi) 1 to 10 $values=do_array_multiflexi($ia); break; case ';': //ARRAY (Multi Flexi) Text $values=do_array_multitext($ia); //It's like the "5th element" movie, come to life break; case '1': //Array (Flexible Labels) dual scale $values=do_array_dual($ia); break; case '*': // Equation $values=do_equation($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; } if ($ia[6] == 'Y') { $qtitle = ''.$clang->gT('*').''.$qtitle; $question_text['mandatory'] = $clang->gT('*'); } //If this question is mandatory but wasn't answered in the last page //add a message HIGHLIGHTING the question if (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] != $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['maxstep']) || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] == $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['prevstep'])) { $mandatory_msg = mandatory_message($ia); } else { $mandatory_msg = ''; } $qtitle .= $mandatory_msg; $question_text['man_message'] = $mandatory_msg; // if (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] != $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['maxstep']) || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] == $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['prevstep'])) { if (!isset($aQuestionAttributes['hide_tip']) || $aQuestionAttributes['hide_tip']==0) { $_vshow = true; // whether should initially be visible - TODO should also depend upon 'hidetip'? } else { $_vshow = false; } list($validation_msg,$isValid) = validation_message($ia,$_vshow); $qtitle .= $validation_msg; $question_text['valid_message'] = $validation_msg; if (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] != $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['maxstep']) || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] == $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['prevstep'])) { $file_validation_msg = file_validation_message($ia); } else { $file_validation_msg = ''; $isValid = true; // don't want to show any validation messages. } $qtitle .= $ia[4] == "|" ? $file_validation_msg : ""; $question_text['file_valid_message'] = $ia[4] == "|" ? $file_validation_msg : ""; if(!empty($question_text['man_message']) || !$isValid || !empty($question_text['file_valid_message'])) { $question_text['input_error_class'] = ' input-error';// provides a class to style question wrapper differently if there is some kind of user input error; } // ===================================================== // START: legacy question_start.pstpl code // The following section adds to the templating system by allowing // templaters to control where the various parts of the question text // are put. $sTemplate = isset($thissurvey['template']) ? $thissurvey['template'] : NULL; if(is_file('templates/'.validateTemplateDir($sTemplate).'/question_start.pstpl')) { $qtitle_custom = ''; $replace=array(); foreach($question_text as $key => $value) { $find[] = '{QUESTION_'.strtoupper($key).'}'; // Match key words from template $replace[] = $value; // substitue text }; if(!defined('QUESTION_START')) { define('QUESTION_START' , file_get_contents(getTemplatePath($thissurvey['template']).'/question_start.pstpl' , true)); }; $qtitle_custom = str_replace( $find , $replace , QUESTION_START); $c = 1; // START: work-around step 1 $qtitle_custom = preg_replace( '/(]+>)(<\/embed>)/i' , '\1NOT_EMPTY\2' , $qtitle_custom ); // END work-around step 1 while($c > 0) // This recursively strips any empty tags to minimise rendering bugs. { $matches = 0; $oldtitle=$qtitle_custom; $qtitle_custom = preg_replace( '/<([^ >]+)[^>]*>[\r\n\t ]*<\/\1>[\r\n\t ]*/isU' , '' , $qtitle_custom , -1); // I removed the $count param because it is PHP 5.1 only. $c = ($qtitle_custom!=$oldtitle)?1:0; }; // START work-around step 2 $qtitle_custom = preg_replace( '/(]+>)NOT_EMPTY(<\/embed>)/i' , '\1\2' , $qtitle_custom ); // END work-around step 2 while($c > 0) // This recursively strips any empty tags to minimise rendering bugs. { $matches = 0; $oldtitle=$qtitle_custom; $qtitle_custom = preg_replace( '/((?: |\r\n|\n\r|\r|\n| )*)+$/i' , '' , $qtitle_custom , -1 ); // I removed the $count param because it is PHP 5.1 only. $c = ($qtitle_custom!=$oldtitle)?1:0; }; $question_text['all'] = $qtitle_custom; } else { $question_text['all'] = $qtitle; }; // END: legacy question_start.pstpl code //=================================================================== $qtitle = $question_text; // ===================================================== $qanda=array($qtitle, $answer, 'help', $display, $name, $ia[2], $ia[5], $ia[1] ); //New Return return array($qanda, $inputnames); } function mandatory_message($ia) { $qinfo = LimeExpressionManager::GetQuestionStatus($ia[0]); if ($qinfo['mandViolation']) { return $qinfo['mandTip']; } else { return ""; } } /** * * @param $ia * @param $show - true if should initially be visible * @return */ function validation_message($ia,$show) { $qinfo = LimeExpressionManager::GetQuestionStatus($ia[0]); $class = "questionhelp"; if (!$show) { $class .= ' hide-tip'; } $tip = '' . $qinfo['validTip'] . ""; $isValid = $qinfo['valid']; return array($tip,$isValid); // if (!$qinfo['valid']) { // if (strlen($tip) == 0) { // $help = $clang->gT('This question must be answered correctly'); // } // else { // $tip =' '.$tip.''; // } // return '
'.$tip.'
'; // } // else { // return $tip; // } } // TMSW Validation -> EM function file_validation_message($ia) { global $filenotvalidated; $clang = Yii::app()->lang; $qtitle = ""; if (isset($filenotvalidated) && is_array($filenotvalidated) && $ia[4] == "|") { global $filevalidationpopup, $popup; foreach ($filenotvalidated as $k => $v) { if ($ia[1] == $k || strpos($k, "_") && $ia[1] == substr(0, strpos($k, "_") - 1)); $qtitle .= '
'.$clang->gT($filenotvalidated[$k]).'
'; } } return $qtitle; } // TMSW Validation -> EM function mandatory_popup($ia, $notanswered=null) { global $showpopups; $clang = Yii::app()->lang; //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) && isset($showpopups) && $showpopups == 1) //ADD WARNINGS TO QUESTIONS IF THEY WERE MANDATORY BUT NOT ANSWERED { global $mandatorypopup, $popup; //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; } } // TMSW Validation -> EM function validation_popup($ia, $notvalidated=null) { global $showpopups; $clang = Yii::app()->lang; //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) && isset($showpopups) && $showpopups == 1) //ADD WARNINGS TO QUESTIONS IF THEY ARE NOT VALID { global $validationpopup, $vpopup; //POPUP WARNING if (!isset($validationpopup)) { $vpopup="\n"; $validationpopup="Y"; } return array($validationpopup, $vpopup); } else { return false; } } // TMSW Validation -> EM function file_validation_popup($ia, $filenotvalidated = null) { global $showpopups; $clang = Yii::app()->lang; if ($filenotvalidated === null) { unset($filenotvalidated); } if (isset($filenotvalidated) && is_array($filenotvalidated) && isset($showpopups) && $showpopups == 1) { global $filevalidationpopup, $fpopup; if (!isset($filevalidationpopup)) { $fpopup="\n"; $filevalidationpopup = "Y"; } return array($filevalidationpopup, $fpopup); } else return false; } function return_timer_script($aQuestionAttributes, $ia, $disable=null) { global $thissurvey; $clang = Yii::app()->lang; header_includes(Yii::app()->getConfig("generalscripts").'coookies.js', 'js'); /* The following lines cover for previewing questions, because no $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['fieldarray'] exists. This just stops error messages occuring */ if(!isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['fieldarray'])) { $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['fieldarray'] = array(); } /* End */ if(isset($thissurvey['timercount'])) { $thissurvey['timercount']++; //Used to count how many timer questions in a page, and ensure scripts only load once } else { $thissurvey['timercount']=1; } if($thissurvey['format'] != "S") { if($thissurvey['format'] != "G") { return "\n\n\n\n"; //We don't do the timer in any format other than question-by-question } } $time_limit=$aQuestionAttributes['time_limit']; $disable_next=trim($aQuestionAttributes['time_limit_disable_next']) != '' ? $aQuestionAttributes['time_limit_disable_next'] : 0; $disable_prev=trim($aQuestionAttributes['time_limit_disable_prev']) != '' ? $aQuestionAttributes['time_limit_disable_prev'] : 0; $time_limit_action=trim($aQuestionAttributes['time_limit_action']) != '' ? $aQuestionAttributes['time_limit_action'] : 1; $time_limit_message_delay=trim($aQuestionAttributes['time_limit_message_delay']) != '' ? $aQuestionAttributes['time_limit_message_delay']*1000 : 1000; $time_limit_message=trim($aQuestionAttributes['time_limit_message'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]) != '' ? htmlspecialchars($aQuestionAttributes['time_limit_message'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']], ENT_QUOTES) : $clang->gT("Your time to answer this question has expired"); $time_limit_warning=trim($aQuestionAttributes['time_limit_warning']) != '' ? $aQuestionAttributes['time_limit_warning'] : 0; $time_limit_warning_2=trim($aQuestionAttributes['time_limit_warning_2']) != '' ? $aQuestionAttributes['time_limit_warning_2'] : 0; $time_limit_countdown_message=trim($aQuestionAttributes['time_limit_countdown_message'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]) != '' ? htmlspecialchars($aQuestionAttributes['time_limit_countdown_message'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']], ENT_QUOTES) : $clang->gT("Time remaining"); $time_limit_warning_message=trim($aQuestionAttributes['time_limit_warning_message'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]) != '' ? htmlspecialchars($aQuestionAttributes['time_limit_warning_message'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']], ENT_QUOTES) : $clang->gT("Your time to answer this question has nearly expired. You have {TIME} remaining."); $time_limit_warning_message=str_replace("{TIME}", "
", $time_limit_warning_message); $time_limit_warning_display_time=trim($aQuestionAttributes['time_limit_warning_display_time']) != '' ? $aQuestionAttributes['time_limit_warning_display_time']+1 : 0; $time_limit_warning_2_message=trim($aQuestionAttributes['time_limit_warning_2_message'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]) != '' ? htmlspecialchars($aQuestionAttributes['time_limit_warning_2_message'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']], ENT_QUOTES) : $clang->gT("Your time to answer this question has nearly expired. You have {TIME} remaining."); $time_limit_warning_2_message=str_replace("{TIME}", "
", $time_limit_warning_2_message); $time_limit_warning_2_display_time=trim($aQuestionAttributes['time_limit_warning_2_display_time']) != '' ? $aQuestionAttributes['time_limit_warning_2_display_time']+1 : 0; $time_limit_message_style=trim($aQuestionAttributes['time_limit_message_style']) != '' ? $aQuestionAttributes['time_limit_message_style'] : "position: absolute; top: 10px; left: 35%; width: 30%; height: 60px; padding: 16px; border: 8px solid #555; background-color: white; z-index:1002; text-align: center; overflow: auto;"; $time_limit_message_style.="\n display: none;"; //Important to hide time limit message at start $time_limit_warning_style=trim($aQuestionAttributes['time_limit_warning_style']) != '' ? $aQuestionAttributes['time_limit_warning_style'] : "position: absolute; top: 10px; left: 35%; width: 30%; height: 60px; padding: 16px; border: 8px solid #555; background-color: white; z-index:1001; text-align: center; overflow: auto;"; $time_limit_warning_style.="\n display: none;"; //Important to hide time limit warning at the start $time_limit_warning_2_style=trim($aQuestionAttributes['time_limit_warning_2_style']) != '' ? $aQuestionAttributes['time_limit_warning_2_style'] : "position: absolute; top: 10px; left: 35%; width: 30%; height: 60px; padding: 16px; border: 8px solid #555; background-color: white; z-index:1001; text-align: center; overflow: auto;"; $time_limit_warning_2_style.="\n display: none;"; //Important to hide time limit warning at the start $time_limit_timer_style=trim($aQuestionAttributes['time_limit_timer_style']) != '' ? $aQuestionAttributes['time_limit_timer_style'] : "position: relative; width: 150px; margin-left: auto; margin-right: auto; border: 1px solid #111; text-align: center; background-color: #EEE; margin-bottom: 5px; font-size: 8pt;"; $timersessionname="timer_question_".$ia[0]; if(isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$timersessionname])) { $time_limit=$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$timersessionname]; } $output = " \n"; if($thissurvey['timercount'] < 2) { $output .=" "; $output .= " "; } $output .= "
".$time_limit_message."
\n\n"; $output .= "
".$time_limit_warning_message."
\n\n"; $output .= "
".$time_limit_warning_2_message."
\n\n"; $output .= "
\n\n"; //Call the countdown script $output .= "\n\n"; return $output; } function return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $rowname, $trbc='', $valuename, $method="tbody", $class=null) { $htmltbody2 = "\n\n\t<$method id='javatbd$rowname'"; $htmltbody2 .= ($class !== null) ? " class='$class'": ""; if (isset($_SESSION['relevanceStatus'][$rowname]) && !$_SESSION['relevanceStatus'][$rowname]) { // If using exclude_all_others, then need to know whether irrelevant rows should be hidden or disabled if (isset($aQuestionAttributes['exclude_all_others'])) { $disableit=false; foreach(explode(';',trim($aQuestionAttributes['exclude_all_others'])) as $eo) { $eorow = $ia[1] . $eo; if ((!isset($_SESSION['relevanceStatus'][$eorow]) || $_SESSION['relevanceStatus'][$eorow]) && (isset($_SESSION[$eorow]) && $_SESSION[$eorow] == "Y")) { $disableit = true; } } if ($disableit) { $htmltbody2 .= " disabled='disabled'"; } else { if (!isset($aQuestionAttributes['array_filter_style']) || $aQuestionAttributes['array_filter_style'] == '0') { $htmltbody2 .= " style='display: none'"; } else { $htmltbody2 .= " disabled='disabled'"; } } } else { if (!isset($aQuestionAttributes['array_filter_style']) || $aQuestionAttributes['array_filter_style'] == '0') { $htmltbody2 .= " style='display: none'"; } else { $htmltbody2 .= " disabled='disabled'"; } } } $htmltbody2 .= ">\n"; return array($htmltbody2, ""); } // ================================================================== // setting constants for 'checked' and 'selected' inputs define('CHECKED' , ' checked="checked"' , true); define('SELECTED' , ' selected="selected"' , true); // ================================================================== // QUESTION METHODS ================================================= function do_boilerplate($ia) { $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); $answer=''; if (trim($aQuestionAttributes['time_limit'])!='') { $answer .= return_timer_script($aQuestionAttributes, $ia); } $answer .= ''; $inputnames[]=$ia[1]; return array($answer, $inputnames); } function do_equation($ia) { $answer=''; $inputnames[]=$ia[1]; $mandatory=null; return array($answer, $inputnames, $mandatory); } // --------------------------------------------------------------- function do_5pointchoice($ia) { $clang=Yii::app()->lang; $imageurl = Yii::app()->getConfig("imageurl"); $checkconditionFunction = "checkconditions"; $aQuestionAttributes= getQuestionAttributeValues($ia[0], $ia[4]); $id = 'slider'.time().rand(0,100); $answer = "\n
    \n"; for ($fp=1; $fp<=5; $fp++) { $answer .= "\t
  • \ngetConfig('surveyID')][$ia[1]] == $fp) { $answer .= CHECKED; } $answer .= " onclick=\"$checkconditionFunction(this.value, this.name, this.type)\" />\n\n\t
  • \n"; } if ($ia[6] != "Y" && SHOW_NO_ANSWER == 1) // Add "No Answer" option if question is not mandatory { $answer .= "\t
  • \ngetConfig('surveyID')][$ia[1]])) { $answer .= CHECKED; } $answer .= " onclick=\"$checkconditionFunction(this.value, this.name, this.type)\" />\n\n\t
  • \n"; } $answer .= "
\ngetConfig('surveyID')][$ia[1]]."\" />\n"; $inputnames[]=$ia[1]; if($aQuestionAttributes['slider_rating']==1){ header_includes('/admin/scripts/rating/jquery.rating.css','css'); header_includes('/admin/scripts/rating/jquery.rating.js','js'); $answer.=" "; $answer.=" "; } if($aQuestionAttributes['slider_rating']==2){ if(!isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) OR $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]==''){ $value=1; }else{ $value=$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]; } $answer.=" "; $answer.=" "; } return array($answer, $inputnames); } // --------------------------------------------------------------- function do_date($ia) { global $thissurvey; $clang=Yii::app()->lang; $aQuestionAttributes=getQuestionAttributeValues($ia[0],$ia[4]); $checkconditionFunction = "checkconditions"; $dateformatdetails = getDateFormatData($thissurvey['surveyls_dateformat']); $numberformatdatat = getRadixPointData($thissurvey['surveyls_numberformat']); if (trim($aQuestionAttributes['dropdown_dates'])!=0) { if (!empty($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]])) { $datetimeobj = getdate(DateTime::createFromFormat("Y-m-d H:i:s", $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]])->getTimeStamp()); $currentyear = $datetimeobj['year']; $currentmonth = $datetimeobj['mon']; $currentdate = $datetimeobj['mday']; $currenthour = $datetimeobj['hours']; $currentminute = $datetimeobj['minutes']; } else { $currentdate=''; $currentmonth=''; $currentyear=''; } $dateorder = preg_split('/[-\.\/ ]/', $dateformatdetails['phpdate']); $answer=''; $answer .= ' '; } else { header_includes(Yii::app()->getConfig("generalscripts").'jquery/lime-calendar.js'); if ($clang->langcode !== 'en') { header_includes(Yii::app()->getConfig("generalscripts").'jquery/locale/jquery.ui.datepicker-'.$clang->langcode.'.js'); } // Format the date for output if (trim($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]])!='') { $datetimeobj = new Date_Time_Converter($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] , "Y-m-d"); $dateoutput = $datetimeobj->convert($dateformatdetails['phpdate']); } else { $dateoutput=''; } if (trim($aQuestionAttributes['dropdown_dates_year_min'])!='') { $minyear=$aQuestionAttributes['dropdown_dates_year_min']; } else { $minyear='1980'; } if (trim($aQuestionAttributes['dropdown_dates_year_max'])!='') { $maxyear=$aQuestionAttributes['dropdown_dates_year_max']; } else { $maxyear='2020'; } $goodchars = str_replace( array("m","d","y"), "", $dateformatdetails['jsdate']); $goodchars = "0123456789".$goodchars[0]; $answer ="

"; if (trim($aQuestionAttributes['hide_tip'])==1) { $answer.="

".sprintf($clang->gT('Format: %s'),$dateformatdetails['dateformat'])."

"; } } $inputnames[]=$ia[1]; return array($answer, $inputnames); } // --------------------------------------------------------------- function do_language($ia) { $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $answerlangs = Survey::model()->findByPk(Yii::app()->getConfig('surveyID'))->additionalLanguages; $answerlangs [] = Survey::model()->findByPk(Yii::app()->getConfig('surveyID'))->language; $answer = "\n\t

\n" ."" ."\n"; $answer .= "getConfig('surveyID')][$ia[1]]."\" />\n"; $inputnames[]=$ia[1]; $answer .= "\n\n\t

\n"; return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_list_dropdown($ia) { global $dropdownthreshold; $clang=Yii::app()->lang; $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (trim($aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $othertext=$aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; } else { $othertext=$clang->gT('Other:'); } if (trim($aQuestionAttributes['category_separator'])!='') { $optCategorySeparator = $aQuestionAttributes['category_separator']; } $answer=''; //Time Limit Code if (trim($aQuestionAttributes['time_limit'])!='') { $answer .= return_timer_script($aQuestionAttributes, $ia); } //End Time Limit Code $query = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' "; $result = Yii::app()->db->createCommand($query)->query(); //Checked $row = $result->read(); $other = $row['other']; //question attribute random order set? if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY ".dbRandom(); } //question attribute alphasort set? elseif ($aQuestionAttributes['alphasort']==1) { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY answer"; } //no question attributes -> order by sortorder else { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY sortorder, answer"; } $ansresult = Yii::app()->db->createCommand($ansquery)->query() or safeDie('Couldn\'t get answers
'.$ansquery.'
'); //Checked $dropdownSize = ''; if (isset($aQuestionAttributes['dropdown_size']) && $aQuestionAttributes['dropdown_size'] > 0) { $_height = sanitize_int($aQuestionAttributes['dropdown_size']) ; $_maxHeight = $ansresult->RowCount(); if ((!empty($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]])) && $ia[6] != 'Y' && $ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { ++$_maxHeight; // for No Answer } if (isset($other) && $other=='Y') { ++$_maxHeight; // for Other } if (!$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) { ++$_maxHeight; // for 'Please choose:' } if ($_height > $_maxHeight) { $_height = $_maxHeight; } $dropdownSize = ' size="'.$_height.'"'; } $prefixStyle = 0; if (isset($aQuestionAttributes['dropdown_prefix'])) { $prefixStyle = sanitize_int($aQuestionAttributes['dropdown_prefix']) ; } $_rowNum=0; $_prefix=''; if (!isset($optCategorySeparator)) { foreach ($ansresult->readAll() as $ansrow) { $opt_select = ''; if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == $ansrow['code']) { $opt_select = SELECTED; } if ($prefixStyle == 1) { $_prefix = ++$_rowNum . ') '; } $answer .= "\n"; } } else { $defaultopts = Array(); $optgroups = Array(); foreach ($ansresult->readAll() as $ansrow) { // Let's sort answers in an array indexed by subcategories @list ($categorytext, $answertext) = explode($optCategorySeparator,$ansrow['answer']); // The blank category is left at the end outside optgroups if ($categorytext == '') { $defaultopts[] = array ( 'code' => $ansrow['code'], 'answer' => $answertext); } else { $optgroups[$categorytext][] = array ( 'code' => $ansrow['code'], 'answer' => $answertext); } } foreach ($optgroups as $categoryname => $optionlistarray) { $answer .= ' '; foreach ($optionlistarray as $optionarray) { if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == $optionarray['code']) { $opt_select = SELECTED; } else { $opt_select = ''; } $answer .= ' '; } $answer .= ' '; } $opt_select=''; foreach ($defaultopts as $optionarray) { if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == $optionarray['code']) { $opt_select = SELECTED; } else { $opt_select = ''; } $answer .= ' '; } } if (!$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]) { $answer = ' '."\n".$answer; } if (isset($other) && $other=='Y') { if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == '-oth-') { $opt_select = SELECTED; } else { $opt_select = ''; } if ($prefixStyle == 1) { $_prefix = ++$_rowNum . ') '; } $answer .= ' \n"; } if (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] != '') && $ia[6] != 'Y' && $ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { if ($prefixStyle == 1) { $_prefix = ++$_rowNum . ') '; } $answer .= '\n"; } $answer .= ' '; if (isset($other) && $other=='Y') { $sselect_show_hide = ' showhideother(this.name, this.value);'; } else { $sselect_show_hide = ''; } $sselect = ' "; // --> END NEW FEATURE - SAVE $inputnames[]=$ia[1]."other"; } else { $answer .= "

"; } // $checkotherscript = ""; // if (isset($other) && $other == 'Y' && $aQuestionAttributes['other_comment_mandatory']==1) // { // $checkotherscript = "\n\n"; // } // $answer = $checkotherscript . $answer; $inputnames[]=$ia[1]; return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_list_radio($ia) { global $dropdownthreshold; global $thissurvey; $clang=Yii::app()->lang; if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "text-keypad"; } else { $kpclass = ""; } $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); $query = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' "; $result = Yii::app()->db->createCommand($query)->query(); foreach ($result->readAll() as $row) { $other = $row['other']; } //question attribute random order set? if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY ".dbRandom(); } //question attribute alphasort set? elseif ($aQuestionAttributes['alphasort']==1) { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY answer"; } //no question attributes -> order by sortorder else { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY sortorder, answer"; } $ansresult = dbExecuteAssoc($ansquery)->readAll(); //Checked $anscount = count($ansresult); if (trim($aQuestionAttributes['display_columns'])!='') { $dcols = $aQuestionAttributes['display_columns']; } else { $dcols= 1; } if (trim($aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $othertext=$aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; } else { $othertext=$clang->gT('Other:'); } if (isset($other) && $other=='Y') {$anscount++;} //Count up for the Other answer if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) {$anscount++;} //Count up if "No answer" is showing $wrapper = setupColumns($dcols , $anscount,"answers-list radio-list","answer-item radio-item"); $answer = $wrapper['whole-start']; //Time Limit Code if (trim($aQuestionAttributes['time_limit'])!='') { $answer .= return_timer_script($aQuestionAttributes, $ia); } //End Time Limit Code // Get array_filter stuff $rowcounter = 0; $colcounter = 1; $trbc=''; foreach ($ansresult as $ansrow) { $myfname = $ia[1].$ansrow['code']; $check_ans = ''; if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == $ansrow['code']) { $check_ans = CHECKED; } list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname, "li","answer-item radio-item"); if(substr($wrapper['item-start'],0,4) == "\t '.$wrapper['item-end']; ++$rowcounter; if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols']) { if($colcounter == $wrapper['cols'] - 1) { $answer .= $wrapper['col-devide-last']; } else { $answer .= $wrapper['col-devide']; } $rowcounter = 0; ++$colcounter; } } if (isset($other) && $other=='Y') { $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; if ($aQuestionAttributes['other_numbers_only']==1) { $numbersonly = 'onkeypress="return goodchars(event,\'-0123456789'.$sSeperator.'\')"'; $oth_checkconditionFunction = 'fixnum_checkconditions'; } else { $numbersonly = ''; $oth_checkconditionFunction = 'checkconditions'; } if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == '-oth-') { $check_ans = CHECKED; } else { $check_ans = ''; } $thisfieldname=$ia[1].'other'; if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$thisfieldname])) { $dispVal = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$thisfieldname]; if ($aQuestionAttributes['other_numbers_only']==1) { $dispVal = str_replace('.',$sSeperator,$dispVal); } $answer_other = ' value="'.htmlspecialchars($dispVal,ENT_QUOTES).'"'; } else { $answer_other = ' value=""'; } list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, array("code"=>"other"), $thisfieldname, $trbc, $myfname, "li", "answer-item radio-item other-item other"); if(substr($wrapper['item-start-other'],0,4) == "\t '.$wrapper['item-end']; $inputnames[]=$thisfieldname; ++$rowcounter; if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols']) { if($colcounter == $wrapper['cols'] - 1) { $answer .= $wrapper['col-devide-last']; } else { $answer .= $wrapper['col-devide']; } $rowcounter = 0; ++$colcounter; } } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { if ((!$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == '') || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == ' ' )) { $check_ans = CHECKED; //Check the "no answer" radio button if there is no answer in session. } else { $check_ans = ''; } $answer .= $wrapper['item-start-noanswer'].' '.$wrapper['item-end']; // --> END NEW FEATURE - SAVE ++$rowcounter; if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols']) { if($colcounter == $wrapper['cols'] - 1) { $answer .= $wrapper['col-devide-last']; } else { $answer .= $wrapper['col-devide']; } $rowcounter = 0; ++$colcounter; } } //END OF ITEMS $answer .= $wrapper['whole-end'].' getConfig('surveyID')][$ia[1]]."\" />\n"; // $checkotherscript = ""; // // if (isset($other) && $other == 'Y' && $aQuestionAttributes['other_comment_mandatory']==1) // { // $checkotherscript = "\n"; // } // // $answer = $checkotherscript . $answer; $inputnames[]=$ia[1]; return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_listwithcomment($ia) { global $maxoptionsize, $thissurvey; $clang=Yii::app()->lang; $dropdownthreshold = Yii::app()->getConfig("dropdownthreshold"); if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "text-keypad"; } else { $kpclass = ""; } $checkconditionFunction = "checkconditions"; $answer = ''; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (!isset($maxoptionsize)) {$maxoptionsize=35;} //question attribute random order set? if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY ".dbRandom(); } //question attribute alphasort set? elseif ($aQuestionAttributes['alphasort']==1) { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY answer"; } //no question attributes -> order by sortorder else { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY sortorder, answer"; } $ansresult=Yii::app()->db->createCommand($ansquery)->query(); $anscount = $ansresult->getRowCount(); $hint_comment = $clang->gT('Please enter your comment here'); if ($aQuestionAttributes['use_dropdown']!=1 && $anscount <= $dropdownthreshold) { $answer .= '
    '; foreach ($ansresult->readAll() as $ansrow) { $check_ans = ''; if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == $ansrow['code']) { $check_ans = CHECKED; } $answer .= '
  • '; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { if ((!$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == '') ||($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == ' ' )) { $check_ans = CHECKED; } elseif (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] != '')) { $check_ans = ''; } $answer .= '
  • '; } $fname2 = $ia[1].'comment'; if ($anscount > 8) {$tarows = $anscount/1.2;} else {$tarows = 4;} // --> START NEW FEATURE - SAVE // --> START ORIGINAL // $answer .= "\t\n" // . "

    '; $inputnames[]=$ia[1]; $inputnames[]=$ia[1].'comment'; } else //Dropdown list { // --> START NEW FEATURE - SAVE $answer .= ' '; $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 .= '

    '; $inputnames[]=$ia[1]; $inputnames[]=$ia[1].'comment'; } return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_ranking($ia) { // note to self: this function needs to define: // inputnames, answer, among others global $thissurvey, $showpopups; global $js_header_includes,$css_header_includes; $clang=Yii::app()->lang; $imageurl = Yii::app()->getConfig("imageurl"); $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{answers}} WHERE qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY sortorder, answer"; } $ansresult = Yii::app()->db->createCommand($ansquery)->query(); //Checked $anscount= $ansresult->getRowCount(); if (trim($aQuestionAttributes["max_answers"])!='') { $max_answers=sanitize_int($aQuestionAttributes["max_answers"]); } else { $max_answers=$anscount; } $anscount= $ansresult->getRowCount(); if (trim($aQuestionAttributes["min_answers"])!='') { $min_answers=sanitize_int($aQuestionAttributes["max_answers"]); } else { $min_answers=0; } $answer = ''; // First start by a ranking without javascript : just a list of select box // construction select box $answers= array(); foreach ($ansresult->readAll() as $ansrow) { $answers[] = $ansrow; } $answer .= '
      '; for ($i=1; $i<=$anscount; $i++) { $myfname=$ia[1].$i; $answer .= "\n
    • "; // TODO put some div for $ansrow['answer'] with HTML $answer .="
    • "; $inputnames[]=$myfname; } $answer .="
    "; header_includes(Yii::app()->getConfig('generalscripts')."jquery/jquery.ui.touch-punch.min.js"); // For touch screen header_includes(Yii::app()->getConfig('generalscripts')."ranking.js"); header_includes("ranking.css","css"); #$answer .= ""; $answer .= "\n"; return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_multiplechoice($ia) { global $thissurvey; $clang = Yii::app()->lang; if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "text-keypad"; } else { $kpclass = ""; } // Find out if any questions have attributes which reference this questions // based on value of attribute. This could be array_filter and array_filter_exclude $attribute_ref=false; $inputnames=array(); $qaquery = "SELECT qid,attribute FROM {{question_attributes}} WHERE value LIKE '".strtolower($ia[2])."' and (attribute='array_filter' or attribute='array_filter_exclude')"; $qaresult = Yii::app()->db->createCommand($qaquery)->query(); //Checked foreach ($qaresult->readAll() as $qarow) { $qquery = "SELECT qid FROM {{questions}} WHERE sid=".$thissurvey['sid']." AND scale_id=0 AND qid=".$qarow['qid']; $qresult = Yii::app()->db->createCommand($qquery)->query(); //Checked if ($qresult->getRowCount() > 0) { $attribute_ref = true; } } $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (trim($aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $othertext=$aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; } else { $othertext=$clang->gT('Other:'); } if (trim($aQuestionAttributes['display_columns'])!='') { $dcols = $aQuestionAttributes['display_columns']; } else { $dcols = 1; } if ($aQuestionAttributes['other_numbers_only']==1) { $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator= $sSeperator['seperator']; $numbersonly = " onkeypress='return goodchars(event,\"-0123456789$sSeperator\")'"; $oth_checkconditionFunction = "fixnum_checkconditions"; } else { $numbersonly = ''; $oth_checkconditionFunction = "checkconditions"; } $qquery = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and parent_qid=0"; $qresult = dbExecuteAssoc($qquery); //Checked $qrow = $qresult->read(); $other = $qrow['other']; if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND scale_id=0 AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND scale_id=0 AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery)->readAll(); //Checked $anscount = count($ansresult); if (trim($aQuestionAttributes['exclude_all_others'])!='' && $aQuestionAttributes['random_order']==1) { //if exclude_all_others is set then the related answer should keep its position at all times //thats why we have to re-position it if it has been randomized $position=0; foreach ($ansresult as $answer) { if ((trim($aQuestionAttributes['exclude_all_others']) != '') && ($answer['title']==trim($aQuestionAttributes['exclude_all_others']))) { if ($position==$answer['question_order']-1) break; //already in the right position $tmp = array_splice($ansresult, $position, 1); array_splice($ansresult, $answer['question_order']-1, 0, $tmp); break; } $position++; } } if ($other == 'Y') { $anscount++; //COUNT OTHER AS AN ANSWER FOR MANDATORY CHECKING! } $wrapper = setupColumns($dcols, $anscount,"subquestions-list questions-list checkbox-list","question-item answer-item checkbox-item"); $answer = '\n\n".$wrapper['whole-start']; $fn = 1; if (!isset($multifields)) { $multifields = ''; } $rowcounter = 0; $colcounter = 1; $startitem=''; $postrow = ''; $trbc=''; foreach ($ansresult as $ansrow) { $myfname = $ia[1].$ansrow['title']; $extra_class=""; $trbc=''; /* Check for array_filter */ list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname, "li","question-item answer-item checkbox-item".$extra_class); if(substr($wrapper['item-start'],0,4) == "\tgetConfig('surveyID')][$myfname])) { if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == 'Y') { $answer .= CHECKED; } } $answer .= " onclick='cancelBubbleThis(event);"; $answer .= '' . "$checkconditionFunction(this.value, this.name, this.type)' />\n" . "\n"; // if ($maxansw > 0) {$maxanswscript .= "\tif (document.getElementById('answer".$myfname."').checked) { count += 1; }\n";} // if ($minansw > 0) {$minanswscript .= "\tif (document.getElementById('answer".$myfname."').checked) { count += 1; }\n";} ++$fn; /* Now add the hidden field to contain information about this answer */ $answer .= ' \n{$wrapper['item-end']}"; $inputnames[]=$myfname; ++$rowcounter; if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols']) { if($colcounter == $wrapper['cols'] - 1) { $answer .= $wrapper['col-devide-last']; } else { $answer .= $wrapper['col-devide']; } $rowcounter = 0; ++$colcounter; } } if ($other == 'Y') { $myfname = $ia[1].'other'; list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, array("code"=>"other"), $myfname, $trbc, $myfname, "li","question-item answer-item checkbox-item other-item"); if(substr($wrapper['item-start-other'],0,4) == "\tgetConfig('surveyID')][$myfname]) && trim($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname])!='') { $answer .= CHECKED; } $answer .= " onclick='cancelBubbleThis(event);if(this.checked===false){ document.getElementById(\"answer$myfname\").value=\"\"; document.getElementById(\"java$myfname\").value=\"\"; $checkconditionFunction(\"\", \"$myfname\", \"text\"); }"; $answer .= " if(this.checked===true) { document.getElementById(\"answer$myfname\").focus(); }; LEMflagMandOther(\"$myfname\",this.checked);"; $answer .= "' /> getConfig('surveyID')][$myfname])) { $dispVal = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; if ($aQuestionAttributes['other_numbers_only']==1) { $dispVal = str_replace('.',$sSeperator,$dispVal); } $answer .= htmlspecialchars($dispVal,ENT_QUOTES); } $answer .= "\" onchange='$(\"#java{$myfname}\").val(this.value);$oth_checkconditionFunction(this.value, this.name, this.type); LEMflagMandOther(\"$myfname\",\$(\"#answer{$myfname}cbox\").attr(\"checked\"));' onkeyup='if ($.trim(this.value)!=\"\") { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"checked\"); } else { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"\"); }' $numbersonly />"; $answer .= ' 0) // { // // // // For multiplechoice question there is no DB field for the other Checkbox // // We only count the -other- as valid if both the cbox and the other text is filled // $minanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '' && document.getElementById('answer".$myfname."cbox').checked ) { count += 1; }\n"; // } if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname])) { $dispVal = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; if ($aQuestionAttributes['other_numbers_only']==1) { $dispVal = str_replace('.',$sSeperator,$dispVal); } $answer .= htmlspecialchars($dispVal,ENT_QUOTES); } $answer .= "\" />\n{$wrapper['item-end']}"; $inputnames[]=$myfname; ++$anscount; ++$rowcounter; if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols']) { if($colcounter == $wrapper['cols'] - 1) { $answer .= $wrapper['col-devide-last']; } else { $answer .= $wrapper['col-devide']; } $rowcounter = 0; ++$colcounter; } } $answer .= $wrapper['whole-end']; // if ( $maxansw > 0 ) // { // $maxanswscript .= " // if (count > max) // { // alert('".sprintf($clang->gT("Please choose at most %d answers for question \"%s\"","js"), $maxansw, trim(javascriptEscape(str_replace(array("\n", "\r"), "", $ia[3]),true,true)))."'); // if (me.type == 'checkbox') { me.checked = false; } // if (me.type == 'text') { // me.value = ''; // if (document.getElementById('answer'+me.name + 'cbox') ){ // document.getElementById('answer'+me.name + 'cbox').checked = false; // } // } // return max; // } // } // //--> // \n"; // $answer = $maxanswscript . $answer; // } // // // if ( $minansw > 0 ) // { // $minanswscript .= // "\tif (count < {$minansw} && document.getElementById('display{$ia[0]}').value == 'on'){\n" // . "alert('".sprintf($clang->gT("Please choose at least %d answer(s) for question \"%s\"","js"), // $minansw, trim(javascriptEscape(str_replace(array("\n", "\r"), "",$ia[3]),true,true)))."');\n" // . "return false;\n" // . "\t} else {\n" // . "if (oldonsubmit_{$ia[0]}){\n" // . "\treturn oldonsubmit_{$ia[0]}();\n" // . "}\n" // . "return true;\n" // . "\t}\n" // . "}\n" // . "document.limesurvey.onsubmit = ensureminansw_{$ia[0]}\n" // . "-->\n" // . "\t\n"; // //$answer = $minanswscript . $answer; // } $checkotherscript = ""; if ($other == 'Y') { // Multiple choice with 'other' is a specific case as the checkbox isn't recorded into DB // this means that if it is cehcked We must force the end-user to enter text in the input // box $checkotherscript = "\n"; } $answer = $checkotherscript . $answer; $answer .= $postrow; return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_multiplechoice_withcomments($ia) { global $thissurvey; $clang = Yii::app()->lang; $inputnames= array(); if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "text-keypad"; } else { $kpclass = ""; } $inputnames = array(); $attribute_ref=false; $qaquery = "SELECT qid,attribute FROM {{question_attributes}} WHERE value LIKE '".strtolower($ia[2])."'"; $qaresult = Yii::app()->db->createCommand($qaquery)->query(); //Checked $attribute_ref=false; foreach($qaresult->readAll() as $qarow) { $qquery = "SELECT qid FROM {{questions}} WHERE sid=".$thissurvey['sid']." AND qid=".$qarow['qid']; $qresult = Yii::app()->db->createCommand($qquery)->query(); //Checked if (count($qresult)> 0) { $attribute_ref = true; } } $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if ($aQuestionAttributes['other_numbers_only']==1) { $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; $numbersonly = 'onkeypress="return goodchars(event,\'-0123456789'.$sSeperator.'\')"'; $oth_checkconditionFunction = "fixnum_checkconditions"; } else { $numbersonly = ''; $oth_checkconditionFunction = "checkconditions"; } if (trim($aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $othertext=$aQuestionAttributes['other_replace_text'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; } else { $othertext=$clang->gT('Other:'); } // // Check if the max_answers attribute is set // $maxansw=0; // $callmaxanswscriptcheckbox = ''; // $callmaxanswscriptcheckbox2 = ''; $callmaxanswscriptother = ''; // $maxanswscript = ''; // if (trim($aQuestionAttributes['max_answers'])!='') { // $maxansw=$aQuestionAttributes['max_answers']; // $callmaxanswscriptcheckbox = "limitmaxansw_{$ia[0]}(this);"; // $callmaxanswscriptcheckbox2= "limitmaxansw_{$ia[0]}"; // $callmaxanswscriptother = "onkeyup=\"limitmaxansw_{$ia[0]}(this)\""; // // $maxanswscript = "\t\n"; // $answer = $maxanswscript . $answer; // } // // if ( $minansw > 0 ) // { // $minanswscript .= // "\tif (count < {$minansw} && document.getElementById('display{$ia[0]}').value == 'on'){\n" // . "alert('".sprintf($clang->gT("Please choose at least %d answer(s) for question \"%s\"","js"), // $minansw, trim(javascriptEscape(str_replace(array("\n", "\r"), "",$ia[3]),true,true)))."');\n" // . "return false;\n" // . "\t} else {\n" // . "if (oldonsubmit_{$ia[0]}){\n" // . "\treturn oldonsubmit_{$ia[0]}();\n" // . "}\n" // . "return true;\n" // . "\t}\n" // . "}\n" // . "document.limesurvey.onsubmit = ensureminansw_{$ia[0]}\n" // . "-->\n" // . "\t\n"; // //$answer = $minanswscript . $answer; // } // $checkotherscript = ""; // //if ($other == 'Y' && $aQuestionAttributes['other_comment_mandatory']==1) //TIBO // if ($other == 'Y' && $aQuestionAttributes['other_comment_mandatory']==1) //TIBO // { // // Multiple choice with 'other' is a specific case as the checkbox isn't recorded into DB // // this means that if it is cehcked We must force the end-user to enter text in the input // // box // $checkotherscript = "\n"; // } // // $answer = $checkotherscript . $answer; return array($answer, $inputnames); } // --------------------------------------------------------------- function do_file_upload($ia) { global $thissurvey; $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $aQuestionAttributes=getQuestionAttributeValues($ia[0]); // Fetch question attributes $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['fieldname'] = $ia[1]; $currentdir = getcwd(); $pos = stripos($currentdir, "admin"); $scriptloc = Yii::app()->getController()->createUrl('uploader/index'); if ($pos) { $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['preview'] = 1 ; $questgrppreview = 1; // Preview is launched from Question or group level } else if ($thissurvey['active'] != "Y") { $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['preview'] = 1; $questgrppreview = 0; } else { $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['preview'] = 0; $questgrppreview = 0; } $uploadbutton = "

    gT('Upload files'). "

    "; $answer = "\n"; header_includes(Yii::app()->getConfig('generalscripts')."modaldialog.js"); // Modal dialog $answer .= $uploadbutton; $answer .= "getConfig('surveyID')][$ia[1]]."' />"; $answer .= "getConfig('surveyID')])) { $tempval = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]."_filecount"]; if (is_numeric($tempval)) { $answer .= $tempval . " />"; } else { $answer .= "0 />"; } } else { $answer .= "0 />"; } $answer .= "
    "; $answer .= ''; $answer .= ''; $inputnames[] = $ia[1]; $inputnames[] = $ia[1]."_filecount"; return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_multipleshorttext($ia) { global $thissurvey; $clang = Yii::app()->lang; $extraclass =""; $answer=''; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if ($aQuestionAttributes['numbers_only']==1) { $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; $numbersonly = 'onkeypress="return goodchars(event,\'-0123456789'.$sSeperator.'\')"'; $extraclass .=" numberonly"; $checkconditionFunction = "fixnum_checkconditions"; } else { $numbersonly = ''; $checkconditionFunction = "checkconditions"; } if (intval(trim($aQuestionAttributes['maximum_chars']))>0) { // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea $maximum_chars= intval(trim($aQuestionAttributes['maximum_chars'])); $maxlength= "maxlength='{$maximum_chars}' "; $extraclass .=" maxchars maxchars-".$maximum_chars; } else { $maxlength= ""; } if (trim($aQuestionAttributes['text_input_width'])!='') { $tiwidth=$aQuestionAttributes['text_input_width']; $extraclass .=" inputwidth".trim($aQuestionAttributes['text_input_width']); } else { $tiwidth=20; } if (trim($aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $prefix=$aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; $extraclass .=" withprefix"; } else { $prefix = ''; } if (trim($aQuestionAttributes['suffix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $suffix=$aQuestionAttributes['suffix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; $extraclass .=" withsuffix"; } else { $suffix = ''; } if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "text-keypad"; $extraclass .=" inputkeypad"; } else { $kpclass = ""; } if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count()*2; //$answer .= "\t\n"; $fn = 1; $answer_main = ''; $label_width = 0; if ($anscount==0) { $inputnames=array(); $answer_main .= '
  • '.$clang->gT('Error: This question has no answers.')."
  • \n"; } else { if (trim($aQuestionAttributes['display_rows'])!='') { //question attribute "display_rows" is set -> we need a textarea to be able to show several rows $drows=$aQuestionAttributes['display_rows']; foreach ($ansresult->readAll() as $ansrow) { $myfname = $ia[1].$ansrow['title']; if ($ansrow['question'] == "") { $ansrow['question'] = " "; } //NEW: textarea instead of input=text field list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li","question-item answer-item text-item".$extraclass); $answer_main .= "\t$htmltbody2\n" . "\n" . "\t\n".$prefix."\n".' \n".$suffix."\n\t\n" . "\t\n"; $fn++; $inputnames[]=$myfname; } } else { foreach ($ansresult->readAll() as $ansrow) { $myfname = $ia[1].$ansrow['title']; if ($ansrow['question'] == "") {$ansrow['question'] = " ";} // color code missing mandatory questions red if ($ia[6]=='Y' && (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] == $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['prevstep']) || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['maxstep'] > $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'])) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '') { $ansrow['question'] = "{$ansrow['question']}"; } list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li","question-item answer-item text-item".$extraclass); $answer_main .= "\t$htmltbody2\n" . "\n" . "\t\n".$prefix."\n".''."\n".$suffix."\n\t\n" . "\t\n"; // --> END NEW FEATURE - SAVE $fn++; $inputnames[]=$myfname; } } } $answer = "
      \n".$answer_main."
    \n"; return array($answer, $inputnames); } // ----------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_multiplenumeric($ia) { global $thissurvey; $clang = Yii::app()->lang; $extraclass =""; $checkconditionFunction = "fixnum_checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); $answer=''; $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; //Must turn on the "numbers only javascript" $numbersonly = 'onkeypress="inputField = event.srcElement ? event.srcElement : event.target || event.currentTarget; if (inputField.value.indexOf(\''.$sSeperator.'\')>0 && String.fromCharCode(getkey(event))==\''.$sSeperator.'\') return false; return goodchars(event,\'-0123456789'.$sSeperator.'\')"'; $extraclass .=" numberonly"; if (intval(trim($aQuestionAttributes['maximum_chars']))>0) { // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea $maximum_chars= intval(trim($aQuestionAttributes['maximum_chars'])); $maxlength= "maxlength='{$maximum_chars}' "; $extraclass .=" maxchars maxchars-".$maximum_chars; } else { $maxlength= "25"; } // //EQUALS VALUE // if (trim($aQuestionAttributes['equals_num_value']) != ''){ // $equals_num_value = $aQuestionAttributes['equals_num_value']; // $numbersonlyonblur[]='calculateValue'.$ia[1].'(3)'; // $calculateValue[]=3; // } // elseif (trim($aQuestionAttributes['num_value_equals_sgqa']) != '' && isset($_SESSION[$aQuestionAttributes['num_value_equals_sgqa']])) // { // $equals_num_value = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$aQuestionAttributes['num_value_equals_sgqa']]; // $numbersonlyonblur[]='calculateValue'.$ia[1].'(3)'; // $calculateValue[]=3; // } // else // { // $equals_num_value=0; // } // // //MIN VALUE // if (trim($aQuestionAttributes['min_num_value']) != ''){ // $min_num_value = $aQuestionAttributes['min_num_value']; // $numbersonlyonblur[]='calculateValue'.$ia[1].'(2)'; // $calculateValue[]=2; // } // elseif (trim($aQuestionAttributes['min_num_value_sgqa']) != '' && isset($_SESSION[$aQuestionAttributes['min_num_value_sgqa']])){ // $min_num_value = $_SESSION[$aQuestionAttributes['min_num_value_sgqa']]; // $numbersonlyonblur[]='calculateValue'.$ia[1].'(2)'; // $calculateValue[]=2; // } // else // { // $min_num_value=0; // } // // //MAX VALUE // if (trim($aQuestionAttributes['max_num_value']) != ''){ // $max_num_value = $aQuestionAttributes['max_num_value']; // $numbersonlyonblur[]='calculateValue'.$ia[1].'(1)'; // $calculateValue[]=1; // } // elseif (trim($aQuestionAttributes['max_num_value_sgqa']) != '' && isset($_SESSION[$aQuestionAttributes['max_num_value_sgqa']])){ // $max_num_value = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$aQuestionAttributes['max_num_value_sgqa']]; // $numbersonlyonblur[]='calculateValue'.$ia[1].'(1)'; // $calculateValue[]=1; // } // else // { // $max_num_value = 0; // } if (trim($aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $prefix=$aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; $extraclass .=" withprefix"; } else { $prefix = ''; } if (trim($aQuestionAttributes['suffix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $suffix=$aQuestionAttributes['suffix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; $extraclass .=" withsuffix"; } else { $suffix = ''; } if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "num-keypad"; $extraclass .=" keypad"; } else { $kpclass = ""; } /*if(!empty($numbersonlyonblur)) { $numbersonly .= ' onblur="'.implode(';', $numbersonlyonblur).'"'; $numbersonly_slider = implode(';', $numbersonlyonblur); } else { $numbersonly_slider = ''; }*/ $numbersonly_slider = ''; if (trim($aQuestionAttributes['text_input_width'])!='') { $tiwidth=$aQuestionAttributes['text_input_width']; $extraclass .=" inputwidth".trim($aQuestionAttributes['text_input_width']); } else { $tiwidth=10; } if ($aQuestionAttributes['slider_layout']==1) { header_includes( Yii::app()->getConfig("generalscripts").'jquery/lime-slider.js'); $slider_layout=true; $extraclass .=" withslider"; if (trim($aQuestionAttributes['slider_accuracy'])!='') { //$slider_divisor = 1 / $slider_accuracy['value']; $decimnumber = strlen($aQuestionAttributes['slider_accuracy']) - strpos($aQuestionAttributes['slider_accuracy'],'.') -1; $slider_divisor = pow(10,$decimnumber); $slider_stepping = $aQuestionAttributes['slider_accuracy'] * $slider_divisor; // error_log('acc='.$slider_accuracy['value']." div=$slider_divisor stepping=$slider_stepping"); } else { $slider_divisor = 1; $slider_stepping = 1; } if (trim($aQuestionAttributes['slider_min'])!='') { $slider_mintext = $aQuestionAttributes['slider_min']; $slider_min = $aQuestionAttributes['slider_min'] * $slider_divisor; } else { $slider_mintext = 0; $slider_min = 0; } if (trim($aQuestionAttributes['slider_max'])!='') { $slider_maxtext = $aQuestionAttributes['slider_max']; $slider_max = $aQuestionAttributes['slider_max'] * $slider_divisor; } else { $slider_maxtext = "100"; $slider_max = 100 * $slider_divisor; } if (trim($aQuestionAttributes['slider_default'])!='') { $slider_default = $aQuestionAttributes['slider_default']; } else { $slider_default = ''; } if ($slider_default == '' && $aQuestionAttributes['slider_middlestart']==1) { $slider_middlestart = intval(($slider_max + $slider_min)/2); } else { $slider_middlestart = ''; } if (trim($aQuestionAttributes['slider_separator'])!='') { $slider_separator = $aQuestionAttributes['slider_separator']; } else { $slider_separator = ''; } } else { $slider_layout = false; } $hidetip=$aQuestionAttributes['hide_tip']; if ($slider_layout === true) // auto hide tip when using sliders { $hidetip=1; } if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count()*2; //$answer .= "\t\n"; $fn = 1; $answer_main = ''; if ($anscount==0) { $inputnames=array(); $answer_main .= '
  • '.$clang->gT('Error: This question has no answers.')."
  • \n"; } else { $label_width = 0; foreach($ansresult->readAll() as $ansrow) { $myfname = $ia[1].$ansrow['title']; if ($ansrow['question'] == "") {$ansrow['question'] = " ";} if ($slider_layout === false || $slider_separator == '') { $theanswer = $ansrow['question']; $sliderleft=''; $sliderright=''; } else { $answer_and_slider_array=explode($slider_separator,$ansrow['question']); if (isset($answer_and_slider_array[0])) $theanswer=$answer_and_slider_array[0]; else $theanswer = ''; if (isset($answer_and_slider_array[1])) $sliderleft=$answer_and_slider_array[1]; else $sliderleft = ''; if (isset($answer_and_slider_array[2])) $sliderright=$answer_and_slider_array[2]; else $sliderright = ''; $sliderleft="
    $sliderleft
    "; $sliderright="
    $sliderright
    "; } // color code missing mandatory questions red if ($ia[6]=='Y' && (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'] == $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['prevstep']) || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['maxstep'] > $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['step'])) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '') { $theanswer = "{$theanswer}"; } list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li","question-item answer-item text-item numeric-item".$extraclass); $answer_main .= "\t$htmltbody2\n"; if ($slider_layout === false) { $answer_main .= "\n"; } else { $answer_main .= "\n"; } if($label_width < strlen(trim(strip_tags($ansrow['question'])))) { $label_width = strlen(trim(strip_tags($ansrow['question']))); } if ($slider_layout === false) { $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; $answer_main .= "\n\t".$prefix."\n\t\t{$suffix}\n\n\t\n"; } else { if ($aQuestionAttributes['slider_showminmax']==1) { //$slider_showmin=$slider_min; $slider_showmin= "\t
    $slider_mintext
    \n"; $slider_showmax= "\t
    $slider_maxtext
    \n"; } else { $slider_showmin=''; $slider_showmax=''; } if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] != '') { $slider_startvalue = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] * $slider_divisor; $displaycallout_atstart=1; } elseif ($slider_default != "") { $slider_startvalue = $slider_default * $slider_divisor; $displaycallout_atstart=1; } elseif ($slider_middlestart != '') { $slider_startvalue = $slider_middlestart; $displaycallout_atstart=0; } else { $slider_startvalue = 'NULL'; $displaycallout_atstart=0; } $answer_main .= "$sliderleft
    \n" . "\t\n" . "\t\n" . "\t\n" . "\t\n" . "\t\n" . "\t\n" . "\t\n" . "\t\n" . "\t\n" . "
    \n" . $slider_showmin . "
    \n" . "
    \n" . $slider_showmax . "\t
    " . "
    $sliderright\n" . "getConfig('surveyID')][$myfname]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] != '') { $answer_main .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; } elseif ($slider_default != "") { $answer_main .= $slider_default; } $answer_main .= "\"/>\n" . "\t\n"; } // $answer .= "\t\n"; $fn++; $inputnames[]=$myfname; } $question_tip = ''; if($hidetip == 0) { $question_tip .= '

    '.$clang->gT('Only numbers may be entered in these fields')."

    \n"; } // if ($max_num_value) // { // $question_tip .= '

    '.sprintf($clang->gT('Total of all entries must not exceed %d'), $max_num_value)."

    \n"; // } // if ($equals_num_value) // { // $question_tip .= '

    '.sprintf($clang->gT('Total of all entries must equal %d'),$equals_num_value)."

    \n"; // } // if ($min_num_value) // { // $question_tip .= '

    '.sprintf($clang->gT('Total of all entries must be at least %s'),$min_num_value)."

    \n"; // } // // // TMSW TODO // if ($max_num_value || $equals_num_value || $min_num_value) // { // $answer_computed = ''; // if ($equals_num_value) // { // $answer_computed .= "\t
  • \n\n\n\t$prefix\n\t\n\t$suffix\n\n\t
  • \n"; // } // $answer_computed .= "\t
  • \n\n\n\t$prefix\n\t\n\t$suffix\n\n\t
  • \n"; // $answer_main .= $answer_computed; // } if (trim($aQuestionAttributes['equals_num_value']) != '' || trim($aQuestionAttributes['min_num_value']) != '' || trim($aQuestionAttributes['max_num_value']) != '' // || trim($aQuestionAttributes['num_value_equals_sgqa']) != '' // || trim($aQuestionAttributes['min_num_value_sgqa']) != '' // || trim($aQuestionAttributes['max_num_value_sgqa']) != '' ) { $qinfo = LimeExpressionManager::GetQuestionStatus($ia[0]); if (trim($aQuestionAttributes['equals_num_value']) != '') { $answer_main .= "\t
  • \n" . "".$clang->gT('Remaining: ')."\n" . "$prefix\n" . "{" . $qinfo['sumRemainingEqn'] . "}\n" . "$suffix\n" . "\t
  • \n"; } $answer_main .= "\t
  • \n" . "".$clang->gT('Total: ')."\n" . "$prefix\n" . "{" . $qinfo['sumEqn'] . "}\n" . "$suffix\n" . "\t
  • \n"; } $answer .= $question_tip."
      \n".$answer_main."
    \n"; } //just added these here so its easy to change in one place $errorClass = 'tip problem'; $goodClass = 'tip good'; /* ================================== Style to be applied to all templates. .numeric-multi p.tip.error { color: #f00; } .numeric-multi p.tip.good { color: #0f0; } */ $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; // if ($max_num_value || $equals_num_value || $min_num_value) // { //Do value validation // $answer .= '\n"; // $answer .= '\n"; // // $answer .= "\n"; // // } return array($answer, $inputnames); } // --------------------------------------------------------------- function do_numerical($ia) { global $thissurvey; $clang = Yii::app()->lang; $extraclass =""; $answertypeclass = "numeric"; $checkconditionFunction = "fixnum_checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (trim($aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $prefix=$aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; $extraclass .=" withprefix"; } else { $prefix = ''; } if (trim($aQuestionAttributes['suffix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $suffix=$aQuestionAttributes['suffix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; $extraclass .=" withsuffix"; } else { $suffix = ''; } if (intval(trim($aQuestionAttributes['maximum_chars']))>0 && intval(trim($aQuestionAttributes['maximum_chars']))<20) { // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea $maximum_chars= intval(trim($aQuestionAttributes['maximum_chars'])); $maxlength= "maxlength='{$maximum_chars}' "; $extraclass .=" maxchars maxchars-".$maximum_chars; } else { $maxlength= "maxlength='20' "; } if (trim($aQuestionAttributes['text_input_width'])!='') { $tiwidth=$aQuestionAttributes['text_input_width']; $extraclass .=" inputwidth-".trim($aQuestionAttributes['text_input_width']); } else { $tiwidth=10; } if (trim($aQuestionAttributes['num_value_int_only'])==1) { $acomma=""; $extraclass .=" integeronly"; $answertypeclass = " integeronly"; } else { $acomma=getRadixPointData($thissurvey['surveyls_numberformat']); $acomma = $acomma['seperator']; } $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; $dispVal = str_replace('.',$sSeperator,$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]); if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $extraclass .=" inputkeypad"; $answertypeclass = "num-keypad"; } else { $kpclass = ""; } // --> START NEW FEATURE - SAVE $answer = "

    " . " \n$prefix\t" . "gT('Only numbers may be entered in this field')."\" " . "id=\"answer{$ia[1]}\" value=\"{$dispVal}\" title=\"".$clang->gT('Only numbers may be entered in this field')."\" onkeypress=\"return goodchars(event,'-0123456789{$acomma}')\" onchange='$checkconditionFunction(this.value, this.name, this.type)' " . " {$maxlength} />\t{$suffix}\n

    \n"; if ($aQuestionAttributes['hide_tip']==0) { $answer .= "

    ".$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) { global $thissurvey; $clang = Yii::app()->lang; $googleMapsAPIKey = Yii::app()->getConfig("googleMapsAPIKey"); $extraclass =""; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if ($aQuestionAttributes['numbers_only']==1) { $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; $numbersonly = 'onkeypress="return goodchars(event,\'-0123456789'.$sSeperator.'\')"'; $extraclass .=" numberonly"; $checkconditionFunction = "fixnum_checkconditions"; } else { $numbersonly = ''; $checkconditionFunction = "checkconditions"; } if (intval(trim($aQuestionAttributes['maximum_chars']))>0) { // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea $maximum_chars= intval(trim($aQuestionAttributes['maximum_chars'])); $maxlength= "maxlength='{$maximum_chars}' "; $extraclass .=" maxchars maxchars-".$maximum_chars; } else { $maxlength= ""; } if (trim($aQuestionAttributes['text_input_width'])!='') { $tiwidth=$aQuestionAttributes['text_input_width']; $extraclass .=" inputwidth-".trim($aQuestionAttributes['text_input_width']); } else { $tiwidth=50; } if (trim($aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $prefix=$aQuestionAttributes['prefix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; $extraclass .=" withprefix"; } else { $prefix = ''; } if (trim($aQuestionAttributes['suffix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $suffix=$aQuestionAttributes['suffix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]; $extraclass .=" withsuffix"; } else { $suffix = ''; } if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "text-keypad"; $extraclass .=" inputkeypad"; } else { $kpclass = ""; } if (trim($aQuestionAttributes['display_rows'])!='') { //question attribute "display_rows" is set -> we need a textarea to be able to show several rows $drows=$aQuestionAttributes['display_rows']; //if a textarea should be displayed we make it equal width to the long text question //this looks nicer and more continuous if($tiwidth == 50) { $tiwidth=40; } //NEW: textarea instead of input=text field // --> START NEW FEATURE - SAVE $answer ="

    " . '

    \n"; } elseif((int)($aQuestionAttributes['location_mapservice'])!=0){ $mapservice = $aQuestionAttributes['location_mapservice']; $currentLocation = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]; $currentLatLong = null; $floatLat = 0; $floatLng = 0; // Get the latitude/longtitude for the point that needs to be displayed by default if (strlen($currentLocation) > 2){ $currentLatLong = explode(';',$currentLocation); $currentLatLong = array($currentLatLong[0],$currentLatLong[1]); } else{ if ((int)($aQuestionAttributes['location_nodefaultfromip'])==0) $currentLatLong = getLatLongFromIp(getIPAddress()); if (!isset($currentLatLong) || $currentLatLong==false){ $floatLat = 0; $floatLng = 0; $LatLong = explode(" ",trim($aQuestionAttributes['location_defaultcoordinates'])); if (isset($LatLong[0]) && isset($LatLong[1])){ $floatLat = $LatLong[0]; $floatLng = $LatLong[1]; } $currentLatLong = array($floatLat,$floatLng); } } // 2 - city; 3 - state; 4 - country; 5 - postal $strBuild = ""; if ($aQuestionAttributes['location_city']) $strBuild .= "2"; if ($aQuestionAttributes['location_state']) $strBuild .= "3"; if ($aQuestionAttributes['location_country']) $strBuild .= "4"; if ($aQuestionAttributes['location_postal']) $strBuild .= "5"; $currentLocation = $currentLatLong[0] . " " . $currentLatLong[1]; $answer = "
    getConfig('surveyID')][$ia[1]]}\">
    "; if ($aQuestionAttributes['location_mapservice']==1 && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") header_includes("https://maps.googleapis.com/maps/api/js?sensor=false"); else if ($aQuestionAttributes['location_mapservice']==1) header_includes("http://maps.googleapis.com/maps/api/js?sensor=false"); elseif ($aQuestionAttributes['location_mapservice']==2) header_includes("http://www.openlayers.org/api/OpenLayers.js"); if (isset($aQuestionAttributes['hide_tip']) && $aQuestionAttributes['hide_tip']==0) { $answer .= "
    " . $clang->gT('Drag and drop the pin to the desired location. You may also right click on the map to move the pin.').'
    '; $question_text['help'] = $clang->gT('Drag and drop the pin to the desired location. You may also right click on the map to move the pin.'); } } else { //no question attribute set, use common input text field $answer = "

    \n" ."" ."$prefix\tgetConfig('surveyID')][$ia[1]]; if ($aQuestionAttributes['numbers_only']==1) { $dispVal = str_replace('.',$sSeperator,$dispVal); } $dispVal = htmlspecialchars($dispVal,ENT_QUOTES,'UTF-8'); $answer .= " value=\"$dispVal\""; $answer .=" {$maxlength} onchange=\"$checkconditionFunction(this.value, this.name, this.type)\" $numbersonly />\n\t$suffix\n

    \n"; } if (trim($aQuestionAttributes['time_limit'])!='') { $answer .= return_timer_script($aQuestionAttributes, $ia, "answer".$ia[1]); } $inputnames[]=$ia[1]; return array($answer, $inputnames); } function getLatLongFromIp($ip){ $ipInfoDbAPIKey = Yii::app()->getConfig("ipInfoDbAPIKey"); $xml = simplexml_load_file("http://api.ipinfodb.com/v2/ip_query.php?key=$ipInfoDbAPIKey&ip=$ip&timezone=false"); if ($xml->{'Status'} == "OK"){ $lat = (float)$xml->{'Latitude'}; $lng = (float)$xml->{'Longitude'}; return(array($lat,$lng)); } else return false; } // --------------------------------------------------------------- function do_longfreetext($ia) { global $thissurvey; $extraclass =""; $clang=Yii::app()->lang; if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "text-keypad"; $extraclass .=" inputkeypad"; } else { $kpclass = ""; } $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (intval(trim($aQuestionAttributes['maximum_chars']))>0) { // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea $maximum_chars= intval(trim($aQuestionAttributes['maximum_chars'])); $maxlength= "maxlength='{$maximum_chars}' "; $extraclass .=" maxchars maxchars-".$maximum_chars; } else { $maxlength= ""; } // --> START ENHANCEMENT - DISPLAY ROWS if (trim($aQuestionAttributes['display_rows'])!='') { $drows=$aQuestionAttributes['display_rows']; } else { $drows=5; } // <-- END ENHANCEMENT - DISPLAY ROWS // --> START ENHANCEMENT - TEXT INPUT WIDTH if (trim($aQuestionAttributes['text_input_width'])!='') { $tiwidth=$aQuestionAttributes['text_input_width']; $extraclass .=" inputwidth-".trim($aQuestionAttributes['text_input_width']); } else { $tiwidth=40; } // <-- END ENHANCEMENT - TEXT INPUT WIDTH // --> START NEW FEATURE - SAVE $answer = "

    "; $answer .='

    \n"; if (trim($aQuestionAttributes['time_limit'])!='') { $answer .= return_timer_script($aQuestionAttributes, $ia, "answer".$ia[1]); } $inputnames[]=$ia[1]; return array($answer, $inputnames); } // --------------------------------------------------------------- function do_hugefreetext($ia) { global $thissurvey; $clang =Yii::app()->lang; $extraclass =""; if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "text-keypad"; $extraclass .=" inputkeypad"; } else { $kpclass = ""; } $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (intval(trim($aQuestionAttributes['maximum_chars']))>0) { // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea $maximum_chars= intval(trim($aQuestionAttributes['maximum_chars'])); $maxlength= "maxlength='{$maximum_chars}' "; $extraclass .=" maxchars maxchars-".$maximum_chars; } else { $maxlength= ""; } // --> START ENHANCEMENT - DISPLAY ROWS if (trim($aQuestionAttributes['display_rows'])!='') { $drows=$aQuestionAttributes['display_rows']; } else { $drows=30; } // <-- END ENHANCEMENT - DISPLAY ROWS // --> START ENHANCEMENT - TEXT INPUT WIDTH if (trim($aQuestionAttributes['text_input_width'])!='') { $tiwidth=$aQuestionAttributes['text_input_width']; $extraclass .=" inputwidth-".trim($aQuestionAttributes['text_input_width']); } else { $tiwidth=70; } // <-- END ENHANCEMENT - TEXT INPUT WIDTH // --> START NEW FEATURE - SAVE $answer = "

    "; $answer .='\n"; $answer .="

    "; if (trim($aQuestionAttributes['time_limit']) != '') { $answer .= return_timer_script($aQuestionAttributes, $ia, "answer".$ia[1]); } $inputnames[]=$ia[1]; return array($answer, $inputnames); } // --------------------------------------------------------------- function do_yesno($ia) { $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $answer = "
      \n" . "\t
    • \ngetConfig('surveyID')][$ia[1]] == 'Y') { $answer .= CHECKED; } // --> START NEW FEATURE - SAVE $answer .= " onclick=\"$checkconditionFunction(this.value, this.name, this.type)\" />\n\n\t
    • \n" . "\t
    • \n END NEW FEATURE - SAVE if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == 'N') { $answer .= CHECKED; } // --> START NEW FEATURE - SAVE $answer .= " onclick=\"$checkconditionFunction(this.value, this.name, this.type)\" />\n\n\t
    • \n"; // --> END NEW FEATURE - SAVE if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { $answer .= "\t
    • \ngetConfig('surveyID')][$ia[1]] == '') { $answer .= CHECKED; } // --> START NEW FEATURE - SAVE $answer .= " onclick=\"$checkconditionFunction(this.value, this.name, this.type)\" />\n\n\t
    • \n"; // --> END NEW FEATURE - SAVE } $answer .= "
    \n\ngetConfig('surveyID')][$ia[1]]."}\" />\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } // --------------------------------------------------------------- function do_gender($ia) { $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); $answer = "
      \n" . "\t
    • \n" . ' getConfig('surveyID')][$ia[1]] == 'F') { $answer .= CHECKED; } $answer .= " onclick=\"$checkconditionFunction(this.value, this.name, this.type)\" />\n" . ' \n\t
    • \n"; $answer .= "\t
    • \ngetConfig('surveyID')][$ia[1]] == 'M') { $answer .= CHECKED; } $answer .= " onclick=\"$checkconditionFunction(this.value, this.name, this.type)\" />\n\n\t
    • \n"; if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { $answer .= "\t
    • \ngetConfig('surveyID')][$ia[1]] == '') { $answer .= CHECKED; } // --> START NEW FEATURE - SAVE $answer .= " onclick=\"$checkconditionFunction(this.value, this.name, this.type)\" />\n\n\t
    • \n"; // --> END NEW FEATURE - SAVE } $answer .= "
    \n\ngetConfig('surveyID')][$ia[1]]."\" />\n"; $inputnames[]=$ia[1]; return array($answer, $inputnames); } // --------------------------------------------------------------- /** * DONE: well-formed valid HTML is appreciated * Enter description here... * @param $ia * @return unknown_type */ // TMSW TODO - Can remove DB query by passing in answer list from EM function do_array_5point($ia) { global $notanswered, $thissurvey; $extraclass =""; $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (trim($aQuestionAttributes['answer_width'])!='') { $answerwidth=$aQuestionAttributes['answer_width']; $extraclass .=" answerwidth-".trim($aQuestionAttributes['answer_width']); } else { $answerwidth = 20; } $cellwidth = 5; // number of columns if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { ++$cellwidth; // add another column } $cellwidth = round((( 100 - $answerwidth ) / $cellwidth) , 1); // convert number of columns to percentage of table width $ansquery = "SELECT question FROM {{questions}} WHERE parent_qid=".$ia[0]." AND question like '%|%'"; $ansresult = dbExecuteAssoc($ansquery); //Checked if ($ansresult->count()>0) {$right_exists=true;$answerwidth=$answerwidth/2;} else {$right_exists=false;} // $right_exists is a flag to find out if there are any right hand answer parts. If there arent we can leave out the right td column if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count(); $fn = 1; $answer = "\n\n\n" . "\t\n" . "\t\n"; $odd_even = ''; for ($xc=1; $xc<=5; $xc++) { $odd_even = alternation($odd_even); $answer .= "\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $odd_even = alternation($odd_even); $answer .= "\n"; } $answer .= "\t\n\n" . "\t\n\n" . "\t\n"; for ($xc=1; $xc<=5; $xc++) { $answer .= "\t\n"; } if ($right_exists) {$answer .= "\t\n";} if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $answer .= "\t\n"; } $answer .= "\n"; $answer_t_content = ''; $trbc = ''; $n=0; //return array($answer, $inputnames); foreach ($ansresult->readAll() as $ansrow) { $myfname = $ia[1].$ansrow['title']; $answertext = dTexts__run($ansrow['question']); 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 ($ia[6]=='Y' && (is_array($notanswered)) && (array_search($myfname, $notanswered) !== FALSE) && ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '') ) { $answertext = "{$answertext}"; } $trbc = alternation($trbc , 'row'); // Get array_filter stuff list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc answers-list radio-list"); $answer_t_content .= $htmltbody2 . "\t\n"; for ($i=1; $i<=5; $i++) { $answer_t_content .= "\t\n"; } $answertext2 = dTexts__run($ansrow['question']); if (strpos($answertext2,'|')) { $answertext2=substr($answertext2,strpos($answertext2,'|')+1); $answer_t_content .= "\t\n"; } elseif ($right_exists) { $answer_t_content .= "\t\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { $answer_t_content .= "\t\n"; } $answer_t_content .= "\n"; $fn++; $inputnames[]=$myfname; } $answer .= $answer_t_content . "\n\t
     $xc ".$clang->gT('No answer')."
    \n$answertext\n" . $hiddenfield . "getConfig('surveyID')][$myfname])) { $answer_t_content .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; } $answer_t_content .= "\" />\n\t\n\n\t$answertext2 \n\n\t
    \n"; return array($answer, $inputnames); } // --------------------------------------------------------------- /** * DONE: well-formed valid HTML is appreciated * Enter description here... * @param $ia * @return unknown_type */ // TMSW TODO - Can remove DB query by passing in answer list from EM function do_array_10point($ia) { global $notanswered, $thissurvey; $extraclass =""; $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $qquery = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."'"; $qresult = dbExecuteAssoc($qquery); //Checked $qrow = $qresult->read(); $other = $qrow['other']; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (trim($aQuestionAttributes['answer_width'])!='') { $answerwidth=$aQuestionAttributes['answer_width']; } else { $answerwidth = 20; } $cellwidth = 10; // number of columns if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { ++$cellwidth; // add another column } $cellwidth = round((( 100 - $answerwidth ) / $cellwidth) , 1); // convert number of columns to percentage of table width if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count(); $fn = 1; $answer = "\n\n\n" . "\t\n" . "\t\n"; $odd_even = ''; for ($xc=1; $xc<=10; $xc++) { $odd_even = alternation($odd_even); $answer .= "\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $odd_even = alternation($odd_even); $answer .= "\n"; } $answer .= "\t\n\n" . "\t\n\n" . "\t\n"; for ($xc=1; $xc<=10; $xc++) { $answer .= "\t\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $answer .= "\t\n"; } $answer .= "\n"; $answer_t_content = 'readAll() as $ansrow) { $myfname = $ia[1].$ansrow['title']; $answertext = dTexts__run($ansrow['question']); /* 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 ($ia[6]=='Y' && (is_array($notanswered)) && (array_search($myfname, $notanswered) !== FALSE) && ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == "") ) { $answertext = "{$answertext}"; } $trbc = alternation($trbc , 'row'); //Get array filter stuff list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc answers-list radio-list"); $answer_t_content .= $htmltbody2 . "\t\n"; for ($i=1; $i<=10; $i++) { $answer_t_content .= "\t\n"; // --> END NEW FEATURE - SAVE } if ($ia[6] != "Y" && SHOW_NO_ANSWER == 1) { $answer_t_content .= "\t\n"; } $answer_t_content .= "\n"; $inputnames[]=$myfname; $fn++; } $answer .= $answer_t_content . "\t\n\n
     $xc".$clang->gT('No answer')."
    \n$answertext\n" . $hiddenfield . "getConfig('surveyID')][$myfname])) { $answer_t_content .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; } $answer_t_content .= "\" />\n\t\n\n\t\n\n\t
    \n"; return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_array_yesnouncertain($ia) { global $notanswered, $thissurvey; $extraclass =""; $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $qquery = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."'"; $qresult = dbExecuteAssoc($qquery); //Checked $qrow = $qresult->readAll(); $other = isset($qrow['other']) ? $qrow['other'] : ''; $aQuestionAttributes=getQuestionAttributeValues($ia[0],$ia[4]); if (trim($aQuestionAttributes['answer_width'])!='') { $answerwidth=$aQuestionAttributes['answer_width']; } else { $answerwidth = 20; } $cellwidth = 3; // number of columns if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { ++$cellwidth; // add another column } $cellwidth = round((( 100 - $answerwidth ) / $cellwidth) , 1); // convert number of columns to percentage of table width if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count(); $fn = 1; $answer = "\n\n" . "\t\n" . "\n\t\n"; $odd_even = ''; for ($xc=1; $xc<=3; $xc++) { $odd_even = alternation($odd_even); $answer .= "\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $odd_even = alternation($odd_even); $answer .= "\n"; } $answer .= "\t\n\n" . "\t\n\n" . "\t\n" . "\t\n" . "\t\n" . "\t\n"; if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $answer .= "\t\n"; } $answer .= "\n\t"; $answer_t_content = ''; if ($anscount==0) { $inputnames=array(); $answer.="\t\n\n"; } else { $trbc = ''; foreach($ansresult->readAll() as $ansrow) { $myfname = $ia[1].$ansrow['title']; $answertext = dTexts__run($ansrow['question']); /* 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 ($ia[6]=='Y' && (is_array($notanswered)) && (array_search($myfname, $notanswered) !== FALSE) && ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '') ) { $answertext = "{$answertext}"; } $trbc = alternation($trbc , 'row'); // Get array_filter stuff list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc answers-list radio-list"); $answer_t_content .= $htmltbody2; $answer_t_content .= "\t\n" . "\t\n" . "\t\n" . "\t\n"; if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { $answer_t_content .= "\t\n"; // --> END NEW FEATURE - SAVE } $answer_t_content .= ""; $inputnames[]=$myfname; $fn++; } } $answer .= $answer_t_content . "\t\\n
     ".$clang->gT('Yes')."".$clang->gT('Uncertain')."".$clang->gT('No')."".$clang->gT('No answer')."
    ".$clang->gT('Error: This question has no answers.')."
    \n" . $hiddenfield . "\t\t\t\t$answertext\n\n\t\n\n\t\n\n" . " END NEW FEATURE - SAVE if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname])) { $answer_t_content .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; } $answer_t_content .= "\" />\n\t\n\t\n\t
    \n"; return array($answer, $inputnames); } // TMSW TODO - Can remove DB query by passing in answer list from EM function do_array_increasesamedecrease($ia) { global $thissurvey; global $notanswered; $extraclass =""; $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $qquery = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."'"; $qresult = dbExecuteAssoc($qquery); //Checked $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (trim($aQuestionAttributes['answer_width'])!='') { $answerwidth=$aQuestionAttributes['answer_width']; } else { $answerwidth = 20; } $cellwidth = 3; // number of columns if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { ++$cellwidth; // add another column } $cellwidth = round((( 100 - $answerwidth ) / $cellwidth) , 1); // convert number of columns to percentage of table width foreach($qresult->readAll() as $qrow) { $other = $qrow['other']; } if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count(); $fn = 1; $answer = "\n\n" . "\t\n" . "\t\n"; $odd_even = ''; for ($xc=1; $xc<=3; $xc++) { $odd_even = alternation($odd_even); $answer .= "\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $odd_even = alternation($odd_even); $answer .= "\n"; } $answer .= "\t\n" . "\t\n" . "\n" . "\t\n" . "\t\n" . "\t\n" . "\t\n"; if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $answer .= "\t\n"; } $answer .= "\n" ."\t\n"; $answer_body = ''; $trbc = ''; foreach($ansresult->readAll() as $ansrow) { $myfname = $ia[1].$ansrow['title']; $answertext = dTexts__run($ansrow['question']); /* 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 ($ia[6]=='Y' && (is_array($notanswered)) && (array_search($myfname, $notanswered) !== FALSE) && ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == "") ) { $answertext = "{$answertext}"; } $trbc = alternation($trbc , 'row'); // Get array_filter stuff list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,'tr',"$trbc answers-list radio-list"); $answer_body .= $htmltbody2; $answer_body .= "\t\n"; $answer_body .= "\t\n" . "\t\n" . "\t\n"; if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { $answer_body .= "\t\n"; } $answer_body .= "\n"; $inputnames[]=$myfname; $fn++; } $answer .= $answer_body . "\t\n
     ".$clang->gT('Increase')."".$clang->gT('Same')."".$clang->gT('Decrease')."".$clang->gT('No answer')."
    \n" . "$answertext\n" . $hiddenfield . "getConfig('surveyID')][$myfname])) { $answer_body .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; } $answer_body .= "\" />\n\t\n" . "\n" . "\t\n" . "\n" . "\t\n" . "\n" . "getConfig('surveyID')][$myfname])) {$answer_body .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname];} $answer_body .= "\" />\n\t\n" . "\n" . "\t
    \n"; return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_array($ia) { global $thissurvey; global $notanswered; $repeatheadings = Yii::app()->getConfig("repeatheadings"); $minrepeatheadings = Yii::app()->getConfig("minrepeatheadings"); $extraclass =""; $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $qquery = "SELECT other FROM {{questions}} WHERE qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."'"; $qresult = dbExecuteAssoc($qquery); //Checked $qrow = $qresult->read(); $other = $qrow['other']; $lquery = "SELECT * FROM {{answers}} WHERE qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY sortorder, code"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (trim($aQuestionAttributes['answer_width'])!='') { $answerwidth=$aQuestionAttributes['answer_width']; } else { $answerwidth=20; } $columnswidth=100-$answerwidth; if ($aQuestionAttributes['use_dropdown'] == 1) { $useDropdownLayout = true; $extraclass .=" dropdown-list"; } else { $useDropdownLayout = false; } $lresult = dbExecuteAssoc($lquery); //Checked if ($useDropdownLayout === false && $lresult->count() > 0) { foreach ($lresult->readAll() as $lrow) { $labelans[]=$lrow['answer']; $labelcode[]=$lrow['code']; } // $cellwidth=sprintf('%02d', $cellwidth); $ansquery = "SELECT question FROM {{questions}} WHERE parent_qid={$ia[0]} AND question like '%|%' "; $ansresult = dbExecuteAssoc($ansquery); //Checked if ($ansresult->count()>0) {$right_exists=true;$answerwidth=$answerwidth/2;} else {$right_exists=false;} // $right_exists is a flag to find out if there are any right hand answer parts. If there arent we can leave out the right td column if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count(); $fn=1; $numrows = count($labelans); if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { ++$numrows; } if ($right_exists) { ++$numrows; } $cellwidth = round( ($columnswidth / $numrows ) , 1 ); $answer_start = "\n\n"; $answer_head = "\t\n" . "\n" . "\t\n"; foreach ($labelans as $ld) { $answer_head .= "\t\n"; } if ($right_exists) {$answer_head .= "\t\n";} if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory and we can show "no answer" { $answer_head .= "\t\n"; } $answer_head .= "\n\t\n\n\t\n"; $answer = ''; $trbc = ''; $inputnames=array(); foreach($ansresult->readAll() as $ansrow) { if (isset($repeatheadings) && $repeatheadings > 0 && ($fn-1) > 0 && ($fn-1) % $repeatheadings == 0) { if ( ($anscount - $fn + 1) >= $minrepeatheadings ) { $answer .= "\n";// Close actual body and open another one $answer .= "\n" . "\t\n"; foreach ($labelans as $ld) { $answer .= "\t\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory and we can show "no answer" { $answer .= "\t\n"; } $answer .= "\n"; } } $myfname = $ia[1].$ansrow['title']; $answertext = dTexts__run($ansrow['question']); $answertextsave=$answertext; if (strpos($answertext,'|')) { $answertext=substr($answertext,0, strpos($answertext,'|')); } /* Check if this item has not been answered: the 'notanswered' variable must be an array, containing a list of unanswered questions, the current question must be in the array, and there must be no answer available for the item in this session. */ if (strpos($answertext,'|')) {$answerwidth=$answerwidth/2;} if ($ia[6]=='Y' && (is_array($notanswered)) && (array_search($myfname, $notanswered) !== FALSE) && ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '') ) { $answertext = ''.$answertext.''; } // Get array_filter stuff // // TMSW - is this correct? $trbc = alternation($trbc , 'row'); list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc answers-list radio-list"); $fn++; $answer .= $htmltbody2; $answer .= "\t\n"; $thiskey=0; foreach ($labelcode as $ld) { $answer .= "\t\t\t\n"; // --> END NEW FEATURE - SAVE $thiskey++; } if (strpos($answertextsave,'|')) { $answertext=substr($answertextsave,strpos($answertextsave,'|')+1); $answer .= "\t\n"; } elseif ($right_exists) { $answer .= "\t\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { $answer .= "\t\n"; // --> END NEW FEATURE - SAVE } $answer .= "\n"; $inputnames[]=$myfname; //IF a MULTIPLE of flexi-redisplay figure, repeat the headings } $answer .= "\n"; $answer_cols = "\t\n" ."\t\n" ; $odd_even = ''; foreach ($labelans as $c) { $odd_even = alternation($odd_even); $answer_cols .= "\n"; } if ($right_exists) { $odd_even = alternation($odd_even); $answer_cols .= "\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $odd_even = alternation($odd_even); $answer_cols .= "\n"; } $answer_cols .= "\t\n"; $answer = $answer_start . $answer_cols . $answer_head .$answer ."
     ".$ld." ".$clang->gT('No answer')."
     ".$ld."".$clang->gT('No answer')."
    \n$answertext" . $hiddenfield . "getConfig('surveyID')][$myfname])) { $answer .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; } $answer .= "\" />\n\t\n" . "\n" . "\t$answertext \n\n\t
    \n"; } elseif ($useDropdownLayout === true && $lresult->count() > 0) { foreach($lresult->readAll() as $lrow) $labels[]=Array('code' => $lrow['code'], 'answer' => $lrow['answer']); $ansquery = "SELECT question FROM {{questions}} WHERE parent_qid={$ia[0]} AND question like '%|%' "; $ansresult = dbExecuteAssoc($ansquery); //Checked if ($ansresult->count()>0) {$right_exists=true;$answerwidth=$answerwidth/2;} else {$right_exists=false;} // $right_exists is a flag to find out if there are any right hand answer parts. If there arent we can leave out the right td column if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count(); $fn=1; $numrows = count($labels); if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { ++$numrows; } if ($right_exists) { ++$numrows; } $cellwidth = round( ($columnswidth / $numrows ) , 1 ); $answer_start = "\n\n"; $answer = "\t\n"; $trbc = ''; $inputnames=array(); foreach ($ansresult->readAll() as $ansrow) { $myfname = $ia[1].$ansrow['title']; $trbc = alternation($trbc , 'row'); $answertext=$ansrow['question']; $answertextsave=$answertext; if (strpos($answertext,'|')) { $answertext=substr($answertext,0, strpos($answertext,'|')); } /* Check if this item has not been answered: the 'notanswered' variable must be an array, containing a list of unanswered questions, the current question must be in the array, and there must be no answer available for the item in this session. */ if (strpos($answertext,'|')) {$answerwidth=$answerwidth/2;} if ($ia[6]=='Y' && (is_array($notanswered)) && (array_search($myfname, $notanswered) !== FALSE) && ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '') ) { $answertext = ''.$answertext.''; } // Get array_filter stuff list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc question-item answer-item dropdown-item"); $answer .= $htmltbody2; $answer .= "\t\n"; $answer .= "\t\n"; } elseif ($right_exists) { $answer .= "\t\n"; } $answer .= "\n"; $inputnames[]=$myfname; //IF a MULTIPLE of flexi-redisplay figure, repeat the headings $fn++; } $answer .= "\t"; $answer = $answer_start . $answer . "\n
    \n$answertext" . $hiddenfield . "getConfig('surveyID')][$myfname])) { $answer .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; } $answer .= "\" />\n\t\n" . "\n"; if (strpos($answertextsave,'|')) { $answertext=substr($answertextsave,strpos($answertextsave,'|')+1); $answer .= "\t$answertext 
    \n"; } else { $answer = "\n

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

    \n"; $inputnames=''; } return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_array_multitext($ia) { global $thissurvey; global $notanswered; $repeatheadings = Yii::app()->getConfig("repeatheadings"); $minrepeatheadings = Yii::app()->getConfig("minrepeatheadings"); $extraclass =""; $clang = Yii::app()->lang; if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "text-keypad"; } else { $kpclass = ""; } $checkconditionFunction = "checkconditions"; $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']); $sSeperator = $sSeperator['seperator']; $defaultvaluescript = ""; $qquery = "SELECT other FROM {{questions}} WHERE qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."'"; $qresult = Yii::app()->db->createCommand($qquery)->query(); $qrow = $qresult->read(); $other = $qrow['other']; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); $show_grand = $aQuestionAttributes['show_grand_total']; $totals_class = ''; $num_class = ''; $show_totals = ''; $col_total = ''; $row_total = ''; $total_col = ''; $col_head = ''; $row_head = ''; $grand_total = ''; $q_table_id = ''; $q_table_id_HTML = ''; $numbersonly = ''; if (intval(trim($aQuestionAttributes['maximum_chars']))>0) { // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea $maximum_chars= intval(trim($aQuestionAttributes['maximum_chars'])); $maxlength= "maxlength='{$maximum_chars}' "; $extraclass .=" maxchars maxchars-".$maximum_chars; } else { $maxlength= ""; } if ($aQuestionAttributes['numbers_only']==1) { $checkconditionFunction = "fixnum_checkconditions"; $q_table_id = 'totals_'.$ia[0]; $q_table_id_HTML = ' id="'.$q_table_id.'"'; // $numbersonly = 'onkeypress="return goodchars(event,\'-0123456789.\')"'; $num_class = ' numbers-only'; $extraclass.=" numberonly"; switch ($aQuestionAttributes['show_totals']) { case 'R': $totals_class = $show_totals = 'row'; $row_total = ' '; $col_head = ' Total'; if($show_grand == true) { $row_head = ' Grand total'; $col_total = '  '; $grand_total = ' '; }; break; case 'C': $totals_class = $show_totals = 'col'; $col_total = ' '; $row_head = ' Total'; if($show_grand == true) { $row_total = '  '; $col_head = ' Grand Total'; $grand_total = ' '; }; break; case 'B': $totals_class = $show_totals = 'both'; $row_total = ' '; $col_total = ' '; $col_head = ' Total'; $row_head = ' Total'; if($show_grand == true) { $grand_total = ' '; } else { $grand_total = '  '; }; break; }; if(!empty($totals_class)) { $totals_class = ' show-totals '.$totals_class; if($aQuestionAttributes['show_grand_total']) { $totals_class .= ' grand'; $show_grand = true; }; }; } else { $numbersonly = ''; }; if (trim($aQuestionAttributes['answer_width'])!='') { $answerwidth=$aQuestionAttributes['answer_width']; } else { $answerwidth=20; }; if (trim($aQuestionAttributes['text_input_width'])!='') { $inputwidth=$aQuestionAttributes['text_input_width']; $extraclass .=" inputwidth-".trim($aQuestionAttributes['text_input_width']); } else { $inputwidth = 20; } $columnswidth=100-($answerwidth*2); $lquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=1 ORDER BY question_order"; $lresult = Yii::app()->db->createCommand($lquery)->query(); if (count($lresult)> 0) { foreach($lresult->readAll() as $lrow) { $labelans[]=$lrow['question']; $labelcode[]=$lrow['title']; } $numrows=count($labelans); if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) {$numrows++;} if( ($show_grand == true && $show_totals == 'col' ) || $show_totals == 'row' || $show_totals == 'both' ) { ++$numrows; }; $cellwidth=$columnswidth/$numrows; $cellwidth=sprintf('%02d', $cellwidth); $ansquery = "SELECT count(question) FROM {{questions}} WHERE parent_qid={$ia[0]} and scale_id=0 AND question like '%|%'"; $ansresult = reset(dbExecuteAssoc($ansquery)->read()); if ($ansresult>0) { $right_exists=true; $answerwidth=$answerwidth/2; } else { $right_exists=false; } // $right_exists is a flag to find out if there are any right hand answer parts. If there arent we can leave out the right td column if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] and scale_id=0 AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] and scale_id=0 AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); $anscount = $ansresult->count(); $fn=1; $answer_cols = "\t\n" ."\n\t\t\n"; $answer_head = "\n\t\n" . "\t\t\n" . "\t\t\t \n"; $odd_even = ''; foreach ($labelans as $ld) { $answer_head .= "\t".$ld."\n"; $odd_even = alternation($odd_even); $answer_cols .= "\n"; } if ($right_exists) { $answer_head .= "\t \n";// class=\"answertextright\" $odd_even = alternation($odd_even); $answer_cols .= "\n"; } if( ($show_grand == true && $show_totals == 'col' ) || $show_totals == 'row' || $show_totals == 'both' ) { $answer_head .= $col_head; $odd_even = alternation($odd_even); $answer_cols .= "\t\t\n"; } $answer_cols .= "\t\n"; $answer_head .= "\n" . "\t\n"; $answer = "\n\n" . $answer_cols . $answer_head; $answer .= ""; $trbc = ''; foreach ($ansresult->readAll() as $ansrow) { if (isset($repeatheadings) && $repeatheadings > 0 && ($fn-1) > 0 && ($fn-1) % $repeatheadings == 0) { if ( ($anscount - $fn + 1) >= $minrepeatheadings ) { $answer .= "\n";// Close actual body and open another one $answer .= "\n" . "\t \n"; foreach ($labelans as $ld) { $answer .= "\t".$ld."\n"; } $answer .= "\n"; } } $myfname = $ia[1].$ansrow['title']; $answertext = dTexts__run($ansrow['question']); $answertextsave=$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 ($ia[6]=='Y' && is_array($notanswered)) { //Go through each labelcode and check for a missing answer! If any are found, highlight this line $emptyresult=0; foreach($labelcode as $ld) { $myfname2=$myfname.'_'.$ld; if((array_search($myfname2, $notanswered) !== FALSE) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname2] == '') { $emptyresult=1; } } if ($emptyresult == 1) { $answertext = "{$answertext}"; } } // Get array_filter stuff $trbc = alternation($trbc , 'row'); list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc subquestion-list questions-list"); $answer .= $htmltbody2; if (strpos($answertext,'|')) {$answertext=substr($answertext,0, strpos($answertext,'|'));} $answer .= "\t\t\t\n" . "\t\t\t\t".$hiddenfield . "$answertext\n" . "\t\t\t\tgetConfig('surveyID')][$myfname])) {$answer .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname];} $answer .= "\" />\n\t\t\t\n"; $thiskey=0; foreach ($labelcode as $ld) { $myfname2=$myfname."_$ld"; $myfname2value = isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname2]) ? $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname2] : ""; $answer .= "\t\n" . "\t\t\t\t\n\t\t\t\n"; $thiskey += 1; } if (strpos($answertextsave,'|')) { $answertext=substr($answertextsave,strpos($answertextsave,'|')+1); $answer .= "\t\t\t$answertext\n"; } elseif ($right_exists) { $answer .= "\t\t\t \n"; } $answer .= str_replace(array('[[ROW_NAME]]','[[INPUT_WIDTH]]') , array(strip_tags($answertext),$inputwidth) , $row_total); $answer .= "\n\t\t\n"; //IF a MULTIPLE of flexi-redisplay figure, repeat the headings $fn++; } if($show_totals == 'col' || $show_totals == 'both' || $grand_total == true) { $answer .= "\t\t$row_head"; for( $a = 0; $a < count($labelcode) ; ++$a ) { $answer .= str_replace(array('[[ROW_NAME]]','[[INPUT_WIDTH]]') , array(strip_tags($answertext),$inputwidth) , $col_total); }; $answer .= str_replace(array('[[ROW_NAME]]','[[INPUT_WIDTH]]') , array(strip_tags($answertext),$inputwidth) , $grand_total)."\n\t\t\n"; } $answer .= "\t\n\n"; if(!empty($q_table_id)) { if ($aQuestionAttributes['numbers_only']==1) { $radix = $sSeperator; } else { $radix = 'X'; // to indicate that should not try to change entered values } $answer .= "\n\n"; } else { $addcheckcond = <<< EOD EOD; $answer .= $addcheckcond; } } else { $answer = "\n

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

    \n"; $inputnames=''; } return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_array_multiflexi($ia) { global $thissurvey; global $notanswered; $repeatheadings = Yii::app()->getConfig("repeatheadings"); $minrepeatheadings = Yii::app()->getConfig("minrepeatheadings"); $extraclass =""; $answertypeclass = ""; $clang = Yii::app()->lang; $checkconditionFunction = "fixnum_checkconditions"; //echo '
    '; print_r($_POST); echo '
    '; $defaultvaluescript = ''; $qquery = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and parent_qid=0"; $qresult = dbExecuteAssoc($qquery); $qrow = $qresult->read(); $other = $qrow['other']; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if (trim($aQuestionAttributes['multiflexible_max'])!='' && trim($aQuestionAttributes['multiflexible_min']) ==''){ $maxvalue=$aQuestionAttributes['multiflexible_max']; $extraclass .=" maxvalue maxvalue-".trim($aQuestionAttributes['multiflexible_max']); if(isset($minvalue['value']) && $minvalue['value'] == 0) {$minvalue = 0;} else {$minvalue=1;} } if (trim($aQuestionAttributes['multiflexible_min'])!='' && trim($aQuestionAttributes['multiflexible_max']) ==''){ $minvalue=$aQuestionAttributes['multiflexible_min']; $extraclass .=" minvalue minvalue-".trim($aQuestionAttributes['multiflexible_max']); $maxvalue=$aQuestionAttributes['multiflexible_min'] + 10; } if (trim($aQuestionAttributes['multiflexible_min'])=='' && trim($aQuestionAttributes['multiflexible_max']) ==''){ if(isset($minvalue['value']) && $minvalue['value'] == 0) {$minvalue = 0;} else {$minvalue=1;} $maxvalue=10; } if (trim($aQuestionAttributes['multiflexible_min']) !='' && trim($aQuestionAttributes['multiflexible_max']) !=''){ if($aQuestionAttributes['multiflexible_min'] < $aQuestionAttributes['multiflexible_max']){ $minvalue=$aQuestionAttributes['multiflexible_min']; $maxvalue=$aQuestionAttributes['multiflexible_max']; } } if (trim($aQuestionAttributes['multiflexible_step'])!='' && $aQuestionAttributes['multiflexible_step'] > 0) { $stepvalue=$aQuestionAttributes['multiflexible_step']; } else { $stepvalue=1; } if($aQuestionAttributes['reverse']==1) { $tmp = $minvalue; $minvalue = $maxvalue; $maxvalue = $tmp; $reverse=true; $stepvalue=-$stepvalue; } else { $reverse=false; } $checkboxlayout=false; if ($aQuestionAttributes['multiflexible_checkbox']!=0) { $minvalue=0; $maxvalue=1; $checkboxlayout=true; $answertypeclass .=" checkbox"; } $inputboxlayout=false; if ($aQuestionAttributes['input_boxes']!=0 && !$checkboxlayout) // checkboxlayout have the { $inputboxlayout=true; $answertypeclass .=" numberonly text"; } if (!$checkboxlayout && !$inputboxlayout) { $answertypeclass .=" dropdown"; } if (intval(trim($aQuestionAttributes['maximum_chars']))>0) { // Only maxlength attribute, use textarea[maxlength] jquery selector for textarea $maximum_chars= intval(trim($aQuestionAttributes['maximum_chars'])); $maxlength= "maxlength='{$maximum_chars}' "; $extraclass .=" maxchars maxchars-".$maximum_chars; } else { $maxlength= ""; } if ($thissurvey['nokeyboard']=='Y') { includeKeypad(); $kpclass = "num-keypad"; $extraclass .=" inputkeypad"; } else { $kpclass = ""; } if (trim($aQuestionAttributes['answer_width'])!='') { $answerwidth=$aQuestionAttributes['answer_width']; } else { $answerwidth=20; } $columnswidth=100-($answerwidth*2); $lquery = "SELECT * FROM {{questions}} WHERE parent_qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=1 ORDER BY question_order"; $lresult = dbExecuteAssoc($lquery); if ($lresult->count() > 0) { foreach ($lresult->readAll() as $lrow) { $labelans[]=$lrow['question']; $labelcode[]=$lrow['title']; } $numrows=count($labelans); if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) {$numrows++;} $cellwidth=$columnswidth/$numrows; $cellwidth=sprintf('%02d', $cellwidth); $ansquery = "SELECT question FROM {{questions}} WHERE parent_qid=".$ia[0]." AND scale_id=0 AND question like '%|%'"; $ansresult = dbExecuteAssoc($ansquery); if ($ansresult->count()>0) {$right_exists=true;$answerwidth=$answerwidth/2;} else {$right_exists=false;} // $right_exists is a flag to find out if there are any right hand answer parts. If there arent we can leave out the right td column if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND scale_id=0 AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND scale_id=0 AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery)->readAll(); //Checked if (trim($aQuestionAttributes['parent_order']!='')) { $iParentQID=(int) $aQuestionAttributes['parent_order']; $aResult=array(); $sessionao = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['answer_order']; foreach ($sessionao[$iParentQID] as $aOrigRow) { $sCode=$aOrigRow['title']; foreach ($ansresult as $aRow) { if ($sCode==$aRow['title']) { $aResult[]=$aRow; } } } $ansresult=$aResult; } $anscount = count($ansresult); $fn=1; $mycols = "\t\n" . "\n\t\n"; $myheader = "\n\t\n" . "\n" . "\t \n"; $odd_even = ''; foreach ($labelans as $ld) { $myheader .= "\t".$ld."\n"; $odd_even = alternation($odd_even); $mycols .= "\n"; } if ($right_exists) { $myheader .= "\t "; $odd_even = alternation($odd_even); $mycols .= "\n"; } $myheader .= "\n" . "\t\n"; $mycols .= "\t\n"; $trbc = ''; $answer = "\n\n" . $mycols . $myheader . "\n"; $answer .= ""; foreach ($ansresult as $ansrow) { if (isset($repeatheadings) && $repeatheadings > 0 && ($fn-1) > 0 && ($fn-1) % $repeatheadings == 0) { if ( ($anscount - $fn + 1) >= $minrepeatheadings ) { $answer .= "\n";// Close actual body and open another one $answer .= "\n" . "\t\n"; foreach ($labelans as $ld) { $answer .= "\t\n"; } $answer .= "\n\n"; } } $myfname = $ia[1].$ansrow['title']; $answertext = dTexts__run($ansrow['question']); $answertextsave=$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 ($ia[6]=='Y' && is_array($notanswered)) { //Go through each labelcode and check for a missing answer! If any are found, highlight this line $emptyresult=0; foreach($labelcode as $ld) { $myfname2=$myfname.'_'.$ld; if((array_search($myfname2, $notanswered) !== FALSE) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname2] == "") { $emptyresult=1; } } if ($emptyresult == 1) { $answertext = ''.$answertext.''; } } // Get array_filter stuff $trbc = alternation($trbc , 'row'); list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc subquestions-list questions-list {$answertypeclass}-list"); $answer .= $htmltbody2; if (strpos($answertext,'|')) {$answertext=substr($answertext,0, strpos($answertext,'|'));} $answer .= "\t\n"; $first_hidden_field = ''; $thiskey=0; foreach ($labelcode as $ld) { if ($checkboxlayout == false) { $myfname2=$myfname."_$ld"; if(isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname2])) { $myfname2_java_value = " value=\"{$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname2]}\" "; } else { $myfname2_java_value = ""; } $answer .= "\t\n"; $inputnames[]=$myfname2; $thiskey++; } else { $myfname2=$myfname."_$ld"; if(isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname2]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname2] == '1') { $myvalue = '1'; $setmyvalue = CHECKED; } else { $myvalue = ''; $setmyvalue = ''; } $answer .= "\t\n"; $thiskey++; } } if (strpos($answertextsave,'|')) { $answertext=substr($answertextsave,strpos($answertextsave,'|')+1); $answer .= "\t\n"; } elseif ($right_exists) { $answer .= "\t\n"; } $answer .= "\n"; //IF a MULTIPLE of flexi-redisplay figure, repeat the headings $fn++; } $answer .= "\t\n
     ".$ld."
    \n" . "$answertext\n" . $hiddenfield . "getConfig('surveyID')][$myfname])) { $answer .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; } $answer .= "\" />\n\t\n" . "\n" . "\t\n" // . "\n" $answer .= "" . "\t$answertext 
    \n"; } else { $answer = "\n

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

    \n"; $inputnames = ''; } return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_arraycolumns($ia) { global $notanswered; $clang = Yii::app()->lang; $extraclass = ""; $checkconditionFunction = "checkconditions"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); $qquery = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."'"; $qresult = dbExecuteAssoc($qquery); //Checked $qrow = $qresult->read(); $other = $qrow['other']; $lquery = "SELECT * FROM {{answers}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY sortorder, code"; $lresult = dbExecuteAssoc($lquery); //Checked if ($lresult->count() > 0) { foreach ($lresult->readAll() as $lrow) { $labelans[]=$lrow['answer']; $labelcode[]=$lrow['code']; $labels[]=array("answer"=>$lrow['answer'], "code"=>$lrow['code']); } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { $labelcode[]=''; $labelans[]=$clang->gT('No answer'); $labels[]=array('answer'=>$clang->gT('No answer'), 'code'=>''); } if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count(); if ($anscount>0) { $fn=1; $cellwidth=$anscount; $cellwidth=round(( 50 / $cellwidth ) , 1); $answer = "\n\n\n" . "\t\n" . "\t\n"; $odd_even = ''; for( $c = 0 ; $c < $anscount ; ++$c ) { $odd_even = alternation($odd_even); $answer .= "\n"; } $answer .= "\t\n\n" . "\t\n" . "\n" . "\t\n"; while ($ansrow = $ansresult->read()) { $anscode[]=$ansrow['title']; $answers[]=dTexts__run($ansrow['question']); } $trbc = ''; $odd_even = ''; for ($_i=0;$_igetConfig('surveyID')][$myfname] == "") ) { $ld = "{$ld}"; } $odd_even = alternation($odd_even); $answer .= "\t\n"; } unset($trbc); $answer .= "\n\t\n\n\t\n"; $ansrowcount=0; $ansrowtotallength=0; foreach($ansresult->readAll() as $ansrow) { $ansrowcount++; $ansrowtotallength=$ansrowtotallength+strlen($ansrow['question']); } $percwidth=100 - ($cellwidth*$anscount); foreach($labels as $ansrow) { $answer .= "\n" . "\t\n"; foreach ($anscode as $ld) { //if (!isset($trbc) || $trbc == 'array1') {$trbc = 'array2';} else {$trbc = 'array1';} $myfname=$ia[1].$ld; $answer .= "\t\n"; } unset($trbc); $answer .= "\n"; $fn++; } $answer .= "\t\n
     $ld
    {$ansrow['answer']}\n" . "\n\t
    \n"; foreach($anscode as $ld) { $myfname=$ia[1].$ld; $answer .= '\n"; $inputnames[]=$myfname; } } else { $answer = '

    '.$clang->gT('Error: There are no answers defined for this question.')."

    "; $inputnames=""; } } else { $answer = "

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

    \n"; $inputnames = ''; } return array($answer, $inputnames); } // --------------------------------------------------------------- // TMSW TODO - Can remove DB query by passing in answer list from EM function do_array_dual($ia) { global $thissurvey; global $notanswered; $repeatheadings = Yii::app()->getConfig("repeatheadings"); $minrepeatheadings = Yii::app()->getConfig("minrepeatheadings"); $extraclass =""; $answertypeclass = ""; // Maybe not $clang = Yii::app()->lang; $checkconditionFunction = "checkconditions"; $inputnames=array(); $labelans1=array(); $labelans=array(); $qquery = "SELECT other FROM {{questions}} WHERE qid=".$ia[0]." AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."'"; $other = reset(dbExecuteAssoc($qquery)->read()); //Checked $lquery = "SELECT * FROM {{answers}} WHERE scale_id=0 AND qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY sortorder, code"; $lquery1 = "SELECT * FROM {{answers}} WHERE scale_id=1 AND qid={$ia[0]} AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY sortorder, code"; $aQuestionAttributes = getQuestionAttributeValues($ia[0], $ia[4]); if ($aQuestionAttributes['use_dropdown']==1) { $useDropdownLayout = true; $extraclass .=" dropdown-list"; $answertypeclass .=" dropdown"; } else { $useDropdownLayout = false; $extraclass .=" radio-list"; $answertypeclass .=" radio"; } if (trim($aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $leftheader= $clang->gT($aQuestionAttributes['dualscale_headerA'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]); } else { $leftheader =''; } if (trim($aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { $rightheader= $clang->gT($aQuestionAttributes['dualscale_headerB'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]); } else { $rightheader =''; } $lresult = dbExecuteAssoc($lquery); //Checked if ($useDropdownLayout === false && $lresult->count() > 0) { if (trim($aQuestionAttributes['answer_width'])!='') { $answerwidth=$aQuestionAttributes['answer_width']; } else { $answerwidth=20; } $columnswidth = 100 - $answerwidth; foreach ($lresult->readAll() as $lrow) { $labelans[]=$lrow['answer']; $labelcode[]=$lrow['code']; } $lresult1 = dbExecuteAssoc($lquery1); //Checked if ($lresult1->count() > 0) { foreach ($lresult1->readAll() as $lrow1) { $labelans1[]=$lrow1['answer']; $labelcode1[]=$lrow1['code']; } } $numrows=count($labelans) + count($labelans1); if ($ia[6] != "Y" && SHOW_NO_ANSWER == 1) {$numrows++;} $cellwidth=$columnswidth/$numrows; $cellwidth=sprintf("%02d", $cellwidth); $ansquery = "SELECT question FROM {{questions}} WHERE parent_qid=".$ia[0]." and scale_id=0 AND question like '%|%'"; $ansresult = dbExecuteAssoc($ansquery); //Checked if ($ansresult->count()>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 if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY ".dbRandom(); } else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' and scale_id=0 ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count(); $fn=1; // unselect second scale when using "no answer" $answer = "\n"; // Header row and colgroups $mycolumns = "\t\n" ."\t\n"; $myheader2 = "\n\n" . "\t \n\n"; $odd_even = ''; foreach ($labelans as $ld) { $myheader2 .= "\t".$ld."\n"; $odd_even = alternation($odd_even); $mycolumns .= "\n"; } $mycolumns .= "\t\n"; if (count($labelans1)>0) // if second label set is used { $mycolumns .= "\t\n" . "\t\n"; $myheader2 .= "\n\t \n\n"; // Separator foreach ($labelans1 as $ld) { $myheader2 .= "\t".$ld."\n"; $odd_even = alternation($odd_even); $mycolumns .= "\n"; } } if ($right_exists) { $myheader2 .= "\t \n"; $mycolumns .= "\n\t\n\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory and we can show "no answer" { $myheader2 .= "\t \n"; // Separator $myheader2 .= "\t".$clang->gT('No answer')."\n"; $odd_even = alternation($odd_even); $mycolumns .= "\n\t\n\n"; $mycolumns .= "\t\n"; } $mycolumns .= "\t\n"; $myheader2 .= "\n"; // build first row of header if needed if ($leftheader != '' || $rightheader !='') { $myheader1 = "\n" . "\t \n" . "\t$leftheader\n"; if (count($labelans1)>0) { $myheader1 .= "\t \n" // Separator ."\t$rightheader\n"; } if ($right_exists) { $myheader1 .= "\t \n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) { $myheader1 .= "\t \n"; // Separator $myheader1 .= "\t \n"; } $myheader1 .= "\n"; } else { $myheader1 = ''; } $answer .= "\n\n" . $mycolumns . "\n\t\n" . $myheader1 . $myheader2 . "\n\t\n" . "\n"; $trbc = ''; foreach ($ansresult->readAll() as $ansrow) { // Build repeat headings if needed if (isset($repeatheadings) && $repeatheadings > 0 && ($fn-1) > 0 && ($fn-1) % $repeatheadings == 0) { if ( ($anscount - $fn + 1) >= $minrepeatheadings ) { $answer .= "\n";// Close actual body and open another one $answer .= "\n\n" . "\t\n"; foreach ($labelans as $ld) { $answer .= "\t\n"; } if (count($labelans1)>0) // if second label set is used { $answer .= "\n"; // Separator foreach ($labelans1 as $ld) { $answer .= "\t\n"; } } if ($right_exists) { $answer .= "\t\n"; } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory and we can show "no answer" { $answer .= "\t\n"; // Separator $answer .= "\t\n"; } $answer .= "\n"; } } $trbc = alternation($trbc , 'row'); $answertext=dTexts__run($ansrow['question']); $answertextsave=$answertext; $dualgroup=0; $myfname0= $ia[1].$ansrow['title']; $myfname = $ia[1].$ansrow['title'].'#0'; $myfname1 = $ia[1].$ansrow['title'].'#1'; // new multi-scale-answer /* 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 ($ia[6]=='Y' && (is_array($notanswered)) && ((array_search($myfname, $notanswered) !== FALSE) || (array_search($myfname1, $notanswered) !== FALSE)) && (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '') || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname1] == '')) ) { $answertext = "{$answertext}"; } // Get array_filter stuff list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname0, $trbc, $myfname,"tr","$trbc answers-list radio-list"); $answer .= $htmltbody2; if (strpos($answertext,'|')) {$answertext=substr($answertext,0, strpos($answertext,'|'));} array_push($inputnames,$myfname); $answer .= "\t\n"; $hiddenanswers=''; $thiskey=0; foreach ($labelcode as $ld) { $answer .= "\t\n"; $thiskey++; } if (count($labelans1)>0) // if second label set is used { $dualgroup++; $hiddenanswers=''; $answer .= "\t\n"; // separator array_push($inputnames,$myfname1); $hiddenanswers .= "getConfig('surveyID')][$myfname1])) {$hiddenanswers .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname1];} $hiddenanswers .= "\" />\n"; $thiskey=0; foreach ($labelcode1 as $ld) // second label set { $answer .= "\t\n"; $thiskey++; } } if (strpos($answertextsave,'|')) { $answertext=substr($answertextsave,strpos($answertextsave,'|')+1); $answer .= "\t\n"; $hiddenanswers = ''; } elseif ($right_exists) { $answer .= "\t\n"; } if ($ia[6] != "Y" && SHOW_NO_ANSWER == 1) { $answer .= "\t\n"; // separator $answer .= "\t\n"; // --> END NEW FEATURE - SAVE } $answer .= "\n"; // $inputnames[]=$myfname; //IF a MULTIPLE of flexi-redisplay figure, repeat the headings $fn++; } $answer .= "\t\n"; $answer .= "
     ".$ld." ".$ld."  ".$clang->gT('No answer')."
    \n" . $hiddenfield . "$answertext\n" . "getConfig('surveyID')][$myfname])) {$answer .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname];} $answer .= "\" />\n\t\n" . "\n"; // --> END NEW FEATURE - SAVE $answer .= "\n\t \n"; if ($hiddenanswers!='') { $answer .=$hiddenanswers; $hiddenanswers=''; } $answer .= "\n"; // --> END NEW FEATURE - SAVE $answer .= "\t$answertext  \n" . "\n" . "\t
    \n"; } elseif ($useDropdownLayout === true && $lresult->count() > 0) { if (trim($aQuestionAttributes['answer_width'])!='') { $answerwidth=$aQuestionAttributes['answer_width']; } else { $answerwidth=20; } $separatorwidth=(100-$answerwidth)/10; $columnswidth=100-$answerwidth-($separatorwidth*2); $answer = ""; // Get Answers //question atribute random_order set? if ($aQuestionAttributes['random_order']==1) { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] and scale_id=0 AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } //no question attributes -> order by sortorder else { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] and scale_id=0 AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY question_order"; } $ansresult = dbExecuteAssoc($ansquery); //Checked $anscount = $ansresult->count(); if ($anscount==0) { $inputnames = array(); $answer .="\n

    ".$clang->gT('Error: This question has no answers.')."

    \n"; } else { //already done $lresult = dbExecuteAssoc($lquery); foreach ($lresult->readAll() as $lrow) { $labels0[]=Array('code' => $lrow['code'], 'title' => $lrow['answer']); } $lresult1 = dbExecuteAssoc($lquery1); //Checked foreach ($lresult1->readAll() as $lrow1) { $labels1[]=Array('code' => $lrow1['code'], 'title' => $lrow1['answer']); } // Get attributes for Headers and Prefix/Suffix if (trim($aQuestionAttributes['dropdown_prepostfix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']])!='') { list ($ddprefix, $ddsuffix) =explode("|",$aQuestionAttributes['dropdown_prepostfix'][$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']]); $ddprefix = $ddprefix; $ddsuffix = $ddsuffix; } else { $ddprefix =''; $ddsuffix=''; } if (trim($aQuestionAttributes['dropdown_separators'])!='') { list ($postanswSep, $interddSep) =explode('|',$aQuestionAttributes['dropdown_separators']); $postanswSep = $postanswSep; $interddSep = $interddSep; } else { $postanswSep = ''; $interddSep = ''; } $colspan_1 = ''; $colspan_2 = ''; $suffix_cell = ''; $answer .= "\n\n\n" . "\t\n"; if($ddprefix != '') { $answer .= "\t\n"; $colspan_1 = ' colspan="2"'; } $answer .= "\t\n"; if($ddsuffix != '') { $answer .= "\t\n"; if(!empty($colspan_1)) { $colspan_2 = ' colspan="3"'; } $suffix_cell = "\t\n"; // suffix } $answer .= "\t\n"; if($ddprefix != '') { $answer .= "\t\n"; } $answer .= "\t\n"; if($ddsuffix != '') { $answer .= "\t\n"; }; // headers $answer .= "\n\t\n" . "\n" . "\t \n" // prefix . "\n" // . "\t\n" . "\t\n" . "\n" . "\t \n" // suffix // Inter DD separator // prefix // . "\t\n" . "\t\n" . $suffix_cell."\n" . "\t\n\n"; $answer .= "\n\n"; $trbc = ''; foreach ($ansresult->readAll() as $ansrow) { $rowname = $ia[1].$ansrow['title']; $dualgroup=0; $myfname = $ia[1].$ansrow['title']."#".$dualgroup; $dualgroup1=1; $myfname1 = $ia[1].$ansrow['title']."#".$dualgroup1; if ($ia[6]=='Y' && (is_array($notanswered)) && ((array_search($myfname, $notanswered) !== FALSE) || (array_search($myfname1, $notanswered) !== FALSE)) && (($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '') || ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname1] == '')) ) { $answertext="".dTexts__run($ansrow['question']).""; } else { $answertext=dTexts__run($ansrow['question']); } $trbc = alternation($trbc , 'row'); // Get array_filter stuff list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $rowname, $trbc, $myfname,"tr","$trbc subquestion-list questions-list dropdown-list"); $answer .= $htmltbody2; $answer .= "\t\n"; // Label0 // prefix if($ddprefix != '') { $answer .= "\t\n"; } $answer .= "\t\n"; } $answer .= "getConfig('surveyID')][$myfname])) { $answer .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]; } $answer .= "\" />\n" . "\t\n"; $inputnames[]=$myfname; $answer .= "\t\n"; //Separator // Label1 // prefix if($ddprefix != '') { $answer .= "\t\n"; } // $answer .= "\t\n"; } $answer .= "getConfig('surveyID')][$myfname1])) { $answer .= $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname1]; } $answer .= "\" />\n" . "\t\n"; $inputnames[]=$myfname1; $answer .= "\n"; } } // End there are answers $answer .= "\t\n"; $answer .= "
     
    $leftheader$leftheader$rightheader$rightheader
    \n" . "\n" . "\t$ddprefix\n" . "\n"; // suffix if($ddsuffix != '') { $answer .= "\t$ddsuffix$interddSep$ddprefix\n" $answer .= "\t\n" . "\n"; // suffix if($ddsuffix != '') { $answer .= "\t$ddsuffix
    \n"; } else { $answer = "

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

    \n"; $inputnames=""; } return array($answer, $inputnames); }