comparison core.js @ 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 0e49d874ba97
comparison
equal deleted inserted replaced
1202:27be75c51b5c 1203:1f352095179e
1933 } 1933 }
1934 }; 1934 };
1935 1935
1936 this.exportXML = function(doc) 1936 this.exportXML = function(doc)
1937 { 1937 {
1938 var node = doc.createElement('surveyelement'); 1938 var node = doc.createElement('surveyentry');
1939 node.setAttribute('type',this.type); 1939 node.setAttribute('type',this.type);
1940 var statement = doc.createElement('statement'); 1940 var statement = doc.createElement('statement');
1941 statement.textContent = this.statement; 1941 statement.textContent = this.statement;
1942 node.appendChild(statement); 1942 node.appendChild(statement);
1943 switch(this.type) 1943 switch(this.type)
1944 { 1944 {
1945 case "statement": 1945 case "statement":
1946 break; 1946 break;
1947 case "question": 1947 case "question":
1948 node.id = this.id; 1948 node.id = this.id;
1949 node.setAttribute("mandatory",this.mandatory); 1949 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
1950 node.setAttribute("boxsize",this.boxsize); 1950 if (this.boxsize != undefined) {node.setAttribute("boxsize",this.boxsize);}
1951 break; 1951 break;
1952 case "number": 1952 case "number":
1953 node.id = this.id; 1953 node.id = this.id;
1954 node.setAttribute("mandatory",this.mandatory); 1954 if (this.mandatory != undefined) { node.setAttribute("mandatory",this.mandatory);}
1955 node.setAttribute("min", this.min); 1955 if (this.min != undefined) {node.setAttribute("min", this.min);}
1956 node.setAttribute("max", this.max); 1956 if (this.max != undefined) {node.setAttribute("max", this.max);}
1957 node.setAttribute("step", this.step); 1957 break;
1958 break;
1959 case "checkbox": 1958 case "checkbox":
1960 case "radio": 1959 case "radio":
1961 node.id = this.id; 1960 node.id = this.id;
1962 for (var i=0; i<this.options.length; i++) 1961 for (var i=0; i<this.options.length; i++)
1963 { 1962 {