test_form.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @controller test.php
  4. *
  5. * @var Test $test
  6. * @var Location $location
  7. * @var Project $project
  8. * @var Template $template
  9. */
  10. ?>
  11. <div class="container mt-3 py-4">
  12. <?php
  13. if($test->isConfirmed()) {
  14. $template->renderBeforeTestForm($project);
  15. }
  16. else if($test->hasStarted()) {
  17. $template->renderDuringTestForm();
  18. }
  19. else if($test->isPendingVerification()) {
  20. $json = json_decode($template->getJSON());
  21. $fields = $json->duringTest;
  22. $values = $test->getValues(true);
  23. ?>
  24. <div class="alert alert-info">
  25. <i class="fal fa-fw fa-info-circle"></i>
  26. <?=htmlspecialchars(__("Answer as clearly and accurately as you can otherwise you may be contacted after the test for clarification and/or verification purposes."))?>
  27. </div>
  28. <form method="post" id="test-form">
  29. <?php
  30. foreach($fields as $field) {
  31. $name = $field->name ?? false;
  32. if($name) {
  33. if(isset($test->$name)) $field->value = $test->$name;
  34. if(isset($values[$name])) $field->value = $values[$name];
  35. }
  36. $field->template = $template;
  37. Form::renderField($field);
  38. }
  39. ?>
  40. <input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
  41. <input type="hidden" name="void" id="void" value="0" />
  42. <div class="form-group">
  43. <button class="btn btn-block btn-success" type="submit" id="test-submit-button">
  44. <?=htmlspecialchars(__("Submit Test Results"))?>
  45. </button>
  46. </div>
  47. <div class="text-center">
  48. <small class="form-text text-muted d-none" id="test-no-internet-text">
  49. <span class="text-danger"><?=htmlspecialchars(__("No Internet Connectivity"))?></span><br />
  50. <?=htmlspecialchars(__("Please check your Internet connectivity and try again."))?>
  51. </small>
  52. <small id="test-submit-status">
  53. </small>
  54. </div>
  55. </form>
  56. <?php
  57. }
  58. else {
  59. ?>
  60. <h2><?=htmlspecialchars(__("Test Completed"))?></h2>
  61. <div class="alert alert-success">
  62. <?=sprintf(htmlspecialchars(__("This test is now completed. %sClick here%s to return to the Account page.")), '<a href="/account">', '</a>')?>
  63. </div>
  64. <?php
  65. }
  66. ?>
  67. </div>