practice_form.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php /** @noinspection PhpUnhandledExceptionInspection */
  2. /**
  3. * @controller practice.php
  4. *
  5. * @var Test $test
  6. * @var Template $template
  7. * @var array $fields
  8. */
  9. ?>
  10. <div class="container mt-3 py-4">
  11. <?php
  12. if($test->isConfirmed()) {
  13. $template->renderBeforeTestForm();
  14. }
  15. else if($test->hasStarted()) {
  16. $template->renderDuringTestForm();
  17. }
  18. else {
  19. ?>
  20. <h2><?=htmlspecialchars(__("Test Completed"))?></h2>
  21. <p class="text-lead"><?=htmlspecialchars(__("Thanks for taking a practice test. You can find your submitted results below."))?></p>
  22. <p><a class="btn btn-lg btn-primary" href="/account/practice/<?=$template->id?>?reset=1"><?=htmlspecialchars(__("Start Over"))?></a></p>
  23. <?php
  24. $values = $test->getValues();
  25. // View submitted data
  26. foreach($fields as $field) {
  27. $name = $field->name ?? false;
  28. if($name) {
  29. $field->value = in_array($name, Test::TEST_FIELDS) ? $test->$name : ($values[$name] ?? null);
  30. }
  31. if($field->type === "header") {
  32. ?>
  33. <hr />
  34. <?php
  35. }
  36. if($field->type === "file") {
  37. ?>
  38. <div class="row mb-1">
  39. <div class="col-sm-4 col-form-label">
  40. <?=htmlspecialchars($field->label)?>
  41. </div>
  42. <div class="col-sm">
  43. <a class="btn btn-primary" href="/account/practice/<?=$template->id?>/files/<?=htmlspecialchars($name)?>" target="_blank"><?=htmlspecialchars(__("View Image"))?></a>
  44. </div>
  45. </div>
  46. <?php
  47. }
  48. else {
  49. $field->template = $template;
  50. Form::renderField($field);
  51. }
  52. }
  53. ?>
  54. <hr />
  55. <h3><?=htmlspecialchars(__("Test Date/Time"))?></h3>
  56. <div class="row mb-1">
  57. <label class="col-sm-4 col-form-label"><?=htmlspecialchars(__("Test Start"))?></label>
  58. <div class="col-sm">
  59. <?=htmlspecialchars($test->dts_start)?>
  60. </div>
  61. </div>
  62. <div class="row mb-1">
  63. <label class="col-sm-4 col-form-label"><?=htmlspecialchars(__("Test End"))?></label>
  64. <div class="col-sm">
  65. <?=htmlspecialchars($test->dts_end)?>
  66. </div>
  67. </div>
  68. <?php
  69. }
  70. ?>
  71. </div>