2.2 What is test.results?
The autograder infrastructure has provided a test.results
data frame to store and display feedback from our Checks.
When writing autograder code for any question, we always first initialize the question’s default test.results
.
For example, to initialize Question 1’s test.results
, we write the following line:
#Testing Student's Question 1 Against Question 1 Solution
test.results[1, ] <- c("Part 1 Question 1 (Public)", 0, 20, "Try again.")
where each element of test.results[#, ]
is as follows:
Element | Description |
---|---|
1 | the question’s number |
“Part 1 Question 1 (Public)” | the question’s displayed part, number and type (Private/Public) |
0 | the question’s default score |
20 | the question’s maximum score |
“Try again.” | the default feedback message |
It is important to note that a question’s displayed number may differ from its question number, especially in the case of multi-part questions.
Recommendation: If students would greatly benefit from a very specific hint (e.g., using a certain function), you can include it in the default feedback message to ensure they see it in the case that none of the Checks trigger.
After initializing a question’s test.results[#, ]
, we can update it through indexing.
- For example, if the student’s Question 1 is correct, we can update
test.results[1, ]
to award them full score with the following line:
Similarly, we can modify the feedback message through the following line:
#Modifying the feedback message for Question 1
test.results[1, 4] <- "Insert feedback message here!"
Note:
For most of the sample code provided for Public Questions, we will be updating test.results[2, ]
(i.e., Question 2).