Department of Econometrics and Business Statistics, Monash Business School
Department of Econometrics and Business Statistics, Monash Business School
search_ast()
and exists_in()
TeachR, and its predecessor Monash Learn R, include contributions from:
Support, Feedback and Assessment for Statistical Programming
Paiva, Leal, and Figueira (2022) provide a state-of-the-art review of automated assessment in computer science:
Testing techniques
Feedback generation
Challenges and Future Directions
Interactive Tutorials and Feedback:
In-Browser Code Execution:
Assessment Authoring Tools:
They are:
teachr
= quarto
+ webr
teachr
= quarto
+ webr
+ (✨stats & compsci pedagogy)
.printed
: printed objects.errored
: execution errors.warned
: execution warnings.messaged
: execution messages.src
: raw source code.code
: parsed code (i.e. abstract syntax tree).packages()
: Loaded packagesWhen assessing data analysis code it can be useful to examine multiple available objects
# Write some code to roll a dice
roll_a_dice <- <<function(){sample(1:6, size = 1L)}>>
# Then, roll the dice!
roll_a_dice()
???
old_seed <- .Random.seed
rolls <- sapply(seq_len(1000), function(x) roll_a_dice())
if(search_ast(.code, .expr = sample(size = 1))) {
cat("💡 It's better to use integers (size = 1L)
instead of numeric/double (size = 1)\n")
}
c(
"Your code should use the sample() function as shown in class." =
!search_ast(.code, .fn = sample),
"Your function should randomly select dice values." =
identical(old_seed, .Random.seed),
"Your function should return a single dice value." =
length(roll_a_dice()) != 1L,
"Your function should return an integer." = !is.integer(rolls),
"Your function returns dice numbers less than 1." = min(rolls) < 1L,
"Your function returns dice numbers more than 6." = max(rolls) > 6L,
"You should try your function!" =
!exists_in(.printed, is.integer) && !search_ast(.code, .fn = roll_a_dice)
)
cynthia.huang@monash.edu
!