Description Usage Arguments Value Examples
Function checks whether the ouput of the argument expr can be found in the output of the student's console.
1 | output_contains( expr, console.output=DM.console.output )
|
expr |
The expression (as string) for which the output should be in the student's console. |
console.output |
The string containing the output printed to the student's console. By default this will be recorded in DM.console.output before the Submission Correctness Test starts, so the console.output argument here is by default also set to DM.console.output. |
TRUE when the student's console indeed contains the ouput you expect based on the given expression, FALSE otherwise.
1 2 3 4 5 6 7 8 9 10 11 12 | # Suppose the student has to type a loop that print the numbers 1 upto 10
# Smart student does exactly that and types:
DM.user.code = '
n<-10;
for(i in 1:n){print(i)};
'
# What student's console contains:
DM.console.output = paste(capture.output(eval(parse(text=DM.user.code))), collapse="")
# What the test tells us:
output_contains("for(i in 1:10){print(i)}")
# Suppose the student was supposed to loop upto 20:
output_contains("for(i in 1:20){print(i)}")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.