Skip to content
Snippets Groups Projects
Commit 324d97a1 authored by iaibrys's avatar iaibrys Committed by GitHub
Browse files

Fix bug and better logging.

parent 36e8ceb4
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ out_file <- "~/Downloads/test_quiz.csv" ...@@ -6,7 +6,7 @@ out_file <- "~/Downloads/test_quiz.csv"
args = commandArgs(trailingOnly=TRUE) args = commandArgs(trailingOnly=TRUE)
if (length(args)==1) { if (length(args)==0) {
stop("At least one argument must be supplied (input file).\n") stop("At least one argument must be supplied (input file).\n")
} else if (length(args)==1) { } else if (length(args)==1) {
json_file <- args[1] json_file <- args[1]
...@@ -32,13 +32,16 @@ names(js$submissions) ...@@ -32,13 +32,16 @@ names(js$submissions)
## Collecting the answers ## Collecting the answers
answers <- js$submissions[,c("Student ID", "Student Name", "Attempt No", "Quiz Attempt Number", "Time Used" )] answers <- js$submissions[,c("Student ID", "Student Name", "Attempt No", "Quiz Attempt Number", "Time Used" )]
answers[, "Time Used"] <- lubridate:::.strptime(js$submissions[,"Last Edit Time"], "%Y-%m-%dT%H:%M:%OS%OO") - lubridate:::.strptime(js$submissions[,"First Edit Time"], "%Y-%m-%dT%H:%M:%OS%OO") # Not needed since bug fixed.
#answers[, "Time Used"] <- lubridate:::.strptime(js$submissions[,"Last Edit Time"], "%Y-%m-%dT%H:%M:%OS%OO") - lubridate:::.strptime(js$submissions[,"First Edit Time"], "%Y-%m-%dT%H:%M:%OS%OO")
questions <- t(sapply(js$submissions$questions,function(x) x[["Question Is Correct"]])) questions <- t(sapply(js$submissions$questions,function(x) x[["Question Is Correct"]]))
questions <- as.data.frame(questions) questions <- as.data.frame(questions)
questions_raw <- questions
names(questions) <- paste0("Q", 1:ncol(questions)) names(questions) <- paste0("Q", 1:ncol(questions))
qstats = apply(questions[,], 2, function(x) length(which(x))) / nrow(questions[,])
questions$TotalCorrect = rowSums(questions) questions$TotalCorrect = rowSums(questions)
questions$PctCorrect = 100.0(questions$TotalCorrect / (ncol(questions)-1)) questions$PctCorrect = 100.0*(questions$TotalCorrect / (ncol(questions)-1))
answers <- cbind(answers, questions) answers <- cbind(answers, questions)
write.table(answers, file=out_file, sep=",", row.names = FALSE) write.table(answers, file=out_file, sep=",", row.names = FALSE)
...@@ -47,4 +50,7 @@ print(answers) ...@@ -47,4 +50,7 @@ print(answers)
## Question stats ## Question stats
count_func <- function(x) length(which(x))
qstats = apply(questions_raw[,], 2, count_func) / nrow(questions[,])
print("SATISTICS")
print(qstats) print(qstats)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment