testwhat (version 4.2.2)

test_an_object: Check if the student defined an object, independent of the name

Description

This function is an adaption of test_object. The function will check if a specific object, defined in the solution, exists. The object the student defined doesn't have to have the same name. In other words, this function will check if any defined variable by the user corresponds to a specific variable in the solution code.

Usage

test_an_object(name, undefined_msg = NULL, eq_condition = "equivalent")

Arguments

name
name of object in solution to test.
undefined_msg
feedback message in case the student did not define an object that corresponds to the solution object. This argument should always be specified.
eq_condition
character string indicating how to compare. See is_equal.

Examples

Run this code
## Not run: 
# # Example 1 solution code:
# # x <- 5
# 
# # sct command to test whether student defined _an_ object with same value
# test_an_object("x")
# 
# # All of the following student submissions are accepted
# # x <- 5
# # y <- 5
# # z <- 4 + 1 + 1e-8
# ## End(Not run)

Run the code above in your browser using DataLab