-
Notifications
You must be signed in to change notification settings - Fork 41
Allow non-R solution code #290
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
Conversation
* Don't try to parse non-R solution code * .solution isn't available in these cases * Update mock_this_exercise() to follow same flow
e1be1ca to
c622ec4
Compare
instead we can get it from `.result` if that's an error condition
|
|
||
| # Skip parse checking if it was already done in {learnr} | ||
| if (!learnr_includes_parse_check(stage)) { | ||
| if (!learnr_includes_parse_check(stage) && identical(learnr_args$engine %||% "r", "r")) { |
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.
In the future, I'll think we'll want to standardize how we discover what language a piece of code is, but this is fine for now
| engine <- knitr_engine_caption(learnr_args[["engine"]]) | ||
| if (!identical(engine, "R")) { |
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.
Same here, I'd rather have a separate function or pattern to check for the exercise/code language, but I think that's a larger amount of work we'll want to tackle later on
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.
Quick question: why does engine == "R", but learnr_args$engine == "r"?
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.
yeah that's totally one of the reasons to standardize. knitr_engine_caption() turns engine strings like r, sql, javascript into text suitable for the exercise caption, e.g. R, SQL or JavaScript. So "r" or NULL comes out as "R".
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.
(In this case we're prepping the string for use in the message, so it makes sense to compare with "R".)
| .label = "mock", | ||
| .engine = "r", | ||
| .stage = "check", | ||
| .result = rlang::missing_arg(), |
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.
What's the difference between .result = rlang::missing_arg() and just .result with no default value?
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.
If .result isn't provided, we want to create .result from the .user_code, provided that it's R code that we can evaluate.
If we don't have R code though, we need the user to tell us what the result will be. That result might be NULL, so I'm using rlang::missing_arg() to tell the difference.
We could leave .result without a default value and use missing(.result) to catch that, but I prefer being explicit. I also prefer using "no default value" as a strong "required argument" signal; in this case .result isn't required.
rossellhayes
left a comment
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!
.solutionisn't available in these casesmock_this_exercise()to follow same flow