|
| 1 | +Exercise templates support several commented annotations that are processed when preparing exercise stubs and solutions. Note that the comment syntax is language dependent, `//` is used here as an example, but in Python an annotation would look like `# SOLUTION FILE`, for example. |
| 2 | + |
| 3 | +### `// SOLUTION FILE` |
| 4 | +Files that contain this annotation are left out of the stub. For example a file like |
| 5 | +```Java |
| 6 | +// SOLUTION FILE |
| 7 | +public class Solution { |
| 8 | + public String solution() { |
| 9 | + return "solution"; |
| 10 | + } |
| 11 | +} |
| 12 | +``` |
| 13 | +would look like this in the exercise solution |
| 14 | +```Java |
| 15 | +public class Solution { |
| 16 | + public String solution() { |
| 17 | + return "solution"; |
| 18 | + } |
| 19 | +} |
| 20 | +``` |
| 21 | +but would be left out entirely from the stub. |
| 22 | + |
| 23 | +### `// BEGIN SOLUTION` |
| 24 | +### `// END SOLUTION` |
| 25 | +Everything between these two annotations is left out of the stub. For example a file like |
| 26 | +```Java |
| 27 | +public class Solution { |
| 28 | + public String solution() { |
| 29 | + // BEGIN SOLUTION |
| 30 | + return "solution"; |
| 31 | + // END SOLUTION |
| 32 | + } |
| 33 | +} |
| 34 | +``` |
| 35 | +would look like this in the exercise solution |
| 36 | +```Java |
| 37 | +public class Solution { |
| 38 | + public String solution() { |
| 39 | + return "solution"; |
| 40 | + } |
| 41 | +} |
| 42 | +``` |
| 43 | +and like this in the exercise stub |
| 44 | +```Java |
| 45 | +public class Solution { |
| 46 | + public String solution() { |
| 47 | + } |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +### `// STUB:` |
| 52 | +Code after this annotation is added to the stub but left out of the solution. For example a file like |
| 53 | +```Java |
| 54 | +public class SomeClass { |
| 55 | + public String SomeFunction() { |
| 56 | + // STUB: return "stub"; |
| 57 | + // BEGIN SOLUTION |
| 58 | + return "solution"; |
| 59 | + // END SOLUTION |
| 60 | + } |
| 61 | +} |
| 62 | +``` |
| 63 | +would look like this in the exercise solution |
| 64 | +```Java |
| 65 | +public class SomeClass { |
| 66 | + public String SomeFunction() { |
| 67 | + return "solution"; |
| 68 | + } |
| 69 | +} |
| 70 | +``` |
| 71 | +and like this in the exercise stub |
| 72 | +```Java |
| 73 | +public class SomeClass { |
| 74 | + public String SomeFunction() { |
| 75 | + return "stub"; |
| 76 | + } |
| 77 | +} |
| 78 | +``` |
| 79 | +This example also shows use of the annotations together. |
| 80 | + |
| 81 | +### `// HIDDEN FILE` |
| 82 | +Files with this annotation are left out of the stub and solution entirely. This is useful for hidden test files that should be ran on the server, but not exposed to the students. |
| 83 | + |
| 84 | +### `// BEGIN HIDDEN` |
| 85 | +### `// END HIDDEN` |
| 86 | +Code between these annotations is left out of the stub and solution entirely. This is useful for hidden tests that should be ran on the server, but not exposed to the students. |
0 commit comments