Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwin97 committed Nov 9, 2019
2 parents 7702065 + f8b34c9 commit a8214bb
Show file tree
Hide file tree
Showing 51 changed files with 1,564 additions and 219 deletions.
56 changes: 28 additions & 28 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -403,70 +403,70 @@ check with the rest of the prior `Reminder` object, to ensure that there is no d
==== Implementation
The main point of this feature is to learn a user's typing habits so as to give them a more seamless experience
while using TutorAid by adapting to their typing style so that they do not have to memorize
built in commands.
built in commands. This is done by having TutorAid trigger in and out of "learner" mode.

The sequence of events is triggered when a user accidentally inputs a wrong command. TutorAid will then prompt
the user on whether or not they wish to add this command to the library as a custom command mapped to the action of a built in command.
A `CommandResult` object now has an added boolean `isUnknown` instance variable to indicate if the command entered is
an unknown command. Using this, TutorAid shifts between "learner" mode and normal mode:

Custom command keywords and their mappings are stored locally in TutorAid.json with
the help of `JsonAdaptedCommand`.
.How TutorAid goes from normal to "learner" mode
image::changeLearner.png[width="800"]

.How TutorAid goes from "learner" to normal mode
image::changeNormal.png[width="800"]

The whole mechanism is mainly facilitated by `TutorAidParser` which has been modified to suit our needs. A TreeMap
is now being used in the process of parsing commands.
The effect of being in "learner" mode results in the `TutorAidParser` using different methods to parse the command. This will be elaborated on in the sample use scenario below.

While in "learner" mode, TutorAid can map wrong commands to the actions of known commands. These wrong/custom command keywords and their mappings are stored locally in TutorAid.json with
the help of `JsonAdaptedCommand`.

A `CommandResult` object now also has an added boolean "unknown" instance variable to indicate if the command entered is
an unknown command. New command classes such as `UnknownCommand`, `NewCommand` and `CancelCommand` were also created.
A TreeMap is now being used in the process of parsing commands. New command classes such as `UnknownCommand`, `NewCommand` and `CancelCommand` were also created.

* `TutorAidParser#checkCommand()` -- Separate "parser" functions for unknown command operations.
* `TutorAidParser#checkCommand` -- Separate "parser" functions for unknown command operations.
Checks if the command a user wants to map his unknown command to is valid and exists or if the user wishes
to exit the operation.
* `TutorAidParser#initialiseBasicCommands()` -- Initialises the functionality of the `TutorAidParser` by adding
* `TutorAidParser#initialiseBasicCommands` -- Initialises the functionality of the `TutorAidParser` by adding
the basic command mappings to its TreeMap.

Given below is an example usage scenario and how the learn custom command mechanism behaves at each step.

Step 1. The user launches the application for the first time. The `TutorAidParser` will be initialized and all basic
commands and previous existing custom commands will be added to its TreeMap.
commands and previous existing custom commands will be added to its TreeMap via `TutorAidParser#initialiseBasicCommands`.

Step 2. The user enters "plus" instead of "add". `TutorAidParser` does a lookup in its TreeMap and in the `TutorAidParser#parseCommand(String userInput)` function and returns a new `UnknownCommand` since
Step 2. The user enters "plus" instead of "add". `TutorAidParser` does a lookup in its TreeMap in the `TutorAidParser#parseCommand(String userInput)` method and returns a new `UnknownCommand` since
the TreeMap does not contain the keyword "plus".

Step 3. The `UnknownCommand` is executed by `Logic` and "plus" is saved on a Stack in the `Model` component. Subsequently, the `CommandResult` is passed to `MainWindow` to display the corresponding text on the GUI. The `CommandResult` triggers `CommandResult#isUnknown()` and sets the "unknown" variable in `MainWindow`
to true.
Step 3. The `UnknownCommand` is executed by `Logic` and "plus" is saved on `savedCommand` in the `Model` component. Subsequently, the `CommandResult` is passed to `MainWindow` to display the corresponding text on the GUI. This `CommandResult` triggers TutorAid into "learner" mode via the earlier explained implementation.

[NOTE]
`Logic#execute(String userInput)` has been changed to `Logic#execute(String userInput, boolean isUnknown)` to account for different execution pathways of unknown and known commands.
Step 4. TutorAid prompts the user to type in a valid command to map the unknown command to. The user types in another wrong command that is not recognised. This time, he enters "ad" instead of "add". Since TutorAid is in "learner" mode, the method `TutorAidParser#checkCommand(String userInput, String prevUnknownCommand)` is now called instead of `TutorAidParser#parseCommand(String userInput)`.

Step 4. TutorAid prompts the user to type in a valid command to map the unknown command to. The user types in another wrong command that is not recognised. This time, he enters "ad" instead of "add". `Logic#execute(String userInput, boolean isUnknown)` now calls `TutorAidParser#checkCommand(String userInput, String prevUnknownCommand)` as `MainWindow` passes in a value of `true` to the `isUnknown` boolean variable of the execute command.
[NOTE]
Logic#execute(String userInput) has been changed to Logic#execute(String userInput, boolean isUnknown) to account for different execution pathways when in normal and "learner" mode.

[NOTE]
`prevUnknownCommand` variable is retrieved from executing a `peek()` command on the `savedCommand` stack in `Model`
`prevUnknownCommand` variable is retrieved from executing a `peek()` command on the `savedCommand` stack in `Model`.

Step 5. In `TutorAidParser#checkCommand(String userInput, String prevUnknownCommand)`, the command is still not recognized and another `UnknownCommand` is returned.
Step 5. In `TutorAidParser#checkCommand(String userInput, String prevUnknownCommand)`, the command is still not recognized and another `UnknownCommand` is returned and "ad" is also saved.
Steps 3-5 occurs continuously as long as an unknown command is being supplied or until the user cancels the operation by typing in "cancel".

Step 7. The user inputs a valid command. `TutorAidParser#checkCommand(String userInput, String prevUnknownCommand)` now finds the valid command in the TreeMap. With the latest "prevUnknownCommand" retrieved from the stack, it adds the unknown command and action of the valid command as a key-value pair to the TreeMap and as a new CommandObject to the `TutorAid` for storage via execution of `NewCommand` object.
Step 6. The user inputs a valid command. `TutorAidParser#checkCommand(String userInput, String prevUnknownCommand)` now finds the valid command in the TreeMap. With the latest `prevUnknownCommand` retrieved from the stack, the unknown command and action of the valid command is added as a key-value pair to the TreeMap and a `NewCommand` object is returned and executed to store this new command mapping with the help of `Model`.

Step 8. `NewCommand` has a `CommandResult` with an "unknown" value of false. This will trigger `MainWindow#setUnknownFalse()` and set the unknown variable in `MainWindow` to false. Normal commands can then be performed as `TutorAidParser#parseCommand(String userInput)` will now be called again instead of `TutorAidParser#checkCommand(String userInput, String prevUnknownCommand)`.
Step 7. `NewCommand` has a `CommandResult` with an `isUnknown` value of `false`. This will trigger TutorAid back to normal mode. Normal commands can then be performed as `TutorAidParser#parseCommand(String userInput)` will now be called again instead of `TutorAidParser#checkCommand(String userInput, String prevUnknownCommand)`.

The following sequence diagrams shows how the learn custom command operation works:

Firstly an unknown command is supplied,

image::UnknownCommandDiagram.png[]
image::UnknownCommandDiagram.png[width="700"]

NOTE: The lifeline for `UnknownCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

After which, a known command is supplied,

image::NewCommandDiagram.png[]

[NOTE]
`TutorAidParser#checkCommand(String userInput, String prevUnknownCommand)` is called instead of the normal `TutorAidParser#parseCommand(String userInput)` function because the boolean input "isUnknown" in `Logic#execute(String userInput, boolean isUnknown)` is set to true.
image::NewCommandDiagram.png[width="700"]

The following activity diagram summarizes what happens when a user executes a new command:

image::LearnCustomCommandsActivityDiagram.png[]
image::LearnCustomCommandsActivityDiagram.png[width="500"]

==== Design Considerations

Expand Down
159 changes: 90 additions & 69 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@ By: `Team CS2103-F14-2` Since: `Sept 2019` Licence: `MIT`

== Introduction

TutorAid is for teaching assistants or tutors who prefer to use a desktop app for managing their classes and related tasks. More importantly, TutorAid is optimized for those who prefer to work with a Command Line Interface (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, TutorAid can get your tasks done faster than traditional GUI apps. Interested? Jump to the Section 2, “Quick Start” to get started. Enjoy!
Are you a teaching assistant that is *struggling* to keep up with the additional responsibility of teaching a class?

Do you sometimes *wish* that there was an easier way to organize and filter through your students?

As a broke uni student, do you *desperately* need a tool to keep track of your earnings?

### Look no further! TutorAid is the one stop solution to answer all of your TA woes!

TutorAid is for teaching assistants or tutors who prefer to use a desktop app for managing their classes and related tasks. TutorAid helps in organizing all the information you need in one place so that you can optimize your workflow.
More importantly, TutorAid is optimized for those who prefer to work with a Command Line Interface (CLI) while still having the benefits of a Graphical User Interface (GUI).

This User Guide was written to help you understand and familiarize yourself with all the commands TutorAid has to help you get started.

If you can type fast, TutorAid can get your tasks done faster than traditional GUI apps. Interested? Jump to the Section 2, “Quick Start” to get started. Enjoy!

== Quick Start

Expand All @@ -35,7 +48,7 @@ e.g. typing *`help`* and pressing kbd:[Enter] will open the help window.


* *`help`* : Links you to the User Guide so you can view how to use all the available commands.
* **`add_task c/CS2103T Lecture mark/Y tt/20/9/2019 16:00, 20/9/2019 18:00` : adds a classId named CS2103T that is on 20th September 2019 4pm.
* **`add_task`**`c/CS2103T Lecture mark/Y tt/20/9/2019 16:00, 20/9/2019 18:00` : adds a classId named CS2103T that is on 20th September 2019 4pm.
* **`claimed earnings`**`02/07/2022 CS2100` : marks that you have claimed this earnings.
* *`exit`* : exits the app

Expand Down Expand Up @@ -286,7 +299,7 @@ Examples:
==== Edit Note: `editnote`

Update Note in the list of notes. +
Format: `editnote [index] mod/MODULE_CODE c/CONTENT`
Format: `editnote INDEX mod/MODULE_CODE c/CONTENT`

Examples:

Expand All @@ -297,7 +310,7 @@ Examples:
==== Delete Note: `deletenote`

Delete Note in the list of notes. +
Format: `deletenote [index]`
Format: `deletenote INDEX`

Examples:

Expand All @@ -306,7 +319,7 @@ Examples:
==== Find Note: `findnote`

Delete Note in the list of notes. +
Format: `findnote [KEYWORD]`
Format: `findnote KEYWORD`

Examples:

Expand All @@ -317,9 +330,6 @@ Examples:
List all note. +
Format: `listnote`

// end::delete[]

// tag::studentProfile[]
=== Student List

==== Add a student: 'add'
Expand Down Expand Up @@ -348,51 +358,47 @@ Examples:

* `delete 1` (deletes the first student.)

==== Edit a student: 'edit'

Edits a Student's fields.
Format: `edit INDEX n/NAME pic/PICTURE r/RESULT att/ATTENDANCE part/PARTICIPATION c/CLASS`

[NOTE]
User does not have to edit all fields of a Student. He can just edit whatever needs to be changed (see example).
==== Find a student: 'find'

[NOTE]
Result of a student can be assigned using this command. e.g. `edit 1 r/79`
Find a student matching the supplied name.
Format: `find NAME`

Examples:

* `edit 1 r/20 att/10 part/10 c/CS2030`
* `find Tom`

==== List students: 'list'
==== List all students in a class: 'list_class'

List all students in TutorAid.
Format: `list`
Lists all students in supplied class name.
Format: `list_class CLASSID`

image::list.png[width="500", align="left"]
Examples:

[NOTE]
`list` command does not take any arguments.
* `list_class CS2030`

==== Find a student: 'find'
==== Mark attendance of students: 'mark_attendance'

Find a student matching the supplied name.
Format: `find NAME`
Marks attendance of students currently displayed.
Format: `mark_attendance INDEXES`

[NOTE]
`mark_attendance` increases attendance of all selected students by exactly 1.

Examples:

* `find Tom`
* `mark_attendance 1,2,3`

==== Add a picture to a student: 'set_pic'
==== Mark participation of students: 'mark_participation'

Adds a picture to display next to the student card.
Format: `set_pic INDEX pic/FILENAME`
Marks participation of students currently displayed.
Format: `mark_participation INDEXES`

[NOTE]
The picture specified must be in either .jpg, .png or .bmp format. It must also be located in the same directory as TutorAid.
`mark_participation` increases participation of all selected students by exactly 1.

Examples:

* `set_pic 2 pic/Tom.jpg`
* `mark_participation 1,2,3`

==== Assign students to a class: 'assign_class'

Expand All @@ -403,38 +409,40 @@ Examples:

* `assign_class 1,2,3 c/CS2030`

==== List all students in a class: 'list_class'
// tag::includeStudentProfile[]
==== Edit a student: 'edit'

Lists all students in supplied class name.
Format: `list_class CLASSID`
Edits a Student's fields.
Format: `edit INDEX n/NAME pic/PICTURE r/RESULT att/ATTENDANCE part/PARTICIPATION c/CLASS`

Examples:
[NOTE]
User does not have to edit all fields of a Student. He can just edit whatever needs to be changed (see example). As such, result of a student can be assigned using this command. e.g. `edit 1 r/79`

* `list_class CS2030`
Examples:

==== Mark attendance of students: 'mark_attendance'
* `edit 1 r/20 att/10 part/10 c/CS2030`

Marks attendance of students currently displayed.
Format: `mark_attendance INDEXES`
==== List students: 'list'

[NOTE]
`mark_attendance` increases attendance of all selected students by exactly 1.
List all students in TutorAid.
Format: `list`

Examples:
image::list.png[width="600", align="left"]

* `mark_attendance 1,2,3`
[NOTE]
`list` command does not take any arguments.

==== Mark participation of students: 'mark_participation'
==== Add a picture to a student: 'set_pic'

Marks participation of students currently displayed.
Format: `mark_participation INDEXES`
Adds a picture to display next to the student card.
Format: `set_pic INDEX pic/FILENAME`

[NOTE]
`mark_participation` increases participation of all selected students by exactly 1.
The picture specified must be in either .jpg, .png or .bmp format. It must also be located in the same directory as TutorAid.

Examples:

* `mark_participation 1,2,3`
* `set_pic 2 pic/Tom.jpg`

==== View serial absentees with defined threshold: 'absentees' [Coming in v2.0]

Expand All @@ -456,7 +464,6 @@ Format: `check_status`
[NOTE]
To be used in conjunction with `absentees`. A preset generic email will be sent by TutorAid to the student's school email account.


==== Upload a picture of the student: 'upload_pic' [Coming in v2.0]

Launches a separate window where the user can either choose an image file on his computer or take a picture with his webcam.
Expand All @@ -470,17 +477,30 @@ Examples:

* `upload_pic 1`

==== Learn wrong commands
=== Learn wrong commands

Accidentally typing in a wrong/unknown command laucnhes TutorAid into learner mode. You can choose to learn this wrong command to execute an existing
command by typing in its command word. Alternatively, you can type `cancel` to revert back to normal operations.

image::customCommandError.png[width="500", align="left"]
image::customCommandError.png[width="600", align="left"]

[NOTE]
You can't learn a full command (e.g. `add n/Caesar c/CS1231`). Doing so will result in an error. TutorAid only allows command words like `add`.

// end::studentProfile[]
Examples:

* `ad` (instead of `add`) -> TutorAid will prompt the user what they meant. Type `add` now to be able
to use `ad` as an `add` command in the future.

// end::includeStudentProfile[]
==== Delete a custom command: 'deleteCustomCommand'

Deletes a custom command you previously added. This custom command will be forgotten by TutorAid and will not be able to be used anymore.
Format: `deleteCustomCommand CUSTOMCOMMAND`

Examples:

* `deleteCustomCommand insertPreviouslyAddedCommandHere`

=== Clearing all entries : `clear`

Expand Down Expand Up @@ -545,16 +565,6 @@ Format: `exit`
Address book data are saved in the hard disk automatically after any command that changes the data. +
There is no need to save manually.

=== Learning wrong commands as custom commands

TutorAid is able to learn a wrongly supplied command to do what the user intended to do. +
Format: `WRONG_COMMAND`

Examples:

* `ad` (instead of `add`) -> TutorAid will prompt the user what they meant. Type `add` now to be able
to use `ad` as an `add` command in the future.

=== Logout : `logout`

Logs out of the account. +
Expand Down Expand Up @@ -600,17 +610,28 @@ _{explain how the user can enable/disable data encryption}_
* *Reminder* : `reminder INDEX STATUS`
* *Earnings* : +
`add_earnings d/DATE c/CLASSID amt/AMOUNT` +
`update_earnings d/DATE c/CLASSID amt/(NEW_AMOUNT)` +
`update_earnings d/DATE c/CLASSID amt/AMOUNT type/TYPE` +
`delete_earnings d/DATE c/CLASSID` +
`find_earnings k/KEYWORD, ...` +
`find_earnings k/KEYWORD ...` +
`claim_earnings d/DATE c/CLASSID` +
`filter_earnings VARIABLE`
* *Note* : +
`addnote mod/MODULE_CODE c/CONTENT` +
`editnote [index] mod/MODULE_CODE c/CONTENT` +
`deletenote 1` +
`findnote [KEYWORD]` +
`editnote INDEX mod/MODULE_CODE c/CONTENT` +
`deletenote INDEX` +
`findnote KEYWORD` +
`listnote`
* *Student List* : +
`add n/NAME c/CLASSID` +
`delete INDEX` +
`edit INDEX n/NAME pic/PICTURE r/RESULT att/ATTENDANCE part/PARTICIPATION c/CLASS` +
`list` +
`find NAME` +
`set_pic INDEX pic/FILENAME` +
`assign_class INDEXES c/CLASSID` +
`list_class CLASSID` +
`mark_attendance INDEXES` +
`mark_participation INDEXES`
* *Undo* : `undo`
* *Redo* : `redo`
* *Clear* : `clear`
Expand Down
Binary file added docs/images/changeLearner.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/changeNormal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/customEnd.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/customRepeat.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/customStarting.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a8214bb

Please sign in to comment.