Skip to content

Commit

Permalink
Merge pull request #97 from dlqs/addReport
Browse files Browse the repository at this point in the history
Add report
  • Loading branch information
afterdusk authored Mar 28, 2019
2 parents 2ccca9a + 9c51621 commit b715eff
Show file tree
Hide file tree
Showing 19 changed files with 361 additions and 28 deletions.
15 changes: 9 additions & 6 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,12 @@ Deletes the second folder in the folder list, along with its cards, on the home

==== Report user performance for folder : `report`

Displays user performance on the right panel for the folder specified by index.
Displays user performance in a fullscreen for the current card folder.

Format: `report FOLDER_INDEX`
Format: `report`

[NOTE]
This command is only considered valid inside a card folder.


==== Enter folder : `change`
Expand Down Expand Up @@ -306,14 +309,14 @@ This command is only considered valid if a card question and answer is currently
There is no backtracking in the current session so there is no `prev` command.


==== End the current session : `end`
==== End the current test or report session : `end`

Quits the current test session.
Quits the current test or report session.

Format: `end`

=== Global Operations
The commands shown in this section are applicable irregardless of whether the user is inside a folder or at the home directory.
The commands shown in this section are applicable regardless of whether the user is inside a folder or at the home directory.

==== Search by keywords : `search`

Expand Down Expand Up @@ -420,7 +423,7 @@ questions displayed. The user is required to key in an answer for each question.
|`change FOLDER_INDEX`|Enters the folder specified by index. Side panel on the left will display the list of cards in that folder.
|`addfolder FOLDER_NAME` | Creates a new flashcard folder with the specified name.
|`deletefolder FOLDER_INDEX` | Removes the flashcard folder specified by index.
|`report FOLDER_INDEX` | Displays user performance on the right panel for the folder specified by index.
|`report` | Displays user performance on the right panel for the current folder.
|`test FOLDER_INDEX` | This command begins a test session, where the display area enters a fullscreen.
|`ans ANSWER` | Enter answer for a flashcard.
|`reveal` | Immediately reveals the correct answer.
Expand Down
8 changes: 6 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,16 +10,20 @@ public class Messages {
public static final String MESSAGE_INVALID_CARD_DISPLAYED_INDEX = "The card index provided is invalid";
public static final String MESSAGE_INVALID_FOLDER_DISPLAYED_INDEX = "The card folder index provided is invalid";
public static final String MESSAGE_CARDS_LISTED_OVERVIEW = "%1$d cards listed!";
public static final String MESSAGE_INVALID_COMMAND_OUTSIDE_FULLSCREEN = "This command is not valid outside a test"
+ " or report";
public static final String MESSAGE_INVALID_COMMAND_OUTSIDE_TEST_SESSION = "This command is valid only inside a test"
+ " session";
public static final String MESSAGE_INVALID_COMMAND_INSIDE_TEST_SESSION = "This command is valid only outside a test"
+ " session";
public static final String MESSAGE_INVALID_COMMAND_INSIDE_REPORT = "This command is not valid while displaying a "
+ "report";
public static final String MESSAGE_INVALID_ANSWER_COMMAND = "Answer command is valid only when a question is "
+ "displayed";
public static final String MESSAGE_INVALID_COMMAND_ON_EMPTY_FOLDER = "This command is not valid on an empty"
+ " folder";
public static final String MESSAGE_INVALID_NEXT_COMMAND = "Next command is valid only when this question has been"
+ " answered";
public static final String MESSAGE_INVALID_ANSWER_COMMAND = "Answer command is valid only when a question is"
+ " displayed";
public static final String MESSAGE_INVALID_COMMAND_OUTSIDE_FOLDER = "Command can only be executed in folder";
public static final String MESSAGE_INVALID_COMMAND_INSIDE_FOLDER = "Command can only be executed in home directory";
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
requireNonNull(model);

if (!model.checkIfInsideTestSession()) {
throw new CommandException(Messages.MESSAGE_INVALID_COMMAND_OUTSIDE_TEST_SESSION);
throw new CommandException(Messages.MESSAGE_INVALID_COMMAND_OUTSIDE_FULLSCREEN);
}
if (model.checkIfCardAlreadyAnswered()) {
throw new CommandException(Messages.MESSAGE_INVALID_ANSWER_COMMAND);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/seedu/address/logic/commands/CommandResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ public enum Type {
EXITED_FOLDER, // The side panel should be updated as folder was exited.
START_TEST_SESSION, // The application should enter a test session.
END_TEST_SESSION, // The current test session should end.
ANSWER_CORRECT,
ANSWER_WRONG,
ENTERED_REPORT,
EXITED_REPORT,
SHOW_NEXT_CARD, // The next card will be displayed in the current test session.
ANSWER_CORRECT, // Correct answer page will be displayed to the user.
ANSWER_WRONG, // Wrong answer page will be displayed to the user.
NONE // use for "nothing to do"
}

Expand Down
17 changes: 13 additions & 4 deletions src/main/java/seedu/address/logic/commands/EndCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ public class EndCommand extends Command {
public static final String COMMAND_WORD = "end";

public static final String MESSAGE_END_TEST_SESSION_SUCCESS = "End test session";
public static final String MESSAGE_END_REPORT_DISPLAY_SUCCESS = "End report display";


@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
if (!model.checkIfInsideTestSession()) {
throw new CommandException(Messages.MESSAGE_INVALID_COMMAND_OUTSIDE_TEST_SESSION);
if (!model.checkIfInsideTestSession() && !model.inReportDisplay()) {
throw new CommandException(Messages.MESSAGE_INVALID_COMMAND_OUTSIDE_FULLSCREEN);
}

if (model.checkIfInsideTestSession()) {
model.endTestSession();
return new CommandResult(MESSAGE_END_TEST_SESSION_SUCCESS, CommandResult.Type.END_TEST_SESSION);
} else {
model.exitReportDisplay();
return new CommandResult(MESSAGE_END_REPORT_DISPLAY_SUCCESS, CommandResult.Type.EXITED_REPORT);
}
model.endTestSession();
return new CommandResult(MESSAGE_END_TEST_SESSION_SUCCESS, CommandResult.Type.END_TEST_SESSION);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class NextCommand extends Command {
@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
if (!model.checkIfInsideTestSession()) {
throw new CommandException(Messages.MESSAGE_INVALID_COMMAND_OUTSIDE_TEST_SESSION);
throw new CommandException(Messages.MESSAGE_INVALID_COMMAND_OUTSIDE_FULLSCREEN);
}
if (!model.checkIfCardAlreadyAnswered()) {
throw new CommandException(Messages.MESSAGE_INVALID_NEXT_COMMAND);
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/seedu/address/logic/commands/ReportCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_INSIDE_REPORT;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_OUTSIDE_FOLDER;

import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;

/**
* Display a report for a folder identified using it's displayed index from the card folder list.
*/
public class ReportCommand extends Command {

public static final String COMMAND_WORD = "report";

public static final String MESSAGE_SUCCESS = "Report displayed";

@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
requireNonNull(model);

if (!model.isInFolder()) {
throw new CommandException(MESSAGE_INVALID_COMMAND_OUTSIDE_FOLDER);
}

if (model.inReportDisplay()) {
throw new CommandException(MESSAGE_INVALID_COMMAND_INSIDE_REPORT);
}

model.enterReportDisplay();
return new CommandResult(MESSAGE_SUCCESS, CommandResult.Type.ENTERED_REPORT);
}
}
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/logic/parser/CommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.NextCommand;
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.ReportCommand;
import seedu.address.logic.commands.SearchCommand;
import seedu.address.logic.commands.SelectCommand;
import seedu.address.logic.commands.SortCommand;
Expand Down Expand Up @@ -83,6 +84,9 @@ public Command parseCommand(String userInput) throws ParseException {
case TestCommand.COMMAND_WORD:
return new TestCommand();

case ReportCommand.COMMAND_WORD:
return new ReportCommand();

case AnswerCommand.COMMAND_WORD:
return new AnswerCommandParser().parse(arguments);

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ public interface Model extends Observable {
*/
boolean checkIfCardAlreadyAnswered();

boolean inReportDisplay();

void enterReportDisplay();

void exitReportDisplay();

void exportCardFolders(Set<CardFolderExport> cardFolderExports, CsvFile csvFile) throws IOException;

void importCardFolders(CsvFile csvFile) throws IOException;
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class ModelManager implements Model {
private boolean cardAlreadyAnswered = false;
private int numAnsweredCorrectly = 0;

// Report display related
private boolean inReportDisplay = false;

// Export related
private CsvManager csvManager = new CsvManager();

Expand Down Expand Up @@ -320,6 +323,24 @@ public void commitActiveCardFolder() {
versionedCardFolder.commit();
}

//=========== Report Displayed =======================================================================
@Override
public boolean inReportDisplay() {
return inReportDisplay;
}

@Override
public void enterReportDisplay() {
inReportDisplay = true;
}

@Override
public void exitReportDisplay() {
inReportDisplay = false;
}



//=========== Test Session ===========================================================================

@Override
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/seedu/address/model/card/UniqueCardList.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@

/**
* A list of cards that enforces uniqueness between its elements and does not allow nulls.
<<<<<<< HEAD
* A card is considered unique by comparing using {@code Card#equals(Card)}. As such, adding and updating of
* cards uses Card#equals(Card) for equality so as to ensure that the card being added or updated is
* unique in terms of identity in the UniqueCardList.
=======
* A card is considered unique by comparing using {@code Card#isSameCard(Card)}. As such, adding and updating of
* cards uses Card#isSameCard(Card) for equality so as to ensure that the card being added or updated is
* unique in terms of identity in the UniqueCardList. However, the removal of a card uses Card#equals(Object) so
* as to ensure that the card with exactly the same fields will be removed.
>>>>>>> parent of 76f8cb02... replace all isSameCard with equal
*
* Supports a minimal set of list operations.
*
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class MainWindow extends UiPart<Stage> {
private BrowserPanel browserPanel;
private FolderListPanel folderListPanel;
private CardListPanel cardListPanel;
private ReportDisplay reportDisplay;
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;
private CardMainScreen cardMainScreen;
Expand Down Expand Up @@ -212,6 +213,16 @@ private void handleExitFolder() {
folderListPanel.refreshContent();
}

private void handleReport() {
reportDisplay = new ReportDisplay(logic.getCardFolder());
Region reportRegion = (reportDisplay).getRoot();
fullScreenPlaceholder.getChildren().add(reportRegion);
}

private void handleEndReport() {
fullScreenPlaceholder.getChildren().remove(fullScreenPlaceholder.getChildren().size() - 1);
}


/**
* Show the page with correct answer.
Expand Down Expand Up @@ -267,6 +278,12 @@ private CommandResult executeCommand(String commandText) throws CommandException
case END_TEST_SESSION:
handleEndTestSession();
break;
case ENTERED_REPORT:
handleReport();
break;
case EXITED_REPORT:
handleEndReport();
break;
case SHOW_NEXT_CARD:
handleNextCardTestSession(commandResult.getTestSessionCard());
break;
Expand Down
Loading

0 comments on commit b715eff

Please sign in to comment.