Skip to content

Commit afcc8d5

Browse files
Create separate add practice exercise doc
1 parent 754d5e0 commit afcc8d5

File tree

4 files changed

+150
-93
lines changed

4 files changed

+150
-93
lines changed

building/config.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,17 @@
102102
{
103103
"uuid": "d951a049-a5ca-4b38-ae06-68b10cfbb2d9",
104104
"slug": "tracks/practice-exercises",
105-
"path": "building/tracks/practice-exercises.md",
105+
"path": "building/tracks/practice-exercises/README.md",
106106
"title": "Practice Exercises",
107107
"blurb": ""
108108
},
109+
{
110+
"uuid": "531f0e8a-0207-42a8-bf68-26ca42f8872f",
111+
"slug": "tracks/practice-exercises/add",
112+
"path": "building/tracks/practice-exercises/add.md",
113+
"title": "Add a Practice Exercise",
114+
"blurb": ""
115+
},
109116
{
110117
"uuid": "34387a23-f65c-490e-96ed-6b5e25298db7",
111118
"slug": "tracks/concept-exercises",

building/tracks/new/add-initial-exercises.md

+1-91
Original file line numberDiff line numberDiff line change
@@ -103,98 +103,8 @@ To make this all a bit more concrete, this is what a sample selection of initial
103103

104104
## Implement exercises
105105

106-
### Scaffold exercise
107-
108106
Having selected the exercises you want include in your track, the next step is to implement them.
109-
You can quickly scaffold a new Practice Exercise by running the `bin/add-practice-exercise` script ([source](https://github.com/exercism/generic-track/blob/main/bin/add-practice-exercise)) from the track's root directory:
110-
111-
```shell
112-
bin/add-practice-exercise <exercise-slug>
113-
```
114-
115-
Optionally, you can also specify the exercise's difficulty (via `-d`) and/or author's GitHub username (via `-a`):
116-
117-
```shell
118-
bin/add-practice-exercise -d 3 -a foobar <exercise-slug>
119-
```
120-
121-
```exercism/note
122-
If you're working on a track repo without this file, feel free to copy them into your repo using the above source link.
123-
```
124-
125-
### Implement exercise
126-
127-
Once the scaffolded files have been created, you'll then have to:
128-
129-
- Add tests to the tests file
130-
- Add an example implementation
131-
- Define the stub file's contents
132-
- Within the exercise's `.meta/config.json` file:
133-
- Add the GitHub username of the exercise's authors to the `authors` key
134-
- Within the track's `config.json` file:
135-
- Check/update the exercise's difficulty
136-
- Add concepts to the `practices` key (only required when the track has concept exercises)
137-
- Add concepts to the `prerequisites` key (only required when the track has concept exercises)
138-
139-
#### Add tests
140-
141-
A key part of adding an exercise is adding tests.
142-
Rougly speaking, there are two options when adding tests for one of the above exercises:
143-
144-
1. Implement the tests from scratch, using the test cases from the exercise's `canonical-data.json` file as found in the [problem-specifications repo][problem-specifications-exercises].
145-
2. Port the tests from another track's implementation (tip: go to `https://exercism.org/exercises/<slug>` to get an overview of which tracks have implemented a specific exercise).
146-
147-
The second option can be particularly appealing, as it can give you results quickly.
148-
Keep in mind, though, that you should tweak the implementation to best fit your track.
149-
As an example, some tracks do not use classes but only work with functions.
150-
If your track usually works with objects though, you should adapt the implementation to what best fits your track.
151-
152-
#### Add example implementation
153-
154-
To ensure that it is possible to write code that passes the tests, an example implementation needs to be added.
155-
156-
```exercism/note
157-
The code does _not_ have to be idiomatic, it only has to pass the tests.
158-
```
159-
160-
You can verify the example implementation passes all the tests by running the `bin/verify-exercises` script ([source](https://github.com/exercism/generic-track/blob/main/bin/verify-exercises)) from the track's root directory:
161-
162-
```shell
163-
bin/verify-exercises <exercise-slug>
164-
```
165-
166-
Use the output to verify that the example implementation passes all the tests.
167-
168-
```exercism/note
169-
If you're working on a track repo without this file, feel free to copy them into your repo using the above source link.
170-
```
171-
172-
```exercism/advanced
173-
Under the hood, the `bin/verify-exercises` script does several things:
174-
175-
- Copy the exercise to a temporary directory
176-
- Overwrite the stub file(s) with the example implementation file(s)
177-
- If the test file has skipped tests, they will be "unskipped"
178-
- Run the tests
179-
```
180-
181-
### Lint exercise
182-
183-
The final step is to run [the linter](/docs/building/configlet/lint) to check if the track's (configuration) files are properly structured - both syntactically and semantically.
184-
185-
First, make sure you have the latest version of [`configlet`](/docs/building/configlet/) by running:
186-
187-
```shell
188-
bin/fetch-configlet
189-
```
190-
191-
The run [the linter](/docs/building/configlet/lint) by running:
192-
193-
```shell
194-
bin/configlet lint
195-
```
196-
197-
Use the output to verify that all is well.
107+
The [Add Practice Exercise docs](/docs/building/tracks/practice-exercises/add) have detailed instructions on how to add a Practic Exercise.
198108

199109
[problem-specifications-exercises]: https://github.com/exercism/problem-specifications/tree/main/exercises/
200110
[allergies]: https://github.com/exercism/problem-specifications/tree/main/exercises/allergies

building/tracks/practice-exercises.md building/tracks/practice-exercises/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[Practice Exercises](/docs/building/product/practice-exercises) are exercises designed to allow students to solve an arbitrary problem, with the aim of them making use of the concepts they have learned so far.
44

5-
Interested in adding your first Practice Exercise to a track? Watch our walkthrough video 👇
5+
Interested in adding your first Practice Exercise to a track? Check the [Add Practice Exercise docs](/docs/building/tracks/practice-exercises/add) or watch our walkthrough video 👇
66

77
[video:vimeo/906101866?h=2954ad331e]()
88

+140
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Add Practice Exercise
2+
3+
This document will explain how to a new [Practice Exercise](/docs/building/tracks/practice-exercises).
4+
5+
## Select exercise
6+
7+
The simplest way to check what Practice Exercises have not yet been implemented is to go to the track's build page (e.g. https://exercism.org/tracks/csharp/build) and check the "Practice Exercises" section.
8+
9+
```exercism/caution
10+
The data on the build page is updated once a day.
11+
```
12+
13+
## Scaffold exercise
14+
15+
You can quickly scaffold a new Practice Exercise by running the `bin/add-practice-exercise` script ([source](https://github.com/exercism/generic-track/blob/main/bin/add-practice-exercise)) from the track's root directory:
16+
17+
```shell
18+
bin/add-practice-exercise <exercise-slug>
19+
```
20+
21+
Optionally, you can also specify the exercise's difficulty (via `-d`) and/or author's GitHub username (via `-a`):
22+
23+
```shell
24+
bin/add-practice-exercise -d 3 -a foobar <exercise-slug>
25+
```
26+
27+
```exercism/note
28+
If you're working on a track repo without this file, feel free to copy them into your repo using the above source link.
29+
```
30+
31+
## Implement exercise
32+
33+
Once the scaffolded files have been created, you'll then have to:
34+
35+
- Add tests to the tests file
36+
- Add an example implementation
37+
- Define the stub file's contents
38+
- Within the exercise's `.meta/config.json` file:
39+
- Add the GitHub username of the exercise's authors to the `authors` key
40+
- Within the track's `config.json` file:
41+
- Check/update the exercise's difficulty
42+
- Add concepts to the `practices` key (only required when the track has concept exercises)
43+
- Add concepts to the `prerequisites` key (only required when the track has concept exercises)
44+
45+
### Add tests
46+
47+
A key part of adding an exercise is adding tests.
48+
Rougly speaking, there are two options when adding tests for one of the above exercises:
49+
50+
1. Implement the tests from scratch, using the test cases from the exercise's `canonical-data.json` file as found in the [problem-specifications repo][problem-specifications-exercises].
51+
2. Port the tests from another track's implementation (tip: go to `https://exercism.org/exercises/<slug>` to get an overview of which tracks have implemented a specific exercise).
52+
53+
The second option can be particularly appealing, as it can give you results quickly.
54+
Keep in mind, though, that you should tweak the implementation to best fit your track.
55+
As an example, some tracks do not use classes but only work with functions.
56+
If your track usually works with objects though, you should adapt the implementation to what best fits your track.
57+
58+
### Add example implementation
59+
60+
To ensure that it is possible to write code that passes the tests, an example implementation needs to be added.
61+
62+
```exercism/note
63+
The code does _not_ have to be idiomatic, it only has to pass the tests.
64+
```
65+
66+
You can verify the example implementation passes all the tests by running the `bin/verify-exercises` script ([source](https://github.com/exercism/generic-track/blob/main/bin/verify-exercises)) from the track's root directory:
67+
68+
```shell
69+
bin/verify-exercises <exercise-slug>
70+
```
71+
72+
Use the output to verify that the example implementation passes all the tests.
73+
74+
```exercism/note
75+
If you're working on a track repo without this file, feel free to copy them into your repo using the above source link.
76+
```
77+
78+
```exercism/advanced
79+
Under the hood, the `bin/verify-exercises` script does several things:
80+
81+
- Copy the exercise to a temporary directory
82+
- Overwrite the stub file(s) with the example implementation file(s)
83+
- If the test file has skipped tests, they will be "unskipped"
84+
- Run the tests
85+
```
86+
87+
### Add stub file(s)
88+
89+
The stub implementation file(s) provide a starting point for students.
90+
91+
We recommend stub files to have the minimal amount of code such that:
92+
93+
- The student can immediately start implementing the logic to pass the tests
94+
- The student is not presented with "weird" syntax errors
95+
96+
In practice, this means defining the functions/methods that are tested by the test suite.
97+
Tracks are free as to how they setup this code, as long as they ensure that the stub code initially fails all the tests.
98+
99+
#### Examples
100+
101+
Python:
102+
103+
```python
104+
def two_fer(name):
105+
pass
106+
```
107+
108+
Kotlin:
109+
110+
```kotlin
111+
fun twofer(name: String): String {
112+
TODO("Implement the function to complete the task")
113+
}
114+
```
115+
116+
## Lint exercise
117+
118+
The final step is to run [the linter](/docs/building/configlet/lint) to check if the track's (configuration) files are properly structured - both syntactically and semantically.
119+
120+
First, make sure you have the latest version of [`configlet`](/docs/building/configlet/) by running:
121+
122+
```shell
123+
bin/fetch-configlet
124+
```
125+
126+
The run [the linter](/docs/building/configlet/lint) by running:
127+
128+
```shell
129+
bin/configlet lint
130+
```
131+
132+
Use the output to verify that all is well.
133+
134+
## Submit Pull Request
135+
136+
Once all is well, you can then [Submit a Pull Request](/docs/building/github/contributors-pull-request-guide) to the track's repository.
137+
138+
Before submitting, please read the [Contributors Pull Request Guide](/docs/building/github/contributors-pull-request-guide) and [Pull Request Guide](/docs/community/being-a-good-community-member/pull-requests).
139+
140+
Ensure the PR description lists the exercise being added.

0 commit comments

Comments
 (0)