Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2021S1#65 from Nijnxw/branch-v1.2-vie…
Browse files Browse the repository at this point in the history
…wlsn

Branch v1.2 viewlsn
  • Loading branch information
chunyongg authored Oct 6, 2020
2 parents dcc285a + 7267584 commit fac4dba
Show file tree
Hide file tree
Showing 38 changed files with 686 additions and 96 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Serenity is a one-stop software for CS2101 tutors to manage your CS2101 classes.
Check out our [User Guide](docs/UserGuide.md) to get started!

This project is based on the AddressBook-Level3 project created by the [SE-EDU initiative](https://se-education.org).

42 changes: 21 additions & 21 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,39 @@ By: `Team Serenity` Since: `Aug 2020`
4. [Features](#features)

4.1. [Setup](#setup)

* [Setup classes at the start of a semester: `importCsv`](#setup-classes-at-the-start-of-a-semester-importcsv)

4.2. [Attendance Taking](#attendance-taking)

* [Mark attendance for a every student: `markAll`](#mark-attendance-for-every-student-markall)

* [Mark attendance for a single student: `mark`](#mark-attendance-for-a-single-student-mark)

* [Flag attendance for a single student: `flag`](#flag-attendance-for-a-single-student-flag)

* [View attendance for a each class: `attendance`](#view-attendance-for-each-class-attendance)

* [Exporting of attendance to CSV: `exportAtt`](#exporting-of-attendance-to-csv-exportatt)

4.3. [Class Participation](#class-participation)

* [Awarding class participation marks: `award`](#awarding-class-participation-marks-award)

* [Viewing statistics of class participation `stats`](#viewing-statistics-of-class-participation-stats)

* [Exporting of class participation grades to CSV: `exportCp`](#exporting-of-class-participation-grades-to-csv-exportcp)

4.4 [Addressing Questions](#addressing-questions)

* [Adding a question: `addQn`](#adding-a-question-addqn)

* [Viewing all questions: `questions`](#viewing-all-questions-list)

* [Deleting a question: `deleteQn`](#deleting-a-question-deleteqn)

* [Marking a question as answered: `ansQn`](#marking-a-question-as-answered-ansqn)

5. [FAQ](#faq)

6. [Command Summary](#command-summary)
Expand All @@ -67,16 +67,16 @@ let's get [started](#quick-start)!

1. Ensure you have Java `11` or above installed in your Computer.

1. Download the latest `Serenity.jar` from [here]().
2. Download the latest `Serenity.jar` from [here]().

1. Copy the file to the folder you want to use as the _home folder_ for your AddressBook.
3. Copy the file to the folder you want to use as the _home folder_ for your AddressBook.

1. Double-click the file to start the app. The GUI similar to the below should appear in a few seconds. Note how the app contains some sample data.<br>
4. Double-click the file to start the app. The GUI similar to the below should appear in a few seconds. Note how the app contains some sample data.<br>
![Ui](images/Ui.png)

1. Type the command in the command box and press Enter to execute it.
5. Type the command in the command box and press Enter to execute it.

1. Refer to the [Features](#features) below for details of each command.
6. Refer to the [Features](#features) below for details of each command.

--------------------------------------------------------------------------------------------------------------------

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/seedu/address/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ public class Messages {
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";

//serenity messages

// Serenity messages
public static final String MESSAGE_GROUP_LISTED_OVERVIEW = "You are in tutorial group %1$s.";
public static final String MESSAGE_GROUP_EMPTY = "no such group!";
public static final String MESSAGE_LESSON_LISTED_OVERVIEW = "You are in tutorial group %1$s, lesson %2$s.";
public static final String MESSAGE_LESSON_EMPTY = "no such lesson!";

}
10 changes: 7 additions & 3 deletions src/main/java/seedu/address/commons/util/CsvUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

import seedu.address.model.group.Lesson;
import seedu.address.model.group.Student;
import seedu.address.model.group.StudentInfo;
import seedu.address.model.group.UniqueStudentInfoList;

/**
* Reads CSV file that the tutor downloads from LUMINUS and writes JSON data to a new CSV file.
Expand Down Expand Up @@ -75,7 +77,7 @@ public Set<Student> readStudentsFromCsv() {
}

/**
* Reads a set of StudentInfo and creates the Lessons
* Reads a set of the Lessons
* @param studentsInfo Set of StudentInfo
* @return Set of Lessons
*/
Expand All @@ -96,7 +98,9 @@ public Set<Lesson> readLessonsFromCsv(Set<StudentInfo> studentsInfo) {
int len = row.length;
for (int i = 4; i < len; i++) {
String lessonName = computeClassName(i - 3); //start from 1
lessons.add(new Lesson(lessonName, studentsInfo));
UniqueStudentInfoList newStudentsInfo = new UniqueStudentInfoList();
newStudentsInfo.setStudentInfo(new ArrayList<>(studentsInfo));
lessons.add(new Lesson(lessonName, newStudentsInfo));
}
} catch (IOException ioe) {
ioe.printStackTrace();
Expand Down Expand Up @@ -135,7 +139,7 @@ public Set<StudentInfo> readStudentsInfoFromCsv(Set<Student> students) {
return studentsInfo;
}

private Lesson createClass(String name, Set<StudentInfo> studentsInfo) {
private Lesson createClass(String name, UniqueStudentInfoList studentsInfo) {
return new Lesson(name, studentsInfo);
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import seedu.address.model.group.Group;
import seedu.address.model.group.Lesson;
import seedu.address.model.group.Student;
import seedu.address.model.group.StudentInfo;
import seedu.address.model.person.Person;

/**
Expand Down Expand Up @@ -69,15 +70,20 @@ public interface Logic {
ObservableList<Group> getFilteredGroupList();

/**
* Returns an unmodifiable view of the filtered list of Students from a group.
* Returns an unmodifiable view of the filtered list of students from a group.
*/
ObservableList<Student> getStudentList();

/**
* Returns an unmodifiable view of the list of lesson from a group.
* Returns an unmodifiable view of the filtered list of lesson from a group.
*/
ObservableList<Lesson> getLessonList();

/**
* Returns an unmodifiable view of the filtered list of students info from a group-lesson.
*/
ObservableList<StudentInfo> getFilteredStudentInfoList();

/**
* Returns the user prefs' serenity file path.
*/
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.parser.AddressBookParser;
import seedu.address.logic.parser.SerenityParser;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.ReadOnlySerenity;
import seedu.address.model.group.Group;
import seedu.address.model.group.Lesson;
import seedu.address.model.group.Student;
import seedu.address.model.group.StudentInfo;
import seedu.address.model.person.Person;
import seedu.address.storage.Storage;

Expand All @@ -31,15 +32,15 @@ public class LogicManager implements Logic {

private final Model model;
private final Storage storage;
private final AddressBookParser addressBookParser;
private final SerenityParser addressBookParser;

/**
* Constructs a {@code LogicManager} with the given {@code Model} and {@code Storage}.
*/
public LogicManager(Model model, Storage storage) {
this.model = model;
this.storage = storage;
addressBookParser = new AddressBookParser();
addressBookParser = new SerenityParser();
}

@Override
Expand Down Expand Up @@ -85,6 +86,8 @@ public void setGuiSettings(GuiSettings guiSettings) {
model.setGuiSettings(guiSettings);
}

// ========== Serenity ==========

@Override
public ReadOnlySerenity getSerenity() {
return model.getSerenity();
Expand All @@ -105,6 +108,11 @@ public ObservableList<Lesson> getLessonList() {
return model.getLessonList();
}

@Override
public ObservableList<StudentInfo> getFilteredStudentInfoList() {
return model.getStudentInfoList();
}

@Override
public Path getSerenityFilePath() {
return model.getSerenityFilePath();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import seedu.address.model.person.NameContainsKeywordsPredicate;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords. Keyword matching is
* case insensitive.
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Keyword matching is case insensitive.
*/
public class FindCommand extends Command {

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/seedu/address/logic/commands/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class ListCommand extends Command {
public static final String COMMAND_WORD = "list";

public static final String MESSAGE_SUCCESS = "Listed all persons";


@Override
public CommandResult execute(Model model) {
requireNonNull(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class ViewGrpCommand extends Command {

public static final String COMMAND_WORD = "viewgrp";
public static final Object MESSAGE_USAGE = COMMAND_WORD
+ ": Finds all students who are part of "
+ "the specified group and displays them as a list with index numbers.\n"
+ ": Finds all students who are part of the specified group (case-insensitive) "
+ "and displays them as a list with index numbers.\n"
+ "Parameters: GROUP \n"
+ "Example: " + COMMAND_WORD + " " + PREFIX_GRP + " G04";

Expand Down
61 changes: 61 additions & 0 deletions src/main/java/seedu/address/logic/commands/ViewLsnCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package seedu.address.logic.commands;

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

import seedu.address.commons.core.Messages;
import seedu.address.model.Model;
import seedu.address.model.group.GrpContainsKeywordPredicate;
import seedu.address.model.group.LsnContainsKeywordPredicate;

/**
* Finds and lists the attendance and class participation of all the students from
* a specified group and lesson. Keyword matching is case insensitive.
*/
public class ViewLsnCommand extends Command {

public static final String COMMAND_WORD = "viewlsn";
public static final Object MESSAGE_USAGE = COMMAND_WORD
+ ": Finds the attendance and class participation of all students "
+ "from the specified lesson of a specific group (case-insensitive) and "
+ "displays them as a list with index numbers.\n"
+ "Parameters: GROUP LESSON\n"
+ "Example: " + COMMAND_WORD + " " + PREFIX_GRP + " G04 " + PREFIX_LSN + " 2-2";

private final GrpContainsKeywordPredicate grpPredicate;
private final LsnContainsKeywordPredicate lsnPredicate;

/**
* Creates a ViewLsnCommand to view the specified {@code Lesson}
*/
public ViewLsnCommand(GrpContainsKeywordPredicate grpPredicate,
LsnContainsKeywordPredicate lsnPredicate) {
this.grpPredicate = grpPredicate;
this.lsnPredicate = lsnPredicate;
}

private String getMessage(Model model) {
return model.getFilteredGroupList().isEmpty()
? Messages.MESSAGE_LESSON_EMPTY
: String.format(Messages.MESSAGE_LESSON_LISTED_OVERVIEW,
model.getFilteredGroupList().get(0).getName(),
model.getFilteredLessonList().get(0).getName());
}

@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.updateFilteredLessonList(lsnPredicate);
return new CommandResult(this.getMessage(model));
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof ViewLsnCommand // instanceof handles nulls
&& grpPredicate.equals(((ViewLsnCommand) other).grpPredicate)) // state check
&& lsnPredicate.equals(((ViewLsnCommand) other).lsnPredicate);
}

}
1 change: 1 addition & 0 deletions src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class CliSyntax {
// Prefix definitions for Serenity
public static final Prefix PREFIX_GRP = new Prefix("grp/");
public static final Prefix PREFIX_PATH = new Prefix("path/");
public static final Prefix PREFIX_LSN = new Prefix("lsn/");

/* Prefix definitions */
public static final Prefix PREFIX_NAME = new Prefix("n/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.ViewGrpCommand;
import seedu.address.logic.commands.ViewLsnCommand;
import seedu.address.logic.parser.exceptions.ParseException;

/**
* Parses user input.
*/
public class AddressBookParser {
public class SerenityParser {

/**
* Used for initial separation of command word and args.
Expand Down Expand Up @@ -55,6 +56,9 @@ public Command parseCommand(String userInput) throws ParseException {
case ViewGrpCommand.COMMAND_WORD:
return new ViewGrpCommandParser().parse(arguments);

case ViewLsnCommand.COMMAND_WORD:
return new ViewLsnCommandParser().parse(arguments);

case AddCommand.COMMAND_WORD:
return new AddCommandParser().parse(arguments);

Expand Down
46 changes: 46 additions & 0 deletions src/main/java/seedu/address/logic/parser/ViewLsnCommandParser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package seedu.address.logic.parser;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GRP;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LSN;

import java.util.stream.Stream;

import seedu.address.logic.commands.ViewLsnCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.group.GrpContainsKeywordPredicate;
import seedu.address.model.group.LsnContainsKeywordPredicate;

public class ViewLsnCommandParser implements Parser<ViewLsnCommand> {

private final ParseException viewLsnCommandParserException = new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewLsnCommand.MESSAGE_USAGE));

@Override
public ViewLsnCommand parse(String args) throws ParseException {

ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_GRP, PREFIX_LSN);

if (!arePrefixesPresent(argMultimap, PREFIX_GRP, PREFIX_LSN) || !argMultimap.getPreamble().isEmpty()) {
throw viewLsnCommandParserException;
}

String[] grpKeyword = argMultimap.getValue(PREFIX_GRP).get().split("\\s+");
String[] lsnKeyword = argMultimap.getValue(PREFIX_LSN).get().split("\\s+");

if (grpKeyword.length > 1 || lsnKeyword.length > 1) {
throw viewLsnCommandParserException;
}

return new ViewLsnCommand(new GrpContainsKeywordPredicate(grpKeyword[0]),
new LsnContainsKeywordPredicate(lsnKeyword[0]));
}

/**
* Returns true if none of the prefixes contains empty {@code Optional} values in the given {@code
* ArgumentMultimap}.
*/
private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) {
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent());
}
}
Loading

0 comments on commit fac4dba

Please sign in to comment.