diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 78e31073cdd..40fe386bab6 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -299,6 +299,22 @@ measures: mean, standardDeviation, upperQuartile, lowerQuartile, max, min, skewn Examples: * `stats st/upperQuartile st/lowerQuartile` returns the upper and lower quartile of the overall student grades. +### Calculating statistics of a graded component + +Calculates the statistics of all students of a specific graded component. + +Format: `compStats [c/COMP_NAME] [st/STATS] [g/TUTORIAL_GRP]` + +* It is allowed to omit `[st/STATS]`. In this case, it will return a summary of all statistics that are currently + supported. +* For stats keywords, it must be currently supported. Here is an exhaustive list of currently supported statistical + measures: mean, standardDeviation, upperQuartile, lowerQuartile, max, min, skewness. +* It is allowed to have multiple stats keywords, but only allowed to have 0 or 1 tutorial group keyword and component +name keyword. + +Examples: +* `compStats st/upperQuartile st/lowerQuartile c/Midterm` returns the upper and lower quartile of the +student grades in Midterm. ### Clearing all entries : `clear` diff --git a/src/main/java/seedu/address/logic/commands/SortStudentCommand.java b/src/main/java/seedu/address/logic/commands/SortStudentCommand.java index 944e5954ecc..3ce170fcfcc 100644 --- a/src/main/java/seedu/address/logic/commands/SortStudentCommand.java +++ b/src/main/java/seedu/address/logic/commands/SortStudentCommand.java @@ -1,6 +1,8 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; +import static seedu.address.logic.parser.CliSyntax.PREFIX_ORDER; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REVERSE; import java.util.function.Predicate; @@ -18,11 +20,13 @@ public class SortStudentCommand extends Command { public static final String MESSAGE_USAGE = COMMAND_WORD + ": Sorts all students by the given order.\n" + "Parameters:\n" - + "Attribute to be sorted: Must be one of \"n\", \"name\", \"s\", \"studentId\", " + + "[" + PREFIX_ORDER + "attribute to be sorted (optional, by default sorted by overall score]: \n" + + "Must be one of \"n\", \"name\", \"s\", \"studentId\", " + "\"studentID\", \"e\", \"email\", \"g\", \"tutorial\", \"tut\", \"tutGroup\"" + "\"ts\", \"totalScore\", \"totalscore\", \"overall\", \"score\"\n" - + "Reverse (optional): If true, the sorted list is reversed (or sorted in Descending order)\n" - + "Example: " + COMMAND_WORD + " s true"; + + "[" + PREFIX_REVERSE + "Reverse (optional, by default increasing)]:\n" + + "If true, the sorted list is reversed (or sorted in Descending order)\n" + + "Example: " + COMMAND_WORD + " o/s r/true"; private final String sortingOrder; private final boolean reverse; diff --git a/src/main/java/seedu/address/logic/commands/SortStudentScoreCommand.java b/src/main/java/seedu/address/logic/commands/SortStudentScoreCommand.java index 73b1576c720..ed0aaea96ac 100644 --- a/src/main/java/seedu/address/logic/commands/SortStudentScoreCommand.java +++ b/src/main/java/seedu/address/logic/commands/SortStudentScoreCommand.java @@ -2,6 +2,7 @@ import static java.util.Objects.requireNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_COMPONENT_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REVERSE; import java.util.Collections; import java.util.function.Predicate; @@ -12,13 +13,9 @@ import seedu.address.model.gradedcomponent.GcName; import seedu.address.model.student.Student; import seedu.address.model.student.model.StudentBook; -import seedu.address.model.studentscore.StudentScore; -import seedu.address.model.studentscore.StudentScoreMatchPredicate; +import seedu.address.model.studentscore.ScoreMatchPredicate; import seedu.address.model.studentscore.model.StudentScoreBook; - - - /** * Sorts the student(s) whose student id by the given order. */ @@ -28,15 +25,16 @@ public class SortStudentScoreCommand extends Command { public static final String MESSAGE_USAGE = COMMAND_WORD + ": Sorts all students scores under a given graded component.\n" + "Parameters:\n" - + PREFIX_COMPONENT_NAME + "COMPONENT NAME\n" - + "Reverse (optional): If true, the sorted list is reversed (or sorted in Descending order)\n" - + "Example: " + COMMAND_WORD + " c/Midterm true"; + + "[" + PREFIX_COMPONENT_NAME + "COMPONENT NAME]\n" + + "[" + PREFIX_REVERSE + "Reverse (optional, by default increasing)]: " + + "If true, the sorted list is reversed (or sorted in Descending order)\n" + + "Example: " + COMMAND_WORD + " c/Midterm r/true"; private final GcName gcName; private final boolean reverse; /** - * Creates an SortStudentCommand to sort the displayed students. + * Creates a SortStudentCommand to sort the displayed students. */ public SortStudentScoreCommand(GcName gcName, boolean reverse) { this.gcName = gcName; @@ -47,12 +45,11 @@ public SortStudentScoreCommand(GcName gcName, boolean reverse) { public CommandResult execute(Model model) { requireNonNull(model); Predicate currentStuPredicate = model.getCurrentStudentsPredicate(); - Predicate currentStuScorePredicate = model.getCurrentScoresPredicate(); StudentBook studentBook = model.getStudentBook(); StudentScoreBook studentScoreBook = model.getStudentScoreBook(); studentScoreBook.sortStudentScore(reverse); studentBook.sortStudentScore(gcName, reverse); - model.updateFilteredStudentScoreList(new StudentScoreMatchPredicate(Collections.singletonList(gcName))); + model.updateFilteredStudentScoreList(new ScoreMatchPredicate(Collections.singletonList(gcName.gcName))); if (currentStuPredicate != null) { model.updateFilteredStudentList(currentStuPredicate); } diff --git a/src/main/java/seedu/address/model/studentscore/ScoreMatchPredicate.java b/src/main/java/seedu/address/model/studentscore/ScoreMatchPredicate.java index da900034467..74b16be4ac6 100644 --- a/src/main/java/seedu/address/model/studentscore/ScoreMatchPredicate.java +++ b/src/main/java/seedu/address/model/studentscore/ScoreMatchPredicate.java @@ -5,6 +5,7 @@ import java.util.function.Predicate; import seedu.address.model.gradedcomponent.GcMatchPredicate; +import seedu.address.model.student.Student; import seedu.address.model.student.StudentMatchPredicate; /** @@ -17,7 +18,7 @@ public class ScoreMatchPredicate implements Predicate { private final List tutorialGroupKeywords; private final List tagKeywords; private final List commentKeywords; - private final StudentMatchPredicate studentMatchPredicate; + private final Predicate studentMatchPredicate; private final GcMatchPredicate gcMatchPredicate; /** @@ -49,7 +50,7 @@ public ScoreMatchPredicate(List idKeywords, List nameKeywords, * * @param studentMatchPredicate the student match predicate */ - public ScoreMatchPredicate(StudentMatchPredicate studentMatchPredicate) { + public ScoreMatchPredicate(Predicate studentMatchPredicate) { this.gcNames = new ArrayList<>(); this.idKeywords = new ArrayList<>(); this.nameKeywords = new ArrayList<>(); @@ -60,6 +61,22 @@ public ScoreMatchPredicate(StudentMatchPredicate studentMatchPredicate) { this.gcMatchPredicate = new GcMatchPredicate(); } + /** + * Constructs a predicate to search for certain students scores. + * + * @param gcKeywords the gc keywords + */ + public ScoreMatchPredicate(List gcKeywords) { + this.gcNames = gcKeywords; + this.idKeywords = new ArrayList<>(); + this.nameKeywords = new ArrayList<>(); + this.tagKeywords = new ArrayList<>(); + this.tutorialGroupKeywords = new ArrayList<>(); + this.commentKeywords = new ArrayList<>(); + this.studentMatchPredicate = new StudentMatchPredicate(); + this.gcMatchPredicate = new GcMatchPredicate(); + } + /** * Instantiates a new Score match predicate. * diff --git a/src/main/java/seedu/address/model/studentscore/StudentScoreMatchPredicate.java b/src/main/java/seedu/address/model/studentscore/StudentScoreMatchPredicate.java deleted file mode 100644 index 7e93b73480a..00000000000 --- a/src/main/java/seedu/address/model/studentscore/StudentScoreMatchPredicate.java +++ /dev/null @@ -1,54 +0,0 @@ -package seedu.address.model.studentscore; - -import java.util.List; -import java.util.function.Predicate; - -import seedu.address.model.gradedcomponent.GcName; - -/** - * Tests that a {@code Student}'s attributes matches any of the attributes given. - */ -public class StudentScoreMatchPredicate implements Predicate { - private final List gcNames; - - /** - * Constructs a predicate to search for certain students. - * - * @param gcNames The keywords for Component Name - */ - public StudentScoreMatchPredicate(List gcNames) { - this.gcNames = gcNames; - } - - @Override - public boolean test(StudentScore studentscore) { - return gcNames.isEmpty() || gcNames.stream() - .anyMatch(keyword -> studentscore.getGcName().equals(keyword)); - } - - @Override - public boolean equals(Object other) { - if (other == this) { - return true; - } - - // instanceof handles nulls - if (!(other instanceof StudentScoreMatchPredicate)) { - return false; - } - - StudentScoreMatchPredicate otherStudentIdMatchPredicate = - (StudentScoreMatchPredicate) other; - return gcNames.equals(otherStudentIdMatchPredicate.gcNames); - } - - @Override - public String toString() { - return "Find students by given criteria"; - } -} - - - - -