Skip to content

Commit

Permalink
Merge branch 'master' into edit-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
qinxutan authored Apr 4, 2024
2 parents 6ffb03b + 1c70f47 commit a58cf92
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 10 deletions.
14 changes: 8 additions & 6 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Parameters:
| TUTORIAL | tutorial/ | Follows the format of NUS tutorial class naming, which starts with 1 alphabetical letter and 2 numeric integers from 0-9. |
| TEAMNAME | team/ | Alphanumeric characters |
| TAG | tag/ | tag associated with the student. Alphanumeric characters |
| SIZE | size/ | The size of the team. A single numeric integer value that is more than 0. |
| SIZE | size/ | The size of the team or class. A single numeric integer value that is more than 0. |
| DESCRIPTION | description/ | The description of the module. |
| BY | by/ | The parameter you want to search by, Alphanumeric characters |
| INDEX | index/ | The index of the associated student |
Expand Down Expand Up @@ -350,19 +350,21 @@ Explanation: This allocates a student with index position `1` in the tutorial cl

Adds a tutorial class with the specified module code and name.

Format: `/add_class module/MODULE_CODE class/TUTORIAL_CLASS`
Format: `/add_class module/MODULE_CODE class/TUTORIAL_CLASS [description/DESC] [size/SIZE]`

Note:
- An optional class size can be specified to apply a size restriction on the class.
- Class size must be a positive integer. Any invalid inputs (non-numeric, negative integers) returns an error.
- If none of the parameters is specified, or if only one is specified, returns an error.

Examples:

- `/add_class module/CS2103T class/T10` <br>
Explanation: If module `CS2103T` already exists in the system, adds a tutorial class `T10` to the existing module.
Else, creates a new module `CS2103T` with 1 tutorial class under it: `T10`
- `/add_class module/CS2109S class/T01` <br>
- `/add_class module/CS2109S class/T01 description/Introduction to AI size/10` <br>
Explanation: If module `CS2109S` already exists in the system, adds a tutorial class `T01` to the existing module.
Else, creates a new module `CS2109S` with 1 tutorial class under it: `T01`
Else, creates a new module `CS2109S` with 1 tutorial class with description `Introduction to AI` and class size of `10` under it: `T01`

---
### Deleting tutorial class : `delete_class`
Expand Down Expand Up @@ -596,14 +598,14 @@ must be in the team before command execution.Explanation: This deletes the stude
| **Edit student contact** | `/edit_student index/<index> <id/, email/, name/, tag/>`<br> e.g.,`/edit_student index/1 name/John` |
| **Sort students** | `/sort_students by/<name or email or id> `<br> e.g.,`search_student by/id` or `/search_student by/name` |
| **View all students** | `/list_students` |
| **Add new tutorial class** | `/add_class module/<module_code> tutorial/<tutorial_class>` <br> e.g., `/add_class module/CS2103T tutorial/T09` |
| **Add new tutorial class** | `/add_class module/<module_code> tutorial/<tutorial_class> [description/<description>] [size/<class_size>]` <br> e.g., `/add_class module/CS2103T tutorial/T09 description/Software Engineering size/10` |
| **Delete tutorial class** | `/delete_class module/<module_code> tutorial/<tutorial_class>` <br> e.g., `/delete_class module/CS2103T tutorial/T09` |
| **View all classes** | `/list_classes` |
| **Add New Student to tutorial class** | `/add_student_to_class <index/, email/ , id/> <index or email or id> module/ <module> tutorial/ <class>` <br> e.g., `/add_student_to_class index/1 module/CS2103T tutorial/T09` |
| **Delete students from tutorial class** | `/delete_student_from_class email/<email> module/ <module> tutorial/ <class>` or `delete_student_from_class id/<id> module/ <module> tutorial/ <class>` <br> e.g., `/delete_student_from_class id/A1234561Z module/CS2103T tutorial/T09` |
| **List students of a tutorial class** | `/class_list_student module/ <module> tutorial/ <class>` <br> e.g., `class_list_students module/CS2103T tutorial/T09` |
| **Delete module** | `/delete_module module/<module_code>` <br> e.g., `delete_class module/CS2103T` |
| **Add new team** | `/add_team module/<moduleCode> tutorial/<tutorialClass> name/<team_name> size/<team_size>` <br> e.g., `/add_team module/CS2103T tutorial/T09 name/Team 1 size/5` |
| **Add new team** | `/add_team module/<moduleCode> tutorial/<tutorialClass> name/<team_name> [size/<team_size>]` <br> e.g., `/add_team module/CS2103T tutorial/T09 name/Team 1 size/5` |
| **Delete team** | `/delete_team module/<moduleCode> tutorial/<tutorialClass> name/<team_name>` <br> e.g., `/delete_team module/CS2103 tutorial/T09 name/Team 4` |
| **View team** | `/view_teams <index/, name/> <index or name> module/<moduleCode> tutorial/<tutorialClass>` <br> e.g., `/view_teams name/Team 1 module/CS2103T tutorial/T09` |
| **Randomly allocate team** | `/random_teams module/<module> tutorial/<tutorialClass> teams/<number_of_teams>` <br> e.g., `/random_teams module/CS2103 tutorial/T09 teams/4` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public DeleteStudentCommand() {

/**
* Deletes a specified student from all tutorial classes from all modules in a model.
* Also deletes the student from all teams included in the tutorial classes (implementation inside deleteStudent)
*
* @param model that contains the modules and tutorial classes
* @param student to be deleted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public class ModuleMessages {
public static final String MESSAGE_MODULE_NOT_FOUND = "The module with module code %s "
+ "does not exist in the address book";
public static final String MESSAGE_TUTORIAL_DOES_NOT_BELONG_TO_MODULE = "The tutorial class with"
public static final String MESSAGE_TUTORIAL_DOES_NOT_BELONG_TO_MODULE = "The tutorial class with "
+ "tutorial code %s does not belong to the module with module code %s";

public static final String MESSAGE_DELETE_MODULE_SUCCESS = "Removed %1$s!";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class PersonMessages {
public static final String MESSAGE_DELETE_STUDENT_FROM_CLASS_SUCCESS = "Deleted student %1$s from %2$s %3$s";
public static final String MESSAGE_DUPLICATE_STUDENT_IN_CLASS = "%1$s already added to %2$s!";
public static final String MESSAGE_DUPLICATE_PERSON = "%1$s already exists in the address book!";
public static final String MESSAGE_DUPLICATE_EMAIL = "A student with this email %1$s already exists"
public static final String MESSAGE_DUPLICATE_EMAIL = "A student with this email %1$s already exists "
+ "in the address book.";
public static final String MESSAGE_DUPLICATE_STUDENTID = "A student with this student id %1$s already"
public static final String MESSAGE_DUPLICATE_STUDENTID = "A student with this student id %1$s already "
+ "exists in the address book.";
}
15 changes: 15 additions & 0 deletions src/main/java/seedu/address/model/module/TutorialClass.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,28 @@ public void addStudent(Person student) {

/**
* Removes a student from the tutorial class if it exists.
* Also removes the student from any tutorial class in this tutorial
*
* @param student
* @return true if the student was removed
*/
public boolean deleteStudent(Person student) {
deleteStudentFromTeams(student);
return students.remove(student);
}

/**
* Deletes a specified student from all teams from the tutorial class.
*
* @param student to be deleted
*/
public void deleteStudentFromTeams(Person student) {
ArrayList<TutorialTeam> list = getTeams();
for (TutorialTeam team : list) {
team.deleteStudent(student);
}
}

/**
* Checks if the student is in the tutorial class.
* @param student
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/ui/HelpWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
public class HelpWindow extends UiPart<Stage> {

public static final String USERGUIDE_URL = "https://ay2324s2-cs2103t-t09-4.github.io/tp/UserGuide.html";
public static final String USERGUIDE_URL =
"https://github.com/AY2324S2-CS2103T-T09-4/tp/blob/master/docs/UserGuide.md";
public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL;

private static final Logger logger = LogsCenter.getLogger(HelpWindow.class);
Expand Down
42 changes: 42 additions & 0 deletions src/test/java/seedu/address/model/module/TutorialClassTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static seedu.address.logic.commands.CommandTestUtil.VALID_TEAM_NAME_AMY;
import static seedu.address.logic.commands.CommandTestUtil.VALID_TEAM_NAME_BOB;
import static seedu.address.model.module.TutorialClass.isValidTutorialClass;
import static seedu.address.testutil.TypicalPersons.ALICE;

Expand Down Expand Up @@ -187,4 +189,44 @@ void deleteStudent_inList_success() {
assertTrue(tutorialClass.deleteStudent(student1));
assertEquals(0, tutorialClass.getStudents().size());
}

@Test
void deleteStudentFromTeams_success() {
ArrayList<Person> students = new ArrayList<>();

// Creating Person object
Person student1 = new PersonBuilder().build();

students.add(student1);

TutorialClass tutorialClass = new TutorialClass(VALID_TUTORIAL, students);

// Create teams, add student to teams, and add teams to tutorial class\
TutorialTeam team1 = new TutorialTeam(VALID_TEAM_NAME_AMY);
TutorialTeam team2 = new TutorialTeam(VALID_TEAM_NAME_BOB);
team1.addStudent(student1);
team2.addStudent(student1);
tutorialClass.addTeam(team1);
tutorialClass.addTeam(team2);


//both teams should have 1 person
int expectedNumOfStudentsInTeamBeforeDelete = 1;
assertEquals(expectedNumOfStudentsInTeamBeforeDelete,
tutorialClass.getTutorialTeam(tutorialClass, team1).getStudents().size());

assertEquals(expectedNumOfStudentsInTeamBeforeDelete,
tutorialClass.getTutorialTeam(tutorialClass, team2).getStudents().size());

//delete the student from all teams
tutorialClass.deleteStudentFromTeams(student1);

//both teams should now be empty (i.e. 0 people)
int expectedNumOfStudentsInTeamAfterDelete = 0;
assertEquals(expectedNumOfStudentsInTeamAfterDelete,
tutorialClass.getTutorialTeam(tutorialClass, team1).getStudents().size());

assertEquals(expectedNumOfStudentsInTeamAfterDelete,
tutorialClass.getTutorialTeam(tutorialClass, team2).getStudents().size());
}
}

0 comments on commit a58cf92

Please sign in to comment.