Skip to content

Commit 54811ed

Browse files
authored
Merge pull request #143 from channne/branch-add-DG
Branch add dg
2 parents e116eba + d345c96 commit 54811ed

8 files changed

+250
-1
lines changed

docs/DeveloperGuide.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ The following **UML activity diagram** shows what happens when a user executes a
217217

218218
<img src="images/AddLabCommandActivityDiagram.png" width="600" />
219219

220+
220221
### `filter`: Filter Students by Labs Feature
221222

222223
The `filter` feature allows user to filter the list of students by their `Lab` and its `LabStatus`.
@@ -268,6 +269,79 @@ The following **UML activity diagram** shows what happens when a `filter` comman
268269

269270
<img src="images/FilterCommandActivityDiagram.png" width="850" />
270271

272+
273+
### `labedit`: Edit Lab Feature
274+
275+
#### Implementation
276+
The `labedit` feature allows for editing of the `LabStatus` and/or `LabMark` of a specified `Lab` in the TAddressBook.<br>
277+
The format of this command is `labedit INDEX l/LAB_NUMBER (s/LAB_STATUS) (m/LAB_MARK)`, where:
278+
* `INDEX` corresponds to the index number of a student, according to the currently displayed student list
279+
* `LAB_NUMBER` corresponds to an existing lab in the TAddressBook
280+
* `LAB_STATUS` is either `u`/`s`/`g` (`UNSUBMITTED`/`SUBMITTED`/`GRADED`)
281+
* `LAB_MARK` is an integer from 0 to 100 inclusive
282+
* The parentheses indicate that at least one of `s/LAB_STATUS` and `m/LAB_MARK` must be provided
283+
284+
The implementation of `labedit` is as follows:
285+
1. When `AddressBookParser#parseCommand` detects `labedit` as the command word, it creates a new `EditLabCommandParser` with the given arguments.
286+
2. `EditLabCommandParser` parses the parameters and throws a `ParseException` if any invalid values are encountered.
287+
3. `EditLabCommand#execute(Model)` will then execute with the current `Model` in the system.
288+
4. The `EditLabCommand` object checks if the given `INDEX` is out of bounds.
289+
5. The `EditLabCommand` object checks if the given combination of `LAB_STATUS` and `LAB_MARK` is valid.
290+
291+
<div markdown="span" class="alert alert-info">:information_source: **Note:** The valid combinations are:
292+
* `LAB_STATUS` and no `LAB_MARK`
293+
* `LAB_MARK` and no `LAB_STATUS`
294+
* `LAB_MARK` and `LAB_STATUS` of `GRADED`
295+
</div>
296+
297+
6. The `EditLabCommand` calls `LabList#setLab` of the student specified by the given `INDEX`, which edits the target `Lab` to the new `Lab`.
298+
299+
The following sequence diagram shows the interactions between components during a `labedit` command, `labedit l/1 s/u`:
300+
301+
<img src="images/EditLabCommandSequenceDiagram.png" width="850" />
302+
303+
<div markdown="span" class="alert alert-info">:information_source: **Note:** In the sequence diagram, the details of `LabList#setLab` have been intentionally omitted. They can be found in the sequence diagram below.
304+
</div>
305+
306+
The following sequence diagram shows how `LabList#setLab` is implemented:
307+
308+
<img src="images/LabListSetLabSequenceDiagram.png" width="550" />
309+
310+
The detailed steps are as follows:
311+
1. `LabList#setLab` checks if the edited `Lab` is the same as the original `Lab`, and whether the target `Lab` exists in the `LabList`.
312+
2. `LabList#setLab` edits the target `Lab` to the new `Lab` with different `LabStatus` and/or `LabMark`.
313+
314+
To summarize, the following activity diagram shows what happens when the user requests to edit a lab:
315+
316+
<img src="images/EditLabCommandActivityDiagram.png" width="500" />
317+
318+
319+
### \[Proposed\] Undo/redo feature
320+
321+
#### Proposed Implementation
322+
323+
The proposed undo/redo mechanism is facilitated by `VersionedAddressBook`. It extends `AddressBook` with an undo/redo history, stored internally as an `addressBookStateList` and `currentStatePointer`. Additionally, it implements the following operations:
324+
325+
* `VersionedAddressBook#commit()` — Saves the current TAddressBook state in its history.
326+
* `VersionedAddressBook#undo()` — Restores the previous TAddressBook state from its history.
327+
* `VersionedAddressBook#redo()` — Restores a previously undone TAddressBook state from its history.
328+
329+
These operations are exposed in the `Model` interface as `Model#commitAddressBook()`, `Model#undoAddressBook()` and `Model#redoAddressBook()` respectively.
330+
331+
Given below is an example usage scenario and how the undo/redo mechanism behaves at each step.
332+
333+
Step 1. The user launches the application for the first time. The `VersionedAddressBook` will be initialized with the initial TAddressBook state, and the `currentStatePointer` pointing to that single TAddressBook state.
334+
335+
![UndoRedoState0](images/UndoRedoState0.png)
336+
337+
Step 2. The user executes `delete 5` command to delete the 5th student in the TAddressBook. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the TAddressBook after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted TAddressBook state.
338+
339+
![UndoRedoState1](images/UndoRedoState1.png)
340+
341+
Step 3. The user executes `add n/David …​` to add a new student. The `add` command also calls `Model#commitAddressBook()`, causing another modified TAddressBook state to be saved into the `addressBookStateList`.
342+
343+
![UndoRedoState2](images/UndoRedoState2.png)
344+
271345
--------------------------------------------------------------------------------------------------------------------
272346

273347
## **Documentation, logging, testing, configuration, dev-ops**
@@ -540,3 +614,15 @@ testers are expected to do more *exploratory* testing.
540614

541615
3. Test case: `labadd l/-1`<br>
542616
Expected: A error message will appear with the correct command format and constraints and no lab will be added.
617+
618+
### Editing a Lab
619+
620+
1. Assume we want to edit `Lab 1` of the person with `INDEX 1` and the current `LabStatus` is `UNSUBMITTED`.
621+
1. Test case: `labedit 1 l/1 s/s`<br>
622+
Expected: The status of `Lab 1` will change from `UNSUBMITTED` to `SUBMITTED`. The lab label will change from red to yellow.
623+
624+
2. Test case: `labedit 1 l/1 s/g`<br>
625+
Expected: An error message will appear stating that the given combination is invalid.
626+
627+
3. Test case: `labedit 1 l/1 s/g m/10`<br>
628+
Expected: The status of `Lab 1` will change from `UNSUBMITTED` to `GRADED`. The lab label will change from red to green.

docs/UserGuide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ Example:
205205
#### View student details : `view`
206206
View a student's details from the TAddressBook. This includes their personal information (i.e. email, GitHub username, etc.)
207207
as well as the status and/or marks achieved for their labs. A sample result is shown below.<br>
208-
![viewUi](images/viewUI.png)
208+
209+
<img src="images/viewUI.png" width="420" />
209210

210211
Format: `view INDEX`
211212

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@startuml
2+
'https://plantuml.com/activity-diagram-beta
3+
4+
start
5+
:User executes labedit command;
6+
if () then ([valid command format])
7+
if () then ([index out of bounds])
8+
:Displays error message;
9+
else ([else])
10+
if () then ([valid combination of LabStatus and LabMark])
11+
if () then ([LabMark is 'Unknown'])
12+
:Creates new lab with given LabStatus;
13+
else ([else])
14+
:Creates new lab with LabStatus GRADED and given LabMark;
15+
endif
16+
if () then ([target lab exists and is different from new lab])
17+
:Edits target lab to new lab;
18+
else ([else])
19+
:Displays error message;
20+
endif
21+
else ([else])
22+
:Displays error message;
23+
endif
24+
endif
25+
else ([invalid command format or parameters])
26+
:Displays error message;
27+
endif
28+
stop
29+
30+
@enduml
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
@startuml
2+
'https://plantuml.com/sequence-diagram
3+
!include style.puml
4+
5+
box Logic LOGIC_COLOR_T1
6+
participant ":LogicManager" as LogicManager LOGIC_COLOR
7+
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
8+
participant ":EditLabCommandParser" as EditLabCommandParser LOGIC_COLOR
9+
participant "e:EditLabCommand" as EditLabCommand LOGIC_COLOR
10+
participant "c:CommandResult" as CommandResult LOGIC_COLOR
11+
end box
12+
13+
box Model MODEL_COLOR_T1
14+
participant "m:Model" as Model MODEL_COLOR
15+
participant ":List<Student>" as List MODEL_COLOR
16+
participant "s:Student" as Student MODEL_COLOR
17+
participant "list:LabList" as LabList MODEL_COLOR
18+
end box
19+
20+
[-> LogicManager : execute("labedit l/1 s/u")
21+
activate LogicManager
22+
23+
LogicManager -> AddressBookParser : parseCommand("labedit l/1 s/u")
24+
activate AddressBookParser
25+
26+
create EditLabCommandParser
27+
AddressBookParser -> EditLabCommandParser
28+
activate EditLabCommandParser
29+
30+
EditLabCommandParser --> AddressBookParser
31+
deactivate EditLabCommandParser
32+
33+
AddressBookParser -> EditLabCommandParser : parse("l/1 s/u")
34+
activate EditLabCommandParser
35+
36+
create EditLabCommand
37+
EditLabCommandParser -> EditLabCommand
38+
activate EditLabCommand
39+
40+
EditLabCommand --> EditLabCommandParser : e
41+
deactivate EditLabCommand
42+
43+
EditLabCommandParser --> AddressBookParser : e
44+
deactivate EditLabCommandParser
45+
EditLabCommandParser -[hidden]-> AddressBookParser
46+
destroy EditLabCommandParser
47+
48+
AddressBookParser --> LogicManager : e
49+
deactivate AddressBookParser
50+
51+
LogicManager -> EditLabCommand : execute(m)
52+
activate EditLabCommand
53+
54+
EditLabCommand -> Model : getFilteredStudentList()
55+
activate Model
56+
57+
Model --> EditLabCommand
58+
deactivate Model
59+
60+
EditLabCommand -> List : get(index)
61+
activate List
62+
63+
List --> EditLabCommand : s
64+
deactivate List
65+
66+
EditLabCommand -> Student : getLabs()
67+
activate Student
68+
69+
Student --> EditLabCommand : list
70+
deactivate Student
71+
72+
EditLabCommand -> LabList : getLab()
73+
activate LabList
74+
75+
LabList --> EditLabCommand : labToEdit
76+
deactivate LabList
77+
78+
EditLabCommand -> LabList : setLab(labToEdit, editedLab)
79+
activate LabList
80+
81+
LabList --> EditLabCommand
82+
deactivate LabList
83+
84+
create CommandResult
85+
EditLabCommand -> CommandResult
86+
activate CommandResult
87+
88+
CommandResult --> EditLabCommand
89+
deactivate CommandResult
90+
91+
EditLabCommand --> LogicManager
92+
deactivate EditLabCommand
93+
94+
[<--LogicManager :
95+
deactivate LogicManager
96+
97+
@enduml
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@startuml
2+
'https://plantuml.com/sequence-diagram
3+
!include style.puml
4+
5+
box Model MODEL_COLOR_T1
6+
participant "LabList" as LabList MODEL_COLOR
7+
participant "target:Lab" as Lab MODEL_COLOR
8+
participant ":ObservableList<Lab>" as ObservableList MODEL_COLOR
9+
end box
10+
11+
[-> LabList : setLab(target, editedLab)
12+
activate LabList
13+
14+
LabList -> Lab : equals(editedLab)
15+
activate Lab
16+
17+
Lab --> LabList
18+
deactivate Lab
19+
20+
LabList -> ObservableList : indexOf(target)
21+
activate ObservableList
22+
23+
ObservableList --> LabList
24+
deactivate ObservableList
25+
26+
LabList -> ObservableList : set(target, editedLab)
27+
activate ObservableList
28+
29+
ObservableList --> LabList
30+
deactivate ObservableList
31+
32+
[<-- LabList
33+
deactivate LabList
34+
35+
@enduml
47.9 KB
Loading
57.3 KB
Loading
15.1 KB
Loading

0 commit comments

Comments
 (0)