mirror of
https://github.com/hcengineering/platform.git
synced 2025-03-20 14:01:51 +00:00
37 lines
1.0 KiB
Svelte
37 lines
1.0 KiB
Svelte
<!--
|
|
Copyright @ 2024 Hardcore Engineering Inc.
|
|
-->
|
|
|
|
<script lang="ts">
|
|
import type { Question } from '@hcengineering/questions'
|
|
import type { Training } from '@hcengineering/training'
|
|
import { createQuery } from '@hcengineering/presentation'
|
|
import { calculateAnswersToPass, queryQuestions } from '@hcengineering/questions-resources'
|
|
import { Loading } from '@hcengineering/ui'
|
|
import Score from './Score.svelte'
|
|
|
|
export let value: Training
|
|
|
|
let questions: Question<unknown>[] = []
|
|
const query = createQuery()
|
|
$: {
|
|
queryQuestions(query, value, 'questions', (result) => {
|
|
questions = result
|
|
})
|
|
}
|
|
|
|
let total: number | null = null
|
|
let needed: number | null = null
|
|
$: {
|
|
const calculated = calculateAnswersToPass(questions, value.passingScore)
|
|
total = calculated.assessmentsTotal
|
|
needed = calculated.answersNeeded
|
|
}
|
|
</script>
|
|
|
|
{#if total === null || needed === null}
|
|
<Loading size="small" />
|
|
{:else}
|
|
<Score count={needed} {total} score={value.passingScore} />
|
|
{/if}
|