\n"; echo "\n"; echo "\t\n"; echo "\t\n"; echo "
".$clang->gT("Export Question")."
$setfont\n"; echo "$setfont
".$clang->gT("Error")."
\n"._EQ_NOGID."
\n"; echo "
\n"; echo "\t
\n"; echo "\n"; exit; } $fn = "limesurvey_group_$gid.lsg"; $xml = getXMLWriter(); if($action=='exportstructureLsrcCsvGroup') { include_once($homedir.'/remotecontrol/lsrc.config.php'); //Select group_name as Filename and save $groupTitleSql = "SELECT group_name FROM {$dbprefix}groups WHERE sid=$surveyid AND gid=$gid "; $groupTitle = $connect->GetOne($groupTitleSql); $xml->openURI('remotecontrol/'.$queDir.substr($groupTitle,0,20).".lsq"); } else { header("Content-Type: text/html/force-download"); header("Content-Disposition: attachment; filename=$fn"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: cache"); // HTTP/1.0 $xml->openURI('php://output'); } $xml->setIndent(true); $xml->startDocument('1.0', 'UTF-8'); $xml->startElement('document'); $xml->writeElement('LimeSurveyDocType','Group'); $xml->writeElement('DBVersion',$dbversionnumber); $xml->startElement('languages'); $lquery = "SELECT language FROM {$dbprefix}groups WHERE gid=$gid group by language"; $lresult=db_execute_assoc($lquery); while ($row=$lresult->FetchRow()) { $xml->writeElement('language',$row['language']); } $xml->endElement(); getXMLStructure($xml,$gid); $xml->endElement(); // close columns $xml->endDocument(); exit; function getXMLStructure($xml,$gid) { global $dbprefix, $connect; // Groups $gquery = "SELECT * FROM {$dbprefix}groups WHERE gid=$gid"; BuildXMLFromQuery($xml,$gquery); // Questions table $qquery = "SELECT * FROM {$dbprefix}questions WHERE gid=$gid and parent_qid=0 order by question_order, language, scale_id"; BuildXMLFromQuery($xml,$qquery); // Questions table - Subquestions $qquery = "SELECT * FROM {$dbprefix}questions WHERE gid=$gid and parent_qid>0 order by question_order, language, scale_id"; BuildXMLFromQuery($xml,$qquery,'subquestions'); //Answers $aquery = "SELECT DISTINCT {$dbprefix}answers.* FROM {$dbprefix}answers, {$dbprefix}questions WHERE ({$dbprefix}answers.qid={$dbprefix}questions.qid) AND ({$dbprefix}questions.gid=$gid)"; BuildXMLFromQuery($xml,$aquery); //Conditions - THIS CAN ONLY EXPORT CONDITIONS THAT RELATE TO THE SAME GROUP $cquery = "SELECT DISTINCT c.* FROM {$dbprefix}conditions c, {$dbprefix}questions q, {$dbprefix}questions b WHERE (c.cqid=q.qid) AND (c.qid=b.qid) AND (q.gid={$gid}) AND (b.gid={$gid})"; BuildXMLFromQuery($xml,$cquery,'conditions'); //Question attributes $surveyid=$connect->GetOne("select sid from {$dbprefix}groups where gid={$gid}"); $sBaseLanguage=GetBaseLanguageFromSurveyID($surveyid); if ($connect->databaseType == 'odbc_mssql' || $connect->databaseType == 'odbtp' || $connect->databaseType == 'mssql_n' || $connect->databaseType =='mssqlnative') { $query="SELECT qa.qid, qa.attribute, cast(qa.value as varchar(4000)) as value FROM {$dbprefix}question_attributes qa JOIN {$dbprefix}questions q ON q.qid = qa.qid AND q.sid={$surveyid} and q.gid={$gid} where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, cast(qa.value as varchar(4000))"; } else { $query="SELECT qa.qid, qa.attribute, qa.value FROM {$dbprefix}question_attributes qa JOIN {$dbprefix}questions q ON q.qid = qa.qid AND q.sid={$surveyid} and q.gid={$gid} where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value"; } BuildXMLFromQuery($xml,$query,'question_attributes'); // Default values $query = "SELECT dv.* FROM {$dbprefix}defaultvalues dv JOIN {$dbprefix}questions ON {$dbprefix}questions.qid = dv.qid AND {$dbprefix}questions.language=dv.language AND {$dbprefix}questions.gid=$gid order by dv.language, dv.scale_id"; BuildXMLFromQuery($xml,$query,'defaultvalues'); }