-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
87d531f
commit 7a31e8f
Showing
2 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,41 @@ | ||
import std/[os, strformat] | ||
import ".."/[cli, helpers, sync/sync, types_track_config] | ||
import "."/[approaches, articles] | ||
import std/[sets, os, strformat] | ||
import ".."/[cli, helpers, fmt/track_config, sync/sync, types_track_config, uuid/uuid] | ||
|
||
proc createConceptExercise*(conf: Conf) = | ||
echo "create ce" | ||
|
||
proc createPracticeExercise*(conf: Conf) = | ||
echo "create pe" | ||
let trackConfigPath = conf.trackDir / "config.json" | ||
let trackConfig = parseFile(trackConfigPath, TrackConfig) | ||
let trackExerciseSlugs = getSlugs(trackConfig.exercises, conf, trackConfigPath) | ||
let userExercise = Slug(conf.action.exerciseCreate) | ||
|
||
if userExercise in trackExerciseSlugs.`concept`: | ||
let msg = &"There already is a concept exercise with `{userExercise}` " & | ||
&"in the track config:\n{trackConfigPath}" | ||
stderr.writeLine msg | ||
quit 1 | ||
elif userExercise in trackExerciseSlugs.practice: | ||
let msg = &"There already is a practice exercise with `{userExercise}` " & | ||
&"in the track config:\n{trackConfigPath}" | ||
stderr.writeLine msg | ||
quit 1 | ||
|
||
let exerciseDir = conf.trackDir / "exercises" / "practice" / $userExercise | ||
let exercise = PracticeExercise( | ||
slug: userExercise, | ||
name: $userExercise, | ||
uuid: $genUuid(), | ||
practices: OrderedSet[string](), | ||
prerequisites: OrderedSet[string](), | ||
difficulty: 1, | ||
status: sMissing | ||
) | ||
|
||
var a = trackConfig.exercises.practice | ||
a.add(exercise) | ||
|
||
trackConfig.exercises.practice = a; | ||
|
||
let prettied = prettyTrackConfig(trackConfig) | ||
writeFile(trackConfigPath, prettied) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters