Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More last minute changes to the survey questions. Adding basic styles…

…heet to admin view of responses.
  • Loading branch information...
commit 6fc6f9275481fc16a71782a3b0bfa2e827dfbdfb 1 parent f9466f4
@aaronpk aaronpk authored
View
28 include/header.php
@@ -4,6 +4,34 @@
<title>Survey</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="jPlayer/jquery.jplayer.min.js"></script>
+ <style type="text/css">
+
+ body, td {
+ font-family: verdana;
+ font-size: 10pt;
+ }
+
+ .callDetails td {
+ font-size: 13pt;
+ }
+
+ .listen {
+ font-size: 80%;
+ }
+
+ .responses .key {
+ width: 140px;
+ }
+ .responses .value {
+ width: 90px;
+ }
+
+ .responses td {
+ border-top: 1px #ddd solid;
+ padding: 3px;
+ }
+
+ </style>
</head>
<body>
View
24 include/include.php
@@ -148,16 +148,21 @@ function sendCallToServer($id, $url)
{
// Gather up all the responses and send them off to the server
$responses = db()->prepare('SELECT * FROM responses WHERE callID = :id');
- $responses->bindParam($id);
+ $responses->bindParam(':id', $id);
$responses->execute();
+ $call = db()->prepare('SELECT * FROM calls WHERE id = :id');
+ $call->bindParam(':id', $id);
+ $call->execute();
+ $call = $call->fetch();
+
$data = array();
while($row = $responses->fetch(PDO::FETCH_ASSOC))
$data[$row['key']] = $row;
$params = array();
- $params['first_name'] = @'http://' . $_SERVER['SERVER_NAME'] . WEB_ROOT . 'recordings/' . $data['name']['recording'];
- $params['street1'] = @'http://' . $_SERVER['SERVER_NAME'] . WEB_ROOT . 'recordings/' . $data['street1']['recording'];
+ $params['first_name'] = @($data['name']['recording'] ? 'http://' . $_SERVER['SERVER_NAME'] . WEB_ROOT . 'recordings/' . $data['name']['recording'] : '');
+ $params['street1'] = @($data['street1']['recording'] ? 'http://' . $_SERVER['SERVER_NAME'] . WEB_ROOT . 'recordings/' . $data['street1']['recording'] : '');
$params['county'] = @$data['county']['value'];
$params['postcode'] = @$data['postcode']['value'];
$params['is_owner'] = @$data['owner']['value'];
@@ -168,13 +173,17 @@ function sendCallToServer($id, $url)
$params['is_habitable'] = @$data['habitable']['value'];
$params['is_accessible'] = @$data['accessible']['value'];
$params['damage'] = @$data['damage_type']['value'];
- $params['description'] = @'http://' . $_SERVER['SERVER_NAME'] . WEB_ROOT . 'recordings/' . @$data['description']['recording'];
+ $params['description'] = @($data['description']['recording'] ? 'http://' . $_SERVER['SERVER_NAME'] . WEB_ROOT . 'recordings/' . @$data['description']['recording'] : '');
$params['insurance'] = @$data['insurance']['value'];
$params['provider'] = @$data['provider']['value'];
+ $params['phone'] = $call['callerID'];
+ $params['preferred'] = 'landline-phone';
$params['source'] = 'voice';
- ircdebug('Sending form data');
-
+ #ircdebug('Sending form data');
+
+ filedebug($params);
+ /*
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
@@ -182,6 +191,7 @@ function sendCallToServer($id, $url)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($ch);
filedebug($response);
+ */
}
function tropoInput()
@@ -359,4 +369,4 @@ public function __get($key)
}
}
-?>
+?>
View
19 include/question.php
@@ -45,11 +45,14 @@
// Find the next question and ask it
foreach($questions as $i=>$q)
{
- if($q['key'] == $key)
+ if(array_key_exists('key', $q) && $q['key'] == $key)
{
$thisQuestion = $q;
if(array_key_exists($i+1, $questions))
- $nextQuestion = $questions[$i+1];
+ {
+ $nextQuestionIndex = $i + 1;
+ $nextQuestion = $questions[$i + 1];
+ }
else
$nextQuestion = FALSE;
}
@@ -59,7 +62,19 @@
if(get('hadRecording') || isset($responseValue))
{
if($nextQuestion)
+ {
+ if(array_key_exists('say', $nextQuestion))
+ {
+ $tropo[] = array(
+ 'say' => array(
+ 'value' => $nextQuestion['say']
+ ),
+ 'voice' => $voice
+ );
+ $nextQuestion = $questions[$nextQuestionIndex + 1];
+ }
askQuestion($nextQuestion);
+ }
else
complete();
}
View
3  index.php
@@ -37,7 +37,6 @@
break;
case 'incoming':
define('SURVEY_MODE', TRUE);
- include('survey.php');
$query = db()->prepare('INSERT INTO `calls` (`date`, `callerID`, `sessionID`) VALUES(:date, :callerID, :sessionID)');
$query->bindValue(':date', date('Y-m-d H:i:s'));
@@ -46,6 +45,8 @@
$query->execute();
$_SESSION['callID'] = db()->lastInsertId();
+ include('survey.php');
+
$tropo[] = array(
'say' => array(
'value' => '. . . ' . $firstPrompt,
View
55 survey.php
@@ -2,6 +2,61 @@
$firstPrompt = 'Thanks for calling the Mobile Assessment of Damage hotline.';
+/*
+ * TODO: resume a past session by entering a reference number
+
+$questions[] = array(
+ 'key' => 'hasreferencenumber',
+ 'name' => 'Reference Number',
+ 'prompt' => 'Do you already have a reference number?',
+ 'prompt2' => didntUnderstand() . 'Do you want to continue a past session by entering a reference number?',
+ 'choices' => '[BOOLEAN]'
+);
+
+if(defined('SURVEY_MODE') && ($callID = surveyVal('hasreferencenumber')) !== FALSE)
+{
+ if($callID)
+ {
+ // Resume a previous session
+ }
+ else
+ {
+ $questions[] = array(
+ 'key' => 'referencenumber',
+ 'name' => 'Reference Number',
+ 'prompt' => 'What is your reference number?',
+ 'prompt2' => 'Please speak the digits of your reference number.',
+ 'choices' => '[DIGITS]'
+ );
+ }
+}
+ */
+
+if(defined('SURVEY_MODE'))
+{
+ $refnum = implode(' ', str_split($_SESSION['callID']));
+
+ $firstPrompt .= ' If we get disconnected, you can continue this call by entering the following reference number. . ';
+ // TODO: Say "Please say ok when you have a pen and paper ready." and wait for up to 60 seconds rather than the default 10
+ $firstPrompt .= ' Your reference number is ' . $refnum . '. Once again, that number is ' . $refnum . '.';
+}
+
+$questions[] = array(
+ 'key' => 'wanttohearinstructions',
+ 'name' => 'Want to hear instructions?',
+ 'prompt' => 'Do you want to know what questions we are going to ask you?',
+ 'prompt2' => didntUnderstand() . 'Please say yes or no.',
+ 'choices' => '[BOOLEAN]'
+);
+
+if(defined('SURVEY_MODE') && surveyVal('wanttohearinstructions') !== FALSE)
+{
+ $questions[] = array(
+ 'say' => 'You will need to know the zip code of the damaged property, the primary cause of damage, your insurance provider, if any, and the estimated dollar amount of damages, and a few other questions. Let\'s get started.'
+ );
+}
+
+
$questions[] = array(
'key' => 'name',
'name' => 'Name',
View
17 view.php
@@ -5,6 +5,11 @@
if(get('id'))
{
+ if(get('send') == 1)
+ {
+ sendCallToServer(get('id'), REMOTE_UPLOAD_SERVER);
+ }
+
?>
<div id="jquery_jplayer"></div>
@@ -32,8 +37,8 @@
$call->execute();
$call = $call->fetch(PDO::FETCH_ASSOC);
- echo '<table>';
- echo '<tr><td>Date:</td><td>' . $call['date'] . '</td></tr>';
+ echo '<table class="callDetails">';
+ echo '<tr><td>Date:</td><td>' . date('F j, Y g:ia', strtotime($call['date'])) . '</td></tr>';
echo '<tr><td>Caller ID:</td><td>' . $call['callerID'] . '</td></tr>';
echo '</table>';
@@ -44,7 +49,7 @@
while($q = $query->fetch(PDO::FETCH_ASSOC))
$responses[$q['key']] = $q;
- echo '<table>';
+ echo '<table class="responses" cellpadding="0" cellspacing="0">';
foreach($responses as $r)
{
if(array_key_exists($r['key'], $data) && array_key_exists('lookup', $data[$r['key']]))
@@ -60,9 +65,9 @@
$value = $r['value'];
echo '<tr>';
- echo '<td>' . (array_key_exists($r['key'], $data) && array_key_exists('name', $data[$r['key']]) ? $data[$r['key']]['name'] : $r['key']) . '</td>';
- echo '<td>' . $value . '</td>';
- echo '<td>' . ($r['recording'] ? '<a href="recordings/' . $r['recording'] . '" id="recording_' . $r['id'] . '" class="recording">listen</a>' : '') . '</td>';
+ echo '<td class="key">' . (array_key_exists($r['key'], $data) && array_key_exists('name', $data[$r['key']]) ? $data[$r['key']]['name'] : $r['key']) . '</td>';
+ echo '<td class="value">' . $value . '</td>';
+ echo '<td class="listen">' . ($r['recording'] ? '<a href="recordings/' . $r['recording'] . '" id="recording_' . $r['id'] . '" class="recording">listen</a>' : '') . '</td>';
echo '</tr>';
}
echo '</table>';
Please sign in to comment.
Something went wrong with that request. Please try again.