DM.closedTest: Test whether variables are equal to pre-specified values and...

Description Usage Arguments Value Examples

View source: R/DM.closedTest.R

Description

Function takes a number of (variable) names as input for which it checks whether they are equal to the supplied values. It then return feedback that can be used as the output of the SCT (Submission Correctness Test).

Usage

1
DM.closedTest( names=NULL, values=NULL, check.existence=NULL)

Arguments

names

Character vector or list with the names of the variables for which you would like their values.

values

Character vector or list with the values the corresponding variables should have. It should have the same length as the names vector obviously.

check.existence

Vector having same length as names and values containing boolean values, which indicate whether the existence in the users workspace of "names" element i should be checked. Typically (and by default) TRUE in case names element "i" is just a variable, but can be FALSE in case names element "i" is actually an expression, not a variable name, for example "names(some.vector)"

Value

The output of this function indicates the correctness of the Test. It can either boolean or a list. In the former case, TRUE/FALSE indicates whether variables have the expected values. In the latter case, the first list-component is TRUE/FALSE indicating the result of the test, whereas the second element contains the text with feedback that should be provided to the student.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# At first, the student typs his code: He needs to assign 4 variables:
a <- "Closed Test Example"
b <- c(1,2,3)
c <- matrix(1:9)
d <- list(name1=3, name2=4)

# Closed Submission Correctness Test as stipulated by the course creator!
names <- c("a","b","c","d")
values <- c("c('Closed Test Example')","c(1,2,3)","matrix(1:9)","list(name1=3,name2=4)")
DM.result <- DM.closedTest(names,values)
DM.result #Everyting the student typed is correct, so it returns TRUE

#Suppose the student forgets to name the list correctly
d <- list(3,4) 
DM.result <- DM.closedTest(names,values)
DM.result #This is picked up correctly by the Submission Correctness Test ;-)

d <- list(name1=3, name2=4) # Correct again
c <- "mistake" # Student makes another mistake...
DM.result <- DM.closedTest(names,values)
DM.result #This is picked up correctly by the Submission Correctness Test ;-), 
#DM.closedTest returns FALSE and then a message to help the student improve his answer

jonathancornelissen/DM documentation built on May 19, 2019, 7:27 p.m.