6.1 private_grader()
Description
Grades Private Questions involving tibbles, vectors, (named) lists, or plots, providing only basic feedback.
The function implements many of the General Checks discussed earlier.
Arguments
Element | Description | Default |
---|---|---|
var_name | character, the expected name of var | - |
var | expected R object, the student’s object | - |
var_test | other R object, the answer key’s object to be compared with var | - |
status | character, the question’s displayed part, number, and type (Private/Public); Example: “Part 2 Question 2 (Private)” | paste0(“Question”, quest_num, ” (Private)“) |
var_status | the data type of var; Example: “tib” (tibble), “vect” (vector), “lst” (list), “plt” (plot) | “tib” |
prev_check | logical indicating if the Prerequisite Check should be triggered. Requires quest_prev value and can optionally be combined with quest_prev_status | TRUE |
is_tibble_check | logical indicating if the tibble Structure Check should be triggered | TRUE |
quest_check_read | logical indicating if the message “Please make sure you are using read_csv(), not read.csv().” should be attached to the tibble Structure Check | FALSE |
quest_num | numeric, the question’s number | 0 |
quest_pt | numeric, the question’s maximum score | 0 |
quest_prev | numeric, the prerequisite question’s number | 1 |
quest_prev_status | character, the prerequisite question’s part and number; Example: “Part 2 Question 3b” | NULL |
Value
The test.results[#, ]
vector, containing the question’s status
, amount of points awarded, total point value, and feedback message.
See What is test.results? for more details.
Details
Designed for grading Private Questions involving tibbles, vectors, lists, or plots only.
Plot grading via private_grader()
is limited. Consistent with previous ECON 145 autograders, full credit is awarded if the student simply names the plot properly and gets any prerequisite question correct. For more detailed feedback, consider using the ggplot_grader()
for ggplot-type questions. See Plots for more information.
The function grades two-way tabyl lists only. For three-way tabyl lists, please use private_tabyl_grader()
instead.
Note that var
is the expected student’s R object and may not necessarily exist (e.g., the student saved their variable under a different name).
- This is not a problem because
private_grader()
first performs the Name Check. Ifvar
does not exist, the subsequent Checks will not be triggered.
Also note that quest_prev_status
is an optional argument when setting prev_check
and quest_prev
but helps clarify an unclear prerequisite question’s location in the feedback message.
- For example, if the prerequisite question is Part 2 Question 3b, but is the eighth question of the assignment (
quest_prev = 8
), this argument can specify its particular location through settingquest_prev_status = “Part 2 Question 3b”
. Otherwise, its question’s number will be displayed (i.e.,"Question 8"
).
Example 1: Tibble
Consider the following questions from Homework 14.
Part 1: Coding Assignment
First, you will combine player salary data with CPI data.
(Private Question) Load in the
Master.csv
file, keeping the columns for player ID, birth year, birth country, first name, last name, weight, height, bats, throws, debut date, and final game date. Save the tibble asplayer_master_data
.(Private Question) Load in the
Salaries.csv
file into R. Join theplayer_master_data
tibble with the data fromSalaries.csv
byplayerID
, keeping only rows with data from both datasets. Save the resulting, joined tibble asplayer_salary_data1
.
Assume each question is worth 5 points.
Then, the autograder code for this question should look like:4
#Comparing the student's tibble `player_master_data` with the answer key's `player_master_data_test`
#Since this is the first question of the assignment, there is no prerequisite check and so `prev_check` is set to `FALSE`
#Moreover, since this question involves the loading in of a .csv file, it would be helpful to remind students to use `read_csv()` and not `read.csv()` by setting `quest_check_read` to `TRUE`
test.results[1, ] <- private_grader("player_master_data", player_master_data, player_master_data_test,
status = "Part 1 Question 1a (Private)", var_status = "tib",
quest_check_read = TRUE, prev_check = FALSE, quest_num = 1, quest_pt = 5)
#Comparing the student's tibble `player_salary_data1` with the answer key's `player_salary_data1_test`
#This question relies on the student correctly reproducing `player_master_data` in the previous question, so `prev_check`, `quest_prev`, and `quest_prev_status` are set appropriately
#Since this question also involves the reading in of data, `quest_check_read` is set to TRUE
test.results[2, ] <- private_grader("player_salary_data1", player_salary_data1, player_salary_data1_test,
status = "Part 1 Question 1b (Private)", var_status = "tib",
prev_check = TRUE, quest_prev = 1, quest_prev_status = "Part 1 Question 1a",
quest_check_read = TRUE, quest_num = 2, quest_pt = 5)
Example 2: Vectors
Consider the following questions from Starter Assignment 1.
Part 1: Numeric Object Type and Logical Operators
(Private Question) Assign number
1.45
to the variablenum_1
. Remember that the assignment operator in R is<-
.(Private Question) Assign number
5
to the variablenum_2
.
Assume each question is worth 1 point.
Then, the autograder code for this question should look like:
#Comparing the student's vector `num_1` with the answer key's `num_1_test`
#Since this question does not rely on another question, `prev_check` is set to `FALSE`
test.results[1, ] <- private_grader("num_1", num_1, num_1_test,
status = "Part 1 Question 1 (Private)", var_status = "vect",
prev_check = FALSE, quest_num = 1, quest_pt = 1)
#Comparing the student's vector `num_2` with the answer key's `num_2_test`
#`prev_check` is set similarly
test.results[2, ] <- private_grader("num_2", num_2, num_2_test,
status = "Part 1 Question 2 (Private)", var_status = "vect",
prev_check = FALSE, quest_num = 2, quest_pt = 1)
Example 3: Lists
Consider the following questions from Homework 7.
Part 1: Coding Assignment
(Private Question) Using
crimeData
, create a table calledage_bin_by_crime_percentages
that shows what percent of crime experienced by each age bin that is violent or nonviolent. Your table should have a column each for violent and nonviolent crimes and a row for each age bin as well as a row for the total across all age bins.(Private Question) Using
crimeData
, create a table calledcrime_by_age_bin_percentages
that shows the percent of violent and nonviolent crimes that occurred in each age bin. Your table should have a column for each age bin and a row each for violent and nonviolent crimes. You should also have a row for the total for each age bin.
Assume each question is worth 10 points and that crimeData
was created in Question 6.
Then, the autograder code for these questions should look:
#Note: Tables (especially those created with `janitor::tabyl()`) should be classified as lists ("lst") when using `private_grader()`
#Comparing the student's list `age_bin_by_crime_percentages` with the answer key's `age_bin_by_crime_percentages_test`
#Since this question relies on `crimeData` being correct, `prev_check` and `quest_prev` are set appropriately (`quest_prev_status` is omitted)
test.results[8, ] <- private_grader("age_bin_by_crime_percentages", age_bin_by_crime_percentages, age_bin_by_crime_percentages_test,
status = "Part 1 Question 8 (Private)", var_status = "lst",
prev_check = TRUE, quest_num = 8, quest_pt = 10, quest_prev = 6)
#Comparing the student's list `crime_by_age_bin_percentages` with the answer key's `crime_by_age_bin_percentages_test`
#`prev_check` and `quest_prev` are set appropriately (`quest_prev_status` is omitted)
test.results[9, ] <- private_grader("crime_by_age_bin_percentages", crime_by_age_bin_percentages, crime_by_age_bin_percentages_test,
status = "Part 1 Question 9 (Private)", var_status = "lst",
prev_check = TRUE, quest_num = 9, quest_pt = 10, quest_prev = 6)
Example 4: Plots
Background
Previously in ECON 145, plots have not been rigorously graded by the autograder due to the desire to award credit to a wide range of students’ plots that closely resemble, but are not identical to, the solution.
Accordingly,
private_grader()
only performs the Prerequisite Check and Name Check when grading plots. If the student’s plot bypasses these Checks, full credit is awarded. Afterwards, plots are manually graded by the TAs in the students’ write-ups.ggplot_grader()
was made in an attempt to provide some level of Checks and feedback for plots created through theggplot2
package. Seeggplot_grader()
for details.
Now consider the hypothetical homework question:
Part 1: Coding Assignment
- (Private Question) Using
basketball_data
from Question 1, create a scatter plot of points (pt
) versus assists (ast
). Save the plot asbasketball_scatter
.
Assume this question is worth 5 points.
Then, the autograder code for this question should look like:
#Comparing the student's plot `basketball_scatter` with the answer key's `basketball_scatter_test`
#Since this question relies on `basketball_data` being correct, `prev_check` and `quest_prev` are set appropriately (`quest_prev_status` is omitted)
test.results[2, ] <- private_grader("basketball_scatter", basketball_scatter, basketball_scatter_test,
status = "Part 1 Question 2 (Private)", var_status = "plt",
prev_check = TRUE, quest_num = 2, quest_pt = 5, quest_prev = 1)
While manipulation of the default parameters can allow
private_grader()
to be implemented with fewer explicit inputs, it is recommended to explicitly define at least the parameters included in these examples for clarity and consistency.↩︎