question-bank-framework 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -2
- package/bin/qb.js +119 -0
- package/bin/qb.ts +128 -0
- package/core/config.tsx +52 -0
- package/core/index.ts +35 -0
- package/core/types.ts +256 -0
- package/framework/components/app-shell.tsx +54 -0
- package/framework/components/filter-builder.tsx +471 -0
- package/framework/components/markdown-content.tsx +109 -0
- package/framework/components/question-bank.tsx +690 -0
- package/framework/components/quiz-list.tsx +118 -0
- package/framework/components/quiz-page.tsx +454 -0
- package/framework/components/ui/badge.tsx +47 -0
- package/framework/components/ui/button.tsx +63 -0
- package/framework/components/ui/checkbox.tsx +29 -0
- package/framework/components/ui/dropdown-menu.tsx +256 -0
- package/framework/components/ui/input.tsx +20 -0
- package/framework/components/ui/popover.tsx +88 -0
- package/framework/components/ui/select.tsx +187 -0
- package/framework/components/ui/sheet.tsx +140 -0
- package/framework/components/ui/table.tsx +121 -0
- package/framework/convex/questionStatuses.ts +30 -0
- package/framework/convex/quizzes.ts +50 -0
- package/framework/convex/schema.ts +18 -0
- package/framework/index.ts +26 -0
- package/framework/lib/convex-api.ts +36 -0
- package/framework/lib/question-filter-store.ts +116 -0
- package/framework/lib/question-filter.ts +376 -0
- package/framework/lib/question-status-storage.ts +117 -0
- package/framework/lib/quiz-storage.ts +118 -0
- package/framework/lib/utils.ts +6 -0
- package/package.json +66 -4
- package/template/bank.config.ts +72 -0
- package/template/content/answers.ts +8 -0
- package/template/content/questions.json +76 -0
- package/template/src/routes/__root.tsx +44 -0
- package/template/src/routes/index.tsx +4 -0
- package/template/src/routes/quiz.$quizId.tsx +4 -0
- package/template/src/routes/quizzes.tsx +4 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Example bank config. Copy to `bank.config.ts` in your app and edit.
|
|
2
|
+
// This mirrors the COMP20008 bank: the schema (year/semester/marks/exam) is
|
|
3
|
+
// config-defined — the framework never hardcodes subject fields.
|
|
4
|
+
|
|
5
|
+
import { defineBank } from 'question-bank-framework';
|
|
6
|
+
import questionsJson from './content/questions.json' with { type: 'json' };
|
|
7
|
+
import { answers } from './content/answers.ts';
|
|
8
|
+
import type { BaseQuestion } from 'question-bank-framework';
|
|
9
|
+
|
|
10
|
+
const questions = questionsJson as BaseQuestion[];
|
|
11
|
+
|
|
12
|
+
const str = (q: BaseQuestion, key: string): string => {
|
|
13
|
+
const v = q[key];
|
|
14
|
+
return typeof v === 'string' || typeof v === 'number' ? String(v) : '';
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const num = (q: BaseQuestion, key: string): number | null => {
|
|
18
|
+
const v = q[key];
|
|
19
|
+
if (typeof v === 'number' && Number.isFinite(v)) return v;
|
|
20
|
+
if (typeof v === 'string' && v.trim() !== '') {
|
|
21
|
+
const n = Number(v);
|
|
22
|
+
return Number.isFinite(n) ? n : null;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const bank = defineBank({
|
|
28
|
+
site: {
|
|
29
|
+
title: 'fieldnotes — COMP20008 question bank',
|
|
30
|
+
brand: 'fieldnotes',
|
|
31
|
+
description: 'A searchable, section-classified question bank built from COMP20008 past exams.',
|
|
32
|
+
},
|
|
33
|
+
namespace: 'comp20008',
|
|
34
|
+
fields: [
|
|
35
|
+
{
|
|
36
|
+
id: 'year',
|
|
37
|
+
label: 'Year',
|
|
38
|
+
type: 'select',
|
|
39
|
+
getValue: (q) => (typeof q['year'] === 'number' ? String(q['year']) : ''),
|
|
40
|
+
searchable: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'semester',
|
|
44
|
+
label: 'Semester',
|
|
45
|
+
type: 'select',
|
|
46
|
+
getValue: (q) => str(q, 'semester'),
|
|
47
|
+
options: [
|
|
48
|
+
{ value: 'S1', label: 'Semester 1' },
|
|
49
|
+
{ value: 'S2', label: 'Semester 2' },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'exam',
|
|
54
|
+
label: 'Exam',
|
|
55
|
+
type: 'text',
|
|
56
|
+
getValue: (q) => `${str(q, 'year')} ${str(q, 'semester')}`.trim(),
|
|
57
|
+
searchable: true,
|
|
58
|
+
column: { header: 'Exam', width: 108, sortable: false },
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'marks',
|
|
62
|
+
label: 'Marks',
|
|
63
|
+
type: 'number',
|
|
64
|
+
getValue: (q) => num(q, 'marks'),
|
|
65
|
+
placeholder: 'Value',
|
|
66
|
+
column: { header: 'Marks', width: 78 },
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
questions,
|
|
70
|
+
answers,
|
|
71
|
+
defaultSorting: [{ id: 'exam', desc: true }],
|
|
72
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Suggested answers keyed by question id. Missing entries hide "Show answer".
|
|
2
|
+
// Split per-year like `answers/2019.ts` in the COMP20008 bank if you like.
|
|
3
|
+
|
|
4
|
+
export const answers: Record<string, string> = {
|
|
5
|
+
'2019-s1-q01': String.raw`**(a)** Not well-formed: several sibling top-level elements, so no single root.`,
|
|
6
|
+
'2019-s1-mc01': String.raw`Only **B** has a single root element with matching open and close tags. A never closes, C closes in the wrong order, and D is not an element at all.`,
|
|
7
|
+
'2019-s1-mc02': String.raw`Remove or correct physically impossible values (**A**), always investigate before discarding (**C**), and document any imputation (**D**). Deleting everything above the mean (**B**) discards roughly half of legitimate data.`,
|
|
8
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "2019-s1-q01",
|
|
4
|
+
"kind": "written",
|
|
5
|
+
"year": 2019,
|
|
6
|
+
"semester": "S1",
|
|
7
|
+
"number": 1,
|
|
8
|
+
"marks": 2,
|
|
9
|
+
"title": "XML/JSON data representation",
|
|
10
|
+
"prompt": "This question concerns representations of data in XML/JSON.\n\n**(a)** (0.5 mark) Is the XML below well-formed? Explain.\n\n```xml\n<subject>COMP20008</subject>\n```\n",
|
|
11
|
+
"source": "2019-s1.md",
|
|
12
|
+
"tags": ["Data fundamentals", "Data, formats & databases"]
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"id": "2019-s1-q02",
|
|
16
|
+
"kind": "written",
|
|
17
|
+
"year": 2019,
|
|
18
|
+
"semester": "S1",
|
|
19
|
+
"number": 2,
|
|
20
|
+
"marks": 7,
|
|
21
|
+
"title": "Temperature sensor readings, noise and outliers",
|
|
22
|
+
"prompt": "Explain the difference between readings which are noise and readings which are outliers.\n",
|
|
23
|
+
"source": "2019-s1.md",
|
|
24
|
+
"tags": ["Data preparation", "Data quality & preparation"]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "ioa-001",
|
|
28
|
+
"kind": "written",
|
|
29
|
+
"year": 2026,
|
|
30
|
+
"semester": "S2",
|
|
31
|
+
"number": 1,
|
|
32
|
+
"marks": null,
|
|
33
|
+
"title": "Research question and evidence",
|
|
34
|
+
"prompt": "What is your research question, and what result would count as evidence?",
|
|
35
|
+
"source": "assignment-ioa",
|
|
36
|
+
"tags": ["Assignment questions", "Justification"]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "2019-s1-mc01",
|
|
40
|
+
"kind": "single",
|
|
41
|
+
"year": 2019,
|
|
42
|
+
"semester": "S1",
|
|
43
|
+
"number": 3,
|
|
44
|
+
"marks": 1,
|
|
45
|
+
"title": "Well-formed XML",
|
|
46
|
+
"prompt": "Which of the following XML documents is well-formed?",
|
|
47
|
+
"options": [
|
|
48
|
+
{ "id": "a", "text": "`<subject>COMP20008<subject>`" },
|
|
49
|
+
{ "id": "b", "text": "`<subject>COMP20008</subject>`" },
|
|
50
|
+
{ "id": "c", "text": "`<subject><topic>COMP20008</subject></topic>`" },
|
|
51
|
+
{ "id": "d", "text": "`COMP20008`" }
|
|
52
|
+
],
|
|
53
|
+
"correctIds": ["b"],
|
|
54
|
+
"source": "2019-s1.md",
|
|
55
|
+
"tags": ["Data fundamentals", "Data, formats & databases"]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "2019-s1-mc02",
|
|
59
|
+
"kind": "multiple",
|
|
60
|
+
"year": 2019,
|
|
61
|
+
"semester": "S1",
|
|
62
|
+
"number": 4,
|
|
63
|
+
"marks": 2,
|
|
64
|
+
"title": "Outlier handling",
|
|
65
|
+
"prompt": "A temperature sensor reports occasional extreme spikes. Which of the following are reasonable outlier-handling steps? **Select all that apply.**",
|
|
66
|
+
"options": [
|
|
67
|
+
{ "id": "a", "text": "Remove spikes that are physically impossible for the sensor" },
|
|
68
|
+
{ "id": "b", "text": "Delete every reading above the mean" },
|
|
69
|
+
{ "id": "c", "text": "Flag spikes and investigate whether they coincide with known events" },
|
|
70
|
+
{ "id": "d", "text": "Replace spikes with interpolated values and document the change" }
|
|
71
|
+
],
|
|
72
|
+
"correctIds": ["a", "c", "d"],
|
|
73
|
+
"source": "2019-s1.md",
|
|
74
|
+
"tags": ["Data preparation", "Data quality & preparation"]
|
|
75
|
+
}
|
|
76
|
+
]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HeadContent, Outlet, Scripts, createRootRoute } from '@tanstack/react-router';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { BankProvider } from 'question-bank-framework';
|
|
4
|
+
import { AppShell } from 'question-bank-framework/framework';
|
|
5
|
+
import { bank } from '../../bank.config.ts';
|
|
6
|
+
import appCss from './styles.css?url';
|
|
7
|
+
|
|
8
|
+
export const Route = createRootRoute({
|
|
9
|
+
head: () => ({
|
|
10
|
+
meta: [
|
|
11
|
+
{ charSet: 'utf-8' },
|
|
12
|
+
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
|
13
|
+
{ title: bank.site.title },
|
|
14
|
+
{ name: 'description', content: bank.site.description ?? '' },
|
|
15
|
+
],
|
|
16
|
+
links: [{ rel: 'stylesheet', href: appCss }],
|
|
17
|
+
}),
|
|
18
|
+
component: RootComponent,
|
|
19
|
+
shellComponent: RootDocument,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
function RootComponent() {
|
|
23
|
+
return (
|
|
24
|
+
<BankProvider bank={bank}>
|
|
25
|
+
<AppShell brand={bank.site.brand}>
|
|
26
|
+
<Outlet />
|
|
27
|
+
</AppShell>
|
|
28
|
+
</BankProvider>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function RootDocument({ children }: { children: ReactNode }) {
|
|
33
|
+
return (
|
|
34
|
+
<html lang="en">
|
|
35
|
+
<head>
|
|
36
|
+
<HeadContent />
|
|
37
|
+
</head>
|
|
38
|
+
<body className="m-0 min-h-screen bg-[#f5f7f4] font-sans text-[#27392f] antialiased">
|
|
39
|
+
{children}
|
|
40
|
+
<Scripts />
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
|
43
|
+
);
|
|
44
|
+
}
|