Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY1920S1#123 from jeongyh99/master
Browse files Browse the repository at this point in the history
Wrote tests and fixed corresponding bugs
  • Loading branch information
alages97 authored Nov 1, 2019
2 parents 6c67479 + d021927 commit dace42a
Show file tree
Hide file tree
Showing 66 changed files with 2,802 additions and 236 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ src/test/data/sandbox/
.DS_Store
*.iml
bin/
CS2103.html
CS2103.html
119 changes: 119 additions & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,16 @@ from one another

|`* * *` |teacher |find a student by name |locate details of students without having to go through the entire list

|`* * *` |teacher |add a student | deal with possible changes

|`* * *` |teacher |keep notes |have reminders for pending tasks

|`* * *` |teacher |prioritize my notes |see the notes that are urgent to me

|`* * *` [Epic] |teacher |generate score statistics |easily view class performance and identify weaker students

|`* * *` |teacher |print my statistics reports |keep a log of individual student performance over the year

|`* *` |student |view the teacher's schedule |request for consultations in appropriate slots

|`* *` |student |view my past results |track my progress and check for updates
Expand All @@ -1313,6 +1323,8 @@ when the teacher is free
|`*` |teacher |have an editable timetable |view my timetable and let students request for consultations at
appropriate slots when I am free



|=======================================================================

_{More to be added}_
Expand Down Expand Up @@ -1596,6 +1608,113 @@ Use case resumes at step 1.
+
Use case resumes at step 1.

[discrete]
=== Use case: Make notes (UC14)

*MSS*

1. Teacher requests to make a note.
2. Teacher enters specifications of the note.
3. NJoy saves the item and displays the new record.
+
Use case ends.

*Extensions*

[none]
* 2a. Njoy detects missing or invalid specifications.
** 2a1. NJoy shows error message.
+
Use case ends.

[discrete]
=== Use case: Edit notes (UC15)

*MSS*

1. Teacher requests to edit a note.
2. Teacher enters specifications of the edited note.
3. NJoy saves the item and displays the new record.
+
Use case ends.

*Extensions*

[none]
* 2a. NJoy detects missing or invalid specifications.
** 2a1. NJoy shows error message.
+
Use case ends.

[discrete]
=== Use case: Delete notes (UC16)

*MSS*

1. Teacher requests to delete a note.
2. Teacher enters specifications of the note to delete.
3. NJoy removes the item and displays the new record.
+
Use case ends.

*Extensions*

[none]
* 2a. NJoy detects invalid specifications.
** 2a1. NJoy shows error message.
+
Use case ends.

[discrete]
=== Use case: List notes (UC17)

*MSS*

1. Teacher requests to list notes to view.
2. NJoy displays the list of notes record.
+
Use case ends.

[discrete]
=== Use case: Sort notes (UC18)

*MSS*

1. Teacher requests to sort the notes by priority.
2. NJoy displays the list of sorted notes record.
+
Use case ends.

[discrete]
=== Use case: Generate Statistics (UC19)

*MSS*

1. Teacher requests to generate statistics report.
2. Teacher enters specifications of the data file.
3. NJoy reads the data file and generates statistics to show.
+
Use case ends.

*Extensions*

[none]
* 2a. NJoy detects invalid specifications of the data file or request.
** 2a1. NJoy shows error message.
+
Use case ends.

[discrete]
=== Use case: Save Statistics Report (UC20)

*MSS*

1. Teacher pass:[generates a statistics report (UC19)].
2. Teacher goes to the directory where report is saved.
3. Teacher sees the saved statistics report.
+
Use case ends.

[appendix]
== Non Functional Requirements

Expand Down
8 changes: 7 additions & 1 deletion docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -783,18 +783,24 @@ The data file needs to be specified in the following format to ensure that the s
[WARNING]
Failure to adhere to the following specifications might result in either the excel file being rejected or erroneous statistics.

* *Data starts at cell A1.*
* *Entries starts at cell A1 with the cell `Students`, regardless of whether there is score data.*
* *First row begins with the cell `Students`, followed by their names. (e.g. row 1 of 4 cells having `Students`, `Jason`, `Mike` and `Peter`)*
* *First column states the different subjects starting from the second topmost cell. (e.g column 1 of 4 cells having `Students`, `Math`, `Science` and `English`.)*
* *All student names have unique identifiers. (e.g. two students named Jason should be identified as `Jason 1` and `Jason 2`)*
* *All students have a corresponding score for all subjects*
* *All scores are numeric characters (integer or decimals)*
* *There are no gaps between rows and columns.*
* *All cells within the row and column range have at least one non-whitespace characters.*
* *All cells outside the row and column range are empty.*

[WARNING]
Failure to adhere to the following specifications might result in some of the statistical data generated not being useful to the user.

* *All scores should be in percentage terms. (0 ~ 100)*

[NOTE]
The general rule for the file format is to ensure all entries in the file are as compact to the top left as possible; the entries should form a rectangular shape on the top left corner of the excel sheet. The rectangle should have no empty entries while all cells outside the rectangle are empty entries.

The statistics report generated uses weighted average scores across the different subjects to perform analysis. All scores carry equal weight. The statistics generated
allow you to see some of the common descriptive statistics and their relative distributions both in terms of frequency and percentile terms.

Expand Down
4 changes: 2 additions & 2 deletions preferences.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"guiSettings" : {
"windowWidth" : 1294.6666259765625,
"windowHeight" : 694.6666870117188,
"windowWidth" : 1550.4000244140625,
"windowHeight" : 838.4000244140625,
"windowCoordinates" : {
"x" : -7,
"y" : -7
Expand Down
Binary file added src/Pictures - Shortcut.lnk
Binary file not shown.
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ public class Messages {

public static final String MESSAGE_INVALID_EVENT_DISPLAYED_INDEX = "The event index provided is invalid";

public static final String MESSAGE_SAVE_STATS_FILE_ERROR = "Statistics Command Error. "
+ "Filename cannot be empty or have any special characters \\ / : * ? \" < > |";
public static final String EXCEL_FILE_NOT_FOUND = "Excel file was not found. Please ensure file path is valid.";
public static final String EXCEL_FILE_NOT_PARSED = "Error occurred retrieving file. Please try with another file";
public static final String EXCEL_FILE_TYPE_ISSUE = "File path must be of type /'.xlsx/'. Please try again.";
public static final String EXCEL_FILE_ILLEGAL_INPUT = "File has illegal input. Please refer to user guide.";
public static final String EXCEL_FILE_ILLEGAL_FORMAT = "File has illegal format. PLease refer to user guide.";
public static final String EXCEL_ILLEGAL_HEADER = "Cell A1 should be 'Students'";

}
11 changes: 11 additions & 0 deletions src/main/java/seedu/address/commons/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,15 @@ public static void writeToFile(Path file, String content) throws IOException {
Files.write(file, content.getBytes(CHARSET));
}

/**
* Checks if the filename is valid for OS.
* @param fileName name of the file to check.
* @return true if fileName is valid
*/
public static boolean isValidFileName(String fileName) {
return !(fileName.contains("\\") || fileName.contains("/") || fileName.contains(":")
|| fileName.contains("*") || fileName.contains("?") || fileName.contains("\"")
|| fileName.contains("<") || fileName.contains(">") || fileName.contains("|")
|| fileName.isEmpty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.CollectionUtil;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
Expand All @@ -24,7 +23,7 @@ public class NoteEditCommand extends NoteCommand {
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits an existing note\n"
+ "Parameters:\n"
+ "INDEX: (must be a positive integer) "
+ "note/{Title}"
+ "note/{Title}\n"
+ "desc/{Description}\n"
+ "Example: note 1 note/tuesday and wednesday desc/grade papers\n";

Expand Down Expand Up @@ -70,19 +69,17 @@ public CommandResult execute(Model model) throws CommandException {
* Creates and returns a {@code Note} with the details of {@code noteToEdit}
* edited with {@code editNoteDescriptor}.
*/
private static Note createEditedNote(Note noteToEdit, EditNoteDescriptor editNoteDescriptor) {
assert noteToEdit != null;
private static Note createEditedNote(
Note noteToEdit, EditNoteDescriptor editNoteDescriptor) throws CommandException {

String updatedNote = !editNoteDescriptor.getNote().get().equals("")
? editNoteDescriptor.getNote().get()
: noteToEdit.getNote();
String updatedDescription = !editNoteDescriptor.getDescription().get().equals("")
? editNoteDescriptor.getDescription().get()
: noteToEdit.getDescription();
Priority priority = editNoteDescriptor.getPriority().isPresent()
? editNoteDescriptor.getPriority().get()
: noteToEdit.getPriority();
assert noteToEdit != null;

if (!editNoteDescriptor.isAnyFieldEdited()) {
throw new CommandException(MESSAGE_NOT_EDITED);
}
String updatedNote = editNoteDescriptor.getNote().orElse(noteToEdit.getNote());
String updatedDescription = editNoteDescriptor.getDescription().orElse(noteToEdit.getDescription());
Priority priority = editNoteDescriptor.getPriority().orElse(noteToEdit.getPriority());
return new Note(updatedNote, updatedDescription, priority);
}

Expand All @@ -109,11 +106,15 @@ public boolean equals(Object other) {
* corresponding field value of the note.
*/
public static class EditNoteDescriptor {
private String note;
private String description;
private Priority priority;

public EditNoteDescriptor() {}
private Optional<String> note;
private Optional<String> description;
private Optional<Priority> priority;

public EditNoteDescriptor() {
note = Optional.empty();
description = Optional.empty();
priority = Optional.empty();
}

/**
* Creates object of details to edit a Note object.
Expand All @@ -128,31 +129,31 @@ public EditNoteDescriptor(NoteEditCommand.EditNoteDescriptor toCopy) {
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(note, description);
return note.isPresent() || description.isPresent() || priority.isPresent();
}

public void setNote(String note) {
public void setNote(Optional<String> note) {
this.note = note;
}

public Optional<String> getNote() {
return Optional.ofNullable(note);
return note;
}

public void setDescription(String description) {
public void setDescription(Optional<String> description) {
this.description = description;
}

public Optional<String> getDescription() {
return Optional.ofNullable(description);
return description;
}

public void setPriority(Priority priority) {
public void setPriority(Optional<Priority> priority) {
this.priority = priority;
}

public Optional<Priority> getPriority() {
return Optional.ofNullable(priority);
return priority;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class NoteListCommand extends NoteCommand {

public static final String MESSAGE_USAGE = COMMAND_WORD + " list";
public static final String MESSAGE_SUCCESS = "Listed all notes";
public static final String MESSAGE_SUCCESS = "This is the list of notes: " + "\n";

@Override
public CommandResult execute(Model model) throws CommandException {
Expand All @@ -29,7 +29,6 @@ public CommandResult execute(Model model) throws CommandException {
* @return The String representation of a success message.
*/
private String generateSuccessMessage(ReadOnlyNotesRecord notesRecord) {
return "This is the list of notes: " + "\n"
+ notesRecord;
return MESSAGE_SUCCESS + notesRecord;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package seedu.address.logic.commands.note;

import static java.util.Objects.requireNonNull;

import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.note.Note;

/**
* Sorts the note list into their priorities.
*/
public class NoteSortCommand extends NoteCommand {

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Sorts the note by Priority from most urgent to least\n"
+ "Parameters:\n"
+ "sort\n"
+ "Example: note sort\n";

public static final String MESSAGE_SUCCESS = "Note sorted by Priority";

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
model.sortNotesRecord(new Note.NoteComparator());
return new CommandResult(MESSAGE_SUCCESS);
}

@Override
public boolean equals(Object other) {
return other == this || other instanceof NoteSortCommand;
}
}
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 @@ -55,6 +55,7 @@ public class CliSyntax {
public static final Prefix PREFIX_NOTE = new Prefix("note/");
public static final Prefix PREFIX_DESCRIPTION = new Prefix("desc/");
public static final Prefix PREFIX_PRIORITY = new Prefix("priority/");
public static final Prefix PREFIX_SORT = new Prefix("sort");
// END OF NOTE PREFIX

// TAG PREFIX
Expand Down
Loading

0 comments on commit dace42a

Please sign in to comment.