2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

merged from master

This commit is contained in:
Adam Zammit
2017-02-16 08:55:10 +11:00
8 changed files with 335 additions and 272 deletions

View File

@@ -79,6 +79,9 @@ $js_foot = array(
);
global $db;
$error = "";
if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['call_max']) && isset($_GET['call_attempt_max']))
{
//need to add sample to questionnaire
@@ -103,51 +106,46 @@ if (isset($_GET['questionnaire_id']) && isset($_GET['sample']) && isset($_GET['
if (isset($_GET['generatecases']))
{
include_once("../functions/functions.operator.php");
//TODO: check here if attributes available for assigning sample variables
//if not - fail
$db->StartTrans();
$lime_sid = $db->GetOne("SELECT lime_sid FROM questionnaire WHERE questionnaire_id = '$questionnaire_id'");
$testing = $db->GetOne("SELECT testing FROM questionnaire WHERE questionnaire_id = '$questionnaire_id'");
//add limesurvey attribute for each sample var record
$sql = "SELECT var,type
FROM sample_import_var_restrict
//find the number of sample variables required
$sql = "SELECT count(*)
FROM sample_import_var_restrict
WHERE sample_import_id = '$sid'
ORDER BY var_id ASC";
AND type = 1";
$rs = $db->GetAll($sql);
$varsrequired = $db->GetOne($sql);
$i = 1;
$addsample = false;
$fields = array();
$fieldcontents='';
foreach($rs as $r)
{
$fields[]=array('attribute_'.$i,'C','255');
$fieldcontents.='attribute_'.$i.'='.$r['var']."\n";
$i++;
}
if ($varsrequired > 0) {
$addsample = true;
}
include_once("../functions/functions.operator.php");
$db->StartTrans();
$lime_sid = $db->GetOne("SELECT lime_sid FROM questionnaire WHERE questionnaire_id = '$questionnaire_id'");
$testing = $db->GetOne("SELECT testing FROM questionnaire WHERE questionnaire_id = '$questionnaire_id'");
//generate one case for each sample record and set outcome to 41
$sql = "SELECT sample_id
FROM sample
WHERE import_id = '$sid'";
$sql = "SELECT sample_id
FROM sample
WHERE import_id = '$sid'";
$rs = $db->GetAll($sql);
$rs = $db->GetAll($sql);
foreach($rs as $r)
{
set_time_limit(30);
//TODO : update add_case function to include attributes based on var_id ASC
add_case($r['sample_id'],$questionnaire_id,"NULL",$testing,41, true);
}
foreach($rs as $r)
{
set_time_limit(30);
if (add_case($r['sample_id'],$questionnaire_id,"NULL",$testing,41, $addsample) === false) {
$error = "Could not add case - please ensure there enough additional attributes available in your Limesurvey participant table";
break;
}
}
$db->CompleteTrans();
}
$db->CompleteTrans();
}
}
if (isset($_POST['edit']))
@@ -312,8 +310,11 @@ print "</div>";
if ($questionnaire_id != false)
{
print "<div class='panel-body'>
if ($error != "") {
print "<div class='alert text-danger'>$error</div>";
}
print "<div class='panel-body'>
<h3 class=''><i class='fa fa-list-ul text-primary'></i>&emsp;". T_("Samples assigned to questionnaire") ." <span class='text-primary'>" . $db->GetOne("SELECT description from questionnaire WHERE questionnaire_id = $questionnaire_id") . "</span></h3>";
$sql = "SELECT q.sort_order, si.description as description,si.sample_import_id,
@@ -400,13 +401,10 @@ if ($questionnaire_id != false)
<div class="col-sm-1"><input type="checkbox" id = "allownew" name="allownew" checked="checked" class="col-sm-1" data-toggle="toggle" data-size="small" data-on="<?php echo T_("Yes");?>" data-off="<?php echo T_("No");?>" data-width="85"/></div>
<label class="control-label text-info"><?php ;?></label><br/><br/><br/>
<?php $self_complete = $db->GetOne("SELECT self_complete FROM questionnaire WHERE questionnaire_id = '$questionnaire_id'");
if ($self_complete) {?>
<label for="generatecases" class="control-label col-lg-4"><?php echo T_("Generate cases for all sample records and set outcome to 'Self completion email invitation sent'?");?></label>
<div class="col-sm-1"><input type="checkbox" id = "generatecases" name="generatecases" class="col-sm-1" data-toggle="toggle" data-size="small" data-on="<?php echo T_("Yes");?>" data-off="<?php echo T_("No");?>" data-width="85"/></div>
<em class="control-label"> * <?php echo T_("Ideal if you intend to send an email invitation to sample members before attempting to call using queXS");?></em>
<em class="control-label"> * <?php echo T_("Ideal if you intend to send an email invitation to sample members before attempting to call using queXS") . " " . T_("Please ensure there are sufficient additional attribute fields in your Limesurvey questionnaire so that sample records can be inserted."); ?></em>
<div class='clearfix '></div></br>
<?php }?>
<input type="hidden" name="questionnaire_id" value="<?php print($questionnaire_id);?>"/>

View File

@@ -65,8 +65,8 @@ if (isset($_POST['import_file']))
if (isset($_POST['ras'])) $ras = 1;
if (isset($_POST['rws'])) $rws = 1;
if (isset($_POST['testing'])) $testing = 1;
if (isset($_POST['referral'])) $referral = 1;
if (isset($_POST['respsc'])) $respsc = 1;
if (isset($_POST['referral'])) $respsc = 1;
if ($_POST['selectrs'] != "none") $rs = 1;
$name = $db->qstr($_POST['description']);
@@ -221,7 +221,14 @@ if (!empty($surveys)){?>
<input name="referral" type="checkbox" data-toggle="toggle" data-on="<?php echo T_("Yes"); ?>" data-off="<?php echo T_("No"); ?>" data-width="80"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Allow for respondent self completion via email invitation?"); ?></label>
<div class="col-sm-4"style="height: 30px;">
<input name="respsc" type="checkbox" data-toggle="toggle" data-on="<?php echo T_("Yes"); ?>" data-off="<?php echo T_("No"); ?>" data-width="80"/>
</div>
</div>
<?php
/* CKEditor */

View File

@@ -296,7 +296,7 @@ if (isset($_POST['update']) && isset($_GET['modify']))
$rs_project_end = $db->qstr(html_entity_decode($_POST['rs_project_end'],ENT_QUOTES,'UTF-8'));
$sql = "UPDATE questionnaire
SET description = $name, info = $info, rs_project_end = $rs_project_end, restrict_appointments_shifts = '$ras', restrict_work_shifts = '$rws', self_complete = $respsc, referral = $referral
SET description = $name, info = $info, rs_project_end = $rs_project_end, restrict_appointments_shifts = '$ras', restrict_work_shifts = '$rws', referral = $referral, self_complete = $respsc
WHERE questionnaire_id = '$questionnaire_id'";
$db->Execute($sql);
@@ -321,7 +321,6 @@ if (isset($_GET['modify']))
$rs = $db->GetRow($sql);
$referral = $testing = $rws = $ras = $rsc = "checked=\"checked\"";
$rscd = "";
$aio = $qbq = $gat = "";
if ($rs['lime_mode'] == "survey") $aio = "selected=\"selected\"";
@@ -335,7 +334,6 @@ if (isset($_GET['modify']))
if ($rs['self_complete'] == 0)
{
$rsc = "";
$rscd = "style='display:none;'";
}
xhtml_head(T_("Modify Questionnaire "),true,$css,$js_head, false, false, false, " &ensp;<span class=' text-uppercase'>" . "$rs[description]" . "</span>");
@@ -390,53 +388,7 @@ if (isset($_GET['modify']))
</div>
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Allow for respondent self completion via email invitation?"); ?> </label>
<div class="col-sm-4" style="height: 30px;"><input name="respsc" id="respsc" type="checkbox" <?php echo $rsc ?> onchange="if(this.checked==true) {show(this,'limesc'); $('#url').attr('required','required');} else{ hide(this,'limesc'); $('#url').removeAttr('required');}" data-toggle="toggle" data-on="<?php echo T_("Yes"); ?>" data-off="<?php echo T_("No"); ?>" data-width="80"/></div>
</div>
<div id="limesc" <?php echo $rscd; ?> >
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Questionnaire display mode for respondent");?>: </label>
<div class="col-sm-4">
<select class="form-control" name="lime_mode">
<option <?php echo $aio;?> value="survey"><?php echo T_("All in one"); ?></option>
<option <?php echo $qbq;?> value="question"><?php echo T_("Question by question"); ?></option>
<option <?php echo $gat;?> value="group"><?php echo T_("Group at a time"); ?></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" ><?php echo T_("Limesurvey template for respondent");?>: </label>
<div class="col-sm-4">
<select class="form-control" name="lime_template">
<?php
if ($handle = opendir(dirname(__FILE__)."/../include/limesurvey/templates")) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && is_dir(dirname(__FILE__)."/../include/limesurvey/templates/" . $entry)){
echo "<option value=\"$entry\" ";
if ($rs['lime_template'] == $entry) echo " selected=\"selected\" ";
echo ">$entry</option>";
}
}
closedir($handle);
}
if ($handle = opendir(dirname(__FILE__)."/../include/limesurvey/upload/templates")) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && is_dir(dirname(__FILE__)."/../include/limesurvey/upload/templates/" . $entry)){
echo "<option value=\"$entry\" ";
if ($rs['lime_template'] == $entry) echo " selected=\"selected\" ";
echo ">$entry</option>";
}
}
closedir($handle);
}
?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label text-danger" ><?php echo T_("URL to forward respondents on self completion (required)");?>: </label>
<div class="col-sm-4">
<input class="form-control" name="lime_endurl" id="url" type="url" value="<?php echo $rs['lime_endurl']; ?>"/>
</div>
<div class="col-sm-4" style="height: 30px;"><input name="respsc" id="respsc" type="checkbox" <?php echo $rsc ?> data-toggle="toggle" data-on="<?php echo T_("Yes"); ?>" data-off="<?php echo T_("No"); ?>" data-width="80"/></div>
</div>
</div>
<?php

View File

@@ -493,7 +493,8 @@ if ($case_id != false)
$sid = get_lime_sid($case_id);
$id = get_lime_id($case_id);
$url = get_lime_url($case_id);
print "<div class='panel-body'>";
print "<div class='panel-body'>";
if ($id)
print "<h4><a href='" . $url . "/admin/dataentry/sa/editdata/subaction/edit/surveyid/$sid/id/$id' class='btn btn-default btn-lime'><i class='fa fa-lemon-o fa-lg'></i>&emsp;" . T_("Modify responses for this case") . "</a></h4>";
else

View File

@@ -1,13 +1,13 @@
-- phpMyAdmin SQL Dump
-- version 3.4.10.1deb1
-- version 4.0.10deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 03, 2015 at 12:47 PM
-- Server version: 5.5.44
-- PHP Version: 5.3.10-1ubuntu3.19
-- Generation Time: Feb 09, 2017 at 02:02 PM
-- Server version: 5.5.54-0ubuntu0.14.04.1-log
-- PHP Version: 5.5.9-1ubuntu4.20
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
@@ -17,7 +17,7 @@ SET time_zone = "+00:00";
/*!40101 SET NAMES utf8 */;
--
-- Database: `quexs`
-- Database: `quexs-remotelime`
--
-- --------------------------------------------------------
@@ -123,7 +123,7 @@ CREATE TABLE `call` (
KEY `call_attempt_id` (`call_attempt_id`),
KEY `contact_phone_id` (`contact_phone_id`),
KEY `start` (`start`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -142,7 +142,7 @@ CREATE TABLE `call_attempt` (
KEY `case_id` (`case_id`),
KEY `end` (`end`),
KEY `respondent_id` (`respondent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -233,7 +233,7 @@ CREATE TABLE `case` (
KEY `questionnaire_id` (`questionnaire_id`),
KEY `sortorder` (`sortorder`),
KEY `last_call_id` (`last_call_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -262,7 +262,7 @@ CREATE TABLE `case_note` (
PRIMARY KEY (`case_note_id`),
KEY `case_id` (`case_id`),
KEY `operator_id` (`operator_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -322,7 +322,7 @@ CREATE TABLE `contact_phone` (
`description` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`contact_phone_id`),
KEY `case_id` (`case_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -367,39 +367,16 @@ CREATE TABLE `extension` (
-- --------------------------------------------------------
--
-- Table structure for table `lime_users`
-- Table structure for table `failed_login_attempts`
--
CREATE TABLE `lime_users` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`users_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`password` blob NOT NULL,
`full_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`parent_id` int(11) NOT NULL,
`lang` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(320) COLLATE utf8_unicode_ci DEFAULT NULL,
`create_survey` tinyint(1) NOT NULL DEFAULT '0',
`create_user` tinyint(1) NOT NULL DEFAULT '0',
`participant_panel` tinyint(1) NOT NULL DEFAULT '0',
`delete_user` tinyint(1) NOT NULL DEFAULT '0',
`superadmin` tinyint(1) NOT NULL DEFAULT '0',
`configurator` tinyint(1) NOT NULL DEFAULT '0',
`manage_template` tinyint(1) NOT NULL DEFAULT '0',
`manage_label` tinyint(1) NOT NULL DEFAULT '0',
`htmleditormode` varchar(7) COLLATE utf8_unicode_ci DEFAULT 'default',
`templateeditormode` varchar(7) COLLATE utf8_unicode_ci DEFAULT 'default',
`questionselectormode` varchar(7) COLLATE utf8_unicode_ci DEFAULT 'default',
`one_time_pw` blob,
`dateformat` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`uid`),
UNIQUE KEY `users_name` (`users_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `lime_users`
--
INSERT INTO `lime_users` (`uid`, `users_name`, `password`, `full_name`, `parent_id`, `lang`, `email`, `create_survey`, `create_user`, `participant_panel`, `delete_user`, `superadmin`, `configurator`, `manage_template`, `manage_label`, `htmleditormode`, `templateeditormode`, `questionselectormode`, `one_time_pw`, `dateformat`) VALUES(1, 'admin', 0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438, 'Your Name', 0, 'auto', 'your-email@example.net', 1, 1, 0, 1, 1, 1, 1, 1, 'default', 'default', 'default', NULL, 1);
CREATE TABLE `failed_login_attempts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(37) COLLATE utf8_unicode_ci NOT NULL,
`last_attempt` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`number_attempts` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -421,12 +398,15 @@ CREATE TABLE `operator` (
`chat_password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`operator_id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `operator`
--
INSERT INTO `operator` (`operator_id`, `username`, `firstName`, `lastName`, `Time_zone_name`, `enabled`, `voip`, `next_case_id`, `chat_enable`, `chat_user`, `chat_password`) VALUES(1, 'admin', 'CATI', 'Admin', 'Australia/Victoria', 1, 0, NULL, 0, '', '');
-- --------------------------------------------------------
INSERT INTO `operator` (`operator_id`, `username`, `firstName`, `lastName`, `Time_zone_name`, `enabled`, `voip`, `next_case_id`, `chat_enable`, `chat_user`, `chat_password`) VALUES
(1, 'admin', 'CATI', 'Admin', 'Australia/Victoria', 1, 0, NULL, 0, '', '');
--
-- Table structure for table `operator_questionnaire`
@@ -450,11 +430,14 @@ CREATE TABLE `operator_skill` (
PRIMARY KEY (`operator_id`,`outcome_type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Dumping data for table `operator_skill`
--
INSERT INTO `operator_skill` (`operator_id`, `outcome_type_id`) VALUES
(1, 1),
(1, 5);
INSERT INTO `operator_skill` (`operator_id`, `outcome_type_id`) VALUES(1, 1);
INSERT INTO `operator_skill` (`operator_id`, `outcome_type_id`) VALUES(1, 5);
-- --------------------------------------------------------
--
-- Table structure for table `outcome`
@@ -472,60 +455,61 @@ CREATE TABLE `outcome` (
`eligible` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'If the respondent is eligible to participate',
`require_note` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether to require a note to be entered',
`calc` char(2) COLLATE utf8_unicode_ci NOT NULL,
`default` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Used as default for questionnaire outcomes',
`permanent` TINYINT(1) UNSIGNED NOT NULL COMMENT 'Permanent outcome, used for all questionnaires, not possible to de-select',
`default` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT 'Used as default for questionnaire outcomes',
`permanent` tinyint(1) unsigned NOT NULL COMMENT 'Permanent outcome, used for all questionnaires, not possible to de-select',
PRIMARY KEY (`outcome_id`),
KEY `calc` (`calc`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=100;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `outcome`
--
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (1,'3.11','Not attempted or worked',0,1,1,0,1,0,0,'UH',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (2,'3.13','No answer',180,1,1,0,1,1,0,'UH',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (3,'3.16','Technical phone problems',180,1,1,0,1,0,0,'UH',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (4,'2.34','Other, Referred to Supervisor (Eligible)',0,2,0,1,1,1,1,'O',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (5,'3.91','Other, Referred to Supervisor (Unknown eligibility)',0,2,0,0,1,0,1,'UO',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (6,'2.111a','Soft Refusal, Other',10080,3,0,1,1,1,1,'R',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (7,'2.111b','Hard Refusal, Other',10080,3,0,1,1,1,1,'R',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (8,'2.112a','Soft Refusal, Respondent',10080,3,0,1,1,1,1,'R',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (9,'2.112b','Hard Refusal, Respondent',10080,3,0,1,1,1,1,'R',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (10,'1.1','Complete',0,4,0,1,1,1,0,'I',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (11,'2.112','Known respondent refusal',0,4,0,1,1,1,0,'R',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (12,'2.111','Household-level refusal',0,4,0,1,1,1,0,'R',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (13,'2.112c','Broken appointment (Implicit refusal)',10080,3,1,0,1,1,0,'R',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (14,'4.32','Disconnected number',0,4,1,0,0,0,0,'',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (15,'4.20','Fax/data line',0,4,1,1,0,0,0,'',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (16,'4.51','Business, government office, other organization',0,4,1,1,0,0,0,'',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (17,'4.70','No eligible respondent',0,4,1,1,0,0,0,'',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (18,'2.35a','Accidental hang up or temporary phone problem',0,1,1,1,1,1,0,'O',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (19,'2.12a','Definite Appointment - Respondent',0,5,0,1,1,1,0,'R',1,1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (20,'2.12b','Definite Appointment - Other',0,5,0,1,1,1,0,'R',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (21,'2.13a','Unspecified Appointment - Respondent',0,5,0,1,1,1,0,'R',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (22,'2.13b','Unspecified Appointment - Other',0,5,0,1,1,1,0,'R',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (23,'2.221','Household answering machine - Message left',180,1,1,1,1,1,0,'NC',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (24,'2.222','Household answering machine - No message left',180,1,1,1,1,1,0,'NC',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (25,'2.31','Respondent Dead',0,4,0,1,0,1,0,'O',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (26,'2.32','Physically or mentally unable/incompetent',0,4,0,1,0,1,0,'O',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (27,'2.331','Household level language problem',0,4,1,1,0,1,0,'O',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (28,'2.332','Respondent language problem',0,4,0,1,0,1,0,'O',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (29,'3.14','Answering machine - Not a household',0,4,1,1,0,0,0,'UH',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (30,'4.10','Out of sample',0,4,0,1,0,0,0,'',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (31,'2.20','Non contact',180,1,1,1,1,1,0,'NC',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (32,'4.80','Quota filled',0,4,0,1,0,0,0,'',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (33,'2.36','Miscellaneous - Unavailable for a week',10080,1,0,1,1,1,0,'O',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (40,'1.1','Self completed online',0,4,0,1,1,1,0,'I',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (41,'2.36','Self completion email invitation sent',10080,1,0,1,1,1,0,'O',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (42,'3.90','Max call attempts reached (Unknown eligibility)',0,1,0,1,1,0,0,'UH',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (43,'3.90','Max calls reached (Unknown eligibility)',0,1,0,1,1,0,0,'UH',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (44,'2.30','Max call attempts reached (Eligible)',0,1,0,1,1,1,0,'O',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES (45,'2.30','Max calls reached (Eligible)',0,1,0,1,1,1,0,'O',1,0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(1, '3.11', 'Not attempted or worked', 0, 1, 1, 0, 1, 0, 0, 'UH', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(2, '3.13', 'No answer', 180, 1, 1, 0, 1, 1, 0, 'UH', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(3, '3.16', 'Technical phone problems', 180, 1, 1, 0, 1, 0, 0, 'UH', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(4, '2.34', 'Other, Referred to Supervisor (Eligible)', 0, 2, 0, 1, 1, 1, 1, 'O', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(5, '3.91', 'Other, Referred to Supervisor (Unknown eligibility)', 0, 2, 0, 0, 1, 0, 1, 'UO', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(6, '2.111a', 'Soft Refusal, Other', 10080, 3, 0, 1, 1, 1, 1, 'R', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(7, '2.111b', 'Hard Refusal, Other', 10080, 3, 0, 1, 1, 1, 1, 'R', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(8, '2.112a', 'Soft Refusal, Respondent', 10080, 3, 0, 1, 1, 1, 1, 'R', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(9, '2.112b', 'Hard Refusal, Respondent', 10080, 3, 0, 1, 1, 1, 1, 'R', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(10, '1.1', 'Complete', 0, 4, 0, 1, 1, 1, 0, 'I', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(11, '2.112', 'Known respondent refusal', 0, 4, 0, 1, 1, 1, 0, 'R', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(12, '2.111', 'Household-level refusal', 0, 4, 0, 1, 1, 1, 0, 'R', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(13, '2.112c', 'Broken appointment (Implicit refusal)', 10080, 3, 1, 0, 1, 1, 0, 'R', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(14, '4.32', 'Disconnected number', 0, 4, 1, 0, 0, 0, 0, '', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(15, '4.20', 'Fax/data line', 0, 4, 1, 1, 0, 0, 0, '', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(16, '4.51', 'Business, government office, other organization', 0, 4, 1, 1, 0, 0, 0, '', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(17, '4.70', 'No eligible respondent', 0, 4, 1, 1, 0, 0, 0, '', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(18, '2.35a', 'Accidental hang up or temporary phone problem', 0, 1, 1, 1, 1, 1, 0, 'O', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(19, '2.12a', 'Definite Appointment - Respondent', 0, 5, 0, 1, 1, 1, 0, 'R', 1, 1);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(20, '2.12b', 'Definite Appointment - Other', 0, 5, 0, 1, 1, 1, 0, 'R', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(21, '2.13a', 'Unspecified Appointment - Respondent', 0, 5, 0, 1, 1, 1, 0, 'R', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(22, '2.13b', 'Unspecified Appointment - Other', 0, 5, 0, 1, 1, 1, 0, 'R', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(23, '2.221', 'Household answering machine - Message left', 180, 1, 1, 1, 1, 1, 0, 'NC', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(24, '2.222', 'Household answering machine - No message left', 180, 1, 1, 1, 1, 1, 0, 'NC', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(25, '2.31', 'Respondent Dead', 0, 4, 0, 1, 0, 1, 0, 'O', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(26, '2.32', 'Physically or mentally unable/incompetent', 0, 4, 0, 1, 0, 1, 0, 'O', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(27, '2.331', 'Household level language problem', 0, 4, 1, 1, 0, 1, 0, 'O', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(28, '2.332', 'Respondent language problem', 0, 4, 0, 1, 0, 1, 0, 'O', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(29, '3.14', 'Answering machine - Not a household', 0, 4, 1, 1, 0, 0, 0, 'UH', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(30, '4.10', 'Out of sample', 0, 4, 0, 1, 0, 0, 0, '', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(31, '2.20', 'Non contact', 180, 1, 1, 1, 1, 1, 0, 'NC', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(32, '4.80', 'Quota filled', 0, 4, 0, 1, 0, 0, 0, '', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(33, '2.36', 'Miscellaneous - Unavailable for a week', 10080, 1, 0, 1, 1, 1, 0, 'O', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(40, '1.1', 'Self completed online', 0, 4, 0, 1, 1, 1, 0, 'I', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(41, '2.36', 'Self completion email invitation sent', 10080, 1, 0, 1, 1, 1, 0, 'O', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(42, '3.90', 'Max call attempts reached (Unknown eligibility)', 0, 1, 0, 1, 1, 0, 0, 'UH', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(43, '3.90', 'Max calls reached (Unknown eligibility)', 0, 1, 0, 1, 1, 0, 0, 'UH', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(44, '2.30', 'Max call attempts reached (Eligible)', 0, 1, 0, 1, 1, 1, 0, 'O', 1, 0);
INSERT INTO `outcome` (`outcome_id`, `aapor_id`, `description`, `default_delay_minutes`, `outcome_type_id`, `tryanother`, `contacted`, `tryagain`, `eligible`, `require_note`, `calc`, `default`, `permanent`) VALUES(45, '2.30', 'Max calls reached (Eligible)', 0, 1, 0, 1, 1, 1, 0, 'O', 1, 0);
-- Auto increment start from 100 for manual entries
ALTER TABLE `outcome` AUTO_INCREMENT = 100;
-- --------------------------------------------------------
--
@@ -562,7 +546,7 @@ CREATE TABLE `process` (
`kill` tinyint(1) NOT NULL DEFAULT '0',
`data` longtext COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`process_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -577,7 +561,7 @@ CREATE TABLE `process_log` (
`data` text COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`process_log_id`),
KEY `process_id` (`process_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -594,7 +578,7 @@ CREATE TABLE `qsqr_question` (
`description` text COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`qsqr_question_id`),
KEY `questionnaire_sample_quota_row_id` (`questionnaire_sample_quota_row_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -642,11 +626,11 @@ CREATE TABLE `questionnaire` (
`lime_template` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Limesurvey template for respondent self completion',
`lime_endurl` varchar(256) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Forwarding end URL for respondent self completion',
`enabled` tinyint(1) NOT NULL DEFAULT '1',
`outcomes` varchar(256) COLLATE utf8_unicode_ci NULL DEFAULT '1,2,3,7,9,10,14,17,18,19' COMMENT 'Comma-separated string of outcomes defined for the questionnaire',
`outcomes` varchar(256) COLLATE utf8_unicode_ci DEFAULT '1,2,3,7,9,10,14,17,18,19' COMMENT 'Comma-separated string of outcomes defined for the questionnaire',
`remote_id` int(11) NOT NULL,
PRIMARY KEY (`questionnaire_id`),
KEY `remote_id` (`remote_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -673,7 +657,7 @@ CREATE TABLE `questionnaire_prefill` (
`value` varchar(2048) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`questionnaire_prefill_id`),
KEY `questionnaire_id` (`questionnaire_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -728,7 +712,7 @@ CREATE TABLE `questionnaire_sample_quota` (
`completions` int(11) NOT NULL,
`quota_reached` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`questionnaire_sample_quota_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -749,7 +733,7 @@ CREATE TABLE `questionnaire_sample_quota_row` (
PRIMARY KEY (`questionnaire_sample_quota_row_id`),
KEY `questionnaire_id` (`questionnaire_id`),
KEY `sample_import_id` (`sample_import_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -793,6 +777,23 @@ CREATE TABLE `questionnaire_timeslot` (
-- --------------------------------------------------------
--
-- Table structure for table `remote`
--
CREATE TABLE `remote` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`description` text COLLATE utf8_unicode_ci NOT NULL,
`rpc_url` text COLLATE utf8_unicode_ci NOT NULL,
`username` text COLLATE utf8_unicode_ci NOT NULL,
`password` text COLLATE utf8_unicode_ci NOT NULL,
`type` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'limesurvey' COMMENT 'type of host',
`entry_url` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'entry url for interviewers',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `respondent`
--
@@ -805,7 +806,7 @@ CREATE TABLE `respondent` (
`Time_zone_name` char(64) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`respondent_id`),
KEY `case_id` (`case_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -835,7 +836,7 @@ CREATE TABLE `sample` (
`phone` char(30) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`sample_id`),
KEY `import_id` (`import_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -850,7 +851,7 @@ CREATE TABLE `sample_import` (
`refusal_conversion` tinyint(1) NOT NULL DEFAULT '1',
`enabled` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`sample_import_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -865,7 +866,7 @@ CREATE TABLE `sample_import_var_restrict` (
`type` smallint(10) unsigned NOT NULL,
`restrict` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`var_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
@@ -1031,6 +1032,29 @@ CREATE TABLE `timezone_template` (
PRIMARY KEY (`Time_zone_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`users_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`password` blob NOT NULL,
`full_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(320) COLLATE utf8_unicode_ci DEFAULT NULL,
`superadmin` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`uid`),
UNIQUE KEY `users_name` (`users_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`uid`, `users_name`, `password`, `full_name`, `email`, `superadmin`) VALUES(1, 'admin', 0x35653838343839386461323830343731353164306535366638646336323932373733363033643064366161626264643632613131656637323164313534326438, 'Your Name', 'your-email@example.net', 1);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View File

@@ -81,24 +81,15 @@ if (isset($_POST['email']) && ((isset($_POST['firstname']) && !empty($_POST['fir
$lime_sid = get_lime_sid($case_id);
$ca = get_call_attempt($operator_id);
$token = get_token($case_id);
$email = $db->qstr($_POST['email']);
$firstname = $db->qstr($_POST['firstname']);
$lastname = $db->qstr($_POST['lastname']);
$email = ($_POST['email']);
$firstname = ($_POST['firstname']);
$lastname = ($_POST['lastname']);
//set in Limesurvey
//set_participant_properties($sSessionKey, $lime_sid, array['token' => $token], array['email' => $email, 'firstname' => $firstname, 'lastname' => $lastname, 'emailstatus' => 'OK']);
$ret = lime_send_email($case_id,$email,$firstname,$lastname);
if (0) //if mail sent - disable temporarily TODO: update properties in limesurvey
if ($ret) //if mail sent
{
// Put call attempt id in to sent in Limesurvey
$sql = "UPDATE ". LIME_PREFIX . "tokens_{$lime_sid}
SET sent='$ca'
WHERE token='$token'";
//$db->Execute($sql);
//Add a note that sent
$sql = "INSERT INTO `case_note` (case_id,operator_id,note,datetime)

View File

@@ -150,13 +150,49 @@ function lime_list_answeroptions($qid,$qcode)
}
/** Get completed responses as an array based on the case_id
*/
function lime_get_responses_by_case($case_id,$fields)
function lime_send_email($case_id,$email,$firstname,$lastname)
{
global $db;
global $limeRPC;
global $limeKey;
global $limeRPC;
global $limeKey;
$sql = "SELECT c.token,c.questionnaire_id
FROM `case` as c
WHERE c.case_id = '$case_id'";
$rs = $db->GetRow($sql);
$token = $rs['token'];
$qid = $rs['questionnaire_id'];
$lime_id = limerpc_init_qid($qid);
$ret = false;
if ($lime_id !== false) {
$q = $limeRPC->set_participant_properties($limeKey,$lime_id,array('token' => $token),array('firstname' => $firstname, 'email' => $email, 'lastname' => $lastname));
if (!isset($q['status'])) {
//send email
$q2 = $limeRPC->invite_participants($limeKey, $lime_id, array($q['tid']));
if (!isset($q['status'])) {
$ret = true;
}
}
}
limerpc_close();
return $ret;
}
/** Get completed responses as an array based on the case_id
*/
function lime_get_responses_by_case($case_id,$fields = null)
{
global $db;
global $limeRPC;
global $limeKey;
$sql = "SELECT c.token,c.questionnaire_id
FROM `case` as c
@@ -165,7 +201,7 @@ function lime_get_responses_by_case($case_id,$fields)
$rs = $db->GetRow($sql);
$token = $rs['token'];
$qid = $rs['qid'];
$qid = $rs['questionnaire_id'];
$lime_id = limerpc_init_qid($qid);
@@ -175,12 +211,10 @@ function lime_get_responses_by_case($case_id,$fields)
$q = $limeRPC->export_responses_by_token($limeKey,$lime_id,'json',$token,null,'complete','code','short',$fields);
if (!isset($q['status'])) {
$ret = json_decode(base64_decode($q));
//TODO: check how this returns
var_dump($ret); die();
}
}
limerpc_close();
limerpc_close();
return $ret;
@@ -190,7 +224,7 @@ function lime_get_responses_by_case($case_id,$fields)
/** Get completd responses as an array based on the questionnaire
* indexed by token
*/
function lime_get_responses_by_questionnaire($qid,$fields)
function lime_get_responses_by_questionnaire($qid,$fields = null)
{
global $limeRPC;
global $limeKey;
@@ -203,8 +237,6 @@ function lime_get_responses_by_questionnaire($qid,$fields)
$q = $limeRPC->export_responses($limeKey,$lime_id,'json',null,'complete','code','short',null,null,$fields);
if (!isset($q['status'])) {
$ret = json_decode(base64_decode($q));
//TODO: check how this returns
var_dump($ret); die();
}
}
@@ -234,7 +266,6 @@ function lime_add_token($qid,$params)
return $ret;
}
function get_token_value($questionnaire_id,$token, $value = 'sent')
{
global $limeKey;
@@ -301,7 +332,6 @@ function get_survey_list ()
* @param mixed $email
* @param resource $replace Optional, defaults to ''.
*
* @return TODO
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @since 2013-02-26
*/
@@ -525,6 +555,25 @@ function validate_email($email){
return TRUE;
}
function lime_compare($val1,$operator,$val2)
{
$val1 = trim($val1);
$val2 = trim($val2);
if ($operator == "<")
return ($val1 < $val2);
else if ($operator == ">")
return ($val1 > $val2);
else if ($operator == "<=")
return ($val1 <= $val2);
else if ($operator == ">=")
return ($val1 >= $val2);
else if ($operator == "NOT LIKE" || $operator == "!=")
return ($val1 != $val2);
else
return ($val1 == $val2);
}
/**
* Return the number of completions for a given
* questionnaire, where the given question has
@@ -543,25 +592,32 @@ function limesurvey_quota_completions($lime_sgqa,$lime_sid,$questionnaire_id,$sa
{
global $db;
$resp = lime_get_responses_by_questionnaire($questionnaire_id,array($lime_sgqa));
$resp = lime_get_responses_by_questionnaire($questionnaire_id);
$completions = false;
$completions = false;
if ($resp !== false) {
$sql = "SELECT c.token
FROM `case` as c
JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = '$sample_import_id')
WHERE c.questionnaire_id = '$questionnaire_id'";
$rs = $db->GetAssoc($sql);
if ($resp !== false) {
$sql = "SELECT c.token,c.token as tok
FROM `case` as c
JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = '$sample_import_id')
WHERE c.questionnaire_id = '$questionnaire_id'";
$rs = $db->GetAssoc($sql);
$completions = 0;
foreach($resp as $r) {
$completions = 0;
foreach($resp as $r) {
foreach($r as $r1) {
foreach($r1 as $rl) {
if (isset($rl->token) && isset($rs[$rl->token])) {
//match to a case in the sample
if (isset($rl->$lime_sgqa)) {
$completions += lime_compare($rl->$lime_sgqa, $comparison, $value);
}
}
}
}
}
}
return $completions;
}
@@ -710,7 +766,7 @@ function limesurvey_percent_complete($case_id)
global $db;
//TODO: use export_responses_by_token and check the lastpage variable
//TODO: use export_responses_by_token and check the lastpage variable?
//
return false;

View File

@@ -436,19 +436,24 @@ function add_case($sample_id,$questionnaire_id,$operator_id = "NULL",$testing =
$llastname = "";
$lemail = "";
$lfirstname = ($db->GetOne("SELECT sv.val
$params = array('firstname' => "",
'lastname' => "",
'email' => "",
'token' => $token);
$params['firstname'] = ($db->GetOne("SELECT sv.val
FROM sample_var as sv, sample_import_var_restrict as s
WHERE sv.var_id = s.var_id
AND sv.sample_id = '$sample_id'
AND s.type = '6'"));
$llastname = ($db->GetOne("SELECT sv.val
$params['lastname'] = ($db->GetOne("SELECT sv.val
FROM sample_var as sv, sample_import_var_restrict as s
WHERE sv.var_id = s.var_id
AND sv.sample_id = '$sample_id'
AND s.type = '7'"));
$lemail = ($db->GetOne("SELECT sv.val
$params['email'] = ($db->GetOne("SELECT sv.val
FROM sample_var as sv, sample_import_var_restrict as s
WHERE sv.var_id = s.var_id
AND sv.sample_id = '$sample_id'
@@ -457,19 +462,32 @@ function add_case($sample_id,$questionnaire_id,$operator_id = "NULL",$testing =
//include limesurvey functions
include_once(dirname(__FILE__).'/functions.limesurvey.php');
$ret = lime_add_token($questionnaire_id,array( 'firstname' => $lfirstname,
'lastname' => $llastname,
'email' => $lemail,
'token' => $token));
//fail to create case if can't add remote token
if ($ret === false)
$db->FailTrans();
if ($addlimeattributes)
if ($addlimeattributes)
{
//TODO: Add attributes from sample
$sql = "SELECT sv.val
FROM sample_var as sv, sample_import_var_restrict as s
WHERE sv.var_id = s.var_id
AND sv.sample_id = '$sample_id'
AND s.type = '1'
ORDER BY s.var_id ASC";
$vars = $db->GetAll($sql);
$att = 1;
foreach($vars as $v) {
$params['attribute_' . $att] = $v['val'];
$att++;
}
}
$ret = lime_add_token($questionnaire_id,$params);
//fail to create case if can't add remote token
if ($ret === false) {
$db->FailTrans();
$case_id = false;
}
}
}
@@ -1776,13 +1794,16 @@ function update_single_row_quota($qsqri,$case_id = false)
//get response data from Limesurvey
$resp = lime_get_responses_by_case($case_id);
//get the result from the current response
$resp = current(current(current($resp)));
foreach($qev as $ev)
{
$sql2 .= " AND '" . $resp[$ev['lime_sgqa']] . " ' {$ev['comparison']} '{$ev['value']}' ";
$sql2 .= " AND '" . trim($resp->$ev['lime_sgqa']) . "' {$ev['comparison']} '{$ev['value']}' ";
}
$match = $db->GetOne($sql2);
}
if ($match == 1)
@@ -1823,24 +1844,40 @@ function update_single_row_quota($qsqri,$case_id = false)
else
{
//find all completions from cases with matching limesurvey records
$sql2 = "SELECT token
FROM `case` as c
WHERE c.questionnaire_id = '$questionnaire_id'";
//get all completed responses from limesurvey, indexed by token
include_once(dirname(__FILE__).'/functions.limesurvey.php');
$resp = lime_get_responses_by_questionnaire($questionnaire_id);
foreach($qev as $ev)
{
//TODO: Exclude responses from the $resp array where there isn't a match
//based on the comparisons
$sql2 .= " AND s.`{$ev['lime_sgqa']}` {$ev['comparison']} '{$ev['value']}' ";
if ($resp !== false) {
$sql2 = "SELECT c.token,c.token as tok
FROM `case` as c
JOIN `sample` as sam ON (c.sample_id = sam.sample_id AND sam.import_id = '$sample_import_id')
WHERE c.questionnaire_id = '$questionnaire_id'";
$rs = $db->GetAssoc($sql2);
foreach($resp as $r) {
foreach($r as $r1) {
foreach($r1 as $rl) {
if (isset($rl->token) && isset($rs[$rl->token])) {
//match to a case in the sample
$tmp = 0;
foreach($qev as $ev) {
if (isset($rl->$ev['lime_sgqa'])) {
$tmp = lime_compare($rl->$ev['lime_sgqa'], $ev['comparison'], $ev['value']);
if ($tmp != 1) {
break;
}
}
}
$completions += $tmp;
}
}
}
}
}
$completions = count($resp);
}
$updatequota = true;
@@ -2465,11 +2502,8 @@ function get_limesurvey_id($operator_id,$rs = false)
else
$sql = "SELECT q.lime_sid as sid";
$sql .= " FROM `case` as c, questionnaire_sample as qs, sample as s, questionnaire as q
$sql .= " FROM `case` as c, questionnaire as q
WHERE c.current_operator_id = '$operator_id'
AND c.sample_id = s.sample_id
AND s.import_id = qs.sample_import_id
AND q.questionnaire_id = qs.questionnaire_id
AND c.questionnaire_id = q.questionnaire_id";
$rs = $db->GetRow($sql);