Submission Correctness Tests (SCTs)
Though they are not your responsibility, Submission Correctness Tests (SCTs) are integral to DataCamp. They allow for robust checking of learner-submitted answers against the provided solution code.
For example, this SCT checks mean_vec
robustly using check_correct()
.
ex() %>% check_correct(
check_object(., "mean_vec") %>% check_equal(),
check_function(., "mean") %>%
check_args("x") %>% check_equal()
)
It first checks if mean_vec
is correct using check_object()
. If it isn't, it digs deeper and checks that mean()
was called, then checks the x
argument of mean()
. If at any point the learner submission is incorrect, learners see feedback messages that help guide them to fix the exercise.
Let's check out how this SCT works.
Note: The instructions and hint in this exercise give you the final answer explicitly. This is not allowed in normal DataCamp courses!
This exercise is part of the course
Course Creation at DataCamp
Exercise instructions
- Play around with passing different numbers in the call to
mean()
. You'll fail the exercise, but it will give you a chance to see the different feedback messages. Be sure to add commas between the numbers & enter them as a vector usingc()
:mean(c(1, 2, 3))
. - Delete the call to
mean()
to see other SCT messages. Play around with other erroneous code. - Once you've tried a few incorrect answers, enter the vector of numbers
c(10, 20, 30, 40, 50)
intomean()
to pass the exercise.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Find the mean of the vector
mean_vec <- mean(___)