Project

General

Profile

« Previous | Next » 

Revision 4364

search within specific fields - with option for matching any vs. all

View differences:

lib/style/skins/first/search.js
272 272
    return tempQuery;
273 273
}
274 274

  
275
function generateSearchString(searchString, searchAssessments, searchAssessmentItems) {
275
/**
276
*	@param searchTerms - and object (hashtable) with, pay attention now:
277
	keys are search values
278
*   values are pathexprs
279
**/
280
function generateSearchString(searchTerms, operator, searchAssessments, searchAssessmentItems) {
276 281
	var queryString = 
277 282
		"<pathquery version=\"1.2\">"
278 283
			+"<querytitle>Web-Search</querytitle>";
......
315 320
			+"<returnfield>response_label/@ident</returnfield>"
316 321
			+"<returnfield>response_label/material/mattext</returnfield>";
317 322
	}		
318
                                                   
323
    
324
    queryString +=
325
    	"<querygroup operator=\"" + operator + "\">";
326
                         
327
    for (var i in searchTerms) {
328
    	var key = i;
329
    	var value = searchTerms[i];                        
330
		queryString +=
331
			"<queryterm searchmode=\"contains\" casesensitive=\"false\">";
332
			if (key != "anyValue") {
333
				queryString += "<pathexpr>" + key + "</pathexpr>";
334
			}	
335
	      	queryString += "<value>" + value + "</value>";
336
	    queryString +="</queryterm>";
337
    }
338
    
319 339
	queryString +=
320
                 "<querygroup operator=\"UNION\">"
321
                         +"<queryterm searchmode=\"contains\" casesensitive=\"false\">"
322
                                 +"<value>" + searchString + "</value>"
323
                         +"</queryterm>"
324
                 +"</querygroup>"
340
		"</querygroup>"
325 341
	+"</pathquery>";
326 342
	
327 343
	return queryString;
lib/style/skins/first/index.jsp
44 44
	src="<%=STYLE_COMMON_URL%>/prototype-1.5.1.1/prototype.js">
45 45
</script>	
46 46
<script language="Javascript">
47
        function trim(stringToTrim) {
48
                return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
49
        }
50 47

  
51
        function checkSearch(submitFormObj) {
52
			var searchString = trim(submitFormObj.searchstring.value);
48
		function browseAll() {
49
			document.getElementById("searchBox").value = "%";
50
			searchAssessments();
51
		}
52
		
53
		function searchAssessments() {
54
			var searchString = document.getElementById("searchBox").value;
55
			var institution = document.getElementById("institution").value;
56
			var instructor = document.getElementById("instructor").value;
57
			var course = document.getElementById("course").value;
58
			var year = document.getElementById("year").value;
59
			var searchTerms = new Object();
60
			searchTerms["anyValue"] = searchString;
61
			searchTerms["institution/organizationName"] = institution;
62
			searchTerms["instructor/individualName/surName"] = instructor;
63
			searchTerms["course/lom/general/title/string"] = course;
64
			searchTerms["course/year"] = year;
53 65
			
54
			if (searchString=="") {
55
				if (confirm("No search terms were entered.\nContinue with a wildcardsearch?")) {
56
					searchString = "%";
57
				} 
58
				else {
59
          			return false;
60
				}
66
			var operator = "UNION";
67
			if (document.getElementById("all").checked) {
68
				operator = "INTERSECT";
61 69
			}
62 70
			
63
			//generate the query
64
			var queryString = 
65
				generateSearchString(
66
					searchString, 
67
					true, 
68
					true);
69
				
70
			//set the form value	
71
    		submitFormObj.query.value = queryString;
72
    		
73
    		submitFormObj.qformat.value = "first";
74
    		
75
    		//alert(submitFormObj.query.value);	
76
			return true;
77
        }
78

  
79
		function browseAll(){
80
			var submitFormObj = document.getElementById("searchForm");
81
			
82
			if (checkSearch(submitFormObj)) {
83
				submitFormObj.submit();
84
			}
85
		}
86
		
87
		function searchAssessments(){
88
			var searchString = document.getElementById("searchBox").value;
89 71
			var metacatURL = "<%=CONTEXT_URL%>/metacat";
90 72
			
91 73
			//generate the query
92 74
			var queryString = 
93 75
				generateSearchString(
94
					searchString, 
76
					searchTerms,
77
					operator,
95 78
					true, 
96 79
					false);
97
					
80
			
81
			//alert("queryString=" + queryString);
82
			
98 83
			callAjax(metacatURL, queryString, "first-assessment");			
99 84
		}
100 85
   </script>
......
105 90
          insertSearchBox("<%=CONTEXT_URL%>");
106 91
      </script>
107 92

  
108
<table width="760" border="0" cellspacing="0" cellpadding="0">
93
<table width="760" border="0" cellspacing="20" cellpadding="0">
109 94
	<!--DWLayoutTable-->
110 95
	<tr>
111 96
		<td>
112
			<p class="intro">
113
				Welcome to the FIRST Assessment Repository. 
114
				The repository contains detailed information on assessment tools used
115
				[primarily] in biological and ecological science courses.
116
				Records herein adhere to a standard educational metadata specification 
117
				and enable educators to explore effective teaching models and techniques.
118
			</p>
119
			<p class="intro">	
120
				The aim is to associate outcome measures (i.e. student test scores) with the particular concepts
121
				on which the student is being tested and also associate the specific instructional techniques employed 
122
				when presenting that material to the student.
123
			</p>
124
				
125
			<p class="intro">
126
				The repository relies primarily on data collected from and submitted by
127
				professors and instructors.  While this system is still in active development,
128
				a quick search should reveal the depth, flexibility, and utility of the model. 
129
				And, of course, feedback is strongly encouraged and greatly appreciated.
130
			</p>
131
			<p class="intro">
132
				Information about the FIRST Project and it's activities is currently available through the 
133
				<a href="http://www.first2.org/">FIRST II</a> site.
134
				
135
			<p class="intro">
136
				If you have any questions, comments or problems,
137
				please contact the repository developer and administrator at
138
				<a	href="mailto:leinfelder@nceas.ucsb.edu">leinfelder@nceas.ucsb.edu</a>
139
			</p>
97
			<form method="POST" action="<%=SERVLET_URL%>" target="_top" id="searchForm">
140 98
			
141
			<br />
142 99
			<table class="tables" cellpadding="8" cellspacing="0">
143 100
				<tr class="sectheader">
144
					<td class="borderbottom" align="left">
145
						<p align="center">Search Assessments and Questions</p>
101
					<td class="borderbottom" align="left" colspan="2">
102
						<p align="center">Search Assessments</p>
146 103
					</td>
147
				</tr>	
104
				</tr>
148 105
				<tr>
149
					<td colspan="2" align="left">
150
						<form method="POST" action="<%=SERVLET_URL%>" target="_top"
151
							onSubmit="return checkSearch(this)" id="searchForm">
106
					<td align="left">
152 107
							
153
								<input name="query" type="hidden"> 
154
								<input name="qformat" value="first" type="hidden"> 
155
								<input type="hidden" name="action" value="squery"> 								
156
								
157
								<table>
158
									<tr>
159
										<td>Any field:</td>
160
										<td><input size="14" name="searchstring" type="text" value="" id="searchBox" onkeypress="searchAssessments()"></td>
161
									</tr>
162
									<tr>
163
										<td colspan="2"><hr/></td>
164
									</tr>
165
									<tr>
166
										<td>Institution: </td>
167
										<td><input name="institution" id="institution" type="text" size="14"/></td>
168
									</tr>
169
									<tr>
170
										<td>Course: </td>
171
										<td><input name="course" id="course" type="text" size="14"/></td>
172
									</tr>
173
									<tr>
174
										<td>Instructor: </td>
175
										<td><input name="instructor" id="instructor" type="text" size="14"/></td>
176
									</tr>
177
									<tr>
178
										<td>Year: </td>
179
										<td><input name="year" id="year" type="text" size="4"/></td>
180
									</tr>
181
									<tr>
182
										<td colspan="2"><hr/></td>
183
									</tr>
184
									<tr>
185
										<td colspan="1">
186
											<!--  <input type="button" onclick="javascript:searchAssessments()" value="Search"/> -->
187
											<input value="Search" type="submit">
188
										</td>
189
										<td>
190
										
191
										</td>
192
									</tr>		
193
								</table>
194
								
195
								
196
						</form>
108
						<input name="query" type="hidden"> 
109
						<input name="qformat" value="first" type="hidden"> 
110
						<input type="hidden" name="action" value="squery"> 								
197 111
						
198
						<div align="center">
199
							<p align="left">This tool allows you to search for Assessments and Questions.
200
							By default, the search will be conducted over all Assessment fields.
201
							These include (but are not limited to):
202
							course and assessment titles and descriptions, instructor name, and keyword fields. 
203
							Expanding the search to include Questions will include additional results for question matches
204
							(much like a question bank). 
205
							<br />
206
							<br />
207
							You can use the '%' character as a wildcard in your searches (e.g.,
208
							'%biology%' would locate any phrase with the word biology embedded within it).
209
							</p>
210
						</div>
112
						<table>
113
							<tr>
114
								<td>Any field:</td>
115
								<td><input size="14" name="searchstring" type="text" value="" id="searchBox"></td>
116
							</tr>
117
							<tr>
118
								<td colspan="2"><hr/></td>
119
							</tr>
120
							<tr>
121
								<td>Institution: </td>
122
								<td><input name="institution" id="institution" type="text" size="14"/></td>
123
							</tr>
124
							<tr>
125
								<td>Course: </td>
126
								<td><input name="course" id="course" type="text" size="14"/></td>
127
							</tr>
128
							<tr>
129
								<td>Instructor: </td>
130
								<td><input name="instructor" id="instructor" type="text" size="14"/></td>
131
							</tr>
132
							<tr>
133
								<td>Year: </td>
134
								<td><input name="year" id="year" type="text" size="4"/></td>
135
							</tr>
136
						</table>
211 137
					</td>
138
					<td valign="bottom">
139
						<table>	
140
							<tr>
141
								<td nowrap="nowrap">
142
									<input name="anyAll" id="any" value="UNION" type="radio" checked="checked"/>
143
								</td>
144
								<td nowrap="nowrap">Match any</td>
145
							</tr>
146
							<tr>		
147
								<td nowrap="nowrap">
148
									<input name="anyAll" id="all" value="INTERSECT" type="radio"/>
149
								</td>	
150
								<td nowrap="nowrap">Match all</td>
151
							</tr>
152
							<tr>
153
						</table>
154
					</td>
212 155
				</tr>
213
				<tr>
214
					<td class="borderbottom">
215
						<div align="center">
216
							<a href="javascript:browseAll()">
217
							Browse All FIRST items
218
							</a> 
219
							<br />
220
						</div>
156
				<tr class="sectheader">
157
					<td class="borderbottom" colspan="1">
158
						<!-- <input type="button" value="Browse all" onclick="browseAll()"/> -->
159
						(<a href="javascript:browseAll()">Browse All...</a>)
221 160
					</td>
161
					<td class="borderbottom" colspan="1">
162
						<input type="button" onclick="javascript:searchAssessments()" value="Search"/>
163
						<!--  <input value="Search" type="submit"> -->
164
					</td>
222 165
				</tr>
223 166
			</table>
224
			<div id="ajaxResults">Loading Search results...</div>
225
			<br />
226
			<br />
227
	
228
			<p class="intro">
229
			This repository is an effort of the <a href="http://www.nceas.ucsb.edu">National Center for Ecological
230
			Analysis and Synthesis (NCEAS)</a> and is based on software developed by
231
			the <a href="http://knb.ecoinformatics.org">Knowledge Network for
232
			Biocomplexity (KNB)</a>, and houses metadata that are compliant with 
233
			[the currently-under-development] Educational Metadata Language (EdML [name subject to change]).</p>
234

  
167
			</form>
168
			
235 169
		</td>
170
		<td colspan="1" valign="top">
171
			<div align="center">
172
				<p align="left">This tool allows you to search for Assessments either by keyword,
173
				or with a structured search that targets particular facets of an assessment.
174
				<br />
175
				<br />
176
				You can use the '%' character as a wildcard in your searches (e.g.,
177
				'%biology%' would locate any phrase with the word biology embedded within it).
178
				</p>
179
			</div>
180
		</td>
236 181
	</tr>
182
	<tr>
183
		<td valign="top" colspan="2">	
184
			<div id="ajaxResults">Search results...</div>
185
		</td>
186
	</tr>
237 187
</table>
238 188

  
239 189
<script language="JavaScript">          

Also available in: Unified diff