Skip to contents

Grades an exam given a parsed list by WhichAnswerOriginal

Usage

GradeExams(
  ExamAnswerParsedList,
  name.ColCorrect,
  name.ColIncorrect,
  MaxOutputGrade = 100,
  ExtraPoints = 0,
  ExtraPointsForAll = 0
)

Arguments

ExamAnswerParsedList

List parsed by WhichAnswerOriginal

name.ColCorrect, name.ColIncorrect

The names of the correct and incorrect columns in each answer sheet of the ExamAnswerParsedList respectively.

MaxOutputGrade

Maximum score that one should get if you get a perfect score, before couning the ExtraPoints

ExtraPoints

Extra points to be added after scoring the exam. This points are added after the scaling is done with MaxOutputGrade.

ExtraPointsForAll

Scalar numeric value, extra points to be given to all student.

Value

It returns the StudentInfo attribute of the parsed list adding the following columns to it

$addedPoints

Individual part of ExtraPoints

$addedAllPoints

Extra Points For All

$maxGrade

Max number of questions for the exam. (It would be different if when removing a question, some students didn't have a question in that exam)

$Grade

Number of correct answers that a student wrote in an exam

$Grade_Total_Exam

This is the total_grade as explained on the Extra Points section.

Details

The score is first added on the base of the number of questions that are found on every parsed list.

If a question is removed from an exam, not all students may have that question as explained in the "Removing questions from the exam" section. If the total rows of a certain student list is \(n\), the score is $$c / n * MaxOutputGrade$$, where \(c\) is the number of correct answers.

After that is done, the ExtraPoints are added.

Extra Points

The structure of ExtraPoints and the convention on how the score is calculated taking it into account is worth mentioning in it's own section. The score is calculated as:

$$total_{grade} = (c + extra_{all}) / (maxn + extra_{all}) * MaxOutputGrade + extra_{individual}$$ Where

c

Number of correct questions

extra_all

Number of extra points for all.

This is thought of to be used as a question that you removed from the exam last minute, but that you want to actually count it as correct for every single student. I.e., a question that everyone got correct but it is not taken into consideration in the grading.

extra_individual

Number of extra points for that student.

max_n

Maximum number of questions in the students exam, which may differ from other students if you had to removed a bugged questions that not everyone had

MaxOutputGrade

The scaling to be done. This should be the maximum grade any student "should" get. (The individual extra points are added after the scaling is done)

Removing Questions from the exam

Note that if after creating the exam, you found that a question is bugged and can't be used to grade the exam, all you have to do is tell the student to answer "something" and you only have to remove it from the original/reference version in the Full Answer Sheet. When you apply the grading function, that question will then be ignored.

Notice how this creates output lists with different lengths in the case that two students didn't have that same question in their exam.

For example, if a exam has 15 questions out of a 50 question document. If student A has a bugged question and student B doesn't, the answer sheet produced for student A will have 14 rows while the one for student B will have 15 rows.

See also

Other Grading Exams: ObtainExamStats()

Examples


#First part coming from FindMatchingRow example

asheet_file <-
    system.file(
        "extdata",
        "ExampleTables",
        "ExampleAnswerSheet.csv",
        package = "TexExamRandomizer")
responses_file <-
    system.file(
        "extdata",
        "ExampleTables",
        "ExampleResponses.csv",
        package = "TexExamRandomizer")
FullAnswerSheet <-
    read.csv(
        asheet_file,
        header = TRUE,
        stringsAsFactors = FALSE,
        na.strings = c("", "NA", "Na"),
        strip.white = TRUE)
Responses <- read.csv(
    responses_file,
    header = TRUE,
    stringsAsFactors = FALSE,
    na.strings = c("", "NA", "Na"),
    strip.white = TRUE)
compiledanswers <-
    WhichAnswerOriginal(
        StudentAnswers = Responses,
        FullExamAnswerSheet = FullAnswerSheet,
        names.StudentAnswerQCols = grep(
            names(Responses),
            pattern = "^Q.*[[:digit:]]",
            value = TRUE),
        names.StudentAnswerExamVersion = grep(
            names(Responses),
            pattern = "Version",
            value = TRUE),
        OriginalExamVersion = 0,
        names.FullExamVersion = "Version",
        names.FullExamOriginalCols = grep(
            names(FullAnswerSheet),
            pattern = "_original",
            value = TRUE),
        names.CorrectAndIncorrectCols = c(
            "choice",
            "CorrectChoice")
    )
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Answer not found in the Answer Sheet
#> Warning: Answer not found in the Answer Sheet
#> Warning: Out Of Bounds answer by the current student
#> Warning: Out Of Bounds answer by the current student
# Actual Code


ExtraPoints_individual <- runif(nrow(Responses), min = 1, max = 10)
ExtraPoints_forall <- 2
GradedStudentTable <-
    GradeExams(
        compiledanswers,
        name.ColCorrect = "CorrectChoice",
        name.ColIncorrect = "choice",
        MaxOutputGrade = 100,
        ExtraPoints = ExtraPoints_individual,
        ExtraPointsForAll = ExtraPoints_forall
    )