Skip to content

Commit

Permalink
Fix JAT scores when there are no movements. #23
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed May 8, 2024
1 parent 41e60a3 commit 4ba8819
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/routes/route_check/jat_check/EditJunction.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@
{/each}
</ol>

<p>Total JAT score: {totalScore($state.jat[junctionIdx][stage])}%</p>
{#if $state.jat[junctionIdx][stage].movements.length > 0}
<p>Total JAT score: {totalScore($state.jat[junctionIdx][stage])}%</p>
{/if}
{:else}
<DefaultButton on:click={() => (editing = null)}>Save</DefaultButton>
<WarningButton on:click={deleteItem}>Delete</WarningButton>
Expand Down
17 changes: 13 additions & 4 deletions src/routes/route_check/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,19 @@ function getJatResults(state: State): JunctionResult[] {
scoreBoth += scoreLookup[m.score];
totalPossibleBoth += 2;
}
// TODO Handle 'not completed's
result.walkingWheeling[stage] = `${(scoreWW / totalPossibleWW) * 100}%`;
result.cycling[stage] = `${(scoreCycling / totalPossibleCycling) * 100}%`;
result.total[stage] = `${(scoreBoth / totalPossibleBoth) * 100}%`;

result.walkingWheeling[stage] =
totalPossibleWW > 0
? `${(scoreWW / totalPossibleWW) * 100}%`
: "Not Completed";
result.cycling[stage] =
totalPossibleCycling > 0
? `${(scoreCycling / totalPossibleCycling) * 100}%`
: "Not Comleted";
result.total[stage] =
totalPossibleBoth > 0
? `${(scoreBoth / totalPossibleBoth) * 100}%`
: "Not Completed";
}
out.push(result);
}
Expand Down

0 comments on commit 4ba8819

Please sign in to comment.