Skip to content

Commit 69cc72e

Browse files
authored
Merge branch 'master' into gui-logo-text
2 parents 86c5494 + 4ca22eb commit 69cc72e

65 files changed

Lines changed: 1750 additions & 108 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/seedu/address/commons/core/Messages.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ public class Messages {
1414
public static final String MESSAGE_GROUP_LISTED_OVERVIEW = "You are in tutorial group %1$s.";
1515
public static final String MESSAGE_GROUP_EMPTY = "No such group!";
1616
public static final String MESSAGE_LESSON_LISTED_OVERVIEW = "You are in tutorial group %1$s, lesson %2$s.";
17-
public static final String MESSAGE_LESSON_EMPTY = "No such lesson!";
1817
public static final String MESSAGE_STUDENT_EMPTY = "No such student!";
18+
public static final String MESSAGE_LESSON_EMPTY = "no such lesson!";
19+
public static final String MESSAGE_NOT_VIEWING_A_GROUP = "Group not specified.";
20+
public static final String MESSAGE_NOT_VIEWING_A_LESSON = "Lesson not specified.";
21+
public static final String MESSAGE_INVALID_QUESTION_DISPLAYED_INDEX = "The question index provided is invalid";
1922

2023
}

src/main/java/seedu/address/logic/Logic.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import seedu.address.model.ReadOnlySerenity;
1212
import seedu.address.model.group.Group;
1313
import seedu.address.model.group.Lesson;
14+
import seedu.address.model.group.Question;
1415
import seedu.address.model.group.Student;
1516
import seedu.address.model.group.StudentInfo;
1617
import seedu.address.model.person.Person;
@@ -80,9 +81,14 @@ public interface Logic {
8081
ObservableList<Lesson> getLessonList();
8182

8283
/**
83-
* Returns an unmodifiable view of the filtered list of students info from a group-lesson.
84+
* Returns an unmodifiable view of the list of students info from a group-lesson.
8485
*/
85-
ObservableList<StudentInfo> getFilteredStudentInfoList();
86+
ObservableList<StudentInfo> getStudentInfoList();
87+
88+
/**
89+
* Returns an unmodifiable view of the list of questions from a group-lesson.
90+
*/
91+
ObservableList<Question> getQuestionList();
8692

8793
/**
8894
* Returns the user prefs' serenity file path.

src/main/java/seedu/address/logic/LogicManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import seedu.address.model.ReadOnlySerenity;
1818
import seedu.address.model.group.Group;
1919
import seedu.address.model.group.Lesson;
20+
import seedu.address.model.group.Question;
2021
import seedu.address.model.group.Student;
2122
import seedu.address.model.group.StudentInfo;
2223
import seedu.address.model.person.Person;
@@ -109,10 +110,15 @@ public ObservableList<Lesson> getLessonList() {
109110
}
110111

111112
@Override
112-
public ObservableList<StudentInfo> getFilteredStudentInfoList() {
113+
public ObservableList<StudentInfo> getStudentInfoList() {
113114
return model.getStudentInfoList();
114115
}
115116

117+
@Override
118+
public ObservableList<Question> getQuestionList() {
119+
return model.getQuestionList();
120+
}
121+
116122
@Override
117123
public Path getSerenityFilePath() {
118124
return model.getSerenityFilePath();

src/main/java/seedu/address/logic/commands/AddGrpCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public CommandResult execute(Model model) throws CommandException {
3939
}
4040

4141
model.addGroup(toAdd);
42-
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
42+
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd), false, false, false, true);
4343
}
4444

4545
@Override
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package seedu.address.logic.commands;
2+
3+
import static java.util.Objects.requireNonNull;
4+
import static seedu.address.logic.parser.CliSyntax.PREFIX_GRP;
5+
import static seedu.address.logic.parser.CliSyntax.PREFIX_PATH;
6+
7+
import seedu.address.logic.commands.exceptions.CommandException;
8+
import seedu.address.model.Model;
9+
import seedu.address.model.group.Group;
10+
import seedu.address.model.group.GrpContainsKeywordPredicate;
11+
import seedu.address.model.group.Lesson;
12+
import seedu.address.model.group.LsnContainsKeywordPredicate;
13+
14+
public class AddLsnCommand extends Command {
15+
16+
public static final String COMMAND_WORD = "addlsn";
17+
public static final String MESSAGE_USAGE = COMMAND_WORD
18+
+ ": Adds a new lesson to a specified tutorial group. "
19+
+ "Parameters: "
20+
+ PREFIX_GRP + "GRP "
21+
+ PREFIX_PATH + "PATH ";
22+
23+
public static final String MESSAGE_SUCCESS = "New lesson for tutorial group %2$s added: %1$s";
24+
public static final String MESSAGE_DUPLICATE_LESSON = "This lesson for tutorial group %1$s already exists.";
25+
public static final String MESSAGE_GROUP_DOES_NOT_EXIST = "Specified Tutorial Group does not exist!";
26+
private final GrpContainsKeywordPredicate trgtGrp;
27+
private final String toAdd;
28+
29+
/**
30+
* Creates an AddGrpCommand to add the specified {@code Group}
31+
*/
32+
public AddLsnCommand(String lesson, GrpContainsKeywordPredicate target) {
33+
requireNonNull(lesson);
34+
trgtGrp = target;
35+
toAdd = lesson;
36+
}
37+
38+
@Override
39+
public CommandResult execute(Model model) throws CommandException {
40+
requireNonNull(model);
41+
model.updateFilteredGroupList(trgtGrp);
42+
43+
if (model.getFilteredGroupList().isEmpty()) {
44+
throw new CommandException(MESSAGE_GROUP_DOES_NOT_EXIST);
45+
}
46+
47+
Group trgtGrp = model.getFilteredGroupList().get(0);
48+
Lesson toAdd = new Lesson(this.toAdd, trgtGrp.getStudents());
49+
50+
if (trgtGrp.getLessons().contains(toAdd)) {
51+
throw new CommandException(String.format(MESSAGE_DUPLICATE_LESSON, toAdd, trgtGrp));
52+
}
53+
54+
trgtGrp.getLessons().add(toAdd);
55+
56+
model.updateLessonList();
57+
model.updateFilteredLessonList(new LsnContainsKeywordPredicate(this.toAdd));
58+
59+
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd, trgtGrp), false, false, true, false);
60+
}
61+
62+
@Override
63+
public boolean equals(Object other) {
64+
return other == this // short circuit if same object
65+
|| (other instanceof AddLsnCommand // instanceof handles nulls
66+
&& toAdd.equals(((AddLsnCommand) other).toAdd));
67+
}
68+
69+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package seedu.address.logic.commands;
2+
3+
import static java.util.Objects.requireNonNull;
4+
import static seedu.address.commons.core.Messages.MESSAGE_NOT_VIEWING_A_GROUP;
5+
import static seedu.address.commons.core.Messages.MESSAGE_NOT_VIEWING_A_LESSON;
6+
import static seedu.address.logic.parser.CliSyntax.PREFIX_QN;
7+
8+
import seedu.address.logic.commands.exceptions.CommandException;
9+
import seedu.address.model.Model;
10+
import seedu.address.model.group.Lesson;
11+
import seedu.address.model.group.Question;
12+
import seedu.address.model.group.UniqueQuestionList;
13+
14+
/**
15+
* Adds a question to the question list of a specific tutorial group's lesson in Serenity.
16+
*/
17+
public class AddQnCommand extends Command {
18+
19+
public static final String COMMAND_WORD = "addqn";
20+
public static final String MESSAGE_USAGE = COMMAND_WORD
21+
+ ": Adds a new question to the specific lesson. "
22+
+ "Parameters: "
23+
+ PREFIX_QN + "QUESTION";
24+
25+
public static final String MESSAGE_SUCCESS = "New question added: %1$s";
26+
public static final String MESSAGE_DUPLICATE_QUESTION = "This question already exists.";
27+
28+
private final Question toAdd;
29+
30+
/**
31+
* Creates an AddQnCommand to add the specified {@code Lesson}
32+
*/
33+
public AddQnCommand(Question question) {
34+
requireNonNull(question);
35+
toAdd = question;
36+
}
37+
38+
@Override
39+
public CommandResult execute(Model model) throws CommandException {
40+
requireNonNull(model);
41+
42+
if (model.getFilteredGroupList().size() != 1) {
43+
throw new CommandException(MESSAGE_NOT_VIEWING_A_GROUP);
44+
}
45+
46+
if (model.getFilteredLessonList().size() != 1) {
47+
throw new CommandException(MESSAGE_NOT_VIEWING_A_LESSON);
48+
}
49+
50+
Lesson uniqueLesson = model.getFilteredLessonList().get(0);
51+
UniqueQuestionList uniqueQuestionList = uniqueLesson.getQuestionList();
52+
53+
if (uniqueQuestionList.contains(toAdd)) {
54+
throw new CommandException(MESSAGE_DUPLICATE_QUESTION);
55+
}
56+
57+
uniqueQuestionList.add(toAdd);
58+
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
59+
}
60+
61+
@Override
62+
public boolean equals(Object other) {
63+
return other == this // short circuit if same object
64+
|| (other instanceof AddQnCommand // instanceof handles nulls
65+
&& toAdd.equals(((AddQnCommand) other).toAdd));
66+
}
67+
68+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package seedu.address.logic.commands;
2+
3+
import static java.util.Objects.requireNonNull;
4+
import static seedu.address.logic.parser.CliSyntax.PREFIX_ID;
5+
import static seedu.address.logic.parser.CliSyntax.PREFIX_STUDENT;
6+
7+
import javafx.collections.ObservableList;
8+
import seedu.address.logic.commands.exceptions.CommandException;
9+
import seedu.address.model.Model;
10+
import seedu.address.model.group.Lesson;
11+
import seedu.address.model.group.Participation;
12+
import seedu.address.model.group.Student;
13+
import seedu.address.model.group.StudentInfo;
14+
import seedu.address.model.group.UniqueStudentInfoList;
15+
16+
public class AddScoreCommand extends Command {
17+
18+
public static final String COMMAND_WORD = "addscore";
19+
public static final String MESSAGE_SUCCESS = "%s: \nParticipation Score - %d";
20+
21+
public static final String MESSAGE_USAGE = COMMAND_WORD
22+
+ ": Gives a student in the class a participation score. \n"
23+
+ "Parameters: " + " " + "SCORE "
24+
+ PREFIX_STUDENT + " NAME" + " " + PREFIX_ID + " STUDENT_NUMBER\n"
25+
+ "Example: " + COMMAND_WORD + " " + "2" + " "
26+
+ PREFIX_STUDENT + " Aaron Tan" + " " + PREFIX_ID + " e0123456";
27+
28+
private Student toAddScore;
29+
private int score;
30+
31+
/**
32+
* Creates an AddScoreCommand to award the specified {@code Student} a participation score
33+
*/
34+
public AddScoreCommand(Student student, int score) {
35+
requireNonNull(student);
36+
// Specified student to add participation score
37+
toAddScore = student;
38+
this.score = score;
39+
}
40+
41+
@Override
42+
public CommandResult execute(Model model) throws CommandException {
43+
requireNonNull(model);
44+
45+
Lesson uniqueLesson = model.getFilteredLessonList().get(0);
46+
UniqueStudentInfoList uniqueStudentInfoList = uniqueLesson.getStudentsInfo();
47+
ObservableList<StudentInfo> studentsInfo = uniqueStudentInfoList.asUnmodifiableObservableList();
48+
49+
// Update single student participation score
50+
for (int i = 0; i < studentsInfo.size(); i++) {
51+
StudentInfo studentInfo = studentsInfo.get(i);
52+
boolean isCorrectStudent = studentInfo.containsStudent(toAddScore);
53+
if (isCorrectStudent) {
54+
Participation update = studentInfo.getParticipation().setScore(score);
55+
StudentInfo updatedStudentInfo = studentInfo.updateParticipation(update);
56+
uniqueStudentInfoList.setStudentInfo(studentInfo, updatedStudentInfo);
57+
model.updateLessonList();
58+
model.updateStudentInfoList();
59+
}
60+
}
61+
return new CommandResult(String.format(MESSAGE_SUCCESS, toAddScore, score));
62+
63+
}
64+
}

src/main/java/seedu/address/logic/commands/CommandResult.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,33 @@ public class CommandResult {
2121
*/
2222
private final boolean exit;
2323

24+
/**
25+
* The application should toggle to lesson data screen
26+
*/
27+
private final boolean isViewLsn;
28+
29+
/**
30+
* The application should toggle to group data screen
31+
*/
32+
private final boolean isViewGrp;
33+
2434
/**
2535
* Constructs a {@code CommandResult} with the specified fields.
2636
*/
27-
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) {
37+
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit, boolean viewLsn, boolean viewGrp) {
2838
this.feedbackToUser = requireNonNull(feedbackToUser);
2939
this.showHelp = showHelp;
3040
this.exit = exit;
41+
this.isViewLsn = viewLsn;
42+
this.isViewGrp = viewGrp;
3143
}
3244

3345
/**
3446
* Constructs a {@code CommandResult} with the specified {@code feedbackToUser}, and other fields set to their
3547
* default value.
3648
*/
3749
public CommandResult(String feedbackToUser) {
38-
this(feedbackToUser, false, false);
50+
this(feedbackToUser, false, false, false, false);
3951
}
4052

4153
public String getFeedbackToUser() {
@@ -50,6 +62,14 @@ public boolean isExit() {
5062
return exit;
5163
}
5264

65+
public boolean isToggleLsnView() {
66+
return isViewLsn;
67+
}
68+
69+
public boolean isToggleGrpView() {
70+
return isViewGrp;
71+
}
72+
5373
@Override
5474
public boolean equals(Object other) {
5575
if (other == this) {
@@ -71,5 +91,4 @@ public boolean equals(Object other) {
7191
public int hashCode() {
7292
return Objects.hash(feedbackToUser, showHelp, exit);
7393
}
74-
7594
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package seedu.address.logic.commands;
2+
3+
import static java.util.Objects.requireNonNull;
4+
import static seedu.address.logic.parser.CliSyntax.PREFIX_GRP;
5+
6+
import seedu.address.commons.core.Messages;
7+
import seedu.address.logic.commands.exceptions.CommandException;
8+
import seedu.address.model.Model;
9+
import seedu.address.model.group.Group;
10+
import seedu.address.model.group.GrpContainsKeywordPredicate;
11+
12+
public class DelGrpCommand extends Command {
13+
14+
public static final String COMMAND_WORD = "delgrp";
15+
public static final String MESSAGE_USAGE = COMMAND_WORD
16+
+ ": Deletes an existing tutorial group. "
17+
+ "Parameter: "
18+
+ PREFIX_GRP + "GRP \n"
19+
+ "Example: " + COMMAND_WORD + " " + PREFIX_GRP + "G04";
20+
21+
public static final String MESSAGE_DELETE_GROUP_SUCCESS = "Tutorial group deleted: %1$s";
22+
23+
private final GrpContainsKeywordPredicate grpPredicate;
24+
25+
/**
26+
* Creates a DelGrpCommand to add the specified {@code Group}
27+
*/
28+
public DelGrpCommand(GrpContainsKeywordPredicate grpPredicate) {
29+
this.grpPredicate = grpPredicate;
30+
}
31+
32+
@Override
33+
public CommandResult execute(Model model) throws CommandException {
34+
requireNonNull(model);
35+
36+
Group toDel = null;
37+
38+
if (!model.getSerenity().getGroupList().isEmpty()) {
39+
for (Group group : model.getSerenity().getGroupList()) {
40+
if (group.getName().equals(grpPredicate.getKeyword())) {
41+
toDel = group;
42+
break;
43+
}
44+
}
45+
}
46+
47+
if (toDel == null) {
48+
throw new CommandException(Messages.MESSAGE_GROUP_EMPTY);
49+
}
50+
51+
model.deleteGroup(toDel);
52+
model.updateFilteredGroupList(grpPredicate);
53+
return new CommandResult(String.format(MESSAGE_DELETE_GROUP_SUCCESS, toDel));
54+
}
55+
}

0 commit comments

Comments
 (0)