-
Notifications
You must be signed in to change notification settings - Fork 5
/
sets.html
200 lines (182 loc) · 7.5 KB
/
sets.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<!--
# This file is stored in review/sets.html in the Andes git repository.
# Although the Andes problem chooser tool will work without any Andes
# installation, you will need an Andes installation to generate associated
# files and a working Andes help server to point to.
#
# Create a directory "sets" for the Andes problem chooser tool:
mkdir sets; cd sets
mkdir problems
# Copy images/*.* from the Andes installation into sets/problems.
# Copy review/sets.html from the Andes installation to sets/index.html.
# Then, modfy the URL in the button handler function to point to
# the desired Andes help server.
#
# In the Andes installation, start up lisp and enter (rhelp) to
# load the help system. Then use the commands
# (sets-json-file)
# (principles-json-file :file "principles.json" :sets t)
# to generate the files sets.json, & principles.json and place
# them in "sets." Likewise, generate a list of problem files using
# (problem-html-files)
# and place them in the directory sets/problems.
#
# Depending on the location of "sets," you may want to create
# a link to "sets" in your web server root directory (eg. /var/www/html).
-->
<title>Andes problem chooser</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.12.1/dijit/themes/tundra/tundra.css" media="screen">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.12.1/dojo/resources/dojo.css">
<style type="text/css">
div#graphic {
overflow: hidden;
}
div.tall {
border-style: solid;
border-color: #ddd;
overflow: auto; height: 60ex;
}
th {
font-weight: bold;
}
.prob {
font-family: Courier,"Courier New";
font-size: 115%;
}
</style>
<script type="text/javascript">
djConfig = {
isDebug: false,
async: true,
parseOnLoad: true
};
if(djConfig.isDebug){
document.write('<scr'+'ipt src="/web-UI/dojo/dojo.js"></scr'+'ipt>');
}else{
document.write('<scr'+'ipt src="//ajax.googleapis.com/ajax/libs/dojo/1.12.1/dojo/dojo.js"></scr'+'ipt>');
}
</script>
<script type="text/javascript">
require(["dojo/dom", "dojo/data/ItemFileReadStore", "dijit/registry", "dijit/Tree", "dijit/tree/ForestStoreModel", "dojo/parser", "dijit/layout/ContentPane"],
function(dom, ItemFileReadStore, registry, Tree, ForestStoreModel) {
var setStore = new ItemFileReadStore({
url: "sets.json"
});
var setModel = new ForestStoreModel({
store: setStore,
labelType: "html",
childrenAttrs: ["items"]
});
var setsTree = new Tree({
model: setModel,
class: "tall",
showRoot: false,
onClick: function(item) {
addProblem(item, setStore);
}
}, "setsTree");
var principlesStore = new ItemFileReadStore({
url: "principles.json"
});
var principlesModel = new ForestStoreModel({
store: principlesStore,
labelType: "html",
childrenAttrs: ["items"]
});
var principlessTree = new Tree({
model: principlesModel,
showRoot: false,
class: "tall",
onClick: function(item) {
addProblem(item, principlesStore);
}
}, "principlesTree");
// add problem statement and any graphic to third column.
function addProblem(item, store) {
if(store.hasAttribute(item,"expand")) {
window.thisProblem=store.getValue(item,"expand");
dom.byId("try").disabled=false;
// console.log("from json: "+store.getValue(item,"expand"));
registry.byId('prob').set('href',"problems/"+store.getValue(item,"expand")+".html");
var label=store.getValue(item,"label");
if(store.hasAttribute(item,"set")) {
label = store.getValue(item,"set") + " " + label;
}
registry.byId('label').set('content',label);
if(store.hasAttribute(item,"graphic")) {
// console.log("from json: "+store.getValue(item,"graphic"));
// console.log(" "+"<img src=\"problems/"+store.getValue(item,"graphic")+"\">");
registry.byId('graphic').set('content',"<img src=\"problems/"+store.getValue(item,"graphic")+"\">");
} else {
// console.log("no graphic");
registry.byId('graphic').set('content',null);
}
}
};
});
</script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
var button = document.getElementById("try");
// Firefox remembers disbled status
button.disabled=true;
// From http://stackoverflow.com/questions/901115
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
button.addEventListener("click", function(){
var u = document.getElementById("user").value;
var s = getParameterByName("s") || "andestutor.org";
var x = getParameterByName("x") || "web-UI";
if(!u.replace(/\s+$/, '')){
alert("Please enter a user name.");
return;
}
if(!window.thisProblem){
alert("Please select a problem to try");
return;
}
var host = ""; // You may want to specify a remote host here.
document.location.href = host + "/" + x + "/index.html?s="+s+"&u="+u+"&p="+window.thisProblem+"&e=";
});
});
</script>
</head>
<body class="tundra">
<h1>Andes problem chooser tool</h1>
<p>The left menu shows a list of all the homework sets,
while the right menu shows a nested list of the principles of
physics.
For each principle, a list of problems
whose solution involves that principle is shown.
For each problem, median solution time and median score is given.
Times and scores are from US Naval Academy students from Fall 2005
to spring 2008.
</p>
<p>If this is your first time using Andes, please start with
<span class="prob">vec1ay</span>, the first problem in Vectors.</p>
<table>
<tr><th>Homework Sets</th><th>List of principles</th>
<th><div data-dojo-type="dijit.layout.ContentPane" id="label"></div></th></tr>
<tr><td style="vertical-align:top;">
<!-- Since this is a widget, specify class in a funky way -->
<div id="setsTree"></div>
</td><td style="vertical-align:top;">
<div id="principlesTree"></div>
</td><td style="vertical-align:top;"> <div data-dojo-type="dijit.layout.ContentPane"
id="prob" data-dojo-props="extractContent:true">Select a problem from the list.</div>
<div data-dojo-type="dijit.layout.ContentPane" id="graphic"></div>
<div><label>user name:</label>
<input type="text" id="user" size="6"/>
<button id="try" disabled>
Try it</button>
</div>
</td></tr>
</table>
</body>
</html>