Skip to content

Commit 998a11e

Browse files
author
jeongyh99
authored
Merge pull request nus-cs2103-AY1920S1#80 from fabbbbbbyy/master
Update Developer Guide & User Guide
2 parents 4e43fb9 + 51878cb commit 998a11e

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

Diff for: docs/DeveloperGuide.adoc

+87
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,93 @@ will not be confused by the layout.
320320
However, this is not feasible as it will break the standard formatting of the answers display since both *Open Ended* and *MCQ*
321321
questions will have 2 different answer formats and may cause confusion to the user.
322322

323+
=== Quiz feature
324+
325+
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. +
326+
327+
The feature comprises of five commands namely,
328+
329+
* <<Feature-Quiz-Create-Manually, `QuizCreateManuallyCommand`>> - Creates a quiz with user input manually
330+
* <<Feature-Quiz-Create-Automatically, `QuizCreateAutomaticallyCommand`>> - Creates a quiz automatically
331+
* <<Feature-Quiz-Add-Question, `QuizAddQuestionCommand`>> - Adds a question to an existing quiz
332+
* <<Feature-Quiz-Remove-Question, `QuizRemoveQuestionCommand`>> - Removes a question from an existing quiz
333+
* <<Feature-Quiz-List, `QuizGetQuestionsAndAnswersCommand`>> - Listing questions and answers of an existing quiz
334+
335+
The commands when executed, will interface with the methods exposed by the `Model` interface to perform the related operations
336+
(See <<Design-Logic, logic component>> for the general overview).
337+
338+
[[Feature-Quiz-Create-Manually]]
339+
==== Create Manually command
340+
341+
The following is a detailed explanation of the operations `QuizCreateManuallyCommand` performs. +
342+
343+
*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.
344+
345+
*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.
346+
347+
*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.
348+
349+
[[Feature-Quiz-Create-Automatically]]
350+
==== Create Automatically command
351+
352+
The following is a detailed explanation of the operations `QuizCreateAutomaticallyCommand` performs. +
353+
354+
*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.
355+
356+
*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.
357+
358+
*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.
359+
360+
[[Feature-Quiz-Add-Question]]
361+
==== Add Question command
362+
363+
The following is a detailed explanation of the operations `QuizAddQuestionCommand` performs. +
364+
365+
*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.
366+
367+
*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.
368+
369+
*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.
370+
371+
[[Feature-Quiz-Remove-Question]]
372+
==== Remove Question command
373+
374+
The following is a detailed explanation of the operations `QuizRemoveQuestionCommand` performs. +
375+
376+
*Step 1*. The `QuizRemoveQuestionCommand#execute(Model model)` method is executed.
377+
378+
*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.
379+
380+
*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.
381+
382+
[[Feature-Quiz-List]]
383+
==== List command
384+
385+
The following is a detailed explanation of the operations `QuizGetQuestionsAndAnswersCommand` performs. +
386+
387+
*Step 1*. The `QuizGetQuestionsAndAnswersCommand#execute(Model model)` method is executed.
388+
389+
*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.
390+
391+
*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.
392+
393+
==== Design Considerations
394+
395+
===== Aspect: Command Syntax
396+
* ** Current Implementation: **
397+
** To be done
398+
399+
* ** Alternatives Considered: **
400+
** To be done
401+
402+
===== Aspect: Command Length
403+
404+
* ** Current Implementation: **
405+
** To be done
406+
407+
* ** Alternatives Considered: **
408+
** To be done
409+
323410
// tag::undoredo[]
324411
////
325412
=== [Proposed] Undo/Redo feature

Diff for: docs/UserGuide.adoc

+20
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@ e.g. `/question open “Which year did Singapore gain independence?” “1965
144144
. *MCQs* ​- `/question mcq “[topic]” “[answer]” “[option1]” “[option2]” “[option3]” “[option 4]”` +
145145
e.g `​/question mcq “Which year did Singapore gain independence?” “1965” “1963” “2019” “1926” “1965”`
146146

147+
=== Quizzes ​-​ `/quiz`
148+
149+
Create and store quizzes using questions specified. Users are also able to edit the quizzes after creation.
150+
151+
. *Creating quizzes manually* ​- `/quiz manual/ quizID/[quizName] questionNumbers/[questionNumbers]` +
152+
e.g. `/quiz manual/ quizID/CS2103T_Quiz questionNumbers/1 2 3`
153+
This creates a quiz named "CS2103T_Quiz" and adds question numbers 1, 2 and 3 from the question bank to the quiz.
154+
. *Creating quizzes automatically* ​- `/quiz auto/ quizID/[quizName] numQuestions/[numberOfQuestions] type/[typeOfQuestion]` +
155+
e.g. `/quiz auto/ quizID/CS2103T_Quiz numQuestions/3 type/open`
156+
This creates a quiz named "CS2103T_Quiz" and adds 3 questions from the question bank to the quiz, ensuring there are no duplicates.
157+
. *Adding questions to quizzes* ​- `/quiz add quizID/[quizName] questionNumber/[questionNumber] quizQuestionNumber/[quizQuestionNumber]` +
158+
e.g. `/quiz add quizID/CS2103T_Quiz questionNumber/1 quizQuestionNumber/3`
159+
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.
160+
. *Removing questions from quizzes* ​- `/quiz remove quizID/[quizName] quizQuestionNumber/[quizQuestionNumber]` +
161+
e.g. `/quiz remove quizID/CS2103T_Quiz quizQuestionNumber/3`
162+
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.
163+
. *List all questions and answers in a readable format* ​- `/quiz list quizID/[quizName]` +
164+
e.g. `/quiz list quizID/CS2103T_Quiz`
165+
This fetches the quiz named "CS2103T_Quiz" and displays all the questions followed by answers of the quiz.
166+
147167
=== Help ​-​ `/help`
148168

149169
Show all available commands usable in the application.

0 commit comments

Comments
 (0)