Type: Package
Title: Automatic Marking of R Assignments
Version: 0.8.8
Author: Mans Magnusson, Oscar Pettersson
Maintainer: Mans Magnusson <mons.magnusson@gmail.com>
Description: Automatic marking of R assignments for students and teachers based on 'testthat' test suites.
License: BSD_2_clause + file LICENSE
Encoding: UTF-8
Depends: R (≥ 3.6.0)
Imports: methods, yaml, testthat (≥ 2.0.0), httr (≥ 1.0.0), checkmate (≥ 1.0.0), codetools, rlang
RoxygenNote: 7.2.3
Suggests: covr, httptest, knitr, rmarkdown
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2024-01-28 15:07:16 UTC; manma760
Repository: CRAN
Date/Publication: 2024-01-29 09:20:06 UTC

Assert a assignment_config object.

Description

Check assignment yml file that it is a correct assignment file.

Usage

assert_assignment_config(assignment)

Arguments

assignment

object to test.

Value

a checked assignment_config object.


Constructor for assignment_config object

Description

Constructor for assignment_config object.

Usage

assignment_config(x)

Arguments

x

a list to convert to a assignment_config object.


Get assignment paths and files

Description

Get assignment paths and files

Usage

assignment_paths_and_files(assignment = NULL)

Arguments

assignment

a assignment_config object.


Check whether required packages are installed and loaded.

Description

Checks if the packages listed in assignment file are loaded and installed. If not, a warning message is printed.

Usage

check_installed_packages(assignment)

Arguments

assignment

assignment_config to check packages for.


Cheer when all tasks pass

Description

Cheer when all tasks pass

Usage

cheer()

Construct assignment description

Description

Construct assignment description

Usage

construct_assignment_description(assignment = NULL)

Arguments

assignment

an assignment to create description for.


Create a github_download_url from a path_github object.

Description

Create a github_download_url from a path_github object.

Usage

create_github_download_url(path)

Arguments

path

a path_github object.


Checks and deletes circular calls

Description

Checks and deletes circular calls

Usage

delete_circular_calls(mark_file)

Arguments

mark_file

File to check

Value

Character vector of the possibly changed mark file


Functions to create directories

Description

Functions to create directories

Usage

mark_my_base_dir()

mark_my_assignment_dir(no = 1)

mark_my_tasks_dir(...)

mark_my_run_code_dir(...)

Arguments

no

assignment number

...

to send to mark_my_assignment_dir


Download assignment and store in temporary folder

Description

Downloads the test files for the current assignment and save them to temp directory.

Usage

download_assignment(assignment, path)

Expect that a given package is used

Description

Tests that the following packages is used.

Usage

expect_attached_package(pkg, info = NULL)

Arguments

pkg

Package to check for.

info

Deprecated.


Expect function arguments

Description

Test that an function object has a function with given arguments.

Usage

expect_function_arguments(
  object,
  expected,
  info = NULL,
  label = NULL,
  expected.label = NULL
)

Arguments

object

Function to check the arguments of.

expected

Expected arguments in function.

info

Deprecated.

label

Additional information.

expected.label

Deprecated.


Expect function contain code

Description

Test that a given code string exists in function

Usage

expect_function_code(
  object,
  expected,
  info = NULL,
  label = NULL,
  expected.label = NULL
)

Arguments

object

Function to check for mandatory code

expected

Expected arguments in function.

info

Deprecated.

label

Additional information.

expected.label

Deprecated.


Expect that the tested function is self-contained

Description

Tests if a fuction is self-contained (i.e. do not use any global variables).

Usage

expect_function_self_contained(object, info = NULL, label = NULL)

Arguments

object

Function to test if it is self-contained.

info

Deprecated.

label

Additional information.


Expect that a forbidden package is not used/attached

Description

Tests that the following packages is not used.

Usage

expect_no_attached_forbidden_package(pkg)

Arguments

pkg

Package to check for.


Expect no forbidden function code

Description

Test that a given code string does not exists in function.

Usage

expect_no_forbidden_function_code(object, forbidden)

Arguments

object

Function to check for mandatory code

forbidden

Code string that are forbidden to use.


Depricated function: expect_package

Description

Function has been depricated and will be removed. Please use expect_attached_package instead.

Usage

expect_package(object, info = NULL, label = NULL)

Depricated function: expect_self_contained

Description

Function has been depricated and will be removed. Please use expect_function_self_contained instead.

Usage

expect_self_contained(object, info = NULL, label = NULL)

Forbidden functions for mark_my_file()

Description

Funcations that are removed prior to running mark_my_file(). The purpose is to avoid reinstalling packages, doing system calls or similar when checking a file.

Usage

forbidden_functions()

Get the full path from assignment paths

Description

The individual paths of assignmentfiles etc can be specified both in full and relative to the assignment file. This function computes the full path.

Usage

get_assignment_full_subpath(sub_path, path)

Arguments

sub_path

the url to compute the full path for.

path

the assignment path_type.


Get the file from the path

Description

Get/download the file from the path.

Usage

get_file(path, dest, ...)

## S3 method for class 'path_local'
get_file(path, dest, ...)

## S3 method for class 'path_http'
get_file(path, dest, ...)

## S3 method for class 'path_github'
get_file(path, dest, ...)

Arguments

path

Path object

dest

Destination for the file

...

Further arguments to send to httr::GET().


Get github information from a github path

Description

Get github information from a github path

Usage

get_github_path_info(path)

Arguments

path

a path to check

Value

a list


Check if a path is from github

Description

Check if a path is from github

Usage

is_github_path(path)

Arguments

path

a path to check

Value

a bool that is named raw, http or api if a github path.


Mark assignment in global environment

Description

Mark assignment in global environment.

Usage

mark_my_assignment(
  tasks = NULL,
  mark_file = NULL,
  force_get_tests = FALSE,
  quiet = FALSE,
  ...
)

Arguments

tasks

Which task should be corrected (if more than one). Default is all. To see the different task, see show_tasks.

mark_file

Argument is deprecated, use mark_my_file instead.

force_get_tests

Argument is deprecated, use set_assignment() instead.

quiet

Should test be run without output?

...

further arguments sent to test_dir().

Examples

assignment_path <- 
  file.path(system.file(package = "markmyassignment"), "extdata", "example_assignment01.yml")
set_assignment(assignment_path)
source(file.path(system.file(package = "markmyassignment"), "extdata", "example_lab_file.R"))
mark_my_assignment()


Mark assignments in a directory

Description

Marks assignments in a directory. Stores the results.

Usage

mark_my_dir(
  directory,
  tasks = NULL,
  assignment_path = NULL,
  force_get_tests = FALSE,
  quiet = FALSE,
  ...
)

Arguments

directory

Directory with assignments files.

tasks

Which task should be corrected (if more than one). Default is all. To see the different task, see show_tasks.

assignment_path

Assignment file to set before marking the assignment (url or local path).

force_get_tests

Argument is deprecated, use set_assignment() instead.

quiet

Should test be run without output?

...

further arguments sent to test_dir().


Mark assignment file

Description

Mark a specific assignment file

Usage

mark_my_file(
  tasks = NULL,
  mark_file = file.choose(),
  assignment_path = NULL,
  force_get_tests = FALSE,
  quiet = FALSE,
  ...
)

Arguments

tasks

Which task should be corrected (if more than one). Default is all. To see the different task, see show_tasks.

mark_file

Path to the file to mark.

assignment_path

Assignment file to set before marking the assignment (url or local path).

force_get_tests

Argument is deprecated, use set_assignment() instead.

quiet

Should test be run without output?

...

further arguments sent to test_dir().

Examples

## Not run: 
assignment_path <- 
  file.path(system.file(package = "markmyassignment"), "extdata", "example_assignment01.yml")
file_path <- file.path(system.file(package = "markmyassignment"), "extdata", "example_lab_file.R")
mark_my_file(mark_file = file_path, assignment_path = assignment_path)

## End(Not run)

Automatic Marking of R Assignments

Description

Automatic marking of R assignments for students and teachers based on testthat test suites.


Get the path type.

Description

Check the path type.

Usage

path_type(path, auth = NULL)

Arguments

path

Character element of url or local search path.

auth

an auth request class with options httpauth and userpwd.

Value

path_type object with c("path_local", "path_http", "path_error")


Read assignment information

Description

Check if there exist an assignmentfile and then load it.

Usage

read_assignment_yml(yml_path = NULL)

Arguments

yml_path

path object from path_type

Value

assignment object


Run test suite

Description

Runs test on the tasks. Always run mandatory tests.

Usage

run_test_suite(caller, tasks = NULL, mark_file = NULL, quiet = FALSE, ...)

Arguments

caller

Either "mark_my_assignment" or "mark_my_file"

tasks

Which task should be tested

mark_file

Run tests on a R-file. Default is NULL means global environment.

quiet

Should the output be supressed (only returning test results)

...

further arguments sent to test_dir().

Value

test_suite results


Set and remove assignments

Description

Sets the assignment to mark and downloads necessary files.

Usage

set_assignment(path, auth = NULL)

remove_assignment()

is_assignment_set()

show_assignment()

Arguments

path

Path to the yml file

auth

Authorization object generated by httr::authenticate(). See authenticate and https://github.com/r-lib/httr/blob/master/demo/oauth2-github.r on details on how to use authenticate().

Examples

assignment_path <- 
  file.path(system.file(package = "markmyassignment"), 
            "/extdata/example_assignment01.yml")
set_assignment(assignment_path)


Get the name of the tasks in the assignment.

Description

Get the name of the tasks in the assignment.

Usage

show_tasks()

Examples

# We first set the assignment
assignment_path <- 
 file.path(system.file(package = "markmyassignment"), "extdata/example_assignment01.yml")
set_assignment(assignment_path)
 
show_tasks()


Check and create folder if missing.

Description

Checks if markmyassignment folder exist in R temp directory. If not, the folder is created.

Usage

temp_folder_check_create()

Get task file name from task names

Description

Get task file name from task names

Usage

translate_tasks_name_to_task_files(tasks)

Arguments

tasks

task names in assignment


Read assignment information

Description

Check if there exist an assignmentfile and then load it.

Usage

write_assignment_yml(assignment, yml_path)

Arguments

assignment

a assignment_config object to write

yml_path

a path to write yml file to