-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathquestions.js
91 lines (82 loc) · 2.07 KB
/
questions.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Questions = new Mongo.Collection('questions');
QuestionSchema = new SimpleSchema({
id: {
type: String,
optional: false,
unique: true
},
questionType: {
type:String,
optional: false
},
quizId: {
type:String,
optional: false
},
title: {
type:String,
optional: false
},
description : {
type:String,
optional: false
},
numberOfOptions: {
type: Number,
optional: true,
max: 10,
min: 2
},
optionTitles: {
label: "Options",
type: [Object],
optional: false,
autoform: {
type: "radio-with-text-input",
options: function(){
var optionsArray = [];
for ( var i=0; i < 8; i++){
var option = Quiz.generateAnswerOption("", false, i)
optionsArray.push(option);
}
return optionsArray;
}
},
custom: function() {
// This custom function renders an error, if this field is not equal to
// the new Password field supplied in the form.
var titlesValid = true;
var selectionFound = false;
for (var i = 0; i < this.value.length; i++){
var obj = this.value[i];
if (!obj.title){
titlesValid = false;
return "invalidQuestionTitles";
}
if (obj.isSelected){
selectionFound = true;
}
}
if (!selectionFound){
return "invalidQuestionSelection";
}
}
},
"optionTitles.$.title": {
type:String,
optional: false
},
"optionTitles.$.isSelected": {
type:Boolean,
optional: false
},
"optionTitles.$.index":{
type:Number,
optional: false
},
options:{
label: "Options",
type: [Object],
}
})
Questions.attachSchema(QuestionSchema);