Ejemplo n.º 1
0
function getXMLStructure($xml, $lids)
{
    global $dbprefix;
    // Label sets table
    $lsquery = "SELECT * FROM {$dbprefix}labelsets WHERE lid=" . implode(' or lid=', $lids);
    BuildXMLFromQuery($xml, $lsquery, 'labelsets');
    // Labels
    $lquery = "SELECT lid, code, title, sortorder, language, assessment_value FROM {$dbprefix}labels WHERE lid=" . implode(' or lid=', $lids);
    BuildXMLFromQuery($xml, $lquery, 'labels');
}
Ejemplo n.º 2
0
function getXMLStructure($xmlwriter, $exclude = array())
{
    global $dbprefix, $surveyid, $connect;
    $sdump = "";
    if (!isset($exclude) && $exclude['answers'] !== true || empty($exclude)) {
        //Answers table
        $aquery = "SELECT {$dbprefix}answers.*\r\n           FROM {$dbprefix}answers, {$dbprefix}questions \r\n\t\t   WHERE {$dbprefix}answers.language={$dbprefix}questions.language \r\n\t\t   AND {$dbprefix}answers.qid={$dbprefix}questions.qid \r\n\t\t   AND {$dbprefix}questions.sid={$surveyid}";
        BuildXMLFromQuery($xmlwriter, $aquery);
    }
    // Assessments
    $query = "SELECT {$dbprefix}assessments.*\r\n          FROM {$dbprefix}assessments \r\n          WHERE {$dbprefix}assessments.sid={$surveyid}";
    BuildXMLFromQuery($xmlwriter, $query);
    if (!isset($exclude) && $exclude['conditions'] !== true || empty($exclude)) {
        //Conditions table
        $cquery = "SELECT DISTINCT {$dbprefix}conditions.*\r\n           FROM {$dbprefix}conditions, {$dbprefix}questions \r\n\t\t   WHERE {$dbprefix}conditions.qid={$dbprefix}questions.qid \r\n\t\t   AND {$dbprefix}questions.sid={$surveyid}";
        BuildXMLFromQuery($xmlwriter, $cquery);
    }
    //Default values
    $query = "SELECT {$dbprefix}defaultvalues.*\r\n          FROM {$dbprefix}defaultvalues JOIN {$dbprefix}questions ON {$dbprefix}questions.qid = {$dbprefix}defaultvalues.qid AND {$dbprefix}questions.sid={$surveyid} AND {$dbprefix}questions.language={$dbprefix}defaultvalues.language ";
    BuildXMLFromQuery($xmlwriter, $query);
    // Groups
    $gquery = "SELECT *\r\n           FROM {$dbprefix}groups \r\n           WHERE sid={$surveyid} \r\n           ORDER BY gid";
    BuildXMLFromQuery($xmlwriter, $gquery);
    //Questions
    $qquery = "SELECT *\r\n           FROM {$dbprefix}questions \r\n           WHERE sid={$surveyid} and parent_qid=0 \r\n           ORDER BY qid";
    BuildXMLFromQuery($xmlwriter, $qquery);
    //Subquestions
    $qquery = "SELECT *\r\n           FROM {$dbprefix}questions \r\n           WHERE sid={$surveyid} and parent_qid>0\r\n           ORDER BY qid";
    BuildXMLFromQuery($xmlwriter, $qquery, 'subquestions');
    //Question attributes
    $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 \r\n          FROM {$dbprefix}question_attributes qa JOIN {$dbprefix}questions  q ON q.qid = qa.qid AND q.sid={$surveyid} \r\n          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\r\n          FROM {$dbprefix}question_attributes qa JOIN {$dbprefix}questions  q ON q.qid = qa.qid AND q.sid={$surveyid} \r\n          where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value";
    }
    BuildXMLFromQuery($xmlwriter, $query, 'question_attributes');
    if (!isset($exclude) && $exclude['quotas'] !== true || empty($exclude)) {
        //Quota
        $query = "SELECT {$dbprefix}quota.*\r\n          FROM {$dbprefix}quota \r\n\t\t  WHERE {$dbprefix}quota.sid={$surveyid}";
        BuildXMLFromQuery($xmlwriter, $query);
        //1Quota members
        $query = "SELECT {$dbprefix}quota_members.*\r\n          FROM {$dbprefix}quota_members \r\n\t\t  WHERE {$dbprefix}quota_members.sid={$surveyid}";
        BuildXMLFromQuery($xmlwriter, $query);
        //Quota languagesettings
        $query = "SELECT {$dbprefix}quota_languagesettings.*\r\n          FROM {$dbprefix}quota_languagesettings, {$dbprefix}quota\r\n\t\t  WHERE {$dbprefix}quota.id = {$dbprefix}quota_languagesettings.quotals_quota_id\r\n\t\t  AND {$dbprefix}quota.sid={$surveyid}";
        BuildXMLFromQuery($xmlwriter, $query);
    }
    // Surveys
    $squery = "SELECT *\r\n           FROM {$dbprefix}surveys \r\n           WHERE sid={$surveyid}";
    //Exclude some fields from the export
    BuildXMLFromQuery($xmlwriter, $squery, '', array('owner_id', 'active', 'datecreated'));
    // Survey language settings
    $slsquery = "SELECT *\r\n             FROM {$dbprefix}surveys_languagesettings \r\n             WHERE surveyls_survey_id={$surveyid}";
    BuildXMLFromQuery($xmlwriter, $slsquery);
}
Ejemplo n.º 3
0
function getXMLStructure($xml, $gid)
{
    global $dbprefix, $connect;
    // Groups
    $gquery = "SELECT *\n               FROM {$dbprefix}groups \n               WHERE gid={$gid}";
    BuildXMLFromQuery($xml, $gquery);
    // Questions table
    $qquery = "SELECT *\n               FROM {$dbprefix}questions \n               WHERE gid={$gid} and parent_qid=0 order by question_order, language, scale_id";
    BuildXMLFromQuery($xml, $qquery);
    // Questions table - Subquestions
    $qquery = "SELECT *\n               FROM {$dbprefix}questions \n               WHERE gid={$gid} and parent_qid>0 order by question_order, language, scale_id";
    BuildXMLFromQuery($xml, $qquery, 'subquestions');
    //Answers
    $aquery = "SELECT DISTINCT {$dbprefix}answers.*\n               FROM {$dbprefix}answers, {$dbprefix}questions \n               WHERE ({$dbprefix}answers.qid={$dbprefix}questions.qid) \n               AND ({$dbprefix}questions.gid={$gid})";
    BuildXMLFromQuery($xml, $aquery);
    //Conditions - THIS CAN ONLY EXPORT CONDITIONS THAT RELATE TO THE SAME GROUP
    $cquery = "SELECT DISTINCT c.*\n               FROM {$dbprefix}conditions c, {$dbprefix}questions q, {$dbprefix}questions b \n               WHERE (c.cqid=q.qid) \n               AND (c.qid=b.qid) \n               AND (q.gid={$gid}) \n               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 \n          FROM {$dbprefix}question_attributes qa JOIN {$dbprefix}questions  q ON q.qid = qa.qid AND q.sid={$surveyid} and q.gid={$gid} \n          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\n          FROM {$dbprefix}question_attributes qa JOIN {$dbprefix}questions  q ON q.qid = qa.qid AND q.sid={$surveyid} and q.gid={$gid}         \n          where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value";
    }
    BuildXMLFromQuery($xml, $query, 'question_attributes');
    // Default values
    $query = "SELECT dv.*\n                FROM {$dbprefix}defaultvalues dv\n                JOIN {$dbprefix}questions ON {$dbprefix}questions.qid = dv.qid \n                AND {$dbprefix}questions.language=dv.language \n                AND {$dbprefix}questions.gid={$gid} \n                order by dv.language, dv.scale_id";
    BuildXMLFromQuery($xml, $query, 'defaultvalues');
}
function getXMLStructure($xml, $qid)
{
    global $dbprefix, $connect;
    // Questions table
    $qquery = "SELECT *\n               FROM {$dbprefix}questions \n               WHERE qid={$qid} and parent_qid=0 order by language, scale_id, question_order";
    BuildXMLFromQuery($xml, $qquery);
    // Questions table - Subquestions
    $qquery = "SELECT *\n               FROM {$dbprefix}questions \n               WHERE parent_qid={$qid} order by language, scale_id, question_order";
    BuildXMLFromQuery($xml, $qquery, 'subquestions');
    // Answers table
    $aquery = "SELECT *\n               FROM {$dbprefix}answers \n               WHERE qid = {$qid} order by language, scale_id, sortorder";
    BuildXMLFromQuery($xml, $aquery);
    // Question attributes
    $surveyid = $connect->GetOne("select sid from {$dbprefix}questions where qid={$qid}");
    $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 \n          FROM {$dbprefix}question_attributes qa JOIN {$dbprefix}questions  q ON q.qid = qa.qid AND q.sid={$surveyid} and q.qid={$qid} \n          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\n          FROM {$dbprefix}question_attributes qa JOIN {$dbprefix}questions  q ON q.qid = qa.qid AND q.sid={$surveyid} and q.qid={$qid}         \n          where q.language='{$sBaseLanguage}' group by qa.qid, qa.attribute, qa.value";
    }
    BuildXMLFromQuery($xml, $query);
    // Default values
    $query = "SELECT *\n              FROM {$dbprefix}defaultvalues \n              WHERE qid={$qid}  order by language, scale_id";
    BuildXMLFromQuery($xml, $query);
}