Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timetable show to DG, Authorship updates #228

Merged
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
40 changes: 38 additions & 2 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ Command: `required`
Response:
Module requirements for major selected by user

## Add lessons in the Weekly Timetable
## Modify lessons in the Weekly Timetable

User Input: `timetable modify`

Expand All @@ -339,10 +339,46 @@ The following sequence diagram details the process of the 'timetable modify loop
- `saveTimetable`: Saves the current timetable to storage.
- `printTimetable`: Returns a formatted timetable display to the command-line interface.

## Show Weekly Timetable Feature

User Input: `timetable show`

The following sequence diagram shows how the timetable show feature works:
![TimetableShowFeature_Seq.png](diagrams%2FTimetableShowFeature_Seq.png)

The following sequence diagram shows how the printTimetable operation works:
![PrintTimetable_Seq.png](diagrams%2FPrintTimetable_Seq.png)

When the user's command is determined to be `timetable show`, the program implements the following operations:
### Function List (when timetableCommandWord == "SHOW")

- `getCurrentSemesterModulesWeekly()`: Returns the ArrayList of ModuleWeekly for the current semester
- `showTimetable(ArrayList<ModuleWeekly> currentSemModulesWeekly)`: Calls the printTimetable function
- `printTimetable(ArrayList<ModuleWeekly> currentSemModulesWeekly)`: Prints the Weekly Timetable to the console
- `createDailyEvents(ArrayList<ModuleWeekly> \ncurrentSemesterModules)`: Converts the ArrayList<ModuleWeekly> to a
List of ArrayList<Events> for different days
- `sortByTime(ArrayList<Event> currentDayEvents)`: Sorts Events in currentDayEvents by start time, duration, then
module code, in ascending order
- `printTimetableHeader()`: Display timetable header
- `printlnHorizontalLine()`: Display horizontal line
- `printCurrentDayEvents(ArrayList<Event> currentDayEvents, day)`: Display the day's events

### Design considerations
Aspect: How timetable is printed:

#### Current implementation: One row per day
- Pros: Each table cell can be wider allowing each event to be printed in 1 line
- Cons: The user needs to read the time for each event to understand when they are free.

#### Previous implementation: One row per hour, one column per day
- Pros: The user can see when they are free by day and hour easily
- Cons: The console must be wide enough for it to be usable and aesthetic. Each table cell for an event was only about
11 characters wide.


## Search Command

The required command is implemented to give users the ability to search for modules based on their titles.
The search command is implemented to give users the ability to search for modules based on their titles.

- `searchCommand(keywords)': Searches NUSModsAPI for modules containing specified keywords in the title.
- `listAllModules()`: Returns all modules for parsing and identifying those containing a specified keyword.
Expand Down
102 changes: 102 additions & 0 deletions docs/diagrams/PrintTimetable.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
@startuml
'https://plantuml.com/sequence-diagram

'autonumber
'autoactivate on


actor Student

participant ":TimetableView" as TV

participant "currentDayEvents\n:ArrayList<Event>" as CDE #white

participant "moduleService\nController\n:ModuleService\nController" as MSC #white

box "Model" #LightBlue
participant "student:\nStudent" as S #white
participant "timetable:\nTimetable" as T #white
end box

activate S

opt timetableCommandWord == "SHOW"
'timetable.getCurrentSemesterModulesWeekly()
S -> T: getCurrent\nSemester\nModulesWeekly()
activate T
T --> S: currentSem\nModulesWeekly
deactivate T

S -> MSC: showTimetable\n(currentSem\nModulesWeekly)
activate MSC


MSC -> TV: printTimetable(currentSemesterModuleWeekly);
activate TV

'createDailyEvents(currentSemesterModules)
TV -> TV: createDailyEvents(ArrayList<ModuleWeekly> \ncurrentSemesterModules)
activate TV
note left
createDailyEvents converts
the ArrayList<ModuleWeekly>
to a List of ArrayList<Events>
for different days
end note
TV --> TV: List<ArrayList<Event>> weeklyTimetableByDay
deactivate TV


loop currentDayEvents
TV -> TV: sortByTime(ArrayList<Event> currentDayEvents)
activate TV
note left
sortByTime sorts Events
in currentDayEvents by
start time, duration,
then module code, in
ascending order
end note
TV --> TV: ArrayList<Event> currentDayEvents (sorted)
deactivate TV
end

TV -> TV: printTimetableHeader()
activate TV
TV --> Student: display Timetable Header
TV --> TV
deactivate TV

loop day
TV -> TV: printlnHorizontalLine()
activate TV
TV --> Student: display Horizontal Line
TV --> TV
deactivate TV

TV -> CDE: weeklyTimetableByDay.get(day)
CDE --> TV: ArrayList<Event> currentDayEvents

TV -> TV: printCurrentDayEvents(ArrayList<Event> \ncurrentDayEvents, day)
activate TV
TV --> Student: display the day's events
TV --> TV:
deactivate TV
end

TV -> TV: printlnHorizontalLine()
activate TV
TV --> Student: display Horizontal Line
TV --> TV
deactivate TV


TV --> MSC
destroy TV
MSC --> S
deactivate MSC
end



@enduml
Binary file added docs/diagrams/PrintTimetable_Seq.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 38 additions & 15 deletions docs/team/janelleenqi.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,43 @@ Highlights: Lessons are displayed by time and day and does not show days that do

Credits: nil

#### 2. Modules Left Feature
#### 2. Save Timetable Feature

Feature: Added the ability to view modules left.
Feature: Saves the weekly timetable of the user throughout the program.

What it does: Allows the user to retrieve a list of modules that is in their schedule but have not been marked as
completed.
What it does: Updates the save file for the weekly timetable of the user when the user uses any features that changes
the timetable (timetable modify, recommend, shift, delete, clear).

Justification: This feature gives clarity to the user as they are able to easily view what modules they have yet to complete.
Justification: This feature allows the user to store their timetable data, so that they can built upon the same
timetable across multiple sessions.

Highlights: nil
Highlights: The timetable needed to be updated when modules were deleted, to remove those modules from the timetable.

Credits: nil
#### 3. Modules Left Feature

Feature: Added the ability to view modules left.

What it does: Allows the user to retrieve a list of modules that required for their major but have not been marked as
completed.

Justification: This feature gives clarity to the user as they are able to easily view what modules they have yet to
complete for graduation.

#### 3. Modules Required Feature
#### 4. Modules Required Feature

Feature: Added the ability to view modules required.

What it does: Provides students with easy access to the requirements of their major, and be aware of Common Curriculum
Requirements.

Justification:

Highlights: nil

Credits: nil
Justification: Gives students an easy access to a list of modules (and their names) they are required to take to
graduate.

### Classes Implemented

#### 1. Event (and its child classes Lecture, Tutorial, Lab)
Purpose: Allow information on a lesson to be store concisely for convenience, as well as methods for comparison
between different events (for printing in order), printing and saving.

#### 2. ModuleList
Purpose: Provides multiple methods to use an ArrayList of Module, for easy retrieval of data (eg. ArrayList of module
Expand All @@ -72,6 +80,21 @@ provided by user, ensuring optimal readability and good user experience.
#### 1. Refactor Code

Justification: Improved abstraction, separation of concerns and made it easier for testing
Highlights: Required an in-depth understanding of code to ensure that I am not breaking features implemented by my
teammates.
Highlights: Required an in-depth understanding of code to ensure that no features were affected.

#### 2. Project Management

My contribution: Created the Labels and Milestones, and a majority of Story/Task-base Issues within the Github Tracker.
Justification: Allowed my team to be clearer on what we need to accomplish, to ensure productivity.

#### 3. Documentation
##### User Guide:
Added documentation for the features left and required
Updated documentation for the features timetable show, timetable modify, help, bye.

##### Developer Guide:
Added implementation details of the features left, required, timetable show.

#### 4. Fixed Bugs

- `Bye`: was case sensitive, needed to input twice to exit
2 changes: 0 additions & 2 deletions src/main/java/seedu/duke/controllers/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,4 @@ public void handleUserInputTillExitCommand() {





}
48 changes: 42 additions & 6 deletions src/main/java/seedu/duke/controllers/ModuleMethodsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,17 @@ public static void computePace(String[] arguments, int completedModuleCredits, S
+ "Recommended Pace: " + creditsPerSem + "MCs per sem until graduation");
}

//@@author janelleenqi
/**
* Displays the list of remaining module codes.
*
* This method takes an ArrayList of module codes and prints them to the console
* after displaying a header message.
*
* @param moduleCodesLeft An ArrayList of Strings representing the remaining module codes.
* It should not be null.
*/
public static void showModulesLeft(ArrayList<String> moduleCodesLeft) {
//add parser.IsInputVal
//boolean validInput = Parser.isValidInputForCommand(commandWord, arguments);
displayMessage("Modules Left: ");
printModuleStringArray(moduleCodesLeft);
}
Expand Down Expand Up @@ -243,35 +251,63 @@ public static void executeClearScheduleCommand(Student student){

}

/**
* Completes the specified module for the given student.
*
* This method attempts to mark the specified module as completed for the given student.
* It checks if the module is already completed, and if so, displays an error message
* and exits the method. If the module is not found in the student's schedule planner,
* a message is displayed. If the prerequisites for the module are not met, an error
* message is displayed, and the prerequisites are shown.
*
* @param student The student for whom the module is to be completed. Must not be null.
* @param moduleCode The code of the module to be completed. Must not be null.
* @throws MissingModuleException If the module does not exist in the student's schedule planner.
* @throws FailPrereqException If the prerequisites for the module are not met.
* Displays an error message and shows the prerequisites.
* @throws RuntimeException If an unexpected InvalidPrereqException occurs (should not happen).
*/
public static void completeModule(Student student, String moduleCode) {
try {
Module module = student.getModuleFromSchedule(moduleCode);
//if module is already completed, exit

// if module is already completed, exit
if (module.getCompletionStatus()) {
UserError.displayModuleAlreadyCompleted(module.getModuleCode());
return;
}

student.completeModuleSchedule(moduleCode);
try{
// update save file
try {
saveSchedule(student);
}catch (IOException ignored){
//we ignore first as GitHub actions cant save schedule on the directory
} catch (IOException ignored){
// GitHub actions cannot save schedule on the directory
}

} catch (MissingModuleException e) {
// module not does exist in schedule planner
displayMessage(e.getMessage());

} catch (InvalidObjectException e) {
assert false;
} catch (FailPrereqException e) {
// prerequisites are not met
displayMessage("Prerequisites not completed for " + moduleCode);
showPrereq(moduleCode, student.getMajor());
} catch (InvalidPrereqException e) {
throw new RuntimeException(e);
}
}

/**
* Prints the required modules for a student based on their major.
*
* This method calls the printRequiredModules function in MajorRequirementsView to print required modules for
* the specified major.
*
* @param major The major of the student that will be used to print the required modules.
*/
public static void getRequiredModulesForStudent(String major) {
printRequiredModules(major);
}
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/seedu/duke/controllers/ModuleServiceController.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,19 @@ public static boolean isConfirmedToClearSchedule() {
return userInput.equals("Y");
}

//@@author janelleenqi
/**
* Modifies the timetable for the specified student based on user input.
* Modifies the timetable for the given student based on user commands.
*
* @param student The student object.
* @throws InvalidModifyArgumentException If an invalid argument is provided.
* This method allows the user to modify the timetable for the current semester
* by processing user commands. It enters a loop to continuously accept commands
* until the user decides to exit. The modified timetable is saved after each
* successful modification. If the timetable view is available, it is printed.
* If the timetable view is unavailable, a simple guide is printed to inform the user.
*
* @param student The student for whom the timetable is to be modified.
* Must not be null.
* @throws InvalidModifyArgumentException If an invalid argument is provided during modification.
*/
public void modifyTimetable(Student student) throws InvalidModifyArgumentException {
Timetable timetable = student.getTimetable();
Expand Down Expand Up @@ -172,7 +180,7 @@ public void modifyTimetable(Student student) throws InvalidModifyArgumentExcepti
try {
saveTimetable(student);
} catch (IOException ignored){
//we ignore first as GitHub actions cant save timetable on the directory
// GitHub actions cannott save timetable on the directory
}
if (timetable.timetableViewIsAvailable()) {
printTimetable(currentSemModulesWeekly);
Expand All @@ -187,7 +195,16 @@ public void modifyTimetable(Student student) throws InvalidModifyArgumentExcepti
}
}


//@@author janelleenqi
/**
* Displays the timetable for the current semester based on the provided module weekly data.
*
* This method displays the timetable for the current semester using the ArrayList of ModuleWeekly objects to the
* user.
*
* @param currentSemesterModuleWeekly The list of ModuleWeekly objects with information about
* the timetable for the current semester
*/
public void showTimetable(ArrayList<ModuleWeekly> currentSemesterModuleWeekly) {
printTimetable(currentSemesterModuleWeekly);
}
Expand Down
Loading
Loading