Introduction

This portfolio is used to showcase my contribution to the CS2103T project in National University of Singapore. There are five students in our group, all majoring in Computer Science. We are given a task to enhance a desktop application Address book 3 with JavaFX GUI. It supports the command line interface for use input. We decided to morph it into a study management application called NUStudy which is targeted to university students. NUStudy is used to manage students' lecture notes, test questions and revision tasks. It also allows students to do mock quiz and view the statistics of the results for better revision.

This is the interface of our project:

Ui
Figure 1. The interface of NUStudy

I am responsible for designing and writing codes for quiz feature. The following sections will describe my contributions to the feature and relevant documentations in detail.

Here are some explanations of the icons and formatting used in this portfolio:

  • A highlighted monospace implies that this is a command that can be inputted and executed by the application.

  • Italics implies a component, class or object in the architecture of the application.

  • The pull requests and issues are represented by a # and its number (e.g. #1)

This symbol indicates that the following information is important.

Summary of contributions

This section briefly describes my contributions to the implementation of quiz feature and other helpful contributions to the group.

Enhancement added: I added the quiz feature of the application (Starting from #36)

  • What it does: This feature allows the users to do a mock quiz. The quiz command allows the users to enter the quiz mode of the application. Users can type answer on command line and the correctness will be checked to show the result. The result of each quiz will be stored as QuizResult and used to support the report feature.

  • Justification: The quiz command will randomly select questions from the database according to the difficulty and subject specified by users and stored in QuizQuestionList. It will act like an actual online quiz which the question will be displayed one at a time and users need to type answer to receive the feedback from the application to know whether it is correct or wrong.

  • Highlights: This feature cooperates with another feature implemented by my teammate. The result of each question from the quiz will be stored and my teammate will use it for report feature. The implementation was tricky in the beginning on how to override the question panel and displaying quiz questions one after another. I solve it by using a boolean to set the QuestionListPanel in the MainWindow class and adding a list containing one quiz question in QuizQuestionList class to display question one by one(#49 #70 #76).

Code contributed: You may review the report of my code contribution to the project here.

Other contributions:

  • Basic design of Question feature:

    • During the development of quiz feature, I helped to design a basic model of question feature so that my teammate could refer to the template for modification and further development (#39).

  • Implement Quiz Result to support report feature:

    • I designed and implemented the basic architecture of quiz result so that my teammate could use it to support the report feature (#53 #74).

  • Identify problems in application for other teams:

    • I helped to discover some of the bugs in the application for another team so that they can fix them and improve the quality of the product (#2 #6).

User guide contributions

We have modified the User Guide of Address Book to demonstrate the commands of our project. The following part shows my contribution to the NUStudy User Guide for quiz feature.


Quiz mode

There is a built-in quiz mode in NUStudy for you to take a revision quiz. You can indicate the number of questions, subject and difficulty and the quiz will randomly select questions for you according to your requirement. You will answer the question one by one and your result will be given.

Entering quiz mode: quiz

You can enter the quiz mode using this command.
Format: quiz n/NUMBER_OF_QUESTIONS d/DIFFICULTY s/SUBJECT

The NUMBER_OF_QUESTIONS must be a positive integer.
DIFFICULTY and SUBJECT are case insensitive.

Example:

Step 1: Types quiz n/2 d/easy s/cs2040 in the command box and presses Enter to execute the command. The following graph specifies how you can input the command.

600
Figure 2. Typing quiz command

Step 2: The result will show the message of successfully entering the quiz mode. The first quiz question will appear on the right column. The following graph shows the result of your quiz command.

600
Figure 3. Result of quiz command

Answering the quiz question

You can type your answer in the command box to answer the question.

The answer is case sensitive.

Example:

Step 1: Types your answer in the command box and presses Enter to execute the command. The figure below is an example of how to answer question.

600
Figure 4. Typing answer in the command line

Step 2: The result will show the correctness of your answer and the next question will be displayed. The following graph simulates the situation after you answer the question.

600
Figure 5. The result after answer

Showing an answer: show

You can check the answer for the current quiz question using this command.
Format: show

You can use it as reference and please do not use it to cheat.

Example:

Step 1: Types show in the command box and presses Enter to execute the command.

Step 2: The answer of current question will be displayed.

600
Figure 6. Typing show command and its result

Skipping a question: skip

You can skip current question and go to the next one using this command.
Format: skip

The question you have skipped will be marked as false for result.

Example:

Step 1: Types skip in the command box and presses Enter to execute the command.

600
Figure 7. Typing skip command

Step 2: The current question is skipped and next question will be displayed.

600
Figure 8. The result of skip command

Exiting quiz mode: quit

You can exit from the quiz mode using this command.
Format: quit

You need to quit the quiz mode every time after you finish the quiz.
You can quit the quiz mode anytime you want.

Example:

Step 1: Types quit in the command box and presses Enter to execute the command.

600
Figure 9. Typing quit command

Step 2: The result shows message of exit from the quiz mode and the original questions will appear. The following graph explains what would happen after you quit from the quiz mode.

600
Figure 10. The result of quit command

Coming in v2.0

Setting a timer for quiz mode

You can set a time limit before you start a quiz to train yourself under exam conditions. NUStudy will automatically end the quiz when time is up.
Format: quiz n/NUMBER_OF_QUESTIONS d/DIFFICULTY s/SUBJECT tl/TIME_LIMIT

Developer guide contributions

We also modified the Developer Guide so that the style and architecture fit our project. The following part shows my contribution to the NUStudy Developer Guide for quiz feature.

In this sections, monospace indicates user command, class objects and methods.

Quiz mode for revision

Implementation

The quiz mode feature is facilitated by Model. The quiz-related commands extend Command with specific question object. The commands update the Model which is implemented by ModelManager. This in turn updates AppData which stores filtered specific questions internally as QuizQuestionList. Local data will be updated in the end by LogicManager. The commands include:

  • QuizModeCommand — Enters the quiz mode with questions selected by user.

  • QuizCheckAnswer — Checks the correctness of answer entered by user.

  • QuizShowAnswerCommand — Shows the answer for current question.

  • QuizSkipQuestion — Skips the current question.

  • QuitQuizModeCommand — Quits the quiz mode.

These operations are exposed in the Model interface as Model#getQuizQuestions(int numOfQuestions, Subject subject Difficulty difficulty), Model#setQuizQuestionList(ObservableList<Question> quizQuestionList), Model#showQuizAnswer(), Model#getFilteredQuizQuestionList(), Model#checkQuizAnswer(Answer answer), Model#removeOneQuizQuestion() and Model#clearQuizQuestionList() respectively.

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

Step 1. The user launches the application for the first time. The app will load all existing information from storage.

Step 2. The user executes quiz n/NUMBER OF QUESTIONS d/DIFFICULTY s/SUBJECT command to enter quiz mode of the app. The quiz command calls Model#getQuizQuestions(int numOfQuestions, Subject subject Difficulty difficulty) and Model#setQuizQuestionList(ObservableList<Question> quizQuestionList), causing the AppData to be updated with a list of specific question selected by user for quiz.

Step 3. The user types answer to answer the question. It calls Model#checkQuizAnswer(Answer answer) and Model#addQuizResult(QuizResult quizResult), causing the AppData to be updated with the result of the answer.

The following graph explains how QuizResult class is designed:

QuizResultClassDiagram
Figure 11. QuizResultClassDiagram

Step 4. The user executes show command to show the answer of current quiz question in the app. The show command calls Model#showQuizAnswer(), causing the AppData to display the answer on the Ui.

Step 5. The user executes skip command to skip the current quiz question in the app. The skip command calls Model#removeOneQuizQuestion(), causing the AppData to display the next quiz question on the Ui.

Step 6. The user executes quit command to exit from the quiz mode. The quit command calls Model#clearQuizQuestionList(), causing the AppData to clear all quiz question list and return to normal mode.

The following sequence diagram shows how the quiz operation works:

QuizModeSequenceDiagram
Figure 12. QuizModeSequenceDiagram

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

400
Figure 13. QuizModeActivityDiagram

Design Considerations

Aspect: How to store the quiz results
  • Alternative 1 (current choice): Update the internal storage QuizResultList in AppData first, then save the updated appData in local storage when the command finishes executing.

    • Pros: It is easier to implement.

    • Cons: It needs the extra step to ensure that the internal list is correctly maintained.

  • Alternative 2: Update the local storage directly when the command is executing.

    • Pros: There is no need to implement the internal list.

    • Cons: The access to local memory is more frequent and it may have performance issues in terms of memory usage.

Aspect: What data structure is used to support the quiz commands
  • Alternative 1 (current choice): Use QuizQuestionList and QuizResultList to store data in AppData.

    • Pros: It is targeted to the quiz model specifically. Quiz question and result list operations are encapsulated in one class.

    • Cons: Logic is duplicated as other models also implement similar list structure.

  • Alternative 2: Use Java list to store the quiz questions and results.

    • Pros: There is no need to maintain a separate list class.

    • Cons: It violates Single Responsibility Principle and Separation of Concerns as the model needs to maintain various list operations.


Use case: Take a quiz (Dongjun)

MSS

  1. Student gives the command to enter the test mode quiz [n/NUMBER_OF_QUESTIONS] [d/DIFFICULTY] [s/SUBJECT]

  2. Application shows a question with difficulty and subject indicated

  3. Application waits for the student to key in the answer

  4. Student enters the answer

  5. Application displays whether the input answer is correct or wrong

  6. Repeat 2 - 5 until all questions are answered

Use case ends

Extensions

  • 1a. Student inputs the invalid quiz command

    • 1a1. Application returns the correct format for quiz command

    • 1a2. Students enter the correct quiz command

  • Use case resumes from step 1

  • 3a. Student chooses to skip current questions by giving skip

    • Application skips this question and display the next question

  • Use case resumes from step 2

  • 3b. Student chooses to get the answer for current question by giving show

    • 3b1. Application displays the answer

  • Use case resumes from step 2

  • a. At any time, Student chooses to exit from the quiz

    • a1. Student gives the command quit

    • a2. Application exits from the quiz mode

  • Use case ends