Skip to content

Commit

Permalink
Merge pull request #130 from TaoJun99/branch-removeall
Browse files Browse the repository at this point in the history
Add feature to remove all completed assignments
  • Loading branch information
yeo-yiheng authored Oct 25, 2021
2 parents 2ad332b + e573f4e commit d093c2d
Show file tree
Hide file tree
Showing 26 changed files with 498 additions and 145 deletions.
57 changes: 27 additions & 30 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,56 +425,53 @@ persons who already have the assignment.
means it is less convenient for users as they have to do extra work.


### [Proposed] Removeall feature
The removeall command allows users to remove the specified assignment of all persons in the same module displayed in the GUI.
It is abstracted as `DeleteAssignmentOfAllCommand` and extends `Command`. When the user inputs the command,
### Clean feature
The clean command allows users to remove the all completed assignment of all persons stored in the model.
It is abstracted as `CleanAssignmentCommand` and extends `Command`. When the user inputs the command,
`Command#execute` is called and returns a `CommandResult`.

Given below is an example usage scenario and how the `DeleteAssignmentOfAllCommand` is executed.
Given below is an example usage scenario and how the `CleanAssignmentCommand` is executed.

Step 1. The user executes `list` command to see the current list of persons.

Step 2. The user executes `removeall m/CS2100 d/Assignment 2 by/ 03/10/2021` command to remove all the completed assignments.
When `Command#execute` is called, the `removeall m/...` command will filter out persons in the current displayed list
with the module field `CS2100`and remove the specified assignment if the person has completed the assignment.
<div markdown="span" class="alert alert-info">:information_source: **Note:** If there are no persons with the specified
module field or there are no persons who have completed the assignment, it will return an error to the user.

</div>
Step 2. The user executes `clean` command to remove all the completed assignments.
When `Command#execute` is called, the `clean` command will get the assignment list of all persons in the model and
remove all assignments with the completed status.

The following sequence diagram shows how the removeall command is executed:
![RemoveAllSequenceDiagram](images/RemoveAllSequenceDiagram.png)
The following sequence diagram shows how the clean command is executed:
![RemoveAllSequenceDiagram](images/CleanSequenceDiagram.png)

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

</div>

Step 3. The user executes `show 1` to check that the specified assignment has been removed for persons in the specified
module who has completed the assignment.
Step 3. The user executes `show 1` to check that all completed assignments has been removed for the first person.

The following activity diagram summarizes what happens when a user executes the removeall command:
The following activity diagram summarizes what happens when a user executes the clean command:

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

#### Design considerations:
**Aspect: Deletes assignment of persons in current displayed list or for all persons:**
**Aspect: Deletes completed assignments of person with assignments currently displayed or for all persons:**

* **Alternative 1 (current choice):** Deletes assignment of persons in current displayed list
* **Alternative 1:** Deletes completed assignments of person with assignments currently displayed
* Pros: Allows for a safer delete of assignments
* Cons: User has to carry out `list` command first if deletion of assignments is desired for all persons
* Cons: User has to carry out `show INDEX` command for every person if deletion of assignments is desired for all persons

* **Alternative 2:** Deletes assignment of all persons
* **Alternative 2(current choice):** Deletes completed assignment of all persons
* Pros: Allows user to delete assignment of all persons without the need of additional commands
* Cons: Undesired deletion of assignment of persons not in displayed list may occur

* Considering the fact that TA<sup>2</sup> is designed to be efficient in managing student submissions,**alternative 1** is
chosen. The potential undesired deletion of assignments in **alternative 2** means the user has to manually recover the
deleted assignment by adding the assignment again. Compared to the additional time taken to execute the `list` command
in **alternative 1**, it may take up much more time.
* Considering the fact that TA<sup>2</sup> is designed to be efficient in managing student submissions,**alternative 2** is
chosen. When the list of persons increase to considerable numbers, deletion of completed assignments will require the user
to input an additional command for each person. Bearing in mind that users make use of the `clean` command to remove
completed assignments that they no longer want to view, **alternative 2** does this job more efficiently. Although there
may be completed assignments that users want to keep in the list which they accidentally delete, there is the `undo` command
which allows the user to retrieve the desired assignments easily.

### \[Proposed\] Data archiving
### give feature
### Give feature
The give command allows users to add the specified assignment to a particular person is stored in the model.
Person who already has the specified assignment will not have a duplicated assignment added to him. The
command is abstracted as `AddAssignmentCommand` and extends `Command`. When the user inputs the command,
Expand Down Expand Up @@ -521,7 +518,7 @@ The following activity diagram summarizes what happens when a user executes the
assignments, which means it is less convenient for users as they have to do extra work.


### remove feature
### Remove feature
The remove command allows users to remove the specified assignment of a particular person in model.
It is abstracted as `DeleteAssignmentCommand` and extends `Command`. When the user inputs the command,
`Command#execute` is called and returns a `CommandResult`.
Expand All @@ -546,7 +543,7 @@ module with that assignment.

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

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

#### Design considerations:
**Aspect: Deletes assignment of a person in current displayed list or for any person in storage:**
Expand All @@ -565,7 +562,7 @@ The following activity diagram summarizes what happens when a user executes the
deleted assignment by adding the assignment again. Compared to the additional time taken to execute the `list` command
in **alternative 1**, it may take up much more time.

### done feature
### Done feature
The done command allows users to mark the specified assignment of a particular person in model.
It is abstracted as `MarkAssignmentCommand` and extends `Command`. When the user inputs the command,
`Command#execute` is called and returns a `CommandResult`.
Expand Down
7 changes: 7 additions & 0 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ Examples:
* `done 3` marks the 3rd assignment in the displayed assignment list as completed.


### Delete completed assignments from all persons: `clean`

Deletes all completed assignments from TA<sup>2</sup>.

Format: `clean`

### Clearing all entries : `clear`

Clears all entries from TA<sup>2</sup>.
Expand Down Expand Up @@ -286,6 +292,7 @@ Action | Format, Examples
**show** | `show INDEX` <br> e.g., `show 2`
**give** | `give INDEX d/DESCRIPTION by/ D/M/YYYY [HHMM]` <br> e.g., `give 1 d/Lab1 by/ 21/8/2021`
**giveall** | `giveall m/module d/DESCRIPTION by/ D/M/YYYY [HHMM]` <br> e.g., `give m/CS2100 d/Lab1 by/ 21/8/2021`
**clean** | `clean`
**remove** | `remove INDEX` <br> e.g., `remove 10`
**done** | `done INDEX` <br> e.g., `done 4`
**undo** | `undo`
Expand Down
16 changes: 16 additions & 0 deletions docs/diagrams/CleanActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@startuml
start
:User executes clean command;

'Since the beta syntax does not support placing the condition outside the
'diamond we place it as the true branch instead.
:Get all persons
stored in the model;
:Get assignment lists
of all persons;
:Delete assignment
if completed;


stop
@enduml
47 changes: 47 additions & 0 deletions docs/diagrams/CleanSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant "r:CleanAssignmentCommand" as CleanAssignmentCommand LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box


[-> LogicManager : execute(clean)
activate LogicManager

LogicManager -> AddressBookParser : parseCommand(clean)
activate AddressBookParser

create CleanAssignmentCommand
AddressBookParser -> CleanAssignmentCommand
activate CleanAssignmentCommand

CleanAssignmentCommand --> AddressBookParser
deactivate CleanAssignmentCommand

AddressBookParser --> LogicManager : u
deactivate AddressBookParser

LogicManager -> CleanAssignmentCommand : execute()
activate CleanAssignmentCommand

CleanAssignmentCommand -> Model : cleanAssignments()
activate Model

Model --> CleanAssignmentCommand
deactivate Model

CleanAssignmentCommand --> LogicManager : result
deactivate CleanAssignmentCommand
CleanAssignmentCommand -[hidden]-> LogicManager : result
destroy CleanAssignmentCommand

[<--LogicManager
deactivate LogicManager
@enduml
File renamed without changes.
20 changes: 0 additions & 20 deletions docs/diagrams/RemoveAllActivityDiagram.puml

This file was deleted.

55 changes: 0 additions & 55 deletions docs/diagrams/RemoveAllSequenceDiagram.puml

This file was deleted.

Binary file added docs/images/CleanActivityDiagram.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 added docs/images/CleanSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file removed docs/images/RemoveAllActivityDiagram.png
Binary file not shown.
Binary file removed docs/images/RemoveAllSequenceDiagram.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class AddAssignmentCommand extends Command {
+ PREFIX_DUEDATE + "DUEDATE\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_DESCRIPTION + "assignment2 "
+ PREFIX_DUEDATE + "11/11/2021 \n\n"
+ PREFIX_DUEDATE + " 11/11/2021 \n\n"
+ FRIENDLY_COMMAND_SYNTAX;

public static final String MESSAGE_SUCCESS = "New assignment added: %1$s";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static seedu.address.logic.parser.CliSyntax.*;

/**
* Adds an assignment to the person's assignment list.
* Adds an assignment to all persons' assignment list if under specified module.
*/
public class AddAssignmentToAllCommand extends Command {

Expand All @@ -29,15 +29,15 @@ public class AddAssignmentToAllCommand extends Command {
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_MODULE + "CS2100 "
+ PREFIX_DESCRIPTION + "assignment2 "
+ PREFIX_DUEDATE + "11/11/2021 ";
+ PREFIX_DUEDATE + " 11/11/2021 ";

public static final String MESSAGE_SUCCESS = "New assignment added to all persons in %1$s: %2$s";

private final Assignment toAdd;
private final Module module;

/**
* Creates an AddAssignmentCommand to add the specified {@code Assignment}
* Creates an AddAssignmentToAllCommand to add the specified {@code Assignment}
*/
public AddAssignmentToAllCommand(Module module, Assignment assignment) {
requireNonNull(assignment);
Expand All @@ -51,7 +51,7 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
// Get Person that match the Module
List<Person> filteredPersonList =
model.getFilteredPersonList()
model.getAddressBook().getPersonList()
.stream()
.filter(person -> person.hasModule(module))
.collect(Collectors.toList());
Expand All @@ -60,11 +60,7 @@ public CommandResult execute(Model model) throws CommandException {
throw new CommandException(MESSAGE_INVALID_PERSON_DISPLAYED_MODULE);
}

for (Person person: filteredPersonList) {
if (!model.hasAssignment(person, toAdd)) {
model.addAssignment(person, toAdd);
}
}
model.addAllAssignment(filteredPersonList, toAdd);

return new CommandResult(String.format(MESSAGE_SUCCESS, module, toAdd));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package seedu.address.logic.commands;

import seedu.address.model.Model;

import static java.util.Objects.requireNonNull;

/**
* Removes all completed assignments for all persons in the addressbook.
*/
public class CleanAssignmentCommand extends Command {

public static final String COMMAND_WORD = "clean";
public static final String MESSAGE_SUCCESS = "Completed assignments removed for all persons!";

@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.cleanAssignments();
return new CommandResult(MESSAGE_SUCCESS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import seedu.address.model.assignment.Status;
import seedu.address.model.person.Module;

import java.util.Locale;
import java.util.stream.Stream;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
Expand All @@ -32,7 +33,7 @@ public AddAssignmentToAllCommand parse(String args) throws ParseException {
AddAssignmentToAllCommand.MESSAGE_USAGE));
}

Module module = ParserUtil.parseModule(argMultimap.getValue(PREFIX_MODULE).get());
Module module = ParserUtil.parseModule(argMultimap.getValue(PREFIX_MODULE).get().toUpperCase(Locale.ROOT));
Description description = ParserUtil.parseDescription(argMultimap.getValue(PREFIX_DESCRIPTION).get());
DueDate dueDate = ParserUtil.parseDate(argMultimap.getValue(PREFIX_DUEDATE).get());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public Command parseCommand(String userInput) throws ParseException {
case RedoCommand.COMMAND_WORD:
return new RedoCommand();

case CleanAssignmentCommand.COMMAND_WORD:
return new CleanAssignmentCommand();

default:
throw new ParseException(MESSAGE_UNKNOWN_COMMAND);
}
Expand Down
Loading

0 comments on commit d093c2d

Please sign in to comment.