1 |
4267
|
leinfelder
|
function checkSearch(submitFormObj) {
|
2 |
|
|
//alert("calling method");
|
3 |
|
|
|
4 |
|
|
//var checkBox = document.getElementById("searchAll");
|
5 |
|
|
var docId = submitFormObj.docid.value;
|
6 |
4273
|
leinfelder
|
//alert("docId=" + docId);
|
7 |
4267
|
leinfelder
|
|
8 |
4281
|
leinfelder
|
//do we want question metadata?
|
9 |
4282
|
leinfelder
|
var includeQuestions = submitFormObj.includeQuestions.checked;
|
10 |
4281
|
leinfelder
|
var questionIds = new Array();
|
11 |
|
|
questionIds[0] = "";
|
12 |
|
|
|
13 |
|
|
if (includeQuestions) {
|
14 |
|
|
if (submitFormObj.assessmentItemId.length > 1) {
|
15 |
|
|
for (var i=0; i < submitFormObj.assessmentItemId.length; i++) {
|
16 |
|
|
questionIds[i] = submitFormObj.assessmentItemId[i].value;
|
17 |
|
|
}
|
18 |
|
|
}
|
19 |
|
|
else {
|
20 |
|
|
questionIds[0] = submitFormObj.assessmentItemId.value;
|
21 |
|
|
}
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
//alert("questionIds=" + questionIds);
|
25 |
|
|
|
26 |
|
|
//construct the assessment metadata query
|
27 |
4267
|
leinfelder
|
var metadataAttributes = "";
|
28 |
|
|
var index = 0;
|
29 |
|
|
for (var i=0; i < submitFormObj.length; i++) {
|
30 |
|
|
var formElement = submitFormObj.elements[i];
|
31 |
4273
|
leinfelder
|
if (formElement.type == "checkbox" && formElement.checked) {
|
32 |
4282
|
leinfelder
|
//ignore certain other checkboxes, kind of a hack
|
33 |
|
|
if (formElement.name == "includeQuestions") {
|
34 |
|
|
continue;
|
35 |
|
|
}
|
36 |
4267
|
leinfelder
|
|
37 |
|
|
metadataAttributes += "<attribute index=\"";
|
38 |
|
|
metadataAttributes += index;
|
39 |
|
|
metadataAttributes += "\">";
|
40 |
|
|
|
41 |
|
|
metadataAttributes += "<pathexpr label=\"";
|
42 |
|
|
metadataAttributes += formElement.name;
|
43 |
|
|
metadataAttributes += "\">";
|
44 |
|
|
metadataAttributes += formElement.value;
|
45 |
|
|
metadataAttributes += "</pathexpr>";
|
46 |
|
|
|
47 |
|
|
metadataAttributes += "</attribute>";
|
48 |
|
|
|
49 |
|
|
index++;
|
50 |
|
|
}
|
51 |
|
|
}
|
52 |
|
|
|
53 |
4281
|
leinfelder
|
//assemble the assessment metadata
|
54 |
4267
|
leinfelder
|
metadataAttributes =
|
55 |
|
|
"<datapackage id=\"" + docId + "\">"
|
56 |
|
|
+ "<entity id=\"" + docId + "\">"
|
57 |
|
|
+ metadataAttributes
|
58 |
|
|
+ "</entity>"
|
59 |
|
|
+ "</datapackage>";
|
60 |
|
|
|
61 |
4281
|
leinfelder
|
//construct the entire query
|
62 |
|
|
var tempQuery =
|
63 |
4267
|
leinfelder
|
"<?xml version=\"1.0\"?>"
|
64 |
|
|
+ "<dataquery>"
|
65 |
4281
|
leinfelder
|
+ "<union>";
|
66 |
|
|
|
67 |
|
|
//loop for each question item
|
68 |
|
|
for (var i=0; i < questionIds.length; i++) {
|
69 |
|
|
var questionId = questionIds[i];
|
70 |
4267
|
leinfelder
|
|
71 |
4281
|
leinfelder
|
tempQuery +=
|
72 |
|
|
"<query>"
|
73 |
|
|
//select the data
|
74 |
|
|
+ "<selection>"
|
75 |
|
|
+ "<datapackage id=\"" + docId + "\">"
|
76 |
|
|
+ "<entity index=\"0\">"
|
77 |
|
|
+ "<attribute index=\"0\"/>"
|
78 |
|
|
+ "<attribute index=\"1\"/>"
|
79 |
|
|
//omit student id attribute
|
80 |
|
|
+ "<attribute index=\"3\"/>"
|
81 |
|
|
+ "<attribute index=\"4\"/>"
|
82 |
4267
|
leinfelder
|
+ "</entity>"
|
83 |
4281
|
leinfelder
|
+ "</datapackage>";
|
84 |
|
|
|
85 |
|
|
//select the metadata
|
86 |
|
|
tempQuery += metadataAttributes;
|
87 |
|
|
|
88 |
|
|
//select the question metadata
|
89 |
|
|
if (questionId.length > 0) {
|
90 |
|
|
tempQuery +=
|
91 |
|
|
"<datapackage id=\"" + questionId + "\">"
|
92 |
|
|
+ "<entity id=\"" + questionId + "\">"
|
93 |
|
|
+ "<attribute index=\"0\">"
|
94 |
|
|
+ "<pathexpr label=\"qId\">//assessment/section/item/@ident</pathexpr>"
|
95 |
|
|
+ "</attribute>"
|
96 |
|
|
+ "<attribute index=\"1\">"
|
97 |
|
|
+ "<pathexpr label=\"qTitle\">//assessment/section/item/@title</pathexpr>"
|
98 |
|
|
+ "</attribute>"
|
99 |
|
|
+ "<attribute index=\"2\">"
|
100 |
|
|
+ "<pathexpr label=\"qLabel\">//assessment/section/item/presentation/@label</pathexpr>"
|
101 |
|
|
+ "</attribute>"
|
102 |
|
|
+ "</entity>"
|
103 |
|
|
+ "</datapackage>";
|
104 |
|
|
}
|
105 |
|
|
|
106 |
|
|
tempQuery += "</selection>";
|
107 |
|
|
|
108 |
|
|
//join to the quesion "table"
|
109 |
|
|
if (questionId.length > 0) {
|
110 |
|
|
tempQuery +=
|
111 |
|
|
"<where>"
|
112 |
|
|
+ "<condition type=\"join\">"
|
113 |
|
|
+ "<left>"
|
114 |
|
|
+ "<datapackage id=\"" + docId + "\">"
|
115 |
|
|
+ "<entity index=\"0\">"
|
116 |
|
|
+ "<attribute index=\"1\"/>"
|
117 |
|
|
+ "</entity>"
|
118 |
|
|
+ "</datapackage>"
|
119 |
|
|
+ "</left>"
|
120 |
|
|
+ "<operator>=</operator>"
|
121 |
|
|
+ "<right>"
|
122 |
|
|
+ "<datapackage id=\"" + questionId + "\">"
|
123 |
|
|
+ "<entity id=\"" + questionId + "\">"
|
124 |
|
|
+ "<attribute index=\"0\">"
|
125 |
|
|
+ "<pathexpr label=\"qId\">//assessment/section/item/@ident</pathexpr>"
|
126 |
|
|
+ "</attribute>"
|
127 |
|
|
+ "</entity>"
|
128 |
|
|
+ "</datapackage>"
|
129 |
|
|
+ "</right>"
|
130 |
|
|
+ "</condition>"
|
131 |
|
|
+ "</where>";
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
tempQuery += "</query>";
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
tempQuery +=
|
138 |
|
|
"</union>"
|
139 |
4267
|
leinfelder
|
+ "</dataquery>";
|
140 |
|
|
|
141 |
4281
|
leinfelder
|
submitFormObj.dataquery.value = tempQuery;
|
142 |
|
|
|
143 |
4273
|
leinfelder
|
//alert(submitFormObj.dataquery.value);
|
144 |
4267
|
leinfelder
|
|
145 |
|
|
return true;
|
146 |
|
|
}
|