Skip to content
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 grade_this_code() to provide pass-through-filter grading #276

Merged
merged 8 commits into from
Jan 19, 2022

Conversation

gadenbuie
Copy link
Member

@gadenbuie gadenbuie commented Jan 12, 2022

This PR relaxes the constraint applied in gradethis_exercise_checker() that gradethis grading functions must return either passing or failing feedback. This builds on rstudio/learnr#610 and uses the new stage argument set in the checker function when evaluating exercises. The constraint is now only applied to stage == "check" since this defines the terminal check action and other grading chunks might pass through.

Then, we build on the above feature by adding an action parameter to grade_this_code(), allowing the grading author to choose if grade_this_code() will pass or fail the user's code. The default is "both" to be consistent with current behavior. If either "pass" or "fail" are chosen, feedback that would result in the opposite action is ignored and no feedback is returned.

The end result is that authors can write check chunks that use static code analysis to filter out problematic results that might be computationally intensive, but that defer to the -check chunk when the code matches.

Use the correct join function to combine these
two giant tables without crashing your session.

```{r join, exercise = TRUE}
dplyr::____(giant, huge)
```

```{r join-solution}
dplyr::inner_join(giant, huge)
```

```{r join-code-check}
grade_this_code(incorrect = "Not that one", action = "fail")
```

```{r join-check}
grade_this({
  pass_if_equal(message = "Good choice!")
  fail()
})
```

If the user picks left_join(), static analysis will return a feedback message highlighting the user's mistake. If the user picks inner_join(), grade_this_code() defers to the -check chunk where the user's evaluated code is graded. (Totally made up example, but similar issues arise in plotting and many other places.)

@gadenbuie gadenbuie added the auto-pkg-maintenance Automatic package maintenance is approved for this PR label Jan 12, 2022
@gadenbuie gadenbuie removed the auto-pkg-maintenance Automatic package maintenance is approved for this PR label Jan 13, 2022
Copy link
Contributor

@rossellhayes rossellhayes left a comment

Choose a reason for hiding this comment

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

This is a really nice change!

@gadenbuie gadenbuie merged commit 4fbbd00 into main Jan 19, 2022
@gadenbuie gadenbuie deleted the allow-no-feedback-by-stage branch January 19, 2022 17:22
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.

2 participants