Skip to content

Commit

Permalink
Lab hardcoded: Move answers into JavaScript
Browse files Browse the repository at this point in the history
Signed-off-by: David A. Wheeler <[email protected]>
  • Loading branch information
david-a-wheeler committed Jan 29, 2025
1 parent 08e3e24 commit 00b6488
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
14 changes: 0 additions & 14 deletions docs/labs/hardcoded.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@
<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">
conn = DriverManager.getConnection(url,
System.getenv("USERNAME"), System.getenv("PASSWORD"));
</script>

<!-- Full pattern of correct answer -->
<script id="correct0" type="plain/text">
\s* conn = DriverManager \. getConnection \( url \,
System \. getenv \( "USERNAME" \) \,
System \. getenv \( "PASSWORD" \) \) \; \s*
</script>

</head>
<body>
<!-- For GitHub Pages formatting: -->
Expand Down
11 changes: 10 additions & 1 deletion docs/labs/hardcoded.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,14 @@ info =
System \. getenv \( "USERNAME" \) \) \; \s* $`,
text: "The order of parameters is wrong. Provide the url, then the username, then the password. You're providing the url, then the password, then the username, which swaps the second and third parameters."
}
]
],
expected: [
`conn = DriverManager.getConnection(url,
System.getenv("USERNAME"), System.getenv("PASSWORD"));`
],
correct: [
String.raw`\s* conn = DriverManager \. getConnection \( url \,
\s* System \. getenv \( "USERNAME" \) \,
\s* System \. getenv \( "PASSWORD" \) \) \; \s*`
],
}

0 comments on commit 00b6488

Please sign in to comment.