Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY1920S1#80 from fabbbbbbyy/master
Browse files Browse the repository at this point in the history
Update Developer Guide & User Guide
  • Loading branch information
jeongyh99 authored Oct 23, 2019
2 parents 4e43fb9 + 51878cb commit 998a11e
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
87 changes: 87 additions & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,93 @@ will not be confused by the layout.
However, this is not feasible as it will break the standard formatting of the answers display since both *Open Ended* and *MCQ*
questions will have 2 different answer formats and may cause confusion to the user.

=== Quiz feature

The quiz feature utilises the questions implemented and stored in the `QuestionBank#questions` observable list. The quiz feature utilises the `QuizCommandParser` class to parse the user command input into the different command types and validates the input. Quizzes are then added into the `QuizBank#quizzes` observable list. The quiz feature also relies heavily on the `QuizManager` class for handling commands from `QuizCommand#execute`. This is done to hide the implementation logic from the `ModelManager` class. +

The feature comprises of five commands namely,

* <<Feature-Quiz-Create-Manually, `QuizCreateManuallyCommand`>> - Creates a quiz with user input manually
* <<Feature-Quiz-Create-Automatically, `QuizCreateAutomaticallyCommand`>> - Creates a quiz automatically
* <<Feature-Quiz-Add-Question, `QuizAddQuestionCommand`>> - Adds a question to an existing quiz
* <<Feature-Quiz-Remove-Question, `QuizRemoveQuestionCommand`>> - Removes a question from an existing quiz
* <<Feature-Quiz-List, `QuizGetQuestionsAndAnswersCommand`>> - Listing questions and answers of an existing quiz

The commands when executed, will interface with the methods exposed by the `Model` interface to perform the related operations
(See <<Design-Logic, logic component>> for the general overview).

[[Feature-Quiz-Create-Manually]]
==== Create Manually command

The following is a detailed explanation of the operations `QuizCreateManuallyCommand` performs. +

*Step 1*. The `QuizCreateManuallyCommand#execute(Model model)` method is executed and it validates the quizId, making sure that there is no existing quiz with the same quizId. Then, it validates the question numbers, making sure that all question numbers currently exist within the `QuestionBank#questions` observable list.

*Step 2*. The method `Model#createQuizManually(String quizId, ArrayList<Integer> questionNumbers)` will then be called to create the quiz with the specified questions. This calls the method `SavedQuizzes#createQuizManually(String quizId, ArrayList<Integer> questionNumbers, SavedQuestions savedQuestions)` which calls the method `QuizManager#createQuizManually(String quizId, ArrayList<Integer> questionNumbers, SavedQuestions savedQuestions, QuizBank quizBank)`. This creates a `Quiz` class instance with the given quizId and iterates through the `QuestionBank#questions` to obtain the questions that the user has specified. Lastly, it adds this new `Quiz` instance to the `QuizBank#quizzes` for storage.

*Step 3*. Then, asuccess message will be generated by the `QuizCreateManuallyCommand#generateSuccessMessage()` method and a new `CommandResult` will be returned with the generated success message.

[[Feature-Quiz-Create-Automatically]]
==== Create Automatically command

The following is a detailed explanation of the operations `QuizCreateAutomaticallyCommand` performs. +

*Step 1*. The `QuizCreateAutomaticallyCommand#execute(Model model)` method is executed and it validates the quizId, making sure that there is no existing quiz with the same quizId.

*Step 2*. The method `Model#createQuizAutomatically(String quizId, int numQuestions, String type)` will then be called to create the quiz with the specified number of questions. This calls the method `SavedQuizzes#createQuizAutomatically(String quizId, int numQuestions, String type, SavedQuestions savedQuestions)` which calls the method `QuizManager#createQuizAutomatically(String quizId, int numQuestions, String type, SavedQuestions savedQuestions, QuizBank quizBank)`. This creates a `Quiz` class instance with the given quizId and iterates through the `QuestionBank#questions` to obtain random questions to add to the quiz. The method ensures that no duplicate questions are added to the quiz, and continues adding questions to the quiz until the correct number of questions have been added. Lastly, it adds this new `Quiz` instance to the `QuizBank#quizzes` for storage.

*Step 3*. Then, a success message will be generated by the `QuizCreateAutomaticallyCommand#generateSuccessMessage()` method and a new `CommandResult` will be returned with the generated success message.

[[Feature-Quiz-Add-Question]]
==== Add Question command

The following is a detailed explanation of the operations `QuizAddQuestionCommand` performs. +

*Step 1*. The `QuizAddQuestionCommand#execute(Model model)` method is executed and it validates the question number, making sure that the question number currently exists within the `QuestionBank#questions` observable list.

*Step 2*. The method `Model#addQuizQuestion(String quizId, int questionNumber, int quizQuestionNumber)` will then be called to add the specified question to the specified quiz. This calls the method `SavedQuizzes#addQuizQuestion(String quizId, int questionNumber, int quizQuestionNumber, SavedQuestions savedQuestions)` which calls the method `QuizManager#addQuizQuestion(String quizId, int questionNumber, int quizQuestionNumber, SavedQuestions savedQuestions, QuizBank quizBank)`. This obtains the question specified by the user, then adds it to the quiz specified by the quizId. This is done by searching through the `QuizBank#quizzes` for a quiz matching the quizId. Then, it calls the method `Quiz#addQuestion(Question question, int questionIndex)` which adds the question to the appropriate index.

*Step 3*. Then, a success message will be generated by the `QuizAddQuestionCommand#generateSuccessMessage()` method and a new `CommandResult` will be returned with the generated success message.

[[Feature-Quiz-Remove-Question]]
==== Remove Question command

The following is a detailed explanation of the operations `QuizRemoveQuestionCommand` performs. +

*Step 1*. The `QuizRemoveQuestionCommand#execute(Model model)` method is executed.

*Step 2*. The method `Model#removeQuizQuestion(String quizId, int questionNumber)` will then be called to remove a specified question from the specified quiz. This calls the method `SavedQuizzes#removeQuizQuestion(String quizId, int questionNumber, SavedQuestions savedQuestions)` which calls the method `QuizManager#removeQuizQuestion(String quizId, int questionNumber, SavedQuestions savedQuestions, QuizBank quizBank)`. This obtains the quiz specified by searching through the `QuizBank#quizzes` for a quiz matching the quizId. Then, it calls the method `Quiz#removeQuestion(int questionIndex)` which removes the question from the specified question index.

*Step 3*. Then, a success message will be generated by the `QuizRemoveQuestionCommand#generateSuccessMessage()` method and a new `CommandResult` will be returned with the generated success message.

[[Feature-Quiz-List]]
==== List command

The following is a detailed explanation of the operations `QuizGetQuestionsAndAnswersCommand` performs. +

*Step 1*. The `QuizGetQuestionsAndAnswersCommand#execute(Model model)` method is executed.

*Step 2*. The method `Model#getQuestionsAndAnswersCommand(String quizId)` will then be called to obtain the questions and answers in String representation for a specified quizId. This calls the method `SavedQuizzes#getQuestionsAndAnswersCommand(String quizId)` which calls the method `QuizManager#getQuestionsAndAnswersCommand(String quizId, QuizBank quizBank)`. This obtains the quiz specified by searching through the `QuizBank#quizzes` for a quiz matching the quizId. Then, it calls `Quiz#getFormattedQuestions()` and `Quiz#getFormattedAnswers()` before formatting them for output.

*Step 3*. Then, a success message will be generated by the `QuizGetQuestionsAndAnswersCommand#generateSuccessMessage()` method and a new `CommandResult` will be returned with the generated success message.

==== Design Considerations

===== Aspect: Command Syntax
* ** Current Implementation: **
** To be done

* ** Alternatives Considered: **
** To be done

===== Aspect: Command Length

* ** Current Implementation: **
** To be done

* ** Alternatives Considered: **
** To be done

// tag::undoredo[]
////
=== [Proposed] Undo/Redo feature
Expand Down
20 changes: 20 additions & 0 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,26 @@ e.g. `/question open “Which year did Singapore gain independence?” “1965
. *MCQs* ​- `/question mcq “[topic]” “[answer]” “[option1]” “[option2]” “[option3]” “[option 4]”` +
e.g `​/question mcq “Which year did Singapore gain independence?” “1965” “1963” “2019” “1926” “1965”`

=== Quizzes ​-​ `/quiz`

Create and store quizzes using questions specified. Users are also able to edit the quizzes after creation.

. *Creating quizzes manually* ​- `/quiz manual/ quizID/[quizName] questionNumbers/[questionNumbers]` +
e.g. `/quiz manual/ quizID/CS2103T_Quiz questionNumbers/1 2 3`
This creates a quiz named "CS2103T_Quiz" and adds question numbers 1, 2 and 3 from the question bank to the quiz.
. *Creating quizzes automatically* ​- `/quiz auto/ quizID/[quizName] numQuestions/[numberOfQuestions] type/[typeOfQuestion]` +
e.g. `/quiz auto/ quizID/CS2103T_Quiz numQuestions/3 type/open`
This creates a quiz named "CS2103T_Quiz" and adds 3 questions from the question bank to the quiz, ensuring there are no duplicates.
. *Adding questions to quizzes* ​- `/quiz add quizID/[quizName] questionNumber/[questionNumber] quizQuestionNumber/[quizQuestionNumber]` +
e.g. `/quiz add quizID/CS2103T_Quiz questionNumber/1 quizQuestionNumber/3`
This adds the question number 1 from the question bank to the quiz "CS2103T_Quiz"'s question number 3, shifting questions previously at or after question 3, down by 1 question. I.e question 3 becomes question 4, question 4 becomes question 5 to accomodate for the added question.
. *Removing questions from quizzes* ​- `/quiz remove quizID/[quizName] quizQuestionNumber/[quizQuestionNumber]` +
e.g. `/quiz remove quizID/CS2103T_Quiz quizQuestionNumber/3`
This removes the question number 3 from the quiz "CS2103T_Quiz", shifting questions previously after question 3, up by 1 question. I.e question 4 becomes question 3, question 5 becomes question 4 to acoomodate for the removed question.
. *List all questions and answers in a readable format* ​- `/quiz list quizID/[quizName]` +
e.g. `/quiz list quizID/CS2103T_Quiz`
This fetches the quiz named "CS2103T_Quiz" and displays all the questions followed by answers of the quiz.

=== Help ​-​ `/help`

Show all available commands usable in the application.
Expand Down

0 comments on commit 998a11e

Please sign in to comment.