knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval=F )
devtools::install_github("tpemartin/rmdgrader", force=T)
library(rmdgrader)
rmdgrader is a package that works with Google classroom and Google drive. It consists of:
Exam Rmd template: The template to follow for rmdgrader to work.
Download: Download student's Rmd file submission from a Google Drive folder
Process: Extract Rmd code lines and restructure them according to questions
Evaluate: Generate answer value objects for grading purpose.
Grading: The stage of comparing students' answer value with correct answer value, and assigning grade by grouped comparing results.
Sythesize: Adding student's grading result to his Rmd file for returning.
Inspection: Manually inspect student's synthesized Rmd, change its grade and update grade
File > New File > R Markdown...
Click From Template, select Exam Rmd, click OK.
Design your exam with answers and save the file as XXXX - ans.Rmd
. Then from Addins > extract exercise Rmd from ans Rmd, it will generate an XXXX.Rmd
that has the same Rmd content as ans.Rmd
but with all the content inside ansXXX
code chunk cleaned. XXXX.Rmd
will be the file instructor distribute to students during the exam.
library(rmdgrader) library(dplyr) # the google drive url with students' submissions gd_url <- "https://drive.google.com/drive/u/0/folders/1lO5s1qeGacUVE4y0hCDaHAr0-n0n6lljKEpDTsKsI9S90jNXRBvRZOV4jHgVtqhGBzy4u3Kn" # the title of the Google classroom assignment title= "midterm" # local path to save the downloads path= "MIDTERM/submissions" # import class roster: Must contain "學號" column and a column represents student's Google classroom login email. roster <- readRDS("/Users/martinl/Github/110-1-r4ds-management/rosterComplete.rds") # specify the column that can identify students google classroom login email colname_googleClassLogin="Google classroom login email (Primary one only)" roster[[colname_googleClassLogin]] |> tolower() -> roster[[colname_googleClassLogin]] download <- rmdgrader::Download(title, path) download$get_courseWork(gd_url, roster, colname_googleClassLogin) # download all download$courseWork$download(overwrite = T)
title-studentIds.Rmd
# download one download$courseWork$download(validSchoolIds=410872134, overwrite = T) download$courseWork$download(validSchoolIds=411073129, overwrite = T) # download$courseWork$download(validSchoolIds=411073126, overwrite = T)
library(rmdgrader) library(purrr) library(dplyr) process <- rmdgrader::Process2( ansRmd="/Users/martinl/Github/110-1-r4ds-management/midterm-ans.Rmd", path_studentRmds = "MIDTERM/submissions" ) process$correctAnsFilename$tryGet_list_codeChunks() process$inBatch_studentsRmds$tryGet_list_codeChunks() # saved the process stage result process$export(path="MIDTERM")
library(rmdgrader) processed <- readRDS("MIDTERM/processed.Rds") ev <- rmdgrader::Evaluate(processed) # For each part of the ans.Rmd, you can resolve for answer objects for grading later ev$answerValues$batch$resolve$part1() # save the evaluation stage result ev$save("MIDTERM/evaluated.Rdata")
load("MIDTERM/evaluated.Rdata") library(rmdgrader) library(purrr) library(dplyr) process = readRDS("MIDTERM/processed.Rds") ae <- allequalService2(process, path="MIDTERM/submissions")
ae
contains all the comparison results, which are grouped and can be checked by# For ans11, check Group 1 comparison result ae$ans11$check_messageGroups$G1()
# if given 5 points ae$ans11$check_messageGroups$G1grade$grade(5)
ae$ans11$check_messageGroups$G1grade$comment("your comment")
If want ot bring out some student's code in a group:
ae$ans11$code$G1$`midterm-410872134.Rmd`()
After settling down with ans11
grading, save the grade by:
ae$save_grade$ans11()
ae$grades$ans11
The above process needs to be done for all ans
.
This is a stage to add student grade to student's Rmd file for returning purpose.
library(rmdgrader) df_grades = readRDS("/Users/martinl/Github/110-1-r4ds-management/MIDTERM/grades.Rds") # define the mapping between each ansXXX and its Rmd header. list(ans11="## 1.1", ans12="## 1.2", ans13="## 1.3", ans14="## 1.4", ans15="## 1.5") -> mapping path="MIDTERM/submissions" syn <- rmdgrader::Synthesize(df_grades, mapping, path) # synthesize all Rmds syn$all() # synthesize one Rmd syn$individual$`midterm-410872134.Rmd`()
rmdgrader::Inspect(path)
to initiate an inspect instance. Make sure the global environment has df_grades
in it.library(rmdgrader) df_grades = readRDS("/Users/martinl/Github/110-1-r4ds-management/MIDTERM/grades.Rds") path="MIDTERM/submissions2" isp <- rmdgrader::Inspect(path)
Use the following to file.edit the first Rmd
isp$file.edit$`Finalexam-410872134.Rmd`()
Use the following to file.edit the next Rmd, continue to use $file.edit_next()
for the next Rmd, $file.edit_previous()
to go back:
isp$file.edit_next()
df_grades
Use the following method to update the df_grades row corresponding to the Rmd file:
isp$update_grade$`Finalexam-410872134.Rmd`()
saveRDS(df_grades, file="/Users/martinl/Github/110-1-r4ds-management/MIDTERM/grades.Rds")
source("support/main.R") source("support/midterm.R") library(rmdgrader) library(dplyr) gd_url <- "https://drive.google.com/drive/folders/1BbD2wbI4gK-14ViZnbeu5dQGTctchdSQCjD-AzcbGfmzBDeT-9poom_nOjwjtF7wcu--yOk0" title= "Final exam" # title of google class assignment path= "FINAL/submissions" # the local folder to download student turn ins. roster <- readRDS("rosterComplete.rds") colname_googleClassLogin="Google classroom login email (Primary one only)" roster[[colname_googleClassLogin]] |> tolower() -> roster[[colname_googleClassLogin]] # undebug(rmdgrader::Download) download <- rmdgrader::Download(title, path) download$get_courseWork(gd_url, roster, colname_googleClassLogin)
rt <- rmdgrader::Return2( path="FINAL/submissions2", download=download ) rt$return_all()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.