laike9m / Python-Type-Challenges

Master Python typing (type hints) with interactive online exercises!

Home Page:https://python-type-challenges.zeabur.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider adding a hint message with links for each question

piglei opened this issue · comments

Currently, there is no hint message for most questions. For a few questions like callable-protocol, there is a short "HINT: Use Protocol" written in the code, but there is no standard.

We do provide a "Solution" button, but it's very different from a hint. When the user is playing with each challenge, a well-designed hint message can guide him and help him complete the question by learning, but the "solution" button takes him directly to the answer--It's faster but the user may not learn anything at all!

So I'm suggesting that we add a hint message to all questions. The hint messages follow a standard format, like this:

  • For basic/any: HINT: Check out Any.
  • For intermediate/callable: HINT: Check out Callable.
  • For intermediate/generic2: HINT: Check out TypeVar, constraints are needed for this question.
  • ...

Implementation

The hint can be added directly in any question.py like this:

## HINT start ##
(message in Markdown format)
## HINT end ##

The server can extracts the message and render it as HTML(to make hyper link works).

Adding hint is something I've always considered, but I haven't thought of an ideal way to store hints.

Here are the requirements if we were to add this feature:

  • Hint should be optional for a challenge (i.e. it's perfectly fine that a challenge does not have hint(s))
  • Adding hint should be easy and add as little extra work as possible for contributors

In terms of implementation, I'm a bit hesitant to put it in question.py. Having to write ## End of your code ## is already very tedious (I can't remember it and have to copy&paste each time adding a new challenge), and ## HINT start ## makes things worse...

At this point I'm more leaning towards putting hints in a separate file. Maybe we can store it in a markdown hints.md so that it's easier to add (than write html). So it would look something like

# hints.md
HINT: Check out [Callable](https://docs.python.org/3/library/typing.html#annotating-callable-objects).

Having to put ## End of your code ## is already very tedious (I can't remember it and have to copy each time adding a new challenge), and ## HINT start ## makes things worse...

lol, yes, that would definitely make it harder to add new questions and make question.py a little too noisy. If we don't want to stick to using magic comments in question.py, introducing a new markdown file for storing hint messages would be better.

I would be happy to implement this feature.

Awesome, that would be of great help!

Another consideration is how to show hints on a challenge page. I think the only requirement is to not show it directly, maybe with a popup or something similar. I'll leave this to you to decide :)

Implemented in #71.

Screenshots:

image image

Closed, since most challenges have hints now. More will be added as time goes.