comparison test_create/test_create.html @ 1754:bd697e53d942

Create_Test: Creates XML Document.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 03 Jun 2015 12:07:07 +0100
parents 070c56725b60
children 3b24b06f93a1
comparison
equal deleted inserted replaced
1753:070c56725b60 1754:bd697e53d942
89 var metric = document.createElement('metricEnable'); 89 var metric = document.createElement('metricEnable');
90 metric.textContent = options[i].id; 90 metric.textContent = options[i].id;
91 globalMetrics.appendChild(metric); 91 globalMetrics.appendChild(metric);
92 } 92 }
93 } 93 }
94 setup.appendChild(globalPreTest);
95 setup.appendChild(globalPostTest);
96 setup.appendChild(globalMetrics);
97 xmlDoc.appendChild(setup);
94 98
99 var audioHolders = document.getElementsByName('audio-holder');
100 for (var i=0; i<audioHolders.length; i++) {
101 var audioHolder = document.createElement('audioHolder');
102 var audioHolderDOM = audioHolders[i];
103 var attribs = audioHolderDOM.getElementsByClassName('attrib')[0].getElementsByTagName('input');
104 audioHolder.id = attribs[0].value;
105 if (attribs[1].value != "") {audioHolder.setAttribute('sampleRate',attribs[1].value);}
106 if (attribs[2].value != "") {audioHolder.setAttribute('hostURL',attribs[2].value);}
107 audioHolder.setAttribute('randomiseOrder',attribs[3].checked);
108 audioHolder.setAttribute('repeatCount',attribs[4].checked);
109 audioHolder.setAttribute('loop',attribs[5].checked);
110 audioHolder.setAttribute('elementComments',attribs[6].checked);
111
112 // Audio-Holder PreTests
113 var audioHolderPreTest = document.createElement('preTest');
114 var audioHolderPostTest = document.createElement('postTest');
115 options = audioHolderDOM.childNodes[2].getElementsByClassName('head');
116 constructPrePost(audioHolderPreTest, options);
117 options = audioHolderDOM.childNodes[3].getElementsByClassName('head');
118 constructPrePost(audioHolderPostTest, options);
119
120 audioHolder.appendChild(audioHolderPreTest);
121 audioHolder.appendChild(audioHolderPostTest);
122
123 // audio-Elements
124 var audioElementsDOM = [];
125 var commentQuestionDOM = [];
126 for (var j=0; j<audioHolderDOM.childElementCount; j++) {
127 var child = audioHolderDOM.childNodes[j];
128 var name = child.getAttribute('name');
129 if (name == 'audio-element') {audioElementsDOM.push(child);}
130 else if (name == 'comment-question') {commentQuestionDOM.push(child);}
131 }
132
133 for (var j=0; j<audioElementsDOM.length; j++) {
134 var audioElement = document.createElement('audioElement');
135 attribs = audioElementsDOM[j].getElementsByClassName('attrib')[0].getElementsByTagName('input');
136 audioElement.id = attribs[0].value;
137 audioElement.setAttribute('url',attribs[1].value);
138 audioHolder.appendChild(audioElement);
139 }
140
141 for (var j=0; j<commentQuestionDOM.length; j++) {
142 var commentQuestion = document.createElement('commentQuestion');
143 attribs = commentQuestionDOM[j].getElementsByClassName('attrib')[0].getElementsByTagName('input');
144 commentQuestion.id = attribs[0].value;
145 commentQuestion.textContent = attribs[1].value;
146 audioHolder.appendChild(commentQuestion);
147 }
148 xmlDoc.appendChild(audioHolder);
149 }
150 return xmlDoc;
95 } 151 }
96 } 152 }
97 153
98 function constructPrePost(parent, options) { 154 function constructPrePost(parent, options) {
99 for (var i=0; i<options.length; i++) { 155 for (var i=0; i<options.length; i++) {