Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use student_identifier only to get files #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 38 additions & 26 deletions R/assist_grading-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ assist_grading <- function(
example_assignment_path,
example_feedback_path,
example_student_identifier,
missing_assignment_grade = NA
missing_assignment_grade = NA,
assignment_folder = NA,
number_assignment = 1 # default is that there is 1 assignment (that makes sense...)
) {

core_assist_grading(
Expand All @@ -61,7 +63,9 @@ assist_grading <- function(
questions_to_grade = "all",
students_to_grade = "all",
team_grading = FALSE,
github_issues = FALSE
github_issues = FALSE,
assignment_folder = assignment_folder,
number_assignment = number_assignment
)

}
Expand All @@ -71,17 +75,19 @@ assist_grading <- function(
#' @title Team assisted grading
#' @export
assist_team_grading <- function(
rubric_path,
roster_path,
grading_progress_log_path,
final_grade_sheet_path,
example_assignment_path,
example_feedback_path,
example_team_identifier,
missing_assignment_grade = NA,
questions_to_grade = "all",
teams_to_grade = "all",
github_issues = FALSE
rubric_path,
roster_path,
grading_progress_log_path,
final_grade_sheet_path,
example_assignment_path,
example_feedback_path,
example_team_identifier,
missing_assignment_grade = NA,
questions_to_grade = "all",
teams_to_grade = "all",
github_issues = FALSE,
assignment_folder = NA,
number_assignment = 1 # default is that there is 1 assignment (that makes sense...)
) {

core_assist_grading(
Expand All @@ -96,7 +102,9 @@ assist_team_grading <- function(
questions_to_grade = questions_to_grade,
students_to_grade = teams_to_grade,
team_grading = TRUE,
github_issues = github_issues
github_issues = github_issues,
assignment_folder = assignment_folder,
number_assignment = number_assignment
)
}

Expand All @@ -105,17 +113,19 @@ assist_team_grading <- function(
#' @title Advanced assisted grading
#' @export
assist_advanced_grading <- function(
rubric_path,
roster_path,
grading_progress_log_path,
final_grade_sheet_path,
example_assignment_path,
example_feedback_path,
example_student_identifier,
missing_assignment_grade = NA,
questions_to_grade = "all",
students_to_grade = "all",
github_issues = FALSE
rubric_path,
roster_path,
grading_progress_log_path,
final_grade_sheet_path,
example_assignment_path,
example_feedback_path,
example_student_identifier,
missing_assignment_grade = NA,
questions_to_grade = "all",
students_to_grade = "all",
github_issues = FALSE,
assignment_folder = NA,
number_assignment = 1 # default is that there is 1 assignment (that makes sense...)
) {

core_assist_grading(
Expand All @@ -130,7 +140,9 @@ assist_advanced_grading <- function(
questions_to_grade = questions_to_grade,
students_to_grade = students_to_grade,
team_grading = FALSE,
github_issues = github_issues
github_issues = github_issues,
assignment_folder = assignment_folder,
number_assignment = number_assignment
)

}
8 changes: 6 additions & 2 deletions R/core_assist_grading.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ core_assist_grading <- function(
questions_to_grade = "all",
students_to_grade = "all",
team_grading = FALSE,
github_issues = FALSE
github_issues = FALSE,
assignment_folder,
number_assignment
) {

# Check example_assignment_path is valid
Expand Down Expand Up @@ -150,7 +152,9 @@ core_assist_grading <- function(
example_student_identifier = example_student_identifier,
roster_path = roster_path,
github_issues = github_issues,
team_grading = team_grading
team_grading = team_grading,
assignment_folder = assignment_folder,
number_assignment = number_assignment
)

# Specify which students to grade
Expand Down
94 changes: 72 additions & 22 deletions R/create_grading_progress_log.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ create_grading_progress_log <- function(
example_student_identifier,
roster_path,
github_issues,
team_grading
) {
team_grading,
assignment_folder,
number_assignment
) {

# Read in class roster
grading_progress_log_new <- readr::read_csv(roster_path, show_col_types = FALSE) %>%
Expand Down Expand Up @@ -64,40 +66,88 @@ create_grading_progress_log <- function(
mutate(assignment_path = NA) %>%
mutate(assignment_missing = FALSE)


assignment_path <- rep(NA, length(example_assignment_path))
assignment_path <- rep(NA, number_assignment)

# Check file exists at assignment file paths
no_assignment_file_paths_work <- TRUE

for(i in 1:length(grading_progress_log_new$student_identifier)) {
for (j in 1:length(example_assignment_path)) {
assignment_path[j] <- str_replace_all(
if(!is.na(assignment_folder)){ # if assignment_folder is defined, use it, and use the code to get all names
assignment_list <- list.files(assignment_folder)

# match assignments with student identifiers
for(i in 1:length(grading_progress_log_new$student_identifier)) {
# get assignment name(s), incl enclosing folder
assignment_name <- paste(assignment_folder, assignment_list[str_which(string = assignment_list,
pattern = grading_progress_log_new$student_identifier[i])],
sep = "/")
# if there is no assignment, assignment_name will become e.g. FOR4934/ which causes errors
# with opening files during grading. Replace with a word so it can be identified further on as missing
# for multiple files, just take the first entry (if there is something there, the assignment is not missing anyway)
if(assignment_name[1] == paste(assignment_folder, "/", sep = "")){
assignment_name <- "missing"
}

# check if there are enough assignments (if multiple are required)
if(length(assignment_name) < length(assignment_path)){ # if not, fill up with NAs
assignment_path <- c(assignment_name, rep(NA, (length(assignment_path) - length(assignment_name))))
} else {
assignment_path <- assignment_name
}
####### maybe also add a message if there are more than the required assignments? #####

for (j in 1:length(assignment_path)){
# double-check if the file exists
if(file.exists(assignment_path[j])) {
# We need to know if none of the assignment file paths work
no_assignment_file_paths_work <- FALSE

} else {
# Note those without an assignment
grading_progress_log_new$assignment_missing[i] <- TRUE
}
}

# Save assignment paths as one string per student
grading_progress_log_new$assignment_path[i] <- paste(
assignment_path,
collapse = ", "
)

}

} else { # if the assignment folder is not defined, use original code that replaces student_identifier

for(i in 1:length(grading_progress_log_new$student_identifier)) {
for (j in 1:length(example_assignment_path)) {
assignment_path[j] <- str_replace_all(
example_assignment_path[j],
pattern = example_student_identifier,
replacement = grading_progress_log_new$student_identifier[i]
)

if(file.exists(assignment_path[j])) {
# We need to know if none of the assignment file paths work
no_assignment_file_paths_work <- FALSE

} else {
# Note those without an assignment
grading_progress_log_new$assignment_missing[i] <- TRUE
if(file.exists(assignment_path[j])) {
# We need to know if none of the assignment file paths work
no_assignment_file_paths_work <- FALSE

} else {
# Note those without an assignment
grading_progress_log_new$assignment_missing[i] <- TRUE

}

}

# Save assignment paths as one string per student
grading_progress_log_new$assignment_path[i] <- paste(
assignment_path,
collapse = ", "
)

}

# Save assignment paths as one string per student
grading_progress_log_new$assignment_path[i] <- paste(
assignment_path,
collapse = ", "
)

}

if (no_assignment_file_paths_work) {
stop(
"No assignment file paths matched to assignment files.\nPlease check that the student identifier matched those in the file paths."
Expand Down Expand Up @@ -171,7 +221,7 @@ create_grading_progress_log <- function(
mutate(last_time_graded = as.POSIXlt(NA)) %>%
mutate(comments = NA) %>%
mutate(comment_qs = NA)

if (github_issues) {
grading_progress_log <- grading_progress_log %>%
mutate(issue_qs = NA) %>%
Expand Down