Skip to content

Commit

Permalink
Merge pull request #19 from ucbds-infra/fix-rmd-pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles authored Jan 26, 2023
2 parents 8ad4544 + 3c9e8d5 commit 67bf57b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

**v1.3.1:**

* Fixed bug in generating PDFs of RMarkdown files in `ottr::export`

**v1.3.0:**

* Added support for exporting PDFs in zip files created by `ottr:export`

**v1.2.0:**

* Refactored structure of the package
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ottr
Title: An R Autograding Extension for Otter-Grader
Version: 1.3.0
Version: 1.3.1
Authors@R: c(
person(given = "Christopher",
family = "Pyles",
Expand All @@ -16,7 +16,7 @@ Description:
License: BSD_3_clause + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
Depends:
R (>= 4.0.0)
Imports:
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export(check)
export(export)
export(run_autograder)
export(valid_syntax)
importFrom(R6,R6Class)
importFrom(jsonlite,toJSON)
2 changes: 2 additions & 0 deletions R/GradingResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ GradingResults <- R6::R6Class(

#' @description Export these results to a JSON string.
#'
#' @importFrom jsonlite toJSON
#'
#' @return The JSON string
to_json = function() {
return(jsonlite::toJSON(self$to_list(), auto_unbox = TRUE, pretty = TRUE, null = "null"))
Expand Down
2 changes: 2 additions & 0 deletions R/TestCase.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#' @field success_message A message to show to students if the test passes
#' @field failure_message A message to show to students if the test fails
#'
#' @importFrom R6 R6Class
#'
#' @export
#'
#' @examples
Expand Down
4 changes: 2 additions & 2 deletions R/export.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export <- function(submission_path, export_path = NULL, display_link = TRUE, pdf
readLines(submission_path))
writeLines(contents, new_subm_path)

rmarkdown::render(new_subm_path, "pdf_document", pdf_path)
rmarkdown::render(new_subm_path, "pdf_document", pdf_path, dirname(submission_path))
file.remove(new_subm_path)
} else {
stop("Only Rmd and ipynb files can be converted to PDFs")
Expand All @@ -63,7 +63,7 @@ export <- function(submission_path, export_path = NULL, display_link = TRUE, pdf

file.remove(zip_filename_file_name)

if (display_link) {
if (display_link && Sys.getenv("RSTUDIO") != "1") {
IRdisplay::display_html(sprintf("
<p>Your submission has been exported. Click <a href='%s' download='%s'
target='_blank'>here</a> to download the zip file.</p>
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_export.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@ test_that("supports PDF exports for Rmd files", {

# check that IRdisplay::display_html was called
expect_called(mock_render, 1)
expect_args(mock_render, 1, tempfile_path, "pdf_document", pdf_path)
expect_args(mock_render, 1, tempfile_path, "pdf_document", pdf_path, dirname(subm_path))
})

0 comments on commit 67bf57b

Please sign in to comment.