Project

General

Profile

1 3531 leinfelder
<?xml version="1.0"?>
2
<!--
3
*  '$RCSfile$'
4
*      Authors: Matt Jones, CHad Berkley
5
*    Copyright: 2000 Regents of the University of California and the
6
*               National Center for Ecological Analysis and Synthesis
7
*  For Details: http://www.nceas.ucsb.edu/
8
*
9
*   '$Author$'
10
*     '$Date$'
11
* '$Revision$'
12
*
13
* This program is free software; you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation; either version 2 of the License, or
16
* (at your option) any later version.
17
*
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
* GNU General Public License for more details.
22
*
23
* You should have received a copy of the GNU General Public License
24
* along with this program; if not, write to the Free Software
25
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
*
27
* This is an XSLT (http://www.w3.org/TR/xslt) stylesheet designed to
28
* convert an XML file showing the resultset of a query
29
* into an HTML format suitable for rendering with modern web browsers.
30
-->
31
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
32
33
	<xsl:output method="html"/>
34
	<xsl:param name="sessid"/>
35
	<xsl:param name="qformat">default</xsl:param>
36
	<xsl:param name="enableediting">false</xsl:param>
37 4289 leinfelder
	<xsl:param name="contextURL"/>
38 3531 leinfelder
	<xsl:template match="/">
39
		<script language="JavaScript">
40
          <![CDATA[
41 3542 leinfelder
          submitform = function(action,docid,form_ref) {
42 3531 leinfelder
              form_ref.action.value=action;
43 3542 leinfelder
              form_ref.docid.value=docid;
44 3531 leinfelder
              form_ref.sessionid.value="]]><xsl:value-of select="$sessid" /><![CDATA[";
45 4290 leinfelder
              form_ref.qformat.value="first";
46 4390 leinfelder
              form_ref.insertTemplate.value="1";
47 3531 leinfelder
              form_ref.submit();
48
          }
49 3542 leinfelder
          setSelect = function(form_ref, checkBoxName, checked) {
50
              var formElements = form_ref.elements;
51
              for (var i=0; i<formElements.length; i++) {
52
              	var myElement = formElements[i];
53
              	if (myElement.name == checkBoxName) {
54
              		myElement.checked = checked;
55
              	}
56
              }
57
          }
58 3531 leinfelder
          ]]>
59
        </script>
60 3542 leinfelder
        <script type="text/javascript" language="Javascript">
61
			<![CDATA[
62 4387 leinfelder
			downloadMergedResponseData = function(formId, fieldFormId) {
63 3551 leinfelder
64
				var submitFormObj = document.getElementById(formId);
65
				submitFormObj.qformat.value = 'csv';
66 4289 leinfelder
				submitFormObj.action.value = 'dataquery';
67 3551 leinfelder
68 4387 leinfelder
				//the form that holds the metadata field mappings - but in the header!
69
				var fieldFormObj =
70 4495 leinfelder
					getIframeDocument("iframeheaderclass").getElementById(fieldFormId);
71 4387 leinfelder
				//alert("fieldFormObj: " + fieldFormObj);
72 4289 leinfelder
73 4387 leinfelder
				multipleAssessmentSearch(submitFormObj, fieldFormObj);
74
75 3551 leinfelder
				submitFormObj.submit();
76
			}
77 4484 leinfelder
			editCart = function(formId, operation, docid) {
78 4361 leinfelder
79
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
80 4484 leinfelder
				//if (!areItemsSelected('docid') && docid) {
81
				//	alert("Please select at least one dataset");
82
				//	return false;
83
				//}
84 4361 leinfelder
85
				var submitFormObj = document.getElementById(formId);
86
				submitFormObj.qformat.value = 'first';
87
				submitFormObj.action.value = 'editcart';
88
				submitFormObj.operation.value = operation;
89 4484 leinfelder
				if (docid) {
90
					submitFormObj.docid.value = docid;
91
				}
92 4361 leinfelder
93
				var myUpdate = new Ajax.Request(
94
					metacatURL,
95
					{	method: 'post',
96
						parameters: Form.serialize(submitFormObj),
97 4379 leinfelder
						evalScripts: true,
98 4388 leinfelder
						onSuccess: function(transport) {
99
							//alert('Cart changes saved: ' + operation);
100 4390 leinfelder
							//if we are in the cart, we should refresh the entire page
101
							if (document.getElementById("ajaxCartResults")) {
102
								window.location.reload();
103
							}
104
							else {
105
								window.document.getElementById("iframeheaderclass").src=window.document.getElementById("iframeheaderclass").src;
106 4493 leinfelder
								//now check the cart contents and update those icons (but wait a second)
107
								setTimeout("setAllCartIcons()", 1000);
108 4390 leinfelder
							}
109
						},
110 4361 leinfelder
						onFailure: function(transport) {alert('failure making ajax call');}
111
					 });
112
113
			}
114 4379 leinfelder
			read = function(formId, docid, divId) {
115
116
				//alert("divId: " + divId);
117
118
				var metacatURL = "]]><xsl:value-of select="$contextURL" /><![CDATA[/metacat";
119
120
				var submitFormObj = document.getElementById(formId);
121
				submitFormObj.qformat.value = 'first';
122
				submitFormObj.action.value = 'read';
123
				submitFormObj.docid.value = docid;
124
				submitFormObj.insertTemplate.value = '0';
125
126
				var myUpdate = new Ajax.Updater(
127
					divId,
128
					metacatURL,
129
					{	method: 'post',
130
						parameters: Form.serialize(submitFormObj),
131
						evalScripts: true,
132
						onSuccess: function(transport) {showDiv(divId); },
133
						onFailure: function(transport) {alert('failure making ajax call');}
134
					 });
135
136
			}
137 3551 leinfelder
			areItemsSelected = function(checkBoxName) {
138
				var checkBoxes = document.getElementsByName(checkBoxName);
139
140
				for (var i=0; i< checkBoxes.length; i++) {
141
					if (checkBoxes[i].checked == true) {
142
						return true;
143
					}
144
				}
145
				//alert("please select a checkbox: " + checkBoxName);
146
				return false;
147
148
			}
149 4411 leinfelder
			setControlVisibility = function() {
150
				if (document.getElementById("ajaxCartResults")) {
151 4484 leinfelder
					new Effect.Appear("download");
152 4880 leinfelder
					new Effect.Appear("transposeDiv");
153 5065 leinfelder
					new Effect.Appear("metadataCountDiv");
154 4411 leinfelder
				}
155 4493 leinfelder
			}
156 4484 leinfelder
			isInCart = function(docid) {
157
158 4495 leinfelder
				//look up the cart in the header
159
				var doc = getIframeDocument("iframeheaderclass");
160 4494 leinfelder
				var objs = doc.getElementsByName("@packageId");
161
162 4484 leinfelder
				if (objs.length == 0) {
163
					return false;
164 4411 leinfelder
				}
165 4484 leinfelder
				for (var i=0; i< objs.length; i++) {
166
					if (docid == objs[i].value) {
167
						return true;
168
					}
169
				}
170
				return false;
171 4493 leinfelder
			}
172 3542 leinfelder
			hideDiv = function(divId) {
173 4493 leinfelder
				new Effect.Puff(divId);
174 4388 leinfelder
				//Element.hide(divId);
175 3542 leinfelder
			}
176 4379 leinfelder
			showDiv = function(divId) {
177 4390 leinfelder
				new Effect.Appear(divId)
178 4388 leinfelder
				//Element.show(divId);
179 4379 leinfelder
			}
180 4493 leinfelder
			setAllCartIcons = function() {
181
				var docids = document.getElementsByName('docid');
182
				for (var i=0; i< docids.length; i++) {
183
					var docid = docids[i].value;
184
					if (docid != "") {
185
						setCartIcon(docid);
186
					}
187
				}
188
			}
189
			setCartIcon = function(docid) {
190
				//show or hide the div
191
				//alert("setting icon for: " + docid);
192
				if (isInCart(docid)) {
193
					hideDiv("ajaxDiv" + docid + "add");
194
					showDiv("ajaxDiv" + docid + "remove");
195
				}
196
				else {
197
					hideDiv("ajaxDiv" + docid + "remove");
198
					showDiv("ajaxDiv" + docid + "add");
199
				}
200 4495 leinfelder
			}
201
202 3542 leinfelder
		 ]]>
203
		</script>
204 3531 leinfelder
205 4390 leinfelder
		<p class="emphasis">Assessments found: <xsl:number value="count(resultset/document)" /></p>
206 3531 leinfelder
207
		<!-- This tests to see if there are returned documents,
208
            if there are not then don't show the query results -->
209
210
		<xsl:if test="count(resultset/document) &gt; 0">
211 4411 leinfelder
			<script type="text/javascript" language="Javascript">
212
				<![CDATA[
213
					//call on load
214
					setControlVisibility();
215
				]]>
216
			</script>
217 4484 leinfelder
			<div id="download" style="display:none;">
218 4411 leinfelder
				<p>
219
					<a>
220
						<xsl:attribute name="href">javascript:{}</xsl:attribute>
221 4484 leinfelder
						<xsl:attribute name="onclick">javascript:downloadMergedResponseData('assessmentForm', 'fieldForm')</xsl:attribute>
222 4411 leinfelder
						<img border="none">
223
							<xsl:attribute name="src">
224
								<xsl:value-of select="$contextURL" />
225 4484 leinfelder
								<xsl:text>/style/images/page_white_put.png</xsl:text>
226 4411 leinfelder
							</xsl:attribute>
227
						</img>
228 4484 leinfelder
						<xsl:text> Download (.csv)</xsl:text>
229 4411 leinfelder
					</a>
230
				</p>
231
			</div>
232 4390 leinfelder
233 4361 leinfelder
			<!-- for reading the assessment details -->
234
			<form action="{$contextURL}/metacat" method="POST" id="readForm" name="readForm" >
235
				<input type="hidden" name="qformat" value="first" />
236
				<input type="hidden" name="sessionid">
237
					<xsl:attribute name="value">
238
						<xsl:value-of select="$sessid" />
239
					</xsl:attribute>
240
				</input>
241
				<input type="hidden" name="action" value="read" />
242
				<input type="hidden" name="docid" />
243 4379 leinfelder
				<input type="hidden" name="insertTemplate" value="1"/>
244 4361 leinfelder
			</form>
245
246 4484 leinfelder
			<!-- for editing cart -->
247
			<form action="{$contextURL}/metacat" method="POST" id="cartForm" name="cartForm" >
248
				<input type="hidden" name="qformat" value="first" />
249
				<input type="hidden" name="sessionid">
250
					<xsl:attribute name="value">
251
						<xsl:value-of select="$sessid" />
252
					</xsl:attribute>
253
				</input>
254
				<input type="hidden" name="action" value="editcart" />
255
				<input type="hidden" name="operation" />
256
				<input type="hidden" name="docid" />
257
258
			</form>
259
260
			<!-- for downloading data -->
261 4872 leinfelder
			<form action="{$contextURL}/style/skins/first/download.jsp" method="POST" id="assessmentForm" name="assessmentForm" >
262 3542 leinfelder
				<input type="hidden" name="qformat" value="first" />
263 4289 leinfelder
				<input type="hidden" name="sessionid">
264
					<xsl:attribute name="value">
265
						<xsl:value-of select="$sessid" />
266
					</xsl:attribute>
267
				</input>
268 3542 leinfelder
				<input type="hidden" name="action" value="read" />
269 4289 leinfelder
				<input type="hidden" name="dataquery" />
270 5065 leinfelder
				<div id="metadataCountDiv" style="display:none;">
271 5081 leinfelder
					--- Options ---
272
					<br />
273 5065 leinfelder
					<select name="metadataCount" id="metadataCount" width="2" >
274 5068 leinfelder
						<option>1</option>
275 5065 leinfelder
						<option>2</option>
276 5068 leinfelder
						<option>3</option>
277 5065 leinfelder
						<option>4</option>
278 5068 leinfelder
						<option>5</option>
279 5065 leinfelder
						<option>6</option>
280 5068 leinfelder
						<option>7</option>
281 5065 leinfelder
						<option>8</option>
282 5068 leinfelder
						<option>9</option>
283 5065 leinfelder
						<option>10</option>
284 5068 leinfelder
						<option>20</option>
285
						<option>30</option>
286
						<option>40</option>
287
						<option>50</option>
288 5065 leinfelder
					</select>
289
					item metadata fields included
290
				</div>
291 4880 leinfelder
				<div id="transposeDiv" style="display:none;">
292 5081 leinfelder
					<input type="checkbox" name="transpose" value="true" />Transpose Data, include:
293
					<br />
294
					<input type="hidden" id="pivotColumns" name="pivotColumns" value="studentid" />
295
					<input type="checkbox" id="pivotColumns" name="pivotColumns" value="score" checked="checked" />score
296
					<input type="checkbox" id="pivotColumns" name="pivotColumns" value="response" checked="checked" />response
297
					<input type="checkbox" id="pivotColumns" name="pivotColumns" value="responsefile" checked="checked" />response file
298 5065 leinfelder
				</div>
299 4859 leinfelder
				<input type="hidden" name="observation" value="3" />
300
				<input type="hidden" name="pivot" value="2" />
301 4361 leinfelder
				<input type="hidden" name="operation" />
302 4484 leinfelder
303 3669 leinfelder
				<xsl:element name="input">
304
					<xsl:attribute name="type">hidden</xsl:attribute>
305
					<xsl:attribute name="id">questionId</xsl:attribute>
306
					<xsl:attribute name="name">questionId</xsl:attribute>
307
					<xsl:attribute name="value"></xsl:attribute>
308
				</xsl:element>
309 3542 leinfelder
310 3531 leinfelder
			<table width="95%" align="left" border="0" cellpadding="0"
311
				cellspacing="0">
312
				<tr>
313 4484 leinfelder
314
					<th style="text-align: left" colspan="2">
315
						Assessment
316 4289 leinfelder
					</th>
317
					<th style="text-align: left">
318 3531 leinfelder
						Course Title
319
					</th>
320
					<th	style="text-align: left">
321
						Instructor[s]
322
					</th>
323
					<th	style="text-align: left">
324
						Organization[s]
325
					</th>
326
					<th	style="text-align: left">
327
						Keywords
328
					</th>
329
				</tr>
330
331
				<xsl:for-each select="resultset/document">
332 3918 leinfelder
					<xsl:sort select="./param[@name='assessment/@id']" />
333 3542 leinfelder
					<xsl:variable name="divId">
334
						<xsl:text>ajaxDiv</xsl:text><xsl:value-of select="./docid" />
335
					</xsl:variable>
336 3531 leinfelder
					<tr valign="top" class="subpanel">
337
						<xsl:attribute name="class">
338 3542 leinfelder
			               <xsl:choose>
339
			                 <xsl:when test="position() mod 2 = 1">rowodd</xsl:when>
340
			                 <xsl:when test="position() mod 2 = 0">roweven</xsl:when>
341
			               </xsl:choose>
342
			             </xsl:attribute>
343 3531 leinfelder
344 4484 leinfelder
						<td class="text_plain" nowrap="nowrap">
345
346 4650 leinfelder
						<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) = 0" >
347
							No Data
348
						</xsl:if>
349
						<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) >= 1" >
350
351 4484 leinfelder
							<script type="text/javascript" language="Javascript">
352
								<![CDATA[
353
									//what are our options?
354
									if (isInCart("]]><xsl:value-of select="./docid" /><![CDATA[")) {
355
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
356
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
357
									}
358
									else {
359
										showDiv("]]><xsl:value-of select="$divId" /><![CDATA[add");
360
										hideDiv("]]><xsl:value-of select="$divId" /><![CDATA[remove");
361
									}
362
								]]>
363
							</script>
364
							<div style="display:none;">
365
								<xsl:attribute name="id">
366
									<xsl:value-of select="$divId" />
367
									<xsl:text>add</xsl:text>
368
								</xsl:attribute>
369
								<a>
370
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
371
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'add',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
372
									<img border="none">
373
										<xsl:attribute name="src">
374
											<xsl:value-of select="$contextURL" />
375 4492 leinfelder
											<xsl:text>/style/skins/first/images/cart_plus_sm.png</xsl:text>
376 4484 leinfelder
										</xsl:attribute>
377
									</img>
378
								</a>
379
							</div>
380
							<div style="display:none;">
381
								<xsl:attribute name="id">
382
									<xsl:value-of select="$divId" />
383
									<xsl:text>remove</xsl:text>
384
								</xsl:attribute>
385
								<a>
386
									<xsl:attribute name="href">javascript:{}</xsl:attribute>
387
									<xsl:attribute name="onclick"><![CDATA[javascript:editCart('cartForm', 'remove',"]]><xsl:value-of select="./docid" /><![CDATA[")]]></xsl:attribute>
388
									<!--  <xsl:text>Remove </xsl:text> -->
389
									<img border="none">
390
										<xsl:attribute name="src">
391
											<xsl:value-of select="$contextURL" />
392 4492 leinfelder
											<xsl:text>/style/skins/first/images/cart_minus_sm.png</xsl:text>
393 4484 leinfelder
										</xsl:attribute>
394
									</img>
395
								</a>
396
							</div>
397
398
							<input type="hidden" name="docid">
399 4289 leinfelder
								<xsl:attribute name="value">
400
									<xsl:value-of select="./docid" />
401
								</xsl:attribute>
402
							</input>
403 4484 leinfelder
404 4650 leinfelder
							</xsl:if>
405
							<xsl:if test="count(./param[@name='dataset/dataTable/entityName']) >= 2" >
406
								<!-- demographic data is present -->
407
								<img border="none">
408
									<xsl:attribute name="src">
409
										<xsl:value-of select="$contextURL" />
410
										<xsl:text>/style/skins/first/images/user.gif</xsl:text>
411
									</xsl:attribute>
412
								</img>
413
							</xsl:if>
414
415 4289 leinfelder
						</td>
416
						<td>
417
418 3542 leinfelder
							<a>
419 4361 leinfelder
								<xsl:attribute name="href">javascript:submitform('read','<xsl:value-of select="./docid" />',document.readForm)</xsl:attribute>
420 3542 leinfelder
								<xsl:text>&#187;&#160;</xsl:text>
421 4636 leinfelder
								<xsl:value-of select="./param[@name='assessment/title']" />
422 3542 leinfelder
							</a>
423
							(<xsl:value-of select="./docid" />)
424 4289 leinfelder
425 3542 leinfelder
							<br />
426 4289 leinfelder
427
							<!--include question ids here -->
428
							<xsl:for-each select="./param[@name='assessmentItems/assessmentItem/assessmentItemId']" >
429
								<input type="hidden">
430
									<xsl:attribute name="name">
431
										<xsl:value-of select="../docid" />
432
									</xsl:attribute>
433
									<xsl:attribute name="value">
434
										<xsl:value-of select="." />
435
									</xsl:attribute>
436
								</input>
437
							</xsl:for-each>
438
439 4650 leinfelder
							<!-- demographic data - present or not? -->
440
							<input type="hidden">
441
								<xsl:attribute name="name">
442
									<xsl:value-of select="./docid" />
443
									<xsl:text>demographicData</xsl:text>
444
								</xsl:attribute>
445
								<xsl:attribute name="value">
446
									<xsl:choose>
447
										<xsl:when test="count(./param[@name='dataset/dataTable/entityName']) >= 2" >
448
											<xsl:text>true</xsl:text>
449
										</xsl:when>
450
										<xsl:otherwise>
451 4653 leinfelder
											<xsl:text></xsl:text>
452 4650 leinfelder
										</xsl:otherwise>
453
									</xsl:choose>
454
								</xsl:attribute>
455
							</input>
456
457 3542 leinfelder
							<br/>
458 4379 leinfelder
459 3531 leinfelder
						</td>
460
461
						<td class="text_plain">
462
							<xsl:for-each
463
								select="./param[@name='lom/general/title/string']">
464
								<xsl:value-of select="." />
465
								<br />
466
							</xsl:for-each>
467
						</td>
468
						<td class="text_plain">
469
							<xsl:for-each
470
								select="./param[@name='individualName/surName']">
471
								<xsl:value-of select="." />
472
								<br />
473
							</xsl:for-each>
474
						</td>
475
						<td class="text_plain">
476
							<xsl:for-each
477
								select="./param[@name='organizationName']">
478
								<xsl:value-of select="." />
479
								<br />
480
							</xsl:for-each>
481
						</td>
482
483
						<td class="text_plain">
484
							<xsl:for-each
485
								select="./param[@name='keyword']">
486
								<xsl:value-of select="." />
487
								<br />
488
							</xsl:for-each>
489
							<xsl:for-each
490
								select="./param[@name='lom/general/keyword/string']">
491
								<xsl:value-of select="." />
492
								<br />
493
							</xsl:for-each>
494
495
						</td>
496
497
					</tr>
498 4379 leinfelder
499
					<tr>
500 4484 leinfelder
						<td colspan="6">
501 4390 leinfelder
							Details
502 4379 leinfelder
							<a>
503 4388 leinfelder
								<xsl:attribute name="href">javascript:read('readForm', '<xsl:value-of select="./docid" />', '<xsl:value-of select="$divId" />')</xsl:attribute>
504 4390 leinfelder
								<img border="none">
505
									<xsl:attribute name="src">
506
										<xsl:value-of select="$contextURL" />
507
										<xsl:text>/style/images/next.gif</xsl:text>
508
									</xsl:attribute>
509
								</img>
510 4379 leinfelder
							</a>
511
							/
512
							<a>
513 4388 leinfelder
								<xsl:attribute name="href">javascript:hideDiv('<xsl:value-of select="$divId" />')</xsl:attribute>
514 4390 leinfelder
								<img border="none">
515
									<xsl:attribute name="src">
516
										<xsl:value-of select="$contextURL" />
517
										<xsl:text>/style/images/previous.gif</xsl:text>
518
									</xsl:attribute>
519
								</img>
520 4379 leinfelder
							</a>
521 4390 leinfelder
522 4388 leinfelder
						</td>
523
					</tr>
524
525
					<tr>
526 4484 leinfelder
						<td colspan="6">
527 4388 leinfelder
							<div style="display:none;">
528 4379 leinfelder
								<xsl:attribute name="id">
529
									<xsl:value-of select="$divId" />
530
								</xsl:attribute>
531
								Assessment details...
532
							</div>
533
						</td>
534
					</tr>
535
536 3531 leinfelder
					<tr class="searchresultsdivider">
537 4289 leinfelder
						<td colspan="6">
538 3531 leinfelder
							<img
539 4289 leinfelder
								src="{$contextURL}/style/skins/default/images/transparent1x1.gif"
540 3531 leinfelder
								width="1" height="1" />
541
						</td>
542
					</tr>
543
544
				</xsl:for-each>
545 3542 leinfelder
546 3531 leinfelder
			</table>
547 3542 leinfelder
548
			</form>
549 3531 leinfelder
550
		</xsl:if>
551
	</xsl:template>
552
553
</xsl:stylesheet>