::install_github("tpemartin/rmdgrader", force=T) devtools
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.
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
<- "https://drive.google.com/drive/u/0/folders/1lO5s1qeGacUVE4y0hCDaHAr0-n0n6lljKEpDTsKsI9S90jNXRBvRZOV4jHgVtqhGBzy4u3Kn"
gd_url # the title of the Google classroom assignment
= "midterm"
title# local path to save the downloads
= "MIDTERM/submissions"
path
# import class roster: Must contain "學號" column and a column represents student's Google classroom login email.
<- readRDS("/Users/martinl/Github/110-1-r4ds-management/rosterComplete.rds")
roster # specify the column that can identify students google classroom login email
="Google classroom login email (Primary one only)"
colname_googleClassLogin
|>
roster[[colname_googleClassLogin]] tolower() -> roster[[colname_googleClassLogin]]
<- rmdgrader::Download(title, path)
download $get_courseWork(gd_url, roster, colname_googleClassLogin)
download# download all
$courseWork$download(overwrite = T) download
title-studentIds.Rmd
# download one
$courseWork$download(validSchoolIds=410872134, overwrite = T)
download$courseWork$download(validSchoolIds=411073129, overwrite = T)
download#
$courseWork$download(validSchoolIds=411073126, overwrite = T) download
library(rmdgrader)
library(purrr)
library(dplyr)
<- rmdgrader::Process2(
process ansRmd="/Users/martinl/Github/110-1-r4ds-management/midterm-ans.Rmd",
path_studentRmds = "MIDTERM/submissions"
)$correctAnsFilename$tryGet_list_codeChunks()
process$inBatch_studentsRmds$tryGet_list_codeChunks()
process
# saved the process stage result
$export(path="MIDTERM") process
library(rmdgrader)
<- readRDS("MIDTERM/processed.Rds")
processed <- rmdgrader::Evaluate(processed)
ev # For each part of the ans.Rmd, you can resolve for answer objects for grading later
$answerValues$batch$resolve$part1()
ev# save the evaluation stage result
$save("MIDTERM/evaluated.Rdata") ev
load("MIDTERM/evaluated.Rdata")
library(rmdgrader)
library(purrr)
library(dplyr)
= readRDS("MIDTERM/processed.Rds")
process <- allequalService2(process, path="MIDTERM/submissions") ae
ae
contains all the comparison results, which are grouped and can be checked by# For ans11, check Group 1 comparison result
$ans11$check_messageGroups$G1() ae
# if given 5 points
$ans11$check_messageGroups$G1grade$grade(5) ae
$ans11$check_messageGroups$G1grade$comment("your comment") ae
If want ot bring out some student’s code in a group:
$ans11$code$`midterm-410872134.Rmd`() ae
After settling down with ans11
grading, save the grade by:
$save_grade$ans11() ae
$grades$ans11 ae
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)
= readRDS("/Users/martinl/Github/110-1-r4ds-management/MIDTERM/grades.Rds")
df_grades # 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
="MIDTERM/submissions"
path<- rmdgrader::Synthesize(df_grades, mapping, path)
syn # synthesize all Rmds
$all()
syn# synthesize one Rmd
$individual$`midterm-410872134.Rmd`() syn