apluslms / a-plus-rst-tools

Tools to publish RST course content for mooc-grader and a-plus. Should be cloned as a course submodule.
MIT License
5 stars 24 forks source link

Add placeholder option for freetext #178

Closed Mikael-Lenander closed 4 months ago

Mikael-Lenander commented 5 months ago

Description

What?

Add placeholder option for freetext directive. Placeholder is a text that is shown in an empty input field.

Why?

Specify units etc.

How?

Adds a new option_spec to FreeText class.

Testing

Remember to add or update unit tests for new features and changes.

What type of test did you run?

Compiled rst code. The placeholder attributes appeared in html files in _build folder.

Did you test the changes in

Think of what is affected by these changes and could become broken

Translation

Programming style

Have you updated the README or other relevant documentation?

Is it Done?

Clean up your git commit history before submitting the pull request!

ihalaij1 commented 5 months ago

Related issue: apluslms/a-plus#1143

Mikael-Lenander commented 4 months ago

I looked into this in more detail and turns out that there is no need for an additional option in the FreeText class. The placeholder can be added to the :extra: option and it renders nicely. However, the placeholder is not added to form_i18n dictionary for some reason, so translations don't work.

ihalaij1 commented 4 months ago

Hey,

I got the placeholder FreeText option working for multilingual courses, it required some changes in MOOC-Grader too. I will be finishing a pull request on it and you can then test it.

ihalaij1 commented 4 months ago

I believe I still need to do similar changes to MOOC-Jutut as I did to MOOC-Grader to get the placeholder to display in Jutut exercises too. I'll see if I can figure it out.

ihalaij1 commented 4 months ago

@Mikael-Lenander I got the placeholder :extra: option working more easily, since it was already somewhat supported by MOOC-Jutut. I had to make some changes in MOOC-Grader to get the translations working in both MOOC-Jutut questionnaires and normal MOOC-Grader questionnaires.

Could you test the PR and tell me if it fulfills your needs? https://github.com/apluslms/mooc-grader/pull/157

I will close this PR now, since we don't need a new :placeholder: option after all.