Skip to content

Implementing a new Question type

Simon Soriano edited this page Oct 10, 2015 · 1 revision

There are two main parts: The question that extends from Quizer::Question and the question attempt that extends from Quizer::QuestionAttempt. Each one have a backend part and a frontend part.

I've created two commits were I (kind of) explain the implementation of Quizer::OpenQuestion

Question

https://github.com/makeitrealcamp/start/commit/91fd3f61031d1ae1745f9d96f787ab3cf0e55934

Description of the process of implementation of a new question type part 1:

- OpenQuestionForm: Form Object that validates que question and sanitizes the params
- OpenQuestion: The model. data_schema describes the structure of the question.
- Question: The new type was added to the method types
- _open_question_form: Form fields required to create an OpenQuestion. These fields are rendered inside quizer/question/_form
- spec/factories/quizer/questions: Factory

Question Attempt:

https://github.com/makeitrealcamp/start/commit/8fafd7c385b2940064688372adaab08918a2b7d4

Description of the process of implementation of a new question type part 2:

- question_attempts.coffe: Implement a View that autosaves open question attempt when answer text area changes
- OpenQuestionAttemptForm: Form object that validates an open question attempt
- QuestionAttempt: Adds OpenQuestionAttempt to types
- OpenQuestionAttempt:  The model that represents an open question attempt
-
- _open_question_attempt.html.erb: The form that is showed inside a quiz attempt
- _open_question_attempt_result.html.erb: The partial that is showed in the results page
- spec/factories/quizer/questions_attempts: Factory

TODO: Explain in detail the design of the Quizer module

Clone this wiki locally