Commit 4dc4db5e authored by Simon Pintarelli's avatar Simon Pintarelli

add sanity checks

parent 76c3c05b
......@@ -35,21 +35,28 @@ max_points_per_task <- c(10, 10, 10, 10) # max. no. of points per task
maxpoints <- sum(max_points_per_task) # max. points
dp <- 0.5 # point interval
dg <- 0.25 # grade interval
## piecewise linear grading scale, make sure to include maxpoints
int_points <- c(0, 21, 35, maxpoints)
int_grades <- c(1, 4, 6, 6)
## piecewise linear grading scale. If no grade is assigned to 0 or maxpoints,
## it is assumed that they map to grade 1 or 6 respectively.
int_points <- c(0, maxpoints)
int_grades <- c(1, 6)
@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ================= END USER SETTINGS =================== %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<<<check_user_settings, echo=FALSE>>=
if(min(int_grades) > 1){
int_grades <- c(1, int_grades)
int_points <- c(0, int_points)
<<<check_user_settings, echo=FALSE, error=TRUE>>=
if(min(int_points) > 0){
int_grades <- c(1, int_grades)
int_points <- c(0, int_points)
}
if(max(int_points) < maxpoints) {
int_grades <- c(int_grades, 6)
int_points <- c(int_points, maxpoints)
}
stopifnot(!is.unsorted(int_points))
stopifnot(!is.unsorted(int_grades))
stopifnot(length(int_points) == length(int_grades))
@
\begin{document}
......@@ -124,9 +131,6 @@ library(xtable)
@
<<prepare data, echo=FALSE, message=FALSE, warning=FALSE>>=
## check user settings
stopifnot(length(int_points) == length(int_grades))
## read data
dset <- read.csv('marks.csv', encoding='ISO-8859-1')
dset <- dset[, !(names(dset) %in% c("Last.Name", "First.Name"))]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment