-
Notifications
You must be signed in to change notification settings - Fork 2
/
questionCont.js
31 lines (24 loc) · 890 Bytes
/
questionCont.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Questions = new Mongo.Collection("questions");
if(Meteor.isClient){
Session.setDefault('score', 0);
Template.body.helpers({
questions: function(){ return Questions.find({})},
score: function(){ return Session.get('score')}
});
Template.question.events({
'submit form':function(event, t){
event.preventDefault();
event.target[0].value = "";
Session.set('score', Session.get('score') + 1);
}
});
Questions.find({}).forEach(function(q){
//Meteor.users.update({_id:Meteor.user()._id},{$set:{"profile.ans":{"id":q.id, "answered": false}}});
});
}
var populateQuestions = function(){
Questions.insert({question: "How much foo do you bar?", id: 0});
Questions.insert({question: "How bar do you foo?", id: 1});
Questions.insert({question: "Do you like foobar?", id: 2});
Questions.insert({question: "Can you foobar?", id: 3});
}