Project

General

Profile

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
			+ "<union>";
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
				//control multiple metadata fields
344
				for (var q = 1; q <= questionMetadataCount; q++) {
345
					tempQuery +=
346
						"<attribute name=\"qMetadataVocabulary_" + q +"\">"
347 5064 leinfelder
							+ "<pathexpr label=\"qMetadataVocabulary\">//assessment/section/item/itemmetadata/qtimetadata/vocabulary</pathexpr>"
348 4876 leinfelder
						+ "</attribute>"
349 4890 leinfelder
						+ "<attribute name=\"qMetadataValue_" + q +"\">"
350 5064 leinfelder
							+ "<pathexpr label=\"qMetadataValue\">//assessment/section/item/itemmetadata/qtimetadata/qtimetadatafield/fieldentry</pathexpr>"
351 4890 leinfelder
						+ "</attribute>";
352
				}
353
				tempQuery +=
354
					"</entity>"
355 4288 leinfelder
				+ "</datapackage>";
356
			}
357
358
			tempQuery += "</selection>";
359 4281 leinfelder
360 4650 leinfelder
			//join to the question "table"
361 4288 leinfelder
			if (questionId.length > 0) {
362 4281 leinfelder
				tempQuery +=
363 4288 leinfelder
					"<where>"
364
						+ "<condition type=\"join\">"
365
							+ "<left>"
366
								+ "<datapackage id=\"" + docId + "\">"
367
									+ "<entity index=\"0\">"
368
										+ "<attribute index=\"1\"/>"
369
									+ "</entity>"
370
								+ "</datapackage>"
371
							+ "</left>"
372
							+ "<operator>=</operator>"
373
							+ "<right>"
374
								+ "<datapackage id=\"" + questionId + "\">"
375
									+ "<entity id=\"" + questionId + "\">"
376 4879 leinfelder
										+ "<attribute name=\"qId\">"
377 4288 leinfelder
											+ "<pathexpr label=\"qId\">//assessment/section/item/@ident</pathexpr>"
378
										+ "</attribute>"
379
									+ "</entity>"
380
								+ "</datapackage>"
381
							+ "</right>"
382
						+ "</condition>"
383
					+ "</where>";
384
			}
385
386
			tempQuery += "</query>";
387
388
		} // for questionId loop
389
390
391
	} //for docObjs loop
392 4281 leinfelder
393 4288 leinfelder
	tempQuery +=
394
		 "</union>"
395
		 + "</dataquery>";
396
397 4377 leinfelder
	//alert(tempQuery);
398 4288 leinfelder
399
    return tempQuery;
400 4290 leinfelder
}
401
402 4364 leinfelder
/**
403
*	@param searchTerms - and object (hashtable) with, pay attention now:
404
	keys are search values
405
*   values are pathexprs
406
**/
407 5058 leinfelder
function generateSearchString(
408
		searchTerms,
409
		assessmentItemIds,
410
		operator,
411
		searchAssessments,
412
		searchAssessmentItems) {
413 4290 leinfelder
	var queryString =
414
		"<pathquery version=\"1.2\">"
415
			+"<querytitle>Web-Search</querytitle>";
416
417
	/** assessments **/
418
	if (searchAssessments) {
419
420
		queryString +=
421
			"<returndoctype>edml://ecoinformatics.org/edml</returndoctype>"
422
423
			//assessment fields
424
               +"<returnfield>assessment/duration</returnfield>"
425 4636 leinfelder
               +"<returnfield>assessment/title</returnfield>"
426 4290 leinfelder
               +"<returnfield>assessment/@id</returnfield>"
427 4650 leinfelder
               +"<returnfield>dataset/dataTable/entityName</returnfield>"
428 4290 leinfelder
               +"<returnfield>lom/general/title/string</returnfield>"
429
               +"<returnfield>lom/general/keyword/string</returnfield>"
430
               +"<returnfield>individualName/surName</returnfield>"
431
               +"<returnfield>organizationName</returnfield>"
432
433
               +"<returnfield>assessmentItems/assessmentItem/assessmentItemId</returnfield>";
434
435
	}
436
437
	/** questions **/
438
	if (searchAssessmentItems) {
439
		queryString +=
440
			"<returndoctype>http://www.imsglobal.org/xsd/ims_qtiasiv1p2</returndoctype>"
441
442
			//question (qti) fields
443
			+"<returnfield>item/@title</returnfield>"
444
			+"<returnfield>item/@ident</returnfield>"
445
               +"<returnfield>qtimetadata/qtimetadatafield/fieldlabel</returnfield>"
446
               +"<returnfield>qtimetadata/qtimetadatafield/fieldentry</returnfield>"
447
			//classification
448
			+"<returnfield>fieldlabel</returnfield>"
449
			+"<returnfield>fieldentry</returnfield>"
450
			+"<returnfield>objectives/material/mattext</returnfield>"
451
			//question content
452 4796 leinfelder
			+"<returnfield>presentation/flow/response_lid/render_choice/material/mattext</returnfield>"
453 4290 leinfelder
			+"<returnfield>response_label/@ident</returnfield>"
454
			+"<returnfield>response_label/material/mattext</returnfield>";
455
	}
456 4364 leinfelder
457 5058 leinfelder
	// a query group for search terms
458
	var termQueryString = "";
459
    termQueryString +=
460
    	"<querygroup operator=\"" + operator + "\">";
461 4364 leinfelder
    for (var i in searchTerms) {
462
    	var key = i;
463 4562 leinfelder
    	var value = searchTerms[i];
464
    	//only if we have a value
465
    	if (value.length > 0) {
466 5058 leinfelder
    		termQueryString +=
467 4562 leinfelder
				"<queryterm searchmode=\"contains\" casesensitive=\"false\">";
468
				if (key != "anyValue") {
469 5058 leinfelder
					termQueryString += "<pathexpr>" + key + "</pathexpr>";
470 4562 leinfelder
				}
471 5058 leinfelder
				termQueryString += "<value>" + value + "</value>";
472
				termQueryString +="</queryterm>";
473 4562 leinfelder
		}
474 4364 leinfelder
    }
475 5058 leinfelder
    termQueryString += "</querygroup>";
476
477
	// querygroup for assessmentItemIds
478
	var itemQueryString = "";
479
	if (assessmentItemIds) {
480
		//the pathexpr
481
		var pathexpr = "assessmentItems/assessmentItem/assessmentItemId";
482
		// a query group for search terms
483
		itemQueryString +=
484
	    	"<querygroup operator=\"" + "UNION" + "\">";
485
	    for (var i in assessmentItemIds) {
486
	    	var itemId = assessmentItemIds[i];
487
	    	//only if we have a value
488
	    	if (itemId.length > 0) {
489
	    		itemQueryString +=
490
					"<queryterm searchmode=\"contains\" casesensitive=\"false\">";
491
					if (key != "anyValue") {
492
						itemQueryString += "<pathexpr>" + pathexpr + "</pathexpr>";
493
					}
494
					itemQueryString += "<value>" + itemId + "</value>";
495
					itemQueryString +="</queryterm>";
496
			}
497
	    }
498
	    itemQueryString += "</querygroup>";
499
	}
500
501
	//combine the various conditions
502 4290 leinfelder
	queryString +=
503 5058 leinfelder
    	"<querygroup operator=\"" + "UNION" + "\">";
504
	queryString += termQueryString;
505
	queryString += itemQueryString;
506
	queryString += "</querygroup>";
507 4290 leinfelder
508 5058 leinfelder
	//end the pathquery
509
	queryString += "</pathquery>";
510
511 4290 leinfelder
	return queryString;
512
513
}
514
515
516
function generateAssessmentSearchString(assessmentItemId) {
517
	var query =
518
		"<pathquery version='1.2'>"
519
		     +"<querytitle>Containing-Assessment-Search</querytitle>"
520
521
		     +"<returndoctype>edml://ecoinformatics.org/edml</returndoctype>"
522
523 5058 leinfelder
		     +"<returnfield>assessment/duration</returnfield>"
524
             +"<returnfield>assessment/title</returnfield>"
525
             +"<returnfield>assessment/@id</returnfield>"
526
             +"<returnfield>dataset/dataTable/entityName</returnfield>"
527
             +"<returnfield>lom/general/title/string</returnfield>"
528
             +"<returnfield>lom/general/keyword/string</returnfield>"
529
             +"<returnfield>individualName/surName</returnfield>"
530
             +"<returnfield>organizationName</returnfield>"
531 4290 leinfelder
532 5058 leinfelder
             +"<returnfield>assessmentItems/assessmentItem/assessmentItemId</returnfield>";
533 4290 leinfelder
534
		    if (assessmentItemId.length > 0) {
535
			    query += "<querygroup operator='UNION'>";
536
537
			    //add the assessmentId if included
538
			    query +=
539
			     		"<queryterm searchmode='contains' casesensitive='false'>"
540
			                  +"<value>"
541
			                  + assessmentItemId
542
			                  +"</value>"
543
			                  +"<pathexpr>assessmentItemId</pathexpr>"
544
			          +"</queryterm>";
545
546
			    //close the query group
547
			     query +=
548
			     "</querygroup>";
549
			}
550
551
		query += "</pathquery>";
552
553
	return query;
554
}
555
556 4363 leinfelder
function generateAssessmentListString(assessmentIds) {
557
	var query =
558
		"<pathquery version='1.2'>"
559
		     +"<querytitle>Assessment-List</querytitle>"
560
561
		     +"<returndoctype>edml://ecoinformatics.org/edml</returndoctype>"
562
563 4636 leinfelder
                      +"<returnfield>assessment/title</returnfield>"
564 4363 leinfelder
                      +"<returnfield>assessment/@id</returnfield>"
565
                      +"<returnfield>assessment/duration</returnfield>"
566 4650 leinfelder
           			  +"<returnfield>dataset/dataTable/entityName</returnfield>"
567 4363 leinfelder
                      +"<returnfield>lom/general/title/string</returnfield>"
568
                      +"<returnfield>lom/general/keyword/string</returnfield>"
569
                      +"<returnfield>individualName/surName</returnfield>"
570
                      +"<returnfield>organizationName</returnfield>"
571
572
                      +"<returnfield>assessmentItems/assessmentItem/assessmentItemId</returnfield>";
573
574
		    if (assessmentIds.length > 0) {
575
			    query += "<querygroup operator='UNION'>";
576
577
			    //add the assessmentId if included
578
			    for (var i=0; i < assessmentIds.length; i++) {
579
				    query +=
580
				     		"<queryterm searchmode='equals' casesensitive='false'>"
581
				                  +"<value>"
582
				                  + assessmentIds[i]
583
				                  +"</value>"
584
				                  +"<pathexpr>@packageId</pathexpr>"
585
				          +"</queryterm>";
586
				}
587
			    //close the query group
588
			     query +=
589
			     "</querygroup>";
590
			}
591
592
		query += "</pathquery>";
593
594
	return query;
595
}
596
597 5058 leinfelder
function callAjax(metacatURL, myQuery, qfmt, divId, callback) {
598 4290 leinfelder
599
	//alert("calling ajax: " + metacatURL);
600
	//alert("myQuery: " + myQuery);
601
602
	//var myRequest = new Ajax.Request(
603
	var myUpdate = new Ajax.Updater(
604 4377 leinfelder
		divId,
605 4290 leinfelder
		metacatURL,
606
		{	method: 'post',
607
			parameters: { action: 'squery', qformat: qfmt, query: myQuery},
608
			evalScripts: true,
609 5058 leinfelder
			onComplete: callback,
610 4290 leinfelder
			onFailure: function(transport) {alert('failure making ajax call');}
611
		 });
612
613
	 //alert("done calling ajax");
614 4495 leinfelder
}
615
function getIframeDocument(iframeId) {
616
	//look up the document
617
	var iframe = window.document.getElementById(iframeId);
618
	var doc = null;
619
	if (iframe.contentDocument) {
620
		doc = iframe.contentDocument;
621
	}
622
	else {
623
		doc = iframe.contentWindow.document;
624
	}
625
	return doc;
626
}