|
|
@@ -5,6 +5,10 @@ Core::addScript("public/js/app-test.js");
|
|
|
$test = Test::get($id);
|
|
|
if(!$test) throw new Exception("Test cannot be found.");
|
|
|
|
|
|
+$is_confirmed = $test->status == Test::STATUS_CONFIRMED;
|
|
|
+$is_started = $test->status == Test::STATUS_STARTED;
|
|
|
+$is_unverified = $test->status == Test::STATUS_PENDING_VERIFICATION;
|
|
|
+
|
|
|
$location = $test->getLocation();
|
|
|
$project = $test->getProject();
|
|
|
$tester = $test->getTester();
|
|
|
@@ -27,7 +31,7 @@ if(Core::$user->level == User::LEVEL_TESTER) {
|
|
|
if($test->status == Test::STATUS_ASSIGNED) throw new Exception("You do not have permission to view this page as you have not accepted the test yet.");
|
|
|
|
|
|
// Show completed message
|
|
|
- if($test->status >= Test::STATUS_PENDING_VERIFICATION) {
|
|
|
+ if($test->status > Test::STATUS_PENDING_VERIFICATION) {
|
|
|
View::includeOnce("header", compact("page_title"));
|
|
|
View::include("test_form", compact("test", "location", "project", "template"));
|
|
|
View::includeOnce("footer");
|
|
|
@@ -48,18 +52,20 @@ if(Core::$user->level == User::LEVEL_TESTER) {
|
|
|
|
|
|
$form_exception = new FormException;
|
|
|
|
|
|
- if($test->status == Test::STATUS_CONFIRMED) {
|
|
|
+ if($is_confirmed) {
|
|
|
// Parse before the test form
|
|
|
$fields = $json->beforeTest;
|
|
|
|
|
|
}
|
|
|
|
|
|
- if($test->status == Test::STATUS_STARTED) {
|
|
|
+ if($is_started || $is_unverified) {
|
|
|
// Parse after the test form
|
|
|
$fields = $json->duringTest;
|
|
|
|
|
|
- $duration = http::value("duration", "int");
|
|
|
- if(!$duration) $form_exception->addError("Duration was not submitted.");
|
|
|
+ if($is_started) {
|
|
|
+ $duration = http::value("duration", "int");
|
|
|
+ if(!$duration) $form_exception->addError("Duration was not submitted.");
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -131,7 +137,7 @@ if(Core::$user->level == User::LEVEL_TESTER) {
|
|
|
if($form_exception->hasErrors()) throw $form_exception;
|
|
|
|
|
|
// Before the Test
|
|
|
- if($test->status == Test::STATUS_CONFIRMED) {
|
|
|
+ if($is_confirmed) {
|
|
|
$test->status = Test::STATUS_STARTED;
|
|
|
$test->dts_start = Util::getDateTime();
|
|
|
$test->dts_updated = Util::getDateTime();
|
|
|
@@ -143,13 +149,15 @@ if(Core::$user->level == User::LEVEL_TESTER) {
|
|
|
}
|
|
|
|
|
|
// During the test
|
|
|
- if($test->status == Test::STATUS_STARTED) {
|
|
|
+ if($is_started || $is_unverified) {
|
|
|
$test->status = Test::STATUS_PENDING_VERIFICATION;
|
|
|
|
|
|
- $unix_start = strtotime($test->dts_start);
|
|
|
- $unix_end = $unix_start + floor($duration / 1000); // $duration is milliseconds
|
|
|
+ if($is_started) {
|
|
|
+ $unix_start = strtotime($test->dts_start);
|
|
|
+ $unix_end = $unix_start + floor($duration / 1000); // $duration is milliseconds
|
|
|
|
|
|
- $test->dts_end = date("Y-m-d H:i:s", $unix_end);
|
|
|
+ $test->dts_end = date("Y-m-d H:i:s", $unix_end);
|
|
|
+ }
|
|
|
|
|
|
$test->pass = ($test->challenge_stage <= 2) ? 1 : 0; // Pass = Challenged during browsing or before
|
|
|
$test->dts_updated = Util::getDateTime();
|