DM.studentTyped: Test whether user code contains a certain string

Description Usage Arguments Value Examples

View source: R/DM.studentTyped.R

Description

Returns either FALSE in case the student didn't type the string, or the number of occurrences in the code. Thus, it is a simple wrapper function for regexes. White spaces are ignored, as well as ";", as well as new lines. Furthermore, the function ignores whether a student uses "=" or "<-" for assignment.

Usage

1
DM.studentTyped(string, user.code=DM.user.code)

Arguments

string

String to look for in the students code.

user.code

The students code as character. By default set to DM.user.code which will contain the students code when the SCT starts.

Value

Either FALSE, either the number of occurences of the string (or something very similar to that string) in the students code.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
DM.user.code <- '
x <- 1:10
mean(x,y=blablaY,z=blablaZ);sum(x)
sapply(x,FUN=sum)
mean(x2=2,y2=3)
'

# Check the student code:
DM.studentTyped("x <- 1:10") #1: Exactly as typed by the student.
DM.studentTyped("x<-1:10;") #1: Not exactly as typed by the student.
DM.studentTyped("x<-5:10;") #FALSE: Mistake by student.
DM.studentTyped("mean") #2: Multiple occurrences.

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