1
0

test_form.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 id="test-submit-alert" class="alert" hidden>
  48. <div class="mb-1">
  49. <i class="fa fa-fw fa-info-circle"></i> <strong></strong>
  50. </div>
  51. <div id="test-submit-status">
  52. </div>
  53. </div>
  54. </form>
  55. <?php
  56. }
  57. else {
  58. ?>
  59. <h2><?=htmlspecialchars(__("Test Completed"))?></h2>
  60. <div class="alert alert-success">
  61. <?=sprintf(htmlspecialchars(__("This test is now completed. %sClick here%s to return to the Account page.")), '<a href="/account">', '</a>')?>
  62. </div>
  63. <?php
  64. }
  65. ?>
  66. </div>