Example #1
0
  private void save_buttonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_save_buttonActionPerformed
    for (int i = 0; i < rubric_table.getColumnCount(); i++) {
      try {
        GradeAccess.enterGrade(
            studentID,
            courseID,
            actName,
            rubric_table.getModel().getValueAt(i, 0).toString(),
            Float.parseFloat(rubric_table.getModel().getValueAt(i, 1).toString()));
      } catch (NumberFormatException e) {
        e.printStackTrace();
      } catch (SQLException e) {
        GradeAccess.updateGrade(
            studentID,
            courseID,
            actName,
            rubric_table.getModel().getValueAt(i, 0).toString(),
            Float.parseFloat(rubric_table.getModel().getValueAt(i, 1).toString()));
      }
    }

    try {
      PrintWriter out = new PrintWriter(paths[0] + "/" + studentID + "/" + actName + ".py");
      out.write(submission_text_area.getText());
      out.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    setOkToNav();
    JOptionPane.showMessageDialog(this, "Grade and comments saved.");
  } // GEN-LAST:event_save_buttonActionPerformed
Example #2
0
  public MarkingCode(
      final String courseID,
      final Activity act,
      final int stud_id,
      String student_name,
      Object[] stud_list) {
    super(act.getName(), CANT_NAV);
    initComponents();
    this.student_list = stud_list;
    this.activity = act;
    this.stud_name = student_name;

    student_name_label.setText(student_name);
    id_label.setText(Integer.toString(stud_id));

    max_grade_field.setEditable(false);
    grade_field.setEditable(false);

    float max = 0;

    this.testsuite_activity = act;
    this.courseID = courseID;
    this.actName = act.getName();
    this.studentID = stud_id;

    String last_indice_check = student_name + " - " + studentID;
    if (last_indice_check.equalsIgnoreCase((String) stud_list[stud_list.length - 1]))
      this.next_button.setEnabled(false);

    System.out.println("Trying to read submission");
    paths = CourseAccess.accessSubmissionPath(courseID, act.getName());
    Scanner in = null;
    String submission = "";
    try {
      in = new Scanner(new FileReader(paths[0] + "/" + stud_id + "/" + act.getName() + ".py"));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    while (in.hasNext()) {
      submission += in.nextLine() + "\n";
    }
    in.close();
    submission_text_area.setText(submission);

    String solution = "";
    try {
      in = new Scanner(new FileReader(paths[1]));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    while (in.hasNext()) {
      solution += in.nextLine() + "\n";
    }
    in.close();
    solution_text_area.setText(solution);

    // Populate the Rubric Table code below this:
    grade_field.setText("");
    Object[][] temp = CourseAccess.accessRubricItems(courseID, act.getName());
    if (temp.length != 0) {
      table = new Object[temp.length][3];
      for (int i = 0; i < table.length; i++) {
        table[i][0] = temp[i][0];
        table[i][1] = 0;
        table[i][2] = temp[i][1];
        max += (float) temp[i][1];
      }
      DefaultTableModel tm =
          new DefaultTableModel(table, COLUMN_NAMES) {
            public boolean isCellEditable(int row, int column) {
              if (column == 0 || column == 2) return false;
              return true;
            }
          };
      ;
      tm.addTableModelListener(
          new javax.swing.event.TableModelListener() {
            public void tableChanged(TableModelEvent e) {
              table_change_actionPerformed(e);
            }
          });
      ;
      rubric_table.setModel(tm);
    }
    Object[] grades = GradeAccess.accessGrades(courseID, act.getName(), stud_id);
    System.out.println(grades.length);
    if (grades.length != 0) {
      for (int i = 0; i < grades.length; i++) {
        table[i][1] = grades[i];
        System.out.println(grades[i]);
      }
      DefaultTableModel tm =
          new DefaultTableModel(table, COLUMN_NAMES) {
            public boolean isCellEditable(int row, int column) {
              if (column == 0 || column == 2) return false;
              return true;
            }
          };
      ;
      tm.addTableModelListener(
          new javax.swing.event.TableModelListener() {
            public void tableChanged(TableModelEvent e) {
              table_change_actionPerformed(e);
            }
          });
      ;
      rubric_table.setModel(tm);
      float gradeTotal = 0;
      for (int i = 0; i < rubric_table.getRowCount(); i++)
        gradeTotal += Float.parseFloat(rubric_table.getModel().getValueAt(i, 1).toString());
      String currentGrade = "" + gradeTotal;
      grade_field.setText(currentGrade);
    }
    String maxField = "" + max;
    max_grade_field.setText(maxField);
    rubric_table.getColumnModel().getColumn(0).setPreferredWidth(500);
  }