11# Creating labs with checker
22
3- These are the instructions for how to create labs with ` checker.js ` ,
3+ These are the instructions for how to create labs with ` checker.js ` .
4+ The main sections are:
5+
6+ * [ Introduction] ( #introduction )
7+ * [ Creating the lab instructions and correct answer] ( #creating-the-lab-instructions-and-correct-answer )
8+ * [ Creating the lab HTML file] ( #creating-the-lab-html-file )
9+ * [ Creating the lab JavaScript file] ( #creating-the-lab-javascript-file )
10+ (including [ JavaScript notation] ( #javascript-notation ) and
11+ [ Debugging] ( #debugging ) )
12+ * [ Localization] ( #localization ) (aka translation)
13+ * [ Submitting a new or updated lab] ( #submitting-a-new-or-updated-lab )
14+ * [ Potential future directions] ( #potential-future-directions )
415
516## Introduction
617
@@ -149,15 +160,38 @@ has its advantages:
149160 These are often useful for patterns.
150161 Use ${BACKQUOTE} for ` ; and ${DOLLAR} for $.
151162
152- JavaScript allows trailing commas, and we encourage using them.
163+ A common error is including the terminating character in the middle of
164+ a string. For example, this is an error: ` "A "foo" is metasyntactic variable" `
165+ because the double-quote before ` foo ` is interpreted as the end of the string.
166+ Some correct alternatives would be
167+ ` "A \"foo\" is metasyntactic variable" `
168+ or
169+ ` 'A "foo" is metasyntactic variable' ` (either works).
170+
171+ Values (including strings)
172+ are grouped into two kinds of structures, * arrays* and * objects* :
173+
174+ * array: An ordered sequence of values with this form: ` [a, b, c] `
175+ * object: A set of properties and their values with this form:
176+ ` {property1: value1, property2: value2, property3: value3} `
177+
178+ A * really* * common* error is
179+ forgetting to add a comma to separate items
180+ when you add an item to an array or object.
181+ For example, if you add ` d ` to the array earlier, you might have this
182+ incorrect form: ` [a, b, c d] ` (ERRONEOUS).
183+
184+ JavaScript allows trailing commas, and we * encourage* using them.
153185In other words,
154186a list in JavaScript can have the form ` [ 'a', 'b', 'c', ] `
155- (note the trailing comma after ` 'c' ` ).
187+ (note the trailing extra comma after ` 'c' ` ).
156188Using trailing commas reduces the likelihood of
157- a common error: forgetting to add a comma when you add an item to a list .
158- Using trailing commas means that when you add a new item (` 'd' ` ) at the end,
189+ forgetting to add the comma between values .
190+ If you using trailing commas, when you add a new item (` 'd' ` ) at the end,
159191you * already* have the comma ready for use.
160192
193+ If things don't work out, see the [ Debugging] ( #debugging ) section.
194+
161195### Expressing correct answer patterns
162196
163197The patterns used for ` correct ` and ` hints `
@@ -347,6 +381,9 @@ You can provide these fields for testing:
347381* ` hints ` : If present, this is an array of hints.
348382 We discuss that now.
349383
384+ We encourage creating many self-tests (` successes ` , ` failures ` , and
385+ tests for hints).
386+
350387### Hints
351388
352389Hints are expressed in the info ` hints ` field.
@@ -449,7 +486,11 @@ These tests are automatically checked every time the page is (re)loaded.
449486
450487Sadly, sometimes things don't work; here are some debugging tips for labs.
451488
452- If you open a page and the text entries don't have color, there
489+ Every time you reload the lab HTML, the program will reload and
490+ all self-tests will be run. If you see no errors, and the text entry
491+ areas are showing in yellow, a * lot* of things are working well.
492+
493+ If you load a page and the text entries don't have color, there
453494was a serious problem loading things.
454495Use your browser's * Developer Tools* to show details.
455496In Chrome, this is More Tools -> Developer Tools -> (Console Tab).
@@ -463,11 +504,17 @@ Note:
463504 this reports an attempt to load a file that's hosted on GitHub pages,
464505 and that page is unlikely to exist on your local machine.
465506
507+ We encourage you to add many self-tests (e.g., ` successes ` , ` failures ` , and
508+ tests for hints) when creating labs.
509+
466510You can set the optional info "debug" field to true.
467511This will display information, particularly on its inputs.
468512This can help you track down a problems if you think your
469513inputs are being interpreted in a way different than you expect.
470514
515+ See the [ JavaScript notation] ( #javascript-notation ) section on how to write
516+ data in JavaScript.
517+
471518### Advanced use: Definitions
472519
473520Regular expressions make it easy to describe many patterns.
@@ -629,6 +676,10 @@ The [list of labs](https://best.openssf.org/labs/) provides more information.
629676WARNING : We aren't currently using all labs we have.
630677Make sure you focus on the labs in use first :-).
631678
679+ See the [JavaScript notation](#javascript-notation) section on how to write
680+ data, and
681+ the [Debugging](#debugging) section to see how to understand and fix problems.
682+
632683# ## No longer using embedded data or YAML
633684
634685At one time we used data files embedded in the HTML (e.g., YAML,
0 commit comments