gradethis icon indicating copy to clipboard operation
gradethis copied to clipboard

Allow multiple correct answers for grade_code()

Open garrettgman opened this issue 4 years ago • 4 comments

Can a teacher supply multiple equivalent solutions for grade_code() to consider correct?

garrettgman avatar Apr 24 '20 21:04 garrettgman

Currently, no

schloerke avatar Apr 24 '20 21:04 schloerke

I know that :) Mental note: word feature requests better.

But to add something useful to the discussion: a good case for this would be when grading a ggplot2 command. An author might decide that it is permissable to put the aesthetic mappings in ggplot() or the geom function. ...of course the permutations add up to an unmanageable number fairly quickly.

garrettgman avatar Apr 27 '20 13:04 garrettgman

Just want to say another good reason for this are when americian vs british spelling will be used in a solution. Got a message today about using "color" vs "colour" in a ggplot tutorial.

chendaniely avatar Jan 17 '22 23:01 chendaniely

Just want to say another good reason for this are when americian vs british spelling will be used in a solution.

Rather than having to specify multiple solutions to cover this particular use case, we should be comparing the functions directly. Since scale_color_manual() is an alias for scale_colour_manual() -- meaning they are literally the same function -- code analysis that compares the function itself rather than by name would catch this use case.

library(gradethis)
library(ggplot2)

ex <- mock_this_exercise(
  "scale_color_manual()",
  "scale_colour_manual()"
)

We currently compare the function name...

grade_this_code()(ex)
#> <gradethis_graded_this_code: [Incorrect]
#>   I expected you to call `scale_colour_manual()` where you called
#>   `scale_color_manual()`. That's okay: you learn more from mistakes
#>   than successes. Let's do it one more time.
#> >

where we should compare the function objects directly.

identical(scale_color_manual, scale_colour_manual)
#> [1] TRUE

gadenbuie avatar Jan 19 '22 20:01 gadenbuie