Skip to content

Commit e14ee46

Browse files
SpecyCopilot
andcommitted
some bug fixes for exam
Co-authored-by: Copilot <copilot@github.com>
1 parent b2f14b9 commit e14ee46

5 files changed

Lines changed: 36 additions & 10 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@fontsource/fira-mono": "^5.2.7",
2424
"@specy/mips": "^1.2.8",
2525
"@specy/risc-v": "^1.0.8",
26-
"@specy/s68k": "^1.3.0",
26+
"@specy/s68k": "^1.3.1",
2727
"@specy/x86": "^2.0.5",
2828
"@sveltejs/vite-plugin-svelte": "^6.2.4",
2929
"@xterm/xterm": "^6.0.0",

src/components/shared/input/Input.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import FaCheckCircle from 'svelte-icons/fa/FaCheckCircle.svelte'
77
import FaRegCircle from 'svelte-icons/fa/FaRegCircle.svelte'
88
import { onMount } from 'svelte'
9+
import type { FullAutoFill } from 'svelte/elements'
910
type statusType = '' | 'correct' | 'wrong'
1011
1112
interface Props {
@@ -19,6 +20,7 @@
1920
focus?: boolean
2021
hideStatus?: boolean
2122
el?: HTMLInputElement
23+
autoComplete?: FullAutoFill
2224
}
2325
2426
let {
@@ -30,6 +32,7 @@
3032
placeholder = '',
3133
focus = false,
3234
hideStatus = true,
35+
autoComplete,
3336
wrapperStyle,
3437
el = $bindable()
3538
}: Props = $props()
@@ -51,6 +54,7 @@
5154
<div class="input-row" {style}>
5255
<input
5356
spellcheck="false"
57+
autocomplete={autoComplete}
5458
bind:value
5559
class="form-input"
5660
use:setType

src/lib/languages/Emulator.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const instances = {
1414
MIPS: null as Promise<typeof MIPSEmulator> | null,
1515
X86: null as Promise<typeof X86Emulator> | null, //X86Emulator2['create']
1616
'RISC-V': null as Promise<typeof RISCVEmulator> | null,
17-
'RISC-V-64': null as Promise<typeof RISCVEmulator> | null,
17+
'RISC-V-64': null as Promise<typeof RISCVEmulator> | null
1818
}
1919

2020
function loadEmulator(type: AvailableLanguages) {
@@ -24,7 +24,9 @@ function loadEmulator(type: AvailableLanguages) {
2424
} else if (type === 'MIPS') {
2525
instances[type] = import('./MIPS/MIPSEmulator.svelte').then((i) => i.MIPSEmulator)
2626
} else if (type === 'RISC-V' || type === 'RISC-V-64') {
27-
instances['RISC-V'] = import('./RISC-V/RISC-VEmulator.svelte').then((i) => i.RISCVEmulator)
27+
instances['RISC-V'] = import('./RISC-V/RISC-VEmulator.svelte').then(
28+
(i) => i.RISCVEmulator
29+
)
2830
instances['RISC-V-64'] = instances['RISC-V']
2931
} else if (type === 'X86') {
3032
instances[type] = import('./X86/X86Emulator.svelte').then((i) => i.X86Emulator)
@@ -45,3 +47,12 @@ export async function GenericEmulator<T extends AvailableLanguages>(
4547
const emulator = await loadEmulator(type)
4648
return emulator!(baseCode, options)
4749
}
50+
51+
export function preloadAllEmulators() {
52+
return Promise.all([
53+
loadEmulator('M68K'),
54+
loadEmulator('MIPS'),
55+
loadEmulator('RISC-V'),
56+
loadEmulator('X86')
57+
])
58+
}

src/routes/exam/session/+page.svelte

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
type OpenQuestionAnswer,
3232
type OpenQuestionSection
3333
} from '$lib/exam'
34-
import { makeHash } from '$lib/utils'
34+
import { makeHash, textDownloader } from '$lib/utils'
3535
import { toast } from '$stores/toastStore'
3636
import { Prompt } from '$stores/promptStore.svelte'
3737
import { onMount } from 'svelte'
@@ -42,6 +42,7 @@
4242
import FaBook from 'svelte-icons/fa/FaBook.svelte'
4343
import ExamReviewAgentSidebar from '$cmp/specific/exam/ExamReviewAgentSidebar.svelte'
4444
import SparklesIcon from '$cmp/shared/agent/SparklesIcon.svelte'
45+
import { preloadAllEmulators } from '$lib/languages/Emulator'
4546
4647
let exam = $state<ExamPayload | null>(null)
4748
let sections = $state([] as ExamSection[])
@@ -470,6 +471,7 @@
470471
471472
onMount(() => {
472473
loadExam()
474+
preloadAllEmulators()
473475
474476
const intervalId = setInterval(() => {
475477
now = Date.now()
@@ -518,6 +520,7 @@
518520
<p>The exam was paused because you left fullscreen or changed tab.</p>
519521
<Row gap="1rem">
520522
<Input
523+
autoComplete="one-time-code"
521524
type="password"
522525
placeholder="Unlock password"
523526
bind:value={unlockPasswordInput}
@@ -532,10 +535,11 @@
532535

533536
{#if examDisabled && submissionUrl}
534537
<div class="overlay">
535-
<h1 class="loading">Exam submitted</h1>
536-
<p>The submission link is in your clipboard.</p>
538+
<h1 class="loading">Exam Finished</h1>
539+
<p>The submission link is in your clipboard. You can now share the submission link. You can also copy it again if needed.</p>
537540
<Row gap="1rem">
538541
<Input
542+
autoComplete="one-time-code"
539543
type="password"
540544
placeholder="Unlock password"
541545
bind:value={unlockPasswordInput}
@@ -549,6 +553,13 @@
549553
}}
550554
>
551555
Copy submission link again
556+
</Button>
557+
<Button
558+
onClick={async () => {
559+
textDownloader(submissionUrl, `${examSubmission.name}-${examSubmission.hash}-submission-link.txt`)
560+
}}
561+
>
562+
Download submission
552563
</Button>
553564
<Card padding="1rem 2rem" background="tertiary">
554565
<Header type="h2">{examSubmission.name} ({examSubmission.hash})</Header>

0 commit comments

Comments
 (0)