location_tests_tab.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. /**
  3. * @var Location $location
  4. */
  5. if(Core::$user->isAdmin()) {
  6. $tests = $location->getTests();
  7. }
  8. else {
  9. $tests = $location->getCompletedTests();
  10. }
  11. ?>
  12. <div class="tab-pane fade" id="tests" role="tabpanel" aria-labelledby="tests-tab">
  13. <?php
  14. if(empty($tests)) {
  15. ?>
  16. <div class="alert alert-info">
  17. This location has no tests.
  18. </div>
  19. <?php
  20. }
  21. else {
  22. ?>
  23. <table class="table table-bordered table-hover">
  24. <thead>
  25. <tr>
  26. <th>ID</th>
  27. <?php
  28. if(Core::$user->isAdmin()) {
  29. ?>
  30. <th>Project</th>
  31. <?php
  32. }
  33. else {
  34. ?>
  35. <th>Date/Time</th>
  36. <?php
  37. }
  38. ?>
  39. <th>Status</th>
  40. <th>Result</th>
  41. <th>Challenge Stage</th>
  42. <th>PDF</th>
  43. <?php
  44. if(Core::$user->isAdmin()) {
  45. ?>
  46. <th>Actions</th>
  47. <?php
  48. }
  49. ?>
  50. </tr>
  51. </thead>
  52. <tbody>
  53. <?php
  54. foreach($tests as $test) {
  55. $project = $test->getProject();
  56. $template = $project->getTemplate();
  57. $has_pass_fail = $template->hasPassFail();
  58. $pass_text = $test->getPassText();
  59. $pass_class = $test->getPassClass();
  60. $pass_icon = $test->getPassIcon();
  61. $challenge_stage = $test->challenge_stage;
  62. $challenge_stage_text = $test->getChallengeStageText();
  63. ?>
  64. <tr>
  65. <td class="text-right align-middle">
  66. <?=$test->id?>
  67. </td>
  68. <td>
  69. <?php
  70. if(Core::$user->isAdmin()) {
  71. ?>
  72. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  73. <?php
  74. }
  75. else {
  76. echo Util::getDisplayDateTimeFromUTC($test->dts_start);
  77. }
  78. ?>
  79. </td>
  80. <td class="text-center">
  81. <span class="badge badge-lg badge-<?=$test->getStatusClass()?>"><?=htmlspecialchars($test->getStatusText())?></span>
  82. </td>
  83. <td class="text-center">
  84. <?php
  85. if($has_pass_fail) {
  86. ?>
  87. <strong class="text-<?=$pass_class?>"><?=htmlspecialchars($pass_text)?></strong>
  88. <?php
  89. }
  90. else {
  91. echo htmlspecialchars(__("N/A"));
  92. }
  93. ?>
  94. </td>
  95. <td>
  96. <?php
  97. if($has_pass_fail) {
  98. if($test->isPending()) {
  99. ?>
  100. <?=htmlspecialchars(__("Pending"))?>
  101. <?php
  102. }
  103. else {
  104. ?>
  105. <strong class="text-<?=$pass_class?>"><?=htmlspecialchars(__("Stage %d", $challenge_stage))?></strong> -
  106. <?=htmlspecialchars($challenge_stage_text)?>
  107. <?php
  108. }
  109. }
  110. else {
  111. echo htmlspecialchars(__("N/A"));
  112. }
  113. ?>
  114. </td>
  115. <td>
  116. <?php
  117. if($test->hasPDF()) {
  118. $pdf_url = $test->getPDFUrl();
  119. ?>
  120. <a href="<?=htmlspecialchars($pdf_url)?>" target="_blank">View PDF</a>
  121. <?php
  122. }
  123. else {
  124. echo htmlspecialchars(__("No PDF available"));
  125. }
  126. ?>
  127. </td>
  128. <?php
  129. if(Core::$user->isAdmin()) {
  130. ?>
  131. <td>
  132. <?php
  133. if($test->status >= Test::STATUS_PENDING_VERIFICATION) {
  134. ?>
  135. <a href="/account/tests/<?=$test->id?>">View Results</a>
  136. <?php
  137. }
  138. else {
  139. ?>
  140. <a href="/account/projects/<?=$test->project_id?>">View Project</a>
  141. <?php
  142. }
  143. ?>
  144. </td>
  145. <?php
  146. }
  147. ?>
  148. </tr>
  149. <?php
  150. }
  151. ?>
  152. </tbody>
  153. </table>
  154. <?php
  155. }
  156. ?>
  157. </div>