@@ -6,11 +6,49 @@ These are the instructions for how to create labs with `checker.js`,
6
6
7
7
The ` checker.js ` system
8
8
represents each lab exercise in an HTML file.
9
- You define a pattern that the correct answer must match
10
- using regular expressions (as well as a example of an expected answer).
9
+ You define text explaining the lab exercise,
10
+ a form allowing the learner to enter their answer,
11
+ pattern(s) that the correct answer(s) must match,
12
+ and an example of an expected answer.
13
+
14
+ Everything runs in the user's browser - no installation is needed.
11
15
This system does * not* run arbitrary code written by the user.
12
16
You can also provide patterns for various hints.
13
17
18
+ There are three basic tasks, which can be done by different people:
19
+
20
+ 1 . Identifying the next lab to do.
21
+ See the [ README] ( ./README.md ) for the list of labs.
22
+ 2 . [ Creating the lab instructions and correct answer] ( #creating-the-lab-instructions-and-correct-answer ) .
23
+ This is done by a subject matter expert. See below.
24
+ 3 . [ Creating the lab HTML file] ( #creating-the-lab-html-file ) .
25
+ Much of the text below focuses on implementing this part.
26
+ You'd typically start with an existing lab, like
27
+ [ input1.html] ( input1.html ) , and modify it for your situation.
28
+ See David A. Wheeler who can help you get started.
29
+
30
+ The text below discusses these in more detail. You can also see our
31
+ [ potential future directions] ( #potential-future-directions ) .
32
+
33
+ ## Creating the lab instructions and correct answer
34
+
35
+ We strongly urge you to first work out the basic lab and what
36
+ a * correct* answer would look like. Others can help you create the pattern
37
+ that describes a correct answer.
38
+
39
+ First consult the [ section's text in the fundamentals course] (more ~ /projects/secure-sw-dev-fundamentals/secure_software_development_fundamentals.md).
40
+ It's probably best to then create some simple program that
41
+ demonstrates it, along with text that explains the task.
42
+
43
+ Remember that we're assuming that learners know how to program, but we
44
+ do * not* assume they know any particular programming language.
45
+ See [ input1.html] ( input1.html ) ,
46
+ [ input2.html] ( input2.html ) , and
47
+ [ csp1.html] ( csp1.html ) for examples of how to do this.
48
+
49
+ ## Creating the lab HTML file
50
+
51
+ Each lab is captured in its own HTML file.
14
52
The HTML file of a given lab is expected to:
15
53
16
54
* Describe the exercise (in HTML text)
@@ -24,11 +62,7 @@ The HTML file of a given lab is expected to:
24
62
25
63
The system is implemented by the client-side JavaScript file ` checker.js ` .
26
64
27
- ## TL;DR
28
-
29
- We strongly urge you to first work out the basic lab and what
30
- a * correct* answer would look like. Others can help you create the pattern
31
- that describes a correct answer.
65
+ ### TL;DR
32
66
33
67
An easy way implement a lab is to copy
34
68
[ input1.html] ( input1.html ) and modify it for your situation.
@@ -49,7 +83,7 @@ We suggest including the buttons (Hint, Reset, and Give up)
49
83
as shown in the examples.
50
84
The code will automatically set up the buttons if they are present.
51
85
52
- ## Quick aside: script tag requirements
86
+ ### Quick aside: script tag requirements
53
87
54
88
Data about the lab is embedded in the HTML in a
55
89
` script ` tag. Embedding this data simplifies lab maintenance,
@@ -69,7 +103,7 @@ Basically, the text embedded in the `script` sections must
69
103
If you * need* to include these text sequences inside the ` script ` region,
70
104
you can typically you can replace ` < ` with ` \x3C ` to resolve it.
71
105
72
- ## Basic lab inputs
106
+ ### Basic lab inputs
73
107
74
108
The basic inputs are:
75
109
@@ -83,12 +117,12 @@ in order (0, 1, 2, ...).
83
117
The number of attempt fields, expected fields, and correct fields
84
118
much match.
85
119
86
- ## Expressing correct answer patterns
120
+ ### Expressing correct answer patterns
87
121
88
122
Correct answer patterns are expressed using a preprocessed form of
89
123
[ JavaScript regular expression (regex) patterns] ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions ) .
90
124
91
- ### Quick introduction to regular expressions (regexes)
125
+ #### Quick introduction to regular expressions (regexes)
92
126
93
127
Regular expressions are a widely-used notation to
94
128
indicate patterns.
@@ -106,7 +140,7 @@ the many different forms that are all correct. E.g.:
106
140
* Pattern ` 9_?999 ` matches ` 9 ` , an optional underscore
107
141
(<tt >_ ; </tt >) because the ` ? ` makes it optional, then ` 999 ` .
108
142
109
- ### How we make regexes readable
143
+ #### How we make regexes readable
110
144
111
145
Regexes are capable and widely used,
112
146
but straightforward regex use for this problem
@@ -176,7 +210,7 @@ defining the lookahead patterns for all required specific answers.
176
210
If you need that kind of order flexibility for longer lists, that is the
177
211
best approach I've found.
178
212
179
- ## Expressing JavaScript code patterns
213
+ ### Expressing JavaScript code patterns
180
214
181
215
If you're defining a pattern to match an answer that is a
182
216
snippet of JavaScript code, here are some tips:
@@ -202,7 +236,7 @@ It's impractical to match all possibilities, e.g., <tt>1</tt> can be
202
236
written as <tt >(5-4)</tt >, but that would be an absurd thing for a
203
237
student to do.
204
238
205
- ## Example pattern
239
+ ### Example pattern
206
240
207
241
Here's an example pattern for matching a correct answer:
208
242
@@ -255,7 +289,7 @@ Here's an explanation of this pattern:
255
289
By ending the last pattern with ` \s* ` we make it clear that
256
290
trailing whitespace is allowed at the end.
257
291
258
- ## Other info
292
+ ### Other info
259
293
260
294
The id ` info ` can provide other optional information.
261
295
If present, it must be a YAML object.
@@ -287,7 +321,7 @@ The `info` object also has other fields:
287
321
some data that may help you debug problems.
288
322
* ` hints ` : If present, this is an array of hints.
289
323
290
- ## Hints
324
+ ### Hints
291
325
292
326
Hints are expressed in the info ` hints ` field.
293
327
This field must be an array
@@ -298,7 +332,7 @@ Each hint object describes a hint, and they are checked in the order given
298
332
If you use JSON format,
299
333
each hint object begins with ` { ` , has a set of fields, and ends with ` } ` .
300
334
301
- ### Format for a hint
335
+ #### Format for a hint
302
336
303
337
Every hint object must have a ` text ` field to be displayed as the hint.
304
338
A hint object can have a ` present ` field (a pattern that must be present
@@ -325,7 +359,7 @@ an array of examples (each example is an array of Strings).
325
359
On load the system will verify that each example will report the
326
360
maatching hint (this helps ensure that the hint order is sensible).
327
361
328
- ### Examples of hints
362
+ #### Examples of hints
329
363
330
364
Here are examples of hints:
331
365
@@ -355,7 +389,7 @@ the hint.
355
389
The second hint triggers when the user attempt *contains* the given
356
390
pattern (note the term `present`).
357
391
358
- # # Notes on YAML
392
+ # ## Notes on YAML
359
393
360
394
The info section supports
361
395
[YAML format version 1.2](https://yaml.org/spec/1.2.2/).
@@ -474,7 +508,7 @@ You can use
474
508
[ convert yaml to json] ( https://onlineyamltools.com/convert-yaml-to-json )
475
509
to interactively experiment with YAML.
476
510
477
- ## Preventing problems
511
+ ### Preventing problems
478
512
479
513
As always, it's best to try to
480
514
make smaller changes, test them, and once they work
@@ -488,7 +522,7 @@ Remember, hints are checked in order - it's possible to create a hint
488
522
that won't trigger because something earlier would always match.
489
523
These tests are automatically checked every time the page is (re)loaded.
490
524
491
- ## Debugging
525
+ ### Debugging
492
526
493
527
Sadly, sometimes things don't work; here are some debugging tips for labs.
494
528
@@ -514,7 +548,7 @@ This will display information, particularly on its inputs.
514
548
This can help you track down a problems if you think your
515
549
inputs are being interpreted in a way different than you expect.
516
550
517
- ## Additional settings for natural languages other than English
551
+ ### Additional settings for natural languages other than English
518
552
519
553
This tool should work fine with languages other than English.
520
554
We expect that there will be a different HTML page for each
@@ -524,7 +558,7 @@ lab and each different natural language.
524
558
For each button you should set the ` title ` attribute for the
525
559
given language.
526
560
527
- ## Advanced use: Select preprocessing commands (e.g., for other languages)
561
+ ### Advanced use: Select preprocessing commands (e.g., for other languages)
528
562
529
563
For most programming languages the default regex preprocessing
530
564
should be fine. However, the * defaults* are * not* a
0 commit comments