test_form.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  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->status == Test::STATUS_CONFIRMED) {
  14. $template->renderBeforeTestForm();
  15. }
  16. else if($test->status == Test::STATUS_STARTED) {
  17. $template->renderDuringTestForm();
  18. }
  19. else if($test->status == Test::STATUS_PENDING_VERIFICATION) {
  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. <div class="bg-light text-center p-3 mt-3">
  41. <input type="hidden" name="submit" value="<?=htmlspecialchars($_SESSION["csrf_token"])?>" />
  42. <button class="btn btn-block btn-primary" type="submit" id="test-submit-button"><?=htmlspecialchars(__("Submit Test Results"))?></button>
  43. <small class="form-text text-muted d-none" id="test-no-internet-text">
  44. <span class="text-danger"><?=htmlspecialchars(__("No Internet Connectivity"))?></span><br />
  45. <?=htmlspecialchars(__("Please check your Internet connectivity and try again."))?>
  46. </small>
  47. <small id="test-submit-status">
  48. </small>
  49. </div>
  50. </form>
  51. <?php
  52. }
  53. else {
  54. ?>
  55. <h2><?=htmlspecialchars(__("Test Completed"))?></h2>
  56. <div class="alert alert-success">
  57. <?=sprintf(htmlspecialchars(__("This test is now completed. %sClick here%s to return to the Account page.")), '<a href="/account">', '</a>')?>
  58. </div>
  59. <?php
  60. }
  61. ?>
  62. </div>