Пример #1
0
 //Count answer-options for this question
 $qrq = "SELECT * FROM " . db_table_name('answers') . " WHERE qid={$qid} AND language='" . $baselang . "' ORDER BY sortorder, answer";
 $qrr = $connect->Execute($qrq);
 //Checked
 $qct = $qrr->RecordCount();
 //Count sub-questions for this question
 $sqrq = "SELECT * FROM " . db_table_name('questions') . " WHERE parent_qid={$qid} AND language='" . $baselang . "'";
 $sqrr = $connect->Execute($sqrq);
 //Checked
 $sqct = $sqrr->RecordCount();
 $qrquery = "SELECT * FROM " . db_table_name('questions') . " WHERE gid={$gid} AND sid={$surveyid} AND qid={$qid} AND language='" . $baselang . "'";
 $qrresult = db_execute_assoc($qrquery) or safe_die($qrquery . "<br />" . $connect->ErrorMsg());
 //Checked
 $questionsummary = "<div class='menubar'>\n";
 // Check if other questions in the Survey are dependent upon this question
 $condarray = GetQuestDepsForConditions($surveyid, "all", "all", $qid, "by-targqid", "outsidegroup");
 // PREVIEW THIS QUESTION BUTTON
 while ($qrrow = $qrresult->FetchRow()) {
     $qrrow = array_map('FlattenText', $qrrow);
     //$qrrow = array_map('htmlspecialchars', $qrrow);
     $questionsummary .= "<div class='menubar-title ui-widget-header'>\n" . "<strong>" . $clang->gT("Question") . "</strong> <span class='basic'>{$qrrow['question']} (" . $clang->gT("ID") . ":{$qid})</span>\n" . "</div>\n" . "<div class='menubar-main'>\n" . "<div class='menubar-left'>\n" . "<img src='{$imageurl}/blank.gif' alt='' width='55' height='20' />\n" . "<img src='{$imageurl}/seperator.gif' alt='' />\n";
     if (bHasSurveyPermission($surveyid, 'surveycontent', 'read')) {
         if (count(GetAdditionalLanguagesFromSurveyID($surveyid)) == 0) {
             $questionsummary .= "<a href=\"#\" accesskey='q' onclick=\"window.open('{$scriptname}?action=previewquestion&amp;sid={$surveyid}&amp;qid={$qid}', '_blank')\"" . "title=\"" . $clang->gTview("Preview This Question") . "\">" . "<img src='{$imageurl}/preview.png' alt='" . $clang->gT("Preview This Question") . "' name='previewquestionimg' /></a>\n" . "<img src='{$imageurl}/seperator.gif' alt='' />\n";
         } else {
             $questionsummary .= "<a href=\"#\" accesskey='q' id='previewquestion'" . "title=\"" . $clang->gTview("Preview This Question") . "\">" . "<img src='{$imageurl}/preview.png' title='' alt='" . $clang->gT("Preview This Question") . "' name='previewquestionimg' /></a>\n" . "<img src='{$imageurl}/seperator.gif' alt=''  />\n";
             $tmp_survlangs = GetAdditionalLanguagesFromSurveyID($surveyid);
             $baselang = GetBaseLanguageFromSurveyID($surveyid);
             $tmp_survlangs[] = $baselang;
             rsort($tmp_survlangs);
             // Test question Language Selection Popup
         $cdresult = $connect->Execute($cdquery) or safe_die($connect->ErrorMsg());
         //Renumber the question we're changing
         $cdquery = "UPDATE " . db_table_name('questions') . " SET question_order=" . ($newpos + 1) . " WHERE gid={$gid} AND question_order=-1";
         $cdresult = $connect->Execute($cdquery) or safe_die($connect->ErrorMsg());
     }
 }
 //Get the questions for this group
 $baselang = GetBaseLanguageFromSurveyID($surveyid);
 $oqquery = "SELECT * FROM " . db_table_name('questions') . " WHERE sid={$surveyid} AND gid={$gid} AND language='" . $baselang . "' and parent_qid=0 order by question_order";
 $oqresult = db_execute_assoc($oqquery);
 $orderquestions = "<div class='header ui-widget-header'>" . $clang->gT("Change Question Order") . "</div>";
 $questioncount = $oqresult->RecordCount();
 $oqarray = $oqresult->GetArray();
 $minioqarray = $oqarray;
 // Get the condition dependecy array for all questions in this array and group
 $questdepsarray = GetQuestDepsForConditions($surveyid, $gid);
 if (!is_null($questdepsarray)) {
     $orderquestions .= "<br/><div class='movableNode' style='margin:0 auto;'><strong><font color='orange'>" . $clang->gT("Warning") . ":</font> " . $clang->gT("Current group is using conditional questions") . "</strong><br /><br /><i>" . $clang->gT("Re-ordering questions in this group is restricted to ensure that questions on which conditions are based aren't reordered after questions having the conditions set") . "</i></strong><br /><br/>" . $clang->gT("See the conditions marked on the following questions") . ":<ul>\n";
     foreach ($questdepsarray as $depqid => $depquestrow) {
         foreach ($depquestrow as $targqid => $targcid) {
             $listcid = implode("-", $targcid);
             $question = arraySearchByKey($depqid, $oqarray, "qid", 1);
             $orderquestions .= "<li><a href='#' onclick=\"window.open('admin.php?sid=" . $surveyid . "&amp;gid=" . $gid . "&amp;qid=" . $depqid . "&amp;action=conditions&amp;markcid=" . $listcid . "','_top')\">" . $question['title'] . ": " . FlattenText($question['question']) . " [QID: " . $depqid . "] </a> ";
         }
         $orderquestions .= "</li>\n";
     }
     $orderquestions .= "</ul></div>";
 }
 $orderquestions .= "<form method='post' action=''><ul class='movableList'>";
 for ($i = 0; $i < $questioncount; $i++) {
     $downdisabled = "";