Skip to content

Commit

Permalink
Merge branch 'master' into ug-fixes-final
Browse files Browse the repository at this point in the history
  • Loading branch information
jessica2828 authored Nov 11, 2024
2 parents 96b4134 + 4d665f7 commit fb1f952
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 37 deletions.
13 changes: 8 additions & 5 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ EduContacts is a **desktop app for educators in tertiary institutions in Singapo
```
Deletes all contacts.

<box type="warning" seamless>
<box type="warning" seamless>

**Warning:**
The `clear` command will erase all contacts from the system. Please ensure that you have backed up any important information before proceeding. This action cannot be undone, so use this command with caution.
**Warning:**
The `clear` command will erase all contacts from the system. Please ensure that you have backed up any important information before proceeding. This action cannot be undone, so use this command with caution.

</box>
</box>

```bash
exit
Expand Down Expand Up @@ -289,13 +289,16 @@ edit ID m/ OLD_MODULE NEW_MODULE
```
* Updates a module of the person identified by the studentId.
* Existing module (`OLD_MODULE`) will be overwritten by the input module (`NEW_MODULE`).
* Editing of `NAME`, `PHONE`, `EMAIL`, `ADDRESS`, `COURSE` and `ROLE` using this format is not supported.

Examples:

* `edit 12345678 m/CS2103T CS2101` will edit a person with student ID of `12345678` by replacing the old module `CS2103T` with the new module `CS2101`.
* `edit 12345678 c/Computer Science` will edit a person with student ID of `12345678` by editing their course to `Computer Science` (the response message of this command is shown in the screenshot below).
* `edit 12121212 c/Computer Science` will edit a person with student ID of `12121212` by editing their course to `Computer Science` (the response message of this command is shown in the screenshot below).

![result for 'edit command result'](images/editCommandResult.png)


<box type="tip" seamless>

**Tip:** Use the `find` command to view the full detail of the student first before proceeding with `edit`. This allows you to view the changes and verify the edit immediately.</box>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class AddCommand extends Command {

public static final String COMMAND_WORD = "add";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to EduContacts. "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to EduContacts.\n"
+ "Parameters: "
+ "ID "
+ PREFIX_NAME + "NAME "
Expand Down
21 changes: 8 additions & 13 deletions src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_MODULE;

import java.util.List;

Expand All @@ -19,16 +20,14 @@ public class DeleteCommand extends Command {

public static final String COMMAND_WORD = "delete";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the student identified by the Student ID used in the displayed person list,\n"
+ "or deletes a module from the person's module list.\n"
+ "Parameters: "
+ "ID\n"
+ "or: "
+ "ID MODULE_KEYWORD\n"
+ "Example: " + COMMAND_WORD + " "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": 2 possible usages\n"
+ "1. Deletes the student identified by the Student ID used in the displayed person list.\n"
+ " Parameters: ID\n"
+ " Example: " + COMMAND_WORD + " "
+ "12345678\n"
+ "or: " + COMMAND_WORD + " "
+ "2. Deletes a module from the person's module list.\n"
+ " Parameters: ID " + PREFIX_MODULE + "MODULE\n"
+ " Example: " + COMMAND_WORD + " "
+ "12345678 m/CS2103T";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Student: %1$s";
Expand Down Expand Up @@ -71,7 +70,6 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
List<Person> lastShownList = model.getFilteredPersonList();
Person toDelete = null;

boolean isPersonDetailsDeleted = false;

for (Person person : lastShownList) {
Expand Down Expand Up @@ -114,13 +112,10 @@ public CommandResult execute(Model model) throws CommandException {

if (toDelete.isSamePerson(model.getPersonToDisplay())) {
model.setPersonToDisplay(null);

isPersonDetailsDeleted = true;
}

model.deletePerson(toDelete);
if (isPersonDetailsDeleted) {

return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(toDelete)), true);
}
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(toDelete)));
Expand Down
24 changes: 13 additions & 11 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,27 @@ public class EditCommand extends Command {

public static final String COMMAND_WORD = "edit";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": 2 possible usages"
+ " 1. Edits the details of the person identified "
+ "by the studentId assigned to the corresponding student. "
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: ID (must be a valid and existing 8-digit ID) "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": 2 possible usages\n"
+ "1. Edits the details of the person identified "
+ "by the studentId assigned to the corresponding student. \n"
+ " Existing values will be overwritten by the input values.\n"
+ " Parameters: ID "
+ "[ID] "
+ "[" + PREFIX_NAME + "NAME] "
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
+ "[" + PREFIX_COURSE + " COURSE] "
+ "[" + PREFIX_ROLE + "ROLE] ...\n"
+ "Example: " + COMMAND_WORD + " 12345678 "
+ " Example: " + COMMAND_WORD + " 12345678 "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_EMAIL + "[email protected]"
+ " 2. Edits a module of the person identified. "
+ "Existing values will be overwritten by the input module.\n"
+ "Parameters: ID (must be a valid and existing 8-digit ID "
+ PREFIX_MODULE + " OLD_MODULE NEW_MODULE";
+ PREFIX_EMAIL + "[email protected]\n"
+ "2. Edits a module of the person identified. \n"
+ " Existing values will be overwritten by the input module.\n"
+ " Parameters: ID "
+ PREFIX_MODULE + "OLD_MODULE NEW_MODULE\n"
+ " Example: " + COMMAND_WORD + " 12345678 "
+ PREFIX_MODULE + "CS2103T CS2101";

public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s";
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public class FindCommand extends Command {

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Finds the student identified by the Student ID used and displays their details.\n"
+ "Parameters: "
+ "ID\n"
+ "Parameters: ID \n"
+ "Example: " + COMMAND_WORD + " "
+ "12345678";

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/logic/commands/GradeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class GradeCommand extends Command {

public static final String COMMAND_WORD = "grade";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Assigns a course-specific grade to a student. "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Assigns a course-specific grade to an existing "
+ "module of the person identified.\n"
+ "Parameters: "
+ "ID "
+ PREFIX_MODULE + "MODULE "
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/seedu/address/logic/commands/ModuleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ public class ModuleCommand extends Command {

public static final String COMMAND_WORD = "module";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a module to a student. "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a module to a student.\n"
+ "Parameters: "
+ "ID "
+ PREFIX_MODULE + "MODULE "
+ "\n"
+ PREFIX_MODULE + "MODULE\n"
+ "Example: " + COMMAND_WORD + " "
+ "12345678 "
+ PREFIX_MODULE + "CS2103T ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ public EditCommand parse(String args) throws ParseException {
EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor();

if (argMultimap.getValue(PREFIX_MODULE).isPresent()) {
if (argMultimap.getValue(PREFIX_NAME).isPresent() || argMultimap.getValue(PREFIX_PHONE).isPresent()
|| argMultimap.getValue(PREFIX_EMAIL).isPresent() || argMultimap.getValue(PREFIX_ADDRESS).isPresent()
|| argMultimap.getValue(PREFIX_COURSE).isPresent() || argMultimap.getValue(PREFIX_ROLE).isPresent()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE));
}

String[] modules = argMultimap.getValue(PREFIX_MODULE).get().split(" ");
if (modules.length != 2) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE));
}

editPersonDescriptor.setModuleChanges(new Module(modules[0].toUpperCase()),
new Module(modules[1].toUpperCase()));
} else {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/seedu/address/model/person/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
public class Module {

public static final String MESSAGE_CONSTRAINTS =
"Modules should only contain alphanumeric characters, and it should not be blank";
"Modules should only contain alphanumeric characters and spaces, and it should not be blank";

/*
* The first character of the Module must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
*/
public static final String VALIDATION_REGEX = "^[a-zA-Z0-9]+$";

public final String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,30 @@ public void parse_missingModuleArguments_failure() {
assertParseFailure(parser, userInput, MESSAGE_INVALID_FORMAT);
}

@Test
public void parse_moduleAndOtherFieldsPresent_failure() {
String studentId = "12345678";
String userInputWithExtraName = studentId + " m/ CS1010S CS1231S n/ Amy Bee";
String userInputWithExtraPhone = studentId + " m/ CS1010S CS1231S p/ 11111111";
String userInputWithExtraEmail = studentId + " m/ CS1010S CS1231S e/ [email protected]";
String userInputWithExtraAddress = studentId + " m/ CS1010S CS1231S a/ 321 Clementi";
String userInputWithExtraCourse = studentId + " m/ CS1010S CS1231S c/ Physics";
String userInputWithExtraRole = studentId + " m/ CS1010S CS1231S r/ Student";

assertParseFailure(parser, userInputWithExtraName, String.format(MESSAGE_INVALID_COMMAND_FORMAT,
EditCommand.MESSAGE_USAGE));
assertParseFailure(parser, userInputWithExtraPhone, String.format(MESSAGE_INVALID_COMMAND_FORMAT,
EditCommand.MESSAGE_USAGE));
assertParseFailure(parser, userInputWithExtraEmail, String.format(MESSAGE_INVALID_COMMAND_FORMAT,
EditCommand.MESSAGE_USAGE));
assertParseFailure(parser, userInputWithExtraAddress, String.format(MESSAGE_INVALID_COMMAND_FORMAT,
EditCommand.MESSAGE_USAGE));
assertParseFailure(parser, userInputWithExtraCourse, String.format(MESSAGE_INVALID_COMMAND_FORMAT,
EditCommand.MESSAGE_USAGE));
assertParseFailure(parser, userInputWithExtraRole, String.format(MESSAGE_INVALID_COMMAND_FORMAT,
EditCommand.MESSAGE_USAGE));
}

@Test
public void parse_noModulesProvided_noModuleChange() {
String studentId = "12345678";
Expand Down

0 comments on commit fb1f952

Please sign in to comment.