| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php /** @noinspection PhpUnhandledExceptionInspection */
- /**
- * @var Test $test
- * @var FormException $form_exception
- */
- $project = $test->getProject();
- if($test->dts_start && $test->dts_end && $project && $project->browse_time && $project->play_time) {
- $dt_start = $test->getDateTimeStart()->setTimezone(TIMEZONE);
- $dt_end = $test->getDateTimeEnd()->setTimezone(TIMEZONE);
- $duration = $dt_end->diffInMinutes($dt_start);
- /** @var string[] $values */
- $values = $test->getValues(true);
- $play_minutes = (int) ($values["play_minutes"] ?? 0);
- $challenge_stage = (int) $test->challenge_stage;
- // Calculate minimum duration
- $min_duration = $project->browse_time;
- if($test->challenge_stage >= 2) {
- $min_duration += $project->play_time;
- }
- $min_duration += $play_minutes;
- if($play_minutes < $project->play_time && in_array($challenge_stage, [4, 5])) {
- $form_exception->addError("Please confirm that you played for at least {$project->play_time} minutes because you have selected After Play / No Challenge.");
- }
- if($duration < $min_duration) {
- $form_exception->addError("Please check the entry and exit times. Based on the information you have given, you should have been at the venue for $min_duration minutes or more.");
- }
- }
|