Skip to content

Commit

Permalink
Address #476 by only displaying a assignment's score if it has been g…
Browse files Browse the repository at this point in the history
…raded.
  • Loading branch information
DavidWhitlock committed Sep 15, 2024
1 parent c6a9390 commit cceb741
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
10 changes: 6 additions & 4 deletions grader/src/main/java/edu/pdx/cs/joy/grader/SummaryReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ static void dumpReportTo(GradeBook book, Student student,
line.append(" (OPTIONAL)");
}
line.append(": ");
line.append(format.format(score));
line.append("/");
line.append(format.format(assignment.getPoints()));


// Skip incompletes and no grades
Expand All @@ -100,7 +97,12 @@ static void dumpReportTo(GradeBook book, Student student,
line.append(" (INCOMPLETE)");

} else if (grade.isNotGraded()) {
line.append( " (NOT GRADED)");
line.append(" (NOT GRADED)");

} else {
line.append(format.format(score));
line.append("/");
line.append(format.format(assignment.getPoints()));
}

pw.println(line);
Expand Down
32 changes: 32 additions & 0 deletions grader/src/test/java/edu/pdx/cs/joy/grader/SummaryReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,36 @@ private static File getStudentReportFile(File directory, Student student) {
return new File(sectionDirectory, SummaryReport.getReportFileName(student.getId()));
}

@Test
void missingGradeIsClearInReport(@TempDir File tempDirectory) throws IOException {
GradeBook gradeBook = new GradeBook("test");

String assignmentName = "Assignment";
Assignment assignment = gradeBook.addAssignment(new Assignment(assignmentName, 10.0));
Assignment assignment2 = gradeBook.addAssignment(new Assignment("Assignment 2", 10.0));

Student studentWithMissingGrade =
gradeBook.addStudent(new Student("studentWithMissingGrade"))
.setLastName("studentWithMissingGrade")
.setEnrolledSection(Student.Section.UNDERGRADUATE)
.setGrade(assignment, Grade.NO_GRADE)
.setGrade(assignment2, 10.0);

Student studentWithGrade =
gradeBook.addStudent(new Student("studentWithGrade"))
.setLastName("studentWithGrade")
.setEnrolledSection(Student.Section.UNDERGRADUATE)
.setGrade(assignment, 10.0)
.setGrade(assignment2, 10.0);

SummaryReport.dumpReports(gradeBook.getStudentIds(), gradeBook, tempDirectory, false);

File studentWithMissingGradeReportFile = getStudentReportFile(tempDirectory, studentWithMissingGrade);
assertThat(studentWithMissingGradeReportFile.exists(), equalTo(true));

String studentWithSomeNonZeroGradesReport = readTextFromFile(studentWithMissingGradeReportFile);
assertThat(studentWithSomeNonZeroGradesReport, not(containsString(String.valueOf(Grade.NO_GRADE))));
assertThat(studentWithSomeNonZeroGradesReport, containsString("NOT GRADED"));
}

}

0 comments on commit cceb741

Please sign in to comment.