-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
64 lines (54 loc) · 2.14 KB
/
index.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="../../tests/jme-runtime.js"></script>
<script src="../../tests/locales.js"></script>
<script src="lib/random_person.js"></script>
<style>
.log {
font-family: monospace;
}
.log.error {
color: red;
font-weight: bold;
}
</style>
</head>
<body>
<ul id="tests"></ul>
<script>
var tests_ul = document.getElementById('tests');
function show(name,value) {
tests_ul.innerHTML += `
<li>${name}: <code>${JSON.stringify(value)}</code></li>
`;
}
function desc(message) {
tests_ul.innerHTML += `<li><strong>${message}</strong></li>`;
}
Numbas.queueScript('base',[],function() {});
Numbas.queueScript('go',['jme','localisation','extensions/random_person/random_person.js'],function() {
Numbas.activateExtension('random_person');
var s = window.scope = new Numbas.jme.Scope([Numbas.jme.builtinScope,Numbas.extensions.random_person.scope]);
var ext = Numbas.extensions.random_person;
window.data = ext.data;
function run(expr) {
show('<code>'+expr+'</code>',Numbas.jme.unwrapValue(scope.evaluate(expr)));
}
run('random_person()');
run('random_person_with_gender("male")');
run('random_person_with_gender("female")');
run('random_person_with_initial("A")');
run('map(x["name"],x,random_people(5))');
run('map(x["name"],x,random_people_with_different_initials(5))');
desc("Using the French dataset");
ext.data = ext.datasets.fr;
run('map(x["name"],x,random_people(15))');
desc("Using the USA dataset");
ext.data = ext.datasets.us;
run('map(x["name"],x,random_people(15))');
});
</script>
</body>
</html>