diff test_create/test_create.html @ 1248:f04d8ababef7

Updated specification object to reflect schema changes
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Wed, 09 Mar 2016 15:00:19 +0000
parents 83b439322229
children ba6b9e1aaef5
line wrap: on
line diff
--- a/test_create/test_create.html	Wed Mar 09 14:40:12 2016 +0000
+++ b/test_create/test_create.html	Wed Mar 09 15:00:19 2016 +0000
@@ -180,6 +180,7 @@
                     this.type = undefined;
                     this.schema = specification.schema.getAllElementsByName('surveyentry')[0];
                     this.id = undefined;
+                    this.name = undefined;
                     this.mandatory = undefined;
                     this.statement = undefined;
                     this.boxsize = undefined;
@@ -235,33 +236,31 @@
                         var statement = doc.createElement('statement');
                         statement.textContent = this.statement;
                         node.appendChild(statement);
-                        switch(this.type)
-                        {
-                        case "statement":
-                            break;
-                        case "question":
+                        if (this.type != "statement") {
                             node.id = this.id;
+                            if (this.name != undefined) { node.setAttribute("name",this.name);}
                             if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
-                            if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
-                            break;
-                        case "number":
-                            node.id = this.id;
-                            if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
-                            if (this.min != undefined) {node.setAttribute("min", this.min);}
-                            if (this.max != undefined) {node.setAttribute("max", this.max);}
-                            break;
-                        case "checkbox":
-                        case "radio":
-                            node.id = this.id;
-                            for (var i=0; i<this.options.length; i++)
+                            switch(this.type)
                             {
-                                var option = this.options[i];
-                                var optionNode = doc.createElement("option");
-                                optionNode.setAttribute("name",option.name);
-                                optionNode.textContent = option.text;
-                                node.appendChild(optionNode);
+                            case "question":
+                                if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
+                                break;
+                            case "number":
+                                if (this.min != undefined) {node.setAttribute("min", this.min);}
+                                if (this.max != undefined) {node.setAttribute("max", this.max);}
+                                break;
+                            case "checkbox":
+                            case "radio":
+                                for (var i=0; i<this.options.length; i++)
+                                {
+                                    var option = this.options[i];
+                                    var optionNode = doc.createElement("option");
+                                    optionNode.setAttribute("name",option.name);
+                                    optionNode.textContent = option.text;
+                                    node.appendChild(optionNode);
+                                }
+                                break;
                             }
-                            break;
                         }
                         return node;
                     };
@@ -529,6 +528,7 @@
 
                 this.commentQuestionNode = function() {
                     this.id = null;
+                    this.name = undefined;
                     this.type = undefined;
                     this.options = [];
                     this.statement = undefined;
@@ -536,6 +536,7 @@
                     this.decode = function(parent,xml)
                     {
                         this.id = xml.id;
+                        this.name = xml.getAttribute('name');
                         this.type = xml.getAttribute('type');
                         this.statement = xml.getElementsByTagName('statement')[0].textContent;
                         var optNodes = xml.getElementsByTagName('option');
@@ -554,6 +555,7 @@
                         var node = root.createElement("commentquestion");
                         node.id = this.id;
                         node.setAttribute("type",this.type);
+                        if (this.name != undefined){node.setAttribute("name",this.name);}
                         var statement = root.createElement("statement");
                         statement.textContent = this.statement;
                         node.appendChild(statement);
@@ -571,6 +573,7 @@
                 this.audioElementNode = function() {
                     this.url = null;
                     this.id = null;
+                    this.name = null;
                     this.parent = null;
                     this.type = null;
                     this.marker = null;