@allons-y/course-kit 0.0.0-stage → 0.2.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/LICENSE +373 -0
- package/README.md +90 -2
- package/assets/fonts/instrument-sans-italic-var.woff2 +0 -0
- package/assets/fonts/instrument-sans-var.woff2 +0 -0
- package/assets/fonts/pt-mono.woff2 +0 -0
- package/assets/scripts/copy.js +99 -0
- package/assets/scripts/deck.js +161 -0
- package/assets/scripts/email.js +19 -0
- package/assets/scripts/practice.js +545 -0
- package/assets/scripts/theme-panel.js +647 -0
- package/assets/scripts/theme-restore.js +17 -0
- package/assets/styles/base.css +2091 -0
- package/assets/styles/deck.css +968 -0
- package/assets/styles/font.css +36 -0
- package/assets/styles/notes.css +137 -0
- package/assets/styles/print.css +428 -0
- package/assets/styles/semantics.css +101 -0
- package/components/practice/check-controls.webc +50 -0
- package/components/practice/choice-list.webc +86 -0
- package/components/practice/cite-panel.webc +108 -0
- package/components/practice/practice-figure.webc +47 -0
- package/components/practice/practice-fill.webc +154 -0
- package/components/practice/practice-grid.webc +82 -0
- package/components/practice/practice-judge.webc +165 -0
- package/components/practice/practice-match.webc +178 -0
- package/components/practice/practice-question.webc +141 -0
- package/components/practice/practice-selfcheck.webc +40 -0
- package/components/practice/practice-terms.webc +95 -0
- package/components/practice/practice-tree.webc +91 -0
- package/components/practice/practice-worksheet.webc +369 -0
- package/components/site/copyright.webc +13 -0
- package/components/site/course-documents.webc +27 -0
- package/components/site/course-now.webc +393 -0
- package/components/site/course-summary.webc +136 -0
- package/components/site/demo-weeks.webc +91 -0
- package/components/site/glossary-entry.webc +31 -0
- package/components/site/glossary-panel.webc +1482 -0
- package/components/site/glossary.webc +45 -0
- package/components/site/grading.webc +50 -0
- package/components/site/instructor.webc +432 -0
- package/components/site/masthead.webc +147 -0
- package/components/site/nav-links.webc +174 -0
- package/components/site/policies.webc +17 -0
- package/components/site/practice-index.webc +31 -0
- package/components/site/schedule-overview.webc +145 -0
- package/components/site/schedule-weeks.webc +589 -0
- package/components/site/site-footer.webc +119 -0
- package/components/site/slide-timetable.webc +152 -0
- package/components/site/syllabus.webc +370 -0
- package/components/ui/arrow-link.webc +19 -0
- package/components/ui/assigned-list.webc +101 -0
- package/components/ui/callout.webc +11 -0
- package/components/ui/card-list.webc +124 -0
- package/components/ui/codepen-embed.webc +123 -0
- package/components/ui/download-button.webc +49 -0
- package/components/ui/eyebrow.webc +18 -0
- package/components/ui/icons/github.webc +6 -0
- package/components/ui/icons/google.webc +9 -0
- package/components/ui/link-list.webc +130 -0
- package/components/ui/link-section.webc +40 -0
- package/components/ui/meeting-card.webc +73 -0
- package/components/ui/meeting-decks.webc +38 -0
- package/components/ui/table-rubric.webc +251 -0
- package/components/ui/today-link.webc +43 -0
- package/components/ui/today-marker.webc +149 -0
- package/components/ui/week-block.webc +53 -0
- package/examples/starter/_data/course.json +20 -0
- package/examples/starter/_data/dates.json +16 -0
- package/examples/starter/_data/grading.json +6 -0
- package/examples/starter/_data/instructor.json +7 -0
- package/examples/starter/_data/policies.json +9 -0
- package/examples/starter/_data/scale.json +8 -0
- package/examples/starter/_data/schedule.json +22 -0
- package/examples/starter/_data/theme.json +17 -0
- package/examples/starter/content/index.webc +12 -0
- package/examples/starter/content/schedule.webc +12 -0
- package/examples/starter/content/slides/index.11tydata.js +5 -0
- package/examples/starter/content/slides/index.webc +12 -0
- package/examples/starter/content/slides/week-1-day-1.md +40 -0
- package/examples/starter/eleventy.config.js +8 -0
- package/glue/deck-notes.data.js +41 -0
- package/glue/deck-notes.webc +32 -0
- package/glue/lesson-day.data.js +17 -0
- package/glue/lesson-day.webc +0 -0
- package/glue/lesson-plans.data.js +13 -0
- package/glue/lesson-plans.webc +2 -0
- package/index.js +6 -0
- package/layouts/base.webc +79 -0
- package/layouts/deck.webc +46 -0
- package/layouts/demo.webc +16 -0
- package/layouts/document.webc +10 -0
- package/layouts/lesson-detail.webc +109 -0
- package/layouts/lesson.webc +71 -0
- package/layouts/notes.webc +23 -0
- package/layouts/worksheet.webc +52 -0
- package/lib/assets.js +42 -0
- package/lib/bundles.js +79 -0
- package/lib/check.js +110 -0
- package/lib/components.js +19 -0
- package/lib/copy.js +656 -0
- package/lib/data/build.js +22 -0
- package/lib/data/fonts.js +16 -0
- package/lib/data/glossary.js +304 -0
- package/lib/data/index.js +8 -0
- package/lib/data/lessons.js +173 -0
- package/lib/data/project.js +22 -0
- package/lib/data/read.js +61 -0
- package/lib/data/site.js +70 -0
- package/lib/data/term.js +80 -0
- package/lib/extensions.js +70 -0
- package/lib/files.js +14 -0
- package/lib/filters.js +584 -0
- package/lib/fit.js +106 -0
- package/lib/glue.js +26 -0
- package/lib/lesson-materials.js +66 -0
- package/lib/markdown.js +568 -0
- package/lib/minify.js +53 -0
- package/lib/paths.js +5 -0
- package/lib/pdf.js +134 -0
- package/lib/plugin.js +231 -0
- package/lib/plugins.js +34 -0
- package/lib/postcss.js +93 -0
- package/lib/theme-server.js +88 -0
- package/lib/theme.js +185 -0
- package/lib/worksheet-dialect.js +415 -0
- package/lib/worksheets.js +276 -0
- package/package.json +119 -4
- package/schemas/course.schema.json +161 -0
- package/schemas/dates.schema.json +165 -0
- package/schemas/grading.schema.json +59 -0
- package/schemas/instructor.schema.json +76 -0
- package/schemas/policies.schema.json +90 -0
- package/schemas/project.schema.json +209 -0
- package/schemas/scale.schema.json +68 -0
- package/schemas/schedule.schema.json +260 -0
- package/schemas/theme.schema.json +704 -0
- package/schemas/worksheet.schema.json +449 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script webc:setup>
|
|
2
|
+
/**
|
|
3
|
+
* The Check and Reset buttons and the score line for one worksheet scope. `practice.js` wires them and fills the tally.
|
|
4
|
+
* @prop {string} scope ties the buttons and tally to a question or section
|
|
5
|
+
* @prop {string} label the check button's text
|
|
6
|
+
* @prop {string} reset the reset button's text
|
|
7
|
+
* @prop {string} confirm the question Reset asks before it clears anything
|
|
8
|
+
*/
|
|
9
|
+
</script>
|
|
10
|
+
<template webc:nokeep>
|
|
11
|
+
<button type="button" :data-check="scope" @text="label"></button>
|
|
12
|
+
<button type="button" :data-reset="scope" :data-confirm="confirm" @text="reset"></button>
|
|
13
|
+
<p :data-tally="scope" role="status"></p>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style webc:scoped>
|
|
17
|
+
:host {
|
|
18
|
+
align-items: center;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
gap: 0.8em;
|
|
22
|
+
margin-block: var(--content-space);
|
|
23
|
+
|
|
24
|
+
p {
|
|
25
|
+
color: var(--color-text-muted);
|
|
26
|
+
margin-block: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
button {
|
|
30
|
+
min-block-size: var(--target-min);
|
|
31
|
+
padding-inline: 1.2em;
|
|
32
|
+
margin: 0;
|
|
33
|
+
border-radius: var(--radius-pill);
|
|
34
|
+
font-weight: var(--font-weight--semi-bold);
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-check] {
|
|
39
|
+
border: var(--border-width) solid var(--color-accent);
|
|
40
|
+
background-color: var(--color-accent);
|
|
41
|
+
color: var(--color-on-accent);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[data-reset] {
|
|
45
|
+
border: var(--border-width) solid var(--color-border-strong);
|
|
46
|
+
background-color: transparent;
|
|
47
|
+
color: var(--color-text);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script webc:setup>
|
|
2
|
+
/**
|
|
3
|
+
* A radio group of lettered choices.
|
|
4
|
+
* @prop {{ name: string, value: string, text: string, letter?: string }[]} choices the options, one radio button each
|
|
5
|
+
* @prop {string} [legend] the group's legend
|
|
6
|
+
* @prop {string} [legendclass] class for the legend, such as `sr-only`
|
|
7
|
+
*/
|
|
8
|
+
</script>
|
|
9
|
+
<fieldset>
|
|
10
|
+
<legend webc:if="legend && legendclass" :class="legendclass" @text="legend"></legend>
|
|
11
|
+
<legend webc:if="legend && !legendclass" @text="legend"></legend>
|
|
12
|
+
<label class="choice" webc:for="choice of choices">
|
|
13
|
+
<input type="radio" :name="choice.name" :value="choice.value">
|
|
14
|
+
<span class="letter" webc:if="choice.letter" @text="choice.letter"></span>
|
|
15
|
+
<span @text="choice.text"></span>
|
|
16
|
+
</label>
|
|
17
|
+
</fieldset>
|
|
18
|
+
|
|
19
|
+
<style webc:scoped>
|
|
20
|
+
:host {
|
|
21
|
+
fieldset {
|
|
22
|
+
border: 0;
|
|
23
|
+
margin: 0;
|
|
24
|
+
padding: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
legend {
|
|
28
|
+
font-weight: var(--font-weight--semi-bold);
|
|
29
|
+
padding-inline: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.letter {
|
|
33
|
+
background: var(--color-surface);
|
|
34
|
+
border-radius: var(--standard-border-radius);
|
|
35
|
+
display: inline-block;
|
|
36
|
+
font-family: var(--mono-font);
|
|
37
|
+
font-weight: var(--font-weight--semi-bold);
|
|
38
|
+
min-inline-size: 1.7em;
|
|
39
|
+
padding: 0.05em 0.35em;
|
|
40
|
+
text-align: center;
|
|
41
|
+
text-transform: uppercase;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
label {
|
|
45
|
+
align-items: baseline;
|
|
46
|
+
border-radius: var(--standard-border-radius);
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
display: flex;
|
|
49
|
+
gap: 0.5em;
|
|
50
|
+
padding: 0.25em 0.4em;
|
|
51
|
+
|
|
52
|
+
&:hover {
|
|
53
|
+
background: var(--color-accent-hover);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&[data-mark="right"] .letter {
|
|
57
|
+
background: var(--color-success);
|
|
58
|
+
color: var(--color-on-success);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&[data-mark="wrong"] .letter {
|
|
62
|
+
background: var(--color-error);
|
|
63
|
+
color: var(--color-on-error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
</style>
|
|
68
|
+
|
|
69
|
+
<script>
|
|
70
|
+
(() => {
|
|
71
|
+
const registry = (window.ckPractice ??= { kinds: {} });
|
|
72
|
+
registry.kinds.choice = {
|
|
73
|
+
/** Mark this kind's controls and report what was found. */
|
|
74
|
+
grade(question, key, id, { mark, checkedValue }) {
|
|
75
|
+
const picked = checkedValue(question, `${id}-choice`);
|
|
76
|
+
if (picked === null) return { answered: false, right: 0, total: 1, blank: 1 };
|
|
77
|
+
for (const label of question.querySelectorAll(".choice")) {
|
|
78
|
+
const value = Number(label.querySelector("input").value);
|
|
79
|
+
if (value === key.answer) mark(label, true);
|
|
80
|
+
else if (value === Number(picked)) mark(label, false);
|
|
81
|
+
}
|
|
82
|
+
return { answered: true, right: Number(picked) === key.answer ? 1 : 0, total: 1, blank: 0 };
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
})();
|
|
86
|
+
</script>
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<script webc:setup>
|
|
2
|
+
/**
|
|
3
|
+
* A "?" disclosure listing the sources for a question.
|
|
4
|
+
* @prop {{ title: string, href?: string }[]} sources the places to read more, shown as links
|
|
5
|
+
* @prop {string} group disclosures sharing a group close each other
|
|
6
|
+
* @prop {string} label the summary's accessible name
|
|
7
|
+
* @prop {string} [heading] a line above the list
|
|
8
|
+
* @prop {string} [marker] the summary glyph, default `?`
|
|
9
|
+
*/
|
|
10
|
+
</script>
|
|
11
|
+
<details class="cite" :name="group">
|
|
12
|
+
<summary :aria-label="label">
|
|
13
|
+
<span aria-hidden="true" webc:if="marker" @text="marker"></span>
|
|
14
|
+
<span aria-hidden="true" webc:if="!marker">?</span>
|
|
15
|
+
</summary>
|
|
16
|
+
<div class="cite-body">
|
|
17
|
+
<p webc:if="heading" @text="heading"></p>
|
|
18
|
+
<ul>
|
|
19
|
+
<li webc:for="source of sources">
|
|
20
|
+
<a :href="source.href" @text="source.label"></a>
|
|
21
|
+
<q webc:if="source.quote" @text="source.quote"></q>
|
|
22
|
+
</li>
|
|
23
|
+
</ul>
|
|
24
|
+
</div>
|
|
25
|
+
</details>
|
|
26
|
+
|
|
27
|
+
<style webc:scoped>
|
|
28
|
+
:host {
|
|
29
|
+
flex: none;
|
|
30
|
+
|
|
31
|
+
details {
|
|
32
|
+
background: none;
|
|
33
|
+
border: 0;
|
|
34
|
+
margin-block: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
position: relative;
|
|
37
|
+
|
|
38
|
+
&[open] summary {
|
|
39
|
+
background: var(--color-accent);
|
|
40
|
+
color: var(--color-on-accent);
|
|
41
|
+
--color-focus-ring: var(--color-on-accent);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
summary {
|
|
46
|
+
background: var(--color-surface);
|
|
47
|
+
block-size: var(--target-min);
|
|
48
|
+
border: var(--thin-border-width) solid var(--color-border-strong);
|
|
49
|
+
border-radius: var(--circle-border-radius);
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
font-weight: var(--font-weight--bold);
|
|
52
|
+
display: grid;
|
|
53
|
+
inline-size: var(--target-min);
|
|
54
|
+
place-items: center;
|
|
55
|
+
line-height: 1;
|
|
56
|
+
list-style: none;
|
|
57
|
+
padding: 0;
|
|
58
|
+
text-align: center;
|
|
59
|
+
|
|
60
|
+
&::-webkit-details-marker {
|
|
61
|
+
display: none;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.cite-body {
|
|
66
|
+
background: var(--color-surface-overlay);
|
|
67
|
+
border: var(--thin-border-width) solid var(--color-border);
|
|
68
|
+
border-radius: var(--standard-border-radius);
|
|
69
|
+
box-shadow: var(--box-shadow);
|
|
70
|
+
font-size: 0.9em;
|
|
71
|
+
inline-size: min(34rem, 80vw);
|
|
72
|
+
inset-block-start: calc(var(--target-min) + 0.25em);
|
|
73
|
+
inset-inline-end: 0;
|
|
74
|
+
padding: 0.8em 1em;
|
|
75
|
+
position: absolute;
|
|
76
|
+
z-index: 10;
|
|
77
|
+
|
|
78
|
+
p {
|
|
79
|
+
font-weight: var(--font-weight--semi-bold);
|
|
80
|
+
margin-block: 0 0.4em;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
ul {
|
|
84
|
+
list-style: none;
|
|
85
|
+
margin-block: 0;
|
|
86
|
+
padding-inline-start: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
li + li {
|
|
90
|
+
margin-block-start: 0.6em;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
q {
|
|
94
|
+
color: var(--color-text-muted);
|
|
95
|
+
display: block;
|
|
96
|
+
font-style: italic;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@media print {
|
|
101
|
+
.cite-body {
|
|
102
|
+
box-shadow: none;
|
|
103
|
+
inline-size: auto;
|
|
104
|
+
position: static;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
</style>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script webc:setup>
|
|
2
|
+
/**
|
|
3
|
+
* A question's inline SVG diagram, written out as authored. Its class vocabulary is styled by the worksheet stylesheet.
|
|
4
|
+
* @prop {object} q a prepared question with a `figure`
|
|
5
|
+
*/
|
|
6
|
+
</script>
|
|
7
|
+
<template webc:nokeep @raw="q.figure"></template>
|
|
8
|
+
|
|
9
|
+
<style webc:scoped>
|
|
10
|
+
/* The class vocabulary an authored ```svg figure draws with, so a diagram
|
|
11
|
+
follows the theme instead of carrying its own hex values. */
|
|
12
|
+
:host {
|
|
13
|
+
svg {
|
|
14
|
+
block-size: auto;
|
|
15
|
+
display: block;
|
|
16
|
+
inline-size: 100%;
|
|
17
|
+
margin-block: var(--content-space);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.region {
|
|
21
|
+
fill: none;
|
|
22
|
+
stroke: var(--color-accent);
|
|
23
|
+
stroke-width: 2.5;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.dashed {
|
|
27
|
+
stroke: var(--color-text-muted);
|
|
28
|
+
stroke-dasharray: 6 5;
|
|
29
|
+
stroke-width: 2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.label {
|
|
33
|
+
fill: var(--color-text-muted);
|
|
34
|
+
font-size: 15px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.small {
|
|
38
|
+
font-size: 13px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.pin {
|
|
42
|
+
fill: var(--color-accent-text);
|
|
43
|
+
font-size: 19px;
|
|
44
|
+
font-weight: var(--font-weight--bold);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<script webc:setup>
|
|
2
|
+
/**
|
|
3
|
+
* A fill-in question: a word bank and a numbered list of blanks.
|
|
4
|
+
* @prop {object} q a prepared `fill` question
|
|
5
|
+
*/
|
|
6
|
+
</script>
|
|
7
|
+
<div class="filling">
|
|
8
|
+
<p class="drag-hint" webc:if="q.dragHint" @text="q.dragHint"></p>
|
|
9
|
+
<p class="word-bank" webc:if="q.bank">
|
|
10
|
+
<span class="word-bank-label" @text="$data.worksheet.copy.wordBank"></span>
|
|
11
|
+
<span class="word" webc:for="word of q.bank"
|
|
12
|
+
:draggable="word.draggable" :data-word="word.text" @text="word.text"></span>
|
|
13
|
+
</p>
|
|
14
|
+
<ol class="blanks">
|
|
15
|
+
<li webc:for="blank of q.blanks" :data-drop="blank.drop">
|
|
16
|
+
<label>
|
|
17
|
+
<span class="blank-label" @text="blank.label"></span>
|
|
18
|
+
<input type="text" autocomplete="off" spellcheck="false"
|
|
19
|
+
:name="blank.name" :data-blank="blank.index" :placeholder="blank.hint">
|
|
20
|
+
</label>
|
|
21
|
+
<span class="answer-key" hidden :data-answer="blank.display"
|
|
22
|
+
@text="`${$data.worksheet.copy.answer} ${blank.display}`"></span>
|
|
23
|
+
</li>
|
|
24
|
+
</ol>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<style webc:scoped>
|
|
28
|
+
:host {
|
|
29
|
+
.drag-hint {
|
|
30
|
+
color: var(--color-text-muted);
|
|
31
|
+
font-size: 0.9em;
|
|
32
|
+
margin-block: 0 0.6em;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.answer-key {
|
|
36
|
+
color: var(--color-error);
|
|
37
|
+
font-size: 0.85em;
|
|
38
|
+
|
|
39
|
+
&:not([hidden]) {
|
|
40
|
+
display: block;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.word-bank {
|
|
45
|
+
align-items: baseline;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-wrap: wrap;
|
|
48
|
+
gap: 0.4em;
|
|
49
|
+
|
|
50
|
+
.word-bank-label {
|
|
51
|
+
color: var(--color-text-muted);
|
|
52
|
+
font-size: 0.85em;
|
|
53
|
+
letter-spacing: 0.06em;
|
|
54
|
+
text-transform: uppercase;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.word {
|
|
58
|
+
background: var(--color-surface);
|
|
59
|
+
border-radius: var(--standard-border-radius);
|
|
60
|
+
font-family: var(--mono-font);
|
|
61
|
+
padding: 0.1em 0.5em;
|
|
62
|
+
|
|
63
|
+
&[draggable="true"] {
|
|
64
|
+
border: var(--thin-border-width) dashed var(--color-border);
|
|
65
|
+
cursor: grab;
|
|
66
|
+
|
|
67
|
+
&:active {
|
|
68
|
+
cursor: grabbing;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&[data-dragging] {
|
|
73
|
+
opacity: 0.45;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&[data-used] {
|
|
77
|
+
opacity: 0.5;
|
|
78
|
+
text-decoration: line-through;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.blanks {
|
|
84
|
+
list-style: none;
|
|
85
|
+
padding-inline-start: 0;
|
|
86
|
+
|
|
87
|
+
label {
|
|
88
|
+
align-items: center;
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-wrap: wrap;
|
|
91
|
+
gap: 0.6em;
|
|
92
|
+
margin-block: 0.4em;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.blank-label {
|
|
96
|
+
flex: 0 1 24em;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
input {
|
|
100
|
+
flex: 0 1 14em;
|
|
101
|
+
font-family: var(--mono-font);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
li {
|
|
105
|
+
&[data-drop] {
|
|
106
|
+
border: var(--thin-border-width) dashed transparent;
|
|
107
|
+
border-radius: var(--standard-border-radius);
|
|
108
|
+
|
|
109
|
+
&[data-over] {
|
|
110
|
+
background: var(--color-drop-target);
|
|
111
|
+
border-color: var(--color-accent);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&[data-mark="wrong"] .blank-label {
|
|
116
|
+
color: var(--color-error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</style>
|
|
122
|
+
|
|
123
|
+
<script>
|
|
124
|
+
(() => {
|
|
125
|
+
const registry = (window.ckPractice ??= { kinds: {} });
|
|
126
|
+
registry.kinds.fill = {
|
|
127
|
+
/** Mark this kind's controls and report what was found. */
|
|
128
|
+
grade(question, key, _id, { mark, normalize }) {
|
|
129
|
+
let right = 0;
|
|
130
|
+
let blank = 0;
|
|
131
|
+
let answered = false;
|
|
132
|
+
for (const [index, accepted] of key.blanks.entries()) {
|
|
133
|
+
const input = question.querySelector(`input[data-blank="${index}"]`);
|
|
134
|
+
if (!input.value.trim()) {
|
|
135
|
+
blank += 1;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
answered = true;
|
|
139
|
+
const typed = normalize(input.value);
|
|
140
|
+
const correct = accepted.some((option) => normalize(option) === typed);
|
|
141
|
+
if (correct) right += 1;
|
|
142
|
+
mark(input.closest("li"), correct);
|
|
143
|
+
}
|
|
144
|
+
return { answered, right, total: key.blanks.length, blank };
|
|
145
|
+
},
|
|
146
|
+
/** Drag a bank entry onto a row, and keep the word bank honest as the student types. */
|
|
147
|
+
enhance(question, { dragDrop, markUsedWords }) {
|
|
148
|
+
dragDrop(question);
|
|
149
|
+
question.addEventListener("input", () => markUsedWords(question));
|
|
150
|
+
markUsedWords(question);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
})();
|
|
154
|
+
</script>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script webc:setup>
|
|
2
|
+
/**
|
|
3
|
+
* A grid question: rows of choices across columns.
|
|
4
|
+
* @prop {object} q a prepared `grid` question
|
|
5
|
+
*/
|
|
6
|
+
</script>
|
|
7
|
+
<table class="grid">
|
|
8
|
+
<thead>
|
|
9
|
+
<tr>
|
|
10
|
+
<th scope="col" @text="q.rowHeader"></th>
|
|
11
|
+
<th scope="col" webc:for="column of q.columns" @text="column"></th>
|
|
12
|
+
</tr>
|
|
13
|
+
</thead>
|
|
14
|
+
<tbody>
|
|
15
|
+
<tr webc:for="row of q.rows" :data-row="row.index">
|
|
16
|
+
<th scope="row">
|
|
17
|
+
<span @text="row.text"></span>
|
|
18
|
+
<span class="answer-key" hidden :data-answer="row.display"
|
|
19
|
+
@text="`${$data.worksheet.copy.answer} ${row.display}`"></span>
|
|
20
|
+
</th>
|
|
21
|
+
<td webc:for="cell of row.cells">
|
|
22
|
+
<label>
|
|
23
|
+
<span class="sr-only" @text="cell.column"></span>
|
|
24
|
+
<input type="radio" :name="cell.name" :value="cell.value">
|
|
25
|
+
</label>
|
|
26
|
+
</td>
|
|
27
|
+
</tr>
|
|
28
|
+
</tbody>
|
|
29
|
+
</table>
|
|
30
|
+
|
|
31
|
+
<style webc:scoped>
|
|
32
|
+
/* A grid wider than the column scrolls inside its own box, not the page. */
|
|
33
|
+
:host {
|
|
34
|
+
display: block;
|
|
35
|
+
max-inline-size: 100%;
|
|
36
|
+
overflow-x: auto;
|
|
37
|
+
|
|
38
|
+
.answer-key {
|
|
39
|
+
color: var(--color-error);
|
|
40
|
+
font-size: 0.85em;
|
|
41
|
+
|
|
42
|
+
&:not([hidden]) {
|
|
43
|
+
display: block;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
th[scope="row"] {
|
|
48
|
+
font-weight: var(--font-weight);
|
|
49
|
+
text-align: start;
|
|
50
|
+
|
|
51
|
+
tr[data-mark="wrong"] & {
|
|
52
|
+
color: var(--color-error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
57
|
+
|
|
58
|
+
<script>
|
|
59
|
+
(() => {
|
|
60
|
+
const registry = (window.ckPractice ??= { kinds: {} });
|
|
61
|
+
registry.kinds.grid = {
|
|
62
|
+
/** Mark this kind's controls and report what was found. */
|
|
63
|
+
grade(question, key, id, { mark, checkedValue }) {
|
|
64
|
+
let right = 0;
|
|
65
|
+
let blank = 0;
|
|
66
|
+
let answered = false;
|
|
67
|
+
for (const [index, expected] of key.rows.entries()) {
|
|
68
|
+
const picked = checkedValue(question, `${id}-row-${index}`);
|
|
69
|
+
if (picked === null) {
|
|
70
|
+
blank += 1;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
answered = true;
|
|
74
|
+
const correct = Number(picked) === expected;
|
|
75
|
+
if (correct) right += 1;
|
|
76
|
+
mark(question.querySelector(`tr[data-row="${index}"]`), correct);
|
|
77
|
+
}
|
|
78
|
+
return { answered, right, total: key.rows.length, blank };
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
})();
|
|
82
|
+
</script>
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<script webc:setup>
|
|
2
|
+
/**
|
|
3
|
+
* A judge question: a verdict, then the one line of code that causes the problem.
|
|
4
|
+
* @prop {object} q a prepared `judge` question
|
|
5
|
+
*/
|
|
6
|
+
</script>
|
|
7
|
+
<div class="judging">
|
|
8
|
+
<div class="verdicts">
|
|
9
|
+
<choice-list :@choices="q.verdicts" :@legend="$data.worksheet.copy.verdict"></choice-list>
|
|
10
|
+
</div>
|
|
11
|
+
<fieldset class="code-lines">
|
|
12
|
+
<legend @text="$data.worksheet.copy.judgeLine"></legend>
|
|
13
|
+
<pre class="lines"><code><label class="code-line" webc:for="codeLine of q.codeLines"><input type="radio" :name="codeLine.name" :value="codeLine.value"><span class="line-code" @raw="codeLine.html"></span></label></code></pre>
|
|
14
|
+
<label class="code-line no-line">
|
|
15
|
+
<input type="radio" :name="q.lineName" value="none">
|
|
16
|
+
<span @text="$data.worksheet.copy.judgeNoLine"></span>
|
|
17
|
+
</label>
|
|
18
|
+
</fieldset>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<style webc:scoped>
|
|
22
|
+
:host {
|
|
23
|
+
legend {
|
|
24
|
+
color: var(--color-text-muted);
|
|
25
|
+
font-size: 0.85em;
|
|
26
|
+
letter-spacing: 0.06em;
|
|
27
|
+
padding-inline: 0;
|
|
28
|
+
text-transform: uppercase;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.code-lines {
|
|
32
|
+
border: 0;
|
|
33
|
+
margin: 0;
|
|
34
|
+
margin-block-start: var(--content-space);
|
|
35
|
+
/* A fieldset defaults to min-content, which defeats the code's scroll. */
|
|
36
|
+
min-inline-size: 0;
|
|
37
|
+
padding: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* One label per line inside a <pre>, with nothing between the labels:
|
|
41
|
+
the HTML minifier leaves <pre> alone, which is what keeps the
|
|
42
|
+
snippet's indentation. */
|
|
43
|
+
.lines {
|
|
44
|
+
--token-string: color-mix(in oklab, var(--color-success) 60%, var(--color-text));
|
|
45
|
+
background: var(--color-surface);
|
|
46
|
+
border-radius: var(--standard-border-radius);
|
|
47
|
+
font-size: 0.9em;
|
|
48
|
+
margin: 0;
|
|
49
|
+
overflow-x: auto;
|
|
50
|
+
padding: 0.35em 0;
|
|
51
|
+
|
|
52
|
+
/* A grid drops the whitespace-only text WebC leaves between the
|
|
53
|
+
looped labels, which a <pre> would otherwise show as blank lines. */
|
|
54
|
+
code {
|
|
55
|
+
background: none;
|
|
56
|
+
display: grid;
|
|
57
|
+
inline-size: max-content;
|
|
58
|
+
min-inline-size: 100%;
|
|
59
|
+
padding: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.token:is(.comment, .prolog, .doctype, .cdata) {
|
|
63
|
+
color: var(--color-text-muted);
|
|
64
|
+
font-style: italic;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.token:is(.keyword, .builtin, .important, .atrule) {
|
|
68
|
+
color: var(--color-accent-text);
|
|
69
|
+
font-weight: var(--font-weight--semi-bold);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.token:is(.string, .char, .regex, .number, .boolean) {
|
|
73
|
+
color: var(--token-string);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.token:is(.punctuation, .operator) {
|
|
77
|
+
color: var(--color-text-muted);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.code-line {
|
|
82
|
+
align-items: center;
|
|
83
|
+
border-inline-start: var(--thick-border-width) solid transparent;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
display: flex;
|
|
86
|
+
gap: 0.6em;
|
|
87
|
+
padding: 0.1em 0.6em;
|
|
88
|
+
|
|
89
|
+
input {
|
|
90
|
+
flex: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* A blank line still gets a row the height of its neighbors. */
|
|
94
|
+
.line-code {
|
|
95
|
+
min-block-size: 1lh;
|
|
96
|
+
white-space: pre;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&:hover {
|
|
100
|
+
background: var(--color-accent-hover);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* The chosen line lights up in the code itself. */
|
|
104
|
+
&:has(input:checked) {
|
|
105
|
+
background: color-mix(in srgb, var(--color-accent-text) 16%, transparent);
|
|
106
|
+
border-inline-start-color: var(--color-accent-text);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
&:has(input:focus-visible) {
|
|
110
|
+
outline: var(--focus-ring-width) solid var(--color-focus-ring);
|
|
111
|
+
outline-offset: calc(var(--focus-ring-width) * -1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&.no-line {
|
|
115
|
+
font-size: 0.9em;
|
|
116
|
+
margin-block-start: 0.3em;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&[data-mark="right"],
|
|
120
|
+
&[data-mark="right"]:has(input:checked) {
|
|
121
|
+
background: color-mix(in srgb, var(--color-success) 22%, var(--color-page));
|
|
122
|
+
border-inline-start-color: var(--color-success);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&[data-mark="wrong"],
|
|
126
|
+
&[data-mark="wrong"]:has(input:checked) {
|
|
127
|
+
background: color-mix(in srgb, var(--color-error) 22%, var(--color-page));
|
|
128
|
+
border-inline-start-color: var(--color-error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
</style>
|
|
133
|
+
|
|
134
|
+
<script>
|
|
135
|
+
(() => {
|
|
136
|
+
const registry = (window.ckPractice ??= { kinds: {} });
|
|
137
|
+
registry.kinds.judge = {
|
|
138
|
+
/** Mark this kind's controls and report what was found. */
|
|
139
|
+
grade(question, key, id, { mark, checkedValue }) {
|
|
140
|
+
const verdict = checkedValue(question, `${id}-choice`);
|
|
141
|
+
const line = checkedValue(question, `${id}-line`);
|
|
142
|
+
if (verdict === null && line === null) return { answered: false, right: 0, total: 2, blank: 2 };
|
|
143
|
+
let right = 0;
|
|
144
|
+
|
|
145
|
+
for (const label of question.querySelectorAll(".verdicts .choice")) {
|
|
146
|
+
const value = Number(label.querySelector("input").value);
|
|
147
|
+
if (value === key.answer) mark(label, true);
|
|
148
|
+
else if (value === Number(verdict)) mark(label, false);
|
|
149
|
+
}
|
|
150
|
+
if (Number(verdict) === key.answer) right += 1;
|
|
151
|
+
|
|
152
|
+
// A snippet with no offending line makes "none" the right pick.
|
|
153
|
+
const expected = key.lines.length ? key.lines.map(String) : ["none"];
|
|
154
|
+
for (const label of question.querySelectorAll(".code-lines .code-line")) {
|
|
155
|
+
const value = label.querySelector("input").value;
|
|
156
|
+
if (expected.includes(value)) mark(label, true);
|
|
157
|
+
else if (value === line) mark(label, false);
|
|
158
|
+
}
|
|
159
|
+
if (line !== null && expected.includes(line)) right += 1;
|
|
160
|
+
|
|
161
|
+
return { answered: true, right, total: 2, blank: (verdict === null ? 1 : 0) + (line === null ? 1 : 0) };
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
})();
|
|
165
|
+
</script>
|