Skip to content

Conversation

@livzorn
Copy link
Contributor

@livzorn livzorn commented Oct 19, 2021

JIRA link

HEEDLS-643

Description

Adjusted the way the remaining length for prompt answers is calculated, so that the number of characters remaining shown to the user accounts for the "\r\n" that will be added to their answer. If there are 2 or fewer characters remaining, the user will see "0 characters remaining" because it is impossible to submit an answer". If there are more than 2 characters remaining, the error will indicate 2 fewer characters than the actual number of character remaining to allow for the newline separator.

Also fixed the titles on Edit course admin field and Add course admin field pages so their will have an "Error" in them if an error has occurred.

Screenshots

image


Developer checks

(Leave tasks unticked if they haven't been appropriate for your ticket.)

I have:

  • Run the formatter and made sure there are no IDE errors.
  • Written tests for the changes (accessibility tests, unit tests for controller, data services, services, view models, etc)
  • Manually tested my work with and without JavaScript. Full manual testing guidelines can be found here: https://softwiretech.atlassian.net/wiki/spaces/HEE/pages/6703648740/Testing
  • Updated/added documentation in Swiki and/or Readme. Links (if any) are below:
  • Updated my Jira ticket with information about other parts of the system that were touched as part of the MR and have to be sanity tested to ensure nothing’s broken.
  • Scanned over my own MR to ensure everything is as expected.

Copy link
Contributor

@AlexJacksonDS AlexJacksonDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to try and add unit tests for both these methods so this issue doesn't crop up again in the future, although I'm not sure how simple that would be. It should be possible to copy the setup for AddRegistrationPromptConfigureAnswers_add_configures_new_answer_and_updates_temp_data, but change the assertions to check the modelstate errors of the view result

@livzorn livzorn force-pushed the HEEDLS-643-prompt-answer-character-limit branch from 77a8261 to 185c91a Compare October 21, 2021 09:29
Copy link
Contributor

@DanBloxham-sw DanBloxham-sw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one minor thing about plurals, and one question that can probably be safely shot down.


var remainingLength = 1000 - (model.OptionsString?.Length - 2 ?? 0);
var remainingLength = 1000 - model.OptionsString.Length;
var remainingLengthShownToUser = remainingLength <= 2 ? 0 : remainingLength - 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we think it is clear enough to just show zero if the answer is over the limit?

I'm wondering about showing how many characters are over the limit so the user knows how much they need to shorten their answer by. But then that might introduce confusion if they then want to add another answer which will mysteriously be another 2 characters shorter.

Do we think its not worth the bother?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm right. I think it would be useful to know how many characters you've entered so you can compare it against the number remaining, and I think it would be more useful than confusing. This error will probably not be encountered very often, and I think it would be more useful than confusing. Added in the number of characters entered to the error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to fix the tests accordingly, will do after lunch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are passing now, and the new error message looks like this, let me know what you think:
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks pretty good. Minor suggestion, I think it would be better if it said "x characters were entered" to make it slightly clearer that those characters are the ones the user just tried to enter. Does that sound reasonable?

ModelState.AddModelError(
nameof(AdminFieldAnswersViewModel.Answer),
$"The complete list of answers must be 1000 characters or fewer ({remainingLength} characters remaining for the new answer)"
$"The complete list of answers must be 1000 characters or fewer ({remainingLengthShownToUser} characters remaining for the new answer)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make the "characters" after the {remainingLengthShownToUser} to be singular if there is only 1 character remaining (I think we have a DisplayStringHelper with a method in for adding an "s" to a string if a count is not 1).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, changed!

@livzorn livzorn force-pushed the HEEDLS-643-prompt-answer-character-limit branch from 185c91a to ba2b0de Compare October 25, 2021 11:39
Copy link
Contributor

@DanBloxham-sw DanBloxham-sw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I've left a minor comment about maybe adding another word to the error message. If you think the extra word is unnecessary, feel free to merge as is.


var remainingLength = 1000 - (model.OptionsString?.Length - 2 ?? 0);
var remainingLength = 1000 - model.OptionsString.Length;
var remainingLengthShownToUser = remainingLength <= 2 ? 0 : remainingLength - 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks pretty good. Minor suggestion, I think it would be better if it said "x characters were entered" to make it slightly clearer that those characters are the ones the user just tried to enter. Does that sound reasonable?

@livzorn livzorn merged commit 264f3d1 into master Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants