Skip to content

Conversation

@rmonnet
Copy link
Contributor

@rmonnet rmonnet commented Nov 26, 2025

In concept exercises, .meta/config.json use the key "exemplar" for the solution example file while practice exercises look for the key "example". I added some logic in run-test.sh to pick the correct key based on the exercise being tested.

This is preventing PR #81 to pass the GHA tests.

In concept exercises, `.meta/config.json` use the key "exemplar"
for the solution example file while practice exercises look for
the key "example". I added some logic in run-test.sh to pick the
correct key based on the exercise being tested.

This is preventing PR exercism#81 to pass the GHA tests.
@rmonnet rmonnet requested a review from glennj November 26, 2025 05:27
@glennj
Copy link
Contributor

glennj commented Nov 27, 2025

A couple of other things to do:

  • add a .files.exemplar to the track config.json (ref the go track)

  • modify bin/gen-exercise.sh to tell it whether you're creating a concept or practice exercise -- it's currently hardcoded

    I would do this:

    type=practice
    while getopts :hpca:d: opt; do
        case $opt in
            h) show_help; exit ;;
            p) type=practice ;;
            c) type=concept ;;
            a) author=$OPTARG ;;
            d) difficulty=$OPTARG ;;
            ?) die "unknown option: -$OPTARG" ;;
        esac
    done
    shift $((OPTIND - 1))
    
    exercise_name="${1:-}"
    exercise_path="exercises/${type}/${exercise_name}"
    
    [[ -z $author ]]     && read -rp 'What is your github userid? ' author
    [[ -z $difficulty ]] && read -rp 'What do you guess the difficulty is? ' difficulty
    
    ...
    
    bin/configlet create "--${type}-exercise" "$exercise_name" --author "$author" --difficulty "$difficulty"

    Then we could do:

    bin/gen-exercise.sh -a rmonnet -d 2 -c lasagna

@glennj
Copy link
Contributor

glennj commented Nov 27, 2025

Ah, except that configlet create --concept-exercises doesn't accept --difficulty ... more logic needed there.

Updated gen-exercise.sh to:

- Allow command line options for author,
  difficulty (practice only), blurb (concept only),
  the type of exercise (practice - default - or concept)
- Generate stub files for concept exercises (there is no problem
  specification for them so this is fairly barebone)
- Handled parameters for concept exercises that `configlet lint`
  flagged but `configlet create` didn't manage ;-)

 Added an exemplar entry to config.json in the file section, again
 for concept exercises.
@rmonnet
Copy link
Contributor Author

rmonnet commented Nov 29, 2025

@glennj , I did update gen-exercise.sh to generate either a practice or concept exercise per your advises. There was a couple of things that configlet create doesn't handle correctly and I got the script to fix these. The tricky part is that there is no problem specification for a concept exercise so the generated files are barebone. I tested on both a practice and a concept exercise and configlet lint was happy with the result.

Take a look and let me know what you think.

@rmonnet rmonnet added x:type/coding Write code that is not student-facing content (e.g. test-runners, generators, but not exercises) x:action/improve Improve existing functionality/content labels Nov 29, 2025
rmonnet added a commit to rmonnet/exercism-odin that referenced this pull request Nov 30, 2025
We currently have a tool to generate scaffolding for a concept
exercise (gen-exercise.sh as of PR exercism#89) but no tool to
create the concept itself.

Configlet doesn't provide such an option either.

This tool is modeled after gen-exercise and will create all the
files required for a concept with some comments describing what
each file should contain (similar to the raw versions of the
files in the top-level 'docs/' folder of the track). It will
also add the concept information to the top-level `config.json`.

There was also a mis-formatting in config.json, this was
corrected here so it doesn't show up in the next unrelated
exercise pull request.
@rmonnet
Copy link
Contributor Author

rmonnet commented Nov 30, 2025

@glennj, I wanted to change the title of the PR but that doesn't seem possible in github. It contains a revised version of gen-exercise.sh that can generate concept exercises as well as practice exercises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

x:action/improve Improve existing functionality/content x:type/coding Write code that is not student-facing content (e.g. test-runners, generators, but not exercises)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants