Project

General

Profile

« Previous | Next » 

Revision 4281

added support for merging response data with question-level metadata

View differences:

lib/style/skins/first/search.js
3 3
	
4 4
    //var checkBox = document.getElementById("searchAll");
5 5
	var docId = submitFormObj.docid.value;
6
	
7 6
	//alert("docId=" + docId);
8 7
	
8
	//do we want question metadata?
9
	var includeQuestions = submitFormObj.includeQuestionsRadio.checked;
10
	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
9 27
	var metadataAttributes = "";
10 28
	var index = 0;
11 29
	for (var i=0; i < submitFormObj.length; i++) {
......
28 46
		}
29 47
	}
30 48
	
49
	//assemble the assessment metadata
31 50
	metadataAttributes = 
32 51
				"<datapackage id=\"" + docId + "\">"
33 52
					+ "<entity id=\"" + docId + "\">"
......
35 54
					+ "</entity>"
36 55
				+ "</datapackage>";
37 56
	
38
        submitFormObj.dataquery.value = 
57
	//construct the entire query
58
	var tempQuery = 
39 59
        "<?xml version=\"1.0\"?>"
40 60
        + "<dataquery>"
41
		+ "<query>"
42
			+ "<selection>"
43
				+ "<datapackage id=\"" + docId + "\">"
44
					+ "<entity index=\"0\">"
45
						+ "<attribute index=\"0\"/>"
46
						+ "<attribute index=\"1\"/>"
47
						//omit student id
48
						+ "<attribute index=\"3\"/>"
49
						+ "<attribute index=\"4\"/>"
50
					+ "</entity>"
51
				+ "</datapackage>"
61
			+ "<union>";
62
			
63
			//loop for each question item
64
			for (var i=0; i < questionIds.length; i++) {
65
				var questionId = questionIds[i];
52 66
				
53
				+ metadataAttributes
54
				
55
			+ "</selection>"
56
			/*
57
			+ "<where>"
58
				+ "<condition type="condition">"
59
					+ "<left>"
60
						+ "<datapackage id="tao.1.1">"
61
							+ "<entity index="0">"
62
								+ "<attribute index="2"/>"
67
				tempQuery +=
68
					"<query>"
69
					//select the data
70
					+ "<selection>"
71
						+ "<datapackage id=\"" + docId + "\">"
72
							+ "<entity index=\"0\">"
73
								+ "<attribute index=\"0\"/>"
74
								+ "<attribute index=\"1\"/>"
75
								//omit student id attribute
76
								+ "<attribute index=\"3\"/>"
77
								+ "<attribute index=\"4\"/>"
63 78
							+ "</entity>"
64
						+ "</datapackage>"
65
					+ "</left>"
66
					+ "<operator>>=</operator>"				
67
					+ "<right>"
68
						+ "<value>15</value>"
69
					+ "</right>"
70
				+ "</condition>"
71
			+ "</where>"
72
			*/
73
		+ "</query>"
79
						+ "</datapackage>";
80
						
81
						//select the metadata
82
						tempQuery += metadataAttributes;
83

  
84
						//select the question metadata						
85
						if (questionId.length > 0) {
86
							tempQuery +=
87
							"<datapackage id=\"" + questionId + "\">"
88
								+ "<entity id=\"" + questionId + "\">"
89
									+ "<attribute index=\"0\">"
90
										+ "<pathexpr label=\"qId\">//assessment/section/item/@ident</pathexpr>"
91
									+ "</attribute>"
92
									+ "<attribute index=\"1\">"
93
										+ "<pathexpr label=\"qTitle\">//assessment/section/item/@title</pathexpr>"
94
									+ "</attribute>"
95
									+ "<attribute index=\"2\">"
96
										+ "<pathexpr label=\"qLabel\">//assessment/section/item/presentation/@label</pathexpr>"
97
									+ "</attribute>"
98
								+ "</entity>"
99
							+ "</datapackage>";
100
						}
101
						
102
					tempQuery += "</selection>";
103
					
104
					//join to the quesion "table"
105
					if (questionId.length > 0) {
106
						tempQuery +=
107
							"<where>"
108
								+ "<condition type=\"join\">"
109
									+ "<left>"
110
										+ "<datapackage id=\"" + docId + "\">"
111
											+ "<entity index=\"0\">"
112
												+ "<attribute index=\"1\"/>"
113
											+ "</entity>"
114
										+ "</datapackage>"
115
									+ "</left>"
116
									+ "<operator>=</operator>"
117
									+ "<right>"
118
										+ "<datapackage id=\"" + questionId + "\">"
119
											+ "<entity id=\"" + questionId + "\">"
120
												+ "<attribute index=\"0\">"
121
													+ "<pathexpr label=\"qId\">//assessment/section/item/@ident</pathexpr>"
122
												+ "</attribute>"
123
											+ "</entity>"
124
										+ "</datapackage>"
125
									+ "</right>"
126
								+ "</condition>"
127
							+ "</where>";
128
					}
129
					
130
					tempQuery += "</query>";
131
				}
132
				 
133
			tempQuery +=
134
			 "</union>"	
74 135
        + "</dataquery>";
75 136
         
137
         submitFormObj.dataquery.value = tempQuery;
138
         
76 139
         //alert(submitFormObj.dataquery.value);
77 140
         
78 141
    return true;

Also available in: Unified diff