diff --git a/common_functions.php b/common_functions.php index 668166d3ee8..ad30c7ff362 100644 --- a/common_functions.php +++ b/common_functions.php @@ -7582,15 +7582,26 @@ function aGetFullResponseTable($iSurveyID, $iResponseID, $sLanguageCode, $bHonor if ($oldgid !== $fname['gid']) { $oldgid = $fname['gid']; - $aResultTable['gid_'.$fname['gid']]=array($fname['group_name']); + if (!$bHonorConditions || checkgroupfordisplay($fname['gid'])) + { + $aResultTable['gid_'.$fname['gid']]=array($fname['group_name']); + } } } if (isset($fname['qid']) && !empty($fname['qid'])) { + if ($bHonorConditions) + { + $isQuestionVisible=checkquestionfordisplay($fname['qid'],null); + } + else + { + $isQuestionVisible=true; + } if ($oldqid !== $fname['qid']) { $oldqid = $fname['qid']; - if (($bHonorConditions && checkquestionfordisplay($fname['qid'],null)) || !$bHonorConditions) + if ($isQuestionVisible) { if (isset($fname['subquestion']) || isset($fname['subquestion1']) || isset($fname['subquestion2'])) { @@ -7625,9 +7636,12 @@ function aGetFullResponseTable($iSurveyID, $iResponseID, $sLanguageCode, $bHonor if (isset($fname['subquestion2'])) $subquestion .= "[{$fname['subquestion2']}]"; + if ($isQuestionVisible) + { + $answer=getextendedanswer($fname['fieldname'], $idrow[$fname['fieldname']]); + $aResultTable[$fname['fieldname']]=array('',$subquestion,$answer); + } - $answer=getextendedanswer($fname['fieldname'], $idrow[$fname['fieldname']]); - $aResultTable[$fname['fieldname']]=array('',$subquestion,$answer); } return $aResultTable; } @@ -7809,4 +7823,63 @@ function fixSubquestions() } +function checkgroupfordisplay($gid) +{ + //This function checks all the questions in a group to see if they have + //conditions, and if the do - to see if the conditions are met. + //If none of the questions in the group are set to display, then + //the function will return false, to indicate that the whole group + //should not display at all. + global $dbprefix, $connect; + $countQuestionsInThisGroup=0; + $countConditionalQuestionsInThisGroup=0; + foreach ($_SESSION['fieldarray'] as $ia) //Run through all the questions + + { + if ($ia[5] == $gid) //If the question is in the group we are checking: + + { + // Check if this question is hidden + $qidattributes=getQuestionAttributes($ia[0]); + if ($qidattributes!==false && $qidattributes['hidden']==0) + { + $countQuestionsInThisGroup++; + if ($ia[7] == "Y") //This question is conditional + + { + $countConditionalQuestionsInThisGroup++; + $QuestionsWithConditions[]=$ia; //Create an array containing all the conditional questions + } + } + } + } + if ($countQuestionsInThisGroup===0) + { + return false; + } + elseif ($countQuestionsInThisGroup != $countConditionalQuestionsInThisGroup || !isset($QuestionsWithConditions) ) + { + //One of the questions in this group is NOT conditional, therefore + //the group MUST be displayed + return true; + } + else + { + //All of the questions in this group are conditional. Now we must + //check every question, to see if the condition for each has been met. + //If 1 or more have their conditions met, then the group should + //be displayed. + foreach ($QuestionsWithConditions as $cc) + { + if (checkquestionfordisplay($cc[0], $gid) === true) + { + return true; + } + } + //Since we made it this far, there mustn't have been any conditions met. + //Therefore the group should not be displayed. + return false; + } +} + // Closing PHP tag intentionally omitted - yes, it is okay diff --git a/index.php b/index.php index 6fbe4374829..2e221855694 100644 --- a/index.php +++ b/index.php @@ -1173,64 +1173,6 @@ function makelanguagechanger() } -function checkgroupfordisplay($gid) -{ - //This function checks all the questions in a group to see if they have - //conditions, and if the do - to see if the conditions are met. - //If none of the questions in the group are set to display, then - //the function will return false, to indicate that the whole group - //should not display at all. - global $dbprefix, $connect; - $countQuestionsInThisGroup=0; - $countConditionalQuestionsInThisGroup=0; - foreach ($_SESSION['fieldarray'] as $ia) //Run through all the questions - - { - if ($ia[5] == $gid) //If the question is in the group we are checking: - - { - // Check if this question is hidden - $qidattributes=getQuestionAttributes($ia[0]); - if ($qidattributes!==false && $qidattributes['hidden']==0) - { - $countQuestionsInThisGroup++; - if ($ia[7] == "Y") //This question is conditional - - { - $countConditionalQuestionsInThisGroup++; - $QuestionsWithConditions[]=$ia; //Create an array containing all the conditional questions - } - } - } - } - if ($countQuestionsInThisGroup===0) - { - return false; - } - elseif ($countQuestionsInThisGroup != $countConditionalQuestionsInThisGroup || !isset($QuestionsWithConditions) ) - { - //One of the questions in this group is NOT conditional, therefore - //the group MUST be displayed - return true; - } - else - { - //All of the questions in this group are conditional. Now we must - //check every question, to see if the condition for each has been met. - //If 1 or more have their conditions met, then the group should - //be displayed. - foreach ($QuestionsWithConditions as $cc) - { - if (checkquestionfordisplay($cc[0], $gid) === true) - { - return true; - } - } - //Since we made it this far, there mustn't have been any conditions met. - //Therefore the group should not be displayed. - return false; - } -} function checkconfield($value) { diff --git a/qanda.php b/qanda.php index d3369c28aa1..1d3ded033e3 100644 --- a/qanda.php +++ b/qanda.php @@ -1,17 +1,17 @@ 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* - */ +* Let's explain what this strange $ia var means +* +* The $ia string comes from the $_SESSION['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['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* +*/ if($shownoanswer > 0 && $thissurvey['shownoanswer'] != 'N') { @@ -127,7 +127,7 @@ function retrieveConditionInfo($ia) foreach ($conditions as $condkey => $condarr) { // We need to sort the merged array by Ascending scenario, cqid, then cfieldname - // otherwise condition evaluations of Tokens in Scenarii won't work in "live" Javascript eval + // otherwise condition evaluations of Tokens in Scenarii won't work in "live" Javascript eval $scenariolist[$condkey] = $condarr[7]; $cqidlist[$condkey] = $condarr[1]; $cfieldnamelist[$condkey] = $condarr[2]; @@ -157,7 +157,7 @@ function retrieveJSidname($cd,$currentgid=null) if (preg_match("/^\+{0,1}[0-9]+X([0-9]+)X(.*)$/",$cd[2]) == 0) { // This is not a true fieldname (for instance a {TOKEN:ATTR..} - // placeholder + // placeholder return "NoJSidname"; } //preg_match("/^[0-9]+X([0-9]+)X([0-9]+)$/",$cd[2],$matchFields); @@ -177,12 +177,12 @@ function retrieveJSidname($cd,$currentgid=null) { if (!isset($currentgid) || $questiongid == $currentgid) { // if question is on same page then field is fvalue_XXXX - //$idname="fvalue_".$cd[1].substr($cd[2], strlen($cd[2])-1,1); // broken when ranking more than 9 items + //$idname="fvalue_".$cd[1].substr($cd[2], strlen($cd[2])-1,1); // broken when ranking more than 9 items $idname="fvalue_".$questionFieldpart; } else { // If question is on another page then field if javaXXXX - $idname="java$cd[2]"; + $idname="java$cd[2]"; } } elseif ($cd[4] == "5" || @@ -219,11 +219,11 @@ function retrieveJSidname($cd,$currentgid=null) { if (!isset($currentgid) || $questiongid == $currentgid) { // if question is on same page then field is answerXXXX - $idname="answer$cd[2]"; + $idname="answer$cd[2]"; } else { // If question is on another page then field if javaXXXX - $idname="java$cd[2]"; + $idname="java$cd[2]"; } } else @@ -355,20 +355,20 @@ function setman_questionandcode($ia) /** - * The point of these functions (setman) is to return an array containing two arrays. - * The first ($mandatorys) is an array containing question, so they can all be checked - * The second ($mandatoryfns) is an arry containing the fieldnames of every question - * What's the difference? The difference arises from multiple option questions, and came - * about when trying to distinguish between answering just one option (which satisfies - * the mandatory requirement, and answering them all). The "mandatorys" input contains the - * actual specific response items that could be filled in.. ie: in a multiple option - * question, there will be a unique one for every possible answer. The "mandatoryfns" array - * contains the generic question fieldname for the question as a whole (it will be repeated - * for multiple option qeustions, but won't contain unique items. - * - * @param mixed $ia - * @return array See explanation above - */ +* The point of these functions (setman) is to return an array containing two arrays. +* The first ($mandatorys) is an array containing question, so they can all be checked +* The second ($mandatoryfns) is an arry containing the fieldnames of every question +* What's the difference? The difference arises from multiple option questions, and came +* about when trying to distinguish between answering just one option (which satisfies +* the mandatory requirement, and answering them all). The "mandatorys" input contains the +* actual specific response items that could be filled in.. ie: in a multiple option +* question, there will be a unique one for every possible answer. The "mandatoryfns" array +* contains the generic question fieldname for the question as a whole (it will be repeated +* for multiple option qeustions, but won't contain unique items. +* +* @param mixed $ia +* @return array See explanation above +*/ function setman_multiflex($ia) { @@ -377,12 +377,12 @@ function setman_multiflex($ia) $mandatorys=array(); $mandatoryfns=array(); $ansquery = "SELECT * FROM {$dbprefix}questions - WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=0 - ORDER BY question_order, title"; + WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=0 + ORDER BY question_order, title"; $ansresult = db_execute_assoc($ansquery); $ans2query = "SELECT * FROM {$dbprefix}questions - WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=1 - ORDER BY question_order, title"; + WHERE parent_qid={$ia[0]} AND language='".$_SESSION['s_lang']."' and scale_id=1 + ORDER BY question_order, title"; $ans2result = db_execute_assoc($ans2query); while ($ans2row=$ans2result->FetchRow()) @@ -453,29 +453,29 @@ function setman_questionandcode_multiscale($ia) // Get Subquestions $subquery="SELECT * " - ."FROM {$dbprefix}questions " - ."WHERE parent_qid={$ia[0]} " - ."AND language='".$_SESSION['s_lang']."' " - ."ORDER BY question_order"; + ."FROM {$dbprefix}questions " + ."WHERE parent_qid={$ia[0]} " + ."AND language='".$_SESSION['s_lang']."' " + ."ORDER BY question_order"; $subresult = db_execute_assoc($subquery); //Checked // Get Answer Scale 1 $ans1query="SELECT qid " - ."FROM {$dbprefix}answers " - ."WHERE qid={$ia[0]} " - ."AND scale_id=0 " - ."AND language='".$_SESSION['s_lang']."' " - ."ORDER BY sortorder"; + ."FROM {$dbprefix}answers " + ."WHERE qid={$ia[0]} " + ."AND scale_id=0 " + ."AND language='".$_SESSION['s_lang']."' " + ."ORDER BY sortorder"; $ans1result = db_execute_assoc($ans1query); //Checked $ans1count = $ans1result->RowCount(); // Get Answer Scale 2 $ans2query="SELECT qid " - ."FROM {$dbprefix}answers " - ."WHERE qid={$ia[0]} " - ."AND scale_id=1 " - ."AND language='".$_SESSION['s_lang']."' " - ."ORDER BY sortorder"; + ."FROM {$dbprefix}answers " + ."WHERE qid={$ia[0]} " + ."AND scale_id=1 " + ."AND language='".$_SESSION['s_lang']."' " + ."ORDER BY sortorder"; $ans2result = db_execute_assoc($ans2query); //Checked $ans2count = $ans2result->RowCount(); @@ -515,16 +515,16 @@ function setman_questionandcode_multiscale($ia) } /** - * This function returns an array containing the "question/answer" html display - * and a list of the question/answer fieldnames associated. It is called from - * question.php, group.php or survey.php - * - * @param mixed $ia - * @param mixed $notanswered - * @param mixed $notvalidated - * @param mixed $filenotvalidated - * @return mixed - */ +* This function returns an array containing the "question/answer" html display +* and a list of the question/answer fieldnames associated. It is called from +* question.php, group.php or survey.php +* +* @param mixed $ia +* @param mixed $notanswered +* @param mixed $notvalidated +* @param mixed $filenotvalidated +* @return mixed +*/ function retrieveAnswers($ia, $notanswered=null, $notvalidated=null, $filenotvalidated=null) { //globalise required config variables @@ -561,7 +561,7 @@ function retrieveAnswers($ia, $notanswered=null, $notvalidated=null, $filenotval $number = isset($ia[9]) ? $ia[9] : ''; $question_text = array( - 'all' => '' // All has been added for backwards compatibility with templates that use question_start.pstpl (now redundant) + 'all' => '' // All has been added for backwards compatibility with templates that use question_start.pstpl (now redundant) ,'text' => $qtitle ,'code' => $ia[2] ,'number' => $number @@ -942,7 +942,7 @@ function validation_message($ia) $help=' '.$helprow['help'].''; } $qtitle .= '
'.$clang->gT('This question must be answered correctly').'.'.$help.'
-'; + '; } } @@ -960,7 +960,7 @@ function file_validation_message($ia) foreach ($filenotvalidated as $k => $v) { if ($ia[1] == $k || strpos($k, "_") && $ia[1] == substr(0, strpos($k, "_") - 1)); - $qtitle .= '
'.$clang->gT($filenotvalidated[$k]).'
'; + $qtitle .= '
'.$clang->gT($filenotvalidated[$k]).'
'; } } return $qtitle; @@ -979,16 +979,16 @@ function mandatory_popup($ia, $notanswered=null) if (!isset($mandatorypopup) && ($ia[4] == 'T' || $ia[4] == 'S' || $ia[4] == 'U')) { $popup="\n"; + \n + \n"; $mandatorypopup="Y"; }else { $popup="\n"; + \n + \n"; $mandatorypopup="Y"; } return array($mandatorypopup, $popup); @@ -1013,9 +1013,9 @@ function validation_popup($ia, $notvalidated=null) if (!isset($validationpopup)) { $vpopup="\n"; + \n + \n"; $validationpopup="Y"; } return array($validationpopup, $vpopup); @@ -1037,9 +1037,9 @@ function file_validation_popup($ia, $filenotvalidated = null) if (!isset($filevalidationpopup)) { $fpopup="\n"; + \n + \n"; $filevalidationpopup = "Y"; } return array($filevalidationpopup, $fpopup); @@ -1052,7 +1052,7 @@ function return_timer_script($qidattributes, $ia, $disable=null) { global $thissurvey, $clang; /* The following lines cover for previewing questions, because no $_SESSION['fieldarray'] exists. - This just stops error messages occuring */ + This just stops error messages occuring */ if(!isset($_SESSION['fieldarray'])) { $_SESSION['fieldarray'] = array(); @@ -1092,84 +1092,84 @@ function return_timer_script($qidattributes, $ia, $disable=null) { $time_limit_warning_2_message=str_replace("{TIME}", "
", $time_limit_warning_2_message); $time_limit_warning_2_display_time=trim($qidattributes['time_limit_warning_2_display_time']) != '' ? $qidattributes['time_limit_warning_2_display_time']+1 : 0; $time_limit_message_style=trim($qidattributes['time_limit_message_style']) != '' ? $qidattributes['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;"; + 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($qidattributes['time_limit_warning_style']) != '' ? $qidattributes['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;"; + 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($qidattributes['time_limit_warning_2_style']) != '' ? $qidattributes['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;"; + 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($qidattributes['time_limit_timer_style']) != '' ? $qidattributes['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;"; + 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[$timersessionname])) { $time_limit=$_SESSION[$timersessionname]; } $output = " - - \n"; + + \n"; if($thissurvey['timercount'] < 2) { $output .=" - "; + "; $output .= " - "; + if(warning > 0 && timeleft<=warning) { + var wsecs=warning%60; + if(wsecs<10) wsecs='0' + wsecs; + var WT1 = (warning - wsecs) / 60; + var wmins = WT1 % 60; if (wmins < 10) wmins = '0' + wmins; + var whours = (WT1 - wmins) / 60; + var dmins='' + var dhours='' + var dsecs='' + if (whours < 10) whours = '0' + whours; + if (whours > 0) dhours = whours + ' ".$clang->gT('hours').", '; + if (wmins > 0) dmins = wmins + ' ".$clang->gT('mins').", '; + if (wsecs > 0) dsecs = wsecs + ' ".$clang->gT('seconds')."'; + if(document.getElementById(warningtimedisplay) !== null) { + document.getElementById(warningtimedisplay).innerHTML = dhours+dmins+dsecs; + } + document.getElementById(warningdisplay).style.display=''; + } + if(warning2 > 0 && timeleft<=warning2) { + var w2secs=warning2%60; + if(wsecs<10) w2secs='0' + wsecs; + var W2T1 = (warning2 - w2secs) / 60; + var w2mins = W2T1 % 60; if (w2mins < 10) w2mins = '0' + w2mins; + var w2hours = (W2T1 - w2mins) / 60; + var d2mins='' + var d2hours='' + var d2secs='' + if (w2hours < 10) w2hours = '0' + w2hours; + if (w2hours > 0) d2hours = w2hours + ' ".$clang->gT('hours').", '; + if (w2mins > 0) d2mins = w2mins + ' ".$clang->gT('mins').", '; + if (w2secs > 0) d2secs = w2secs + ' ".$clang->gT('seconds')."'; + if(document.getElementById(warning2timedisplay) !== null) { + document.getElementById(warning2timedisplay).innerHTML = dhours+dmins+dsecs; + } + document.getElementById(warning2display).style.display=''; + } + if(warning > 0 && warninghide > 0 && document.getElementById(warningdisplay).style.display != 'none') { + if(warninghide == 1) { + document.getElementById(warningdisplay).style.display='none'; + warning=0; + } + warninghide--; + } + if(warning2 > 0 && warning2hide > 0 && document.getElementById(warning2display).style.display != 'none') { + if(warning2hide == 1) { + document.getElementById(warning2display).style.display='none'; + warning2=0; + } + warning2hide--; + } + var secs = timeleft % 60; + if (secs < 10) secs = '0'+secs; + var T1 = (timeleft - secs) / 60; + var mins = T1 % 60; if (mins < 10) mins = '0'+mins; + var hours = (T1 - mins) / 60; + if (hours < 10) hours = '0'+hours; + var d2hours=''; + var d2mins=''; + var d2secs=''; + if (hours > 0) d2hours = hours+' ".$clang->gT('hours').": '; + if (mins > 0) d2mins = mins+' ".$clang->gT('mins').": '; + if (secs > 0) d2secs = secs+' ".$clang->gT('seconds')."'; + if (secs < 1) d2secs = '0 ".$clang->gT('seconds')."'; + document.getElementById(timerdisplay).innerHTML = '".$time_limit_countdown_message."
'+d2hours + d2mins + d2secs; + if (timeleft>0){ + var text='countdown('+questionid+', '+timeleft+', '+action+', '+warning+', '+warning2+', '+warninghide+', '+warning2hide+', \"'+disable+'\")'; + setTimeout(text,1000); + } else { + //Countdown is finished, now do action + switch(action) { + case 2: //Just move on, no warning + if(document.getElementById('movenextbtn') !== null) { + if(document.getElementById('movenextbtn').disabled==true) document.getElementById('movenextbtn').disabled=false; + } + if(document.getElementById('moveprevbtn') !== null) { + if(document.getElementById('moveprevbtn').disabled==true && '$disable_prev' > 0) document.getElementById('moveprevbtn').disabled=false; + } + freezeFrame(disable); + subcookiejar.crumble('limesurvey_timers', timersessionname); + if(document.getElementById('movenextbtn') != null) { + document.limesurvey.submit(); + } else { + setTimeout(\"document.limesurvey.submit();\", 1000); + } + break; + case 3: //Just warn, don't move on + document.getElementById(expireddisplay).style.display=''; + if(document.getElementById('movenextbtn') !== null) { + if(document.getElementById('movenextbtn').disabled==true) document.getElementById('movenextbtn').disabled=false; + } + if(document.getElementById('moveprevbtn') !== null) { + if(document.getElementById('moveprevbtn').disabled==true && '$disable_prev' > 0) document.getElementById('moveprevbtn').disabled=false; + } + freezeFrame(disable); + this.onsubmit=function() {subcookiejar.crumble('limesurvey_timers', timersessionname);}; + break; + default: //Warn and move on + document.getElementById(expireddisplay).style.display=''; + if(document.getElementById('movenextbtn') !== null) { + if(document.getElementById('movenextbtn').disabled==true) document.getElementById('movenextbtn').disabled=false; + } + if(document.getElementById('moveprevbtn') !== null) { + if(document.getElementById('moveprevbtn').disabled==true && '$disable_prev' > 0) document.getElementById('moveprevbtn').disabled=false; + } + freezeFrame(disable); + subcookiejar.crumble('limesurvey_timers', timersessionname); + setTimeout('document.limesurvey.submit()', ".$time_limit_message_delay."); + break; + } + } + } + //--> + "; } $output .= "
".$time_limit_message."
\n\n"; @@ -1352,18 +1352,18 @@ function countdown(questionid,timer,action,warning,warning2,warninghide,warning2 $output .= "
\n\n"; //Call the countdown script $output .= "\n\n"; + $(document).ready(function() { + countdown(".$ia[0].", ".$time_limit.", ".$time_limit_action.", ".$time_limit_warning.", ".$time_limit_warning_2.", ".$time_limit_warning_display_time.", ".$time_limit_warning_2_display_time.", '".$disable."'); + }); + \n\n"; return $output; } function return_array_filter_selected($ia, $qidattributes, $thissurvey, $ansrow, $rowname, $trbc='', $valuename, $method="tbody", $class=null) // function which returns TRUE if the given $ansrow contains a row which is selected, ie, not filtered out in previous answer { - $filter_select = TRUE; - if + $filter_select = TRUE; + if ( (trim($qidattributes['array_filter'])!='' && // The array filter attribute is set $thissurvey['format'] == 'S' // and the survey is being presented in question-by-question mode @@ -1378,17 +1378,17 @@ function return_array_filter_selected($ia, $qidattributes, $thissurvey, $ansrow, if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; if (!empty($selected) && !in_array($ansrow['title'],$selected)) { - $filter_select = FALSE; - } - else - { - $filter_select = TRUE; - } - } + $filter_select = FALSE; + } + else + { + $filter_select = TRUE; + } + } - if + if (isset($qidattributes['array_filter_exclude']) && - ( + ( (trim($qidattributes['array_filter_exclude'])!='' && $thissurvey['format'] == 'S' ) || @@ -1396,21 +1396,21 @@ function return_array_filter_selected($ia, $qidattributes, $thissurvey, $ansrow, $thissurvey['format'] == 'G' && getArrayFiltersExcludesOutGroup($ia[0]) == true ) - ) + ) ) { $selected = getArrayFilterExcludesForQuestion($ia[0]); if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; if (!empty($selected) && !in_array($ansrow['title'],$selected)) { - $filter_select = TRUE; - } - else - { - $filter_select = FALSE; - } - } - return $filter_select; + $filter_select = TRUE; + } + else + { + $filter_select = FALSE; + } + } + return $filter_select; } function return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $rowname, $trbc='', $valuename, $method="tbody", $class=null) { @@ -1425,11 +1425,11 @@ function return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, function return_array_filter_include_strings($ia, $qidattributes, $thissurvey, $ansrow, $rowname, $trbc='', $valuename, $method="tbody", $class=null) { /* DO ARRAY_FILTER ATTRIBUTE - We set the $hiddenfield for each answer, and the value of this is available to java to let javascripts - know whether each answer is currently being displayed. $htmltbody2 determines whether the answer row - should be displayed initially. If no answers for the source question have been selected then the whole - answer row should start in the display-off position for array_filter or the display-on position - for array_filter_exclude. */ + We set the $hiddenfield for each answer, and the value of this is available to java to let javascripts + know whether each answer is currently being displayed. $htmltbody2 determines whether the answer row + should be displayed initially. If no answers for the source question have been selected then the whole + answer row should start in the display-off position for array_filter or the display-on position + for array_filter_exclude. */ //Are we doing array_filter, or array_filter_exclude. Where a conflict occurs, do array_filter @@ -1449,32 +1449,32 @@ function return_array_filter_include_strings($ia, $qidattributes, $thissurvey, $ $htmltbody2 .= ($class !== null) ? " class='$class'": ""; $htmltbody2 .= ">\n"; if($ia[4]=="1") { - //This is an array dual scale question and we have to massage the tbidpslay rowname + //This is an array dual scale question and we have to massage the tbidpslay rowname $hiddenfield = "\n"; $hiddenfield .= "\n"; } else { $hiddenfield = "\n"; } } else if - ( - (trim($qidattributes['array_filter'])!='' && // The array filter attribute is set - $thissurvey['format'] == 'S' // and the survey is being presented in question-by-question mode - ) || // OR - (trim($qidattributes['array_filter'])!='' && // The array filter attribute is set - $thissurvey['format'] == 'G' && // and the survey is being presented in group-by-group mode - getArrayFiltersOutGroup($ia[0]) == true // and the source question for the array filter is in a different group than this question - ) - ) - { - $selected = getArrayFiltersForQuestion($ia[0]); - if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; - if (!empty($selected) && !in_array($ansrow['title'],$selected)) + ( + (trim($qidattributes['array_filter'])!='' && // The array filter attribute is set + $thissurvey['format'] == 'S' // and the survey is being presented in question-by-question mode + ) || // OR + (trim($qidattributes['array_filter'])!='' && // The array filter attribute is set + $thissurvey['format'] == 'G' && // and the survey is being presented in group-by-group mode + getArrayFiltersOutGroup($ia[0]) == true // and the source question for the array filter is in a different group than this question + ) + ) + { + $selected = getArrayFiltersForQuestion($ia[0]); + if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; + if (!empty($selected) && !in_array($ansrow['title'],$selected)) { $htmltbody2 = "\n\n\t<$method id='javatbd$rowname' style='display: none'"; $htmltbody2 .= ($class !== null) ? " class='$class'": ""; $htmltbody2 .= ">\n"; if($ia[4]=="1") { - //This is an array dual scale question and we have to massage the tbidpslay rowname + //This is an array dual scale question and we have to massage the tbidpslay rowname $hiddenfield = "\n"; $hiddenfield .= "\n"; } else { @@ -1488,21 +1488,21 @@ function return_array_filter_include_strings($ia, $qidattributes, $thissurvey, $ $htmltbody2 .= ($class !== null) ? " class='$class'": ""; $htmltbody2 .= ">"; if($ia[4]=="1") { - //This is an array dual scale question and we have to massage the tbidpslay rowname + //This is an array dual scale question and we have to massage the tbidpslay rowname $hiddenfield = "\n"; $hiddenfield .= "\n"; } else { $hiddenfield = "\n"; + } } } - } else { $htmltbody2 = "\n\n\t<$method id='javatbd$rowname'"; $htmltbody2 .= ($class !== null) ? " class='$class'": ""; $htmltbody2 .= ">\n"; if($ia[4]=="1") { - //This is an array dual scale question and we have to massage the tbidpslay rowname + //This is an array dual scale question and we have to massage the tbidpslay rowname $hiddenfield = "\n"; $hiddenfield .= "\n"; } else { @@ -1517,10 +1517,10 @@ function return_array_filter_include_strings($ia, $qidattributes, $thissurvey, $ function return_array_filter_exclude_strings($ia, $qidattributes, $thissurvey, $ansrow, $rowname, $trbc='', $valuename, $method="tbody", $class=null) { /* DO ARRAY_FILTER_EXCLUDE ATTRIBUTE - We set the $hiddenfield for each answer, and the value of this is available to java to let javascripts - know whether each answer is currently being displayed. $htmltbody2 determines whether the answer row - should be displayed initially. If no answers for the source question have been selected then the whole - answer row should start in the display-on position. */ + We set the $hiddenfield for each answer, and the value of this is available to java to let javascripts + know whether each answer is currently being displayed. $htmltbody2 determines whether the answer row + should be displayed initially. If no answers for the source question have been selected then the whole + answer row should start in the display-on position. */ $htmltbody2 = ''; $hiddenfield= ''; @@ -1540,22 +1540,22 @@ function return_array_filter_exclude_strings($ia, $qidattributes, $thissurvey, $ $hiddenfield = "\n"; $hiddenfield .= "\n"; } else { - $hiddenfield = "\n"; + $hiddenfield = "\n"; } } else if - ( - (trim($qidattributes['array_filter_exclude'])!='' && - $thissurvey['format'] == 'S' - ) || - (trim($qidattributes['array_filter_exclude'])!='' && - $thissurvey['format'] == 'G' && - getArrayFiltersExcludesOutGroup($ia[0]) == true - ) - ) - { - $selected = getArrayFilterExcludesForQuestion($ia[0]); - if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; - if (!empty($selected) && !in_array($ansrow['title'],$selected)) + ( + (trim($qidattributes['array_filter_exclude'])!='' && + $thissurvey['format'] == 'S' + ) || + (trim($qidattributes['array_filter_exclude'])!='' && + $thissurvey['format'] == 'G' && + getArrayFiltersExcludesOutGroup($ia[0]) == true + ) + ) + { + $selected = getArrayFilterExcludesForQuestion($ia[0]); + if (isset($ansrow['code'])) $ansrow['title'] = $ansrow['code']; + if (!empty($selected) && !in_array($ansrow['title'],$selected)) { $htmltbody2 = "\n\n\t<$method id='javatbd$rowname'>\n"; if($ia[4]=="1") { @@ -1563,8 +1563,8 @@ function return_array_filter_exclude_strings($ia, $qidattributes, $thissurvey, $ $hiddenfield = "\n"; $hiddenfield .= "\n"; } else { - $hiddenfield=""; - } + $hiddenfield=""; + } } else { @@ -1574,7 +1574,7 @@ function return_array_filter_exclude_strings($ia, $qidattributes, $thissurvey, $ $hiddenfield = "\n"; $hiddenfield .= "\n"; } else { - $hiddenfield="\n"; + $hiddenfield="\n"; } $_SESSION[$valuename]=''; //Remove any saved results for this since it is no longer being displayed } @@ -1587,8 +1587,8 @@ function return_array_filter_exclude_strings($ia, $qidattributes, $thissurvey, $ $hiddenfield = "\n"; $hiddenfield .= "\n"; } else { - $hiddenfield = ""; - } + $hiddenfield = ""; + } } //End of array_filter attribute @@ -1626,7 +1626,7 @@ function do_boilerplate($ia) function do_5pointchoice($ia) { global $clang, $imageurl; - global $js_header_includes, $css_header_includes; + global $js_header_includes, $css_header_includes; if ($ia[8] == 'Y') { @@ -1638,7 +1638,7 @@ function do_5pointchoice($ia) } $qidattributes=getQuestionAttributes($ia[0],$ia[4]); //print_r($qidattributes); - $id = 'slider'.time().rand(0,100); + $id = 'slider'.time().rand(0,100); $answer = "\n\n\n"; $inputnames[]=$ia[1]; if($qidattributes['slider_rating']==1){ - $css_header_includes[]= '/admin/scripts/rating/jquery.rating.css'; - $js_header_includes[]='/admin/scripts/rating/jquery.rating.js'; - $answer.='

'; - $answer.=" - - "; + $css_header_includes[]= '/admin/scripts/rating/jquery.rating.css'; + $js_header_includes[]='/admin/scripts/rating/jquery.rating.js'; + $answer.='

'; + $answer.=" + + "; } if($qidattributes['slider_rating']==2){ - if(!IsSet($_SESSION[$ia[1]]) OR $_SESSION[$ia[1]]==''){ - $value=1; - }else{ - $value=$_SESSION[$ia[1]]; - } - $answer.=" -
-
1
2
3
4
5

-
-
-
-
-
-
- - "; + if(!IsSet($_SESSION[$ia[1]]) OR $_SESSION[$ia[1]]==''){ + $value=1; + }else{ + $value=$_SESSION[$ia[1]]; + } + $answer.=" +
+
1
2
3
4
5

+
+
+
+
+
+
+ + "; } return array($answer, $inputnames); @@ -1787,122 +1787,122 @@ function do_date($ia) // Show day select box case 'j': case 'd': $answer .= ' '; + break; + // Show month select box + case 'n': + case 'm': $answer .= ' '; + break; + // Show year select box + case 'Y': $answer .= ' '; - break; - // Show month select box - case 'n': - case 'm': $answer .= ' '; - break; - // Show year select box - case 'Y': $answer .= ' '; - break; + for ($i=$yearmax; ($reverse? $i<=$yearmin: $i>=$yearmin); $i+=$step) { + if ($i == $currentyear) + { + $i_date_selected = SELECTED; + } + else + { + $i_date_selected = ''; + } + $answer .= ' '; + } + $answer .= ''; + + break; } } $answer .= ' -

'; +

'; $answer .= ' - - '; + + '; } @@ -1910,7 +1910,7 @@ function do_date($ia) { if ($clang->langcode !== 'en') { - $js_header_includes[] = '/scripts/jquery/locale/jquery.ui.datepicker-'.$clang->langcode.'.js'; + $js_header_includes[] = '/scripts/jquery/locale/jquery.ui.datepicker-'.$clang->langcode.'.js'; } $css_header_includes[]= '/scripts/jquery/css/start/jquery-ui.css'; @@ -1945,15 +1945,15 @@ function do_date($ia) $goodchars = "0123456789".$goodchars[0]; $answer ="

- gT('Date picker')."\" size=\"10\" name=\"{$ia[1]}\" id=\"answer{$ia[1]}\" value=\"$dateoutput\" maxlength=\"10\" onkeypress=\"return goodchars(event,'".$goodchars."')\" onchange=\"$checkconditionFunction(this.value, this.name, this.type)\" /> - - - + gT('Date picker')."\" size=\"10\" name=\"{$ia[1]}\" id=\"answer{$ia[1]}\" value=\"$dateoutput\" maxlength=\"10\" onkeypress=\"return goodchars(event,'".$goodchars."')\" onchange=\"$checkconditionFunction(this.value, this.name, this.type)\" /> + + + -

-

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

"; +

+

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

"; } $inputnames[]=$ia[1]; @@ -2094,7 +2094,7 @@ function do_list_dropdown($ia) foreach ($optgroups as $categoryname => $optionlistarray) { $answer .= ' - '; + '; foreach ($optionlistarray as $optionarray) { @@ -2108,7 +2108,7 @@ function do_list_dropdown($ia) } $answer .= ' - '; + '; } $answer .= ' '; @@ -2126,7 +2126,7 @@ function do_list_dropdown($ia) } $answer .= ' - '; + '; } } @@ -2153,7 +2153,7 @@ function do_list_dropdown($ia) $answer .= '\n"; } $answer .= ' - '; + '; if (isset($other) && $other=='Y') { @@ -2164,9 +2164,9 @@ function do_list_dropdown($ia) $sselect_show_hide = ''; } $sselect = ' -

- + '; $answer = $sselect.$answer; if (isset($other) && $other=='Y') @@ -2359,7 +2359,7 @@ function do_list_radio($ia) $answer .= $startitem; $answer .= "\t$hiddenfield\n"; $answer .=' - + '.$wrapper['item-end']; ++$rowcounter; @@ -2424,10 +2424,10 @@ function do_list_radio($ia) $answer .= $startitem; $answer .= "\t$hiddenfield\n"; $answer .= ' - - + + '.$wrapper['item-end']; $inputnames[]=$thisfieldname; @@ -2460,7 +2460,7 @@ function do_list_radio($ia) } $answer .= $wrapper['item-start'].' - + '.$wrapper['item-end']; // --> END NEW FEATURE - SAVE @@ -2483,7 +2483,7 @@ function do_list_radio($ia) } //END OF ITEMS $answer .= $wrapper['whole-end'].' -\n"; + \n"; $checkotherscript = ""; @@ -2571,8 +2571,8 @@ function do_listwithcomment($ia) if ($lwcdropdowns == 'R' && $anscount <= $dropdownthreshold) { $answer .= '

-
"; } $minanswscript = "\n"; + } + return max; + } + } + //--> + \n"; $answer = $maxanswscript . $answer; } @@ -3341,7 +3341,7 @@ function excludeAllOthers$ia[1](value, doconditioncheck) if ( $minansw > 0 ) { $minanswscript .= - "\tif (count < {$minansw} && document.getElementById('display{$ia[0]}').value == 'on'){\n" + "\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(javascript_escape(str_replace(array("\n", "\r"), "",$ia[3]),true,true)))."');\n" . "return false;\n" @@ -3391,18 +3391,18 @@ function excludeAllOthers$ia[1](value, doconditioncheck) if (count($excludeallothers)>0) { $excludeallotherscript .= " - if (document.getElementById(value).checked) - { - $excludeallotherscripton - } - else - { - $excludeallotherscriptoff - } - } - //--> - "; - $answer = $excludeallotherscript . $answer; + if (document.getElementById(value).checked) + { + $excludeallotherscripton + } + else + { + $excludeallotherscriptoff + } + } + //--> + "; + $answer = $excludeallotherscript . $answer; } $answer .= $postrow; return array($answer, $inputnames); @@ -3507,17 +3507,17 @@ function do_multiplechoice_withcomments($ia) } $qquery = "SELECT other FROM {$dbprefix}questions - WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."' and parent_qid=0"; + WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."' and parent_qid=0"; $qresult = db_execute_assoc($qquery); //Checked while ($qrow = $qresult->FetchRow()) {$other = $qrow['other'];} if ($qidattributes['random_order']==1) { $ansquery = "SELECT * FROM {$dbprefix}questions - WHERE parent_qid=$ia[0] AND language='".$_SESSION['s_lang']."' - ORDER BY ".db_random(); + WHERE parent_qid=$ia[0] AND language='".$_SESSION['s_lang']."' + ORDER BY ".db_random(); } else { $ansquery = "SELECT * FROM {$dbprefix}questions - WHERE parent_qid=$ia[0] AND language='".$_SESSION['s_lang']."' - ORDER BY question_order"; + WHERE parent_qid=$ia[0] AND language='".$_SESSION['s_lang']."' + ORDER BY question_order"; } $ansresult = db_execute_assoc($ansquery); //Checked $anscount = $ansresult->RecordCount()*2; @@ -3608,7 +3608,7 @@ function do_multiplechoice_withcomments($ia) $answer_main .= " $callmaxanswscriptother />\n\t\n\n" . "\n\t