The markmyassignment
package is a tool to for teachers
to set up testthat test suites for R programming labs or exams.
The package is a wrapper for testthat
test suites and a
single assignment yml file online govern a lab or an exam. Students set
the assignment they want to work with using
set_assignment()
. Then all test suites and assignment
information are downloaded and stored in the tempdir()
folder of the current R session. The students can then easily test their
assignments with the function mark_my_assignment()
or
mark_my_file()
.
markmyassignment
makes it easy for students to get
automatic feedback on their lab assignments (or exams) with very limited
overhead. The only thing the students need are: - an URL to the
assignment yml file online or locally, - internet connection and -
markmyassignment
installed on their local computer.
The main purpose of the package is two-fold. First, making it possible for students to test their own assignments improve the learning since a good test suite guides the students toward problems in their code. The package also considerably speeds up the time it takes to correct labs for teachers.
The package has been used at Linkoping University, Sweden, since 2013 in multiple R courses (advanced and beginners courses). The package has been very popular among students.
The easiest way to install the package in R is as follows:
All documentation of the package and the functionality can be found using:
See the students vignette for markmyassignment here or in R:
To use markmyassignment
in a course, the following steps
are needed.
testthat
for
tasks in the labThe first step is to create a lab. =) Then produce unit tests using
the testthat
package for the assignments the students
should turn in.
If the task is to create a numeric vector with the values
pi
and e
an example test file can be found here.
In a similar way, one or more mandatory test files can be used for
testing of the overall lab file. One example is that there can be
mandatory for students to supply a character element name
the students name. An example test file can be found here.
The next step is to put all tasks together to a full assignment. This
is a collection of test files and mandatory test files. The assignment
files is in yaml format and consists of
the root nodes name
(assignment name),
description
(assignment description), tasks
(tasks in assignments as separate nodes) and mandatory
(optional, with URLs to mandatory test).
A working template with descriptions of each part can be found here. The assignment can be set with:
set_assignment("https://github.com/MansMeg/markmyassignment/blob/master/inst/extdata/assignment_template.yml")
Give the URL to the assignment file to the students.
See the students vignette for markmyassignment here or in R:
All solutions from the students can be collected and marked
automatically. The assignment to test needs to be set with
set_assignment()
. The mark_my_dir()
function
can then be used for the directory with the student solutions. The
function returns a data.frame
with one row per unit test
file and lab file. In this way, multiple files can be marked at the same
time. Of course, some manual check is needed as well.
In marking of student lab files there are some extra exceptions
included in markmyassignment
with the purpose of testing
student assignment. The included expectations are:
expect_attached_package
expect_function_arguments
expect_function_code
expect_function_self_contained
expect_no_attached_forbidden_package
expect_no_forbidden_function_code
expect_package
expect_self_contained
See the documentation for each function for further information and usage.
Since markmyassignment
is in essence just a wrapper for
testthat
, it is simple to choose your own argument for
test_dir()
using ...
in
mark_my_assignment()
. As an example, to use the testthat
summary reporter in testing the student assignment, just write:
It is possible to use basic authentication to access private http
URLs (for example to test assignments without making them public). This
is done by simply adding a httr
authentication to the
set_assignment()
function. Here is an example of how to use
a private repo on github: