forked from Khan/perseus
-
Notifications
You must be signed in to change notification settings - Fork 34
/
testrender.html
178 lines (153 loc) · 5.15 KB
/
testrender.html
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Perseus render</title>
<link rel="stylesheet" type="text/css" href="/ke/css/khan-site.css" />
<link rel="stylesheet" type="text/css" href="/ke/css/khan-exercise.css" />
<link rel="stylesheet" type="text/css" href="/lib/katex/katex.css" />
<link rel="stylesheet" type="text/css" href="/lib/mathquill/mathquill.css" />
<link rel="stylesheet/less" type="text/css" href="/stylesheets/exercise-content-package/perseus.less" />
<script src="/lib/less.js"></script>
</head>
<body>
<div id="problem-and-answer" class="current-card framework-perseus vertical-shadow" style="width: 797px; margin: 20px;">
<div id="problemarea">
<div id="workarea"></div>
<div id="hintsarea"></div>
</div>
<div id="answer_area_wrap">
<div id="answer_area">
<form id="answerform">
<div id="anwsercontent" class="info-box">
<b>Answer</b> <br>
<div id="solutionarea"></div>
<div class="answer-buttons">
<input type="button" class="simple-button green" value="Check Answer" id="check-answer" />
<div id="positive-reinforcement" style="display: none;"><img src="/ke/images/face-smiley.png" /></div>
</div>
</div>
</form>
<div class="info-box">
<div class="answer-buttons">
<input type="button" class="simple-button orange" value="Hint" id="take-hint" />
</div>
</div>
</div>
</div>
<div style="clear: both;"></div>
</div>
<div id="extras" style="margin: 20px;">
<button id="score">Score</button>
<span id="scratchpadEnabled" style="margin-left: 15px;">
Scratchpad available
</span>
</div>
<script src="lib/babel-polyfills.min.js"></script>
<script src="/lib/es5-shim.js"></script>
<script src="/lib/jquery.js"></script>
<script src="/lib/underscore.js"></script>
<script src="/lib/react-with-addons.js"></script>
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full&delayStartupUntil=configured"></script>
<script src="/lib/katex/katex.js"></script>
<script src="/lib/mathquill/mathquill-basic.js"></script>
<script src="/lib/kas.js"></script>
<script>
var KhanUtil = {
debugLog: function() {}
};
var Khan = {
Util: KhanUtil,
error: function() {},
query: {debug: ""},
imageBase: "/ke/images/",
scratchpad: {
enable: function() {
Khan.scratchpad.enabled = true;
document.getElementById("scratchpadEnabled").innerText =
"Scratchpad available";
},
disable: function() {
Khan.scratchpad.enabled = false;
document.getElementById("scratchpadEnabled").innerText =
"Scratchpad not available";
},
enabled: true,
}
};
</script>
<script src="/ke/local-only/i18n.js"></script>
<script src="/ke/local-only/jquery.qtip.js"></script>
<script src="/ke/exercises-stub.js"></script>
<script src="ke/local-only/require.js"></script>
<script>
(function() {
// Load khan-exercises modules, then perseus
require(["ke-deps.js"], function() {
// pre built
// require(["build/perseus.js"], initPerseus);
// pre built with source maps
// require(["build/perseus.debug.js"], initPerseus);
// built on demand
require(["live-build/perseus.js"], initPerseus);
});
$('#score').on('click', function() {
console.log(window.itemRenderer.scoreInput());
});
function initPerseus(Perseus) {
window.Perseus = Perseus;
window.ReactDOM = React.__internalReactDOM;
var defaultQuestion = {
"question": {
"content": "",
"images": {},
"widgets": {}
},
"answerArea": {
"calculator": false
},
"itemDataVersion": {
"major": 0,
"minor": 1
},
"hints": []
};
$('#take-hint').on('click', function() {
window.itemRenderer.showHint();
});
$('#check-answer').on('click', function() {
var score = window.itemRenderer.scoreInput();
if (score.empty) {
return;
} else if (score.correct) {
$('#positive-reinforcement').show();
$('#check-answer').val('Correct!');
} else {
$('#check-answer').val('Incorrect, try again.');
}
});
var query = Perseus.Util.parseQueryString(window.location.hash.substring(1));
var question = query.content ? JSON.parse(query.content) : defaultQuestion;
Perseus.init({}).then(function() {
var itemMountNode = document.createElement("div");
var ItemRenderer = React.createFactory(Perseus.ItemRenderer);
window.itemRenderer = ReactDOM.render(ItemRenderer({
item: question,
problemNum: Math.floor(Math.random() * 50) + 1,
initialHintsVisible: 0,
enabledFeatures: {
highlight: true,
toolTipFormats: true
}
}, null), itemMountNode);
window.itemRenderer.focus();
}).then(function() {
console.log("all done.", +new Date/1000);
}, function(err) {
console.error(err);
});
}
})();
</script>
</body>
</html>