Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ __Optional Files:__
An example file has been given for you to understand the formatting.
This file can be included if you want to add in prescheduled times.
For example, an instructor was scheduled in another department.
- `your_name_choice.json` [java/hello-world/src/main/resources/input/](java/hello-world/src/main/resources/input/).
An example file is given for you to understand th formatting.
This file can be used if you want to specify if a courses lab or activity time should be spread out across multiple
days or if the time should be all in one block.

Note I'll give you some of the files that aren't included.

Expand Down
29 changes: 27 additions & 2 deletions java/hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,32 @@ If instructors teach in multiple departments, you can include the times they hav
The file should be a `json` placed in the [./src/main/resources/input/](./src/main/resources/input/) directory.
An example of the file has been provided in the same directory your file should be placed.

Once your file containing preshceulded times is placed, create the key in your `config.yaml` named `prescheduledFileName` mapped to the value of your file name, as seen in this example [file](./src/main/resources/constants/config.example.yaml)
Once your file containing prescheduled times is placed, create the key in your `config.yaml` named `prescheduledFileName` mapped to the value of your file name, as seen in this example [file](./src/main/resources/constants/config.example.yaml)


# Setting lab/act pattern
If a course contains a lab or activity you can set if the course should have all it's lab/act time all in one block of time
or spread out amongst various days.
You can set the pattern for a course globally and/or per instructor.
Note, instructor choice takes precedence over global.
If a course has a lab/act and no pattern is given to the course, the default is **"Multiple"**

Time use this option you must include in your `config.yaml` they key name `patternsFileName` mapped the value of your
file name, which must be a JSON file. An example of the JSON format that is expected is given
[here](./src/main/resources/input/coursePatterns.example.json).

The only patterns available for a course are **"One"** and **"Multiple"**.
If the pattern **"One"** is chosen and the course has lecture portion to it, the course will be split into two lessons.
One lesson will have only the lecture units while the other lesson contains only the lab/act units.
If the pattern **"Multiple"** is selected or defaulted to and the course has a lecture portion,
the lecture units and lab/act units will be bundled together into a lesson instance.

Other things to consider:
- If a studio course instance is scheduled to have all it's lab/act time to be in **one** block, then the constraint
enforcing that lab/act time must be immediately after lecture will not be enforced for this lesson.
- When setting the instructor preference, the key (aka the instructor's name) should be their canonical name.





Expand All @@ -107,6 +132,6 @@ If there aren't any or there is a test you want to inlcude, follow the image gui

**Example setup in intellij**
On step 1 you will see pop up. Select `edit` under configuration.
On step 2 you will see a menu and you should choose the `JUnit` option.
On step 2 you will see a menu, and you should choose the `JUnit` option.
On step 3 you will choose the same first 2 options and then choose the test class you want to run.
![example intellij test setup](../../documentation_media/intellij_test_setup.png)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
import org.acme.schooltimetabling.domain.Timeslot;
import org.acme.schooltimetabling.domain.Timetable;
import org.acme.schooltimetabling.domain.teacher.Teacher;
import org.acme.schooltimetabling.fileObjects.CoursePatterns;
import org.acme.schooltimetabling.fileObjects.ScheduleConfig;
import org.acme.schooltimetabling.fileObjects.ScheduleFormat;
import org.acme.schooltimetabling.helperClasses.*;
import org.acme.schooltimetabling.helperClasses.Generators.*;
import org.slf4j.Logger;
Expand All @@ -39,6 +42,10 @@ public static void main(String[] args) throws Exception{
ScheduleConfig.getSeasonTerm()));
LOGGER.info("Loading critical constants");
Constants.load();
if(ScheduleConfig.isTesting()){
LOGGER.error("Configuration must not have testing set to true when creating a solution. Exiting...");
return;
}

Map<String, Teacher> teacherMap = TeacherGenerator.teacherGenDriver();
/*generate timeslots*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import org.acme.schooltimetabling.apiCalls.ApiConstants;
import org.acme.schooltimetabling.helperClasses.ScheduleConfig;
import org.acme.schooltimetabling.fileObjects.ScheduleConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import retrofit2.Call;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package org.acme.schooltimetabling.builders.lessons;

import org.acme.schooltimetabling.constants.Constants;
import org.acme.schooltimetabling.domain.Room;
import org.acme.schooltimetabling.domain.Timeslot;
import org.acme.schooltimetabling.domain.lesson.Lesson;
import org.acme.schooltimetabling.domain.teacher.Teacher;
import org.acme.schooltimetabling.fileObjects.LabPatterns;
import org.acme.schooltimetabling.fileObjects.ScheduleConfig;


/**
* <p>Use this class to build {@code Lesson} objects. Using the constructors is getting
* kind of messy. The following must be set <i>id, course name, course configuration,
* teacher object, and section</i>. The following are optional: modifier ("") and
* labPattern (<i>null</i> if only lecture; {@link LabPatterns} if the configuration includes
* a lab/act)</p>
*
* <p>Note about setting <i>id</i>. that the <i>id</i> is for the lesson object.
* Don't mistake this with the section number of a courses lecture and/or lab. </p>
*
* <p>Note about setting the <i>section</i> number. If the course configuration for the lesson you
* are building has either a lecture or a lab/act, then set the section number normally. If the
* course configuration has both a lecture and a lab/act then just pass the lecture section number.
* The lesson will assume the section number after the lecture is reserved for the lab/act</p>
*/
public class LessonBuilder {
//required build fields
private String id = null;
private String courseName = null;
private String courseConfig = null;
private Teacher teacherObj = null;
private Integer section = null;

//optional build fields
private String modifier = "";
private LabPatterns labPattern = null;
private Integer linkerId = null;

//fields used only when testing
private Timeslot timeslot = null;
private Room room = null;
private int courseId = -1;


/**
* unique id of the Lesson object that will be built
*/
public LessonBuilder id(int id){
if(id < 0) throw new IllegalArgumentException("the id must be greater then zero");
this.id = String.valueOf(id);
return this;
}

public LessonBuilder section(int lecSection) {
this.section = lecSection;
return this;
}

public LessonBuilder courseName(String courseName) {
this.courseName = courseName;
return this;
}

public LessonBuilder modifier(String modifier) {
if(Constants.SPECIAL_CODE_CONVERSION.containsKey(modifier)) modifier = Constants.SPECIAL_CODE_CONVERSION.get(modifier);
else if(!Constants.SPECIAL_CODE_CONVERSION.containsValue(modifier)) throw new IllegalArgumentException("Modifier is " +
"not a valid option. Look in Constants.java for valid modifiers.");
this.modifier = modifier;
return this;
}

public LessonBuilder courseConfig(String courseConfig) {
if(courseConfig == null || !validateConfig(courseConfig)) throw new IllegalArgumentException("A course config must be given in the format " +
"d-d-d. Where d is an digit and one of them must be non-zero and digit order is lec-lab-act" );
this.courseConfig = courseConfig;
return this;
}

private boolean validateConfig(String config){
return config.matches("^(?=.*[1-9])[0-9]-[0-9]-[0-9]$");
}

public LessonBuilder teacherObj(Teacher teacherObj) {
this.teacherObj = teacherObj;
return this;
}

public LessonBuilder labPattern(LabPatterns labPattern) {
this.labPattern = labPattern;
return this;
}

public LessonBuilder linkerId(Integer linkerId){
this.linkerId = linkerId;
return this;
}

public LessonBuilder timeslot(Timeslot timeslot){
if(!ScheduleConfig.isTesting()) throw new RuntimeException("This is only available during testing, Shouldn't be " +
"set manually");
this.timeslot = timeslot;
return this;
}

public LessonBuilder room(Room room){
if(!ScheduleConfig.isTesting()) throw new RuntimeException("This is only available during testing, Shouldn't be " +
"set manually");
this.room = room;
return this;
}

/**
* id for the course; i.e all lessons that are scheduling course 'csc1000' will share the same
* <i>courseId</i>, like '1';
*/
public LessonBuilder courseId(int courseId){
if(!ScheduleConfig.isTesting()) throw new RuntimeException("This is only available during testing, Shouldn't be " +
"set manually");
this.courseId = courseId;
return this;
}

public LessonBuilder clear() {
id = null;
section = null;
courseName = null;
modifier = "";
courseConfig = null;
teacherObj = null;
labPattern = null;
linkerId = null;
timeslot = null;
room = null;
courseId = -1;
return this;
}

public Lesson build() {
//mandatory fields
if (id == null || section == null || courseName == null || courseConfig == null || teacherObj == null) {
throw new IllegalCallerException(
"When calling build() you must have values set for id, section, courseName, courseConfig, and teacherObj"
);
}



//check if we need a default for the lab
String[] units = courseConfig.split("-");
int labUnits = Integer.parseInt(units[1]);
int actUnits = Integer.parseInt(units[2]);
if(labPattern == null && (labUnits != 0 || actUnits != 0)) labPattern = LabPatterns.MULTIPLE;

if(modifier == null) modifier = "";

if(ScheduleConfig.isTesting()){
if(timeslot == null || room == null) throw new RuntimeException("When building a lesson during testing, " +
"a 'timeslot' and a 'room' or else the lesson won't be detected by the constraint");
return Lesson.test_buildLesson(
id, section, courseName, teacherObj.getName(), modifier, courseConfig, courseId, teacherObj,
timeslot, room, linkerId, labPattern
);
}

return new Lesson(id, section, courseName, modifier, courseConfig, teacherObj, labPattern, linkerId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.acme.schooltimetabling.constants.Constants;
import org.acme.schooltimetabling.constants.Days;
import org.acme.schooltimetabling.helperClasses.BitSetHelper;
import org.acme.schooltimetabling.helperClasses.ScheduleConfig;
import org.acme.schooltimetabling.fileObjects.ScheduleConfig;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.acme.schooltimetabling.apiCalls.teacherEndpoint.TeacherRecord;
import org.acme.schooltimetabling.helperClasses.Generators.Generator;
import org.acme.schooltimetabling.helperClasses.ParseInput;
import org.acme.schooltimetabling.helperClasses.ScheduleConfig;
import org.acme.schooltimetabling.fileObjects.ScheduleConfig;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
Expand Down
Loading
Loading