mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Merged from McMasterReports branch
This commit is contained in:
@@ -72,5 +72,6 @@ T_("Thursday");
|
||||
T_("Friday");
|
||||
T_("Saturday");
|
||||
T_("Sunday");
|
||||
T_("Quota filled");
|
||||
|
||||
?>
|
||||
|
||||
@@ -64,6 +64,8 @@ print "<li><a href=\"javascript:link('mainobj','dataoutput.php');\">" . T_("Data
|
||||
|
||||
print "<li><h3>" . T_("Questionnaire progress") . "</h3>";
|
||||
print "<ul><li><a href=\"javascript:link('mainobj','displayappointments.php');\">" . T_("Display all future appointments") . "</a></li>";
|
||||
print "<li><a href=\"javascript:link('mainobj','samplecallattempts.php');\">" . T_("Sample call attempts report") . "</a></li>";
|
||||
print "<li><a href=\"javascript:link('mainobj','quotareport.php');\">" . T_("Quota report") . "</a></li>";
|
||||
print "<li><a href=\"javascript:link('mainobj','outcomes.php');\">" . T_("Questionnaire outcomes") . "</a></li></ul></li>";
|
||||
|
||||
print "<li><h3>" . T_("Performance") . "</h3>";
|
||||
|
||||
@@ -96,10 +96,11 @@ if (isset($_POST['import_file']))
|
||||
if ($rs)
|
||||
{
|
||||
$qid = $db->Insert_ID();
|
||||
print "<p>Successfully inserted $name as questionnaire $qid, linked to $lime_sid</p>";
|
||||
print "<p>" . T_("Successfully inserted") . " $name " . T_("as questionnaire") . " $qid, " . T_("linked to") . " $lime_sid</p>";
|
||||
print "<p>" . T_("You must now edit and activate the questionnaire") . "</p>";
|
||||
}else
|
||||
{
|
||||
print "<p>Error: Failed to insert questionnaire</p>";
|
||||
print "<p>" . T_("Error: Failed to insert questionnaire") . "</p>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -64,12 +64,11 @@ include("../functions/functions.input.php");
|
||||
*/
|
||||
include("../functions/functions.operator.php");
|
||||
|
||||
xhtml_head(T_("Operator Performance"),true,false,array("../js/window.js"));
|
||||
xhtml_head(T_("Operator Performance"),true,array("../css/table.css"),array("../js/window.js"));
|
||||
|
||||
$rs = get_CPH();
|
||||
$rs = get_stats_total(get_stats());
|
||||
print "<h2>" . T_("Overall") . "</h2>";
|
||||
xhtml_table($rs,array("firstName","completions","time","CPH"),array(T_("Operator"),T_("Completions"),T_("Total time"),T_("Completions per hour")),"tclass");
|
||||
xhtml_table(get_effectiveness(),array("firstName","effectiveness"),array(T_("Operator"),T_("Effectiveness (proportion of time on a call in a case)")),"tclass");
|
||||
xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness")));
|
||||
|
||||
$questionnaire_id = false;
|
||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
@@ -77,10 +76,9 @@ display_questionnaire_chooser($questionnaire_id);
|
||||
|
||||
if ($questionnaire_id)
|
||||
{
|
||||
$rs = get_CPH_by_questionnaire($questionnaire_id);
|
||||
$rs = get_stats_total(get_stats_by_questionnaire($questionnaire_id));
|
||||
print "<h2>" . T_("This project") . "</h2>";
|
||||
xhtml_table($rs,array("firstName","completions","time","CPH"),array(T_("Operator"),T_("Completions"),T_("Total time"),T_("Completions per hour")),"tclass");
|
||||
xhtml_table(get_effectiveness_by_questionnaire($questionnaire_id),array("firstName","effectiveness"),array(T_("Operator"),T_("Effectiveness (proportion of time on a call in a case)")),"tclass");
|
||||
xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness")));
|
||||
|
||||
$operator_id = get_operator_id();
|
||||
|
||||
@@ -99,9 +97,9 @@ if ($questionnaire_id)
|
||||
|
||||
if ($shift_id)
|
||||
{
|
||||
$rs = get_CPH_by_shift($questionnaire_id,$shift_id);
|
||||
$rs = get_stats_total(get_stats_by_shift($questionnaire_id,$shift_id));
|
||||
print "<h2>" . T_("This shift") . "</h2>";
|
||||
xhtml_table($rs,array("firstName","completions","time","CPH"),array(T_("Operator"),T_("Completions"),T_("Total time"),T_("Completions per hour")),"tclass");
|
||||
xhtml_table($rs,array("firstName","completions","totalcalls","time","callt","CPH","CALLSPH","effectiveness"),array(T_("Operator"),T_("Completions"),T_("Calls"),T_("Total time"),T_("Call time"),T_("Completions p/h"),T_("Calls p/h"),T_("Effectiveness")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ include ("../functions/functions.operator.php");
|
||||
*/
|
||||
include("../functions/functions.input.php");
|
||||
|
||||
$operator_id = get_operator_id();
|
||||
$admin_operator_id = get_operator_id();
|
||||
|
||||
$questionnaire_id = false;
|
||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
@@ -122,7 +122,7 @@ if ($questionnaire_id != false)
|
||||
print "</table>";
|
||||
|
||||
|
||||
$sql = "SELECT o.description as des, o.outcome_id, count( c.case_id ) as count
|
||||
$sql = "SELECT o.description as des, o.outcome_id, count( c.case_id ) as count, ROUND((count(c.case_id) / (SELECT count(case_id) FROM `case` WHERE questionnaire_id = '$questionnaire_id')) * 100,2) as perc
|
||||
FROM `case` AS c, `outcome` AS o
|
||||
WHERE c.questionnaire_id = '$questionnaire_id'
|
||||
AND c.current_outcome_id = o.outcome_id
|
||||
@@ -133,75 +133,111 @@ if ($questionnaire_id != false)
|
||||
if (!empty($rs))
|
||||
{
|
||||
translate_array($rs,array("des"));
|
||||
xhtml_table($rs,array("des","count"),array(T_("Outcome"),T_("Count")),"tclass",array("des" => "Complete"));
|
||||
xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc"));
|
||||
|
||||
$operator_id = false;
|
||||
if (isset($_GET['operator_id'])) $operator_id = bigintval($_GET['operator_id']);
|
||||
|
||||
//display a list of operators
|
||||
$sql = "SELECT s.operator_id as value,s.firstname as description, CASE WHEN s.operator_id = '$operator_id' THEN 'selected=\'selected\'' ELSE '' END AS selected
|
||||
FROM operator as s, operator_questionnaire as q
|
||||
WHERE s.operator_id = q.operator_id
|
||||
AND q.questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$r = $db->GetAll($sql);
|
||||
|
||||
print "<h2>" . T_("Operator") . ": " . "</h2>";
|
||||
if(!empty($r))
|
||||
display_chooser($r,"operator_id","operator_id",true,"questionnaire_id=$questionnaire_id");
|
||||
|
||||
if ($operator_id != false)
|
||||
{
|
||||
print "<p>" . T_("Operator call outcomes") . "</p>";
|
||||
|
||||
$sql = "SELECT o.description as des, o.outcome_id, count( c.call_id ) as count, ROUND((count(c.call_id) / (SELECT count(call.call_id) FROM `call` JOIN `case` ON (call.case_id = `case`.case_id AND `case`.questionnaire_id = $questionnaire_id ) WHERE call.operator_id = '$operator_id')) * 100,2) as perc
|
||||
FROM `call` AS c, `case` as ca, `outcome` AS o
|
||||
WHERE ca.questionnaire_id = '$questionnaire_id'
|
||||
AND ca.case_id = c.case_id
|
||||
AND c.operator_id = '$operator_id'
|
||||
AND c.outcome_id = o.outcome_id
|
||||
GROUP BY o.outcome_id";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
if (!empty($rs))
|
||||
{
|
||||
translate_array($rs,array("des"));
|
||||
xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc"));
|
||||
}
|
||||
}
|
||||
|
||||
$sample_import_id = false;
|
||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
|
||||
//display a list of samples
|
||||
$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
|
||||
WHERE s.sample_import_id = q.sample_import_id
|
||||
AND q.questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$r = $db->GetAll($sql);
|
||||
|
||||
|
||||
print "<h2>" . T_("Sample") . ": " . "</h2>";
|
||||
if(!empty($r))
|
||||
display_chooser($r,"sample_import_id","sample_import_id",true,"questionnaire_id=$questionnaire_id");
|
||||
|
||||
|
||||
if ($sample_import_id != false)
|
||||
{
|
||||
print "<p>" . T_("Sample status") . "</p>";
|
||||
|
||||
$sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . T_("Drawn from sample") . "' ELSE '" . T_("Remain in sample") . "' END as drawn,
|
||||
count(*) as count
|
||||
FROM sample as s
|
||||
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)
|
||||
WHERE s.import_id = '$sample_import_id'
|
||||
GROUP BY (c.sample_id is not null)";
|
||||
|
||||
xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")));
|
||||
|
||||
|
||||
print "<p>" . T_("Outcomes") . "</p>";
|
||||
|
||||
|
||||
$sql = "SELECT o.description as des, o.outcome_id, count( c.case_id ) as count,ROUND(count(c.case_id) / (SELECT count(case_id) FROM `case` JOIN sample ON (`case`.sample_id = sample.sample_id AND sample.import_id = '$sample_import_id') WHERE questionnaire_id = '$questionnaire_id' ) * 100,2) as perc
|
||||
|
||||
FROM `case` AS c, `outcome` AS o, sample as s
|
||||
WHERE c.questionnaire_id = '$questionnaire_id'
|
||||
AND c.sample_id = s.sample_id
|
||||
AND s.import_id = '$sample_import_id'
|
||||
AND c.current_outcome_id = o.outcome_id
|
||||
GROUP BY o.outcome_id";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
if (!empty($rs))
|
||||
{
|
||||
translate_array($rs,array("des"));
|
||||
xhtml_table($rs,array("des","count","perc"),array(T_("Outcome"),T_("Count"),T_("%")),"tclass",array("des" => "Complete"),array("count","perc"));
|
||||
}
|
||||
else
|
||||
print "<p>" . T_("No outcomes recorded for this sample") . "</p>";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
print "<p>" . T_("No outcomes recorded for this questionnaire") . "</p>";
|
||||
|
||||
|
||||
$sample_import_id = false;
|
||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
|
||||
//display a list of samples
|
||||
$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
|
||||
WHERE s.sample_import_id = q.sample_import_id
|
||||
AND q.questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$r = $db->GetAll($sql);
|
||||
|
||||
|
||||
print "<h2>" . T_("Sample") . ": " . "</h2>";
|
||||
if(!empty($r))
|
||||
display_chooser($r,"sample_import_id","sample_import_id",true,"questionnaire_id=$questionnaire_id");
|
||||
|
||||
|
||||
if ($sample_import_id != false)
|
||||
{
|
||||
print "<p>" . T_("Sample status") . "</p>";
|
||||
|
||||
$sql = "SELECT CASE WHEN (c.sample_id is not null) = 1 THEN '" . T_("Drawn from sample") . "' ELSE '" . T_("Remain in sample") . "' END as drawn,
|
||||
count(*) as count
|
||||
FROM sample as s
|
||||
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)
|
||||
WHERE s.import_id = '$sample_import_id'
|
||||
GROUP BY (c.sample_id is not null)";
|
||||
|
||||
xhtml_table($db->GetAll($sql),array("drawn","count"),array(T_("Status"),T_("Number")));
|
||||
|
||||
|
||||
print "<p>" . T_("Outcomes") . "</p>";
|
||||
|
||||
|
||||
$sql = "SELECT o.description as des, o.outcome_id, count( c.case_id ) as count
|
||||
FROM `case` AS c, `outcome` AS o, sample as s
|
||||
WHERE c.questionnaire_id = '$questionnaire_id'
|
||||
AND c.sample_id = s.sample_id
|
||||
AND s.import_id = '$sample_import_id'
|
||||
AND c.current_outcome_id = o.outcome_id
|
||||
GROUP BY o.outcome_id";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
if (!empty($rs))
|
||||
{
|
||||
translate_array($rs,array("des"));
|
||||
xhtml_table($rs,array("des","count"),array(T_("Outcome"),T_("Count")),"tclass",array("des" => "Complete"));
|
||||
}
|
||||
else
|
||||
print "<p>" . T_("No outcomes recorded for this sample") . "</p>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
//display a list of shifts with completions and a link to either add a report or view reports
|
||||
print "<h2>" . T_("Shifts") . "</h2>";
|
||||
|
||||
$sql = "SELECT s.shift_id, CONCAT(DATE_FORMAT(CONVERT_TZ(s.start,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."'), ' - ', DATE_FORMAT(CONVERT_TZ(s.end,'UTC',o.Time_zone_name),'" . DATE_TIME_FORMAT ."')) as description,
|
||||
CASE WHEN sr.shift_id IS NULL THEN CONCAT('<a href=\'shiftreport.php?questionnaire_id=$questionnaire_id&shift_id=', s.shift_id, '&createnewreport=yes\'>" . T_("No shift reports: Add report") . "</a>') ELSE CONCAT('<a href=\'shiftreport.php?questionnaire_id=$questionnaire_id&shift_id=', s.shift_id, '\'>" . T_("View shift reports") . "</a>') END AS link, c.completions as completions, CONCAT('<a href=\'operatorperformance.php?questionnaire_id=$questionnaire_id&shift_id=', s.shift_id, '\'>" . T_("View operator performance") . "</a>') as operform
|
||||
FROM `shift` as s
|
||||
JOIN operator as o on (o.operator_id = '$operator_id')
|
||||
JOIN operator as o on (o.operator_id = '$admin_operator_id')
|
||||
LEFT JOIN shift_report as sr on (sr.shift_id = s.shift_id)
|
||||
LEFT JOIN ( SELECT count(*) as completions,sh.shift_id
|
||||
FROM `call` as a, `case` as b, shift as sh
|
||||
|
||||
245
admin/quotareport.php
Normal file
245
admin/quotareport.php
Normal file
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* This file is part of queXS
|
||||
*
|
||||
* queXS is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* queXS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with queXS; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*
|
||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
||||
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2009
|
||||
* @package queXS
|
||||
* @subpackage admin
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration file
|
||||
*/
|
||||
include_once(dirname(__FILE__).'/../config.inc.php');
|
||||
|
||||
/**
|
||||
* Database file
|
||||
*/
|
||||
include ("../db.inc.php");
|
||||
|
||||
/**
|
||||
* XHTML functions
|
||||
*/
|
||||
include ("../functions/functions.xhtml.php");
|
||||
|
||||
/**
|
||||
* Display functions
|
||||
*/
|
||||
include("../functions/functions.display.php");
|
||||
|
||||
/**
|
||||
* Input functions
|
||||
*/
|
||||
include("../functions/functions.input.php");
|
||||
|
||||
/**
|
||||
* Operator functions
|
||||
*/
|
||||
include("../functions/functions.operator.php");
|
||||
|
||||
/**
|
||||
* Limesurvey functions
|
||||
*/
|
||||
include("../functions/functions.limesurvey.php");
|
||||
|
||||
xhtml_head(T_("Quota report"),true,array("../css/table.css"),array("../js/window.js"));
|
||||
|
||||
print "<h2>" . T_("Select a questionnaire from the list below") . "</h2>";
|
||||
$questionnaire_id = false;
|
||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
display_questionnaire_chooser($questionnaire_id);
|
||||
|
||||
if ($questionnaire_id)
|
||||
{
|
||||
print "<h2>" . T_("Select a sample from the list below") . "</h2>";
|
||||
$sample_import_id = false;
|
||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
display_sample_chooser($questionnaire_id,$sample_import_id);
|
||||
|
||||
if ($sample_import_id)
|
||||
{
|
||||
if (isset($_GET['rowquota']))
|
||||
{
|
||||
$qsq = bigintval($_GET['rowquota']);
|
||||
$qr = 0;
|
||||
if (isset($_GET['close'])) $qr = 1;
|
||||
$sql = "UPDATE questionnaire_sample_quota_row
|
||||
SET quota_reached = $qr
|
||||
WHERE questionnaire_sample_quota_row_id = '$qsq'";
|
||||
$db->Execute($sql);
|
||||
if ($qr == 1)
|
||||
close_row_quota($qsq);
|
||||
else
|
||||
open_row_quota($qsq,false);
|
||||
}
|
||||
|
||||
//Display report of quotas
|
||||
$report = array();
|
||||
|
||||
//Rows to display: Strata Status Quota Sample Sample Used Sample Remaining Completes % Complete
|
||||
|
||||
// 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
|
||||
FROM sample as s
|
||||
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)
|
||||
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
|
||||
$drawn = 0;
|
||||
$remain = 0;
|
||||
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
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
|
||||
WHERE c.current_outcome_id = 10
|
||||
AND s.import_id = '$sample_import_id'
|
||||
AND s.sample_id = c.sample_id
|
||||
AND c.questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$rs = $db->GetRow($sql);
|
||||
|
||||
$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));
|
||||
|
||||
//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)
|
||||
$sql = "SELECT questionnaire_sample_quota_row_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison,exclude_var,exclude_val,qsq.description
|
||||
FROM questionnaire_sample_quota_row as qsq, questionnaire as q
|
||||
WHERE qsq.questionnaire_id = '$questionnaire_id'
|
||||
AND qsq.sample_import_id = '$sample_import_id'
|
||||
AND q.questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$r = $db->GetAll($sql);
|
||||
|
||||
foreach ($r as $v)
|
||||
{
|
||||
if ($v['lime_sgqa'] == -1)
|
||||
{
|
||||
$completions = limesurvey_quota_replicate_completions($v['lime_sid'],$questionnaire_id,$sample_import_id,$v['exclude_val'],$v['exclude_var']);
|
||||
$v['completions'] = "";
|
||||
$perc = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
$completions = limesurvey_quota_completions($v['lime_sgqa'],$v['lime_sid'],$questionnaire_id,$sample_import_id,$v['value'],$v['comparison']);
|
||||
$perc = 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
|
||||
FROM sample as s
|
||||
JOIN questionnaire_sample as qs ON (qs.questionnaire_id = '$questionnaire_id' and qs.sample_import_id = s.import_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']}')
|
||||
LEFT JOIN `case` as c ON (c.questionnaire_id = qs.questionnaire_id and c.sample_id = s.sample_id)
|
||||
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
|
||||
$drawn = 0;
|
||||
$remain = 0;
|
||||
|
||||
foreach ($rs as $r)
|
||||
{
|
||||
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 ($v['quota_reached'] == 1)
|
||||
$status = "<a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&rowquota={$v['questionnaire_sample_quota_row_id']}&open=open'>" . T_("closed") . "</a>";
|
||||
else
|
||||
$status = "<a href='?questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id&rowquota={$v['questionnaire_sample_quota_row_id']}&close=close'>" . T_("open") . "</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($v['quota_reached'] == 1)
|
||||
$status = T_("closed");
|
||||
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);
|
||||
}
|
||||
|
||||
//c. (Questionnaire quota) Monitor outcomes of questions in completed questionnaires, and abort interview when completion limit is reached
|
||||
$sql = "SELECT *
|
||||
FROM " . LIME_PREFIX . "quota as qu, questionnaire as q
|
||||
WHERE qu.sid = q.lime_sid
|
||||
AND qu.active = 1
|
||||
AND q.questionnaire_id = '$questionnaire_id'";
|
||||
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
//for each limesurvey quota
|
||||
foreach($rs as $r)
|
||||
{
|
||||
//limesurvey quotas for this question
|
||||
$quotas = (get_limesurvey_quota_info($r['id']));
|
||||
$sqlq = array();
|
||||
|
||||
foreach ($quotas as $q)
|
||||
$sqlq[] = "s." . $q['fieldname'] . " = '" . $q['value'] . "'";
|
||||
|
||||
$sql = "SELECT COUNT(id) as count
|
||||
FROM ".LIME_PREFIX."survey_{$r['sid']} as s
|
||||
JOIN `case` as c ON (c.questionnaire_id = '$questionnaire_id')
|
||||
JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = '$sample_import_id')
|
||||
WHERE ".implode(' AND ',$sqlq)." "."
|
||||
AND submitdate IS NOT NULL
|
||||
AND s.token = c.case_id";
|
||||
|
||||
$rs = $db->GetRow($sql);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
xhtml_table($report,array("strata","status","quota","sample","sampleused","sampleremain","completions","perc"),array(T_("Strata"),T_("Status"),T_("Quota"),T_("Sample"),T_("Sample Used"),T_("Sample Remaining"),T_("Completions"),T_("% Complete")),"tclass",false,false);
|
||||
}
|
||||
}
|
||||
|
||||
xhtml_foot();
|
||||
|
||||
|
||||
?>
|
||||
@@ -69,22 +69,29 @@ include("../functions/functions.operator.php");
|
||||
|
||||
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']))
|
||||
{
|
||||
//need to add quota
|
||||
$value = -1;
|
||||
$comparison = -1;
|
||||
$completions = -1;
|
||||
$sgqa = -1;
|
||||
|
||||
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
$sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
$value = $db->quote($_GET['value']);
|
||||
$completions = $db->quote($_GET['completions']);
|
||||
$sgqa = $db->quote($_GET['sgqa']);
|
||||
$comparison = $db->quote($_GET['comparison']);
|
||||
if ($_GET['sgqa'] != -1)
|
||||
{
|
||||
$sgqa = $db->quote($_GET['sgqa']);
|
||||
$comparison = $db->quote($_GET['comparison']);
|
||||
$value = $db->quote($_GET['value']);
|
||||
$completions = $db->quote($_GET['completions']);
|
||||
}
|
||||
$exclude_val = $db->quote($_GET['exclude_val']);
|
||||
$exclude_var = $db->quote($_GET['exclude_var']);
|
||||
$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)
|
||||
VALUES ($questionnaire_id, $sample_import_id, $sgqa, $value, $completions, $comparison, $exclude_var, $exclude_val)";
|
||||
$sql = "INSERT INTO questionnaire_sample_quota_row(questionnaire_id, sample_import_id, lime_sgqa,value,completions,comparison,exclude_var,exclude_val,description)
|
||||
VALUES ($questionnaire_id, $sample_import_id, $sgqa, $value, $completions, $comparison, $exclude_var, $exclude_val, $description)";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
@@ -99,20 +106,7 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['questionnaire_sample_quota_
|
||||
$questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
$questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
|
||||
|
||||
$db->StartTrans();
|
||||
|
||||
$sql = "DELETE FROM questionnaire_sample_quota_row
|
||||
WHERE questionnaire_sample_quota_row_id = '$questionnaire_sample_quota_row_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$sql = "DELETE FROM questionnaire_sample_quota_row_exclude
|
||||
WHERE questionnaire_sample_quota_row_id = '$questionnaire_sample_quota_row_id'";
|
||||
|
||||
$db->Execute($sql);
|
||||
|
||||
$db->CompleteTrans();
|
||||
|
||||
open_row_quota($questionnaire_sample_quota_row_id);
|
||||
}
|
||||
|
||||
$questionnaire_id = false;
|
||||
@@ -142,6 +136,12 @@ if ($questionnaire_id != false)
|
||||
|
||||
if ($sample_import_id != false)
|
||||
{
|
||||
if (isset($_POST['copy_sample_import_id']))
|
||||
{
|
||||
copy_row_quota($questionnaire_id,$sample_import_id,bigintval($_POST['copy_sample_import_id']));
|
||||
print "<h3>" . T_("Copied quotas") . "</h3>";
|
||||
}
|
||||
|
||||
print "<h1>" . T_("Current row quotas (click to delete)") . "</h1>";
|
||||
|
||||
$sql = "SELECT questionnaire_sample_quota_row_id,lime_sgqa,value,completions,quota_reached,lime_sid,comparison,exclude_var,exclude_val
|
||||
@@ -160,18 +160,39 @@ if ($questionnaire_id != false)
|
||||
{
|
||||
foreach($r as $v)
|
||||
{
|
||||
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> - ";
|
||||
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['quota_reached'] == 1)
|
||||
print T_("Row quota reached");
|
||||
print T_("Row quota reached (Closed)");
|
||||
else
|
||||
print T_("Row quota not yet reached");
|
||||
print T_("Row quota not yet reached (Open)");
|
||||
|
||||
print " - " . T_("Current completions: ") . limesurvey_quota_completions($v['lime_sgqa'],$v['lime_sid'],$questionnaire_id,$sample_import_id,$v['value'],$v['comparison']);
|
||||
if ($v['lime_sgqa'] != -1)
|
||||
print " - " . T_("Current completions: ") . limesurvey_quota_completions($v['lime_sgqa'],$v['lime_sid'],$questionnaire_id,$sample_import_id,$v['value'],$v['comparison']);
|
||||
|
||||
print "</div>";
|
||||
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT s.sample_import_id as value,s.description, '' AS selected
|
||||
FROM sample_import as s, questionnaire_sample as q
|
||||
WHERE q.questionnaire_id = $questionnaire_id
|
||||
AND q.sample_import_id = s.sample_import_id
|
||||
AND s.sample_import_id != '$sample_import_id'";
|
||||
|
||||
$ss = $db->GetAll($sql);
|
||||
|
||||
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): ");
|
||||
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>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -193,8 +214,13 @@ if ($questionnaire_id != false)
|
||||
LEFT JOIN `" . LIME_PREFIX . "answers` AS a ON ( a.qid = q.qid )
|
||||
WHERE q.sid = '$lime_sid'";
|
||||
|
||||
|
||||
display_chooser($db->GetAll($sql),"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id");
|
||||
$rs = $db->GetAll($sql);
|
||||
|
||||
$selected = "";
|
||||
if ($sgqa == -1) $selected = "selected='selected'";
|
||||
array_unshift($rs,array("value" => -1, "description" => T_("No question (Replicate)"), "selected" => $selected));
|
||||
|
||||
display_chooser($rs,"sgqa","sgqa",true,"questionnaire_id=$questionnaire_id&sample_import_id=$sample_import_id");
|
||||
|
||||
if ($sgqa != false)
|
||||
{
|
||||
@@ -236,9 +262,16 @@ if ($questionnaire_id != false)
|
||||
?>
|
||||
<form action="" method="get">
|
||||
<p>
|
||||
<label for="description"><? echo T_("Describe this quota"); ?> </label><input type="text" name="description" id="description"/> <br/>
|
||||
<? if ($sgqa != -1) { ?>
|
||||
<label for="value"><? echo T_("The code value to compare"); ?> </label><input type="text" name="value" id="value"/> <br/>
|
||||
<label for="comparison"><? 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/>
|
||||
<label for="completions"><? echo T_("The number of completions to stop calling at"); ?> </label><input type="text" name="completions" id="completions"/> <br/>
|
||||
<? } else { ?>
|
||||
<input type="hidden" name="value" value="-1"/>
|
||||
<input type="hidden" name="comparison" value="-1"/>
|
||||
<input type="hidden" name="completions" value="-1"/>
|
||||
<? } ?>
|
||||
<label for="exclude_val"><? echo T_("Exclude from the sample where the value is like"); ?></label>
|
||||
<?
|
||||
|
||||
|
||||
130
admin/samplecallattempts.php
Normal file
130
admin/samplecallattempts.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* Display sample call attempt report (A listing of how many attempts made for cases within a sample)
|
||||
*
|
||||
*
|
||||
* This file is part of queXS
|
||||
*
|
||||
* queXS is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* queXS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with queXS; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*
|
||||
* @author Adam Zammit <adam.zammit@acspri.org.au>
|
||||
* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2009
|
||||
* @package queXS
|
||||
* @subpackage admin
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration file
|
||||
*/
|
||||
include_once(dirname(__FILE__).'/../config.inc.php');
|
||||
|
||||
/**
|
||||
* Database file
|
||||
*/
|
||||
include ("../db.inc.php");
|
||||
|
||||
/**
|
||||
* XHTML functions
|
||||
*/
|
||||
include ("../functions/functions.xhtml.php");
|
||||
|
||||
/**
|
||||
* Display functions
|
||||
*/
|
||||
include("../functions/functions.display.php");
|
||||
|
||||
/**
|
||||
* Input functions
|
||||
*/
|
||||
include("../functions/functions.input.php");
|
||||
|
||||
xhtml_head(T_("Sample call attempt"),true,array("../css/table.css"),array("../js/window.js"));
|
||||
|
||||
print "<h2>" . T_("Overall") . "</h2>";
|
||||
|
||||
$sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
|
||||
FROM ( SELECT count( call_attempt_id ) AS ca1
|
||||
FROM call_attempt
|
||||
GROUP BY case_id) AS t1
|
||||
GROUP BY ca1";
|
||||
|
||||
xhtml_table($db->GetAll($sql),array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
|
||||
|
||||
$questionnaire_id = false;
|
||||
if (isset($_GET['questionnaire_id'])) $questionnaire_id = bigintval($_GET['questionnaire_id']);
|
||||
display_questionnaire_chooser($questionnaire_id);
|
||||
|
||||
if ($questionnaire_id)
|
||||
{
|
||||
$sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
|
||||
FROM ( SELECT count( call_attempt.call_attempt_id ) AS ca1
|
||||
FROM call_attempt
|
||||
JOIN `case` ON (`case`.case_id = call_attempt.case_id AND `case`.questionnaire_id = '$questionnaire_id')
|
||||
GROUP BY call_attempt.case_id) AS t1
|
||||
GROUP BY ca1";
|
||||
|
||||
print "<h2>" . T_("This project") . "</h2>";
|
||||
xhtml_table($db->GetAll($sql),array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
|
||||
|
||||
$sample_import_id = false;
|
||||
if (isset($_GET['sample_import_id'])) $sample_import_id = bigintval($_GET['sample_import_id']);
|
||||
display_sample_chooser($questionnaire_id,$sample_import_id);
|
||||
|
||||
if ($sample_import_id)
|
||||
{
|
||||
$sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
|
||||
FROM ( SELECT count( call_attempt.call_attempt_id ) AS ca1
|
||||
FROM call_attempt
|
||||
JOIN `case` ON (`case`.case_id = call_attempt.case_id AND `case`.questionnaire_id = '$questionnaire_id')
|
||||
JOIN sample ON (sample.sample_id = `case`.sample_id AND sample.import_id = '$sample_import_id')
|
||||
GROUP BY call_attempt.case_id) AS t1
|
||||
GROUP BY ca1";
|
||||
|
||||
print "<h2>" . T_("This sample") . "</h2>";
|
||||
xhtml_table($db->GetAll($sql),array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
|
||||
|
||||
$questionnaire_sample_quota_row_id = false;
|
||||
if (isset($_GET['questionnaire_sample_quota_row_id'])) $questionnaire_sample_quota_row_id = bigintval($_GET['questionnaire_sample_quota_row_id']);
|
||||
display_quota_chooser($questionnaire_id,$sample_import_id,$questionnaire_sample_quota_row_id);
|
||||
|
||||
if ($questionnaire_sample_quota_row_id)
|
||||
{
|
||||
$sql = "SELECT ca1 AS callattempts, COUNT( ca1 ) AS sample
|
||||
FROM ( SELECT count( call_attempt.call_attempt_id ) AS ca1
|
||||
FROM call_attempt
|
||||
JOIN `case` ON (`case`.case_id = call_attempt.case_id AND `case`.questionnaire_id = '$questionnaire_id')
|
||||
JOIN sample ON (sample.sample_id = `case`.sample_id AND sample.import_id = '$sample_import_id')
|
||||
JOIN questionnaire_sample_quota_row as q ON (q.questionnaire_sample_quota_row_id = '$questionnaire_sample_quota_row_id')
|
||||
JOIN sample_var ON (sample_var.sample_id = `case`.sample_id AND sample_var.var LIKE q.exclude_var AND sample_var.val LIKE q.exclude_val)
|
||||
GROUP BY call_attempt.case_id) AS t1
|
||||
GROUP BY ca1";
|
||||
|
||||
print "<h2>" . T_("This quota") . "</h2>";
|
||||
xhtml_table($db->GetAll($sql),array("sample","callattempts"),array(T_("Number of cases"),T_("Call attempts made")),"tclass",false,array("sample"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xhtml_foot();
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user