[Solved] Is it possible to mark a problem as 'complete' with API instead of Website?

each time i submit my solution via API, i have to go into the website and manually click ‘mark as complete’. Is there a way to mark as complete via an API or some batch way?

Also when I mark as complete w/ GUI , a second popup always shows itself asking whether I want to publish or not, then I have to click through it. Can I skip this ?

$ exercism submit
$ exercism complete 
$ exercism complete --no-publish (optional flag?)
1 Like

In my opinion if you’re only solving the exercise and marking it as complete you’re missing out on some important aspects:

  • Publishing your solution contributes to the “collected wisdom”. Others can browse solutions and learn about different approaches, different implementations, etc.
  • Browsing the solutions of others provides the same opportunity for you. You don’t know what you don’t know, sometimes there are better (simpler, easier to read, more idiomatic, more efficient) or just different solutions that give you insights you wouldn’t get on your own.
  • Requesting mentorship is in my opinion Exercism’s most unique and useful feature. Often mentors can spot subtle issues not caught by the tests, or suggest changes that can make a solution simpler, easier to understand, more idiomatic or more efficient. Both as a student and a mentor I had many fruitful discussions that improved my understanding of the problem, my solution or even made me a better programmer.
  • Mentoring others is an underrated way of becoming better. You’re getting accustomed to reading code, spotting potential problems or parts that can be improved, you will get better at talking about code, about decisions and compromises, and arguing your position. Also, (at least in my experience) “social learning” and “learning by teaching” can really consolidate and deepen existing knowledge.

I’m just a mentor but if I had a say in this I would object to promoting the usage of the Exercism without interaction with mentors, students, or the solutions of others.

1 Like

yeah thats fine too, just a CLI with the complete option is all i want. “Published” by default would be ok

1 Like

Yes! You absolutely can mark exercises as complete via the API. However, that aspect of the API isn’t exposed in the CLI. If you’re up for a challenge, you could write yourself some code to access that API endpoint. I don’t think the API is well documented yet, though.

1 Like
  1. get the .id of the ./.exercism/metadata.json,
  2. using root = "https://exercism.org/api/v2"
  3. send a PATCH request to $root/solutions/$id/publish

Following this, you might want to enable comments for your solution:

  1. get .track, .exercise and .handle from metadata.json
  2. send a PATCH request to $root/tracks/$track/exercises/$exercise/community_solutions/$handle/comments/enable

Reading website/api.rb at main · exercism/website · GitHub reveals the current API.

(self-promotion: I do this in my GitHub - glennj/exercism-cli-fish-wrapper: A fish wrapper for the Exercism CLI)

4 Likes

huge Glennj, thanks! works like a charm.

when in problem directory… a quick bash curl for anyone else (using jq):

alias exercism_complete='
root=https://exercism.org/api/v2;
id=$(cat .exercism/metadata.json | jq .id --raw-output);
token=$(cat ~/.config/exercism/user.json | jq .token --raw-output);
curl -X PATCH -H "Authorization: Bearer $token" \
     $root/solutions/$id/publish
'
2 Likes