1
0

location_tests_tab.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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->isPending()) {
  94. ?>
  95. <?=htmlspecialchars(__("Pending"))?>
  96. <?php
  97. }
  98. else {
  99. ?>
  100. <strong class="text-<?=$pass_class?>"><?=htmlspecialchars(__("Stage %d", $challenge_stage))?></strong> -
  101. <?=htmlspecialchars($challenge_stage_text)?>
  102. <?php
  103. }
  104. }
  105. else {
  106. echo htmlspecialchars(__("N/A"));
  107. }
  108. ?>
  109. </td>
  110. <td>
  111. <?php
  112. if($test->hasPDF()) {
  113. $pdf_url = $test->getPDFUrl();
  114. ?>
  115. <a href="<?=htmlspecialchars($pdf_url)?>" target="_blank">View PDF</a>
  116. <?php
  117. }
  118. else {
  119. echo htmlspecialchars(__("No PDF available"));
  120. }
  121. ?>
  122. </td>
  123. <?php
  124. if(Core::$user->isAdmin()) {
  125. ?>
  126. <td>
  127. <?php
  128. if($test->status >= Test::STATUS_PENDING_VERIFICATION) {
  129. ?>
  130. <a href="/account/tests/<?=$test->id?>">View Results</a>
  131. <?php
  132. }
  133. else {
  134. ?>
  135. <a href="/account/projects/<?=$test->project_id?>">View Project</a>
  136. <?php
  137. }
  138. ?>
  139. </td>
  140. <?php
  141. }
  142. ?>
  143. </tr>
  144. <?php
  145. }
  146. ?>
  147. </tbody>
  148. </table>
  149. <?php
  150. }
  151. ?>
  152. </div>