changeset 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 1620cbee9111
children be98bbeea41a
files js/specification.js test_create.html
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
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);
--- a/test_create.html	Tue Sep 26 10:15:39 2017 +0100
+++ b/test_create.html	Tue Sep 26 11:22:47 2017 +0100
@@ -933,6 +933,15 @@
                     <button type="button" class="btn btn-danger" ng-click="removeCommentQuestion(cq)">Remove Comment Question</button>
                     <div class="attributes">
                         <div class="attribute">
+                            <span>Type:</span>
+                            <select ng-model="cq.type">
+                                <option value="question">Question</option>
+                                <option value="checkbox">Checkbox</option>
+                                <option value="radio">Radio</option>
+                                <option value="slider">Slider</option>
+                            </select>
+                        </div>
+                        <div class="attribute">
                             <span>Unique ID:</span>
                             <input type="text" ng-model="cq.id" required/>
                         </div>
@@ -940,6 +949,10 @@
                             <span>Common Name:</span>
                             <input type="text" ng-model="cq.name" />
                         </div>
+                        <div class="attribute">
+                            <span>Mandatory:</span>
+                            <input type="checkbox" ng-model="cq.mandatory" />
+                        </div>
                         <div class="attribute" ng-show="cq.type == 'slider'">
                             <span>Minimum:</span>
                             <input type="number" ng-model="cq.min" />