mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
new "quota" pages
increased nr of charachters for question description, modified order to be more understandable to set quota parameters *requires translation strings update
This commit is contained in:
488
admin/quota.php
488
admin/quota.php
@@ -1,228 +1,260 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Set quota's for answered questions
|
* Set quota's for answered questions
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This file is part of queXS
|
* This file is part of queXS
|
||||||
*
|
*
|
||||||
* queXS is free software; you can redistribute it and/or modify
|
* queXS is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* queXS is distributed in the hope that it will be useful,
|
* queXS is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with queXS; if not, write to the Free Software
|
* along with queXS; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Adam Zammit <adam.zammit@deakin.edu.au>
|
* @author Adam Zammit <adam.zammit@deakin.edu.au>
|
||||||
* @copyright Deakin University 2007,2008,2009
|
* @copyright Deakin University 2007,2008,2009
|
||||||
* @package queXS
|
* @package queXS
|
||||||
* @subpackage admin
|
* @subpackage admin
|
||||||
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
|
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
|
||||||
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration file
|
* Configuration file
|
||||||
*/
|
*/
|
||||||
include("../config.inc.php");
|
include("../config.inc.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database file
|
* Database file
|
||||||
*/
|
*/
|
||||||
include ("../db.inc.php");
|
include ("../db.inc.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XHTML functions
|
* XHTML functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.xhtml.php");
|
include("../functions/functions.xhtml.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display functions
|
* Display functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.display.php");
|
include("../functions/functions.display.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input functions
|
* Input functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.input.php");
|
include("../functions/functions.input.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limesurvey functions
|
* Limesurvey functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.limesurvey.php");
|
include("../functions/functions.limesurvey.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operator functions
|
* Operator functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.operator.php");
|
include("../functions/functions.operator.php");
|
||||||
|
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
|
||||||
if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']) && isset($_GET['completions']) && isset($_GET['sample_import_id']) && isset($_GET['comparison']))
|
if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']) && isset($_GET['completions']) && isset($_GET['sample_import_id']) && isset($_GET['comparison']))
|
||||||
{
|
{
|
||||||
//need to add quota
|
//need to add quota
|
||||||
|
|
||||||
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||||
$sample_import_id = bigintval($_GET['sample_import_id']);
|
$sample_import_id = bigintval($_GET['sample_import_id']);
|
||||||
$value = $db->quote($_GET['value']);
|
$value = $db->quote($_GET['value']);
|
||||||
$completions = $db->quote($_GET['completions']);
|
$completions = $db->quote($_GET['completions']);
|
||||||
$sgqa = $db->quote($_GET['sgqa']);
|
$sgqa = $db->quote($_GET['sgqa']);
|
||||||
$comparison = $db->quote($_GET['comparison']);
|
$comparison = $db->quote($_GET['comparison']);
|
||||||
|
|
||||||
$sql = "INSERT INTO questionnaire_sample_quota(questionnaire_id, sample_import_id, lime_sgqa,value,completions,comparison)
|
$sql = "INSERT INTO questionnaire_sample_quota(questionnaire_id, sample_import_id, lime_sgqa,value,completions,comparison)
|
||||||
VALUES ($questionnaire_id, $sample_import_id, $sgqa, $value, $completions, $comparison)";
|
VALUES ($questionnaire_id, $sample_import_id, $sgqa, $value, $completions, $comparison)";
|
||||||
|
|
||||||
$db->Execute($sql);
|
$db->Execute($sql);
|
||||||
|
|
||||||
//Make sure to calculate on the spot
|
//Make sure to calculate on the spot
|
||||||
update_quotas($questionnaire_id);
|
update_quotas($questionnaire_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_sample_quota_id']))
|
if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_sample_quota_id']))
|
||||||
{
|
{
|
||||||
//need to remove quota
|
//need to remove quota
|
||||||
|
|
||||||
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||||
$questionnaire_sample_quota_id = bigintval($_GET['questionnaire_sample_quota_id']);
|
$questionnaire_sample_quota_id = bigintval($_GET['questionnaire_sample_quota_id']);
|
||||||
|
|
||||||
$sql = "DELETE FROM questionnaire_sample_quota
|
$sql = "DELETE FROM questionnaire_sample_quota
|
||||||
WHERE questionnaire_sample_quota_id = '$questionnaire_sample_quota_id'";
|
WHERE questionnaire_sample_quota_id = '$questionnaire_sample_quota_id'";
|
||||||
|
|
||||||
$db->Execute($sql);
|
$db->Execute($sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$questionnaire_id = false;
|
$questionnaire_id = false;
|
||||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||||
|
|
||||||
xhtml_head(T_("Quota management"),true,false,array("../js/window.js"));
|
xhtml_head(T_("Quota management"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js"));
|
||||||
print "<h1>" . T_("Select a questionnaire from the list below") . "</h1>";
|
print "<h3 class='form-inline pull-left'>" . T_("Questionnaire") . ": </h3>";
|
||||||
|
|
||||||
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||||
FROM questionnaire
|
FROM questionnaire
|
||||||
WHERE enabled = 1";
|
WHERE enabled = 1";
|
||||||
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id");
|
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline pull-left ");
|
||||||
|
|
||||||
|
if ($questionnaire_id != false)
|
||||||
if ($questionnaire_id != false)
|
{
|
||||||
{
|
$sample_import_id = false;
|
||||||
$sample_import_id = false;
|
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
|
||||||
|
|
||||||
print "<h1>" . T_("Select a sample from the list below") . "</h1>";
|
|
||||||
|
$sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||||
$sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
FROM sample_import as s, questionnaire_sample as q
|
||||||
FROM sample_import as s, questionnaire_sample as q
|
WHERE q.questionnaire_id = $questionnaire_id
|
||||||
WHERE q.questionnaire_id = $questionnaire_id
|
AND q.sample_import_id = s.sample_import_id";
|
||||||
AND q.sample_import_id = s.sample_import_id";
|
$s = $db->GetAll($sql);
|
||||||
|
if (!empty($s)){
|
||||||
display_chooser($db->GetAll($sql),"sample","sample_import_id",true,"questionnaire_id=$questionnaire_id");
|
|
||||||
|
print "<h3 class='form-inline pull-left'>   " . T_("Sample") . ":  </h3>";
|
||||||
if ($sample_import_id != false)
|
display_chooser($db->GetAll($sql),"sample","sample_import_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"pull-left");
|
||||||
{
|
|
||||||
print "<h1>" . T_("Current quotas (click to delete)") . "</h1>";
|
} else {
|
||||||
|
print "<div class='clearfix'></div><div class='well text-info'>" . T_("No samples assigned to this questionnaire.") . "</div>";
|
||||||
$sql = "SELECT questionnaire_sample_quota_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison
|
|
||||||
FROM questionnaire_sample_quota as qsq, questionnaire as q
|
}
|
||||||
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
|
||||||
AND qsq.sample_import_id = '$sample_import_id'
|
print "<div class='clearfix'></div>";
|
||||||
AND q.questionnaire_id = '$questionnaire_id'";
|
|
||||||
|
if ($sample_import_id != false)
|
||||||
$r = $db->GetAll($sql);
|
{
|
||||||
|
print "<h2>" . T_("Current quotas") . ":</h2>";//(click to delete)
|
||||||
if (empty($r))
|
|
||||||
{
|
$sql = "SELECT questionnaire_sample_quota_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison
|
||||||
print "<p>" . T_("Currently no quotas") . "</p>";
|
FROM questionnaire_sample_quota as qsq, questionnaire as q
|
||||||
}
|
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
||||||
else
|
AND qsq.sample_import_id = '$sample_import_id'
|
||||||
{
|
AND q.questionnaire_id = '$questionnaire_id'";
|
||||||
foreach($r as $v)
|
|
||||||
{
|
$r = $db->GetAll($sql);
|
||||||
print "<div><a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&questionnaire_sample_quota_id={$v['questionnaire_sample_quota_id']}'>" . T_("Stop calling this sample when:") . " {$v['lime_sgqa']} {$v['comparison']} {$v['value']} " . T_("for") . ": {$v['completions']} " . T_("completions") ."</a> - ";
|
|
||||||
|
if (empty($r))
|
||||||
if ($v['quota_reached'] == 1)
|
{
|
||||||
print T_("Quota reached");
|
print "<p class='well text-info'>" . T_("Currently no quotas") . "</p>";
|
||||||
else
|
}
|
||||||
print T_("Quota not yet reached");
|
else
|
||||||
|
{
|
||||||
print " - " . T_("Current completions: ") . limesurvey_quota_completions($v['lime_sgqa'],$v['lime_sid'],$questionnaire_id,$sample_import_id,$v['value'],$v['comparison']);
|
foreach($r as $v)
|
||||||
|
{
|
||||||
print "</div>";
|
print "<div><a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&questionnaire_sample_quota_id={$v['questionnaire_sample_quota_id']}'>" . T_("Stop calling this sample when:") . " {$v['lime_sgqa']} {$v['comparison']} {$v['value']} " . T_("for") . ": {$v['completions']} " . T_("completions") ."</a> - ";
|
||||||
|
|
||||||
}
|
if ($v['quota_reached'] == 1)
|
||||||
}
|
print T_("Quota reached");
|
||||||
|
else
|
||||||
|
print T_("Quota not yet reached");
|
||||||
print "<h1>" . T_("Select a question for the quota") . "</h1>";
|
|
||||||
|
print " - " . T_("Current completions: ") . limesurvey_quota_completions($v['lime_sgqa'],$v['lime_sid'],$questionnaire_id,$sample_import_id,$v['value'],$v['comparison']);
|
||||||
$sql = "SELECT lime_sid
|
|
||||||
FROM questionnaire
|
print "</div>";
|
||||||
WHERE questionnaire_id = '$questionnaire_id'";
|
|
||||||
|
}
|
||||||
$r = $db->GetRow($sql);
|
}
|
||||||
|
|
||||||
$lime_sid = $r['lime_sid'];
|
|
||||||
|
print "<h3 class=' '>" . T_("Select a question for the quota") . "</h3>";
|
||||||
$sgqa = false;
|
|
||||||
if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
|
$sql = "SELECT lime_sid
|
||||||
|
FROM questionnaire
|
||||||
$sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ': ', lq.question) END as description, CASE WHEN CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
WHERE questionnaire_id = '$questionnaire_id'";
|
||||||
FROM `" . LIME_PREFIX . "questions` AS lq
|
|
||||||
LEFT JOIN `" . LIME_PREFIX . "questions` AS lq2 ON ( lq2.qid = lq.parent_qid )
|
$r = $db->GetRow($sql);
|
||||||
JOIN `" . LIME_PREFIX . "groups` as g ON (g.gid = lq.gid)
|
|
||||||
WHERE lq.sid = '$lime_sid'
|
$lime_sid = $r['lime_sid'];
|
||||||
ORDER BY g.group_order ASC, lq.question_order ASC";
|
|
||||||
|
$sgqa = false;
|
||||||
|
if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
|
||||||
display_chooser($db->GetAll($sql),"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id");
|
|
||||||
|
$sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ': ', lq.question) END as description, CASE WHEN CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||||
if ($sgqa != false)
|
FROM `" . LIME_PREFIX . "questions` AS lq
|
||||||
{
|
LEFT JOIN `" . LIME_PREFIX . "questions` AS lq2 ON ( lq2.qid = lq.parent_qid )
|
||||||
print "<h1>" . T_("Enter the details for creating the quota:") . "</h1>";
|
JOIN `" . LIME_PREFIX . "groups` as g ON (g.gid = lq.gid)
|
||||||
print "<h2>" . T_("Pre defined values for this question:") . "</h2>";
|
WHERE lq.sid = '$lime_sid'
|
||||||
|
ORDER BY lq.parent_qid ASC, lq.question_order ASC";//, lq.parent_qid ASC lq.qid ASC,
|
||||||
$qid = explode("X", $sgqa);
|
|
||||||
$qid = $qid[2];
|
|
||||||
|
display_chooser($db->GetAll($sql),"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id",true,true,false,true,"form-group");
|
||||||
$sql = "SELECT l.code,l.answer as title
|
|
||||||
FROM `" . LIME_PREFIX . "answers` as l
|
print "<div class='clearfix'></div>";
|
||||||
WHERE l.qid = '$qid'";
|
|
||||||
|
if ($sgqa != false)
|
||||||
$rs = $db->GetAll($sql);
|
{
|
||||||
|
|
||||||
if (!isset($rs) || empty($rs))
|
print "<div class='col-sm-6 panel-body'><h3>" . T_("Enter the details for creating the quota:") . "</h3>";
|
||||||
print "<p>" . T_("No labels defined for this question") ."</p>";
|
|
||||||
else
|
?>
|
||||||
xhtml_table($rs,array('code','title'),array(T_("Code value"), T_("Description")));
|
<form action="" method="get" class="form-inline form-group">
|
||||||
|
|
||||||
|
<p><label for="comparison"><?php echo T_("The type of comparison"); ?>: </label>
|
||||||
?>
|
<select name="comparison" class='form-control' id="comparison">
|
||||||
<form action="" method="get">
|
<option value="LIKE">LIKE</option>
|
||||||
<p>
|
<option value="NOT LIKE">NOT LIKE</option>
|
||||||
<label for="value"><?php echo T_("The code value to compare"); ?> </label><input type="text" name="value" id="value"/> <br/>
|
<option value="=">=</option><option value="!=">!=</option>
|
||||||
<label for="comparison"><?php echo T_("The type of comparison"); ?></label><select name="comparison" id="comparison"><option value="LIKE">LIKE</option><option value="NOT LIKE">NOT LIKE</option><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option></select><br/>
|
<option value="<"><</option>
|
||||||
<label for="completions"><?php echo T_("The number of completions to stop calling at"); ?> </label><input type="text" name="completions" id="completions"/> <br/>
|
<option value=">">></option>
|
||||||
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
|
<option value="<="><=</option>
|
||||||
<input type="hidden" name="sample_import_id" value="<?php print($sample_import_id); ?>"/>
|
<option value=">=">>=</option></select></p>
|
||||||
<input type="hidden" name="sgqa" value="<?php print($sgqa); ?>"/>
|
|
||||||
<input type="submit" name="add_quota" value="<?php print(T_("Add quota")); ?>"/></p>
|
<p><label for="value"><?php echo T_("The code value to compare"); ?>: </label>
|
||||||
</form>
|
<input type="text" name="value" id="value" class="form-control" size="35" required /></p>
|
||||||
<?php
|
|
||||||
}
|
<p><label for="completions"><?php echo T_("The number of completions to stop calling at"); ?>: </label>
|
||||||
}
|
<input type="number" name="completions" id="completions" class="form-control" size="6" maxlength="6" style="width:8em;" required /></p>
|
||||||
}
|
|
||||||
xhtml_foot();
|
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
|
||||||
|
<input type="hidden" name="sample_import_id" value="<?php print($sample_import_id); ?>"/>
|
||||||
|
<input type="hidden" name="sgqa" value="<?php print($sgqa); ?>"/>
|
||||||
?>
|
|
||||||
|
<p><input type="submit" name="add_quota" value="<?php print(T_("Add quota")); ?>" class="btn btn-primary fa"/></p>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
print "</div>";
|
||||||
|
|
||||||
|
print "<div class='col-sm-6 panel-body'><h3>" . T_("Code values for this question") . ":</h3>";
|
||||||
|
|
||||||
|
$qid = explode("X", $sgqa);
|
||||||
|
$qid = $qid[2];
|
||||||
|
|
||||||
|
$sql = "SELECT CONCAT('<b class=\'fa\'> ', l.code , '</b>')as code,l.answer as title
|
||||||
|
FROM `" . LIME_PREFIX . "answers` as l
|
||||||
|
WHERE l.qid = '$qid'";
|
||||||
|
|
||||||
|
$rs = $db->GetAll($sql);
|
||||||
|
|
||||||
|
if (!isset($rs) || empty($rs))
|
||||||
|
print "<p class='well text-info'>" . T_("No labels defined for this question") ."</p>";
|
||||||
|
else
|
||||||
|
xhtml_table($rs,array('code','title'),array(T_("Code value"), T_("Description")));
|
||||||
|
|
||||||
|
|
||||||
|
print "</div>";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xhtml_foot();
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -1,293 +1,298 @@
|
|||||||
<?php /**
|
<?php /**
|
||||||
* Display a report of all quota's
|
* Display a report of all quota's
|
||||||
* a. (Standard quota) Monitor outcomes of questions in completed questionnaires, and exclude selected sample records when completion limit is reached
|
* a. (Standard quota) Monitor outcomes of questions in completed questionnaires, and exclude selected sample records when completion limit is reached
|
||||||
* b. (Replicate quota) Exclude selected sample records
|
* b. (Replicate quota) Exclude selected sample records
|
||||||
* c. (Questionnaire quota) Monitor outcomes of questions in completed questionnaires, and abort interview when completion limit is reached
|
* c. (Questionnaire quota) Monitor outcomes of questions in completed questionnaires, and abort interview when completion limit is reached
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This file is part of queXS
|
* This file is part of queXS
|
||||||
*
|
*
|
||||||
* queXS is free software; you can redistribute it and/or modify
|
* queXS is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* queXS is distributed in the hope that it will be useful,
|
* queXS is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with queXS; if not, write to the Free Software
|
* along with queXS; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
||||||
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2009
|
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2009
|
||||||
* @package queXS
|
* @package queXS
|
||||||
* @subpackage admin
|
* @subpackage admin
|
||||||
* @link http://www.acspri.org.au/ queXS was writen for ACSPRI
|
* @link http://www.acspri.org.au/ queXS was writen for ACSPRI
|
||||||
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration file
|
* Configuration file
|
||||||
*/
|
*/
|
||||||
include_once(dirname(__FILE__).'/../config.inc.php');
|
include_once(dirname(__FILE__).'/../config.inc.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database file
|
* Database file
|
||||||
*/
|
*/
|
||||||
include ("../db.inc.php");
|
include ("../db.inc.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XHTML functions
|
* XHTML functions
|
||||||
*/
|
*/
|
||||||
include ("../functions/functions.xhtml.php");
|
include ("../functions/functions.xhtml.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display functions
|
* Display functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.display.php");
|
include("../functions/functions.display.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input functions
|
* Input functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.input.php");
|
include("../functions/functions.input.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operator functions
|
* Operator functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.operator.php");
|
include("../functions/functions.operator.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limesurvey functions
|
* Limesurvey functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.limesurvey.php");
|
include("../functions/functions.limesurvey.php");
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST['submit']))
|
if (isset($_POST['submit']))
|
||||||
{
|
{
|
||||||
$questionnaire_id = bigintval($_POST['questionnaire_id']);
|
$questionnaire_id = bigintval($_POST['questionnaire_id']);
|
||||||
|
|
||||||
$db->StartTrans();
|
$db->StartTrans();
|
||||||
|
|
||||||
$sql = "UPDATE questionnaire_sample_quota_row
|
$sql = "UPDATE questionnaire_sample_quota_row
|
||||||
SET autoprioritise = 0
|
SET autoprioritise = 0
|
||||||
WHERE questionnaire_id = '$questionnaire_id'";
|
WHERE questionnaire_id = '$questionnaire_id'";
|
||||||
|
|
||||||
$db->Execute($sql);
|
$db->Execute($sql);
|
||||||
|
|
||||||
foreach($_POST as $key => $val)
|
foreach($_POST as $key => $val)
|
||||||
{
|
{
|
||||||
$qsqr = bigintval(substr($key,1));
|
$qsqr = bigintval(substr($key,1));
|
||||||
if (substr($key,0,1) == 'a')
|
if (substr($key,0,1) == 'a')
|
||||||
{
|
{
|
||||||
$sql = "UPDATE questionnaire_sample_quota_row
|
$sql = "UPDATE questionnaire_sample_quota_row
|
||||||
SET autoprioritise = 1
|
SET autoprioritise = 1
|
||||||
WHERE questionnaire_sample_quota_row_id = $qsqr";
|
WHERE questionnaire_sample_quota_row_id = $qsqr";
|
||||||
|
|
||||||
$db->Execute($sql);
|
$db->Execute($sql);
|
||||||
}
|
}
|
||||||
else if (substr($key,0,1) == 'p')
|
else if (substr($key,0,1) == 'p')
|
||||||
{
|
{
|
||||||
$val = intval($val);
|
$val = intval($val);
|
||||||
|
|
||||||
$sql = "UPDATE questionnaire_sample_quota_row
|
$sql = "UPDATE questionnaire_sample_quota_row
|
||||||
SET priority = '$val'
|
SET priority = '$val'
|
||||||
WHERE questionnaire_sample_quota_row_id = $qsqr";
|
WHERE questionnaire_sample_quota_row_id = $qsqr";
|
||||||
|
|
||||||
$db->Execute($sql);
|
$db->Execute($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update_quota_priorities($questionnaire_id);
|
update_quota_priorities($questionnaire_id);
|
||||||
|
|
||||||
$db->CompleteTrans();
|
$db->CompleteTrans();
|
||||||
}
|
}
|
||||||
|
|
||||||
xhtml_head(T_("Quota report"),true,array("../css/table.css"),array("../js/window.js"));
|
xhtml_head(T_("Quota report"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js"));
|
||||||
|
|
||||||
print "<h2>" . T_("Select a questionnaire from the list below") . "</h2>";
|
print "<h3 class='form-inline pull-left'>" . T_("Select a questionnaire") . ": </h3>";
|
||||||
$questionnaire_id = false;
|
|
||||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
$questionnaire_id = false;
|
||||||
display_questionnaire_chooser($questionnaire_id);
|
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||||
|
display_questionnaire_chooser($questionnaire_id,false,"form-inline form-group", "form-control");
|
||||||
if ($questionnaire_id)
|
|
||||||
{
|
if ($questionnaire_id)
|
||||||
print "<h2>" . T_("Select a sample from the list below") . "</h2>";
|
{
|
||||||
$sample_import_id = false;
|
print "<h3 class='form-inline pull-left'>" . T_("Select a sample") . ": </h3>";
|
||||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
$sample_import_id = false;
|
||||||
display_sample_chooser($questionnaire_id,$sample_import_id);
|
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||||
|
display_sample_chooser($questionnaire_id,$sample_import_id,false,"form-inline form-group clearfix", "form-control");
|
||||||
if ($sample_import_id)
|
|
||||||
{
|
if ($sample_import_id)
|
||||||
if (isset($_GET['rowquota']))
|
{
|
||||||
{
|
if (isset($_GET['rowquota']))
|
||||||
$qsq = bigintval($_GET['rowquota']);
|
{
|
||||||
$qr = 0;
|
$qsq = bigintval($_GET['rowquota']);
|
||||||
if (isset($_GET['close'])) $qr = 1;
|
$qr = 0;
|
||||||
$sql = "UPDATE questionnaire_sample_quota_row
|
if (isset($_GET['close'])) $qr = 1;
|
||||||
SET quota_reached = $qr
|
$sql = "UPDATE questionnaire_sample_quota_row
|
||||||
WHERE questionnaire_sample_quota_row_id = '$qsq'";
|
SET quota_reached = $qr
|
||||||
$db->Execute($sql);
|
WHERE questionnaire_sample_quota_row_id = '$qsq'";
|
||||||
if ($qr == 1)
|
$db->Execute($sql);
|
||||||
close_row_quota($qsq);
|
if ($qr == 1)
|
||||||
else
|
close_row_quota($qsq);
|
||||||
open_row_quota($qsq,false);
|
else
|
||||||
}
|
open_row_quota($qsq,false);
|
||||||
|
}
|
||||||
//Display report of quotas
|
|
||||||
$report = array();
|
//Display report of quotas
|
||||||
|
$report = array();
|
||||||
//Rows to display: Strata Status Quota Sample Sample Used Sample Remaining Completes % Complete
|
|
||||||
|
//Rows to display: Strata Status Quota Sample Sample Used Sample Remaining Completes % Complete
|
||||||
// Firstly, for the entire sample
|
|
||||||
|
// Firstly, for the entire sample
|
||||||
//We need to calc Sample size, Sample drawn, Sample remain, Completions, %complete
|
|
||||||
$sql = "SELECT (c.sample_id is not null) as type, count(*) as count
|
//We need to calc Sample size, Sample drawn, Sample remain, Completions, %complete
|
||||||
FROM sample as s
|
$sql = "SELECT (c.sample_id is not null) as type, count(*) as count
|
||||||
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id)
|
FROM sample as s
|
||||||
LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id)
|
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id)
|
||||||
WHERE s.import_id = '$sample_import_id'
|
LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id)
|
||||||
GROUP BY (c.sample_id is not null)";
|
WHERE s.import_id = '$sample_import_id'
|
||||||
|
GROUP BY (c.sample_id is not null)";
|
||||||
$rs = $db->GetAll($sql);
|
|
||||||
|
$rs = $db->GetAll($sql);
|
||||||
//type == 1 is drawn from sample, type == 0 is remains in sample
|
|
||||||
$drawn = 0;
|
//type == 1 is drawn from sample, type == 0 is remains in sample
|
||||||
$remain = 0;
|
$drawn = 0;
|
||||||
|
$remain = 0;
|
||||||
foreach ($rs as $r)
|
|
||||||
{
|
foreach ($rs as $r)
|
||||||
if ($r['type'] == 1) $drawn = $r['count'];
|
{
|
||||||
if ($r['type'] == 0) $remain = $r['count'];
|
if ($r['type'] == 1) $drawn = $r['count'];
|
||||||
}
|
if ($r['type'] == 0) $remain = $r['count'];
|
||||||
|
}
|
||||||
$sql = "SELECT count(*) as count
|
|
||||||
FROM `case` as c, sample as s
|
$sql = "SELECT count(*) as count
|
||||||
WHERE c.current_outcome_id = 10
|
FROM `case` as c, sample as s
|
||||||
AND s.import_id = '$sample_import_id'
|
WHERE c.current_outcome_id = 10
|
||||||
AND s.sample_id = c.sample_id
|
AND s.import_id = '$sample_import_id'
|
||||||
AND c.questionnaire_id = '$questionnaire_id'";
|
AND s.sample_id = c.sample_id
|
||||||
|
AND c.questionnaire_id = '$questionnaire_id'";
|
||||||
$rs = $db->GetRow($sql);
|
|
||||||
|
$rs = $db->GetRow($sql);
|
||||||
$completions = $rs['count'];
|
|
||||||
|
$completions = $rs['count'];
|
||||||
$report[] = array("strata" => T_("Total sample"), "quota" => $drawn + $remain, "sample" => $drawn + $remain, "sampleused" => $drawn, "sampleremain" => $remain, "completions" => $completions, "perc" => ROUND(($completions / ($drawn + $remain)) * 100,2));
|
|
||||||
|
$report[] = array("strata" => T_("Total sample"), "quota" => $drawn + $remain, "sample" => $drawn + $remain, "sampleused" => $drawn, "sampleremain" => $remain, "completions" => $completions, "perc" => ROUND(($completions / ($drawn + $remain)) * 100,2));
|
||||||
//a. (Standard quota) Monitor outcomes of questions in completed questionnaires, and exclude selected sample records when completion limit is reached
|
|
||||||
//b. (Replicate quota) Exclude selected sample records (where lime_sgqa == -1)
|
//a. (Standard quota) Monitor outcomes of questions in completed questionnaires, and exclude selected sample records when completion limit is reached
|
||||||
$sql = "SELECT questionnaire_sample_quota_row_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison,exclude_var,exclude_val,qsq.description,current_completions, priority, autoprioritise
|
//b. (Replicate quota) Exclude selected sample records (where lime_sgqa == -1)
|
||||||
FROM questionnaire_sample_quota_row as qsq, questionnaire as q
|
$sql = "SELECT questionnaire_sample_quota_row_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison,exclude_var,exclude_val,qsq.description,current_completions, priority, autoprioritise
|
||||||
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
FROM questionnaire_sample_quota_row as qsq, questionnaire as q
|
||||||
AND qsq.sample_import_id = '$sample_import_id'
|
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
||||||
AND q.questionnaire_id = '$questionnaire_id'";
|
AND qsq.sample_import_id = '$sample_import_id'
|
||||||
|
AND q.questionnaire_id = '$questionnaire_id'";
|
||||||
$r = $db->GetAll($sql);
|
|
||||||
|
$r = $db->GetAll($sql);
|
||||||
foreach ($r as $v)
|
|
||||||
{
|
foreach ($r as $v)
|
||||||
$completions = $v['current_completions'];
|
{
|
||||||
$priority = $v['priority'];
|
$completions = $v['current_completions'];
|
||||||
$autoprioritise = $v['autoprioritise'];
|
$priority = $v['priority'];
|
||||||
$checked = "";
|
$autoprioritise = $v['autoprioritise'];
|
||||||
if ($autoprioritise) $checked = "checked='checked'";
|
$checked = "";
|
||||||
$qsqr = $v['questionnaire_sample_quota_row_id'];
|
if ($autoprioritise) $checked = "checked='checked'";
|
||||||
|
$qsqr = $v['questionnaire_sample_quota_row_id'];
|
||||||
|
|
||||||
if ($v['lime_sgqa'] == -1)
|
|
||||||
{
|
if ($v['lime_sgqa'] == -1)
|
||||||
$v['completions'] = "";
|
{
|
||||||
$perc = "";
|
$v['completions'] = "";
|
||||||
}
|
$perc = "";
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
$perc = ($v['completions'] <= 0 ? 0 : ROUND(($completions / ($v['completions'])) * 100,2));
|
{
|
||||||
}
|
$perc = ($v['completions'] <= 0 ? 0 : ROUND(($completions / ($v['completions'])) * 100,2));
|
||||||
|
}
|
||||||
//We need to calc Sample size, Sample drawn, Sample remain
|
|
||||||
$sql = "SELECT (c.sample_id is not null) as type, count(*) as count
|
//We need to calc Sample size, Sample drawn, Sample remain
|
||||||
FROM sample as s
|
$sql = "SELECT (c.sample_id is not null) as type, count(*) as count
|
||||||
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id)
|
FROM sample as s
|
||||||
JOIN sample_var as sv ON (sv.sample_id = s.sample_id AND sv.var LIKE '{$v['exclude_var']}' AND sv.val LIKE '{$v['exclude_val']}')
|
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_id)
|
||||||
LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id)
|
JOIN sample_var as sv ON (sv.sample_id = s.sample_id AND sv.var LIKE '{$v['exclude_var']}' AND sv.val LIKE '{$v['exclude_val']}')
|
||||||
WHERE s.import_id = '$sample_import_id'
|
LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id)
|
||||||
GROUP BY (c.sample_id is not null)";
|
WHERE s.import_id = '$sample_import_id'
|
||||||
|
GROUP BY (c.sample_id is not null)";
|
||||||
$rs = $db->GetAll($sql);
|
|
||||||
//type == 1 is drawn from sample, type == 0 is remains in sample
|
$rs = $db->GetAll($sql);
|
||||||
$drawn = 0;
|
//type == 1 is drawn from sample, type == 0 is remains in sample
|
||||||
$remain = 0;
|
$drawn = 0;
|
||||||
|
$remain = 0;
|
||||||
foreach ($rs as $r)
|
|
||||||
{
|
foreach ($rs as $r)
|
||||||
if ($r['type'] == 1) $drawn = $r['count'];
|
{
|
||||||
if ($r['type'] == 0) $remain = $r['count'];
|
if ($r['type'] == 1) $drawn = $r['count'];
|
||||||
}
|
if ($r['type'] == 0) $remain = $r['count'];
|
||||||
|
}
|
||||||
if ($completions < $v['completions'] || $v['lime_sgqa'] == -1) //if completions less than the quota, allow for closing/opening
|
|
||||||
{
|
if ($completions < $v['completions'] || $v['lime_sgqa'] == -1) //if completions less than the quota, allow for closing/opening
|
||||||
if ($v['quota_reached'] == 1)
|
{
|
||||||
$status = "<a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&rowquota=$qsqr&open=open'>" . T_("closed") . "</a>";
|
if ($v['quota_reached'] == 1)
|
||||||
else
|
$status = "<a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&rowquota=$qsqr&open=open'>" . T_("closed") . "</a>";
|
||||||
$status = "<a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&rowquota=$qsqr&close=close'>" . T_("open") . "</a>";
|
else
|
||||||
}
|
$status = "<a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&rowquota=$qsqr&close=close'>" . T_("open") . "</a>";
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
if ($v['quota_reached'] == 1)
|
{
|
||||||
$status = T_("closed");
|
if ($v['quota_reached'] == 1)
|
||||||
else
|
$status = T_("closed");
|
||||||
$status = T_("open");
|
else
|
||||||
}
|
$status = T_("open");
|
||||||
|
}
|
||||||
$report[] = array("strata" => "<a href='quotarow.php?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id'>" . $v['description'] . "</a>", "status" => $status, "quota" => $v['completions'], "sample" => $drawn + $remain, "sampleused" => $drawn, "sampleremain" => $remain, "completions" => $completions, "perc" => $perc, "priority" => "<input type='text' size='3' value='$priority' id='p$qsqr' name='p$qsqr' />", "autoprioritise" => "<input type='checkbox' id='a$qsqr' name='a$qsqr' $checked />");
|
|
||||||
}
|
$report[] = array("strata" => "<a href='quotarow.php?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id'>" . $v['description'] . "</a>", "status" => $status, "quota" => $v['completions'], "sample" => $drawn + $remain, "sampleused" => $drawn, "sampleremain" => $remain, "completions" => $completions, "perc" => $perc, "priority" => "<input type='text' size='3' value='$priority' id='p$qsqr' name='p$qsqr' />", "autoprioritise" => "<input type='checkbox' id='a$qsqr' name='a$qsqr' $checked />");
|
||||||
|
}
|
||||||
//c. (Questionnaire quota) Monitor outcomes of questions in completed questionnaires, and abort interview when completion limit is reached
|
|
||||||
$sql = "SELECT *
|
//c. (Questionnaire quota) Monitor outcomes of questions in completed questionnaires, and abort interview when completion limit is reached
|
||||||
FROM " . LIME_PREFIX . "quota as qu, questionnaire as q
|
$sql = "SELECT *
|
||||||
WHERE qu.sid = q.lime_sid
|
FROM " . LIME_PREFIX . "quota as qu, questionnaire as q
|
||||||
AND qu.active = 1
|
WHERE qu.sid = q.lime_sid
|
||||||
AND q.questionnaire_id = '$questionnaire_id'";
|
AND qu.active = 1
|
||||||
|
AND q.questionnaire_id = '$questionnaire_id'";
|
||||||
$rs = $db->GetAll($sql);
|
|
||||||
|
$rs = $db->GetAll($sql);
|
||||||
//for each limesurvey quota
|
|
||||||
foreach($rs as $r)
|
//for each limesurvey quota
|
||||||
{
|
foreach($rs as $r)
|
||||||
//limesurvey quotas for this question
|
{
|
||||||
$quotas = (get_limesurvey_quota_info($r['id']));
|
//limesurvey quotas for this question
|
||||||
$sqlq = array();
|
$quotas = (get_limesurvey_quota_info($r['id']));
|
||||||
|
$sqlq = array();
|
||||||
foreach ($quotas as $q)
|
|
||||||
$sqlq[] = "s." . $q['fieldname'] . " = '" . $q['value'] . "'";
|
foreach ($quotas as $q)
|
||||||
|
$sqlq[] = "s." . $q['fieldname'] . " = '" . $q['value'] . "'";
|
||||||
$sql = "SELECT COUNT(id) as count
|
|
||||||
FROM ".LIME_PREFIX."survey_{$r['sid']} as s
|
$sql = "SELECT COUNT(id) as count
|
||||||
JOIN `case` as c ON (c.questionnaire_id = '$questionnaire_id')
|
FROM ".LIME_PREFIX."survey_{$r['sid']} as s
|
||||||
JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = '$sample_import_id')
|
JOIN `case` as c ON (c.questionnaire_id = '$questionnaire_id')
|
||||||
WHERE ".implode(' AND ',$sqlq)." "."
|
JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = '$sample_import_id')
|
||||||
AND submitdate IS NOT NULL
|
WHERE ".implode(' AND ',$sqlq)." "."
|
||||||
AND s.token = c.token";
|
AND submitdate IS NOT NULL
|
||||||
|
AND s.token = c.token";
|
||||||
$rs = $db->GetRow($sql);
|
|
||||||
|
$rs = $db->GetRow($sql);
|
||||||
$completions = $rs['count'];
|
|
||||||
$perc = ROUND(($completions / $r['qlimit']) * 100,2);
|
$completions = $rs['count'];
|
||||||
|
$perc = ROUND(($completions / $r['qlimit']) * 100,2);
|
||||||
$report[] = array("strata" => "<a href='" . LIME_URL . "/admin/admin.php?action=quotas&sid={$r['sid']}"a_id={$r['id']}&subaction=quota_editquota'>" . $r['name'] . "</a>", "quota" => $r['qlimit'], "completions" => $completions, "perc" => $perc);
|
|
||||||
}
|
$report[] = array("strata" => "<a href='" . LIME_URL . "/admin/admin.php?action=quotas&sid={$r['sid']}"a_id={$r['id']}&subaction=quota_editquota'>" . $r['name'] . "</a>", "quota" => $r['qlimit'], "completions" => $completions, "perc" => $perc);
|
||||||
|
}
|
||||||
print "<form action='' method='post'>";
|
|
||||||
xhtml_table($report,array("strata","status","quota","sample","sampleused","sampleremain","completions","perc","priority","autoprioritise"),array(T_("Strata"),T_("Status"),T_("Quota"),T_("Sample"),T_("Sample Used"),T_("Sample Remaining"),T_("Completions"),T_("% Complete"),T_("Set priority"),T_("Auto prioritise")),"tclass",false,false);
|
print "<form action='' method='post'>";
|
||||||
print "<p><input type='hidden' name='questionnaire_id' id='questionnaire_id' value='$questionnaire_id'/><input type='submit' id='submit' name='submit' value='" . TQ_("Update priorities") . "'/></p></form>";
|
xhtml_table($report,array("strata","status","quota","sample","sampleused","sampleremain","completions","perc","priority","autoprioritise"),array(T_("Strata"),T_("Status"),T_("Quota"),T_("Sample"),T_("Sample Used"),T_("Sample Remaining"),T_("Completions"),T_("% Complete"),T_("Set priority"),T_("Auto prioritise")),"tclass",false,false);
|
||||||
}
|
|
||||||
|
if ($report[0]("strata") != T_("Total sample"))
|
||||||
}
|
print "<input type='hidden' name='questionnaire_id' id='questionnaire_id' value='$questionnaire_id'/></br>
|
||||||
|
<input type='submit' id='submit' name='submit' class='btn btn-primary fa'value='" . TQ_("Update priorities") . "'/>";
|
||||||
xhtml_foot();
|
|
||||||
|
print "</form>";
|
||||||
|
}
|
||||||
?>
|
|
||||||
|
}
|
||||||
|
|
||||||
|
xhtml_foot();
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -1,344 +1,381 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Set quota's for answered questions and be able to exclude sample records by row
|
* Set quota's for answered questions and be able to exclude sample records by row
|
||||||
* instead of an entire sample
|
* instead of an entire sample
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* This file is part of queXS
|
* This file is part of queXS
|
||||||
*
|
*
|
||||||
* queXS is free software; you can redistribute it and/or modify
|
* queXS is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* queXS is distributed in the hope that it will be useful,
|
* queXS is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with queXS; if not, write to the Free Software
|
* along with queXS; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Adam Zammit <adam.zammit@deakin.edu.au>
|
* @author Adam Zammit <adam.zammit@deakin.edu.au>
|
||||||
* @copyright Deakin University 2007,2008,2009
|
* @copyright Deakin University 2007,2008,2009
|
||||||
* @package queXS
|
* @package queXS
|
||||||
* @subpackage admin
|
* @subpackage admin
|
||||||
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
|
* @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility
|
||||||
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
* @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration file
|
* Configuration file
|
||||||
*/
|
*/
|
||||||
include("../config.inc.php");
|
include("../config.inc.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database file
|
* Database file
|
||||||
*/
|
*/
|
||||||
include ("../db.inc.php");
|
include ("../db.inc.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XHTML functions
|
* XHTML functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.xhtml.php");
|
include("../functions/functions.xhtml.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display functions
|
* Display functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.display.php");
|
include("../functions/functions.display.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input functions
|
* Input functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.input.php");
|
include("../functions/functions.input.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limesurvey functions
|
* Limesurvey functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.limesurvey.php");
|
include("../functions/functions.limesurvey.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operator functions
|
* Operator functions
|
||||||
*/
|
*/
|
||||||
include("../functions/functions.operator.php");
|
include("../functions/functions.operator.php");
|
||||||
|
|
||||||
|
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']) && isset($_GET['completions']) && isset($_GET['sample_import_id']) && isset($_GET['comparison']) && isset($_GET['exclude_var']) && isset($_GET['exclude_val']))
|
if (isset($_GET['questionnaire_id']) && isset($_GET['sgqa']) && isset($_GET['value']) && isset($_GET['completions']) && isset($_GET['sample_import_id']) && isset($_GET['comparison']) && isset($_GET['exclude_var']) && isset($_GET['exclude_val']))
|
||||||
{
|
{
|
||||||
//need to add quota
|
//need to add quota
|
||||||
$value = -1;
|
$value = -1;
|
||||||
$comparison = -1;
|
$comparison = -1;
|
||||||
$completions = -1;
|
$completions = -1;
|
||||||
$sgqa = -1;
|
$sgqa = -1;
|
||||||
$autoprioritise = 0;
|
$autoprioritise = 0;
|
||||||
|
|
||||||
if (isset($_GET['autoprioritise'])) $autoprioritise = 1;
|
if (isset($_GET['autoprioritise'])) $autoprioritise = 1;
|
||||||
|
|
||||||
$priority = intval($_GET['priority']);
|
$priority = intval($_GET['priority']);
|
||||||
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||||
$sample_import_id = bigintval($_GET['sample_import_id']);
|
$sample_import_id = bigintval($_GET['sample_import_id']);
|
||||||
if ($_GET['sgqa'] != -1)
|
if ($_GET['sgqa'] != -1)
|
||||||
{
|
{
|
||||||
if ($_GET['sgqa'] != -2)
|
if ($_GET['sgqa'] != -2)
|
||||||
{
|
{
|
||||||
$comparison = $db->quote($_GET['comparison']);
|
$comparison = $db->quote($_GET['comparison']);
|
||||||
$value = $db->quote($_GET['value']);
|
$value = $db->quote($_GET['value']);
|
||||||
$sgqa = $db->quote($_GET['sgqa']);
|
$sgqa = $db->quote($_GET['sgqa']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sgqa = -2;
|
$sgqa = -2;
|
||||||
}
|
}
|
||||||
$completions = $db->quote($_GET['completions']);
|
$completions = $db->quote($_GET['completions']);
|
||||||
}
|
}
|
||||||
$exclude_val = $db->quote($_GET['exclude_val']);
|
$exclude_val = $db->quote($_GET['exclude_val']);
|
||||||
$exclude_var = $db->quote($_GET['exclude_var']);
|
$exclude_var = $db->quote($_GET['exclude_var']);
|
||||||
$description = $db->quote($_GET['description']);
|
$description = $db->quote($_GET['description']);
|
||||||
|
|
||||||
$sql = "INSERT INTO questionnaire_sample_quota_row(questionnaire_id, sample_import_id, lime_sgqa,value,completions,comparison,exclude_var,exclude_val,description, priority, autoprioritise)
|
$sql = "INSERT INTO questionnaire_sample_quota_row(questionnaire_id, sample_import_id, lime_sgqa,value,completions,comparison,exclude_var,exclude_val,description, priority, autoprioritise)
|
||||||
VALUES ($questionnaire_id, $sample_import_id, $sgqa, $value, $completions, $comparison, $exclude_var, $exclude_val, $description, $priority, $autoprioritise)";
|
VALUES ($questionnaire_id, $sample_import_id, $sgqa, $value, $completions, $comparison, $exclude_var, $exclude_val, $description, $priority, $autoprioritise)";
|
||||||
|
|
||||||
$db->Execute($sql);
|
$db->Execute($sql);
|
||||||
|
|
||||||
//Make sure to calculate on the spot
|
//Make sure to calculate on the spot
|
||||||
update_quotas($questionnaire_id);
|
update_quotas($questionnaire_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_sample_quota_row_id']))
|
if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_sample_quota_row_id']))
|
||||||
{
|
{
|
||||||
//need to remove quota
|
//need to remove quota
|
||||||
|
|
||||||
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||||
$questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
|
$questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
|
||||||
|
|
||||||
open_row_quota($questionnaire_sample_quota_row_id);
|
open_row_quota($questionnaire_sample_quota_row_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$questionnaire_id = false;
|
$questionnaire_id = false;
|
||||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||||
|
|
||||||
xhtml_head(T_("Quota row management"),true,false,array("../js/window.js"));
|
xhtml_head(T_("Quota row management"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../css/custom.css"),array("../js/window.js"));
|
||||||
print "<h1>" . T_("Select a questionnaire from the list below") . "</h1>";
|
print "<h3 class='form-inline pull-left'>" . T_("Questionnaire") . ": </h3>";
|
||||||
|
|
||||||
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
$sql = "SELECT questionnaire_id as value,description, CASE WHEN questionnaire_id = '$questionnaire_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||||
FROM questionnaire
|
FROM questionnaire
|
||||||
WHERE enabled = 1";
|
WHERE enabled = 1";
|
||||||
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id");
|
display_chooser($db->GetAll($sql),"questionnaire","questionnaire_id", true,false,true,true,false,true,"form-inline pull-left ");
|
||||||
|
|
||||||
|
|
||||||
if ($questionnaire_id != false)
|
if ($questionnaire_id != false)
|
||||||
{
|
{
|
||||||
$sample_import_id = false;
|
$sample_import_id = false;
|
||||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||||
|
|
||||||
print "<h1>" . T_("Select a sample from the list below") . "</h1>";
|
|
||||||
|
|
||||||
$sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
$sql = "SELECT s.sample_import_id as value,s.description, CASE WHEN s.sample_import_id = '$sample_import_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||||
FROM sample_import as s, questionnaire_sample as q
|
FROM sample_import as s, questionnaire_sample as q
|
||||||
WHERE q.questionnaire_id = $questionnaire_id
|
WHERE q.questionnaire_id = $questionnaire_id
|
||||||
AND q.sample_import_id = s.sample_import_id";
|
AND q.sample_import_id = s.sample_import_id";
|
||||||
|
$s = $db->GetAll($sql);
|
||||||
display_chooser($db->GetAll($sql),"sample","sample_import_id",true,"questionnaire_id=$questionnaire_id");
|
if (!empty($s)){
|
||||||
|
print "<h3 class='form-inline pull-left'>   " . T_("Sample") . ": </h3>";
|
||||||
if ($sample_import_id != false)
|
display_chooser($s,"sample","sample_import_id",true,"questionnaire_id=$questionnaire_id",true,true,false,true,"pull-left");
|
||||||
{
|
} else {
|
||||||
if (isset($_POST['copy_sample_import_id']))
|
print "<div class='clearfix'></div><div class='well text-info'>" . T_("No samples assigned to this questionnaire.") . "</div>";
|
||||||
{
|
}
|
||||||
copy_row_quota($questionnaire_id,$sample_import_id,bigintval($_POST['copy_sample_import_id']));
|
print "<div class='clearfix'></div>";
|
||||||
print "<h3>" . T_("Copied quotas") . "</h3>";
|
|
||||||
}
|
if ($sample_import_id != false)
|
||||||
|
{
|
||||||
if (isset($_POST['copy_sample_import_id_with_adjustment']))
|
if (isset($_POST['copy_sample_import_id']))
|
||||||
{
|
{
|
||||||
copy_row_quota_with_adjusting($questionnaire_id,$sample_import_id,bigintval($_POST['copy_sample_import_id_with_adjustment']));
|
copy_row_quota($questionnaire_id,$sample_import_id,bigintval($_POST['copy_sample_import_id']));
|
||||||
print "<h3>" . T_("Copied quotas") . "</h3>";
|
print "<h3>" . T_("Copied quotas") . ":</h3>";
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<h1>" . T_("Current row quotas (click to delete)") . "</h1>";
|
if (isset($_POST['copy_sample_import_id_with_adjustment']))
|
||||||
|
{
|
||||||
$sql = "SELECT questionnaire_sample_quota_row_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison,exclude_var,exclude_val,current_completions
|
copy_row_quota_with_adjusting($questionnaire_id,$sample_import_id,bigintval($_POST['copy_sample_import_id_with_adjustment']));
|
||||||
FROM questionnaire_sample_quota_row as qsq, questionnaire as q
|
print "<h3>" . T_("Copied quotas with adjustment") . ":</h3>";
|
||||||
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
}
|
||||||
AND qsq.sample_import_id = '$sample_import_id'
|
|
||||||
AND q.questionnaire_id = '$questionnaire_id'";
|
print "<h2>" . T_("Current row quotas ") . ":</h2>"; //(click to delete)
|
||||||
|
|
||||||
$r = $db->GetAll($sql);
|
$sql = "SELECT questionnaire_sample_quota_row_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison,exclude_var,exclude_val,current_completions
|
||||||
|
FROM questionnaire_sample_quota_row as qsq, questionnaire as q
|
||||||
if (empty($r))
|
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
||||||
{
|
AND qsq.sample_import_id = '$sample_import_id'
|
||||||
print "<p>" . T_("Currently no row quotas") . "</p>";
|
AND q.questionnaire_id = '$questionnaire_id'";
|
||||||
}
|
|
||||||
else
|
$r = $db->GetAll($sql);
|
||||||
{
|
|
||||||
foreach($r as $v)
|
if (empty($r))
|
||||||
{
|
{
|
||||||
if ($v['lime_sgqa'] == -1)
|
print "<p class='well text-info'>" . T_("Currently no row quotas") . "</p>";
|
||||||
print "<div><a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&questionnaire_sample_quota_row_id={$v['questionnaire_sample_quota_row_id']}'>" . T_("Replicate: Where") . " " . $v['exclude_var'] . " " . T_("like") . " " . $v['exclude_val'] . "</a> - ";
|
}
|
||||||
else if ($v['lime_sgqa'] == -2)
|
else
|
||||||
print "<div><a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&questionnaire_sample_quota_row_id={$v['questionnaire_sample_quota_row_id']}'>" . T_("Sample only. Stop calling where") . " " . $v['exclude_var'] . " " . T_("like") . " " . $v['exclude_val'] . " " . T_("rows from this sample when:") . " {$v['completions']} " . T_("completions") . "</a> - ";
|
{
|
||||||
|
foreach($r as $v)
|
||||||
else
|
{
|
||||||
print "<div><a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&questionnaire_sample_quota_row_id={$v['questionnaire_sample_quota_row_id']}'>" . T_("Stop calling") . " " . $v['exclude_var'] . " " . T_("like") . " " . $v['exclude_val'] . " " . T_("rows from this sample when:") . " {$v['lime_sgqa']} {$v['comparison']} {$v['value']} " . T_("for") . ": {$v['completions']} " . T_("completions") ."</a> - ";
|
if ($v['lime_sgqa'] == -1)
|
||||||
|
print "<div><a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&questionnaire_sample_quota_row_id={$v['questionnaire_sample_quota_row_id']}'>" . T_("Replicate: Where") . " " . $v['exclude_var'] . " " . T_("like") . " " . $v['exclude_val'] . "</a> - ";
|
||||||
if ($v['quota_reached'] == 1)
|
else if ($v['lime_sgqa'] == -2)
|
||||||
print T_("Row quota reached (Closed)");
|
print "<div><a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&questionnaire_sample_quota_row_id={$v['questionnaire_sample_quota_row_id']}'>" . T_("Sample only. Stop calling where") . " " . $v['exclude_var'] . " " . T_("like") . " " . $v['exclude_val'] . " " . T_("rows from this sample when:") . " {$v['completions']} " . T_("completions") . "</a> - ";
|
||||||
else
|
|
||||||
print T_("Row quota not yet reached (Open)");
|
else
|
||||||
|
print "<div><a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&questionnaire_sample_quota_row_id={$v['questionnaire_sample_quota_row_id']}'>" . T_("Stop calling") . " " . $v['exclude_var'] . " " . T_("like") . " " . $v['exclude_val'] . " " . T_("rows from this sample when:") . " {$v['lime_sgqa']} {$v['comparison']} {$v['value']} " . T_("for") . ": {$v['completions']} " . T_("completions") ."</a> - ";
|
||||||
if ($v['lime_sgqa'] != -1)
|
|
||||||
print " - " . T_("Current completions: ") . $v['current_completions'] . ":" . limesurvey_quota_completions($v['lime_sgqa'],$v['lime_sid'],$questionnaire_id,$sample_import_id,$v['value'],$v['comparison']);
|
if ($v['quota_reached'] == 1)
|
||||||
|
print T_("Row quota reached (Closed)");
|
||||||
print "</div>";
|
else
|
||||||
|
print T_("Row quota not yet reached (Open)");
|
||||||
}
|
|
||||||
|
if ($v['lime_sgqa'] != -1)
|
||||||
|
print " - " . T_("Current completions: ") . $v['current_completions'] . ":" . limesurvey_quota_completions($v['lime_sgqa'],$v['lime_sid'],$questionnaire_id,$sample_import_id,$v['value'],$v['comparison']);
|
||||||
$sql = "SELECT s.sample_import_id as value,s.description, '' AS selected
|
|
||||||
FROM sample_import as s, questionnaire_sample as q
|
print "</div>";
|
||||||
WHERE q.questionnaire_id = $questionnaire_id
|
|
||||||
AND q.sample_import_id = s.sample_import_id
|
}
|
||||||
AND s.sample_import_id != '$sample_import_id'";
|
|
||||||
|
$sql = "SELECT s.sample_import_id as value,s.description, '' AS selected
|
||||||
$ss = $db->GetAll($sql);
|
FROM sample_import as s, questionnaire_sample as q
|
||||||
|
WHERE q.questionnaire_id = $questionnaire_id
|
||||||
if (!empty($ss))
|
AND q.sample_import_id = s.sample_import_id
|
||||||
{
|
AND s.sample_import_id != '$sample_import_id'";
|
||||||
print "<form action='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id' method='post'><p>" . T_("Copy quotas for this sample to (No error/duplicate checking): ");
|
|
||||||
display_chooser($ss,"copy_sample_import_id","copy_sample_import_id",false,false,false,false);
|
$ss = $db->GetAll($sql);
|
||||||
print "<input type='submit' id='submit' value=\"" . T_("Copy") . "\"/></p></form>";
|
|
||||||
|
if (!empty($ss))
|
||||||
print "<form action='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id' method='post'><p>" . T_("Copy quotas for this sample to (No error/duplicate checking) with adjusting: ");
|
{
|
||||||
display_chooser($ss,"copy_sample_import_id_with_adjustment","copy_sample_import_id_with_adjustment",false,false,false,false);
|
print "<form action='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id' method='post'>
|
||||||
print "<input type='submit' id='submit' value=\"" . T_("Copy adjustments") . "\"/></p></form>";
|
<p>" . T_("Copy quotas for this sample to (No error/duplicate checking): ");
|
||||||
}
|
display_chooser($ss,"copy_sample_import_id","copy_sample_import_id",false,false,false,false);
|
||||||
|
print "<input type='submit' id='submit' value=\"" . T_("Copy") . "\"/></p></form>";
|
||||||
}
|
|
||||||
|
print "<form action='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id' method='post'>
|
||||||
|
<p>" . T_("Copy quotas for this sample to (No error/duplicate checking) with adjusting: ");
|
||||||
print "<h1>" . T_("Select a question for the row quota") . "</h1>";
|
display_chooser($ss,"copy_sample_import_id_with_adjustment","copy_sample_import_id_with_adjustment",false,false,false,false);
|
||||||
|
print "<input type='submit' id='submit' value=\"" . T_("Copy adjustments") . "\"/></p></form>";
|
||||||
$sql = "SELECT lime_sid
|
}
|
||||||
FROM questionnaire
|
|
||||||
WHERE questionnaire_id = '$questionnaire_id'";
|
}
|
||||||
|
|
||||||
$r = $db->GetRow($sql);
|
|
||||||
|
print "<h3>" . T_("Select a question for the row quota") . ": </h3>";
|
||||||
$lime_sid = $r['lime_sid'];
|
|
||||||
|
$sql = "SELECT lime_sid
|
||||||
$sgqa = false;
|
FROM questionnaire
|
||||||
if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
|
WHERE questionnaire_id = '$questionnaire_id'";
|
||||||
|
|
||||||
$sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ': ', lq.question) END as description, CASE WHEN CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
$r = $db->GetRow($sql);
|
||||||
FROM `" . LIME_PREFIX . "questions` AS lq
|
|
||||||
LEFT JOIN `" . LIME_PREFIX . "questions` AS lq2 ON ( lq2.qid = lq.parent_qid )
|
$lime_sid = $r['lime_sid'];
|
||||||
JOIN `" . LIME_PREFIX . "groups` as g ON (g.gid = lq.gid)
|
|
||||||
WHERE lq.sid = '$lime_sid'
|
$sgqa = false;
|
||||||
ORDER BY g.group_order ASC, lq.question_order ASC";
|
if (isset($_GET['sgqa'])) $sgqa = $_GET['sgqa'];
|
||||||
|
|
||||||
$rs = $db->GetAll($sql);
|
$sql = "SELECT CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) as value, CASE WHEN lq.parent_qid = 0 THEN lq.question ELSE CONCAT(lq2.question, ': ', lq.question) END as description, CASE WHEN CONCAT( lq.sid, 'X', lq.gid, 'X', CASE WHEN lq.parent_qid = 0 THEN lq.qid ELSE CONCAT(lq.parent_qid, lq.title) END) = '$sgqa' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||||
|
FROM `" . LIME_PREFIX . "questions` AS lq
|
||||||
$selected = "";
|
LEFT JOIN `" . LIME_PREFIX . "questions` AS lq2 ON ( lq2.qid = lq.parent_qid )
|
||||||
if ($sgqa == -1) $selected = "selected='selected'";
|
JOIN `" . LIME_PREFIX . "groups` as g ON (g.gid = lq.gid)
|
||||||
array_unshift($rs,array("value" => -1, "description" => T_("No question (Replicate)"), "selected" => $selected));
|
WHERE lq.sid = '$lime_sid'
|
||||||
|
ORDER BY lq.parent_qid ASC, lq.question_order ASC";
|
||||||
$selected = "";
|
|
||||||
if ($sgqa == -2) $selected = "selected='selected'";
|
$rs = $db->GetAll($sql);
|
||||||
array_unshift($rs,array("value" => -2, "description" => T_("Sample only quota"), "selected" => $selected));
|
|
||||||
|
$selected = "";
|
||||||
display_chooser($rs,"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id");
|
if ($sgqa == -1) $selected = "selected='selected'";
|
||||||
|
array_unshift($rs,array("value" => -1, "description" => T_("No question (Replicate)"), "selected" => $selected));
|
||||||
if ($sgqa != false)
|
|
||||||
{
|
$selected = "";
|
||||||
$sample_var = false;
|
if ($sgqa == -2) $selected = "selected='selected'";
|
||||||
if (isset($_GET['sample_var']))
|
array_unshift($rs,array("value" => -2, "description" => T_("Sample only quota"), "selected" => $selected));
|
||||||
$sample_var = $_GET['sample_var'];
|
|
||||||
|
display_chooser($rs,"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id");
|
||||||
print "<h1>" . T_("Select the sample variable to exclude") . "</h1>";
|
|
||||||
|
print "</br>";
|
||||||
$sql = "SELECT sv.var as value, sv.var as description, CASE WHEN sv.var LIKE '$sample_var' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
|
||||||
FROM sample_var AS sv, sample AS s
|
if ($sgqa != false)
|
||||||
WHERE s.import_id = $sample_import_id
|
{
|
||||||
AND s.sample_id = sv.sample_id
|
$sample_var = false;
|
||||||
GROUP BY sv.var";
|
if (isset($_GET['sample_var']))
|
||||||
|
$sample_var = $_GET['sample_var'];
|
||||||
display_chooser($db->GetAll($sql),"sample_var","sample_var",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&sgqa=$sgqa");
|
|
||||||
|
print "<h3 class='form-inline pull-left'>" . T_("Select the sample variable to exclude") . ": </h3>";
|
||||||
if ($sample_var != false)
|
|
||||||
{
|
$sql = "SELECT sv.var as value, sv.var as description, CASE WHEN sv.var LIKE '$sample_var' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||||
print "<h1>" . T_("Enter the details for creating the row quota:") . "</h1>";
|
FROM sample_var AS sv, sample AS s
|
||||||
print "<h2>" . T_("Pre defined values for this question:") . "</h2>";
|
WHERE s.import_id = $sample_import_id
|
||||||
|
AND s.sample_id = sv.sample_id
|
||||||
$rs = "";
|
GROUP BY sv.var";
|
||||||
|
|
||||||
if ($sgqa != -2 && $sgqa != -1 && !empty($sgqa))
|
display_chooser($db->GetAll($sql),"sample_var","sample_var",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&sgqa=$sgqa",true,true,false,true,"pull-left");
|
||||||
{
|
|
||||||
$qid = explode("X", $sgqa);
|
print "<div class='clearfix form-group'></div>";
|
||||||
$qid = $qid[2];
|
|
||||||
|
if ($sample_var != false)
|
||||||
$sql = "SELECT l.code,l.answer as title
|
{
|
||||||
FROM `" . LIME_PREFIX . "answers` as l
|
|
||||||
WHERE l.qid = '$qid'";
|
print "<div class='col-sm-6 panel-body'><h3>" . T_("Enter the details for creating the row quota:") . "</h3>";
|
||||||
|
|
||||||
$rs = $db->GetAll($sql);
|
?>
|
||||||
}
|
<form action="" method="get" class="form-inline table">
|
||||||
|
|
||||||
if (!isset($rs) || empty($rs))
|
<p><label for="description"><?php echo T_("Describe this quota"); ?>: </label>
|
||||||
print "<p>" . T_("No labels defined for this question") ."</p>";
|
<input type="text" class="form-control" name="description" id="description" required size="60"/></p>
|
||||||
else
|
|
||||||
xhtml_table($rs,array('code','title'),array(T_("Code value"), T_("Description")));
|
<p><label for="priority"><?php echo T_("Quota priority (50 is default, 100 highest, 0 lowest)"); ?>: </label>
|
||||||
|
<input type="number" class="form-control" name="priority" id="priority" value="50" min="0" max="100" style="width:5em;"/></p>
|
||||||
|
|
||||||
?>
|
<p><label for="autoprioritise"><?php echo T_("Should the priority be automatically updated ?</br> (based on the number of completions in this quota)"); ?> </label>
|
||||||
<form action="" method="get">
|
<input type="checkbox" name="autoprioritise" id="autoprioritise"/></p>
|
||||||
<p>
|
<?php if ($sgqa != -1) { if ($sgqa != -2) { ?>
|
||||||
<label for="description"><?php echo T_("Describe this quota"); ?> </label><input type="text" name="description" id="description"/> <br/>
|
|
||||||
<label for="priority"><?php echo T_("Quota priority (50 is default, 100 highest, 0 lowest)"); ?> </label><input type="text" name="priority" id="priority" value="50"/> <br/>
|
<p><label for="comparison"><?php echo T_("The type of comparison"); ?>: </label>
|
||||||
<label for="autoprioritise"><?php echo T_("Should the priority be automatically updated based on the number of completions in this quota?"); ?> </label><input type="checkbox" name="autoprioritise" id="autoprioritise"/> <br/>
|
<select name="comparison" class="form-control" id="comparison">
|
||||||
<?php if ($sgqa != -1) { if ($sgqa != -2) { ?>
|
<option value="LIKE">LIKE</option>
|
||||||
<label for="value"><?php echo T_("The code value to compare"); ?> </label><input type="text" name="value" id="value"/> <br/>
|
<option value="NOT LIKE">NOT LIKE</option>
|
||||||
<label for="comparison"><?php echo T_("The type of comparison"); ?></label><select name="comparison" id="comparison"><option value="LIKE">LIKE</option><option value="NOT LIKE">NOT LIKE</option><option value="=">=</option><option value="!=">!=</option><option value="<"><</option><option value=">">></option><option value="<="><=</option><option value=">=">>=</option></select><br/>
|
<option value="=">=</option><option value="!=">!=</option>
|
||||||
<?php } else { ?>
|
<option value="<"><</option><option value=">">></option>
|
||||||
<input type="hidden" name="value" value="-2"/>
|
<option value="<="><=</option><option value=">=">>=</option>
|
||||||
<input type="hidden" name="comparison" value="-2"/>
|
</select></p>
|
||||||
<?php } ?>
|
|
||||||
<label for="completions"><?php echo T_("The number of completions to stop calling at"); ?> </label><input type="text" name="completions" id="completions"/> <br/>
|
<p><label for="value"><?php echo T_("The code value to compare"); ?>: </label>
|
||||||
<?php } else { ?>
|
<input type="text" class="form-control" name="value" id="value" required /></p>
|
||||||
<input type="hidden" name="value" value="-1"/>
|
|
||||||
<input type="hidden" name="comparison" value="-1"/>
|
<?php } else { ?>
|
||||||
<input type="hidden" name="completions" value="-1"/>
|
<input type="hidden" name="value" value="-2"/>
|
||||||
<?php } ?>
|
<input type="hidden" name="comparison" value="-2"/>
|
||||||
<label for="exclude_val"><?php echo T_("Exclude from the sample where the value is like"); ?></label>
|
<?php } ?>
|
||||||
<?php
|
|
||||||
|
<p><label for="completions"><?php echo T_("The number of completions to stop calling at"); ?>: </label>
|
||||||
$sql = "SELECT sv.val as value, sv.val as description, '' AS selected
|
<input type="number" class="form-control" name="completions" id="completions" size="6" maxlength="6" style="width:6em;" required/></p>
|
||||||
FROM sample_var AS sv, sample AS s
|
|
||||||
WHERE s.import_id = $sample_import_id
|
<?php } else { ?>
|
||||||
AND s.sample_id = sv.sample_id
|
<input type="hidden" name="value" value="-1"/>
|
||||||
AND sv.var = '$sample_var'
|
<input type="hidden" name="comparison" value="-1"/>
|
||||||
GROUP BY sv.val";
|
<input type="hidden" name="completions" value="-1"/>
|
||||||
|
<?php } ?>
|
||||||
display_chooser($db->GetAll($sql),"exclude_val","exclude_val",false,false,false,false);
|
|
||||||
flush();
|
<p><label for="exclude_val"><?php echo T_("Exclude from the sample where the value is like"); ?>: </label>
|
||||||
?>
|
<?php
|
||||||
<br/>
|
|
||||||
<input type="hidden" name="exclude_var" value="<?php print($sample_var); ?>"/>
|
$sql = "SELECT sv.val as value, sv.val as description, '' AS selected
|
||||||
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
|
FROM sample_var AS sv, sample AS s
|
||||||
<input type="hidden" name="sample_import_id" value="<?php print($sample_import_id); ?>"/>
|
WHERE s.import_id = $sample_import_id
|
||||||
<input type="hidden" name="sgqa" value="<?php print($sgqa); ?>"/>
|
AND s.sample_id = sv.sample_id
|
||||||
<input type="submit" name="add_quota" value="<?php print(T_("Add row quota")); ?>"/></p>
|
AND sv.var = '$sample_var'
|
||||||
</form>
|
GROUP BY sv.val";
|
||||||
<?php
|
|
||||||
}
|
display_chooser($db->GetAll($sql),"exclude_val","exclude_val",false,false,false,false);
|
||||||
}
|
flush();
|
||||||
}
|
?>
|
||||||
}
|
</p>
|
||||||
xhtml_foot();
|
<input type="hidden" name="exclude_var" value="<?php print($sample_var); ?>"/>
|
||||||
|
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id); ?>"/>
|
||||||
|
<input type="hidden" name="sample_import_id" value="<?php print($sample_import_id); ?>"/>
|
||||||
?>
|
<input type="hidden" name="sgqa" value="<?php print($sgqa); ?>"/>
|
||||||
|
|
||||||
|
<input type="submit" name="add_quota" value="<?php print(T_("Add row quota")); ?>" class="btn btn-primary fa"/>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
print "</div>";
|
||||||
|
|
||||||
|
print "<div class='col-sm-6 panel-body'><h3>" . T_("Code values for this question") . ":</h3>";
|
||||||
|
|
||||||
|
$rs = "";
|
||||||
|
|
||||||
|
if ($sgqa != -2 && $sgqa != -1 && !empty($sgqa))
|
||||||
|
{
|
||||||
|
$qid = explode("X", $sgqa);
|
||||||
|
$qid = $qid[2];
|
||||||
|
|
||||||
|
$sql = "SELECT CONCAT('<b class=\'fa\'> ', l.code , '</b>')as code, l.answer as title
|
||||||
|
FROM `" . LIME_PREFIX . "answers` as l
|
||||||
|
WHERE l.qid = '$qid'";
|
||||||
|
|
||||||
|
$rs = $db->GetAll($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($rs) || empty($rs))
|
||||||
|
print "<p class='well text-info'>" . T_("No labels defined for this question") ."</p>";
|
||||||
|
else
|
||||||
|
xhtml_table($rs,array('code','title'),array(T_("Code value"), T_("Description")));
|
||||||
|
|
||||||
|
print "</div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xhtml_foot();
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user