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

import edu.pdx.cs410J.ParserException;

import java.io.*;
import java.util.Optional;

public class GradesFromD2LImporter {

  public static void importGradesFromD2L(GradesFromD2L d2lGrades, GradeBook gradebook) {
    for (GradesFromD2L.D2LStudent d2LStudent : d2lGrades.getStudents()) {
      Optional<Student> student = d2lGrades.findStudentInGradebookForD2LStudent(d2LStudent, gradebook);
      if (!student.isPresent()) {
        String message = "Could not find student " + d2LStudent + " in gradebook";
        System.err.println(message);

      } else {
        for (String quizName : d2LStudent.getQuizNames()) {
          Optional<Assignment> optional = d2lGrades.findAssignmentInGradebookForD2lQuiz(quizName, gradebook);
          Assignment quiz = optional.orElseThrow(() -> new IllegalStateException("No quiz named \"" + quizName + "\" in gradebook"));
          student.get().setGrade(quiz.getName(), new Grade(quiz, d2LStudent.getScore(quizName)));
        }
      }
    }
  }

  public static void main(String[] args) throws IOException, ParserException {
    String d2lCsvFileName = null;
    String gradeBookFileName = null;

    for (String arg : args) {
      if (d2lCsvFileName == null) {
        d2lCsvFileName = arg;

      } else if (gradeBookFileName == null) {<commit_msg>Added some debug logging to the D2L grade importer.<commit_after>package edu.pdx.cs410J.grader;

import edu.pdx.cs410J.ParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.util.List;
import java.util.Optional;

public class GradesFromD2LImporter {

  private static final Logger logger = LoggerFactory.getLogger("edu.pdx.cs410J.grader");

  public static void importGradesFromD2L(GradesFromD2L d2lGrades, GradeBook gradebook) {
    List<GradesFromD2L.D2LStudent> students = d2lGrades.getStudents();
    logger.debug("Importing grades for " + students.size() + " students");

    for (GradesFromD2L.D2LStudent d2LStudent : students) {
      Optional<Student> student = d2lGrades.findStudentInGradebookForD2LStudent(d2LStudent, gradebook);
      if (!student.isPresent()) {
        String message = "Could not find student " + d2LStudent + " in gradebook";
        System.err.println(message);

      } else {
        for (String quizName : d2LStudent.getQuizNames()) {
          Optional<Assignment> optional = d2lGrades.findAssignmentInGradebookForD2lQuiz(quizName, gradebook);
          Assignment quiz = optional.orElseThrow(() -> new IllegalStateException("No quiz named \"" + quizName + "\" in gradebook"));

          Double score = d2LStudent.getScore(quizName);
          logger.debug("Recording grade of " + score + " for " + student.get() + " for " + quiz.getName());
          student.get().setGrade(quiz.getName(), new Grade(quiz, score));
        }
      }
    }
  }

  public static void main(String[] args) throws IOException, ParserException {
    String d2lCsvFileName = null;
    String gradeBookFileName = null;

    for (String arg : args) {
      if (d2lCsvFileName == null) {
        d2lCsvFileName = arg;

      } else if (gradeBookFileName == null) {
{'fraction_non_alphanumeric': 0.11076049226885452, 'fraction_numerical': 0.018302303565793626, 'mean_word_length': 3.614264919941776, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5452597', 'n_tokens_mistral': 1035, 'n_tokens_neox': 996, 'n_words': 215}