Merge pull request #15 from mattbk/add-participant-id-collection
Add participant ID
This commit is contained in:
13
index.php
13
index.php
@ -69,6 +69,10 @@ switch ($mode) {
|
|||||||
$variables['imageWithElement'] = 'img/'.$phase.'-with.png';
|
$variables['imageWithElement'] = 'img/'.$phase.'-with.png';
|
||||||
$variables['imageWithoutElement'] = 'img/'.$phase.'-without.png';
|
$variables['imageWithoutElement'] = 'img/'.$phase.'-without.png';
|
||||||
$variables['step_count'] = $index;
|
$variables['step_count'] = $index;
|
||||||
|
// Store the participant ID with some simple validation to prevent SQL injection
|
||||||
|
if (isset($_POST['participantid'])) {
|
||||||
|
$_SESSION['participantid'] = preg_replace('/[^A-Za-z0-9\. -]/', '', $_POST['participantid']);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'phase_next':
|
case 'phase_next':
|
||||||
$template = 'next.html.twig';
|
$template = 'next.html.twig';
|
||||||
@ -107,12 +111,16 @@ switch ($mode) {
|
|||||||
//Building an INSERT query:
|
//Building an INSERT query:
|
||||||
//Include userid (once collection form is added into the start page)
|
//Include userid (once collection form is added into the start page)
|
||||||
// DB fields are listed here:
|
// DB fields are listed here:
|
||||||
$columnstoimplode = array("uid", "datetime", "host", "phase", "xcoordinate", "ycoordinate","responsetime","score");
|
$columnstoimplode = array("uid", "datetime", "host", "participantid","phase", "xcoordinate", "ycoordinate","responsetime","score");
|
||||||
// Note that backticks (`) go around field names...
|
// Note that backticks (`) go around field names...
|
||||||
$columns = "`".implode("`, `", $columnstoimplode)."`";
|
$columns = "`".implode("`, `", $columnstoimplode)."`";
|
||||||
// Set up timestamp so you can tell participants apart. http://alvinalexander.com/php/php-date-formatted-sql-timestamp-insert
|
// Set up timestamp so you can tell participants apart. http://alvinalexander.com/php/php-date-formatted-sql-timestamp-insert
|
||||||
$timestamp = date('Y-m-d G:i:s');
|
$timestamp = date('Y-m-d G:i:s');
|
||||||
|
// Add the uid placeholder, timestamd, and host/IP
|
||||||
$valuestoimplode = array("", $timestamp, $_SERVER['REMOTE_ADDR']);
|
$valuestoimplode = array("", $timestamp, $_SERVER['REMOTE_ADDR']);
|
||||||
|
// Add the participant ID
|
||||||
|
array_push($valuestoimplode,$_SESSION['participantid']);
|
||||||
|
// Add the results
|
||||||
$valuestoimplode = array_merge($valuestoimplode,$ready);
|
$valuestoimplode = array_merge($valuestoimplode,$ready);
|
||||||
$values = "'".implode("', '", $valuestoimplode)."'";
|
$values = "'".implode("', '", $valuestoimplode)."'";
|
||||||
//print_r($values);
|
//print_r($values);
|
||||||
@ -170,7 +178,7 @@ switch ($mode) {
|
|||||||
$stats = array();
|
$stats = array();
|
||||||
|
|
||||||
//Skip empty results (created during debugging)
|
//Skip empty results (created during debugging)
|
||||||
if ($record['responsetime'] > 0) {
|
if ($record['participantid'] != "") {
|
||||||
//Put your results in one array
|
//Put your results in one array
|
||||||
$variables['data'][] = $record;
|
$variables['data'][] = $record;
|
||||||
}
|
}
|
||||||
@ -188,7 +196,6 @@ switch ($mode) {
|
|||||||
|
|
||||||
} //End while to loop through results from database.
|
} //End while to loop through results from database.
|
||||||
|
|
||||||
|
|
||||||
$results->free();
|
$results->free();
|
||||||
break;
|
break;
|
||||||
} //End case to select page.
|
} //End case to select page.
|
||||||
|
@ -4,7 +4,12 @@
|
|||||||
<header class="hero-unit">
|
<header class="hero-unit">
|
||||||
<h1>Change blindness test</h1>
|
<h1>Change blindness test</h1>
|
||||||
<p>We would like a few minutes of your time to help us with a test in change blindness. Your help is very much appreciated.</p>
|
<p>We would like a few minutes of your time to help us with a test in change blindness. Your help is very much appreciated.</p>
|
||||||
<p><a class="btn btn-primary btn-large" href="{{ start_url }}">Get started »</a></p>
|
|
||||||
|
<form action="{{ start_url }}" method="post">
|
||||||
|
Name: <input type="text" name="participantid">
|
||||||
|
<input type="submit" value="Start">
|
||||||
|
</form>
|
||||||
|
|
||||||
<p><div class="fb-like" data-layout="button_count" data-width="450" data-show-faces="false" data-font="arial"></div></p>
|
<p><div class="fb-like" data-layout="button_count" data-width="450" data-show-faces="false" data-font="arial"></div></p>
|
||||||
<p><a href="https://twitter.com/share" class="twitter-share-button" data-via="RaymondJelierse" data-hashtags="vcd">Tweet</a></p>
|
<p><a href="https://twitter.com/share" class="twitter-share-button" data-via="RaymondJelierse" data-hashtags="vcd">Tweet</a></p>
|
||||||
</header>
|
</header>
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
<th>uid</th>
|
<th>uid</th>
|
||||||
<th>date</th>
|
<th>date</th>
|
||||||
<th>host</th>
|
<th>host</th>
|
||||||
|
<th>participant</th>
|
||||||
<th>phase</th>
|
<th>phase</th>
|
||||||
<th>x</th>
|
<th>x</th>
|
||||||
<th>y</th>
|
<th>y</th>
|
||||||
@ -67,6 +68,7 @@
|
|||||||
<td>{{record.uid}}.</td>
|
<td>{{record.uid}}.</td>
|
||||||
<td>{{ record.datetime }}</td>
|
<td>{{ record.datetime }}</td>
|
||||||
<td>{{ record.host }}</td>
|
<td>{{ record.host }}</td>
|
||||||
|
<td>{{ record.participantid }}</td>
|
||||||
<td>{{ record.phase }}</td>
|
<td>{{ record.phase }}</td>
|
||||||
<td>{{ record.xcoordinate }}</td>
|
<td>{{ record.xcoordinate }}</td>
|
||||||
<td>{{ record.ycoordinate }}</td>
|
<td>{{ record.ycoordinate }}</td>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
uid datetime host phase xcoordinate ycoordinate responsetime score
|
uid datetime host participant phase xcoordinate ycoordinate responsetime score
|
||||||
{% for record in data %}
|
{% for record in data %}
|
||||||
{{record.uid}} {{record.datetime}} {{record.host}} {{record.phase}} {{record.xcoordinate}} {{record.ycoordinate}} {{record.responsetime}} {{record.score}}
|
{{record.uid}} {{record.datetime}} {{record.host}} {{record.participantid}} {{record.phase}} {{record.xcoordinate}} {{record.ycoordinate}} {{record.responsetime}} {{record.score}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Reference in New Issue
Block a user