Forráskód Böngészése

Remove duration requirement in practice form

Alan Lam 8 éve
szülő
commit
65f8c4bbfb
1 módosított fájl, 3 hozzáadás és 11 törlés
  1. 3 11
      controllers/practice.php

+ 3 - 11
controllers/practice.php

@@ -56,11 +56,6 @@ if($submit) {
 		if($is_started || $is_unverified) {
 			// Parse after the test form
 			$fields = $json->duringTest;
-
-			if($is_started) {
-				$duration = http::value("duration", "int");
-				if(!$duration) $form_exception->addError("Duration was not submitted.");
-			}
 		}
 
 		foreach($fields as $field) {
@@ -136,6 +131,9 @@ if($submit) {
 				if($end_unix < $recorded_start_unix) $form_exception->addError("Test End date/time cannot be later than the recorded start date/time.");
 			}
 		}
+		else {
+			$form_exception->addError("Entry Time and Exit Time must be filled in.");
+		}
 
 		if($form_exception->hasErrors()) throw $form_exception;
 
@@ -156,16 +154,10 @@ if($submit) {
 			$test->status = Test::STATUS_PENDING_VERIFICATION;
 
 			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);
-
 				if($start_unix && $end_unix) {
 					$test->dts_start = date("Y-m-d H:i:s", $start_unix);
 					$test->dts_end = date("Y-m-d H:i:s", $end_unix);
 				}
-
 			}
 
 			$test->pass = ($test->challenge_stage <= 2) ? 1 : 0; // Pass = Challenged during browsing or before