Mercurial > hg > webaudioevaluationtool
changeset 1203:1f352095179e
Bug Fix #1611 : Generates valid XML from examples.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Mon, 22 Feb 2016 14:55:16 +0000 |
parents | 27be75c51b5c |
children | 96acb21e1cd5 |
files | core.js test_create/test_create.html |
diffstat | 2 files changed, 17 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/core.js Mon Feb 22 14:38:45 2016 +0000 +++ b/core.js Mon Feb 22 14:55:16 2016 +0000 @@ -1935,7 +1935,7 @@ this.exportXML = function(doc) { - var node = doc.createElement('surveyelement'); + var node = doc.createElement('surveyentry'); node.setAttribute('type',this.type); var statement = doc.createElement('statement'); statement.textContent = this.statement; @@ -1945,17 +1945,16 @@ case "statement": break; case "question": - node.id = this.id; - node.setAttribute("mandatory",this.mandatory); - node.setAttribute("boxsize",this.boxsize); - break; - case "number": - node.id = this.id; - node.setAttribute("mandatory",this.mandatory); - node.setAttribute("min", this.min); - node.setAttribute("max", this.max); - node.setAttribute("step", this.step); - break; + node.id = this.id; + 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;
--- a/test_create/test_create.html Mon Feb 22 14:38:45 2016 +0000 +++ b/test_create/test_create.html Mon Feb 22 14:55:16 2016 +0000 @@ -230,7 +230,7 @@ this.exportXML = function(doc) { - var node = doc.createElement('surveyelement'); + var node = doc.createElement('surveyentry'); node.setAttribute('type',this.type); var statement = doc.createElement('statement'); statement.textContent = this.statement; @@ -241,15 +241,14 @@ break; case "question": node.id = this.id; - node.setAttribute("mandatory",this.mandatory); - node.setAttribute("boxsize",this.boxsize); + 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; - node.setAttribute("mandatory",this.mandatory); - node.setAttribute("min", this.min); - node.setAttribute("max", this.max); - node.setAttribute("step", this.step); + 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":