Commit 965db1c0 authored by William Paul Liggett's avatar William Paul Liggett

Log Data to CSV: The raw data has been broken down into two JS arrays to allow...

Log Data to CSV: The raw data has been broken down into two JS arrays to allow more flexibility in terms of processing a correlated single CSV later for analysis. This is great news actually!
parent 61c343e2
......@@ -12,10 +12,24 @@
// Determines when to record the user's activity, such as when they press the space bar during a test.
var ov_record_user_activity = false;
// Multidimensional Array: Documents how well the user is doing during a test. The data is eventually submitted to the server.
// Random Letter Log: Documents various facts about each random letter shown. This is half of the data we need collected.
// The other crucial aspect is the User Activity Log, but we'll capture this aspect in its own array.
// Both sets of data will eventually be submitted to the server, after which the server will pair up the data values correctly.
// Note: We don't need the following cells as we can create the information on the server: "SID", "Target", "Distractor", "FalseAlarm", and "Correct"
// The heading of each cell is listed below, but the heading will not be repeated for new rows.
var ov_user_activity_array = [["GlobalTrialCounter", "CurrentTrial", "TimeStamp", "Type", "Block", "ov_random_letter_is_o", "RT"]];
// Furthermore, the "GlobalTrialCounter" will effectively serve as the row number!
var ov_random_letter_log = [["GlobalTrialCounter", "CurrentTrial", "TimeStamp", "Type", "Block", "ov_random_letter_is_o"]];
// User Activity Log: Documents the datetimes of every occurrence of when the user pressed the space bar. This is the other half
// of the data we need collected. The other crucial aspect is the Random Letter Log.
// FYI when "GlobalTrialCounter = 0": A user can generate activity entries after the test starts but before a random letter is
// shown. This is because there is a small delay between when the letter is visually presented inititially.
// Moreover, a user can generate activity entries multiple times on the same "GlobalTrialCounter" number. This is because the
// random letter changes at the pace of EVENTS_PER_MINUTE (default: 57.5 events = 958.33 ms) and the user is allowed to press
// the space bar as many times as they want. Lastly, if the user holds down the space bar, an activity entry is generated at
// however fast the operating system (OS) sends repeating keystrokes when holding a key down. Note: A user can easily modify
// this rate within their profile on their OS. It's just a setting in their control panel.
var ov_user_activity_log = [["GlobalTrialCounter", "ov_participant_response_time"]];
// Records the datetime in ms since the Unix epoch. It'll be set once the test actually begins.
var ov_test_began_datetime = -1;
......@@ -54,7 +68,6 @@ var ov_current_trial_counter = 0;
// Response Time (RT): Measure the time in ms of how long it took them to press the space bar after a random letter was displayed.
// Note: It doesn't matter if the random letter was the correct letter 'O' as the RT is logged whenever the user presses the
// space bar or is set to -1 to indicate that the user did not respond to a random letter.
var ov_participant_response_time_previously = -1;
var ov_participant_response_time = -1;
;(function(window, $) {
......@@ -81,19 +94,15 @@ var ov_participant_response_time = -1;
function changeRandomLetter() {
var random_int = getRandomInt(3);
var chosen_letter = "";
// Records when the time actually began in the format of: "19:11:12:565 (the "565" is the milliseconds)
//ov_current_random_letter_time_as_string = getCurrentDatetime()[2];
// Reports something like: 1520215907134. Used for calculating the user's response time.
ov_current_random_letter_datetime = Date.now();
// Global Trial Counter: [Practice Test] + [Actual Test]
// Increments by one each time a new random letter is shown to the user. Eventually output in the CSV.
++ov_global_trial_counter;
if(ov_record_user_activity === true) {
++ov_global_trial_counter;
}
// Current Trial Counter: ONLY the Actual Test (experiment), as the Practice Test will just log zeroes.
if(ov_test_type === "E") {
if((ov_record_user_activity === true) && (ov_test_type === "E")) {
++ov_current_trial_counter;
}
......@@ -151,6 +160,9 @@ var ov_participant_response_time = -1;
}
}
// Reports the time in ms since the Unix epoch, such as: 1520215907134.
ov_current_random_letter_datetime = Date.now();
// Displays the random letter for only a short duration (e.g., 50 ms).
// Shows the letter briefly.
$("span." + chosen_letter).removeClass("hidden");
......@@ -161,9 +173,12 @@ var ov_participant_response_time = -1;
}, DISPLAY_LETTER_DURATION);
// Logs the activity to the JS array as a new row for each letter shown to the user.
// Note: The `ov_subject_id' var was defined already by the PHP script.
// The title headings are: "GlobalTrialCounter", "CurrentTrial", "TimeStamp", "Type", "Block", "ov_random_letter_is_o", "RT"
ov_user_activity_array.push([ov_global_trial_counter, ov_current_trial_counter, ov_current_random_letter_datetime, ov_test_type, ov_test_block, ov_random_letter_is_o, ov_participant_response_time]);
if(ov_record_user_activity === true) {
// Note: The `ov_subject_id' var was defined already by the PHP script.
// Also, the "GlobalTrialCounter" will effectively serve as the row number!
// The title headings are: "GlobalTrialCounter", "CurrentTrial", "TimeStamp", "Type", "Block", "ov_random_letter_is_o"
ov_random_letter_log.push([ov_global_trial_counter, ov_current_trial_counter, ov_current_random_letter_datetime, ov_test_type, ov_test_block, ov_random_letter_is_o]);
}
}
// Shows the vigilance test (small background circles and flashing random letters) when needed.
......@@ -234,18 +249,11 @@ var ov_participant_response_time = -1;
$("body").keydown(function(event) {
// The space bar character in ASCII is #32.
if((event.which === 32) && (ov_record_user_activity === true)) {
// THIS WORKS, BUT IS ONLY USEFUL FOR DEBUGGING.
//$("#testing_spacebar").append("@");
// !@#$ ... THIS MAY NOT BE NEEDED.
// The user's previous response time.
ov_participant_response_time_previously = ov_participant_response_time;
// The user's pressed the space bar at this time in ms (Unix epoch from 1970).
ov_participant_response_time = Date.now();
// User Activity Log: Tracks the time of when the user pressed the space bar.
ov_user_activity_log.push([ov_global_trial_counter, ov_participant_response_time]);
}
});
......@@ -262,14 +270,14 @@ 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 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(20000); // 20 seconds
//var four_minutes_in_ms = parseFloat(10000); // 10 seconds
//var twelve_minutes_in_ms = parseFloat(360000); // 6 minutes = 360,000 ms
//var four_minutes_in_ms = parseFloat(240000); // 4 minutes = 240,000 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.
......
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