location_tests_tab.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. /**
  3. * @var Location $location
  4. */
  5. $tests = $location->getCompletedTests();
  6. ?>
  7. <div class="tab-pane fade" id="tests" role="tabpanel" aria-labelledby="tests-tab">
  8. <?php
  9. if(empty($tests)) {
  10. ?>
  11. <div class="alert alert-info">
  12. This location has no tests.
  13. </div>
  14. <?php
  15. }
  16. else {
  17. ?>
  18. <table class="table table-bordered table-hover">
  19. <thead>
  20. <tr>
  21. <th>ID</th>
  22. <?php
  23. if(Core::$user->isAdmin()) {
  24. ?>
  25. <th>Project</th>
  26. <?php
  27. }
  28. else {
  29. ?>
  30. <th>Date/Time</th>
  31. <?php
  32. }
  33. ?>
  34. <th>Status</th>
  35. <th>Result</th>
  36. <th>Challenge Stage</th>
  37. <th>PDF</th>
  38. <?php
  39. if(Core::$user->isAdmin()) {
  40. ?>
  41. <th>Actions</th>
  42. <?php
  43. }
  44. ?>
  45. </tr>
  46. </thead>
  47. <tbody>
  48. <?php
  49. foreach($tests as $test) {
  50. $project = $test->getProject();
  51. $template = $project->getTemplate();
  52. $has_pass_fail = $template->hasPassFail();
  53. $pass_text = $test->getPassText();
  54. $pass_class = $test->getPassClass();
  55. $pass_icon = $test->getPassIcon();
  56. $challenge_stage = $test->challenge_stage;
  57. $challenge_stage_text = $test->getChallengeStageText();
  58. ?>
  59. <tr>
  60. <td class="text-right align-middle">
  61. <?=$test->id?>
  62. </td>
  63. <td>
  64. <?php
  65. if(Core::$user->isAdmin()) {
  66. ?>
  67. <a href="/account/projects/<?=$project->id?>"><?=htmlspecialchars($project->name)?></a>
  68. <?php
  69. }
  70. else {
  71. echo Util::getDisplayDateTimeFromUTC($test->dts_start);
  72. }
  73. ?>
  74. </td>
  75. <td class="text-center">
  76. <span class="badge badge-lg badge-<?=$test->getStatusClass()?>"><?=htmlspecialchars($test->getStatusText())?></span>
  77. </td>
  78. <td class="text-center">
  79. <?php
  80. if($has_pass_fail) {
  81. ?>
  82. <strong class="text-<?=$pass_class?>"><?=htmlspecialchars($pass_text)?></strong>
  83. <?php
  84. }
  85. else {
  86. echo htmlspecialchars(__("N/A"));
  87. }
  88. ?>
  89. </td>
  90. <td>
  91. <?php
  92. if($has_pass_fail) {
  93. if($test->isVoid()) {
  94. ?>
  95. <strong><?=htmlspecialchars(__("Void"))?></strong>
  96. <?php
  97. }
  98. elseif($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>