Exemplo n.º 1
0
 private void test_suite_buttonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_test_suite_buttonActionPerformed
   setOkToNav();
   GUIUtils.getMasterFrame(this)
       .movePage(
           new TestSuite(
               testsuite_activity.getStudentSubPath() + "/" + studentID + "/" + actName + ".py",
               testsuite_activity.getSolnPath(),
               activity.getNumOfTests(),
               actName,
               courseID));
   setCantNav();
 } // GEN-LAST:event_test_suite_buttonActionPerformed
Exemplo n.º 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);
  }