Commit 7d4343de authored by William Paul Liggett's avatar William Paul Liggett

Test Condition #1 now works and improved the way that participant's sign into/out-of the system.

parent 01ea5936
......@@ -38,7 +38,7 @@
<p class="version_info"><strong>TO DO:</strong></p>
<ol>
<li>Test Conditions #1, 3, and 4: Visually show the correct durations for the tasks and break depending on the test
<li>Test Conditions #3, and 4: Visually show the correct durations for the tasks and break depending on the test
condition. This includes embedding a nature video for test condition #3. [Estimate: 3 hours]</li>
<li>Log Data to CSV: Using the two raw CSV files, build a single, collated CSV to produce a data analysis report.
......@@ -49,6 +49,25 @@
However, I could create the ability to download all of the files as a ZIP archive if desired. Therefore, this
is an <em>optional</em> feature [Estimate: 0-2 hours]</li>
</ol>
<p class="version_info">Version 1.8.0 (2018-03-21):</p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_17">2</span> hours.</em></p>
<ul>
<li>
Test Conditions #1: This condition now works and flows as expected! So, this means that conditions #1 and #2
are good to go.
</li>
<li>
Participant Login Management: Fixed a glitch with regards to different users logging onto the same computer
would accidentally inherit the past user's test condition scenario. For example, person A with condition #1 begins
a test while person B with condition #2 is waiting for person A to finish. Then, person A finishes, so person B
logs in and accidentally inherits person A's test condition of the value of #1 (when person B should have #2).
</li>
<li>
Participant Login Management: A "Sign Out" button was added at the end of the test so that it was clear what the
next person should do when sitting down at the same computer that a previous participant used.
</li>
</ul>
<p class="version_info">Version 1.7.5 (2018-03-19):</p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_16">2.75</span> hours.</em></p>
......@@ -220,7 +239,8 @@
parseFloat($("#hours_logged_for_update_13").html()) +
parseFloat($("#hours_logged_for_update_14").html()) +
parseFloat($("#hours_logged_for_update_15").html()) +
parseFloat($("#hours_logged_for_update_16").html());
parseFloat($("#hours_logged_for_update_16").html()) +
parseFloat($("#hours_logged_for_update_17").html());
// Displays the total labor hours at the top of the page.
$("#total_labor_hours").html(calculated_labor_time);
......
......@@ -183,6 +183,12 @@ td {
text-align: center;
}
/* The participant's "Sign Out" button */
#user_sign_out_button {
margin: 3rem auto 1rem auto;
display: block;
}
/* --- START of jQuery UI: Pop-up Dialog Boxes --- */
div#dialog_form_add_test label, div#dialog_form_add_test input,
div#dialog_form_edit_test label, div#dialog_form_edit_test input,
......
......@@ -32,7 +32,7 @@
// Used to display an HTML login form on first load or if the username and password was incorrect.
// The <form action="." just simply means it sends the request to this page (index.php) in the current directory.
$login_form = PHP_EOL .
"$tab$tab<form action=\".\" name=\"UserLogin\" id=\"UserLogin\" method=\"post\">" . PHP_EOL .
"$tab$tab<form action=\".\" name=\"UserLogin\" id=\"UserLogin\" method=\"POST\">" . PHP_EOL .
"$tab$tab$tab<label for=\"username\">Username:</label>" . PHP_EOL .
"$tab$tab$tab<input type=\"text\" name=\"username\" id=\"username\" />" . PHP_EOL .
"$tab$tab$tab<br />" . PHP_EOL .
......@@ -42,7 +42,8 @@
"$tab$tab$tab<input type=\"submit\" value=\"Submit\" />" . PHP_EOL .
"$tab$tab</form>" . PHP_EOL;
// GET: The page upon first load, before the <form> has been submitted.
// GET: The page upon first load before the <form> has been submitted, or when a user clicks the "Sign Out" button
// once they've taken an OpenVigilance Task test.
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.
......@@ -54,6 +55,15 @@
// POST: Confirms if the administrative password is accurate after the <form> has been submitted.
// Note: I am specifically defining an `else if' clause since REQUEST_METHOD could be: GET, POST, HEAD, or PUT
else if($_SERVER['REQUEST_METHOD'] === "POST") {
// Closes out the user's previous session. This can happen since the OpenVigilance Task app might be used by
// multiple people using the same computer (e.g., person A starts a test, while person B waits for A to finish).
// So, we'll just disconnect any old session data in order to avoid the glitch where person B can sign-in with
// their login information but they accidentally inherit person A's old session variables.
if(isset($_SESSION['ov_database_user_sk'])) {
$_SESSION = array();
session_regenerate_id();
}
// Grabs what the user submitted and sanitizes the input to avoid an SQL injection or XSS attack.
$submitted_username = intval($_POST['username']); // Regular users only have numeric account names.
$submitted_password = htmlspecialchars($_POST['password'], ENT_QUOTES, 'UTF-8');
......@@ -181,8 +191,13 @@
"$tab$tab$tab$tab<span class=\"letter_d\">D</span>" . PHP_EOL .
"$tab$tab$tab$tab<span class=\"letter_backwards_d\">D</span>" . PHP_EOL .
"$tab$tab$tab</div>" . PHP_EOL .
"$tab$tab</div>" . PHP_EOL .
"<p id=\"testing_spacebar\"></p>";
"$tab$tab</div>" . PHP_EOL;
// Sets up a hidden form to be used to sign-out a user after they've finished taking a test.
echo "$tab$tab<div id=\"user_sign_out\" class=\"hidden\">" . PHP_EOL .
"$tab$tab$tab<form action=\".\" name=\"UserSignOut\" id=\"UserSignOut\" method=\"GET\">" . PHP_EOL .
"$tab$tab$tab$tab<input id=\"user_sign_out_button\" type=\"submit\" value=\"Sign Out\" />" . PHP_EOL .
"$tab$tab$tab</form>" . PHP_EOL;
}
}
?>
......
......@@ -232,9 +232,11 @@ var ov_participant_response_time = -1;
}
// Shows the vigilance test (small background circles and flashing random letters) when needed.
function showVigilanceDisplay(banner_text = "", each_test_block_duration = 0) {
function showVigilanceDisplay(banner_text = "", each_test_block_duration = 0, record_activity = true) {
// Let's the primary keydown() script know that any space bar presses should be counted in the user activity array.
ov_record_user_activity = true;
// The only reason this should be set to `false' is for Test Condition #4 as the break still shows random letter,
// but we're not supposed to record the user's activity in this instance.
ov_record_user_activity = record_activity;
// Outputs the "Practice Test" banner.
if(banner_text !== "") {
......@@ -371,16 +373,10 @@ var ov_participant_response_time = -1;
var response_as_json = JSON.parse(response);
if(response_as_json.successful === true) {
$("#vigilance_display_banner_text").html("Test Complete");
$("#vigilance_display_extra_text").html("We know this test was difficult, so we thank you very much for participating!");
}
else {
if(response_as_json.successful !== true) {
report_ajax_error("OV Error Code: #AJ001<br />jqXHR: " + jqXHR.toString() +
"<br />textStatus: " + textStatus + "<br />JSON response: " + response +
ajax_sequence_response_trail);
}
},
......@@ -417,16 +413,10 @@ var ov_participant_response_time = -1;
var response_as_json = JSON.parse(response);
if(response_as_json.successful === true) {
$("#vigilance_display_banner_text").html("Test Complete");
$("#vigilance_display_extra_text").html("We know this test was difficult, so we thank you very much for participating!");
}
else {
if(response_as_json.successful !== true) {
report_ajax_error("OV Error Code: #AJ004<br />jqXHR: " + jqXHR.toString() +
"<br />textStatus: " + textStatus + "<br />JSON response: " + response +
ajax_sequence_response_trail);
}
},
......@@ -450,6 +440,15 @@ var ov_participant_response_time = -1;
if((ajax_any_error_whatsoever) && $("#vigilance_display_banner_text").html() !== "Network Failure") {
report_ajax_error();
}
// Success! Let's end the participant's test.
else {
$("#vigilance_display_banner_text").html("Test Complete");
$("#vigilance_display_extra_text").html("We know this test was difficult, so we thank you very much for participating!");
// Shows the participant's "Sign Out" button to allow another participant to sign-in on the same computer.
$("#user_sign_out").removeClass("hidden");
}
}
// An event is a random letter change set to the rate of EVENTS_PER_MINUTE.
......@@ -482,23 +481,15 @@ var ov_participant_response_time = -1;
var thirty_seconds_in_ms = parseFloat(30000); // 30 seconds = 30,000 ms [Used between the practice and the real test.]
var practice_time_in_ms = thirty_seconds_in_ms; // Practice Test is only 30 seconds for now.
//var twelve_minutes_in_ms = parseFloat(720000); // 12 minutes = 720,000 ms
var four_minutes_in_ms = parseFloat(240000); // 4 minutes = 240,000 ms
//var four_minutes_in_ms = parseFloat(240000); // 4 minutes = 240,000 ms
// Inaccurate... TESTING VALUES.
var twelve_minutes_in_ms = parseFloat(120000); // 2 minutes = 120,000 ms
//var four_minutes_in_ms = thirty_seconds_in_ms;
var twelve_minutes_in_ms = thirty_seconds_in_ms;
//var twelve_minutes_in_ms = parseFloat(120000); // 2 minutes = 120,000 ms
var four_minutes_in_ms = thirty_seconds_in_ms;
//var twelve_minutes_in_ms = parseFloat(360000); // 6 minutes = 360,000 ms
//var four_minutes_in_ms = parseFloat(240000); // 4 minutes = 240,000 ms
// -----------------------------------------------------------------------------------------------------------------
// 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 30-second practice test regardless of which condition is used.
showVigilanceDisplay("Practice Test");
......@@ -509,8 +500,16 @@ var ov_participant_response_time = -1;
// Starts the real test after the 30-second mini-break.
setTimeout(showVigilanceDisplay, (practice_time_in_ms + thirty_seconds_in_ms));
// -----------------------------------------------------------------------------------------------------------------
// 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.
// -----------------------------------------------------------------------------------------------------------------
if(ov_test_condition === 1) {
// Concludes the test once 24 minutes have passed.
// No break for the participant. Concludes the test once 24 minutes have passed.
setTimeout(concludeTest, (practice_time_in_ms + thirty_seconds_in_ms + twelve_minutes_in_ms * 2));
}
......@@ -531,6 +530,7 @@ var ov_participant_response_time = -1;
}
else {
// Test Condition #4
}
......
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