Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get timelimit from complete exercise object #494

Merged
merged 3 commits into from
Feb 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions R/exercise.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ setup_exercise_handler <- function(exercise_rx, session) {
# observe input
observeEvent(exercise_rx(), {

# get exercise
# get exercise from app
exercise <- exercise_rx()

# short circuit for restore (we restore some outputs like errors so that
Expand All @@ -39,11 +39,6 @@ setup_exercise_handler <- function(exercise_rx, session) {
}
}

# get timelimit option (either from chunk option or from global option)
timelimit <- exercise$options$exercise.timelimit
if (is.null(timelimit))
timelimit <- getOption("tutorial.exercise.timelimit", default = 30)

# get exercise evaluator factory function (allow replacement via global option)
evaluator_factory <- getOption("tutorial.exercise.evaluator", default = NULL)
if (is.null(evaluator_factory)) {
Expand All @@ -67,6 +62,7 @@ setup_exercise_handler <- function(exercise_rx, session) {
exercise <- append(exercise, get_exercise_cache(exercise$label))
# If there is no locally defined error check code, look for globally defined error check option
exercise$error_check <- exercise$error_check %||% exercise$options$exercise.error.check.code

if (!isTRUE(exercise$should_check)) {
exercise$check <- NULL
exercise$code_check <- NULL
Expand All @@ -75,6 +71,11 @@ setup_exercise_handler <- function(exercise_rx, session) {
# variable has now served its purpose so remove it
exercise$should_check <- NULL

# get timelimit option (either from chunk option or from global option)
timelimit <- exercise$options$exercise.timelimit
if (is.null(timelimit))
timelimit <- getOption("tutorial.exercise.timelimit", default = 30)

# placeholder for current learnr version to deal with exercise structure differences
# with other learnr versions
exercise$version <- "1"
Expand Down