How do i Generate quiz from dropdown selection based on the subject choosen{
    'click  .quiz':  function (evt) {
    var Id = this._id;
    var subject = Questions.findOne({_id: Id});
    var selected_subject = subject.selected_subject;
    if(selected_subject == 'Mathematics') {
        Questions.find({selected_subject: 'Mathematics'});




         <div class="box-header with-border">
            <h3 class="box-title">Select Subject</h3><br><br>
            <select class="form-control select2" style="width: 100%;" id="selected_subject">
                <option selected="selected" >Physics</option>

my Database is as follows:

      "_id": "kAKbfLRHFZinrrRZv",
      "selected_subject": "English",
      "question": "what is the plural of Subject",
      "ans_A": "subjects",
      "ans_B": "book",
      "ans_C": "class",
     "ans_D": "courses",
    "correctAns": "subjects"


I’m a newbie to, but I’ll take a stab. As far as i can tell, you need to save the data from the user selection about the subject. Is that correct?

If so, it may be possible to:

  1. Save the user subject selection to a Session. Use Session.set(‘subjectSelection’, )
  2. Then, use Session.get to retrieve this information in the /quiz template.

I guess you will simply just use this to filter the publish of your database with a limit tag to get a subset of questions you can display. Just an idea. Thanks so much.


@tathagatbanerjee is correct. You need to do something with this data:

In fact, I’d suggest routing with the selected_subject as a route param:

Router.go('/quiz/' + selected_subject);

And then dealing with the data querying part once the quiz template is shown. E.g.

  questions: function () {
    var selected_subject = Router.current().params.selected_subject;
    return Questions.find({selected_subject: selected_subject});

To make this work, you’ll need to change your route definition to:

Router.route('/quiz/:selected_subject', function () {
  // Whatever else you do in the route definition

The good thing about doing it this way, is you can route directly to a particular quiz.