<commit_before>package edu.pdx.cs399J.grader;

import java.io.*;
import java.text.*;
import java.util.*;

import edu.pdx.cs399J.ParserException;

/**
 * Class that creates a pretty report that summarizes a student's
 * grades.
 */
public class SummaryReport {
  private static HashMap allTotals = new HashMap();  // Students -> Double

  /**
   * Computes the student's final average and makes a pretty report.
   */
  private static void dumpReportTo(GradeBook book, Student student,
                                   PrintWriter pw) {
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMinimumFractionDigits(1);
    format.setMaximumFractionDigits(1);

    Set grades = new HashSet();
    Assignment lowestQuiz = null;
    double best = 0.0;
    double total = 0.0;

    pw.println("Grade summary for: " + student.getFullName());
    SimpleDateFormat df = 
      new SimpleDateFormat("EEEE MMMM d, yyyy 'at' h:mm a");
    pw.println("Generated on: " + df.format(new Date()));
    pw.println("");

    Iterator allGradeNames = 
      (new TreeSet(book.getAssignmentNames())).iterator();
    while (allGradeNames.hasNext()) {
      String gradeName = (String) allGradeNames.next();
      Grade grade = student.getGrade(gradeName);
      Assignment assign = book.getAssignment(gradeName);

      // Average non-existent scores as zero
      double score;
      if (grade == null) {
        score = 0.0;

      } else {
        score = grade.getScore();
      }

//       System.out.println("Examining " + assign + ", score: " + score);

      if (assign.getType() == Assignment.QUIZ) {
        if (lowestQuiz == null) {
          lowestQuiz = assign;
//           System.out.println("Lowest quiz: " + lowestQuiz + 
//                              ", score: " + score);

        } else {
          Grade lowestGrade = student.getGrade(lowestQuiz.getName());
          if (lowestGrade != null && score < lowestGrade.getScore()) {
            lowestQuiz = assign;
//             System.out.println("Lowest quiz: " + lowestQuiz + ", score: "
//                                + score + ", lowest grade: " +
//                                student.getGrade(lowestQuiz.getName()));
          }
        }
      }

      String line = "  " + assign.getName() + " (" +
        assign.getDescription() + "): " + format.format(score) + "/" +
        format.format(assign.getPoints());


      // Skip incompletes and no grades
      if (grade == null) {
        line += " (MISSING GRADE)";

      } else if (grade.getScore() == Grade.INCOMPLETE || 
                grade.getScore() == Grade.NO_GRADE) {
        line += " (INCOMPLETE)";
      }

      pw.println(line);

      // Don't count optional assignments toward the maximum point
      // total
      if (assign.getType() != Assignment.OPTIONAL) {
        best += assign.getPoints();
      }

      total += score;
    }<commit_msg>Note optional assignments in report.<commit_after>package edu.pdx.cs399J.grader;

import java.io.*;
import java.text.*;
import java.util.*;

import edu.pdx.cs399J.ParserException;

/**
 * Class that creates a pretty report that summarizes a student's
 * grades.
 */
public class SummaryReport {
  private static HashMap allTotals = new HashMap();  // Students -> Double

  /**
   * Computes the student's final average and makes a pretty report.
   */
  private static void dumpReportTo(GradeBook book, Student student,
                                   PrintWriter pw) {
    NumberFormat format = NumberFormat.getNumberInstance();
    format.setMinimumFractionDigits(1);
    format.setMaximumFractionDigits(1);

    Set grades = new HashSet();
    Assignment lowestQuiz = null;
    double best = 0.0;
    double total = 0.0;

    pw.println("Grade summary for: " + student.getFullName());
    SimpleDateFormat df = 
      new SimpleDateFormat("EEEE MMMM d, yyyy 'at' h:mm a");
    pw.println("Generated on: " + df.format(new Date()));
    pw.println("");

    Iterator allGradeNames = 
      (new TreeSet(book.getAssignmentNames())).iterator();
    while (allGradeNames.hasNext()) {
      String gradeName = (String) allGradeNames.next();
      Grade grade = student.getGrade(gradeName);
      Assignment assign = book.getAssignment(gradeName);

      // Average non-existent scores as zero
      double score;
      if (grade == null) {
        score = 0.0;

      } else {
        score = grade.getScore();
      }

//       System.out.println("Examining " + assign + ", score: " + score);

      if (assign.getType() == Assignment.QUIZ) {
        if (lowestQuiz == null) {
          lowestQuiz = assign;
//           System.out.println("Lowest quiz: " + lowestQuiz + 
//                              ", score: " + score);

        } else {
          Grade lowestGrade = student.getGrade(lowestQuiz.getName());
          if (lowestGrade != null && score < lowestGrade.getScore()) {
            lowestQuiz = assign;
//             System.out.println("Lowest quiz: " + lowestQuiz + ", score: "
//                                + score + ", lowest grade: " +
//                                student.getGrade(lowestQuiz.getName()));
          }
        }
      }

      StringBuffer line = new StringBuffer();
      line.append("  ");
      line.append(assign.getName());
      line.append(" (");
      line.append(assign.getDescription());
      line.append(")");
      if (assign.getType() == Assignment.OPTIONAL) {
        line.append(" (OPTIONAL)");
      }
      line.append(": ");
      line.append(format.format(score));
      line.append("/");
      line.append(format.format(assign.getPoints()));


      // Skip incompletes and no grades
      if (grade == null) {
        line.append(" (MISSING GRADE)");

      } else if (grade.getScore() == Grade.INCOMPLETE || 
                grade.getScore() == Grade.NO_GRADE) {
        line.append(" (INCOMPLETE)");
      }

      pw.println(line);

      // Don't count optional assignments toward the maximum point
      // total
      if (assign.getType() != Assignment.OPTIONAL) {
        best += assign.getPoints();
      }

      total += score;
    }
{'fraction_non_alphanumeric': 0.13608112528622832, 'fraction_numerical': 0.004579653254824992, 'mean_word_length': 2.142343268242549, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3424294', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1737, 'n_words': 410}