* * You should have received a copy of the GNU General Public License * along with queXF; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ include_once "../config.inc.php"; include_once "../db.inc.php"; include "../functions/functions.output.php"; include "../functions/functions.xhtml.php"; if (isset($_GET['ddi'])) { export_ddi(intval($_GET['ddi'])); exit; } if (isset($_GET['data'])) { outputdata(intval($_GET['data'])); exit; } if (isset($_GET['csvlabel'])) { outputdatacsv(intval($_GET['csvlabel']), "", true); exit; } if (isset($_GET['csv'])) { outputdatacsv(intval($_GET['csv'])); exit; } if (isset($_GET['csvmerged'])) { outputdatacsv(intval($_GET['csvmerged']), "", false, false, false, true); exit; } if (isset($_GET['banding'])) {
1: { color: '#FF0000',lineDashStyle: [3,2],lineWidth: 1 }}, viewWindowMode:'explicit', vAxis:{viewWindow:{max:45,min:10},ticks: [10, 15, 20, 25, 30, 35, 40, 45]} } }); dashboard.bind(rangeslider, chart2); dashboard.draw(data); } function drawChartnsp() { //draw graph without setpoint data var data= google.visualization.arrayToDataTable([ ['time','level'], <?php outputdata($whichnode, False, 1001); ?> ]); var dashboard = new google.visualization.Dashboard( document.getElementById('dashboard_div')); var rangeslider = new google.visualization.ControlWrapper({ 'controlType':'DateRangeFilter', 'containerId': 'filter_div', 'options':{'filterColumnLabel':'time', 'height':100} });
/** * Export the data in PSPP form (may also work with SPSS) * * @param int qid The qid to export * */ function export_pspp($qid, $unverified = false) { global $db; $unv = ""; if ($unverified) { $unv = T_("unverified") . "_"; } header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: text"); header("Content-Disposition: attachment; filename={$unv}data_{$qid}.sps"); echo "DATA LIST FIXED /"; $sql = "SELECT b.bgid, bg.btid, (CASE WHEN bg.varname = '' THEN CONCAT('Q_',b.bgid) ELSE bg.varname END) as varname, count( b.bid ) as count,bg.width,bg.label\n\t\tFROM boxes as b\n\t\tJOIN boxgroupstype as bg ON (bg.bgid = b.bgid)\n\t\tJOIN pages as p ON (p.pid = b.pid)\n\t\tWHERE p.qid = '{$qid}'\n\t\tAND bg.btid > 0\n\t\tGROUP BY b.bgid\n\t\tORDER BY bg.sortorder"; $cols = $db->GetAll($sql); $cc = count($cols); //PSPP variable name cannot start with a number and must be unique - check $vars = array(); for ($i = 0; $i < $cc; $i++) { //start numeric if (is_numeric(substr($cols[$i]['varname'], 0, 1))) { $cols[$i]['varname'] = "V" . $cols[$i]['varname']; } //make unique $letter = "A"; $checked = false; $added = false; while (!$checked) { if (isset($vars[$cols[$i]['varname']])) { if ($added) { $letter = chr(ord($letter) + 1); $cols[$i]['varname'] = substr($cols[$i]['varname'], 0, -1) . $letter; } else { $cols[$i]['varname'] = $cols[$i]['varname'] . $letter; $added = true; } } else { $checked = true; $vars[$cols[$i]['varname']] = $cols[$i]['varname']; } } } $startpos = 1; $width = 0; $colsc = 0; foreach ($cols as $col) { $varname = $col['varname']; $length = $col['count']; $vartype = " "; if ($col['btid'] == 1) { $length = max(strlen($col['count']), $col['width']); //check if any values are non-numeric $sql = "SELECT count(*) as c\n\t\t\t\tFROM `boxes` \n\t\t\t\tWHERE `bgid` = '{$col['bgid']}'\n\t\t\t\tAND `value` NOT REGEXP '[0-9]+' \n\t\t\t\tAND `value` != ''"; $vt = $db->Getrow($sql); if (isset($vt['c']) && !empty($vt['c'])) { $vartype = " (A) "; $cols[$colsc]['is_string'] = true; } } if ($col['btid'] == 3 || $col['btid'] == 6) { $vartype = "(A) "; } if ($col['btid'] == 6 || $col['btid'] == 5) { $length = $col['width']; } if ($col['btid'] == 2) { $length = 1; for ($i = 1; $i <= $col['count']; $i++) { $nam = $varname . "_{$i}"; $startpos = $startpos + $width; $width = $length; $endpos = $startpos + $width - 1; echo "{$nam} {$startpos}-{$endpos} {$vartype}"; } } else { $startpos = $startpos + $width; $width = $length; $endpos = $startpos + $width - 1; echo "{$varname} {$startpos}-{$endpos} {$vartype}"; } $colsc++; } $startpos = $startpos + $width; $endpos = $startpos + 9; echo "formid {$startpos}-{$endpos} "; $startpos = $startpos + 10; $endpos = $startpos + 9; echo "rpc_id {$startpos}-{$endpos} "; echo " .\nVARIABLE LABELS "; $first = true; foreach ($cols as $col) { $vardescription = pspp_escape($col['label']); $varname = $col['varname']; if ($first) { $first = false; } else { echo "/"; } if ($col['btid'] == 2) { for ($i = 1; $i <= $col['count']; $i++) { $nam = $varname . "_{$i}"; echo "{$nam} '{$vardescription}' "; } } else { echo "{$varname} '{$vardescription}' "; } } echo "/formid 'queXF Form ID' /rpc_id 'queXF RPC ID' .\n"; echo "VALUE LABELS "; foreach ($cols as $col) { $varname = $col['varname']; if ($col['btid'] == 1 || $col['btid'] == 2) { $sql = "SELECT value,label\n\t\t\t\tFROM boxes\n\t\t\t\tWHERE bgid = '{$col['bgid']}'"; $rs = $db->GetAll($sql); if (!empty($rs)) { echo " /{$varname}"; foreach ($rs as $r) { if ($r['value'] != "") { if (!isset($col['is_string'])) { echo " {$r['value']} '"; } else { echo " '"; //make label same width echo str_pad($r['value'], $col['width'], " ", STR_PAD_LEFT); echo "' '"; } echo pspp_escape($r['label']) . "'"; } } } } } echo " .\nBEGIN DATA.\n"; outputdata($qid, "", false, true, $unverified); echo "END DATA.\n"; }
* * You should have received a copy of the GNU General Public License * along with queXF; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ include_once "../config.inc.php"; include_once "../db.inc.php"; include "../functions/functions.output.php"; include "../functions/functions.xhtml.php"; if (isset($_GET['ddi'])) { export_ddi(intval($_GET['ddi'])); exit; } if (isset($_GET['data'])) { outputdata(intval($_GET['data']), "", true, true, true); exit; } if (isset($_GET['csvlabel'])) { outputdatacsv(intval($_GET['csvlabel']), "", true, true); exit; } if (isset($_GET['csv'])) { outputdatacsv(intval($_GET['csv']), "", false, true); exit; } if (isset($_GET['banding'])) { export_banding(intval($_GET['banding'])); exit; } if (isset($_GET['pspp'])) {