You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know I can test for an exact match on a student's code using grade_this_code() but is there a way to check for an exact match on what was typed as an answer on the code using grade_this().
I am working on teaching students about the type of vectors used by R. I want students to use typeof() to realize that R returns the major version of R as a character string (because it is a number that will not be used for math):
I see students providing: typeof(R.version$nickname) as a solution. That, like the correct answer of typeof(R.version$major), returns a character string. So it is being called a correct answer.
Is there a way to trap the case that students type a specific response inside of grade_this()? I think you can see what I am getting at using this code
```{r ex2-typeof-check}
grade_this({
# I want to see if they typed this text
fail_if_equal(.user_code == "typeof(R.version$nickname)",
message = "You are checking the nickname you want to be checking the major"
)
pass_if_equal(typeof(R.version$major),
message = "Interesting the version number is being treated as a character string. R does not want you to do math on the version number."
)
fail_if_equal(R.version$major,
message = "Your code is telling you the major version. You want to check the type using `typeof()`."
)
fail_if_equal(R.version,
message = "That code tells you everything about the R version. Add a `$` and the key word for the `major` version."
)
fail(message = "Not quite. Take a peek at the hints!")
})
```
I see that .user_code captures the provided text but I don't see how to use it in a logic check.
The text was updated successfully, but these errors were encountered:
I know I can test for an exact match on a student's code using
grade_this_code()
but is there a way to check for an exact match on what was typed as an answer on the code usinggrade_this()
.I am working on teaching students about the type of vectors used by R. I want students to use
typeof()
to realize that R returns the major version of R as a character string (because it is a number that will not be used for math):I see students providing:
typeof(R.version$nickname)
as a solution. That, like the correct answer oftypeof(R.version$major)
, returns a character string. So it is being called a correct answer.Is there a way to trap the case that students type a specific response inside of
grade_this()
? I think you can see what I am getting at using this codeI see that
.user_code
captures the provided text but I don't see how to use it in a logic check.The text was updated successfully, but these errors were encountered: