@@ -8,43 +8,48 @@ define(["underscore", "QServer", "PrairieRandom"], function(_, QServer, PrairieR
8
8
9
9
MTFServer . prototype . getData = function ( vid , options ) {
10
10
var rand = new PrairieRandom . RandomGenerator ( vid ) ;
11
+
12
+ // Set some default values first.
13
+ // Missing values should be caught by the schemas.
11
14
options = _ . defaults ( options , {
12
- text : "Question text not defined." ,
13
- correctAnswers : [ "Correct answers not defined." ] ,
14
- incorrectAnswers : [ "Incorrect answers not defined." ] ,
15
- numberAnswers : 5 ,
15
+ trueStatements : [ ] ,
16
+ falseStatements : [ ]
16
17
} ) ;
17
18
18
- var numberCorrect = 1 ;
19
- var numberIncorrect = options . numberAnswers - numberCorrect ;
20
- numberIncorrect = Math . min ( numberIncorrect , options . incorrectAnswers . length ) ;
19
+ var numberTrue = options . trueStatements . length ;
20
+ var numberFalse = options . falseStatements . length ;
21
+
22
+ // TODO(tnip): This is kinda weird. We should be checking for
23
+ // definedness on the full set. If empty, throw an error.
24
+ //
25
+ // Here, we want a list of all the statements so we can list them all.
26
+ var allStatements = [ ] ;
27
+ allStatements = allStatements . concat ( options . trueStatements ) ;
28
+ allStatements = allStatements . concat ( options . falseStatements ) ;
21
29
22
- var answers = [ ] ;
23
- answers = answers . concat ( rand . randNElem ( numberCorrect , options . correctAnswers ) ) ;
24
- answers = answers . concat ( rand . randNElem ( numberIncorrect , options . incorrectAnswers ) ) ;
25
- var perm = rand . shuffle ( answers ) ;
26
- answers = _ ( answers ) . map ( function ( value , index ) {
27
- return { key : String . fromCharCode ( 'a' . charCodeAt ( ) + index ) , text : value } ;
30
+ allStatements = _ ( allStatements ) . map ( function ( value , index ) {
31
+ return { key : 'q' + index . toString ( ) , statement : value } ;
28
32
} ) ;
33
+
34
+ console . log ( allStatements ) ;
35
+
29
36
var params = {
30
- text : options . text ,
31
- answers : answers ,
32
- } ;
33
- var trueIndex = _ ( perm ) . indexOf ( 0 ) ;
34
- var trueAnswer = {
35
- key : answers [ trueIndex ] . key ,
36
- text : answers [ trueIndex ] . text ,
37
+ statements : allStatements
37
38
} ;
39
+
38
40
var questionData = {
39
41
params : params ,
40
- trueAnswer : trueAnswer ,
42
+ trueAnswer : { }
41
43
} ;
44
+
42
45
return questionData ;
43
46
}
44
47
48
+ /*
45
49
MTFServer.prototype.transformTrueAnswer = function(vid, params, trueAns) {
46
50
return {key: trueAns.key};
47
51
}
52
+ */
48
53
49
54
return MTFServer ;
50
55
} ) ;
0 commit comments