public static void main(String[] args) throws IOException, ClassNotFoundException {
   ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("resources/course.save"));
   ObjectInputStream ois = new ObjectInputStream(new FileInputStream("resources/course.save"));
   Course course = new Course("Programming", 220);
   oos.writeObject(course);
   Course readerObject = (Course) ois.readObject();
   readerObject.printInfo();
 }
Example #2
0
 public static ScoreMenu[] loadFile() {
   MainWindow.initDataFile(SCORE_MENU_FILE);
   DataInputStream input;
   Course course;
   Class tempClass;
   Student student;
   int[] testTime;
   long[] id;
   float[] score;
   ScoreMenu[] scoreMenu = new ScoreMenu[20];
   int count = 0;
   try {
     input = new DataInputStream(new FileInputStream(SCORE_MENU_FILE));
     while (input.available() > 0) {
       if (count >= scoreMenu.length) {
         ScoreMenu[] temp = new ScoreMenu[scoreMenu.length * 2];
         for (int i = 0; i < scoreMenu.length; i++) temp[i] = scoreMenu[i];
         scoreMenu = temp;
       }
       tempClass = new Class();
       tempClass.setGrade(input.readInt());
       tempClass.setMajor(input.readUTF());
       tempClass.setClassNumber(input.readInt());
       tempClass.setStudentNumber(0);
       int num = input.readInt();
       for (int i = 0; i < num; i++) {
         student = new Student();
         student.setId(input.readLong());
         student.setName(input.readUTF());
         tempClass.addStudent(student);
       }
       course = new Course();
       course.setId(input.readUTF());
       course.setName(input.readUTF());
       course.setCredit(input.readFloat());
       course.setPeriod(input.readInt());
       testTime = new int[5];
       for (int i = 0; i < 5; i++) testTime[i] = input.readInt();
       num = input.readInt();
       id = new long[num];
       score = new float[num];
       for (int i = 0; i < num; i++) id[i] = input.readLong();
       for (int i = 0; i < num; i++) score[i] = input.readFloat();
       scoreMenu[count] = new ScoreMenu(tempClass, course, testTime, num, id, score);
       count++;
     }
     input.close();
     return scoreMenu;
   } catch (Exception e) {
     return null;
   }
 }
Example #3
0
  public static void main(String[] args) throws IOException {
    testOutput("output/test1", test1());
    //		testOutput("output/test2", test2());
    testOutput("output/test3", test3());

    /*testing Course*/
    Course testCourse = new Course("ID", "Test Course");
    testCourse.addQuiz(test1());
    testCourse.addQuiz(test2());
    testCourse.addQuiz(test3());
    testCourse.addQuiz(test4());
    testOutput("output/testCourse", testCourse);
  }
 public static File copyResourceFile(
     String sourceName, String copyName, Project project, Task task) throws IOException {
   StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
   Course course = taskManager.getCourse();
   int taskNum = task.getIndex() + 1;
   int lessonNum = task.getLesson().getIndex() + 1;
   assert course != null;
   String pathToResource =
       FileUtil.join(
           new File(course.getResourcePath()).getParent(),
           Lesson.LESSON_DIR + lessonNum,
           Task.TASK_DIR + taskNum);
   File resourceFile = new File(pathToResource, copyName);
   FileUtil.copy(new File(pathToResource, sourceName), resourceFile);
   return resourceFile;
 }
  // Deze method maakt activities aan
  public List<Activity> createActivity(
      Course course,
      Integer activitiesPerWeek,
      Integer maxNumberStudents,
      String nameLectureType,
      boolean hoorcollege) {
    List<Activity> activities = new ArrayList<>();
    // Algoritme om (werk)groepen aan te maken
    for (int i = 1; i <= activitiesPerWeek; i++) {
      if (!hoorcollege && activitiesPerWeek >= 1) {

        // Verdeelt studenten over groepen als er meer studenten zijn dan capaciteit van 1
        // (werk)groep
        if (course.courseStudents.size() > maxNumberStudents) {
          int numberGroups =
              (int)
                  Math.ceil(((double) course.courseStudents.size()) / ((double) maxNumberStudents));
          int numberStudentsGroup =
              (int) Math.ceil(((double) course.courseStudents.size()) / ((double) numberGroups));

          course.numberOfGroups = numberGroups;
          int j;
          for (j = 1; j < numberGroups; j++) {
            List<Student> studentsWorkGroup =
                course.courseStudents.subList(
                    (j - 1) * numberStudentsGroup, j * numberStudentsGroup);
            Activity workGroup = new Activity(course, nameLectureType, i, j, studentsWorkGroup);
            activities.add(workGroup);
          }
          List<Student> studentsWorkGroup =
              course.courseStudents.subList(
                  numberStudentsGroup * (j - 1), course.courseStudents.size());
          Activity workGroup = new Activity(course, nameLectureType, i, j, studentsWorkGroup);
          activities.add(workGroup);

        }
        // Maakt 1 (werk)groep
        else {
          Activity subGroup = new Activity(course, nameLectureType, i, 1, course.courseStudents);
          activities.add(subGroup);
        }
        // Maakt 1 hoorcollege
      } else if (hoorcollege && activitiesPerWeek >= 1) {
        Activity hoorCollege = new Activity(course, nameLectureType, i, 1, course.courseStudents);
        activities.add(hoorCollege);
      }
    }
    return activities;
  }
Example #6
0
 public static ScoreMenu queryFromFile(Class classes, Course courses) {
   MainWindow.initDataFile(SCORE_MENU_FILE);
   DataInputStream input;
   Class tempClass = new Class();
   Student student;
   Course course = new Course();
   int[] testTime = new int[5];
   int numberOfAttendTestStudent;
   long idOfStudents[];
   float scoreOfTest[];
   try {
     input = new DataInputStream(new FileInputStream(SCORE_MENU_FILE));
     while (input.available() > 0) {
       tempClass.setGrade(input.readInt());
       tempClass.setMajor(input.readUTF());
       tempClass.setClassNumber(input.readInt());
       int studentNumber = input.readInt();
       tempClass.setStudentNumber(0);
       for (int i = 0; i < studentNumber; i++) {
         student = new Student();
         student.setId(input.readLong());
         student.setName(input.readUTF());
         tempClass.addStudent(student);
       }
       course.setId(input.readUTF());
       course.setName(input.readUTF());
       course.setCredit(input.readFloat());
       course.setPeriod(input.readInt());
       for (int i = 0; i < 5; i++) testTime[i] = input.readInt();
       numberOfAttendTestStudent = input.readInt();
       idOfStudents = new long[numberOfAttendTestStudent];
       scoreOfTest = new float[numberOfAttendTestStudent];
       for (int i = 0; i < numberOfAttendTestStudent; i++) idOfStudents[i] = input.readLong();
       for (int i = 0; i < numberOfAttendTestStudent; i++) scoreOfTest[i] = input.readFloat();
       if ((classes.equals(tempClass)) && (courses.equals(course))) {
         input.close();
         return new ScoreMenu(
             tempClass, course, testTime, numberOfAttendTestStudent, idOfStudents, scoreOfTest);
       }
     }
     input.close();
     return null;
   } catch (Exception e) {
     return null;
   }
 }
Example #7
0
 public boolean saveToFile() {
   MainWindow.initDataFile(SCORE_MENU_FILE);
   DataInputStream input;
   DataOutputStream output;
   Class tempClass = new Class();
   Student student = new Student();
   Course course = new Course();
   int[] testTime = new int[5];
   int numberOfAttendTestStudent;
   long idOfStudents[];
   float scoreOfTest[];
   try {
     input = new DataInputStream(new FileInputStream(SCORE_MENU_FILE));
     while (input.available() > 0) {
       tempClass.setGrade(input.readInt());
       tempClass.setMajor(input.readUTF());
       tempClass.setClassNumber(input.readInt());
       int studentNumber = input.readInt();
       tempClass.setStudentNumber(0);
       for (int i = 0; i < studentNumber; i++) {
         student.setId(input.readLong());
         student.setName(input.readUTF());
       }
       course.setId(input.readUTF());
       course.setName(input.readUTF());
       course.setCredit(input.readFloat());
       course.setPeriod(input.readInt());
       for (int i = 0; i < 5; i++) testTime[i] = input.readInt();
       numberOfAttendTestStudent = input.readInt();
       idOfStudents = new long[numberOfAttendTestStudent];
       scoreOfTest = new float[numberOfAttendTestStudent];
       for (int i = 0; i < numberOfAttendTestStudent; i++) idOfStudents[i] = input.readLong();
       for (int i = 0; i < numberOfAttendTestStudent; i++) scoreOfTest[i] = input.readFloat();
       if ((this.classOfScoreMenu.equals(tempClass)) && (this.course.equals(course))) {
         input.close();
         return false;
       }
     }
     input.close();
     output = new DataOutputStream(new FileOutputStream(SCORE_MENU_FILE, true));
     output.writeInt(this.classOfScoreMenu.getGrade());
     output.writeUTF(this.classOfScoreMenu.getMajor());
     output.writeInt(this.classOfScoreMenu.getClassNumber());
     int num = this.classOfScoreMenu.getStudentNumber();
     output.writeInt(num);
     Student[] students = this.classOfScoreMenu.getStudents();
     for (int i = 0; i < num; i++) {
       output.writeLong(students[i].getId());
       output.writeUTF(students[i].getName());
     }
     output.writeUTF(this.course.getId());
     output.writeUTF(this.course.getName());
     output.writeFloat(this.course.getCredit());
     output.writeInt(this.course.getPeriod());
     for (int i = 0; i < 5; i++) output.writeInt(this.testTime[i]);
     output.writeInt(this.numberOfAttendTestStudent);
     for (int i = 0; i < this.numberOfAttendTestStudent; i++)
       output.writeLong(this.idOfStudents[i]);
     for (int i = 0; i < this.numberOfAttendTestStudent; i++)
       output.writeFloat(this.scoreOfTest[i]);
     output.close();
     return true;
   } catch (Exception e) {
     return false;
   }
 }