Browse Source

Add explainers for report summary data; fix calculation of merged fails

Alan Lam 2 years ago
parent
commit
54453853c9

+ 1 - 1
template_processing/age_verification_greene_king/reports_process_test.php

@@ -169,7 +169,7 @@ else if($test->challenge_stage === 5 || $test->void_primary) {
 if($gaming_pass || $alcohol_pass) {
 	$total_data->mergedCounts["pass"]++;
 }
-elseif($alcohol_pass === false) {
+elseif($alcohol_pass === false || $test->challenge_stage === 3 || $test->challenge_stage === 4) {
 	$total_data->mergedCounts["fail"]++;
 }
 else {

+ 39 - 8
views/reports.php

@@ -383,7 +383,7 @@ let projectData = <?=json_encode($project_table_data)?>;
 
 		<?php
 
-		$render_pass_fail_row = static function(string $title, $pass, $fail, $void) {
+		$render_pass_fail_row = static function(string $title, $pass, $fail, $void, $explainer = "") {
 			$total = $pass + $fail;
 
 			$pass_percentage = 0;
@@ -392,13 +392,18 @@ let projectData = <?=json_encode($project_table_data)?>;
 			}
 			?>
 			<tr>
-				<th><?=htmlspecialchars($title)?></th>
+				<th rowspan="2"><?=htmlspecialchars($title)?></th>
 				<td class="text-right"><?=$total?></td>
 				<td class="text-right"><?=$pass?></td>
 				<td class="text-right"><?=$fail?></td>
 				<td class="text-right"><?=$pass_percentage?>%</td>
 				<td class="text-right"><?=$void?></td>
 			</tr>
+			<tr>
+				<td colspan="5">
+					<?=htmlspecialchars($explainer)?>
+				</td>
+			</tr>
 			<?php
 		};
 		?>
@@ -425,20 +430,39 @@ let projectData = <?=json_encode($project_table_data)?>;
 				</thead>
 				<tbody>
 				<tr>
-					<th><?=htmlspecialchars(__("Venue Tests"))?></th>
+					<th rowspan="2"><?=htmlspecialchars(__("Venue Tests"))?></th>
 					<td class="text-right"><?=htmlspecialchars($total_data->testCount)?></td>
 					<td></td>
 					<td></td>
 					<td></td>
 					<td class="text-right"><?=htmlspecialchars($total_data->voidCount)?></td>
 				</tr>
+				<tr>
+					<td colspan="5">
+						<?=htmlspecialchars(__("There were %d tests of which %d were voids resulting in %d gaming tests being carried out.", $total_data->testCount + $total_data->voidCount, $total_data->voidCount, $total_data->testCount))?>
+					</td>
+				</tr>
 				<?php
 				if(isset($total_data->passCount)) {
-					$render_pass_fail_row(__("Gaming Tests"), $total_data->passCount, $total_data->failCount, $total_data->gamingCounts["void"] ?? 0);
+					$pass_count = $total_data->passCount;
+					$fail_count = $total_data->failCount;
+					$void_count = $total_data->gamingCounts["void"] ?? 0;
+					$explainer = __("There were %d gaming tests of which there were %d passes and %d fails and %d voids.", ($pass_count + $fail_count + $void_count), $pass_count, $fail_count, $void_count);
+
+					$render_pass_fail_row(__("Gaming Tests"), $pass_count, $fail_count, $void_count, $explainer);
 				}
 
 				if(isset($total_data->barCounts)) {
-					$render_pass_fail_row(__("Alcohol Tests"), $total_data->barCounts["pass"],  $total_data->barCounts["fail"], $total_data->barCounts["void"] ?? 0);
+
+					$gaming_stage_5 = $total_data->stage5Count ?? 0;
+					$gaming_void_count = $total_data->gamingCounts["void"] ?? 0;
+
+					$pass_count = $total_data->barCounts["pass"];
+					$fail_count = $total_data->barCounts["fail"];
+					$void_count = $total_data->barCounts["void"] ?? 0;
+					$explainer = __("There were %d alcohol tests which come from %d gaming tests that ended up in Stage 5 plus %d gaming tests that were void. Of these alcohol tests there were %d passes and %d fails and %d voids.", ($pass_count + $fail_count + $void_count), $gaming_stage_5, $gaming_void_count, $pass_count, $fail_count, $void_count);
+
+					$render_pass_fail_row(__("Alcohol Tests"), $pass_count, $fail_count, $void_count, $explainer);
 				}
 
 				?>
@@ -448,15 +472,22 @@ let projectData = <?=json_encode($project_table_data)?>;
 				<?php
 
 				if(isset($total_data->combinedCounts)) {
-					$render_pass_fail_row(__("Gaming and Alcohol"), $total_data->combinedCounts["pass"],  $total_data->combinedCounts["fail"], $total_data->combinedCounts["void"] ?? 0);
+					$render_pass_fail_row(__("Gaming and Alcohol"), $total_data->combinedCounts["pass"],  $total_data->combinedCounts["fail"], $total_data->combinedCounts["void"] ?? 0, __("The gaming and alcohol tests added together."));
 				}
 
 				if(isset($total_data->blendedCounts)) {
-					$render_pass_fail_row(__("Gaming and Assumed Alcohol"), $total_data->blendedCounts["pass"],  $total_data->blendedCounts["fail"], $total_data->blendedCounts["void"] ?? 0);
+					$render_pass_fail_row(__("Gaming and Assumed Alcohol"), $total_data->blendedCounts["pass"],  $total_data->blendedCounts["fail"], $total_data->blendedCounts["void"] ?? 0, __("The gaming and alcohol tests added together but also assuming that any gaming test pass is also an alcohol test pass. %d passes were added.", $total_data->passCount));
 				}
 
 				if(isset($total_data->mergedCounts)) {
-					$render_pass_fail_row(__("Gaming or Alcohol Pass"), $total_data->mergedCounts["pass"],  $total_data->mergedCounts["fail"], $total_data->mergedCounts["void"] ?? 0);
+					$pass_count = $total_data->mergedCounts["pass"];
+					$fail_count = $total_data->mergedCounts["fail"];
+					$void_count = $total_data->mergedCounts["void"] ?? 0;
+
+					$gaming_stage_3 = $total_data->stage3Count ?? 0;
+					$gaming_stage_4 = $total_data->stage4Count ?? 0;
+
+					$render_pass_fail_row(__("Gaming or Alcohol Pass"), $pass_count, $fail_count, $void_count, __("The gaming and alcohol passes added together. %d tests either passed the gaming test or alcohol test. There were %d outright fails: %d were caught at Stage 3, %d were caught at Stage 4 and %d failed the alcohol test.", $pass_count, $total_data->mergedCounts["fail"], $gaming_stage_3, $gaming_stage_4, $total_data->barCounts["fail"]));
 				}
 
 				?>