Loaded points for all tasks
This commit is contained in:
parent
11b51efdcc
commit
ea4f0c49ff
4 changed files with 323 additions and 151 deletions
|
@ -12,7 +12,7 @@
|
|||
refresh as refreshTaskStatuses,
|
||||
taskStatuses,
|
||||
} from "./task-status-cache";
|
||||
import { isLoggedIn } from "./ksp-task-grabber";
|
||||
import { grabAssignment, isLoggedIn } from "./ksp-task-grabber";
|
||||
|
||||
export let tasks: TasksFile;
|
||||
|
||||
|
@ -201,6 +201,22 @@
|
|||
tasks.tasks = [...tasks.tasks, ...newDescriptors];
|
||||
}
|
||||
|
||||
async function loadMaxPoints() {
|
||||
const loadedTasks = await Promise.all(tasks.tasks.map(async t => {
|
||||
if (t.type != "open-data") {
|
||||
return t
|
||||
}
|
||||
const a = await grabAssignment(t.taskReference)
|
||||
if (a.points == null)
|
||||
throw Error(`Points are null for ${t.taskReference}`)
|
||||
return { ...t, points: a.points }
|
||||
}))
|
||||
|
||||
tasks = { ...tasks, tasks: loadedTasks }
|
||||
|
||||
alert("Načteno :)")
|
||||
}
|
||||
|
||||
function hideSelection() {
|
||||
for (let t of graph.getCurrentSelection()) {
|
||||
t.hidden = true;
|
||||
|
@ -373,8 +389,15 @@
|
|||
<button
|
||||
on:click={loadYear}
|
||||
disabled={!isLoggedIn()}
|
||||
title={isLoggedIn() ? 'Nahraje všechny úlohy z jednoho ročníku, které tu ještě nejsou' : 'Je nutné být přihlášený a na stránce v KSP template.'}>Nahrát
|
||||
celý ročník</button>
|
||||
title={isLoggedIn() ? 'Nahraje všechny úlohy z jednoho ročníku, které tu ještě nejsou' : 'Je nutné být přihlášený a na stránce v KSP template.'}>
|
||||
Nahrát celý ročník
|
||||
</button>
|
||||
<button
|
||||
on:click={loadMaxPoints}
|
||||
title="Stáhne ke každé úloze maximální počet bodů"
|
||||
>
|
||||
Aktualizovat počty bodů
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<button on:click={hideSelection}>Skrýt výběr</button>
|
||||
|
|
|
@ -10,7 +10,8 @@ export type TaskDescriptor = {
|
|||
} & (
|
||||
{
|
||||
type: "open-data",
|
||||
taskReference: string
|
||||
taskReference: string,
|
||||
points: number
|
||||
}
|
||||
|
|
||||
{
|
||||
|
|
|
@ -48,6 +48,7 @@ describe('tasks assignment', () => {
|
|||
expect(assignment.points).toBeGreaterThanOrEqual(1)
|
||||
expect(assignment.description.trim()).toBeTruthy()
|
||||
expect(assignment.name.trim()).toBeTruthy()
|
||||
expect(assignment.points).toBe(t.points)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
441
tasks.json
441
tasks.json
File diff suppressed because it is too large
Load diff
Reference in a new issue