Skip to content

Commit

Permalink
Merge pull request #3083 from bitzesty/staging-word-count
Browse files Browse the repository at this point in the history
[STAGING] fix: Refactor word limit error message in QaeFormBuilder and Textarea Question
  • Loading branch information
TheDancingClown authored Sep 9, 2024
2 parents 6dbed0d + 8b36c58 commit 3a5b8bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion forms/qae_form_builder/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def skip_base_validation?

def limit_with_buffer(limit)
if limit > 15
(limit + limit * 0.1).to_i + 1
(limit + limit * 0.1).to_i
else
limit
end
Expand Down
6 changes: 3 additions & 3 deletions forms/qae_form_builder/textarea_question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ def errors

limit = question.delegate_obj.words_max

if limit && limit_with_buffer(limit) && length && length > (limit_with_buffer(limit) - 1)
if limit && limit_with_buffer(limit) && length && length > (limit_with_buffer(limit))
result[question.hash_key] ||= ""
error = if limit_with_buffer(limit) > 15
" Question #{question.ref} has a word limit of #{limit}. Your answer has to be #{limit_with_buffer(limit) - 1} words or less (as we allow 10% leeway)."
" Question #{question.ref} has a word limit of #{limit}. Your answer has to be #{limit_with_buffer(limit)} words or less (as we allow 10% leeway)."
else
" Question #{question.ref} has a word limit of #{limit}. Your answer has to be #{limit_with_buffer(limit) - 1} word or less."
" Question #{question.ref} has a word limit of #{limit}. Your answer has to be #{limit_with_buffer(limit)} words or less."
end
result[question.hash_key] << error
end
Expand Down

0 comments on commit 3a5b8bb

Please sign in to comment.