Text next to number entry input specifying precision #454

Closed
christianp opened this Issue Aug 25, 2016 · 6 comments

Projects

None yet

2 participants

@christianp
Member

Pretty much every number entry question I write has "give your answer to 3 decimal places" in the prompt.

This text should automatically be displayed next to the input, for non-gapfill numberentry parts. For gapfills, I don't think there's a way of showing the hint without interfering with the layout.

@christianp christianp added the Wishlist label Aug 25, 2016
@christianp
Member

To do this:

  • Add a string called numberentry.give your answer to precision to the locale file saying something like "give your answer to %s %s", where the parameters are the number of places and kind of precision.
  • In themes/default/xslt/question.xslt, in the template for numberentry part with mode="typespecific", add a span after the input and preview, with data-bind="html: precisionHint. Make sure it's only shown when the part has no parent.
  • in themes/default/files/scripts/display.js, add a ko.computed observable called precisionHint to the NumberEntryPartDisplay object which returns the message string. The relevant properties are this.part.settings.precisionType and this.part.settings.precision.

You could also add an option to not display the message, which would involve touching the editor.

@wandeg
Contributor
wandeg commented Oct 9, 2016

Hi is it ok if I take this up?

@christianp
Member

Sure! Thanks!

@wandeg
Contributor
wandeg commented Oct 9, 2016

I'm not sure what you meant by 'Make sure it's only shown when the part has no parent' in point 2, my web development is a bit rusty.
Please have a look at the pull request and comment on any necessary changes

@christianp christianp added a commit that closed this issue Oct 10, 2016
@christianp christianp add "show precision restriction hint" option for numberentry part
This adds an option "show precision restriction hint" to numberentry parts. If enabled, a line of text will appear next to the input, describing the precision required from the student (e.g. "round your answer to 2 decimal places")

There's a .exam migration, so existing questions have this option turned off, while new questions will have it turned on by default. Old questions tend to already have some text describing the required precision in the part prompt.

fixes #454
67f2a49
@christianp
Member

I ended up adding an option to show the hint or not - the main reason is that we've got a lot of existing questions which have the same text in the question prompt already. It also lets us have the text in gapfill parts, but allow it to be omitted when the layout would make it awkward.

@wandeg: I suggest you get a local copy of the Numbas editor installed before making any more changes. Thanks for taking the first step and making a pull request, though!

@wandeg
Contributor
wandeg commented Oct 10, 2016

Will do. Thanks for marking it as up-for-grabs for first timers .

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