Adjust ranking offsets

This commit is contained in:
Neale Pickett 2022-10-09 22:34:44 -06:00
parent ac4f025633
commit 29eda96724
3 changed files with 82 additions and 1 deletions

View File

@ -220,3 +220,68 @@ a low ranking from a single judge can carry a lot of weight.
</tr>
</tfoot>
</table>
### Being in 1st provides a nice buffer
Try playing around with Alice's rankings with Adjudicators 2 and 3 here.
She has to get ranked a lot lower before her overall ranking starts going down.
<div class="scrolly">
<table class="scorecard">
<thead>
<tr>
<td></td>
<th>Alice</th>
<th>Bob</th>
<th>Carol</th>
<th>Dave</th>
<th>Erin</th>
</tr>
</thead>
<tbody>
<tr>
<th class="justify-left">Adj. 1</th>
<td><input type="number" min=1 max=99 value=1></td>
<td><input type="number" min=1 max=99 value=3></td>
<td><input type="number" min=1 max=99 value=2></td>
<td><input type="number" min=1 max=99 value=4></td>
<td><input type="number" min=1 max=99 value=5></td>
</tr>
<tr>
<th class="justify-left">Adj. 2</th>
<td><input type="number" min=1 max=99 value=7></td>
<td><input type="number" min=1 max=99 value=1></td>
<td><input type="number" min=1 max=99 value=2></td>
<td><input type="number" min=1 max=99 value=3></td>
<td><input type="number" min=1 max=99 value=4></td>
</tr>
<tr>
<th class="justify-left">Adj. 3</th>
<td><input type="number" min=1 max=99 value=4></td>
<td><input type="number" min=1 max=99 value=2></td>
<td><input type="number" min=1 max=99 value=1></td>
<td><input type="number" min=1 max=99 value=3></td>
<td><input type="number" min=1 max=99 value=5></td>
</tr>
</tbody>
<tfoot>
<tr>
<th class="justify-left">Award Points</th>
<td class="justify-right"><output name="points"></td>
<td class="justify-right"><output name="points"></td>
<td class="justify-right"><output name="points"></td>
<td class="justify-right"><output name="points"></td>
<td class="justify-right"><output name="points"></td>
</tr>
<tr>
<th class="justify-left">Ranking</th>
<td class="justify-right"><output name="ranking"></td>
<td class="justify-right"><output name="ranking"></td>
<td class="justify-right"><output name="ranking"></td>
<td class="justify-right"><output name="ranking"></td>
<td class="justify-right"><output name="ranking"></td>
</tr>
</tfoot>
</table>
</div>

View File

@ -3,6 +3,7 @@ import {awardPoints} from "./awardPoints.mjs"
function scorecardUpdate(scorecard) {
let scores = []
let points = []
let highestRank = []
let firstRow = scorecard.querySelector("tbody tr")
for (let input of firstRow.querySelectorAll("input")) {
@ -16,6 +17,7 @@ function scorecardUpdate(scorecard) {
let ranking = Number(input.value)
scores[i] += ranking
points[i] += awardPoints[ranking]
highestRank[i] = Math.min(highestRank[i] || 100, ranking)
i += 1
}
}
@ -29,10 +31,19 @@ function scorecardUpdate(scorecard) {
}
{
let rankOffset = 0
let overallRanking = []
let rankedPoints = [...points].sort((a, b) => b - a)
for (let i = 0; i < points.length; i++) {
overallRanking[i] = rankedPoints.indexOf(points[i]) + 1
if (overallRanking[i] == 1) {
rankOffset = highestRank[i]
}
}
let i = 0
for (let out of scorecard.querySelectorAll("tfoot output[name='ranking']")) {
out.value = rankedPoints.indexOf(points[i]) + 1
out.value = rankedPoints.indexOf(points[i]) + rankOffset
i += 1
}
}

View File

@ -6,6 +6,11 @@
display: initial;
}
.scrolly {
max-width: 100%;
overflow-x: auto;
}
.awardPoints {
display: inline-block;
max-height: 60vh;