Commit 24c652f7 authored by William Paul Liggett's avatar William Paul Liggett

Test Condition #2: Visually, the display for this vigilance test now works as intended.

parent 12e2f2d0
......@@ -45,7 +45,7 @@ else if($test_condition > 4) {
// Logs into the OpenVigilance Task tests database to control and alter user tests.
// `$pdo' is defined as the database connection.
require_once "../../../../../protected_site_configs/junktext.com/openvigilance_db_connection.php";
require_once "../../../../../protected_site_configs/junktext.com/openvigilance_db_connection_admin.php";
// Auto-generate the subject's (user's) login code.
$login_code = "";
......
......@@ -51,7 +51,7 @@ else if($sk <= 0) {
// Logs into the OpenVigilance Task tests database to control and alter user tests.
// `$pdo' is defined as the database connection.
require_once "../../../../../protected_site_configs/junktext.com/openvigilance_db_connection.php";
require_once "../../../../../protected_site_configs/junktext.com/openvigilance_db_connection_admin.php";
// Uses MySQL transactions to be atomic.
// MySQL Command: START TRANSACTION;
......
......@@ -51,7 +51,7 @@ else if(strlen($login_code) !== 4) {
// Logs into the OpenVigilance Task tests database to control and alter user tests.
// `$pdo' is defined as the database connection.
require_once "../../../../../protected_site_configs/junktext.com/openvigilance_db_connection.php";
require_once "../../../../../protected_site_configs/junktext.com/openvigilance_db_connection_admin.php";
// Test Control: Remove the OV test in the database.
$sql = "DELETE FROM test_control WHERE sk=:sk AND subject_id=:subject_id AND test_condition=:test_condition AND login_code=:login_code";
......
......@@ -35,10 +35,22 @@
<p class="version_info"><strong>TO DO:</strong></p>
<ol>
<li>Vigilance Tests: Record the activity of each subject during the test and save it as a CSV data file on the server.</li>
<li>Admin Page: Add a section to show the stored CSV files so that they can be downloaded or deleted at will.</li>
<li>Test Conditions #1, 3, and 4: Visually show the correct durations for the tasks and break depending on the test condition. [Estimate: 4.0 hours]</li>
<li>Vigilance Tests: Record the activity of each subject during the test and save it as a CSV data file on the server. [Estimate: 5.0 to 10.0 hours]</li>
<li>Admin Page: Add a section to show the stored CSV files so that they can be downloaded at will. This section will not be fancy, as it will just be a bunch of links
and maybe an ability to download all of the files as a ZIP archive. [Estimate: 2.0 hours]</li>
</ol>
<p class="version_info">Version 1.7.0 (2018-03-01):</p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_11">4.0</span> hours.</em></p>
<ul>
<li>Test Condition #2: Visually, the display for this vigilance test now works as intended. This is the 12 min task +
4 min break (with a blank screen) + 12 min task. However, the data collection is not operational yet.</li>
<li>Subject Login: Once the user logs in, their welcome message will be different depending if they have a break or
not in the middle of their test, depending on which test condition they have been assigned to.</li>
<li>Vigilance Tests: Removed the "OpenVigilance Task" page title to reduce a user's eye wandering impulses.</li>
</ul>
<p class="version_info">Version 1.6.0 (2018-02-28):</p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_10">3</span> hours.</em></p>
<ul>
......@@ -127,7 +139,8 @@
parseFloat($("#hours_logged_for_update_7").html()) +
parseFloat($("#hours_logged_for_update_8").html()) +
parseFloat($("#hours_logged_for_update_9").html()) +
parseFloat($("#hours_logged_for_update_10").html());
parseFloat($("#hours_logged_for_update_10").html()) +
parseFloat($("#hours_logged_for_update_11").html());
// Displays the total labor hours at the top of the page.
$("#total_labor_hours").html(calculated_labor_time);
......
......@@ -15,9 +15,11 @@
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<h1>OpenVigilance Task</h1>
<?php
error_reporting(E_ALL);
// Some pages don't need this <h1> title tag, but for those that do we'll define it once to be DRY.
$h1_page_title = "<h1 id=\"h1_page_title\">OpenVigilance Task</h1>" . PHP_EOL;
// Makes the tab whitespace makes the HTML source look nice. There are 4 spaces.
$tab = " ";
......@@ -43,6 +45,7 @@
if($_SERVER['REQUEST_METHOD'] === "GET") {
// Displays the HTML login <form>.
// There should be no error on first load, but this keeps the form layout in the same position.
echo $h1_page_title;
echo "<p class='error_msg'>$error_msg</p>";
echo $login_form;
}
......@@ -55,10 +58,12 @@
$submitted_password = htmlspecialchars($_POST['password']);
// Confirms whether the login is valid and sets the boolean `$valid_login_user' variable.
// Also, the user's full account details acquired from the database are stored in `$account_found'.
require_once "admin/valid_login_user.php";
// Login invalid: Re-displays the login <form>.
if(!$valid_login_user) {
echo $h1_page_title;
echo "<p class='error_msg'>$error_msg</p>";
echo $login_form;
}
......@@ -66,13 +71,80 @@
// Login successful!
else {
// Maintains the authenticated user session across different pages.
if(!isset($_SESSION['ov_user'])) {
// The surrogate key in the database must be unique, so there's no need to check
// the other session variables even further initially.
if(!isset($_SESSION['ov_database_user_sk'])) {
$_SESSION['ov_database_user_sk'] = intval($account_found['sk']);
$_SESSION['ov_user'] = $submitted_username;
$_SESSION['ov_test_condition'] = intval($account_found['test_condition']);
$_SESSION['ov_login_code'] = $submitted_password;
}
// Displays the OV test (images and so forth) to the user.
echo "<div class=\"container\">" . PHP_EOL .
// -----------------------------------------------------------------------------------------------------------
// Changes up what the test participant sees and whether they get a break and what kind of break they'll have.
//
// Test Condition #1: No break. Two back-to-back 12 minute task blocks.
// Test Condition #2: 12 minute task. Break w/a blank, white screen. 12 minute task again.
// Test Condition #3: 12 minute task. Break w/a nature video. 12 minute task again.
// Test Condition #4: 12 minute task. Break w/random letters still flashing. 12 minute task again.
// -----------------------------------------------------------------------------------------------------------
$login_welcome_msg_no_break = "<div id=\"login_welcome_msg\"><p>" .
"In this experiment, letters will appear rapidly in the center of the screen. They will appear behind a " .
"large pattern that is made up of small circles. The letters will either be an O, D, or a backwards D. " .
"Your task is to detect the letter O. Each time that a letter O appears, press the space bar. You will " .
"have approximately 1 second to respond before the next letter appears so respond as rapidly as you can " .
"while being accurate.</p>" .
"<p>When either the letter D or backwards D appears, you should not make any response. There will be a " .
"short practice block before the task begins. After the practice block, the task will last approximately " .
"25 minutes.</p>" .
"<p>If you have any questions please ask the experimenter now. When you are ready, press the \"Start " .
"Test\" button to continue on to the practice block.</p></div>";
$login_welcome_msg_with_break = "<div id=\"login_welcome_msg\"><p>" .
"In this experiment, letters will appear rapidly in the center of the screen. They will appear behind a " .
"large pattern that is made up of small circles. The letters will either be an O, D, or a backwards D. " .
"Your task is to detect the letter O. Each time that a letter O appears, press the space bar. You will " .
"have approximately 1 second to respond before the next letter appears so respond as rapidly as you can " .
"while being accurate.</p>" .
"<p>When either the letter D or backwards D appears, you should not make any response. There will be a " .
"short practice block before the task begins. After the practice block, the task will last approximately " .
"25 minutes. You will have a short break at the midpoint of the task. During this break please remain in " .
"your seat, and do not take out your phone or any other personal items.</p>" .
"<p>If you have any questions please ask the experimenter now. When you are ready, press the \"Start " .
"Test\" button to continue on to the practice block.</p></div>";
$start_test_button = "<input type=\"button\" name=\"StartTestButton\" id=\"StartTestButton\" value=\"Start Test\" />";
$test_condition_js_var = "<script>var ov_test_condition = parseInt(" . $_SESSION['ov_test_condition'] . ");</script>";
// ---------------------------------------------------------------
// Test Condition #1: No break. See above description for details.
// ---------------------------------------------------------------
if($_SESSION['ov_test_condition'] === 1) {
$login_welcome_msg = $login_welcome_msg_no_break;
}
// ----------------------------------------------------------------------------
// Test Conditions #2-4: With a 4-min break. See above description for details.
// ----------------------------------------------------------------------------
else {
$login_welcome_msg = $login_welcome_msg_with_break;
}
// ------------------------------------------------
// Outputs the correct HTML for any test condition.
// ------------------------------------------------
echo $test_condition_js_var;
echo $h1_page_title;
echo $login_welcome_msg;
echo $start_test_button;
// Displays the OV test (images and so forth) to the user. JavaScript is used to unhide it.
echo "<div class=\"container hidden\" id=\"VigilanceDisplay\">" . PHP_EOL .
"$tab$tab$tab<img id=\"background-smaller-circles\" src=\"media/background-smaller-circles_(936_by_466_px,_Resolution_at_1360x768_~16_by_9).png\" alt=\"Background of Smaller Circles\" />" . PHP_EOL .
"$tab$tab$tab<div class=\"random_letter\">" . PHP_EOL .
"$tab$tab$tab$tab<span class=\"letter_o\">O</span>" . PHP_EOL .
......
......@@ -7,18 +7,6 @@
------------------------------------------------------------------------------------------------------------------ */
;(function(window, $) {
$(document).ready(function() {
// Hides any random letters when the document first loads up.
$("div.random_letter").addClass("hidden");
$("span.letter_o").addClass("hidden");
$("span.letter_d").addClass("hidden");
$("span.letter_backwards_d").addClass("hidden");
// Unhides the main <div> for the random_letter now.
$("div.random_letter").removeClass("hidden");
});
// 50 ms display duration for the letter to appear and then disappear on the screen.
const DISPLAY_LETTER_DURATION = 50;
......@@ -105,9 +93,75 @@
}, DISPLAY_LETTER_DURATION);
}
function showVigilanceDisplay() {
$("#VigilanceDisplay").removeClass("hidden");
}
function hideVigilanceDisplay() {
$("#VigilanceDisplay").addClass("hidden");
}
function concludeTest() {
$("#VigilanceDisplay").remove();
$("body").append("<p>Test Complete! Thank you for participating.</p>");
}
// An event is a random letter change set to the rate of EVENTS_PER_MINUTE.
setInterval(changeRandomLetter, EVENTS_PER_MINUTE);
$(document).ready(function() {
$("body").on("click", "#StartTestButton", function(event) {
// Hides the login welcome message after the participant presses the "Start Test" button.
$("#h1_page_title").remove();
$("#login_welcome_msg").remove();
$("#StartTestButton").remove();
var twelve_minutes_in_ms = parseFloat(720000); // 12 minutes = 720,000 ms
var four_minutes_in_ms = parseFloat(240000); // 4 minutes = 240,000 ms
// Inaccurate... TESTING VALUES.
//var twelve_minutes_in_ms = parseFloat(30000); // 30 seconds
//var four_minutes_in_ms = parseFloat(10000); // 10 seconds
// -----------------------------------------------------------------------------------------------------------------
// The `ov_test_condition' var was set via PHP, which changes depending on which condition the user is assigned to.
//
// Test Condition #1: No break. Two back-to-back 12 minute task blocks.
// Test Condition #2: 12 minute task. Break w/a blank, white screen. 12 minute task again.
// Test Condition #3: 12 minute task. Break w/a nature video. 12 minute task again.
// Test Condition #4: 12 minute task. Break w/random letters still flashing. 12 minute task again.
// -----------------------------------------------------------------------------------------------------------------
// Begins the OV test regardless of which condition is used.
showVigilanceDisplay();
if(ov_test_condition === 1) {
// Concludes the test once 24 minutes have passed.
setTimeout(concludeTest, (twelve_minutes_in_ms * 2));
}
else if(ov_test_condition === 2) {
// Hides the initial OV display after 12 minutes to show a blank screen.
setTimeout(hideVigilanceDisplay, twelve_minutes_in_ms);
// Shows the OV display again after the 4 minute break.
setTimeout(showVigilanceDisplay, (twelve_minutes_in_ms + four_minutes_in_ms));
// Concludes the test once 28 minutes have passed (12 min + 4 min + 12 min).
setTimeout(concludeTest, (twelve_minutes_in_ms * 2 + four_minutes_in_ms));
}
else if(ov_test_condition === 3) {
}
else {
}
$("#VigilanceDisplay").removeClass("hidden");
});
});
})(window, jQuery);
// @license-end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment