diff --git a/admin/assignsample.php b/admin/assignsample.php
index eec75a46..a9efad0a 100644
--- a/admin/assignsample.php
+++ b/admin/assignsample.php
@@ -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 "";
if ($questionnaire_id != false)
{
-
- print "
";
if ($id)
print "
";
else
diff --git a/database/quexs.sql b/database/quexs.sql
index d8a6cef5..5e2cc31e 100644
--- a/database/quexs.sql
+++ b/database/quexs.sql
@@ -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 */;
diff --git a/email.php b/email.php
index 1fd11ecf..a6040fe5 100644
--- a/email.php
+++ b/email.php
@@ -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)
diff --git a/functions/functions.limesurvey.php b/functions/functions.limesurvey.php
index 4502000c..a4c11aa3 100644
--- a/functions/functions.limesurvey.php
+++ b/functions/functions.limesurvey.php
@@ -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
* @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;
diff --git a/functions/functions.operator.php b/functions/functions.operator.php
index 02128c97..9ff5a6c2 100644
--- a/functions/functions.operator.php
+++ b/functions/functions.operator.php
@@ -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);