1 |
4288
|
leinfelder
|
/****************************************************************************
|
2 |
|
|
* Multiple Assessment download
|
3 |
|
|
* @param form containing the neceassary input items
|
4 |
|
|
* @return true/false for form submission
|
5 |
|
|
*****************************************************************************/
|
6 |
4387
|
leinfelder
|
function multipleAssessmentSearch(submitFormObj, fieldFormObj) {
|
7 |
4377
|
leinfelder
|
|
8 |
|
|
//alert("submitFormObj=" + submitFormObj);
|
9 |
4288
|
leinfelder
|
//harvest the metadata fields we want to include
|
10 |
|
|
var metadataObjs = new Array();
|
11 |
|
|
var index = 0;
|
12 |
4387
|
leinfelder
|
for (var i=0; i < fieldFormObj.length; i++) {
|
13 |
|
|
var formElement = fieldFormObj.elements[i];
|
14 |
|
|
var metadataObj = new Object();
|
15 |
|
|
metadataObj.name = formElement.name;
|
16 |
|
|
metadataObj.value = formElement.value;
|
17 |
|
|
metadataObjs[index] = metadataObj;
|
18 |
|
|
index++;
|
19 |
4288
|
leinfelder
|
}
|
20 |
4267
|
leinfelder
|
|
21 |
4288
|
leinfelder
|
//TODO option for all questions vs. just one
|
22 |
4555
|
leinfelder
|
//var questionId = submitFormObj.questionId.value;
|
23 |
4288
|
leinfelder
|
//alert("questionId=" + questionId);
|
24 |
|
|
|
25 |
|
|
var documentObjects = new Array();
|
26 |
4290
|
leinfelder
|
var index = 0;
|
27 |
4377
|
leinfelder
|
if (submitFormObj.docid.length > 1) {
|
28 |
|
|
for (var i=0; i < submitFormObj.docid.length; i++) {
|
29 |
4484
|
leinfelder
|
if (submitFormObj.docid[i].value != "") {
|
30 |
4290
|
leinfelder
|
var documentObject = new Object();
|
31 |
4377
|
leinfelder
|
documentObject.docid = submitFormObj.docid[i].value;
|
32 |
4650
|
leinfelder
|
documentObject.demographicData = submitFormObj[documentObject.docid + "demographicData"].value;
|
33 |
4290
|
leinfelder
|
|
34 |
4555
|
leinfelder
|
var questionIds = new Array();
|
35 |
4290
|
leinfelder
|
for (var z = 0; z < submitFormObj[documentObject.docid].length; z++) {
|
36 |
|
|
questionIds[z] = submitFormObj[documentObject.docid][z].value;
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
documentObject.questionIds = questionIds;
|
40 |
|
|
documentObjects[index] = documentObject;
|
41 |
|
|
index++;
|
42 |
|
|
}
|
43 |
4288
|
leinfelder
|
}
|
44 |
|
|
}
|
45 |
|
|
else {
|
46 |
4377
|
leinfelder
|
//alert("submitFormObj.docid=" + submitFormObj.docid);
|
47 |
4484
|
leinfelder
|
if (submitFormObj.docid.value != "") {
|
48 |
4290
|
leinfelder
|
var documentObject = new Object();
|
49 |
4377
|
leinfelder
|
documentObject.docid = submitFormObj.docid.value;
|
50 |
4650
|
leinfelder
|
documentObject.demographicData = submitFormObj[documentObject.docid + "demographicData"].value;
|
51 |
|
|
|
52 |
4555
|
leinfelder
|
var questionIds = new Array();
|
53 |
4792
|
leinfelder
|
if (submitFormObj[documentObject.docid].length > 1) {
|
54 |
|
|
for (var z = 0; z < submitFormObj[documentObject.docid].length; z++) {
|
55 |
|
|
questionIds[z] = submitFormObj[documentObject.docid][z].value;
|
56 |
|
|
}
|
57 |
4290
|
leinfelder
|
}
|
58 |
4792
|
leinfelder
|
else {
|
59 |
|
|
questionIds[0] = submitFormObj[documentObject.docid].value;
|
60 |
|
|
}
|
61 |
4290
|
leinfelder
|
|
62 |
|
|
documentObject.questionIds = questionIds;
|
63 |
|
|
documentObjects[0] = documentObject;
|
64 |
4288
|
leinfelder
|
}
|
65 |
|
|
}
|
66 |
|
|
|
67 |
5065
|
leinfelder
|
var itemMetadataCount = submitFormObj.metadataCount.value;
|
68 |
|
|
|
69 |
|
|
var query = generateQuery(documentObjects, metadataObjs, itemMetadataCount);
|
70 |
|
|
|
71 |
4288
|
leinfelder
|
submitFormObj.dataquery.value = query;
|
72 |
|
|
|
73 |
|
|
return true;
|
74 |
|
|
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
/****************************************************************************
|
78 |
|
|
* Single Assessment download
|
79 |
|
|
* @param form containing the neceassary input items
|
80 |
|
|
* @return true/false for form submission
|
81 |
|
|
*****************************************************************************/
|
82 |
|
|
function assessmentSearch(submitFormObj) {
|
83 |
|
|
|
84 |
|
|
//harvest the metadata fields we want to include
|
85 |
|
|
var metadataObjs = new Array();
|
86 |
|
|
var index = 0;
|
87 |
|
|
for (var i=0; i < submitFormObj.length; i++) {
|
88 |
|
|
var formElement = submitFormObj.elements[i];
|
89 |
|
|
if (formElement.type == "checkbox" && formElement.checked) {
|
90 |
|
|
//ignore certain other checkboxes, kind of a hack
|
91 |
|
|
if (formElement.name == "includeQuestions") {
|
92 |
|
|
continue;
|
93 |
|
|
}
|
94 |
|
|
var metadataObj = new Object();
|
95 |
|
|
metadataObj.name = formElement.name;
|
96 |
|
|
metadataObj.value = formElement.value;
|
97 |
|
|
metadataObjs[index] = metadataObj;
|
98 |
|
|
index++;
|
99 |
|
|
}
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
//var checkBox = document.getElementById("searchAll");
|
103 |
4267
|
leinfelder
|
var docId = submitFormObj.docid.value;
|
104 |
4273
|
leinfelder
|
//alert("docId=" + docId);
|
105 |
4267
|
leinfelder
|
|
106 |
4281
|
leinfelder
|
//do we want question metadata?
|
107 |
4282
|
leinfelder
|
var includeQuestions = submitFormObj.includeQuestions.checked;
|
108 |
4281
|
leinfelder
|
var questionIds = new Array();
|
109 |
|
|
questionIds[0] = "";
|
110 |
|
|
|
111 |
|
|
if (includeQuestions) {
|
112 |
|
|
if (submitFormObj.assessmentItemId.length > 1) {
|
113 |
|
|
for (var i=0; i < submitFormObj.assessmentItemId.length; i++) {
|
114 |
|
|
questionIds[i] = submitFormObj.assessmentItemId[i].value;
|
115 |
|
|
}
|
116 |
|
|
}
|
117 |
|
|
else {
|
118 |
|
|
questionIds[0] = submitFormObj.assessmentItemId.value;
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
|
122 |
4288
|
leinfelder
|
//set up the list of objects to pass to the query assembler, just one document
|
123 |
|
|
var documentObjects = new Array();
|
124 |
|
|
var documentObject = new Object();
|
125 |
|
|
documentObject.docid = docId;
|
126 |
|
|
documentObject.questionIds = questionIds;
|
127 |
|
|
documentObjects[0] = documentObject;
|
128 |
4281
|
leinfelder
|
|
129 |
4288
|
leinfelder
|
var query = generateQuery(documentObjects, metadataObjs);
|
130 |
|
|
|
131 |
|
|
submitFormObj.dataquery.value = query;
|
132 |
|
|
|
133 |
|
|
return true;
|
134 |
|
|
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
/****************************************************************************
|
138 |
4387
|
leinfelder
|
* Save fields for the attribute maping
|
139 |
|
|
* @param formId containing the neceassary input items
|
140 |
|
|
* @return true/false for form submission
|
141 |
|
|
*****************************************************************************/
|
142 |
|
|
function saveFields(formId, metacatURL) {
|
143 |
|
|
|
144 |
|
|
var submitFormObj = document.getElementById(formId);
|
145 |
|
|
|
146 |
|
|
//send the request to clear
|
147 |
|
|
var myRequest = new Ajax.Request(
|
148 |
|
|
metacatURL,
|
149 |
|
|
{ method: 'post',
|
150 |
|
|
parameters: {
|
151 |
|
|
action: 'editcart',
|
152 |
|
|
operation: 'clearfields'},
|
153 |
|
|
evalScripts: true,
|
154 |
|
|
//onSuccess: function(transport) {alert('success: ' + transport.status);},
|
155 |
|
|
onFailure: function(transport) {alert('failure clearing fields');}
|
156 |
|
|
});
|
157 |
|
|
|
158 |
|
|
//go through the check boxes and set the ones we want
|
159 |
|
|
var count = 0;
|
160 |
|
|
for (var i=0; i < submitFormObj.length; i++) {
|
161 |
|
|
var formElement = submitFormObj.elements[i];
|
162 |
|
|
if (formElement.type == "checkbox" && formElement.checked) {
|
163 |
4411
|
leinfelder
|
//ignore certain other checkboxes, kind of a hack, but it's javascript...
|
164 |
4387
|
leinfelder
|
if (formElement.name == "includeQuestions") {
|
165 |
|
|
continue;
|
166 |
|
|
}
|
167 |
4411
|
leinfelder
|
if (formElement.name == "docid") {
|
168 |
|
|
continue;
|
169 |
|
|
}
|
170 |
4387
|
leinfelder
|
|
171 |
|
|
//send the request
|
172 |
|
|
var myRequest = new Ajax.Request(
|
173 |
|
|
metacatURL,
|
174 |
|
|
{ method: 'post',
|
175 |
|
|
parameters: {
|
176 |
|
|
action: 'editcart',
|
177 |
|
|
operation: 'addfield',
|
178 |
|
|
field: formElement.name,
|
179 |
|
|
path: formElement.value},
|
180 |
|
|
evalScripts: true,
|
181 |
4411
|
leinfelder
|
onSuccess: function(transport) {
|
182 |
|
|
//alert('Selections saved: ' + operation);
|
183 |
|
|
//refresh after the save
|
184 |
|
|
if (document.getElementById("ajaxCartResults")) {
|
185 |
|
|
window.location.reload();
|
186 |
|
|
}
|
187 |
|
|
else {
|
188 |
|
|
window.document.getElementById("iframeheaderclass").src=window.document.getElementById("iframeheaderclass").src;
|
189 |
|
|
}
|
190 |
|
|
},
|
191 |
4387
|
leinfelder
|
onFailure: function(transport) {alert('failure saving field: ' + formElement.name);}
|
192 |
|
|
});
|
193 |
|
|
count++;
|
194 |
|
|
}
|
195 |
|
|
}
|
196 |
|
|
|
197 |
4411
|
leinfelder
|
//window.document.getElementById("iframeheaderclass").src = window.document.getElementById("iframeheaderclass").src;
|
198 |
4387
|
leinfelder
|
|
199 |
4388
|
leinfelder
|
//alert(count + ' Field selections saved.');
|
200 |
4387
|
leinfelder
|
|
201 |
|
|
return true;
|
202 |
|
|
|
203 |
|
|
}
|
204 |
|
|
|
205 |
|
|
/****************************************************************************
|
206 |
4288
|
leinfelder
|
* Query Generation function
|
207 |
|
|
* @param docObjs is an Array of Objects with "docid" (String) and "questionIds" (Array) properties
|
208 |
|
|
* @param metadataObjs is an Array of Objects with "name" and "value" properties (both String)
|
209 |
|
|
* @return generated query string
|
210 |
|
|
*****************************************************************************/
|
211 |
5065
|
leinfelder
|
function generateQuery(docObjs, metadataObjs, itemMetadataCount) {
|
212 |
4288
|
leinfelder
|
//alert("calling method");
|
213 |
|
|
|
214 |
4890
|
leinfelder
|
//make parameters at some point
|
215 |
4887
|
leinfelder
|
var includeDemographicData = false;
|
216 |
4890
|
leinfelder
|
var questionMetadataCount = 2;
|
217 |
5065
|
leinfelder
|
if (itemMetadataCount) {
|
218 |
|
|
questionMetadataCount = itemMetadataCount;
|
219 |
|
|
}
|
220 |
4890
|
leinfelder
|
var questionChoiceCount = 5;
|
221 |
4887
|
leinfelder
|
|
222 |
4288
|
leinfelder
|
//construct the assessment metadata attribute selection snippet
|
223 |
4267
|
leinfelder
|
var metadataAttributes = "";
|
224 |
|
|
var index = 0;
|
225 |
4288
|
leinfelder
|
for (var j=0; j < metadataObjs.length; j++) {
|
226 |
|
|
var metadataObj = metadataObjs[j];
|
227 |
4267
|
leinfelder
|
|
228 |
4288
|
leinfelder
|
metadataAttributes += "<attribute index=\"";
|
229 |
|
|
metadataAttributes += index;
|
230 |
|
|
metadataAttributes += "\">";
|
231 |
|
|
|
232 |
|
|
metadataAttributes += "<pathexpr label=\"";
|
233 |
|
|
metadataAttributes += metadataObj.name;
|
234 |
|
|
metadataAttributes += "\">";
|
235 |
|
|
metadataAttributes += metadataObj.value;
|
236 |
|
|
metadataAttributes += "</pathexpr>";
|
237 |
|
|
|
238 |
|
|
metadataAttributes += "</attribute>";
|
239 |
|
|
|
240 |
|
|
index++;
|
241 |
|
|
}//metadataObjs loop
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
//construct the begining of the query
|
245 |
|
|
var tempQuery =
|
246 |
|
|
"<?xml version=\"1.0\"?>"
|
247 |
|
|
+ "<dataquery>"
|
248 |
5084
|
leinfelder
|
+ "<union order=\"true\">";
|
249 |
4267
|
leinfelder
|
|
250 |
4288
|
leinfelder
|
for (var i=0; i < docObjs.length; i++) {
|
251 |
|
|
|
252 |
|
|
var docId = docObjs[i].docid;
|
253 |
4650
|
leinfelder
|
var containsDemographicData = docObjs[i].demographicData;
|
254 |
|
|
//alert("containsDemographicData=" + containsDemographicData);
|
255 |
4288
|
leinfelder
|
|
256 |
|
|
//get the question ids for this question
|
257 |
|
|
var questionIds = docObjs[i].questionIds;
|
258 |
4267
|
leinfelder
|
|
259 |
4377
|
leinfelder
|
//alert("questionIds=" + questionIds);
|
260 |
4288
|
leinfelder
|
|
261 |
|
|
//assemble the assessment metadata
|
262 |
|
|
var metadataAttributeSelection = "";
|
263 |
|
|
if (metadataAttributes.length > 0) {
|
264 |
|
|
metadataAttributeSelection =
|
265 |
4267
|
leinfelder
|
"<datapackage id=\"" + docId + "\">"
|
266 |
|
|
+ "<entity id=\"" + docId + "\">"
|
267 |
|
|
+ metadataAttributes
|
268 |
|
|
+ "</entity>"
|
269 |
|
|
+ "</datapackage>";
|
270 |
4288
|
leinfelder
|
}
|
271 |
|
|
|
272 |
|
|
//loop for each question item
|
273 |
|
|
for (var k=0; k < questionIds.length; k++) {
|
274 |
|
|
var questionId = questionIds[k];
|
275 |
|
|
|
276 |
|
|
tempQuery +=
|
277 |
|
|
"<query>"
|
278 |
4650
|
leinfelder
|
+ "<selection>";
|
279 |
|
|
|
280 |
4288
|
leinfelder
|
//select the data
|
281 |
4650
|
leinfelder
|
tempQuery +=
|
282 |
|
|
"<datapackage id=\"" + docId + "\">"
|
283 |
4288
|
leinfelder
|
+ "<entity index=\"0\">"
|
284 |
|
|
+ "<attribute index=\"0\"/>"
|
285 |
|
|
+ "<attribute index=\"1\"/>"
|
286 |
4859
|
leinfelder
|
//DO NOT omit student id attribute - used for transpose
|
287 |
|
|
+ "<attribute index=\"2\"/>"
|
288 |
4288
|
leinfelder
|
+ "<attribute index=\"3\"/>"
|
289 |
|
|
+ "<attribute index=\"4\"/>"
|
290 |
5062
|
leinfelder
|
// the external response file
|
291 |
|
|
+ "<attribute index=\"6\"/>"
|
292 |
4288
|
leinfelder
|
+ "</entity>"
|
293 |
|
|
+ "</datapackage>";
|
294 |
|
|
|
295 |
4650
|
leinfelder
|
//select the demographic data
|
296 |
4887
|
leinfelder
|
if (includeDemographicData) {
|
297 |
|
|
if (containsDemographicData) {
|
298 |
|
|
tempQuery +=
|
299 |
|
|
"<datapackage id=\"" + docId + "\">"
|
300 |
|
|
+ "<entity index=\"1\">"
|
301 |
|
|
//omit student id attribute
|
302 |
|
|
+ "<attribute index=\"1\"/>"
|
303 |
|
|
+ "<attribute index=\"2\"/>"
|
304 |
|
|
+ "<attribute index=\"3\"/>"
|
305 |
|
|
+ "</entity>"
|
306 |
|
|
+ "</datapackage>";
|
307 |
|
|
}
|
308 |
|
|
else {
|
309 |
|
|
tempQuery +=
|
310 |
|
|
"<staticItem name=\"demographic_1\" value=\"\" />"
|
311 |
|
|
+ "<staticItem name=\"demographic_2\" value=\"\" />"
|
312 |
|
|
+ "<staticItem name=\"demographic_3\" value=\"\" />";
|
313 |
|
|
}
|
314 |
4650
|
leinfelder
|
}
|
315 |
|
|
|
316 |
4288
|
leinfelder
|
//select the metadata
|
317 |
|
|
tempQuery += metadataAttributeSelection;
|
318 |
4267
|
leinfelder
|
|
319 |
4288
|
leinfelder
|
//select the question metadata
|
320 |
|
|
if (questionId.length > 0) {
|
321 |
|
|
tempQuery +=
|
322 |
|
|
"<datapackage id=\"" + questionId + "\">"
|
323 |
|
|
+ "<entity id=\"" + questionId + "\">"
|
324 |
4879
|
leinfelder
|
+ "<attribute name=\"qId\">"
|
325 |
4288
|
leinfelder
|
+ "<pathexpr label=\"qId\">//assessment/section/item/@ident</pathexpr>"
|
326 |
|
|
+ "</attribute>"
|
327 |
4879
|
leinfelder
|
+ "<attribute name=\"qTitle\">"
|
328 |
4288
|
leinfelder
|
+ "<pathexpr label=\"qTitle\">//assessment/section/item/@title</pathexpr>"
|
329 |
|
|
+ "</attribute>"
|
330 |
4879
|
leinfelder
|
+ "<attribute name=\"qLabel\">"
|
331 |
4288
|
leinfelder
|
+ "<pathexpr label=\"qLabel\">//assessment/section/item/presentation/@label</pathexpr>"
|
332 |
|
|
+ "</attribute>"
|
333 |
4879
|
leinfelder
|
+ "<attribute name=\"qPrompt\">"
|
334 |
4998
|
leinfelder
|
+ "<pathexpr label=\"qPrompt\">(//assessment/section/item/presentation/flow/response_lid/render_choice/material/mattext)|(//assessment/section/item/presentation/flow/response_str/material/mattext)|(//assessment/section/item/presentation/flow/material/mattext)</pathexpr>"
|
335 |
4890
|
leinfelder
|
+ "</attribute>";
|
336 |
|
|
//control multiple choices
|
337 |
|
|
for (var p = 1; p <= questionChoiceCount; p++) {
|
338 |
|
|
tempQuery +=
|
339 |
|
|
"<attribute name=\"qChoice_" + p + "\">"
|
340 |
5019
|
leinfelder
|
+ "<pathexpr label=\"qChoice\">//assessment/section/item/presentation/flow/response_lid/render_choice/flow_label/response_label/material/mattext</pathexpr>"
|
341 |
4890
|
leinfelder
|
+ "</attribute>";
|
342 |
|
|
}
|
343 |
5083
|
leinfelder
|
//at least one metadata field
|
344 |
|
|
tempQuery +=
|
345 |
|
|
"<attribute name=\"qMetadataVocabulary\">"
|
346 |
|
|
+ "<pathexpr label=\"qMetadataVocabulary\">//assessment/section/item/itemmetadata/qtimetadata/vocabulary</pathexpr>"
|
347 |
|
|
+ "</attribute>"
|
348 |
|
|
+ "<attribute name=\"qMetadataValue\">"
|
349 |
|
|
+ "<pathexpr label=\"qMetadataValue\">//assessment/section/item/itemmetadata/qtimetadata/qtimetadatafield/fieldentry</pathexpr>"
|
350 |
|
|
+ "</attribute>";
|
351 |
4890
|
leinfelder
|
//control multiple metadata fields
|
352 |
5083
|
leinfelder
|
for (var q = 2; q <= questionMetadataCount; q++) {
|
353 |
4890
|
leinfelder
|
tempQuery +=
|
354 |
|
|
"<attribute name=\"qMetadataVocabulary_" + q +"\">"
|
355 |
5064
|
leinfelder
|
+ "<pathexpr label=\"qMetadataVocabulary\">//assessment/section/item/itemmetadata/qtimetadata/vocabulary</pathexpr>"
|
356 |
4876
|
leinfelder
|
+ "</attribute>"
|
357 |
4890
|
leinfelder
|
+ "<attribute name=\"qMetadataValue_" + q +"\">"
|
358 |
5064
|
leinfelder
|
+ "<pathexpr label=\"qMetadataValue\">//assessment/section/item/itemmetadata/qtimetadata/qtimetadatafield/fieldentry</pathexpr>"
|
359 |
4890
|
leinfelder
|
+ "</attribute>";
|
360 |
|
|
}
|
361 |
|
|
tempQuery +=
|
362 |
|
|
"</entity>"
|
363 |
4288
|
leinfelder
|
+ "</datapackage>";
|
364 |
|
|
}
|
365 |
|
|
|
366 |
|
|
tempQuery += "</selection>";
|
367 |
4281
|
leinfelder
|
|
368 |
4650
|
leinfelder
|
//join to the question "table"
|
369 |
4288
|
leinfelder
|
if (questionId.length > 0) {
|
370 |
4281
|
leinfelder
|
tempQuery +=
|
371 |
4288
|
leinfelder
|
"<where>"
|
372 |
|
|
+ "<condition type=\"join\">"
|
373 |
|
|
+ "<left>"
|
374 |
|
|
+ "<datapackage id=\"" + docId + "\">"
|
375 |
|
|
+ "<entity index=\"0\">"
|
376 |
|
|
+ "<attribute index=\"1\"/>"
|
377 |
|
|
+ "</entity>"
|
378 |
|
|
+ "</datapackage>"
|
379 |
|
|
+ "</left>"
|
380 |
|
|
+ "<operator>=</operator>"
|
381 |
|
|
+ "<right>"
|
382 |
|
|
+ "<datapackage id=\"" + questionId + "\">"
|
383 |
|
|
+ "<entity id=\"" + questionId + "\">"
|
384 |
4879
|
leinfelder
|
+ "<attribute name=\"qId\">"
|
385 |
4288
|
leinfelder
|
+ "<pathexpr label=\"qId\">//assessment/section/item/@ident</pathexpr>"
|
386 |
|
|
+ "</attribute>"
|
387 |
|
|
+ "</entity>"
|
388 |
|
|
+ "</datapackage>"
|
389 |
|
|
+ "</right>"
|
390 |
|
|
+ "</condition>"
|
391 |
|
|
+ "</where>";
|
392 |
|
|
}
|
393 |
|
|
|
394 |
|
|
tempQuery += "</query>";
|
395 |
|
|
|
396 |
|
|
} // for questionId loop
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
} //for docObjs loop
|
400 |
4281
|
leinfelder
|
|
401 |
4288
|
leinfelder
|
tempQuery +=
|
402 |
|
|
"</union>"
|
403 |
|
|
+ "</dataquery>";
|
404 |
|
|
|
405 |
4377
|
leinfelder
|
//alert(tempQuery);
|
406 |
4288
|
leinfelder
|
|
407 |
|
|
return tempQuery;
|
408 |
4290
|
leinfelder
|
}
|
409 |
|
|
|
410 |
4364
|
leinfelder
|
/**
|
411 |
|
|
* @param searchTerms - and object (hashtable) with, pay attention now:
|
412 |
|
|
keys are search values
|
413 |
|
|
* values are pathexprs
|
414 |
|
|
**/
|
415 |
5058
|
leinfelder
|
function generateSearchString(
|
416 |
|
|
searchTerms,
|
417 |
|
|
assessmentItemIds,
|
418 |
|
|
operator,
|
419 |
|
|
searchAssessments,
|
420 |
|
|
searchAssessmentItems) {
|
421 |
4290
|
leinfelder
|
var queryString =
|
422 |
|
|
"<pathquery version=\"1.2\">"
|
423 |
|
|
+"<querytitle>Web-Search</querytitle>";
|
424 |
|
|
|
425 |
|
|
/** assessments **/
|
426 |
|
|
if (searchAssessments) {
|
427 |
|
|
|
428 |
|
|
queryString +=
|
429 |
|
|
"<returndoctype>edml://ecoinformatics.org/edml</returndoctype>"
|
430 |
|
|
|
431 |
|
|
//assessment fields
|
432 |
|
|
+"<returnfield>assessment/duration</returnfield>"
|
433 |
4636
|
leinfelder
|
+"<returnfield>assessment/title</returnfield>"
|
434 |
4290
|
leinfelder
|
+"<returnfield>assessment/@id</returnfield>"
|
435 |
4650
|
leinfelder
|
+"<returnfield>dataset/dataTable/entityName</returnfield>"
|
436 |
4290
|
leinfelder
|
+"<returnfield>lom/general/title/string</returnfield>"
|
437 |
|
|
+"<returnfield>lom/general/keyword/string</returnfield>"
|
438 |
|
|
+"<returnfield>individualName/surName</returnfield>"
|
439 |
|
|
+"<returnfield>organizationName</returnfield>"
|
440 |
|
|
|
441 |
|
|
+"<returnfield>assessmentItems/assessmentItem/assessmentItemId</returnfield>";
|
442 |
|
|
|
443 |
|
|
}
|
444 |
|
|
|
445 |
|
|
/** questions **/
|
446 |
|
|
if (searchAssessmentItems) {
|
447 |
|
|
queryString +=
|
448 |
|
|
"<returndoctype>http://www.imsglobal.org/xsd/ims_qtiasiv1p2</returndoctype>"
|
449 |
|
|
|
450 |
|
|
//question (qti) fields
|
451 |
|
|
+"<returnfield>item/@title</returnfield>"
|
452 |
|
|
+"<returnfield>item/@ident</returnfield>"
|
453 |
|
|
+"<returnfield>qtimetadata/qtimetadatafield/fieldlabel</returnfield>"
|
454 |
|
|
+"<returnfield>qtimetadata/qtimetadatafield/fieldentry</returnfield>"
|
455 |
|
|
//classification
|
456 |
|
|
+"<returnfield>fieldlabel</returnfield>"
|
457 |
|
|
+"<returnfield>fieldentry</returnfield>"
|
458 |
|
|
+"<returnfield>objectives/material/mattext</returnfield>"
|
459 |
|
|
//question content
|
460 |
4796
|
leinfelder
|
+"<returnfield>presentation/flow/response_lid/render_choice/material/mattext</returnfield>"
|
461 |
4290
|
leinfelder
|
+"<returnfield>response_label/@ident</returnfield>"
|
462 |
|
|
+"<returnfield>response_label/material/mattext</returnfield>";
|
463 |
|
|
}
|
464 |
4364
|
leinfelder
|
|
465 |
5058
|
leinfelder
|
// a query group for search terms
|
466 |
|
|
var termQueryString = "";
|
467 |
|
|
termQueryString +=
|
468 |
|
|
"<querygroup operator=\"" + operator + "\">";
|
469 |
4364
|
leinfelder
|
for (var i in searchTerms) {
|
470 |
|
|
var key = i;
|
471 |
4562
|
leinfelder
|
var value = searchTerms[i];
|
472 |
|
|
//only if we have a value
|
473 |
|
|
if (value.length > 0) {
|
474 |
5058
|
leinfelder
|
termQueryString +=
|
475 |
4562
|
leinfelder
|
"<queryterm searchmode=\"contains\" casesensitive=\"false\">";
|
476 |
|
|
if (key != "anyValue") {
|
477 |
5058
|
leinfelder
|
termQueryString += "<pathexpr>" + key + "</pathexpr>";
|
478 |
4562
|
leinfelder
|
}
|
479 |
5058
|
leinfelder
|
termQueryString += "<value>" + value + "</value>";
|
480 |
|
|
termQueryString +="</queryterm>";
|
481 |
4562
|
leinfelder
|
}
|
482 |
4364
|
leinfelder
|
}
|
483 |
5058
|
leinfelder
|
termQueryString += "</querygroup>";
|
484 |
|
|
|
485 |
|
|
// querygroup for assessmentItemIds
|
486 |
|
|
var itemQueryString = "";
|
487 |
|
|
if (assessmentItemIds) {
|
488 |
|
|
//the pathexpr
|
489 |
|
|
var pathexpr = "assessmentItems/assessmentItem/assessmentItemId";
|
490 |
|
|
// a query group for search terms
|
491 |
|
|
itemQueryString +=
|
492 |
|
|
"<querygroup operator=\"" + "UNION" + "\">";
|
493 |
|
|
for (var i in assessmentItemIds) {
|
494 |
|
|
var itemId = assessmentItemIds[i];
|
495 |
|
|
//only if we have a value
|
496 |
|
|
if (itemId.length > 0) {
|
497 |
|
|
itemQueryString +=
|
498 |
|
|
"<queryterm searchmode=\"contains\" casesensitive=\"false\">";
|
499 |
|
|
if (key != "anyValue") {
|
500 |
|
|
itemQueryString += "<pathexpr>" + pathexpr + "</pathexpr>";
|
501 |
|
|
}
|
502 |
|
|
itemQueryString += "<value>" + itemId + "</value>";
|
503 |
|
|
itemQueryString +="</queryterm>";
|
504 |
|
|
}
|
505 |
|
|
}
|
506 |
|
|
itemQueryString += "</querygroup>";
|
507 |
|
|
}
|
508 |
|
|
|
509 |
|
|
//combine the various conditions
|
510 |
4290
|
leinfelder
|
queryString +=
|
511 |
5058
|
leinfelder
|
"<querygroup operator=\"" + "UNION" + "\">";
|
512 |
|
|
queryString += termQueryString;
|
513 |
|
|
queryString += itemQueryString;
|
514 |
|
|
queryString += "</querygroup>";
|
515 |
4290
|
leinfelder
|
|
516 |
5058
|
leinfelder
|
//end the pathquery
|
517 |
|
|
queryString += "</pathquery>";
|
518 |
|
|
|
519 |
4290
|
leinfelder
|
return queryString;
|
520 |
|
|
|
521 |
|
|
}
|
522 |
|
|
|
523 |
|
|
|
524 |
|
|
function generateAssessmentSearchString(assessmentItemId) {
|
525 |
|
|
var query =
|
526 |
|
|
"<pathquery version='1.2'>"
|
527 |
|
|
+"<querytitle>Containing-Assessment-Search</querytitle>"
|
528 |
|
|
|
529 |
|
|
+"<returndoctype>edml://ecoinformatics.org/edml</returndoctype>"
|
530 |
|
|
|
531 |
5058
|
leinfelder
|
+"<returnfield>assessment/duration</returnfield>"
|
532 |
|
|
+"<returnfield>assessment/title</returnfield>"
|
533 |
|
|
+"<returnfield>assessment/@id</returnfield>"
|
534 |
|
|
+"<returnfield>dataset/dataTable/entityName</returnfield>"
|
535 |
|
|
+"<returnfield>lom/general/title/string</returnfield>"
|
536 |
|
|
+"<returnfield>lom/general/keyword/string</returnfield>"
|
537 |
|
|
+"<returnfield>individualName/surName</returnfield>"
|
538 |
|
|
+"<returnfield>organizationName</returnfield>"
|
539 |
4290
|
leinfelder
|
|
540 |
5058
|
leinfelder
|
+"<returnfield>assessmentItems/assessmentItem/assessmentItemId</returnfield>";
|
541 |
4290
|
leinfelder
|
|
542 |
|
|
if (assessmentItemId.length > 0) {
|
543 |
|
|
query += "<querygroup operator='UNION'>";
|
544 |
|
|
|
545 |
|
|
//add the assessmentId if included
|
546 |
|
|
query +=
|
547 |
|
|
"<queryterm searchmode='contains' casesensitive='false'>"
|
548 |
|
|
+"<value>"
|
549 |
|
|
+ assessmentItemId
|
550 |
|
|
+"</value>"
|
551 |
|
|
+"<pathexpr>assessmentItemId</pathexpr>"
|
552 |
|
|
+"</queryterm>";
|
553 |
|
|
|
554 |
|
|
//close the query group
|
555 |
|
|
query +=
|
556 |
|
|
"</querygroup>";
|
557 |
|
|
}
|
558 |
|
|
|
559 |
|
|
query += "</pathquery>";
|
560 |
|
|
|
561 |
|
|
return query;
|
562 |
|
|
}
|
563 |
|
|
|
564 |
4363
|
leinfelder
|
function generateAssessmentListString(assessmentIds) {
|
565 |
|
|
var query =
|
566 |
|
|
"<pathquery version='1.2'>"
|
567 |
|
|
+"<querytitle>Assessment-List</querytitle>"
|
568 |
|
|
|
569 |
|
|
+"<returndoctype>edml://ecoinformatics.org/edml</returndoctype>"
|
570 |
|
|
|
571 |
4636
|
leinfelder
|
+"<returnfield>assessment/title</returnfield>"
|
572 |
4363
|
leinfelder
|
+"<returnfield>assessment/@id</returnfield>"
|
573 |
|
|
+"<returnfield>assessment/duration</returnfield>"
|
574 |
4650
|
leinfelder
|
+"<returnfield>dataset/dataTable/entityName</returnfield>"
|
575 |
4363
|
leinfelder
|
+"<returnfield>lom/general/title/string</returnfield>"
|
576 |
|
|
+"<returnfield>lom/general/keyword/string</returnfield>"
|
577 |
|
|
+"<returnfield>individualName/surName</returnfield>"
|
578 |
|
|
+"<returnfield>organizationName</returnfield>"
|
579 |
|
|
|
580 |
|
|
+"<returnfield>assessmentItems/assessmentItem/assessmentItemId</returnfield>";
|
581 |
|
|
|
582 |
|
|
if (assessmentIds.length > 0) {
|
583 |
|
|
query += "<querygroup operator='UNION'>";
|
584 |
|
|
|
585 |
|
|
//add the assessmentId if included
|
586 |
|
|
for (var i=0; i < assessmentIds.length; i++) {
|
587 |
|
|
query +=
|
588 |
|
|
"<queryterm searchmode='equals' casesensitive='false'>"
|
589 |
|
|
+"<value>"
|
590 |
|
|
+ assessmentIds[i]
|
591 |
|
|
+"</value>"
|
592 |
|
|
+"<pathexpr>@packageId</pathexpr>"
|
593 |
|
|
+"</queryterm>";
|
594 |
|
|
}
|
595 |
|
|
//close the query group
|
596 |
|
|
query +=
|
597 |
|
|
"</querygroup>";
|
598 |
|
|
}
|
599 |
|
|
|
600 |
|
|
query += "</pathquery>";
|
601 |
|
|
|
602 |
|
|
return query;
|
603 |
|
|
}
|
604 |
|
|
|
605 |
5058
|
leinfelder
|
function callAjax(metacatURL, myQuery, qfmt, divId, callback) {
|
606 |
4290
|
leinfelder
|
|
607 |
|
|
//alert("calling ajax: " + metacatURL);
|
608 |
|
|
//alert("myQuery: " + myQuery);
|
609 |
|
|
|
610 |
|
|
//var myRequest = new Ajax.Request(
|
611 |
|
|
var myUpdate = new Ajax.Updater(
|
612 |
4377
|
leinfelder
|
divId,
|
613 |
4290
|
leinfelder
|
metacatURL,
|
614 |
|
|
{ method: 'post',
|
615 |
|
|
parameters: { action: 'squery', qformat: qfmt, query: myQuery},
|
616 |
|
|
evalScripts: true,
|
617 |
5058
|
leinfelder
|
onComplete: callback,
|
618 |
4290
|
leinfelder
|
onFailure: function(transport) {alert('failure making ajax call');}
|
619 |
|
|
});
|
620 |
|
|
|
621 |
|
|
//alert("done calling ajax");
|
622 |
4495
|
leinfelder
|
}
|
623 |
|
|
function getIframeDocument(iframeId) {
|
624 |
|
|
//look up the document
|
625 |
|
|
var iframe = window.document.getElementById(iframeId);
|
626 |
|
|
var doc = null;
|
627 |
|
|
if (iframe.contentDocument) {
|
628 |
|
|
doc = iframe.contentDocument;
|
629 |
|
|
}
|
630 |
|
|
else {
|
631 |
|
|
doc = iframe.contentWindow.document;
|
632 |
|
|
}
|
633 |
|
|
return doc;
|
634 |
|
|
}
|