-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow feedback on unparsable unicode characters to render without i18next
#765
Conversation
…is comprehensible when `i18next` is unavailable
Yeah that is elegant but let's use the same method we used in the other functions and not add the new dependency |
…` to handle interpolation
Got it, refactored to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thank you!
expect_unparsable_message <- function(user_code, problem, key) { | ||
ex <- mock_exercise(user_code = user_code) | ||
feedback <- evaluate_exercise(ex, new.env())$feedback | ||
expect_equal(feedback, exercise_check_code_is_parsable(ex)$feedback) | ||
expect_match(feedback$message, regexp = key, fixed = TRUE) | ||
for (character in problem) { | ||
expect_match(feedback$message, regexp = character, fixed = TRUE) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This cleans up the code quite a bit
@@ -4,6 +4,8 @@ | |||
|
|||
- The embedded Ace editor used in learnr exercises now defaults to a tab width of 2, aligning with the Tidyverse style guide (#761). | |||
|
|||
- Add a fallback to generate a comprehensible English feedback message for code that fails to parse because it contains non-ASCII characters. Previously, if i18next was unavailable, the feedback would contain uninterpolated i18next markup. Now the feedback is pre-interpolated so students will always see a comprehensible message (#765). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can trim this down a little bit
- Add a fallback to generate a comprehensible English feedback message for code that fails to parse because it contains non-ASCII characters. Previously, if i18next was unavailable, the feedback would contain uninterpolated i18next markup. Now the feedback is pre-interpolated so students will always see a comprehensible message (#765). | |
- learnr now pre-renders (in English) the feedback message it provides when non-ASCII characters are included in submitted unparsable R code. This makes the feedback useful in places where learnr's in-browser translations aren't available (#765). |
Applies suggestion from #765
Pre-interpolate message generated by
unparsable_unicode_message()
so feedback is comprehensible wheni18next
is unavailable.Previously, if
i18next
was unavailable, the feedback would contain uninterpolated strings, like this:This PR adds a dependency on
glue
, which provides an elegant way to pre-interpolate the string, but isn't strictly necessary. If we'd like to avoid adding a dependency, I can refactor to just use regex.PR task list:
devtools::document()