generated from jhudsl/OTTR_Template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔄 Created local 'scripts/quiz-check.R' from remote 'scripts/quiz-chec…
…k.R' release-null
- Loading branch information
jhudsl-robot
committed
Apr 5, 2022
1 parent
cd68b40
commit 4a583dd
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env Rscript | ||
|
||
# Adapted for this jhudsl repository by Candace Savonen Mar 2022 | ||
|
||
# Run spell check and save results | ||
|
||
library(magrittr) | ||
|
||
# Find .git root directory | ||
root_dir <- rprojroot::find_root(rprojroot::has_dir(".git")) | ||
|
||
output_file <- file.path(root_dir, 'check_reports', 'question_error_report.tsv') | ||
|
||
if (!dir.exists('check_reports')) { | ||
dir.create('check_reports') | ||
} | ||
|
||
ottrpal::check_quizzes(quiz_dir = file.path(root_dir, 'quizzes'), write_report = TRUE, verbose = TRUE) | ||
|
||
if (file.exists("question_error_report.tsv")) { | ||
quiz_errors <- readr::read_tsv("question_error_report.tsv") | ||
|
||
file.copy('question_error_report.tsv', file.path(root_dir, 'check_reports')) | ||
file.remove('question_error_report.tsv') | ||
|
||
# Print out how many quiz check errors | ||
write(nrow(quiz_errors), stdout()) | ||
|
||
} else { | ||
quiz_errors <- data.frame(errors = NA) | ||
|
||
# Print out how many quiz check errors | ||
write("1", stdout()) | ||
} | ||
|
||
# Save question errors to file | ||
readr::write_tsv(quiz_errors, output_file) | ||
|
||
message(paste0("Saved to: ", output_file)) |