Commit e37b748d authored by William Paul Liggett's avatar William Paul Liggett

Admin Page: The capability to remove user tests now works. Other bug fixes were applied too.

parent d9666d53
......@@ -78,104 +78,123 @@
$statement = $pdo->prepare($sql);
$statement->execute();
$rows = $statement->fetchAll(); // Grabs all of the rows.
$num_rows = count($rows);
// Section heading.
echo "<h2>Scheduled Tests</h2>" . PHP_EOL;
if($num_rows > 0) {
// Creates the main <form> to enable the add, edit, and remove button functionalities.
echo "$tab$tab<form action=\".\" name=\"ScheduledTests\" method=\"post\">" . PHP_EOL;
// Sets up the <table> heading.
echo "$tab$tab$tab<table name=\"table_scheduled_tests\" id=\"table_scheduled_tests\">" . PHP_EOL .
"$tab$tab$tab$tab<thead>" . PHP_EOL .
"$tab$tab$tab$tab$tab<tr>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<th>&nbsp;</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<th>Subject ID</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<th>Test Condition</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<th>Login Code</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab</tr>" . PHP_EOL .
"$tab$tab$tab$tab</thead>" . PHP_EOL .
"$tab$tab$tab$tab<tbody>" . PHP_EOL;
// Creates the main <form> to enable the add, edit, and remove button functionalities.
echo "$tab$tab<form action=\".\" name=\"ScheduledTests\" method=\"post\">" . PHP_EOL;
// The rows of the <table>.
foreach($rows as $key => $value) {
echo "$tab$tab$tab$tab$tab<tr>" . PHP_EOL .
// I'm putting the "data-ov-..." values in the radio button element to make the JavaScript references less annoying.
"$tab$tab$tab$tab$tab$tab<td><input type=\"radio\" name=\"scheduled_test\" " .
"id=\"" . $value["sk"] . "\" value=\"" . $value["sk"] . "\" " .
"data-ov-subject-id=\"" . $value["subject_id"] . "\" " .
"data-ov-test-condition=\"" . $value["test_condition"] . "\" " .
"data-ov-login-code=\"" . $value["login_code"] . "\" /></td>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<td>" . $value["subject_id"] . "</td>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<td>" . $value["test_condition"] . "</td>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<td>" . $value["login_code"] . "</td>" . PHP_EOL .
"$tab$tab$tab$tab$tab</tr>" . PHP_EOL;
}
// Closes out the <table>
echo "$tab$tab$tab$tab</tbody>" . PHP_EOL .
"$tab$tab$tab</table>" . PHP_EOL;
// Closes out the main <form>.
echo "$tab$tab$tab<div id=\"scheduled_tests_buttons\">" . PHP_EOL .
"$tab$tab$tab$tab<input type=\"button\" name=\"add_test\" id=\"add_test\" value=\"Add Test\" />" . PHP_EOL .
"$tab$tab$tab$tab<input type=\"button\" name=\"edit_test\" id=\"edit_test\" value=\"Edit Test\" />" . PHP_EOL .
"$tab$tab$tab$tab<input type=\"button\" name=\"remove_test\" id=\"remove_test\" value=\"Remove Test\" />" . PHP_EOL .
"$tab$tab$tab</div>" . PHP_EOL .
"$tab$tab</form>" . PHP_EOL;
// ---------------------------------------------------------------------------------------------------------
// Pop-up Dialog Form: This the sub-form to add a scheduled test. Uses jQuery UI to pop-out when needed.
echo "$tab$tab<div id=\"dialog_form_add_test\" title=\"Add Test\" class=\"hidden\">" . PHP_EOL .
"$tab$tab$tab<p class=\"validateTips\">All form fields are required.</p>" . PHP_EOL .
"$tab$tab$tab<form id=\"AddTest\">" . PHP_EOL .
"$tab$tab$tab$tab<fieldset>" . PHP_EOL .
//"$tab$tab$tab$tab$tab<input type=\"hidden\" name=\"add_test_sk\" id=\"add_test_sk\" value=\"\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"add_test_subject_id\">Subject ID</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"add_test_subject_id\" id=\"add_test_subject_id\" value=\"\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"add_test_condition\">Test Condition</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"add_test_condition\" id=\"add_test_condition\" value=\"\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"add_login_code\">Login Code</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"add_login_code\" id=\"add_login_code\" value=\"Auto-generated.\" disabled=\"disabled\" title=\"Cannot edit as the code is auto-generated.\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
// Allow form submission with keyboard without duplicating the dialog button
"$tab$tab$tab$tab$tab<input type=\"submit\" tabindex=\"-1\" style=\"position:absolute; top:-1000px\">" . PHP_EOL .
"$tab$tab$tab$tab</fieldset>" . PHP_EOL .
"$tab$tab$tab</form>" . PHP_EOL .
"$tab$tab</div>" . PHP_EOL;
// Pop-up Dialog Form: This the sub-form to edit a scheduled test. Uses jQuery UI to pop-out when needed.
echo "$tab$tab<div id=\"dialog_form_edit_test\" title=\"Edit Test\" class=\"hidden\">" . PHP_EOL .
"$tab$tab$tab<p class=\"validateTips\">All form fields are required.</p>" . PHP_EOL .
"$tab$tab$tab<form id=\"EditTest\">" . PHP_EOL .
"$tab$tab$tab$tab<fieldset>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"hidden\" name=\"edit_test_sk\" id=\"edit_test_sk\" value=\"\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"edit_test_subject_id\">Subject ID</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"edit_test_subject_id\" id=\"edit_test_subject_id\" value=\"\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"edit_test_condition\">Test Condition</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"edit_test_condition\" id=\"edit_test_condition\" value=\"\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"edit_login_code\">Login Code</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"edit_login_code\" id=\"edit_login_code\" value=\"\" disabled=\"disabled\" title=\"Cannot edit as the code is auto-generated.\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
// Allow form submission with keyboard without duplicating the dialog button
"$tab$tab$tab$tab$tab<input type=\"submit\" tabindex=\"-1\" style=\"position:absolute; top:-1000px\">" . PHP_EOL .
"$tab$tab$tab$tab</fieldset>" . PHP_EOL .
"$tab$tab$tab</form>" . PHP_EOL .
"$tab$tab</div>" . PHP_EOL;
// Pop-up Dialog Message: Cannot edit a test that hasn't been selected.
echo "$tab$tab<div id=\"dialog_edit_test_error\" title=\"Edit Test\" class=\"hidden\">" . PHP_EOL .
"$tab$tab$tab<p>Please select a test that you want to edit.</p>" . PHP_EOL .
"$tab$tab</div>" . PHP_EOL;
// Sets up the <table> heading.
echo "$tab$tab$tab<table name=\"table_scheduled_tests\" id=\"table_scheduled_tests\">" . PHP_EOL .
"$tab$tab$tab$tab<thead>" . PHP_EOL .
"$tab$tab$tab$tab$tab<tr>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<th>&nbsp;</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<th>Subject ID</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<th>Test Condition</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<th>Login Code</th>" . PHP_EOL .
"$tab$tab$tab$tab$tab</tr>" . PHP_EOL .
"$tab$tab$tab$tab</thead>" . PHP_EOL .
"$tab$tab$tab$tab<tbody>" . PHP_EOL;
// The rows of the <table>.
foreach($rows as $key => $value) {
echo "$tab$tab$tab$tab$tab<tr>" . PHP_EOL .
// I'm putting the "data-ov-..." values in the radio button element to make the JavaScript references less annoying.
"$tab$tab$tab$tab$tab$tab<td><input type=\"radio\" name=\"scheduled_test\" " .
"id=\"" . $value["sk"] . "\" value=\"" . $value["sk"] . "\" " .
"data-ov-subject-id=\"" . $value["subject_id"] . "\" " .
"data-ov-test-condition=\"" . $value["test_condition"] . "\" " .
"data-ov-login-code=\"" . $value["login_code"] . "\" /></td>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<td>" . $value["subject_id"] . "</td>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<td>" . $value["test_condition"] . "</td>" . PHP_EOL .
"$tab$tab$tab$tab$tab$tab<td>" . $value["login_code"] . "</td>" . PHP_EOL .
"$tab$tab$tab$tab$tab</tr>" . PHP_EOL;
}
// Closes out the <table>
echo "$tab$tab$tab$tab</tbody>" . PHP_EOL .
"$tab$tab$tab</table>" . PHP_EOL;
// Closes out the main <form>.
echo "$tab$tab$tab<div id=\"scheduled_tests_buttons\">" . PHP_EOL .
"$tab$tab$tab$tab<input type=\"button\" name=\"add_test\" id=\"add_test\" value=\"Add Test\" />" . PHP_EOL .
"$tab$tab$tab$tab<input type=\"button\" name=\"edit_test\" id=\"edit_test\" value=\"Edit Test\" />" . PHP_EOL .
"$tab$tab$tab$tab<input type=\"button\" name=\"remove_test\" id=\"remove_test\" value=\"Remove Test\" />" . PHP_EOL .
"$tab$tab$tab</div>" . PHP_EOL .
"$tab$tab</form>" . PHP_EOL;
// ---------------------------------------------------------------------------------------------------------
// Add Test: Pop-up Dialog Form. Uses jQuery UI to pop-out when needed.
echo "$tab$tab<div id=\"dialog_form_add_test\" title=\"Add Test\" class=\"hidden\">" . PHP_EOL .
"$tab$tab$tab<p class=\"validateTips\">All form fields are required.</p>" . PHP_EOL .
"$tab$tab$tab<form id=\"AddTest\">" . PHP_EOL .
"$tab$tab$tab$tab<fieldset>" . PHP_EOL .
//"$tab$tab$tab$tab$tab<input type=\"hidden\" name=\"add_test_sk\" id=\"add_test_sk\" value=\"\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"add_test_subject_id\">Subject ID</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"add_test_subject_id\" id=\"add_test_subject_id\" value=\"\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"add_test_condition\">Test Condition</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"add_test_condition\" id=\"add_test_condition\" value=\"\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"add_login_code\">Login Code</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"add_login_code\" id=\"add_login_code\" value=\"Auto-generated.\" disabled=\"disabled\" title=\"Cannot edit as the code is auto-generated.\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
// Allow form submission with keyboard without duplicating the dialog button
"$tab$tab$tab$tab$tab<input type=\"submit\" tabindex=\"-1\" style=\"position:absolute; top:-1000px\">" . PHP_EOL .
"$tab$tab$tab$tab</fieldset>" . PHP_EOL .
"$tab$tab$tab</form>" . PHP_EOL .
"$tab$tab</div>" . PHP_EOL;
// Edit Test: Pop-up Dialog Form. Uses jQuery UI to pop-out when needed.
echo "$tab$tab<div id=\"dialog_form_edit_test\" title=\"Edit Test\" class=\"hidden\">" . PHP_EOL .
"$tab$tab$tab<p class=\"validateTips\">All form fields are required.</p>" . PHP_EOL .
"$tab$tab$tab<form id=\"EditTest\">" . PHP_EOL .
"$tab$tab$tab$tab<fieldset>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"hidden\" name=\"edit_test_sk\" id=\"edit_test_sk\" value=\"\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"edit_test_subject_id\">Subject ID</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"edit_test_subject_id\" id=\"edit_test_subject_id\" value=\"\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"edit_test_condition\">Test Condition</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"edit_test_condition\" id=\"edit_test_condition\" value=\"\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"edit_login_code\">Login Code</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"edit_login_code\" id=\"edit_login_code\" value=\"\" disabled=\"disabled\" title=\"Cannot edit as the code is auto-generated.\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
// Allow form submission with keyboard without duplicating the dialog button
"$tab$tab$tab$tab$tab<input type=\"submit\" tabindex=\"-1\" style=\"position:absolute; top:-1000px\">" . PHP_EOL .
"$tab$tab$tab$tab</fieldset>" . PHP_EOL .
"$tab$tab$tab</form>" . PHP_EOL .
"$tab$tab</div>" . PHP_EOL;
// Remove Test: Pop-up Dialog Form. Uses jQuery UI to pop-out when needed.
// There are extra hidden elements as diabled input text box fields cannot be submitted to the server per the W3C.
echo "$tab$tab<div id=\"dialog_form_remove_test\" title=\"Remove Test\" class=\"hidden\">" . PHP_EOL .
"$tab$tab$tab<p>Do you want to remove this test?</p>" . PHP_EOL .
"$tab$tab$tab<form id=\"RemoveTest\">" . PHP_EOL .
"$tab$tab$tab$tab<fieldset>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"hidden\" name=\"remove_test_sk\" id=\"remove_test_sk\" value=\"\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"remove_test_subject_id\">Subject ID</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"remove_test_subject_id\" id=\"remove_test_subject_id\" value=\"\" disabled=\"disabled\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"hidden\" name=\"remove_test_subject_id_hidden\" id=\"remove_test_subject_id_hidden\" value=\"\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"remove_test_condition\">Test Condition</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"remove_test_condition\" id=\"remove_test_condition\" value=\"\" disabled=\"disabled\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"hidden\" name=\"remove_test_condition_hidden\" id=\"remove_test_condition_hidden\" value=\"\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<label for=\"remove_login_code\">Login Code</label>" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"text\" name=\"remove_login_code\" id=\"remove_login_code\" value=\"\" disabled=\"disabled\" class=\"text ui-widget-content ui-corner-all\" />" . PHP_EOL .
"$tab$tab$tab$tab$tab<input type=\"hidden\" name=\"remove_login_code_hidden\" id=\"remove_login_code_hidden\" value=\"\" />" . PHP_EOL .
// Allow form submission with keyboard without duplicating the dialog button
"$tab$tab$tab$tab$tab<input type=\"submit\" tabindex=\"-1\" style=\"position:absolute; top:-1000px\">" . PHP_EOL .
"$tab$tab$tab$tab</fieldset>" . PHP_EOL .
"$tab$tab$tab</form>" . PHP_EOL .
"$tab$tab</div>" . PHP_EOL;
// Error Pop-up Dialog: Cannot edit/remove a test that hasn't been selected.
echo "$tab$tab<div id=\"dialog_form_error_message\" title=\"Error\" class=\"hidden\">" . PHP_EOL .
"$tab$tab$tab<p>Please select a test that you want to <span id=\"error_edit_or_remove_span\"></span>.</p>" . PHP_EOL .
"$tab$tab</div>" . PHP_EOL;
// There were no rows to display. More OV tests should be added.
else {
echo '<p class="center">There are no tests currently scheduled.</p>';
}
//else {
//echo '<p class="center">There are no tests currently scheduled.</p>';
//}
}
}
?>
......
......@@ -82,10 +82,12 @@ if($successful_insert) {
$new_sk = $statement->fetch()[0];
// Inform the web browser that all went well and informs the Ajax client what the login_code is for the subject.
output_json_response(true, "", strval($login_code), strval($new_sk));
output_json_response(true, "", strval($login_code), strval($new_sk));
return;
}
else {
// The database was not properly updated for some reason.
output_json_response(false, "The input data was valid, but the database could not be updated at this time for some reason.");
return;
}
<?php
/* --------------------------------------------------------------------------------------------------------------
* Copyright (C) 2018 by William Paul Liggett (junktext@junktext.com)
* This Source Code Form is subject to the terms of the Mozilla Public License (MPL), v. 2.0.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* Filename: scheduled_test_remove.php
*
* Purpose: Removes an OpenVigilance Task test in the database.
* The page is meant to be used as a simple web service, such as with Ajax or the like.
*
* Output: JSON array as defined in ``output_json_response.php''.
* -------------------------------------------------------------------------------------------------------------- */
error_reporting(E_ALL);
// Maintains the authenticated user session across different admin pages.
// Ensures only valid administrators can do anything.
session_start();
if(!isset($_SESSION['ov_admin_user'])) {
output_json_response(false, "Not logged on as an administrator.");
return;
}
// Function: output_json_response($successful, $error_message)
require_once "output_json_response.php";
// -------------------------------------------------------------------------------
// POST input variables sent by the web browser.
// Note: The login_code cannot be set by an OV admin. The code is auto-generated.
// -------------------------------------------------------------------------------
$sk = intval($_POST['remove_test_sk']); // Surrogate Key identifier of the scheduled test in the database.
$subject_id = intval($_POST['remove_test_subject_id_hidden']); // The ID of the person meant to take the test.
$test_condition = intval($_POST['remove_test_condition_hidden']); // The kind of test being taken.
$login_code = strval($_POST['remove_login_code_hidden']); // The 4-char login for the subject (user).
// Validate the data.
if($subject_id <= 0 || $test_condition <= 0) {
output_json_response(false, "The subject_id nor the test_condition cannot be less than or equal to zero.");
return;
}
else if($test_condition > 4) {
output_json_response(false, "The test_condition cannot be greater than 4.");
return;
}
else if(strlen($login_code) !== 4) {
output_json_response(false, "The login_code must have four characters.");
return;
}
// 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";
// 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";
$statement = $pdo->prepare($sql);
$statement->bindValue(":sk", $sk, PDO::PARAM_INT);
$statement->bindValue(":subject_id", $subject_id, PDO::PARAM_INT);
$statement->bindValue(":test_condition", $test_condition, PDO::PARAM_INT);
$statement->bindValue(":login_code", $login_code, PDO::PARAM_STR);
$successful_deletion = $statement->execute(); // true or false
if($successful_deletion) {
// Inform the web browser that all went well and informs the Ajax client what the login_code is for the subject.
output_json_response(true, "");
return;
}
else {
// Extra Data
$extra_data1 = 'sk = ' . strval($sk) .', subject_id = ' . strval($subject_id) .', test_condition = ' . strval($test_condition) . ', login_code = ' . strval($login_code);
// The database was not properly updated for some reason.
output_json_response(false, "The database could not be updated at this time for some reason.", $extra_data1);
return;
}
......@@ -30,25 +30,33 @@
<body>
<h1>OpenVigilance Task: Change Log</h1>
<h2>Programmer: William Paul Liggett (junktext@junktext.com)</h2>
<p><em>Total labor time: 31 hours.</em></p>
<p><em>Total labor time: <span id="total_labor_hours"></span> hours.</em></p>
<p class="version_info"><strong>To Do:</strong></p>
<p class="version_info"><strong>TO DO:</strong></p>
<ol>
<li>Admin Page: Capability to remove user tests.</li>
<li>Subject Login Page: Allow a test participant to login if they have a test scheduled.</li>
<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>
</ol>
<p class="version_info">Version 1.5.2 (2018-02-27):</p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_9">3</span> hours.</em></p>
<ul>
<li>Admin Page: The capability to remove user tests now works.</li>
<li>Improved the interface to be more seamless and less confusing when adding, editing, and removing tests.</li>
<li>Fixed a database permission issue.</li>
</ul>
<p class="version_info">Version 1.5.1 (2018-02-26):</p>
<p><em>Estimated labor time: 2.5 hours.</em></p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_8">2.5</span> hours.</em></p>
<ul>
<li>Admin Page: The capability to add user tests with an auto-generated login code works!</li>
<li>Admin Page: Made the process to update a scheduled test to be less fragile by confirming the database was updated correctly.</li>
</ul>
<p class="version_info">Version 1.5.0 (2018-02-21 to 2018-02-25):</p>
<p><em>Estimated labor time: 8 hours.</em></p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_7">8</span> hours.</em></p>
<ul>
<li>
Admin Page: The capability to edit tests have been fully implemented! Utilizes advanced JavaScript, GUI controls,
......@@ -58,14 +66,14 @@
</ul>
<p class="version_info">Version 1.4.1 (2018-02-20):</p>
<p><em>Estimated labor time: 1 hour.</em></p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_6">1</span> hour.</em></p>
<ul>
<li>Placed form buttons on the scheduled tests control section. However, the buttons don't do much yet.</li>
<li>Styled the buttons to be centered correctly and to react as intended (e.g., radio grouping).</li>
</ul>
<p class="version_info">Version 1.4.0 (2018-02-19):</p>
<p><em>Estimated labor time: 2.5 hours.</em></p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_5">2.5</span> hours.</em></p>
<ul>
<li>Built a web database to store and manage the user tests.</li>
<li>Put mock tests in the database and have confirmed it is accurate for both when there are tests scheduled and when they are not.</li>
......@@ -73,20 +81,20 @@
</ul>
<p class="version_info">Version 1.3.0 (2018-02-18):</p>
<p><em>Estimated labor time: 1.5 hours.</em></p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_4">1.5</span> hours.</em></p>
<ul>
<li>Added an admin page. The login process works. The rest of the functionality will be incorporated later.</li>
<li>Made the admin login form look a bit nicer.</li>
</ul>
<p class="version_info">Version 1.2.0 (2018-02-16):</p>
<p><em>Estimated labor time: 1.5 hours.</em></p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_3">1.5</span> hours.</em></p>
<ul>
<li>The duration of the random letters have been set to only show on the screen for 50 ms.</li>
</ul>
<p class="version_info">Version 1.1.0 (2018-02-07 to 2018-02-09):</p>
<p><em>Estimated labor time: 6 hours.</em></p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_2">6</span> hours.</em></p>
<ul>
<li>Randomization function added and the capability for a random letter to update automatically works at the rate of 57.5 events per minute.</li>
<li>Older MATLAB code from Mr. Adamo: I installed Octave and Psychtoolbox-3 on my computer and ran the old MATLAB code, but it wasn't able to fully run correctly. Nonetheless I have explored some of the older code and determined the color value used for the random letters.</li>
......@@ -94,7 +102,7 @@
</ul>
<p class="version_info">Version 1.0.0 (2018-01-31):</p>
<p><em>Estimated labor time: 8 hours.</em></p>
<p><em>Estimated labor time: <span id="hours_logged_for_update_1">8</span> hours.</em></p>
<ul>
<li>Initial codebase. Main HTML and CSS files were created, with a focus on display precision by using a real-world ruler (in millimeters)!</li>
<li>Smaller Background Circles: Exact dimensions in millimeters to 1360x768 pixel resolution. This took a while as converting a pixel-based image to the correct millimeter equivalent was extremely tedious.</li>
......@@ -102,5 +110,19 @@
<li>CSS: Backwards D letter renders correctly.</li>
<li>Font: TeX Gyre Adventor Bold is an open source font replacement for the costly and legally-restrictive ITC Avant Garde Gothic font. The ITC font was designed by Herb Lubalin and Tom Carnase in 1970. Here is the EULA for that ITC Avant Garde font (which is why we're not using this font): <br /><a href="https://www.fonts.com/info/legal/eula/monotype-imaging" target="_blank">https://www.fonts.com/info/legal/eula/monotype-imaging</a></li>
</ul>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
var calculated_labor_time = parseFloat($("#hours_logged_for_update_1").html()) +
parseFloat($("#hours_logged_for_update_2").html()) +
parseFloat($("#hours_logged_for_update_3").html()) +
parseFloat($("#hours_logged_for_update_4").html()) +
parseFloat($("#hours_logged_for_update_5").html()) +
parseFloat($("#hours_logged_for_update_6").html()) +
parseFloat($("#hours_logged_for_update_7").html()) +
parseFloat($("#hours_logged_for_update_8").html()) +
parseFloat($("#hours_logged_for_update_9").html());
$("#total_labor_hours").html(calculated_labor_time);
</script>
</body>
</html>
......@@ -149,26 +149,30 @@ td {
/* --- 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 {
div#dialog_form_edit_test label, div#dialog_form_edit_test input,
div#dialog_form_remove_test label, div#dialog_form_remove_test input {
display: block;
}
div#dialog_form_add_test input.text,
div#dialog_form_edit_test input.text {
div#dialog_form_edit_test input.text,
div#dialog_form_remove_test input.text {
margin-bottom: 12px;
width: 95%;
padding: 0.4em;
}
div#dialog_form_add_test fieldset,
div#dialog_form_edit_test fieldset {
div#dialog_form_edit_test fieldset,
div#dialog_form_remove_test fieldset {
padding: 0;
border: 0;
margin-top: 25px;
}
div#dialog_form_add_test h1,
div#dialog_form_edit_test h1 {
div#dialog_form_edit_test h1,
div#dialog_form_remove_test h1 {
font-size: 1.2em;
margin: 0.6em 0;
}
......@@ -183,7 +187,8 @@ div#dialog_form_edit_test h1 {
}
form#AddTest input[disabled = "disabled"],
form#EditTest input[disabled = "disabled"] {
form#EditTest input[disabled = "disabled"],
form#RemoveTest input[disabled = "disabled"] {
background-color: #dedede; /* Gray */
}
/* --- END of jQuery UI: Pop-up Dialog Boxes --- */
\ No newline at end of file
......@@ -246,9 +246,13 @@
// The "Edit Test" button on the main <form> that causes the pop-up dialog to show.
$("#edit_test").button().on("click", function() {
// Pop-up Dialog Message: Cannot edit a test that hasn't been selected.
// Error Dialog Message: Cannot edit a test that hasn't been selected.
if(typeof($("input[type='radio']:checked").val()) === "undefined") {
$("#dialog_edit_test_error").dialog({
// Sets the text of the dialog to say "edit".
$("#error_edit_or_remove_span").html("edit");
// Error dialog configuration.
$("#dialog_form_error_message").dialog({
resizable: false,
height: "auto",
width: 400,
......@@ -261,7 +265,7 @@
});
}
// Shows the pop-up dialog with the data filled in from the record that was selected by the user.
// No error so far. Shows the pop-up dialog with the data filled in from the record that was selected by the user.
else {
// Getters. Grabs the record data of the row selected prior to any modifications by the edit dialog.
DOMelem_radio_btn_selected = $("input[type='radio']:checked");
......@@ -281,6 +285,138 @@
edit_dialog.dialog("open");
}
});
// -------------------------------------------------------------------------------------------------
// Remove Test
// -------------------------------------------------------------------------------------------------
var remove_dialog, remove_form,
remove_subject_id = $("#remove_test_subject_id"),
remove_test_condition = $("#remove_test_condition"),
remove_login_code = $("#remove_login_code"),
remove_allFields = $([]).add(remove_subject_id).add(remove_test_condition).add(remove_login_code);
function removeTest() {
var valid = true;
remove_allFields.removeClass("ui-state-error");
/*
valid = valid && checkLength(name, "username", 3, 16);
valid = valid && checkLength(email, "email", 6, 80);
valid = valid && checkLength(password, "password", 5, 16);
valid = valid && checkRegexp(name, /^[a-z]([0-9a-z_\s])+$/i, "Username may consist of a-z, 0-9, underscores, spaces and must begin with a letter.");
valid = valid && checkRegexp(email, emailRegex, "eg. ui@jquery.com");
valid = valid && checkRegexp(password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9");
if (valid) {
$("#users tbody").append("<tr>" +
"<td>" + name.val() + "</td>" +
"<td>" + email.val() + "</td>" +
"<td>" + password.val() + "</td>" +
"</tr>");
dialog.dialog("close");
}
*/
if(valid) {
new_scheduled_subject_id = $("#remove_test_subject_id").val();
new_scheduled_test_condition = $("#remove_test_condition").val();
// The data sent to the server is what the admin wanted modified via the pop-up dialog defined further below.
// Specifically, see the Getters and Setters near the bottom.
$.ajax({
type: 'POST',
url: "../admin/scheduled_test_remove.php",
dataType: "json",
data: $("form#RemoveTest").serialize(),
success: function(response) {
// Success! Updates the DOM by removing the row in the <table>.
if(response.successful === true) {
DOMelem_radio_btn_selected.parent().parent().remove();
}
// Error
else {
alert("Error: " + response.error_message);
}
}
});
// Auto-closes the pop-up remove dialog for the user.
remove_dialog.dialog("close");
}
return valid;
}
remove_dialog = $("#dialog_form_remove_test").dialog({
autoOpen: false,
height: 400,
width: 350,
modal: true,
buttons: {
"Confirm Removal": removeTest,
Cancel: function() {
remove_dialog.dialog("close");
}
},
close: function() {
document.getElementById("RemoveTest").reset();
remove_allFields.removeClass("ui-state-error");
}
});
remove_form = remove_dialog.find("form#dialog_form_remove_test").on("submit", function(event) {
event.preventDefault();
removeTest();
});
// The "Remove Test" button on the main <form> that causes the pop-up dialog to show.
$("#remove_test").button().on("click", function() {
// Error Dialog Message: Cannot remove a test that hasn't been selected.
if(typeof($("input[type='radio']:checked").val()) === "undefined") {
// Sets the text of the dialog to say "remove".
$("#error_edit_or_remove_span").html("remove");
// Error dialog configuration.
$("#dialog_form_error_message").dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
buttons: {
Okay: function() {
$(this).dialog("close");
}
}
});
}
// No error so far. Shows the pop-up dialog with the data filled in from the record that was selected by the user.
else {
// Getters. Grabs the record data of the row selected prior to any modifications by the remove dialog.
DOMelem_radio_btn_selected = $("input[type='radio']:checked");
scheduled_sk = DOMelem_radio_btn_selected.val();
scheduled_subject_id = DOMelem_radio_btn_selected.attr("data-ov-subject-id");
scheduled_test_condition = DOMelem_radio_btn_selected.attr("data-ov-test-condition");
scheduled_login_code = DOMelem_radio_btn_selected.attr("data-ov-login-code");
// Setters. Puts the data into the pop-up dialog for the user to remove.
// Note: The 'sk' field isn't shown, but we need the data to be sent to the server nonetheless.
$("#remove_test_sk").val(scheduled_sk);
$("#remove_test_subject_id").val(scheduled_subject_id);
$("#remove_test_condition").val(scheduled_test_condition);
$("#remove_login_code").val(scheduled_login_code);
// More setters for the hidden fields as disabled fields cannot submit data to a server per the W3C.
$("#remove_test_sk_hidden").val(scheduled_sk);
$("#remove_test_subject_id_hidden").val(scheduled_subject_id);
$("#remove_test_condition_hidden").val(scheduled_test_condition);
$("#remove_login_code_hidden").val(scheduled_login_code);
// Opens the pop-up remove dialog for the user.
remove_dialog.dialog("open");
}
});
});
})(window, jQuery);
......
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