From 02f9444fa9331ad77572087f7b58d1539d37f4a1 Mon Sep 17 00:00:00 2001 From: seraphimstreets Date: Tue, 14 Nov 2023 06:53:48 +0800 Subject: [PATCH] Update Developer Guide --- docs/DeveloperGuide.md | 21 ++++- .../DeleteGradedComponentSequenceDiagram.puml | 80 +++++++++++++++++++ docs/team/seraphimstreets.md | 1 + .../modulight/model/student/Student.java | 4 +- 4 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 docs/diagrams/DeleteGradedComponentSequenceDiagram.puml diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 2636da5097b..45a29c86116 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -231,7 +231,7 @@ Below is an activity diagram that demonstrates how this command works. ### Add Graded Component - + The `addComp` command allows users to add a graded component and automaticaly create student scores associated with that component for every student in the database. A typical program flow is as follows: @@ -259,7 +259,7 @@ Alternative Implementations: ### Edit Graded Component - + The `editComp` command allows users to edit a graded component's details based on its 1-based index, which are propagated to the component's associated student scores. A typical program flow is as follows: @@ -285,6 +285,23 @@ Alternative Implementations: create some inefficiency as the `Model` has to search through the entire `GradedComponent` list for the appropriate item to replace. Therefore, this is a possible extension that future developers may consider. +### Delete Graded Component + + + +The `deleteComp` command allows users to delete a graded component alongside its associated student scores based on its 1-based index. +A typical program flow is as follows: + +1. User enters a command to delete a graded component, for instance `deleteComp 2`. +2. `DeleteGradedComponentCommandParser` checks that the only argument provided is a valid index, which is an integer between 1 and the size of the displayed `GradedComponent` list. +3. Index is passed into `DeleteGradedComponentCommand`'s constructor which is then executed. +4. The graded component corresponding to the index in the currently displayed `GradedComponentBook` list is removed. +5. All associated student scores of that `GradedComponent` are also removed. + +Alternative Implementations: +* We originally considered having users remove graded components based on their unique component name. Ultimately, we decided it would be faster for users to type in an index rather than a name (especially if it is quite lengthy), +although future developers may want to extend this functionality so that users can choose to remove by either index or component name. + ### Sort Commands The Sort related features allows NUS professors to sort the currently displayed students or student scores. When successfully executed, the sorted students or student scores will be shown on the Graphical User Interface.
diff --git a/docs/diagrams/DeleteGradedComponentSequenceDiagram.puml b/docs/diagrams/DeleteGradedComponentSequenceDiagram.puml new file mode 100644 index 00000000000..ac22146086c --- /dev/null +++ b/docs/diagrams/DeleteGradedComponentSequenceDiagram.puml @@ -0,0 +1,80 @@ +@startuml +!include style.puml +skinparam ArrowFontStyle plain + +box Logic LOGIC_COLOR_T1 +participant ":LogicManager" as LogicManager LOGIC_COLOR +participant ":ModuLightParser" as ModuLightParser LOGIC_COLOR +participant ":DeleteGradedComponentCommandParser" as DeleteGradedComponentCommandParser LOGIC_COLOR +participant ":DeleteGradedComponentCommand" as DeleteGradedComponentCommand LOGIC_COLOR +participant ":CommandResult" as CommandResult LOGIC_COLOR +end box + +box Model MODEL_COLOR_T1 +participant ":Model" as Model MODEL_COLOR +end box + +[-> LogicManager : execute("deleteComp 1") +activate LogicManager + +LogicManager -> ModuLightParser : parseCommand("deleteComp 1") +activate ModuLightParser + +create DeleteGradedComponentCommandParser +ModuLightParser -> DeleteGradedComponentCommandParser +activate DeleteGradedComponentCommandParser + +DeleteGradedComponentCommandParser --> ModuLightParser +deactivate DeleteGradedComponentCommandParser + +ModuLightParser -> DeleteGradedComponentCommandParser : parse(arguments) +activate DeleteGradedComponentCommandParser + + +create DeleteGradedComponentCommand +DeleteGradedComponentCommandParser -> DeleteGradedComponentCommand : new DeleteGradedComponentCommand(index) +activate DeleteGradedComponentCommand + +DeleteGradedComponentCommand --> DeleteGradedComponentCommandParser +deactivate DeleteGradedComponentCommand + +DeleteGradedComponentCommandParser --> ModuLightParser +deactivate DeleteGradedComponentCommandParser +'Hidden arrow to position the destroy marker below the end of the activation bar. +DeleteGradedComponentCommandParser -[hidden]-> ModuLightParser +destroy DeleteGradedComponentCommandParser + +ModuLightParser --> LogicManager +deactivate ModuLightParser + +LogicManager -> DeleteGradedComponentCommand : execute() +activate DeleteGradedComponentCommand + +DeleteGradedComponentCommand -> Model : removeGradedComponent(gc) +activate Model + +Model --> DeleteGradedComponentCommand +deactivate Model + +loop for all associated studentScores of gc + DeleteGradedComponentCommand -> Model :removeStudentScore(studentScore) + activate Model + + Model --> DeleteGradedComponentCommand + deactivate Model +end + + +create CommandResult +DeleteGradedComponentCommand -> CommandResult +activate CommandResult + +CommandResult --> DeleteGradedComponentCommand +deactivate CommandResult + +DeleteGradedComponentCommand --> LogicManager : result +deactivate DeleteGradedComponentCommand + +[<--LogicManager +deactivate LogicManager +@enduml diff --git a/docs/team/seraphimstreets.md b/docs/team/seraphimstreets.md index f4e1e13d76e..3f58974fb0f 100644 --- a/docs/team/seraphimstreets.md +++ b/docs/team/seraphimstreets.md @@ -81,3 +81,4 @@ Format: `deleteComp INDEX` Examples: `deleteComp 2` deletes the second graded component in the displayed Graded Components List ### Contributions to Developer Guide + diff --git a/src/main/java/seedu/modulight/model/student/Student.java b/src/main/java/seedu/modulight/model/student/Student.java index f07f8d362b5..faec33570d8 100644 --- a/src/main/java/seedu/modulight/model/student/Student.java +++ b/src/main/java/seedu/modulight/model/student/Student.java @@ -120,7 +120,9 @@ private float calcTotalScore() { GradedComponent gc = sc.getGradedComponent(); Weightage w = gc.getWeightage(); float weight = w.weightage; - totalScore += weight / totalWeightage * sc.calcRelativeScore(); + if (totalWeightage != 0) { + totalScore += weight / totalWeightage * sc.calcRelativeScore(); + } } return totalScore; }