forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some conflicts from another PR that has been merged
- Loading branch information
Showing
74 changed files
with
3,186 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,23 +113,26 @@ Examples: | |
* `edit 1 p/91234567 e/[email protected]` Edits the phone number and email address of the 1st person to be `91234567` and `[email protected]` respectively. | ||
* `edit 2 n/Betsy Crower t/` Edits the name of the 2nd person to be `Betsy Crower` and clears all existing tags. | ||
|
||
### Locating persons by name: `find` | ||
### Filtering persons by name: `filter` | ||
|
||
Finds persons whose names contain any of the given keywords. | ||
Finds persons whose attributes contain any of the given keywords. | ||
|
||
Format: `find KEYWORD [MORE_KEYWORDS]` | ||
Format: `filter [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/CLASS] [s/SEX] [r/REGISTER_NUMBER] [en/ECNAME] [ep/ECNUMBER] [t/TAG]…` | ||
|
||
* The search is case-insensitive. e.g `hans` will match `Hans` | ||
* The order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans` | ||
* Only the name is searched. | ||
* Only full words will be matched e.g. `Han` will not match `Hans` | ||
* Persons matching at least one keyword will be returned (i.e. `OR` search). | ||
e.g. `Hans Bo` will return `Hans Gruber`, `Bo Yang` | ||
* Similar for emergency contact names and addresses | ||
* As for phone numbers, register numbers and class, the entire number must be provided in the command to filter | ||
|
||
Examples: | ||
* `find John` returns `john` and `John Doe` | ||
* `find alex david` returns `Alex Yeoh`, `David Li`<br> | ||
 | ||
* `filter n/John` returns `john` and `John Doe` | ||
* `filter p/99999999` returns `Alex Yeoh` | ||
* This image shows how students can be filtered using their phone number (99999999 - Alex Yeoh) | ||
 | ||
|
||
### Deleting a person : `delete` | ||
|
||
|
@@ -183,6 +186,26 @@ Examples: | |
* `addEcNumber 1 ep/91234567` to add the emergency contact's number 91234567 to the 1st person in the list. | ||
* `addEcNumber 2 ep/` to delete the emergency contact's number from the 2nd person in the list. | ||
|
||
### Adding Attendance : `addAttendance` | ||
|
||
Adds the date and reason as to why the specified person in the address book is absent. | ||
|
||
Format: `addAttendance INDEX aa/[DATE] ar/[REASON]` | ||
|
||
<box type="tip" seamless> | ||
|
||
**Tip:** You can delete the attendance by leaving the `REASON` field empty. | ||
</box> | ||
|
||
* Adds the date where student is absent `DATE` and the reason `REASON` to the person at the specified `INDEX` | ||
* Deletes the attendance at the specified `INDEX` | ||
* The index **must be a positive integer** 1, 2, 3, … | ||
* The date **must be in the form of DD-MM-YYYY**. | ||
|
||
Examples: | ||
* `addAttendance 1 aa/[24-09-2024] ar/[Sick]` to add the date where the 1st person in the list is absent and the reason. | ||
* `addAttendance 1 aa/[24-09-2024] ar/` to delete the attendance from the 1st person in the list. | ||
|
||
### Adding an Exam : `addExam` | ||
|
||
Adds an exam to every person in the address book. | ||
|
@@ -214,6 +237,37 @@ Examples: | |
* `addExamScore 1 ex/Midterm sc/70` | ||
* `addExamScore 1 ex/Midterm sc/NIL` | ||
|
||
### Adding a Submission : `addSubmission` | ||
|
||
Adds a submission to every person in the address book. | ||
|
||
Format: `addSubmission sm/SUBMISSION_NAME` | ||
|
||
<box type="tip" seamless> | ||
|
||
**Tip:** If a new student is added after a submission is added, the submission has to be added again for it to be reflected for the new student. | ||
</box> | ||
|
||
* The submission name can only contain alphanumeric characters and spaces. | ||
|
||
Examples: | ||
* `addSubmission sm/Assignment 1` | ||
|
||
### Adding a Submission Status: `addSubmissionStatus` | ||
|
||
Adds a submission status for the specified submission for the person at the specified index. | ||
|
||
Format: `addSubmissionStatus INDEX sm/SUBMISSION_NAME ss/SUBMISSION_STATUS` | ||
|
||
* The submission status must be a boolean value "T" or "F", or `NIL`. | ||
* The submission status can be edited using the same command with a different submission status. | ||
* The submission status can be deleted by entering the submission status as `NIL`. | ||
* The index **must be a positive integer** 1, 2, 3, … | ||
|
||
Examples: | ||
* `addSubmissionStatus 1 sm/Assignment 1 ss/T` | ||
* `addSubmissionStatus 1 sm/Tutorial 2 ss/NIL` | ||
|
||
### Sorting the list : `sort` | ||
|
||
Sorts the list of students based on the students attributes. | ||
|
@@ -282,17 +336,20 @@ _Details coming soon ..._ | |
|
||
## Command summary | ||
|
||
Action | Format, Examples | ||
-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
**Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS c/CLASS s/SEX r/REGISTER_NUMBER [t/TAG]…` <br> e.g., `add n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 1234665 c/1A s/M r/1 t/friend t/colleague` | ||
**Clear** | `clear` | ||
**Delete** | `delete INDEX`<br> e.g., `delete 3` | ||
**Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/CLASS] [s/SEX] [r/REGISTER_NUMBER] [en/ECNAME] [ep/ECNUMBER] [t/TAG]…`<br> e.g.,`edit 2 n/James Lee e/[email protected]` | ||
**Find** | `find KEYWORD [MORE_KEYWORDS]`<br> e.g., `find James Jake` | ||
**List** | `list` | ||
**Help** | `help` | ||
**Add Emergency Contact Name** | `addEcName INDEX [en/EMERGENCY CONTACT NAME]` <br> e.g., `addEcName 1 en/John Doe` | ||
**Add Emergency Contact Number** | `EcNumber INDEX [ep/EMERGENCY_CONTACT_NUMBER]`<br> e.g., `EcNumber 2 ep/91231234` | ||
**AddExam** | `addExam ex/EXAMNAME` <br> e.g., `addExam ex/Midterm` | ||
**AddExamScore** | `addExamScore INDEX ex/EXAMNAME sc/SCORE` <br> e.g., `addExamScore 1 ex/Midterm sc/70` | ||
**Sort** | `sort [ATTRIBUTE]` <br> e.g., `sort student class` | ||
| Action | Format, Examples | | ||
|----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| **Add** | `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS c/CLASS s/SEX r/REGISTER_NUMBER [t/TAG]…` <br> e.g., `add n/James Ho p/22224444 e/[email protected] a/123, Clementi Rd, 1234665 c/1A s/M r/1 t/friend t/colleague` | | ||
| **Clear** | `clear` | | ||
| **Delete** | `delete INDEX`<br> e.g., `delete 3` | | ||
| **Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/CLASS] [s/SEX] [r/REGISTER_NUMBER] [en/ECNAME] [ep/ECNUMBER] [t/TAG]…`<br> e.g.,`edit 2 n/James Lee e/[email protected]` | | ||
| **Filter** | `filter [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [c/CLASS] [s/SEX] [r/REGISTER_NUMBER] [en/ECNAME] [ep/ECNUMBER] [t/TAG]…`<br> e.g., `filter n/James p/90332234` | | ||
| **List** | `list` | | ||
| **Help** | `help` | | ||
| **Add Emergency Contact Name** | `addEcName INDEX [en/EMERGENCY CONTACT NAME]` <br> e.g., `addEcName 1 en/John Doe` | | ||
| **Add Emergency Contact Number** | `EcNumber INDEX [ep/EMERGENCY_CONTACT_NUMBER]`<br> e.g., `EcNumber 2 ep/91231234` | | ||
| **AddExam** | `addExam ex/EXAMNAME` <br> e.g., `addExam ex/Midterm` | | ||
| **AddExamScore** | `addExamScore INDEX ex/EXAMNAME sc/SCORE` <br> e.g., `addExamScore 1 ex/Midterm sc/70` | | ||
| **Add Attendance** | `addAttendance INDEX aa/[DATE] ar/[REASON]`<br> e.g., `addAttendance 1 aa/[24-09-2024] ar/[Sick]` | | ||
| **AddSubmission** | `addSubmission sm/SUBMISSION_NAME` <br> e.g., `addSubmission sm/Assignment 1` | | ||
| **AddSubmissionStatus** | `addSubmissionStatus INDEX sm/SUBMISSION_NAME ss/SUBMISSION_STATUS` <br> e.g., `addSubmissionStatus 1 sm/Assignment 1 ss/T` | | ||
| **Sort** | `sort [ATTRIBUTE]` <br> e.g., `sort student class` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions
101
src/main/java/seedu/address/logic/commands/AddAttendanceCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.person.AbsentDate; | ||
import seedu.address.model.person.AbsentReason; | ||
import seedu.address.model.person.Person; | ||
|
||
/** | ||
* Adds absent date and reason to an existing person in the address book. | ||
*/ | ||
public class AddAttendanceCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "addAttendance"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds the date where student " | ||
+ "identified by the index is absent and the reason. To delete date, leave the reason empty.\n" | ||
+ "Parameters: [INDEX] aa/DATE ar/REASON\n" | ||
+ "Example to add absent date: " + COMMAND_WORD + " 1 aa/24-09-2024 ar/MC\n" | ||
+ "Example to delete absent date: " + COMMAND_WORD + " 1 aa/24-09-2024 ar/\n"; | ||
|
||
public static final String MESSAGE_ADD_ATTENDANCE_SUCCESS = "Added attendance for Person: %1$s"; | ||
public static final String MESSAGE_DELETE_ATTENDANCE_SUCCESS = "Removed attendance from Person: %1$s"; | ||
|
||
private final Index index; | ||
private final AbsentDate absentDate; | ||
private final AbsentReason absentReason; | ||
|
||
/** | ||
* @param index of the person in the filtered person list to include why the person is absent | ||
* @param absentDate date where the person to be updated is absent | ||
* @param absentReason reason why the person to be updated is absent | ||
*/ | ||
public AddAttendanceCommand(Index index, AbsentDate absentDate, AbsentReason absentReason) { | ||
requireAllNonNull(index, absentDate, absentReason); | ||
|
||
this.index = index; | ||
this.absentDate = absentDate; | ||
this.absentReason = absentReason; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
List<Person> lastShownList = model.getFilteredPersonList(); | ||
|
||
if (index.getZeroBased() >= lastShownList.size()) { | ||
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); | ||
} | ||
|
||
Person personToEdit = lastShownList.get(index.getZeroBased()); | ||
|
||
HashMap<AbsentDate, AbsentReason> newAttendances = new HashMap<>(personToEdit.getAttendances()); | ||
if (absentReason.absentReason.isEmpty()) { | ||
newAttendances.remove(this.absentDate); | ||
} else { | ||
newAttendances.put(this.absentDate, this.absentReason); | ||
} | ||
|
||
Person editedPerson = new Person(personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(), | ||
personToEdit.getAddress(), personToEdit.getRegisterNumber(), personToEdit.getSex(), | ||
personToEdit.getStudentClass(), personToEdit.getEcName(), personToEdit.getEcNumber(), | ||
personToEdit.getExams(), personToEdit.getTags(), newAttendances, personToEdit.getSubmissions()); | ||
|
||
model.setPerson(personToEdit, editedPerson); | ||
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); | ||
return new CommandResult(generateSuccessMessage(editedPerson)); | ||
} | ||
|
||
private String generateSuccessMessage(Person personToEdit) { | ||
String message = !absentReason.absentReason.isEmpty() | ||
? MESSAGE_ADD_ATTENDANCE_SUCCESS : MESSAGE_DELETE_ATTENDANCE_SUCCESS; | ||
return String.format(message, Messages.format(personToEdit)); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
if (!(other instanceof AddAttendanceCommand)) { | ||
return false; | ||
} | ||
|
||
AddAttendanceCommand e = (AddAttendanceCommand) other; | ||
return index.equals(e.index) | ||
&& absentDate.equals(e.absentDate) | ||
&& absentReason.equals(e.absentReason); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.