The goal of pli
is to provide an interface to PrairieLearn’s API
endpoints. By
providing a bridge to the endpoints, we can quickly import assessment
data into R and perform psychometric analyses. Moreover, the data can
automatically be moved between PrairieLearn and LMS systems that do not
yet have an LTI connection available. (Looking at you
Canvas.)
You can install the released version of pli
only from
GitHub with:
if(!requireNamespace("devtools")) { install.packages("devtools") }
devtools::install_github("illinois-r/pli")
Prior to using pli
, a personal access token (PAT) must be created on
PrairieLearn’s production server.
https://prairielearn.engr.illinois.edu/pl/settings
Once on the page, press “(+) Generate New Token.” The token will only be
displayed once. Please make sure to copy the token. For pli
to know
about the token, please include it in ~/.Renviron
file as
PRAIRIELEARN_API_TOKEN
.
First, open the ~/.Renviron
file by typing in R:
usethis::edit_r_environ()
Second, within the file, add the following line:
PRAIRIELEARN_API_TOKEN="<your-token-here>"
Subsitute <your-token-here>
with the token that was generated.
(Note: Make sure to remove <>
.)
Third, save the file and restart R for the changes to take effect.
The package supports downloading data from the following endpoints:
Function | Description |
---|---|
pl_course_gradebook() |
Gradebook |
pl_assessment_list() |
List of all assessments in course |
pl_assessment_view() |
View a single assessment in course |
pl_assessment_instance_list() |
List of all instances underneath a specific assessment |
pl_assessment_instance_view() |
View a single student instances of an assessment |
pl_assessment_submission_list() |
List of all submission underneath a specific assessment |
pl_assessment_submission_view() |
View a single student submission |
Login in to PrairieLearn and select the course you wish to obtain information from. The course instance number for this course can be obtained by looking at the URL for the class:
https://prairielearn.engr.illinois.edu/pl/course_instance/54777/instructor/instance_admin/assessments
In this case, the course instance number would be 54777
. With this in
hand, let’s query the grade book:
library(pli)
course_instance_id = 54777
## Gradebook Manipulations ----
# Download the entire gradebook
grades = pl_course_gradebook(course_instance_id)
# Format for a single assessment to Compass2g
library(tidyverse)
grades %>%
filter(assessment_id == 1228980) %>%
select(user_uid, points) %>%
mutate(
points = replace_na(points, 0),
user_uid = gsub("@.*","", user_uid)
) %>%
write_csv("grades-quiz1.csv")
## Specific assessment manipulation ----
# Get an overview of all assessments
assessments = pl_assessment_list(course_instance_id)
# Retrieve scores for that instance
quiz_1 = pl_assessment_instance_list(course_instance_id, 1228980)
# Export to Compass2g
grade_format_compass2g(quiz_1, "quiz1-stat486.csv")
James Joseph Balamuta
GPL (>= 2)