|
9 | 9 | "slideshow": {
|
10 | 10 | "slide_type": ""
|
11 | 11 | },
|
12 |
| - "tags": [] |
| 12 | + "tags": [], |
| 13 | + "vscode": { |
| 14 | + "languageId": "raw" |
| 15 | + } |
13 | 16 | },
|
14 | 17 | "source": [
|
15 | 18 | ".. important::\n",
|
16 |
| - " Jupyter widgets cannot be run within in documentation. To be able to interact with the widget you must run a mybinder instance. To run a mybinder instance of this notebook please use this link https://mybinder.org/v2/gh/osscar-org/scicode-widgets/HEAD?labpath=docs%2Fsrc%2Fexercises.ipynb." |
| 19 | + " Jupyter widgets cannot be run within the documentation. To interact with the widget, you must run a mybinder instance. To run a mybinder instance of this notebook, please use this link https://mybinder.org/v2/gh/osscar-org/scicode-widgets/HEAD?labpath=docs%2Fsrc%2Fcheck.ipynb." |
17 | 20 | ]
|
18 | 21 | },
|
19 | 22 | {
|
|
29 | 32 | "id": "2",
|
30 | 33 | "metadata": {},
|
31 | 34 | "source": [
|
32 |
| - "Checks intention is to give students a way to validate their code solution. The student's code can be validated by providing a list of inputs and references comparing the output of the student's code with the references, or by directy testing certain functional behavior of the code. In cases when reference outputs need to be obfuscated the outputs that are compared can be passed through a _fingerprint_ function. This notebook goes through each of these features and presents an example." |
| 35 | + "The purpose of a check is to give students a way to validate their code solutions. The student's code can be validated by providing a list of inputs and references, which are compared to the output of the student's code, or by directly testing certain functional behavior of the code. In cases when reference outputs need to be obfuscated, the outputs that are compared can be passed through a _fingerprint_ function. This notebook goes through each of these features and presents an example." |
33 | 36 | ]
|
34 | 37 | },
|
35 | 38 | {
|
|
51 | 54 | "id": "4",
|
52 | 55 | "metadata": {},
|
53 | 56 | "source": [
|
54 |
| - "Similar as for the `ExerciseRegistry` we need to define a `CheckRegistry` that registers the checks for each exercise." |
| 57 | + "Similar to the `ExerciseRegistry`, we need to define a `CheckRegistry` that registers the checks for each exercise." |
55 | 58 | ]
|
56 | 59 | },
|
57 | 60 | {
|
|
89 | 92 | "\n",
|
90 | 93 | "\n",
|
91 | 94 | "check_code_ex = CodeExercise(\n",
|
92 |
| - " key=\"sinus_with_references_1\",\n", |
| 95 | + " key=\"sine_with_references_1\",\n", |
93 | 96 | " code=sin,\n",
|
94 | 97 | " check_registry=check_registry,\n",
|
95 | 98 | ")\n",
|
|
121 | 124 | "id": "8",
|
122 | 125 | "metadata": {},
|
123 | 126 | "source": [
|
124 |
| - "Because there are asserts that are repeatedly needed for almost any kind of exercise, we provide of a set of asserts" |
| 127 | + "Since some asserts are frequently needed across various exercises, we provide a common set of asserts." |
125 | 128 | ]
|
126 | 129 | },
|
127 | 130 | {
|
|
139 | 142 | " assert_type,\n",
|
140 | 143 | ")\n",
|
141 | 144 | "\n",
|
142 |
| - "def sinus(arr):\n", |
| 145 | + "def sine(arr):\n", |
143 | 146 | " import numpy as np\n",
|
144 | 147 | " return np.cos(arr) # oops! wrong solution\n",
|
145 | 148 | "\n",
|
146 | 149 | "check_code_ex = CodeExercise(\n",
|
147 |
| - " key=\"sinus_with_references_2\",\n", |
148 |
| - " title=\"sinus\",\n", |
149 |
| - " code=sinus,\n", |
| 150 | + " key=\"sine_with_references_2\",\n", |
| 151 | + " title=\"sine\",\n", |
| 152 | + " code=sine,\n", |
150 | 153 | " check_registry=check_registry,\n",
|
151 | 154 | ")\n",
|
152 | 155 | "\n",
|
|
216 | 219 | },
|
217 | 220 | "outputs": [],
|
218 | 221 | "source": [
|
219 |
| - "def sinus(arr):\n", |
| 222 | + "def sine(arr):\n", |
220 | 223 | " import numpy as np\n",
|
221 | 224 | " return np.cos(arr) # oops! wrong solution\n",
|
222 | 225 | "\n",
|
223 | 226 | "code_ex_functional_behavior = CodeExercise(\n",
|
224 |
| - " key=\"sinus_functional_behavior\",\n", |
225 |
| - " code=sinus,\n", |
| 227 | + " key=\"sine_functional_behavior\",\n", |
| 228 | + " code=sine,\n", |
226 | 229 | " check_registry=check_registry,\n",
|
227 | 230 | ")\n",
|
228 | 231 | "\n",
|
|
250 | 253 | "tags": []
|
251 | 254 | },
|
252 | 255 | "source": [
|
253 |
| - "## Obfuscating the reference solution with fingerprint" |
| 256 | + "## Obfuscating the reference solution with a fingerprint" |
254 | 257 | ]
|
255 | 258 | },
|
256 | 259 | {
|
|
272 | 275 | " \n",
|
273 | 276 | " What has wings but in the air it not swings.\n",
|
274 | 277 | " I looked to the north, but it was not worth.\n",
|
275 |
| - " What I am looking for?\n", |
| 278 | + " What am I looking for?\n", |
276 | 279 | " \"\"\"\n",
|
277 | 280 | " return \"\"\n",
|
278 |
| - "code_input_sinus = CodeInput(riddle)\n", |
| 281 | + "code_input_sine = CodeInput(riddle)\n", |
279 | 282 | "\n",
|
280 | 283 | "check_code_ex = CodeExercise(\n",
|
281 | 284 | " key=\"riddle\",\n",
|
282 |
| - " code=code_input_sinus,\n", |
| 285 | + " code=code_input_sine,\n", |
283 | 286 | " check_registry=check_registry,\n",
|
284 | 287 | ")\n",
|
285 | 288 | "\n",
|
286 | 289 | "#def assert_equal(output, reference):\n",
|
287 |
| - "# return \"\" if output == reference else \"Not correct solution. Hint: it is an animal in the antarctica.\"\n", |
| 290 | + "# return \"\" if output == reference else \"Not correct solution. Hint: it is an animal in the Antarctica.\"\n", |
288 | 291 | "\n",
|
289 | 292 | "char_to_num = {char: num for num, char in enumerate(\"abcdefghijklmnopqrmnstuvwxyz\")}\n",
|
290 | 293 | "def string_to_int(output):\n",
|
|
318 | 321 | "id": "18",
|
319 | 322 | "metadata": {},
|
320 | 323 | "source": [
|
321 |
| - "The check registry also provides the possibility to check all the widgets. " |
| 324 | + "The check registry also allows checking of all the widgets simultaneously. " |
322 | 325 | ]
|
323 | 326 | },
|
324 | 327 | {
|
|
338 | 341 | "id": "20",
|
339 | 342 | "metadata": {},
|
340 | 343 | "source": [
|
341 |
| - "For the demo to automatically we simulate a button press using the private function that should not be used" |
| 344 | + "For the demo, we simulate a button press using the private function that should not be used" |
342 | 345 | ]
|
343 | 346 | },
|
344 | 347 | {
|
|
0 commit comments