Skip to content

Commit

Permalink
Merge pull request #235 from juliussneezer04/master
Browse files Browse the repository at this point in the history
Bug Fixes
  • Loading branch information
rushilramesh authored Nov 6, 2021
2 parents 9b2befd + 4feb683 commit f31fcd0
Show file tree
Hide file tree
Showing 45 changed files with 351 additions and 149 deletions.
108 changes: 19 additions & 89 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,86 +154,6 @@ Classes used by multiple components are in the `seedu.address.commons` package.

This section describes some noteworthy details on how certain features are implemented.

### \[Proposed\] Undo/redo feature

#### Proposed Implementation

The proposed undo/redo mechanism is facilitated by `VersionedClassmate`. It extends `Classmate` with an undo/redo history, stored internally as an `classmateStateList` and `currentStatePointer`. Additionally, it implements the following operations:

* `VersionedClassmate#commit()` — Saves the current ClassMATE state in its history.
* `VersionedClassmate#undo()` — Restores the previous ClassMATE state from its history.
* `VersionedClassmate#redo()` — Restores a previously undone ClassMATE state from its history.

These operations are exposed in the `Model` interface as `Model#commitClassmate()`, `Model#undoClassmate()` and `Model#redoClassmate()` respectively.

Given below is an example usage scenario and how the undo/redo mechanism behaves at each step.

Step 1. The user launches the application for the first time. The `VersionedClassmate` will be initialized with the initial ClassMATE state, and the `currentStatePointer` pointing to that single ClassMATE state.

![UndoRedoState0](images/UndoRedoState0.png)

Step 2. The user executes `deletestu 5` command to delete the 5th student in the student list. The `deletestu` command calls `Model#commitClassmate()`, causing the modified state of ClassMATE after the `deletestu 5` command executes to be saved in the `classmateStateList`, and the `currentStatePointer` is shifted to the newly inserted ClassMATE state.

![UndoRedoState1](images/UndoRedoState1.png)

Step 3. The user executes `addstu n/David …​` to add a new student. The `addstu` command also calls `Model#commitClassmate()`, causing another modified ClassMATE state to be saved into the `classmateStateList`.

![UndoRedoState2](images/UndoRedoState2.png)

<div markdown="span" class="alert alert-info">:information_source: **Note:** If a command fails its execution, it will not call `Model#commitClassmate()`, so the ClassMATE state will not be saved into the `classmateStateList`.

</div>

Step 4. The user now decides that adding the student was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoClassmate()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous ClassMATE state, and restores ClassMATE to that state.

![UndoRedoState3](images/UndoRedoState3.png)

<div markdown="span" class="alert alert-info">:information_source: **Note:** If the `currentStatePointer` is at index 0, pointing to the initial ClassMATE state, then there are no previous ClassMATE states to restore. The `undo` command uses `Model#canUndoClassmate()` to check if this is the case. If so, it will return an error to the user rather
than attempting to perform the undo.

</div>

The following sequence diagram shows how the undo operation works:

![UndoSequenceDiagram](images/UndoSequenceDiagram.png)

<div markdown="span" class="alert alert-info">:information_source: **Note:** The lifeline for `UndoCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

</div>

The `redo` command does the opposite — it calls `Model#redoClassmate()`, which shifts the `currentStatePointer` once to the right, pointing to the previously undone state, and restores the ClassMATE to that state.

<div markdown="span" class="alert alert-info">:information_source: **Note:** If the `currentStatePointer` is at index `classmateStateList.size() - 1`, pointing to the latest ClassMATE state, then there are no undone ClassMATE states to restore. The `redo` command uses `Model#canRedoClassmate()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo.

</div>

Step 5. The user then decides to execute the command `liststu`. Commands that do not modify ClassMATE, such as `liststu`, will usually not call `Model#commitClassmate()`, `Model#undoClassmate()` or `Model#redoClassmate()`. Thus, the `classmateStateList` remains unchanged.

![UndoRedoState4](images/UndoRedoState4.png)

Step 6. The user executes `clear`, which calls `Model#commitClassmate()`. Since the `currentStatePointer` is not pointing at the end of the `classmateStateList`, all ClassMATE states after the `currentStatePointer` will be purged. Reason: It no longer makes sense to redo the `add n/David …​` command. This is the behavior that most modern desktop applications follow.

![UndoRedoState5](images/UndoRedoState5.png)

The following activity diagram summarizes what happens when a user executes a new command:

<img src="images/CommitActivityDiagram.png" width="250" />

#### Design considerations:

**Aspect: How undo & redo executes:**

* **Alternative 1 (current choice):** Saves the entire ClassMATE.
* Pros: Easy to implement.
* Cons: May have performance issues in terms of memory usage.

* **Alternative 2:** Individual command knows how to undo/redo by
itself.
* Pros: Will use less memory (e.g. for `deletestu`, just save the student being deleted).
* Cons: We must ensure that the implementation of each individual command are correct.

_{more aspects and alternatives to be added}_

### Tutorial Class Management Features
(Contributed by Rushil Ramesh and Vishnu Sundaresan)

Expand Down Expand Up @@ -524,7 +444,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli

| Priority | As a …​ | I want to …​ | So that I can…​ |
| -------- | ------------------------------------------ | ------------------------------ | ---------------------------------------------------------------------- |
| `* * *` | new user | see usage instructions | refer to instructions when I forget how to use the App |
| `* * *` | new user | see help | refer to instructions when I forget how to use the App |
| `* *` | new user | view sample data | see what the app looks like when in use |
| `* * *` | user | add a new student | |
| `* * *` | user | view a student's details | easily check the details and progress of the students |
Expand All @@ -538,11 +458,10 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
| `* * *` | user | view all classes | see which classes I'm taking |
| `* * *` | user | view all students in a class | see the students enrolled in a particular class |
| `* *` | experienced user | add class participation details to a student | track the paricipation of each student |
| `* *` | user | hide private contact details | minimize chance of someone else seeing them by accident |
| `*` | user with many students in ClassMATE | sort students by name | locate a student easily |
| `*` | user with many classes in ClassMATE | sort classes by name | locate a class easily |

*{More to be added}*
| `* *` | experienced user | add groups within tutorial classes | to organise my class groups |
| `* *` | experienced user | add students to specific sub-groups | to organise students in groups based on examination (e.g. OP1) |
| `* *` | experienced user | delete students from specific sub-groups | remove students from the group as required |
| `*` | user | add different types of marks to students | to mark students for various assessments |

### Use cases

Expand Down Expand Up @@ -731,13 +650,24 @@ testers are expected to do more *exploratory* testing.

1. Other incorrect delete commands to try: `delete`, `delete x`, `...` (where x is larger than the list size)<br>
Expected: Similar to previous.
1. Deleting a student that at a negative index.
1. Prerequisites: List all students using the `liststu` command. Multiple students in the list.
1. Test case: `deletestu -5`<br>
Expected: No student is deleted. Error details shown in the status message. Status bar remains the same.
1. Other incorrect delete commands to try: `delete`, `delete x`, `...` (where x is larger than the list size)<br>
Expected: Similar to previous.

1. _{ more test cases …​ }_

### Saving data

1. Dealing with missing/corrupted data files

1. _{explain how to simulate a missing/corrupted file, and the expected behavior}_
1. Prerequisites: None

1. _{ more test cases …​ }_
2. Test case: JSON file missing.<br>

Expected: ClassMATE gives warning about missing storage, and creates a new storage file populated with sample data.

3. Test case: JSON file corrupted

Expected: ClassMATE gives warning about corrupted data, and creates a new storage file populated with sample data.
77 changes: 43 additions & 34 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Once you have attempted these commands, you're ready to go!

<div markdown="block" class="alert alert-info">
**:information_source: Notes about the command format:**<br>
These are general rules applying to all explanations and command formats listed below!


* Words in `UPPER_CASE` are the parameters to be supplied by the user.<br>
e.g. in `addstu n/NAME`, `NAME` is a parameter which can be used as `add n/John Doe`.
Expand All @@ -110,6 +112,10 @@ Once you have attempted these commands, you're ready to go!
* If you add parameters for commands that do not take in parameters (such as `help`, `liststu`, `exit` and `clear`), they will be ignored.<br>
e.g. if the command specifies `help 123`, it will be interpreted as `help`.

* `INDEX` items must be positive integers. Negative integers, decimal values, and zero will not be accepted for any command `INDEX`. <br>

e.g. if the command `viewstu -5` is entered, it will throw an invalid command format error, telling you to enter a positive integer `INDEX` only!

</div>

## Features
Expand All @@ -135,17 +141,23 @@ Adds a tutorial class to ClassMATE.

Entering format: `addc c/CLASS_CODE s/SCHEDULE [t/TAG]…​`

<div markdown="span" class="alert alert-primary"> :bulb: **Note:**
<div markdown="span" class="alert alert-primary"> :bulb: ** Note: ** <br>
Class Code should consist of 'G' followed by two numerical digits (i.e. any value from 'G01' to 'G99').<br>
Schedule consists of 2 weekly timeslots
</div>

* Schedule should strictly follow the format: [Day] (hh:mm)am/pm to (hh:mm)am/pm, [Day]...

* Incorrect timings are not checked.

* Class Code should consist of 'G' followed by two numerical digits (i.e. any value from 'G01' to 'G99').
* Schedule consists of 2 weekly timeslots
<div markdown="span" class="alert alert-primary">:warning: **Warning:**
Entering wrong/impossible timings is possible and will not be stopped. Enter schedule timings carefully. :warning:
</div>

Examples:

* `addc c/G06 s/Tuesday 2 to 4pm, Friday 2 to 4pm`
* `addc c/G01 s/Monday 10am to 12pm, Thursday 10am to 12pm`
* `addc c/G06 s/Tuesday 2:00pm to 4:00pm, Friday 2:00 to 4:00pm`
* `addc c/G01 s/Monday 10:00am to 12:00pm, Thursday 10:00am to 12:00pm`

### Viewing a class: `viewc`

Expand All @@ -154,15 +166,16 @@ Examples:
Views a class in ClassMATE, as shown above

<div markdown="span" class="alert alert-info">:information_source: **Note:**<br>
`viewc` highlights the class chosen, and filters out only students in the class!
`viewc` highlights the class at the given INDEX, and filters out only students in that class!
</div>



Entering format: `viewc INDEX`

* Views the class details at the specified INDEX.
* Details of a class includes students in the class and the class schedule.
* The index refers to the index number shown in the displayed list of classes.
* The index refers to the index number shown in the displayed list of classes, **not the Class Code**.
* The index must be a positive integer 1, 2, 3, …​

<div markdown="span" class="alert alert-primary">:bulb: **Tip:**
Expand All @@ -186,12 +199,11 @@ Find classes by class codes.

Entering format: `findc KEYWORD [MORE_KEYWORDS]`

* The search is not absolute. e.g `G0` will match `G06`
* The search is absolute. e.g `G0` will not match `G06`

Examples:

* `findc G02` returns `G02` if it exists
* `findc G` returns `G01`, `G02`, `G03`<br>
* `findc G02` returns `G02` if it exists<br>

### Deleting a class: `deletec`

Expand Down Expand Up @@ -229,15 +241,12 @@ Adds a student to ClassMATE.

Entering format: `addstu n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS c/CLASS_CODE [t/TAG]…​`

<div markdown="span" class="alert alert-info">:information_source: **Notes about addstu:** <br>

* The Name of a student accommodates special characters such as hyphens, apostrophes and slashes.
* The phone number should be at least 3 digits long.
* The tutorial class with the given Class Code must already exist in classmate.
* A student can have any number of tags (including 0)

</div>

Examples:
* If class G06 has not been created, add the class first using `addc`.
* `addstu n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01 c/G06`
Expand All @@ -250,9 +259,19 @@ Edits an existing student in ClassMATE.
Entering format: `editstu INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/CLASS_CODE] [t/TAG]…​`

* Edits the student at the specified `INDEX`. The index refers to the index number shown in the displayed student list. The index **must be a positive integer** 1, 2, 3, …​

* At least one of the optional fields must be provided.

* The index will be checked *after* it checks for provision of at least one optional field.

<div markdown="span" class="alert alert-primary"> :information-source: **Note:**
An error message will be displayed to provide at least one field if no fields are provided, regardless of whether the INDEX is valid or not. The INDEX will be checked after at least one optional field is provided.
</div>

* Existing values will be updated to the input values.

* When editing tags, the existing tags of the student will be removed i.e adding of tags is not cumulative.

* You can remove all the student’s tags by typing `t/` without
specifying any tags after it.

Expand Down Expand Up @@ -372,17 +391,6 @@ Examples:
* `liststu` followed by `addlm 2 m/Low` and `deleteam 2` deletes all marks assigned to the 2nd student in the student list.
* `findstu Betsy` followed by `deleteam 1` deletes all sessions' mark for 1st student in the results of `findstu`.

### Clearing all students : `clear`

Clears all students from ClassMATE. Below is how it would look like.

![clear](images/clear.png)

Entering format: `clear`

<div markdown="span" class="alert alert-primary">:warning: **Warning:**
This command deletes **ALL** students and is irreversible :warning:
</div>

## Tutorial Class Commands

Expand All @@ -401,16 +409,12 @@ Adds a tutorial class to ClassMATE.

Entering format: `addc c/CLASS_CODE s/SCHEDULE [t/TAG]…​`

<div markdown="span" class="alert alert-primary"> :information-source: **Note:**

* Class Code should consist of 'G' followed by two numerical digits (i.e. any value from `G01` to `G99`).

* Schedule consists of 2 weekly timeslots. Day of the week should be capitalized. Short form for days are also accepted (e.g. Tues for Tuesday).

* Time slots in Schedules should be written in the H:MM am/pm (e.g. 12:00pm)

</div>

Examples:
* `addc c/G01 s/Tuesday 2:00pm to 4:00pm, Friday 2:00 to 4:00pm`
* With short form for days: `addc c/G02 s/Tues 10:00am to 12:00pm, Fri 10:00am to 12:00pm`
Expand All @@ -420,10 +424,16 @@ Examples:

![viewing a class](images/viewc.png)

Displayes a class and its students in ClassMATE, as shown above.
Displays a class and its students in ClassMATE, as shown above.

<div markdown="span" class="alert alert-info">:information_source: **Note:**<br>
`viewc` highlights the class chosen, and filters out only students in the class!
</div>
<div markdown="span" class="alert alert-primary">:bulb: **Tip:**


In order to view all classes after, use the `listc` command. To view all students after, use `liststu`

</div>

Entering format: `viewc INDEX`
Expand Down Expand Up @@ -553,7 +563,7 @@ Only `OP1` and `OP2` are accepted as Group Types.


Example:
* `liststu c/G06`shows that Betsy is a student in class G06, with Index 1.
* `liststu` shows that Betsy is a student in class G06, with Index 1.
`addsg 1 gn/1 c/G06 type/OP1` then adds the student at Index 1, Betsy, to OP1 Group 1 in class G06

### Deleting Student from a group: `deletesg`
Expand All @@ -571,7 +581,7 @@ Only `OP1` and `OP2` are accepted as Group Types.


Example:
* `liststu c/G06`shows that Betsy is a student in class G06 with Index 1.
* `liststu`shows that Betsy is a student in class G06 with Index 1.
`deletesg 1 g/A c/G06 type/OP1` then removes Betsy from OP1 Group A in class G06

### Clearing all data : `clear`
Expand Down Expand Up @@ -618,8 +628,8 @@ If your changes to the data file makes its format invalid, ClassMATE will discar
Action | Format, Examples
--------|------------------
**Help** | `help`
**Add student** | `addstu n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS c/CLASS_CODE [t/TAG]…​`<br> e.g., `add n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 1234665 c/G01 t/attentive`
**Edit student** | `editstu INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/CLASS_CODE] [t/TAG]…​`<br> e.g., `edit 2 n/James Lee e/[email protected]`
**Add student** | `addstu n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS c/CLASS_CODE [t/TAG]…​`<br> e.g., `addstu n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 1234665 c/G01 t/attentive`
**Edit student** | `editstu INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/CLASS_CODE] [t/TAG]…​`<br> e.g., `editstu 2 n/James Lee e/[email protected]`
**View student** | `viewstu INDEX`<br> e.g., `liststu` followed by `viewstu 2`
**Find student** | `findstu KEYWORD [MORE_KEYWORDS]`<br> e.g., `findstu John`
**Delete student** | `deletestu INDEX`<br> e.g., `liststu` followed by `deletestu 3`
Expand All @@ -631,7 +641,6 @@ Action | Format, Examples
**Find class** | `findc KEYWORD [MORE_KEYWORDS]`<br> e.g., `findc G02`
**Add Tutorial Group** | `addcg gn/GROUP_NUMBER c/CLASS_CODE type/TYPE` <br> e.g.,`addcg gn/1 c/G01 type/OP1`
**Delete Tutorial Group** | `deletecg gn/GROUP_NUMBER c/CLASS_CODE type/TYPE` <br> e.g., `deletecg gn/1 c/G11 type/OP1`
**List Tutorial Group** | `listg`
**Add Student to Group** | `addsg INDEX g/GROUP_NUMBER c/CLASSCODE type/TYPE` <br> e.g., `addsg 1 gn/1 c/G01 type/OP1`
**Delete Student from Group** | `deletesg INDEX g/GROUP_NUMBER c/CLASSCODE type/TYPE` <br> e.g., `deletesg 1 gn/1 c/G01 type/OP1`
**Clear all students** | `clear`
Expand Down
Binary file modified docs/diagrams/AddGroupSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/diagrams/BetterModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/diagrams/BetterModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ Student *--> Name
Student *--> Phone
Student *--> Email
Student *--> Address
Student *--> StudentMark
TutorialClass *--> Schedule
@enduml
Binary file modified docs/diagrams/ModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Class TutorialClass
Class TutorialGroup
Class Address
Class Email
Class StudentMark
Class Name
Class Phone
Class Tag
Expand Down Expand Up @@ -58,6 +59,7 @@ Student *--> Email
Student *--> Address
Student *--> ClassCode
Student *--> "*" Tag
Student *--> "*" StudentMark
TutorialClass *--> ClassCode
TutorialClass *--> "*" Tag
TutorialClass *--> Schedule
Expand Down
Binary file modified docs/diagrams/StorageClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f31fcd0

Please sign in to comment.