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
|
//problems in computing the area and perimeter of squares given a side
//problems in determining the length of a side given the area or the perimeter
var something = ['yard','field','parking lot','floor','lake','pasture'];
var units = ['mm2','cm2','dm2','m2','dam2','hm2','km2'];
var factor = [0,100,10000,1000000,100000000,1000000000,1000000000000]
var nunits = units.length;
function generate_decimal(min,max) {
n = Math.random()*(max-min)+min;
ntxt = n + ' ';
point = ntxt.indexOf('.');
whole = ntxt.substring(0,point-1)
decimal = ntxt.substring(point+1,point+4)
return whole + '.' + decimal;
};
function generate_operand(min,max) {
return Math.random()*(max-min) + min;
};
function shift(i1,i2,amount){
if(i2>i1){
f = factor[i2-i1];
return amount/f;
}else{
f = factor[i1-i2];
return amount*f;
}
};
function generate_opportunity(questions){
//build quiz.js
quiztxt = '';
for (q=0;q<questions;q++){
type = Math.random();
if(type < 0.3){
//determine area from side
side = parseInt(generate_operand(1,100));
area = side*side;
quiztxt = quiztxt+'{ ques: "The side of a square is '
quiztxt = quiztxt+side+" in length. What is it's area?"+'"';
quiztxt = quiztxt+", ans:'"+area+"'},\n"
}else if (type<0.6){
//determine perimeter from side
side = parseInt(generate_operand(1,100));
perimeter = 4*side;
quiztxt = quiztxt+'{ ques: "The side of a square is '
quiztxt = quiztxt+side+" in length. What is it's perimeter?"+'"';
quiztxt = quiztxt+", ans:'"+perimeter+"'},\n"
}else if (type<0.8){
//determine side from perimeter
side = parseInt(generate_operand(1,100));
perimeter = 4*side;
area = side*side;
quiztxt = quiztxt+'{ ques: "The perimeter of a square is '
quiztxt = quiztxt+perimeter+" in length. What is it's area?"+'"';
quiztxt = quiztxt+", ans:'"+area+"'},\n"
}else{
//determine perimeter from area
side = parseInt(generate_operand(1,100));
perimeter = 4*side;
area = side*side;
quiztxt = quiztxt+'{ ques: "The area of a square is '
quiztxt = quiztxt+area+" in size. What is it's perimeter?"+'"';
quiztxt = quiztxt+", ans:'"+perimeter+"'},\n"
};
};
return quiztxt;
};
function initialize(karma) {
quiztxt = generate_opportunity(12);
url = window.location+"";
$('<div id="txtMain" />')
.load('http://localhost:8008/cgi-bin/getFile.py',
{'filename':'content/Mathematics/map412m10/map412m10a15/a.txt'})
.appendTo('#content');
$('<div id="workArea" />')
.load('http://localhost:8008/cgi-bin/writeQuiz.py',
{'activity':url,'text': quiztxt});
};
function startGame(karma) {
$('<div id="quizArea" />')
.appendTo('#content')
.jQuizMe(quiz,options)
};
setUpLesson(initialize, startGame);
|