Skip to content

Instantly share code, notes, and snippets.

@simonista
Last active December 28, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save simonista/7488107 to your computer and use it in GitHub Desktop.
Save simonista/7488107 to your computer and use it in GitHub Desktop.

How To Create A New Question Type (wip)

  • add a new file in app/models/quiz_question/ that extends QuizQuestion::Base (or another question type)
  • extend the appropriate scoring functions:
    • stats
    • total_answer_parts
    • correct_answer_parts
    • incorrect_answer_parts
    • requires_manual_scoring?
  • add the question type string to AssessmentQuestion::ALL_QUESTION_TYPES
  • add a new QuestionType struct to QuizzesHelper#answer_type
  • update AssessmentQuestion.parse_question
  • add an option + explanation to app/view/quizzes/_form_question.html.erb
  • look through quizzes.js and add support -- sorry :(
    • look at checkShowDetails
    • look in updateFormAnswer for how to support comments
    • setup question_type and answer_type in answerTypeDetails
    • add a result in answerSelectionType
    • add logic to updateFormQuestion
    • setup answers object in $(".add_answer_link").bind('click', ...)
    • look at $("#question_form_template").submit(...)
  • edit _single_answer.html.erb or _multiple_answer.html.erb depending on your answer type
    • you should key off of what you put in entry_type in QuizzesHelper#answer_type
  • edit _form_answer.html.erb if you need to add custom ui to the question building interface.
    • create a div with class as the answer_type you added to answerTypeDetails in quizzes.js
  • add copy/import/export support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment