Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/quiz module #142

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open

Conversation

zeala
Copy link

@zeala zeala commented Dec 20, 2015

Hi,

I've started implementing the Quiz functionality. It's far from ready, but maybe you can have a quick review to see if this is on the right track.

Thanks.

@brylie
Copy link
Member

brylie commented Dec 20, 2015

Just a quick look through the code brings up a few ideas. The quiz functionality might be implemented using Aldeed AutoForm / SimpleSchema.

The Quiz questions/question types would each be defined via a simple schema that would look something like this:

QuizSchema = new SimpleSchema({
    quizType: {
       type: String,
        allowedValues: ['multi-choice', 'freeform', ...]
        // Extend this list as new question types are added
    },
    multiChoice: {
        type: Object
        optional: true,
        customValidation: function () {
          // field is required only if quizType is set to 'multi-choice'
        }
    },
    "multiChoice.question" { // Question text to display to the user
        type: String
    }
    "multiChoice.choice": {
        type: [Object], // brackets here mean the question can have multiple choice
    },
    "multiChoice.choice.text": {
        type: String // Text to show user, i.e. answer text
    },
    "multiChoice.choice.isCorrectAnswer": {
        type: Boolean // It may be possible to have multiple correct answers
    }
});

This approach can help us to quickly have a form-based user interface for creating quizzes. The multi-choice approach can be made flexible to allow multiple correct answers, meaning the user has to select all correct answers for success.

This schema can be extended to include other question types.

@Rahbaran
Copy link
Member

i had a quick chat with @zeala . She's going to try to use autoform next week.

@brylie
Copy link
Member

brylie commented Dec 23, 2015

Great :-) I am available for pair-programming this week. @zeala, please let me know what day/time works, if you are interested in pair programming.

@brylie brylie added this to the 1.0 milestone Dec 23, 2015

QuizOptions = {};

QuizOptions.MULTIPLE_CHOICE_SINGLE_ANSWER = "Multiple Choice - single answer";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this can probably be done at the schema level.

@brylie
Copy link
Member

brylie commented Jan 11, 2016

Lets break this feature effort into multiple parts:

  • Defining collection, schema, and AutoForm for inputting the quiz data
  • Defining templates and helpers for displaying quizzes to end users and tracking their submissions
  • Defining logic to compare user submissions with correct answers

The code in this branch is really complicated, and could be greatly simplified by focusing on the collection, schema, and autoform for quiz definition.

@brylie
Copy link
Member

brylie commented Jan 11, 2016

Also, please refer to the initial schema suggestion (with some modification):

QuizQuestions = new Mongo.Collection("quizQuestions");
QuizQuestions.schema = new SimpleSchema({
    questionType: {
       type: String,
        allowedValues: ['multipleChoice', 'freeform', ...]
        // Extend this list as new question types are added
    },
    multiChoice: {
      type: Object
      optional: true,
      customValidation: function () {
         // field is required only if quizType is set to 'multipleChoice'
         // Get value of questionType field
         let questionType = this.field("questionType").value
        if (questionType === "multipleChoice") {
            return true; // field is required
        } else {
          return false; // field is not required
        }
       }
    },
    "multiChoice.question" { // Question text to display to the user
        type: String
    }
    "multiChoice.choice": {
        type: [Object], // brackets here mean the question can have multiple choice
    },
    "multiChoice.choice.text": {
        type: String // Text to show user, i.e. answer text
    },
    "multiChoice.choice.isCorrectAnswer": {
        type: Boolean // It may be possible to have multiple correct answers
    }
});

With this schema, we can define new question types easily. We can then use AutoForm afFieldValueIs to dynamically toggle the sub fields based on the quizType field value on the quiz input form:

<!-- Create new quiz form, add question section -->
{{# if afFieldValueIs name="questionType" value="multipleChoice" }}
  <!-- Show the multiple choice question field -->
  {{> afQuickField name="multipleChoice" }}
{{/ if }}

@brylie
Copy link
Member

brylie commented Jan 11, 2016

I think we can shrink this PR to closer to 500 lines of code, with re-design. The current state of the code can be preserved in this branch, if you simply create a new feature branch. E.g. feature/quiz-input-form-collection-and-schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants