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
61 changes: 1 addition & 60 deletions docs/labs/input2.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="input2.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

<!-- Sample expected answer -->
Expand All @@ -33,66 +34,6 @@
\) , \s*
</script>

<!--
The following define hints. Hints are expressed in a JSON array, so:
- \ in a regex is written as \\
- " in a regex is written as \"
- All field names and value strings must be quoted
- commas must *separate* the entries - last one must NOT have a comma.
-->
<script id="info" type="application/yaml">
---
hints:
- absent: ", $"
text: This is a parameter, it must end with a comma.
- absent: |
query \( ["'`]id["'`] \)
text: "Use query() with an 'id' parameter."
- present: |
query \( ["'`]id["'`] \) [^. ]
text: 'After query("id") use a period to invoke a verification method.'
- present: |
(islength|Islength|IsLength|ISLENGTH)
text: >
JavaScript is case-sensitive. Use isLength instead of the case you have.
- absent: isLength
text: "Use isLength()."
- present: |
isLength \( m
text: "You need to pass isLength() an object within {...}."
- absent: matches
text: "Use matches()."
- present: |
matches \( /[^^]
text: "Match the whole string - begin the regular expression with ^"
- present: |
matches \( /.*[^$]/
text: "Match the whole string - end the regular expression with $"
- present: |
matches \( /.*[^$]/
text: Match the whole string - end the regular expression with $
- present: |
matches \( /\^\[A-Z\]-
text: That would match only one letter before the dash, you need two.
- present: |
matches \( /.*(\[0-9\]|\d)\*
text: >
You need to match one or more digits; * allows 0 or more.
A + would be better suited for this task.
- present: |
\s*, , $
text: >
You have two commas at the end. Use only one. You may need to
scroll or increase the text area to see both of them.
successes:
- - query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\d+-[0-9]+$/),
- - ' query (`id`) . isLength( {max:80}).matches(/^[A-Z]{2}-\d+-[0-9]+$/ ) , '
failures:
- - query('id').isLength({max:80}).matches( /^[A-Z]{2}-[0-9]+- [0-9]+$/ ),
- - query('id').isLength().matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ ),
- - query('id').isLength({max:80}).matches( /[A-Z]{2}-[0-9]+-[0-9]+/ ),
- - query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\d+-[0-9]+$/)
</script>
</head>
<body>
<!-- For GitHub Pages formatting: -->
Expand Down
79 changes: 79 additions & 0 deletions docs/labs/input2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
info =
{
hints: [
{
absent: ", $",
text: "This is a parameter, it must end with a comma."
},
{
absent: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \)`,
text: "Use query() with an 'id' parameter."
},
{
present: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \) [^. ]`,
text: "After query(\"id\") use a period to invoke a verification method."
},
{
present: "(islength|Islength|IsLength|ISLENGTH)",
text: "JavaScript is case-sensitive. Use isLength instead of the case you have.\n"
},
{
absent: "isLength",
text: "Use isLength()."
},
{
present: String.raw`isLength \( [a-z]`,
text: "You need to pass isLength() an object within {...}."
},
{
absent: "matches",
text: "Use matches()."
},
{
present: String.raw`matches \( /[^^]`,
text: "Match the whole string - begin the regular expression with ^"
},
{
present: String.raw`matches \( /[^$/]*[^$]/`,
text: "Match the whole string - end the regular expression with $"
},
{
present: String.raw`matches \( /[^$/]*[^$]/`,
text: "Match the whole string - end the regular expression with $"
},
{
present: String.raw`matches \( /\^\[A-Z\]-`,
text: "That would match only one letter before the dash, you need two."
},
{
present: String.raw`matches \( /.*(\[0-9\]|\d)\*`,
text: "You need to match one or more digits; * allows 0 or more. A + would be better suited for this task.\n"
},
{
present: String.raw`\s*, , $`,
text: "You have two commas at the end. Use only one. You may need to scroll or increase the text area to see both of them.\n"
}
],
successes: [
[
"query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/),"
],
[
" query (`id`) . isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/ ) , "
]
],
failures: [
[
"query('id').isLength({max:80}).matches( /^[A-Z]{2}-[0-9]+- [0-9]+$/ ),"
],
[
"query('id').isLength().matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ ),"
],
[
"query('id').isLength({max:80}).matches( /[A-Z]{2}-[0-9]+-[0-9]+/ ),"
],
[
"query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/)"
]
]
}