diff js/specification.js @ 3036:ae0950bc1c99

Close #218. Added to test_create.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 26 Sep 2017 11:22:47 +0100
parents 49eca76782d2
children e441e3d5c7e7
line wrap: on
line diff
--- a/js/specification.js	Tue Sep 26 10:15:39 2017 +0100
+++ b/js/specification.js	Tue Sep 26 11:22:47 2017 +0100
@@ -704,8 +704,12 @@
                 AHNode.appendChild(this.audioElements[i].encode(root));
             }
             // Create <CommentQuestion>
-            for (i = 0; i < this.commentQuestions.length; i++) {
-                AHNode.appendChild(this.commentQuestions[i].encode(root));
+            if (this.commentQuestions.length > 0) {
+                var node = root.createElement("commentquestions");
+                for (i = 0; i < this.commentQuestions.length; i++) {
+                    node.appendChild(this.commentQuestions[i].encode(root));
+                }
+                AHNode.appendChild(node);
             }
 
             AHNode.appendChild(this.preTest.encode(root));
@@ -804,6 +808,7 @@
                         throw ("Unknown type " + this.type);
                 }
                 node.id = this.id;
+                node.setAttribute("mandatory", this.mandatory);
                 node.setAttribute("type", this.type);
                 if (this.name !== undefined) {
                     node.setAttribute("name", this.name);