GetOne($sQuery); $aQuestiontypeInfo=getqtypelist($sQuestiontype,'array'); $iScaleCount=$aQuestiontypeInfo[$sQuestiontype]['subquestions']; for ($iScale = 0; $iScale < $iScaleCount; $iScale++) { $sQuery = "SELECT * FROM ".db_table_name('questions')." WHERE parent_qid={$qid} AND language='{$baselang}' and scale_id={$iScale}"; $subquestiondata=$connect->GetArray($sQuery); if (count($subquestiondata)==0) { $sQuery = "INSERT INTO ".db_table_name('questions')." (sid,gid,parent_qid,title,question,question_order,language,scale_id) VALUES($surveyid,$gid,$qid,'SQ001',".db_quoteall($clang->gT('Some example subquestion')).",1,".db_quoteall($baselang).",{$iScale})"; $connect->Execute($sQuery); //Checked $sQuery = "SELECT * FROM ".db_table_name('questions')." WHERE parent_qid={$qid} AND language='{$baselang}' and scale_id={$iScale}"; $subquestiondata=$connect->GetArray($sQuery); } // check that there are subquestions for every language supported by the survey foreach ($anslangs as $language) { foreach ($subquestiondata as $row) { $sQuery = "SELECT count(*) FROM ".db_table_name('questions')." WHERE parent_qid={$qid} AND language='{$language}' AND qid={$row['qid']} and scale_id={$iScale}"; $qrow = $connect->GetOne($sQuery); //Checked if ($qrow == 0) // means that no record for the language exists in the questions table { db_switchIDInsert('questions',true); $sQuery = "INSERT INTO ".db_table_name('questions')." (qid,sid,gid,parent_qid,title,question,question_order,language, scale_id) VALUES({$row['qid']},$surveyid,{$row['gid']},$qid,".db_quoteall($row['title']).",".db_quoteall($row['question']).",{$row['question_order']},".db_quoteall($language).",{$iScale})"; $connect->Execute($sQuery); //Checked db_switchIDInsert('questions',false); } } } } array_unshift($anslangs,$baselang); // makes an array with ALL the languages supported by the survey -> $anslangs $vasummary = "\n\n"; //delete the subquestions in languages not supported by the survey $qquery = "SELECT DISTINCT language FROM ".db_table_name('questions')." WHERE (parent_qid = $qid) AND (language NOT IN ('".implode("','",$anslangs)."'))"; $qresult = db_execute_assoc($qquery); //Checked while ($qrow = $qresult->FetchRow()) { $qquery = "DELETE FROM ".db_table_name('questions')." WHERE (parent_qid = $qid) AND (language = '".$qrow["language"]."')"; $connect->Execute($qquery); //Checked } // Check sort order for subquestions $qquery = "SELECT type FROM ".db_table_name('questions')." WHERE qid=$qid AND language='".$baselang."'"; $qresult = db_execute_assoc($qquery); //Checked while ($qrow=$qresult->FetchRow()) {$qtype=$qrow['type'];} if (!isset($_POST['ansaction'])) { //check if any nulls exist. If they do, redo the sortorders $caquery="SELECT * FROM ".db_table_name('questions')." WHERE parent_qid=$qid AND question_order is null AND language='".$baselang."'"; $caresult=$connect->Execute($caquery); //Checked $cacount=$caresult->RecordCount(); if ($cacount) { fixsortorderAnswers($qid); // !!Adjust this!! } } // Print Key Control JavaScript $vasummary .= PrepareEditorScript(); $query = "SELECT question_order FROM ".db_table_name('questions')." WHERE parent_qid='{$qid}' AND language='".GetBaseLanguageFromSurveyID($surveyid)."' ORDER BY question_order desc"; $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg()); //Checked $anscount = $result->RecordCount(); $row=$result->FetchRow(); $maxsortorder=$row['question_order']+1; $vasummary .= "
\n" .$clang->gT("Edit subquestions") ."
\n" ."
gT("Error: You are trying to use duplicate answer codes.",'js')."','".$clang->gT("Error: 'other' is a reserved keyword.",'js')."');\">\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n"; $vasummary .= "
"; $first=true; $sortorderids=''; $codeids=''; $vasummary .= "
\n"; // the following line decides if the assessment input fields are visible or not // for some question types the assessment values is set in the label set instead of the answers $qtypes=getqtypelist('','array'); $scalecount=$qtypes[$qtype]['subquestions']; foreach ($anslangs as $anslang) { $vasummary .= "
" ."

".getLanguageNameFromCode($anslang, false); if ($anslang==GetBaseLanguageFromSurveyID($surveyid)) {$vasummary .= '('.$clang->gT("Base language").')';} $vasummary .= "

"; for ($scale_id = 0; $scale_id < $scalecount; $scale_id++) { $position=0; if ($scalecount>1) { if ($scale_id==0) { $vasummary .="
\n".$clang->gT("Y-Scale")."
"; } else { $vasummary .="
\n".$clang->gT("X-Scale")."
"; } } $query = "SELECT * FROM ".db_table_name('questions')." WHERE parent_qid='{$qid}' AND language='{$anslang}' AND scale_id={$scale_id} ORDER BY question_order, title"; $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg()); //Checked $anscount = $result->RecordCount(); $vasummary .="\n" ."" ."\n" ."\n" ."\n"; if ($activated != 'Y' && $first) { $vasummary .="\n"; } $vasummary .="" .""; $alternate=false; while ($row=$result->FetchRow()) { $row['title'] = htmlspecialchars($row['title']); $row['question']=htmlspecialchars($row['question']); if ($first) {$codeids=$codeids.' '.$row['question_order'];} $vasummary .= "{$row['title']}"; } elseif ($activated != 'Y' && $first) // If survey is decactivated { $vasummary .= "\n" ."\n"; $position++; } ++$anscount; $vasummary .= "
 ".$clang->gT("Code")."".$clang->gT("Subquestion")."".$clang->gT("Action")."
"; } else { $vasummary .= "{$row['title']}"; } // $vasummary .= "\n" ."\n" . getEditor("editanswer","answer_".$row['language']."_".$row['qid']."_{$row['scale_id']}", "[".$clang->gT("Subquestion:", "js")."](".$row['language'].")",$surveyid,$gid,$qid,'editanswer') ."\n"; // Deactivate delete button for active surveys if ($activated != 'Y' && $first) { $vasummary.=""; $vasummary.=""; } $vasummary .= "
\n"; $disabled=''; if ($activated == 'Y') { $disabled="disabled='disabled'"; } $vasummary .= ""; $vasummary .= ""; } $first=false; $vasummary .= "
"; } // Label set browser //
$vasummary .= " "; $vasummary .= " "; $vasummary .= "

" ."\n"; $position=sprintf("%05d", $position); if ($activated == 'Y') { $vasummary .= "

\n" ."" .$clang->gT("Warning").": ".$clang->gT("You cannot add/remove subquestions or edit their codes because the survey is active.")."\n" ."\n" ."\n"; } $vasummary .= "

"; ?>