Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 3 additions & 29 deletions docs/labs/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,9 @@
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="template.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

<!-- See create_labs.md for how to create your own lab! -->

<!-- Sample expected answer -->
<script id="expected0" type="plain/text">
EXPECTED0
</script>
<!--
-->
<script id="expected1" type="plain/text">
EXPECTED1
</script>

<!-- Full pattern of correct answer -->
<script id="correct0" type="plain/text">
\s* EXPECTED0 \s*
</script>
<script id="correct1" type="plain/text">
\s* EXPECTED1 \s*
</script>

<script id="info" type="application/yaml">
---
hints:
- present: "unknown"
text: Unknown is not part of the answer.
# debug: true
</script>
</head>
<body>
<!-- For GitHub Pages formatting: -->
Expand Down Expand Up @@ -71,10 +45,10 @@ <h2>Interactive Lab (<span id="grade"></span>)</h2>
<p>
<form id="lab">
<pre><code
>// If you use a one-line input:
>// If you use a one-line input (answer "EXPECTED0"):
<input id="attempt0" type="text" size="60" spellcheck="false" value="initial text0">

// If you use a textarea:
// If you use a textarea (answer "EXPECTED1"):
<textarea id="attempt1" rows="10" cols="60" spellcheck="false">
initial text 1;
</textarea>
Expand Down
46 changes: 46 additions & 0 deletions docs/labs/template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
info =
{
hints: [
{
present: "initial",
text: "The term 'initial' is not part of the answer."
},
{
present: "unknown",
text: "Unknown is not part of the answer."
},
{
absent: String.raw`EXPECTED`,
text: "The word 'EXPECTED' is expected."
},
{
present: "initial",
index: 1,
text: "The term 'initial' is not part of the answer."
},
{
absent: String.raw`EXPECTED`,
index: 1,
text: "The word 'EXPECTED' is expected."
},
],
expected: [
"EXPECTED0",
"EXPECTED1"
],
correct: [
String.raw`\s* EXPECTED0 \s*`,
String.raw`\s* EXPECTED1 \s*`
],
successes: [
[ " EXPECTED0 ", " EXPECTED1 " ],
[ " EXPECTED0 ", " EXPECTED1 " ]
],
failures: [
[ "EXPECTED", "EXPECTED1" ],
[ "Unknown", "EXPECTED1" ],
[ "EXPECTED0", "EXPECTED" ],
[ "EXPECTED0", "EXPECTED11" ]
],
// debug: true // to enable debug output
}