Index: config-defaults.php =================================================================== --- config-defaults.php (revision 8708) +++ config-defaults.php (working copy) @@ -425,6 +425,41 @@ $updatecheckperiod=7; +/** + * @var $showXquestions allows you to control whether or not + * {THEREAREXQUESTIONS} is displayed (if it is included in a template) + * hide = always hide {THEREAREXQUESTIONS} + * show = always show {THEREAREXQUESTIONS} + * choose = allow survey admins to choose + */ +$showXquestions = 'show'; + + +/** + * @var $showgroupinfo allows you to control whether or not + * {GROUPNAME} and/or {GROUPDESCRIPTION} are displayed (if they are + * included in a template) + * none = always hide both title and description + * name = always {GROUPNAME} only + * description = always show {GROUPDESCRIPTION} only + * both = always show both {GROUPNAME} and {GROUPDESCRIPTION} + * choose = allow survey admins to choose + */ +$showgroupinfo = 'both'; + + +/** + * @var $showqnumcode allows you to control whether or not + * {QUESTION_NUMBER} and/or {QUESTION_CODE} are displayed (if they + * are included in a template) + * none = always hide both {QUESTION_NUMBER} and {QUESTION_CODE} + * code = always show {QUESTION_CODE} only + * number = always show {QUESTION_NUMBER} only + * both = always show both {QUESTION_NUMBER} and {QUESTION_CODE} + * choose = allow survey admins to choose + */ +$showqnumcode = 'none'; + //DO NOT EVER CHANGE THE FOLLOWING LINE --------------- require_once(dirname(__FILE__).'/config.php'); //----------------------------------------------------- Index: qanda.php =================================================================== --- qanda.php (revision 8708) +++ qanda.php (working copy) @@ -34,6 +34,7 @@ * $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 @@ -476,6 +477,7 @@ */ function retrieveAnswers($ia, $notanswered=null, $notvalidated=null) { +//echo '
(qanda.php '.__LINE__.') $ia = '.print_r($ia,true).'
'; //globalise required config variables global $dbprefix, $shownoanswer, $clang; //These are from the config-defaults.php file global $thissurvey, $gl; //These are set by index.php @@ -516,6 +518,8 @@ $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' => $ia[9] ,'help' => '' ,'mandatory' => '' ,'man_message' => '' Index: common.php =================================================================== --- common.php (revision 8708) +++ common.php (working copy) @@ -2754,7 +2754,8 @@ global $percentcomplete, $move; global $groupname, $groupdescription; global $question; - global $questioncode, $answer, $navigator; + global $showXquestions, $showgroupinfo, $showqnumcode; + global $answer, $navigator; global $help, $totalquestions, $surveyformat; global $completed, $register_errormsg; global $notanswered, $privacy, $surveyid; @@ -2816,9 +2817,34 @@ if (strpos($line, "{WELCOME}") !== false) $line=str_replace("{WELCOME}", $thissurvey['welcome'], $line); if (strpos($line, "{LANGUAGECHANGER}") !== false) $line=str_replace("{LANGUAGECHANGER}", $languagechanger, $line); if (strpos($line, "{PERCENTCOMPLETE}") !== false) $line=str_replace("{PERCENTCOMPLETE}", $percentcomplete, $line); - if (strpos($line, "{GROUPNAME}") !== false) $line=str_replace("{GROUPNAME}", $groupname, $line); - if (strpos($line, "{GROUPDESCRIPTION}") !== false) $line=str_replace("{GROUPDESCRIPTION}", $groupdescription, $line); + if( + $showgroupinfo == 'both' || + $showgroupinfo == 'name' || + ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'B') || + ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'N') + ) + { + if (strpos($line, "{GROUPNAME}") !== false) $line=str_replace("{GROUPNAME}", $groupname, $line); + } + else + { + if (strpos($line, "{GROUPNAME}") !== false) $line=str_replace("{GROUPNAME}", '' , $line); + }; + if( + $showgroupinfo == 'both' || + $showgroupinfo == 'number' || + ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'B') || + ($showgroupinfo == 'choose' && $thissurvey['showgroupinfo'] == 'D') + ) + { + if (strpos($line, "{GROUPDESCRIPTION}") !== false) $line=str_replace("{GROUPDESCRIPTION}", $groupdescription, $line); + } + else + { + if (strpos($line, "{GROUPDESCRIPTION}") !== false) $line=str_replace("{GROUPDESCRIPTION}", '' , $line); + }; + if (is_array($question)) { if (strpos($line, "{QUESTION}") !== false) @@ -2843,21 +2869,54 @@ if (strpos($line, '{QUESTION_MAN_CLASS}') !== false) $line=str_replace('{QUESTION_MAN_CLASS}', $question['man_class'], $line); if (strpos($line, "{QUESTION_INPUT_ERROR_CLASS}") !== false) $line=str_replace("{QUESTION_INPUT_ERROR_CLASS}", $question['input_error_class'], $line); - if (strpos($line, "{QUESTION_CODE}") !== false) $line=str_replace("{QUESTION_CODE}", $question['code'], $line); - if (strpos($line, "{ANSWER}") !== false) $line=str_replace("{ANSWER}", $answer, $line); - $totalquestionsAsked = $totalquestions - $totalBoilerplatequestions; - if ($totalquestionsAsked < 1) + if( + $showqnumcode == 'both' || + $showqnumcode == 'number' || + ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'B') || + ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'N') + ) { - if (strpos($line, "{THEREAREXQUESTIONS}") !== false) $line=str_replace("{THEREAREXQUESTIONS}", $clang->gT("There are no questions in this survey"), $line); //Singular + if (strpos($line, "{QUESTION_NUMBER}") !== false) $line=str_replace("{QUESTION_NUMBER}", $question['number'], $line); } - if ($totalquestionsAsked == 1) + else { - if (strpos($line, "{THEREAREXQUESTIONS}") !== false) $line=str_replace("{THEREAREXQUESTIONS}", $clang->gT("There is 1 question in this survey"), $line); //Singular + if (strpos($line, "{QUESTION_NUMBER}") !== false) $line=str_replace("{QUESTION_NUMBER}", '' , $line); + }; + if( + $showqnumcode == 'both' || + $showqnumcode == 'code' || + ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'B') || + ($showqnumcode == 'choose' && $thissurvey['showqnumcode'] == 'C') + ) + { + if (strpos($line, "{QUESTION_CODE}") !== false) $line=str_replace("{QUESTION_CODE}", $question['code'], $line); } else { - if (strpos($line, "{THEREAREXQUESTIONS}") !== false) $line=str_replace("{THEREAREXQUESTIONS}", $clang->gT("There are {NUMBEROFQUESTIONS} questions in this survey."), $line); //Note this line MUST be before {NUMBEROFQUESTIONS} + if (strpos($line, "{QUESTION_CODE}") !== false) $line=str_replace("{QUESTION_CODE}", '' , $line); + }; + + if (strpos($line, "{ANSWER}") !== false) $line=str_replace("{ANSWER}", $answer, $line); + $totalquestionsAsked = $totalquestions - $totalBoilerplatequestions; + if($showXquestions == 'show' || ($showXquestions == 'choose' && $thissurvey['showXquestions'] == 'Y')) + { + if ($totalquestionsAsked < 1) + { + if (strpos($line, "{THEREAREXQUESTIONS}") !== false) $line=str_replace("{THEREAREXQUESTIONS}", $clang->gT("There are no questions in this survey"), $line); //Singular + } + if ($totalquestionsAsked == 1) + { + if (strpos($line, "{THEREAREXQUESTIONS}") !== false) $line=str_replace("{THEREAREXQUESTIONS}", $clang->gT("There is 1 question in this survey"), $line); //Singular + } + else + { + if (strpos($line, "{THEREAREXQUESTIONS}") !== false) $line=str_replace("{THEREAREXQUESTIONS}", $clang->gT("There are {NUMBEROFQUESTIONS} questions in this survey."), $line); //Note this line MUST be before {NUMBEROFQUESTIONS} + }; } + else + { + if (strpos($line, '{THEREAREXQUESTIONS}') !== false) $line=str_replace('{THEREAREXQUESTIONS}' , '' , $line); + }; if (strpos($line, "{NUMBEROFQUESTIONS}") !== false) $line=str_replace("{NUMBEROFQUESTIONS}", $totalquestionsAsked, $line); if (strpos($line, "{TOKEN}") !== false) { Index: group.php =================================================================== --- group.php (revision 8708) +++ group.php (working copy) @@ -326,9 +326,13 @@ $qtypesarray = array(); +$qnumber = 0; + foreach ($_SESSION['fieldarray'] as $ia) { $qtypesarray[$ia[1]] = $ia[4]; + ++$qnumber; + $ia[9] = $qnumber; // incremental question count; if ($ia[5] == $gid) { Index: question.php =================================================================== --- question.php (revision 8708) +++ question.php (working copy) @@ -109,7 +109,7 @@ else {$currentquestion=$_SESSION['step']-1;} $ia=$_SESSION['fieldarray'][$currentquestion]; - +$ia[]=$_SESSION['step']; list($newgroup, $gid, $groupname, $groupdescription, $gl)=checkIfNewGroup($ia); // MANAGE CONDITIONAL QUESTIONS AND HIDDEN QUESTIONS Index: survey.php =================================================================== --- survey.php (revision 8708) +++ survey.php (working copy) @@ -251,8 +251,11 @@ { $gid=$gl[0]; $groupUnconditionnalQuestionsCount[$gid]=0; + $qnumber = 0; foreach ($_SESSION['fieldarray'] as $ia) { + ++$qnumber; + $ia[9] = $qnumber; // incremental question count; if ($ia[5] == $gid) { $qidattributes=getQuestionAttributes($ia[0]); @@ -260,6 +263,7 @@ continue; } $qtypesarray[$ia[1]] = $ia[4]; + list($plus_qanda, $plus_inputnames)=retrieveAnswers($ia); if ($plus_qanda) { Index: admin/html.php =================================================================== --- admin/html.php (revision 8708) +++ admin/html.php (working copy) @@ -2689,6 +2689,149 @@ . ""; + // Show {THEREAREXQUESTIONS} block + switch($showXquestions) + { + case 'choose': $editsurvey .= '
  • \n" + . '
  • '; + break; + case 'show': + $editsurvey .= '
  • ' + .$clang->gT('Show "There are X questions in this survey"').' '.$clang->gT('is forced on by the LimeSurvey administrator') + .'
  • '; + break; + case 'hide': + $editsurvey .= '
  • ' + .$clang->gT('Show "There are X questions in this survey"').' '.$clang->gT('is forced off by the LimeSurvey administrator') + .'
  • '; + break; + } + + + // Show {GROUPNAME} and/or {GROUPDESCRIPTION} block + switch($showgroupinfo) + { + case 'both': + $editsurvey .= '
  • ' + .$clang->gT('Both Group Name and Group Description are forced on by the LimeSurvey administrator') + .'
  • '; + break; + case 'choose': $editsurvey .= '
  • \n" + . '
  • '; + break; + case 'name': + $editsurvey .= '
  • ' + .$clang->gT('Group Name is forced and Group Description is forced off by the LimeSurvey administrator') + .'
  • '; + break; + case 'description': + $editsurvey .= '
  • ' + .$clang->gT('Group Name is forced off and Group Description is forced on by the LimeSurvey administrator') + .'
  • '; + break; + case 'none': + $editsurvey .= '
  • ' + .$clang->gT('Both Group Name and Group Description are forced off by the LimeSurvey administrator') + .'
  • '; + break; + }; + + + + // Show {GROUPNAME} and/or {GROUPDESCRIPTION} block + switch($showqnumcode) + { + case 'none': + $editsurvey .= '
  • ' + .$clang->gT('Both Question Number and Question Code are forced off by the LimeSurvey administrator') + .'
  • '; + break; + case 'choose': $editsurvey .= '
  • \n" + . '
  • '; + break; + case 'number': + $editsurvey .= '
  • ' + .$clang->gT('Question Number is forced on and Question Code is forced off by the LimeSurvey administrator') + .'
  • '; + break; + case 'code': + $editsurvey .= '
  • ' + .$clang->gT('Question Number is forced off and Question Code is forced on by the LimeSurvey administrator') + .'
  • '; + break; + case 'both': + $editsurvey .= '
  • ' + .$clang->gT('Both Question Number and Question Code are forced on by the LimeSurvey administrator') + .'
  • '; + break; + }; + + + + // End Presention and navigation TAB $editsurvey .= "\n"; @@ -3286,10 +3429,103 @@ . "" + . ""; + // Show {THEREAREXQUESTIONS} block + switch($showXquestions) + { + case 'choose': $newsurvey .= '
  • \n" + . '
  • '; + break; + case 'show': + $newsurvey .= '
  • '. + $clang->gT('Show "There are X questions in this survey"').' '.$clang->gT('is forced on by the LimeSurvey administrator') + .'
  • '; + break; + case 'hide': + $newsurvey .= '
  • ' + .$clang->gT('Show "There are X questions in this survey"').' '.$clang->gT('is forced off by the LimeSurvey administrator') + .'
  • '; + break; + }; + + + // Show {GROUPNAME} and/or {GROUPDESCRIPTION} block + switch($showgroupinfo) + { + case 'both': + $newsurvey .= '
  • ' + .$clang->gT('Both Group Name and Group Description are forced on by the LimeSurvey administrator') + .'
  • '; + break; + case 'choose': $newsurvey .= '
  • \n" + . '
  • '; + break; + case 'name': + $newsurvey .= '
  • ' + .$clang->gT('Group Name is forced and Group Description is forced off by the LimeSurvey administrator') + .'
  • ';uu + break; + case 'description': + $newsurvey .= '
  • ' + .$clang->gT('Group Name is forced off and Group Description is forced on by the LimeSurvey administrator') + .'
  • '; + break; + case 'none': + $newsurvey .= '
  • ' + .gT('Both Group Name and Group Description are forced off by the LimeSurvey administrator') + .'
  • '; + break; + }; + + + + // Show {GROUPNAME} and/or {GROUPDESCRIPTION} block + switch($showqnumcode) + { + case 'none': + $newsurvey .= '
  • ' + .$clang->gT('Both Question Number and Question Code are forced off by the LimeSurvey administrator') + .'
  • '; + break; + case 'choose': $newsurvey .= '
  • \n" + . '
  • '; + break; + case 'number': + $newsurvey .= '
  • ' + .$clang->gT('Question Number is forced and Question Code is forced off by the LimeSurvey administrator') + .'
  • '; + break; + case 'code': + $newsurvey .= '
  • ' + .$clang->gT('Question Number is forced off and Question Code is forced on by the LimeSurvey administrator') + .'
  • '; + break; + case 'both': + $newsurvey .= '
  • ' + .$clang->gT('Both Question Number and Question Code are forced on by the LimeSurvey administrator') + .'
  • '; + break; + }; + + + + //Default date format - . "
  • \n" + $newsurvey .= "
  • \n" . "