diff --git a/demo-material/form-data.json b/demo-material/form-data.json index 257de19..c0998d5 100644 --- a/demo-material/form-data.json +++ b/demo-material/form-data.json @@ -1,9 +1,9 @@ -{ + { "name": "form name", "description": "description", "pages": [ { - "id": "b8107c034ded6bf430488ca30d524bed", + "id": "16062797c1e9a92a9dbaae5e9ce17d6c", "number": 1, "name": null, "description": null, @@ -13,333 +13,288 @@ }, "elements": [ { - "id": "7180d9e3d0c341bb99c91c73d5b97351", + "id": "e30d62038bb2becbe76cb144dc37472e", "orderNo": 1, "type": "question", "question": { - "id": "ed9a53e5ebc4fd4cdf84686743c0b939", - "text": "short text", - "type": "text", + "id": "e2473fd90ef36ab5bae5f0a33cf01ea3", + "text": "Enter a number 0-100", + "type": "number", "required": true, - "pageFlowModifier": false + "pageFlowModifier": false, + "min": 0, + "max": 100 } }, { - "id": "3f215923f068d5355ce9dcc61aa340c7", + "id": "3d6c0026132b6aa22f3da1922862b33e", "orderNo": 2, "type": "question", "question": { - "id": "46d605c6b29161e49918733ea2c21b10", - "text": "long text", - "type": "textarea", + "id": "17079f62650f74b378b1436aefbba299", + "text": "What is your name?", + "type": "text", "required": true, "pageFlowModifier": false } }, { - "id": "2da74f344ce74b0c9c501f05dd27b94a", + "id": "29f66f70cfb6b48b55cdec00c1afbad4", "orderNo": 3, "type": "question", "question": { - "id": "16a37f04b1f2c4ed9ccad0f90c202f3e", - "text": "radio question", - "type": "radio", + "id": "4775dc2cbdc8da2e63811caf9bac33f5", + "text": "What is your Birthday?", + "type": "date", "required": true, - "offeredAnswers": [ - { - "id": "c1860469d05cb0be1ef6c254809c207e", - "orderNo": 2, - "value": "bbbb", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - } - ], - "otherAnswer": true + "pageFlowModifier": false } }, { - "id": "a720b9734f64a7fd728df4cd5d995117", + "id": "02c00717cb929fb788634ee0d86d8bbb", "orderNo": 4, "type": "question", "question": { - "id": "3ba201eb2562dca36a5257ef3ff2be2d", - "text": "checkbox", - "type": "checkbox", + "id": "671fd9130b1e7ead23dd2e90555474c9", + "text": "What time do you wake up?", + "type": "time", "required": true, - "offeredAnswers": [ - { - "id": "16eddc288f7e58b5c3407de778f933a1", - "orderNo": 1, - "value": "aaaa", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - }, - { - "id": "567678e87b794541a9e6f7e1376b562c", - "orderNo": 2, - "value": "bbb", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - }, - { - "id": "1e27b677f96d2d08ce0fb0d5723607da", - "orderNo": 3, - "value": "cccc", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - } - ], - "pageFlowModifier": false, - "otherAnswer": true + "pageFlowModifier": false } }, { - "id": "24490cf9c495cb33d4c8d2a0f813b817", + "id": "11ac9c831ca3adc019905564da1036db", "orderNo": 5, "type": "question", "question": { - "id": "edb85ee7c9da14ffeb15bb9f8cfaffd3", - "text": "Is {{price}} a fair price?", - "type": "radio", + "id": "67e855cec05b1c93ff57d376d798ec45", + "text": "What is your email?", + "type": "email", "required": true, - "offeredAnswers": [ - { - "id": "68a49a4f13203098f0fc6a744c1fe704", - "orderNo": 1, - "value": "yes", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - }, - { - "id": "53e006974790df5099ab26e9f2ce9c06", - "orderNo": 2, - "value": "{{noAnswer}}", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - } - ] + "pageFlowModifier": false } }, { - "id": "ee297f58ceec1470c9db35559409755c", + "id": "1f21b81c070c13d350ed2237b397172a", "orderNo": 6, "type": "question", "question": { - "id": "a7106ec0fba810a84899b8579f5fd924", - "text": "Is {{person.name}} age {{person.age}}?", - "type": "radio", + "id": "a333d8d16ee02341e72eb94629abfd98", + "text": "Enter a number 0-100", + "type": "range", "required": true, - "offeredAnswers": [ - { - "id": "ae38733fc632753099f430b1c1ffcefc", - "orderNo": 1, - "value": "yes", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - }, - { - "id": "61a226f242d86522a49b786c654c4165", - "orderNo": 2, - "value": "no", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - } - ] + "pageFlowModifier": false, + "min": 0, + "max": 100 } }, { - "id": "d3c87dfb2945a84ad79e9c4b888d7df3", + "id": "ba965ceba420a87139c9d1719cf76f6c", "orderNo": 7, "type": "question", "question": { - "id": "f9c1586e1f1f40705e1eefbd00224218", - "text": "range", - "type": "range", + "id": "15c42f5d490d68abf3c48e790ed508d6", + "text": "What is your homepage?", + "type": "url", "required": true, - "pageFlowModifier": false, - "min": 1, - "max": 10 + "pageFlowModifier": false } }, { - "id": "1b183679857291f8ad46c03c3173e64d", + "id": "b0c2a905c103455f285fd68cdf1100ff", "orderNo": 8, "type": "question", "question": { - "id": "10b08afca4dff80e975f4910ee85ef3f", - "text": "grid question", + "id": "4c39312a94e066a856a195753832de05", + "text": "Describe your favorite food", + "type": "textarea", + "required": true, + "pageFlowModifier": false + } + }, + { + "id": "e0a45a061f022e7785e2e600158904b3", + "orderNo": 9, + "type": "question", + "question": { + "id": "b6f584afe412f506eb56e922d84322e5", + "text": "What is your favorite time of day?", "type": "grid", "required": true, "grid": { "rows": [ { - "id": "48b09d72e6fb0d2a63985eef4018346e", + "id": "36683a4385337df9ab6b580207272b5b", "orderNo": 1, - "label": "row 1" + "label": "Weekend" }, { - "id": "f35a6e5d1ce9407b5ece224198032cb6", + "id": "a5b1523d67c878e149d86f0ffe4bbc1b", "orderNo": 2, - "label": "row 2" + "label": "Weekday" } ], "cols": [ { - "id": "ace63d4001112c28e97b00ff67ceeeca", + "id": "223bbfa4fecc0900f21c8a79ead634a2", "orderNo": 1, - "label": "col 1" + "label": "Morning" }, { - "id": "24062ae1fc97dead41d337ede7f2e55e", + "id": "1f1b13a99fa798fc5deedb1238e0d92c", "orderNo": 2, - "label": "col2" + "label": "Night" } ] }, "pageFlowModifier": false } - } - ], - "namedPage": false, - "isFirst": true, - "isLast": false - }, - { - "id": "d7b158cc2aff4c00b3d452006d79368d", - "number": 2, - "name": null, - "description": null, - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - }, - "elements": [ + }, { - "id": "82332304478a82ee69f2d60157930e0a", - "orderNo": 1, + "id": "617c8334bebadd2ccc1397185838aba3", + "orderNo": 10, "type": "question", "question": { - "id": "dc640ed493ba5a00d4a44f3a216cfa34", - "text": "priority list", + "id": "3643ebd79db7a48115058b5ce75a74c8", + "text": "What is more important?", "type": "priority", "required": true, "priorityList": [ { - "id": "c389bfb386b59483c7592719d9968d35", + "id": "3424ad4e994547d0a251f7135df35306", "orderNo": 1, - "value": "aaaaaaaaaaaa" + "value": "Food" }, { - "id": "66a28c757482c280b30db318b5922201", + "id": "68ce06f38d686faaa56b63b9d24d2a86", "orderNo": 2, - "value": "bbbbbbbbbb" - }, - { - "id": "14629777a4bda0e1d40044429aaf63f9", - "orderNo": 3, - "value": "cccccccccccccc" + "value": "Water" } ], "pageFlowModifier": false } }, { - "id": "358c65a9f3590235b3b9d019722f2372", - "orderNo": 2, + "id": "2ce584fc08829f270a55e2b957b072c1", + "orderNo": 11, "type": "question", "question": { - "id": "8666ad943291900f0e5b34bc14bb18dc", - "text": "division", - "type": "division", + "id": "be2f2711c2c5f869fa636fde360a9455", + "text": "Do you like your computer?", + "type": "radio", "required": true, - "divisionList": [ + "offeredAnswers": [ + { + "id": "589eabfe8af7673375f137eca83f194d", + "orderNo": 2, + "value": "No", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "e2b88bc85951622b3b59901a77678255", + "orderNo": 2, + "value": "Yes", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + } + ] + } + }, + { + "id": "e57dcdafc7b6a4f49d15869374ad0a2e", + "orderNo": 12, + "type": "question", + "question": { + "id": "719ef4f8afc21bf07ecfcd81b077d7b0", + "text": "What animal would you keep as a pet?", + "type": "checkbox", + "required": true, + "offeredAnswers": [ { - "id": "dc3c109e947b736c49415faf0b595091", + "id": "451cfffbb07ab6f201a08e3be739d534", "orderNo": 1, - "value": "aaaaaa" + "value": "Cat", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } }, { - "id": "476d950019a69252524ac00d2a39ef54", + "id": "992d824c43e4032b297a959bb2b0e925", "orderNo": 2, - "value": "bbbbb" + "value": "Dog", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } }, { - "id": "d9b54b9da75bdfe78d4cbc41d0cdf9e0", + "id": "c2a18d282713ea602f31073626f15ed5", "orderNo": 3, - "value": "cccccccc" + "value": "Cow", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } } ], "pageFlowModifier": false, - "quantity": 100, - "unit": "%" + "otherAnswer": true } - } - ], - "namedPage": false, - "isFirst": false, - "isLast": false - }, - { - "id": "5d9fc08eaac5739f574db0e5b86a6a36", - "number": 3, - "name": "Page name", - "description": null, - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - }, - "elements": [ + }, { - "id": "99f0e2587c29cde3abb2ab2076fc375c", - "orderNo": 1, + "id": "f24eae2eee292456ad41c0ee6d5322a5", + "orderNo": 13, "type": "paragraph", "paragraph": { - "id": "12448073a8702376af0b427b63022926", - "html": "Lorem {{templateData}} ipsum dolor sit amet, consectetur adipiscing elit. Nullam quis nunc quis nisi lacinia commodo quis in urna. Maecenas dictum urna eget fringilla vehicula. Morbi congue id dolor vel volutpat. Aenean suscipit lectus velit, eget eleifend massa pretium quis. Cras quis pharetra nulla. Proin porttitor fermentum est, eu aliquam velit porttitor quis. Sed non bibendum odio, a pellentesque neque. Donec eu lectus vitae nisl ornare aliquet. Donec ornare felis non elit malesuada tincidunt. Praesent ipsum augue, venenatis in auctor vel, aliquet et augue. Ut efficitur elit eu elit fringilla, imperdiet suscipit libero consequat. Ut in metus libero. Nullam vestibulum, augue nec varius elementum, erat orci iaculis neque, quis varius ante leo eu lectus. Vestibulum eget ante enim. Nulla lobortis, felis sed mattis posuere, urna leo pharetra mi, ut elementum augue erat sed odio. In mattis, orci nec maximus fermentum, tellus lacus porta purus, sed scelerisque massa justo id nunc." + "id": "725240f307c6091116b698c3ec97aa2b", + "html": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam quis nunc quis nisi lacinia commodo quis in urna. Maecenas dictum urna eget fringilla vehicula. Morbi congue id dolor vel volutpat. Aenean suscipit lectus velit, eget eleifend massa pretium quis. Cras quis pharetra nulla. Proin porttitor fermentum est, eu aliquam velit porttitor quis. Sed non bibendum odio, a pellentesque neque. Donec eu lectus vitae nisl ornare aliquet. Donec ornare felis non elit malesuada tincidunt. Praesent ipsum augue, venenatis in auctor vel, aliquet et augue. Ut efficitur elit eu elit fringilla, imperdiet suscipit libero consequat. Ut in metus libero. Nullam vestibulum, augue nec varius elementum, erat orci iaculis neque, quis varius ante leo eu lectus. Vestibulum eget ante enim. Nulla lobortis, felis sed mattis posuere, urna leo pharetra mi, ut elementum augue erat sed odio. In mattis, orci nec maximus fermentum, tellus lacus porta purus, sed scelerisque massa justo id nunc." } }, { - "id": "2d9145a0b749ca85959268737c90029c", - "orderNo": 2, + "id": "791597697a9bfda41264a79dfc3865df", + "orderNo": 14, "type": "image", "image": { - "id": "e94d4dcdbc45d90d0561116518e13b77", - "align": "center", - "src": "lena.gif", - "caption": "Image caption" + "id": "22c56ce862e63ce07f74ddbe50fd446f", + "align": "left", + "src": "lena.gif" } }, { - "id": "1dfa4dc8242f7b98b5449d380fee1785", - "orderNo": 3, + "id": "bc898f0149fe91c7afb5dabbb7c41a4b", + "orderNo": 15, "type": "question", "question": { - "id": "7d8826e84a398532fbe78be646214eab", - "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit?", - "type": "textarea", + "id": "bcaf100bc048236e2939fe71cae38fb3", + "text": "How do you spend your time?", + "type": "division", "required": true, - "pageFlowModifier": false + "divisionList": [ + { + "id": "beddb9695d2b814d859ace81c26a58c7", + "orderNo": 1, + "value": "Awake" + }, + { + "id": "2699c939c2b1596030a6aba4edbbdafb", + "orderNo": 2, + "value": "Asleep" + } + ], + "pageFlowModifier": false, + "quantity": 100, + "unit": "%" } } ], - "namedPage": true, - "isFirst": false, + "namedPage": false, + "isFirst": true, "isLast": true } ] diff --git a/demo-material/response-data.json b/demo-material/response-data.json index ba03eff..2c1385a 100644 --- a/demo-material/response-data.json +++ b/demo-material/response-data.json @@ -1,45 +1,56 @@ { - "ed9a53e5ebc4fd4cdf84686743c0b939": { - "answer": "short text answer" + "e2473fd90ef36ab5bae5f0a33cf01ea3": { + "answer": 10 }, - "46d605c6b29161e49918733ea2c21b10": { - "answer": "long text answer" + "17079f62650f74b378b1436aefbba299": { + "answer": "Bob" }, - "16a37f04b1f2c4ed9ccad0f90c202f3e": { - "selectedAnswer": "c1860469d05cb0be1ef6c254809c207e" + "4775dc2cbdc8da2e63811caf9bac33f5": { + "answer": "2016-05-20T07:00:00.000Z" }, - "3ba201eb2562dca36a5257ef3ff2be2d": { - "selectedAnswers": [ - "567678e87b794541a9e6f7e1376b562c" - ], - "other": "checkbox other answer" + "671fd9130b1e7ead23dd2e90555474c9": { + "answer": "1970-01-01T12:00:00.000Z" + }, + "67e855cec05b1c93ff57d376d798ec45": { + "answer": "bob@bob.com" + }, + "a333d8d16ee02341e72eb94629abfd98": { + "answer": "18" + }, + "15c42f5d490d68abf3c48e790ed508d6": { + "answer": "http://bob.com" + }, + "4c39312a94e066a856a195753832de05": { + "answer": "Bobbing for Apples" }, - "10b08afca4dff80e975f4910ee85ef3f": { - "48b09d72e6fb0d2a63985eef4018346e": "ace63d4001112c28e97b00ff67ceeeca", - "f35a6e5d1ce9407b5ece224198032cb6": "ace63d4001112c28e97b00ff67ceeeca" + "b6f584afe412f506eb56e922d84322e5": { + "36683a4385337df9ab6b580207272b5b": "223bbfa4fecc0900f21c8a79ead634a2", + "a5b1523d67c878e149d86f0ffe4bbc1b": "1f1b13a99fa798fc5deedb1238e0d92c" }, - "dc640ed493ba5a00d4a44f3a216cfa34": { + "3643ebd79db7a48115058b5ce75a74c8": { "priorityList": [ { "priority": 1, - "id": "c389bfb386b59483c7592719d9968d35" + "id": "68ce06f38d686faaa56b63b9d24d2a86" }, { "priority": 2, - "id": "14629777a4bda0e1d40044429aaf63f9" - }, - { - "priority": 3, - "id": "66a28c757482c280b30db318b5922201" + "id": "3424ad4e994547d0a251f7135df35306" } ] }, - "8666ad943291900f0e5b34bc14bb18dc": { - "dc3c109e947b736c49415faf0b595091": 10, - "476d950019a69252524ac00d2a39ef54": 30, - "d9b54b9da75bdfe78d4cbc41d0cdf9e0": 60 + "be2f2711c2c5f869fa636fde360a9455": { + "selectedAnswer": "589eabfe8af7673375f137eca83f194d" + }, + "719ef4f8afc21bf07ecfcd81b077d7b0": { + "selectedAnswers": [ + "992d824c43e4032b297a959bb2b0e925", + "451cfffbb07ab6f201a08e3be739d534", + "c2a18d282713ea602f31073626f15ed5" + ] }, - "7d8826e84a398532fbe78be646214eab": { - "answer": "Aenean non ante id turpis aliquam dignissim ut quis erat. Integer sed libero nunc." + "bcaf100bc048236e2939fe71cae38fb3": { + "beddb9695d2b814d859ace81c26a58c7": 60, + "2699c939c2b1596030a6aba4edbbdafb": 40 } } \ No newline at end of file diff --git a/demo/form-data.json b/demo/form-data.json index 9cfa125..c0998d5 100644 --- a/demo/form-data.json +++ b/demo/form-data.json @@ -1,9 +1,9 @@ -{ + { "name": "form name", "description": "description", "pages": [ { - "id": "b8107c034ded6bf430488ca30d524bed", + "id": "16062797c1e9a92a9dbaae5e9ce17d6c", "number": 1, "name": null, "description": null, @@ -13,201 +13,137 @@ }, "elements": [ { - "id": "7180d9e3d0c341bb99c91c73d5b97351", + "id": "e30d62038bb2becbe76cb144dc37472e", "orderNo": 1, "type": "question", "question": { - "id": "ed9a53e5ebc4fd4cdf84686743c0b939", - "text": "short text", - "type": "text", + "id": "e2473fd90ef36ab5bae5f0a33cf01ea3", + "text": "Enter a number 0-100", + "type": "number", "required": true, - "pageFlowModifier": false + "pageFlowModifier": false, + "min": 0, + "max": 100 } }, { - "id": "3f215923f068d5355ce9dcc61aa340c7", + "id": "3d6c0026132b6aa22f3da1922862b33e", "orderNo": 2, "type": "question", "question": { - "id": "46d605c6b29161e49918733ea2c21b10", - "text": "long text", - "type": "textarea", + "id": "17079f62650f74b378b1436aefbba299", + "text": "What is your name?", + "type": "text", "required": true, "pageFlowModifier": false } }, { - "id": "2da74f344ce74b0c9c501f05dd27b94a", + "id": "29f66f70cfb6b48b55cdec00c1afbad4", "orderNo": 3, "type": "question", "question": { - "id": "16a37f04b1f2c4ed9ccad0f90c202f3e", - "text": "radio question", - "type": "radio", + "id": "4775dc2cbdc8da2e63811caf9bac33f5", + "text": "What is your Birthday?", + "type": "date", "required": true, - "offeredAnswers": [ - { - "id": "c1860469d05cb0be1ef6c254809c207e", - "orderNo": 2, - "value": "bbbb", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - } - ], - "otherAnswer": true + "pageFlowModifier": false } }, { - "id": "a720b9734f64a7fd728df4cd5d995117", + "id": "02c00717cb929fb788634ee0d86d8bbb", "orderNo": 4, "type": "question", "question": { - "id": "3ba201eb2562dca36a5257ef3ff2be2d", - "text": "checkbox", - "type": "checkbox", + "id": "671fd9130b1e7ead23dd2e90555474c9", + "text": "What time do you wake up?", + "type": "time", "required": true, - "offeredAnswers": [ - { - "id": "16eddc288f7e58b5c3407de778f933a1", - "orderNo": 1, - "value": "aaaa", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - }, - { - "id": "567678e87b794541a9e6f7e1376b562c", - "orderNo": 2, - "value": "bbb", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - }, - { - "id": "1e27b677f96d2d08ce0fb0d5723607da", - "orderNo": 3, - "value": "cccc", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - } - ], - "pageFlowModifier": false, - "otherAnswer": true + "pageFlowModifier": false } }, { - "id": "24490cf9c495cb33d4c8d2a0f813b817", + "id": "11ac9c831ca3adc019905564da1036db", "orderNo": 5, "type": "question", "question": { - "id": "edb85ee7c9da14ffeb15bb9f8cfaffd3", - "text": "Is {{price}} a fair price?", - "type": "radio", + "id": "67e855cec05b1c93ff57d376d798ec45", + "text": "What is your email?", + "type": "email", "required": true, - "offeredAnswers": [ - { - "id": "68a49a4f13203098f0fc6a744c1fe704", - "orderNo": 1, - "value": "yes", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - }, - { - "id": "53e006974790df5099ab26e9f2ce9c06", - "orderNo": 2, - "value": "{{noAnswer}}", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - } - ] + "pageFlowModifier": false } }, { - "id": "ee297f58ceec1470c9db35559409755c", + "id": "1f21b81c070c13d350ed2237b397172a", "orderNo": 6, "type": "question", "question": { - "id": "a7106ec0fba810a84899b8579f5fd924", - "text": "Is {{person.name}} age {{person.age}}?", - "type": "radio", + "id": "a333d8d16ee02341e72eb94629abfd98", + "text": "Enter a number 0-100", + "type": "range", "required": true, - "offeredAnswers": [ - { - "id": "ae38733fc632753099f430b1c1ffcefc", - "orderNo": 1, - "value": "yes", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - }, - { - "id": "61a226f242d86522a49b786c654c4165", - "orderNo": 2, - "value": "no", - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - } - } - ] + "pageFlowModifier": false, + "min": 0, + "max": 100 } - } - ], - "namedPage": false - }, - { - "id": "d7b158cc2aff4c00b3d452006d79368d", - "number": 2, - "name": null, - "description": null, - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - }, - "elements": [ + }, { - "id": "1b183679857291f8ad46c03c3173e64d", - "orderNo": 1, + "id": "ba965ceba420a87139c9d1719cf76f6c", + "orderNo": 7, + "type": "question", + "question": { + "id": "15c42f5d490d68abf3c48e790ed508d6", + "text": "What is your homepage?", + "type": "url", + "required": true, + "pageFlowModifier": false + } + }, + { + "id": "b0c2a905c103455f285fd68cdf1100ff", + "orderNo": 8, "type": "question", "question": { - "id": "10b08afca4dff80e975f4910ee85ef3f", - "text": "grid question", + "id": "4c39312a94e066a856a195753832de05", + "text": "Describe your favorite food", + "type": "textarea", + "required": true, + "pageFlowModifier": false + } + }, + { + "id": "e0a45a061f022e7785e2e600158904b3", + "orderNo": 9, + "type": "question", + "question": { + "id": "b6f584afe412f506eb56e922d84322e5", + "text": "What is your favorite time of day?", "type": "grid", "required": true, "grid": { "rows": [ { - "id": "48b09d72e6fb0d2a63985eef4018346e", + "id": "36683a4385337df9ab6b580207272b5b", "orderNo": 1, - "label": "row 1" + "label": "Weekend" }, { - "id": "f35a6e5d1ce9407b5ece224198032cb6", + "id": "a5b1523d67c878e149d86f0ffe4bbc1b", "orderNo": 2, - "label": "row 2" + "label": "Weekday" } ], "cols": [ { - "id": "ace63d4001112c28e97b00ff67ceeeca", + "id": "223bbfa4fecc0900f21c8a79ead634a2", "orderNo": 1, - "label": "col 1" + "label": "Morning" }, { - "id": "24062ae1fc97dead41d337ede7f2e55e", + "id": "1f1b13a99fa798fc5deedb1238e0d92c", "orderNo": 2, - "label": "col2" + "label": "Night" } ] }, @@ -215,112 +151,151 @@ } }, { - "id": "82332304478a82ee69f2d60157930e0a", - "orderNo": 2, + "id": "617c8334bebadd2ccc1397185838aba3", + "orderNo": 10, "type": "question", "question": { - "id": "dc640ed493ba5a00d4a44f3a216cfa34", - "text": "priority list", + "id": "3643ebd79db7a48115058b5ce75a74c8", + "text": "What is more important?", "type": "priority", "required": true, "priorityList": [ { - "id": "c389bfb386b59483c7592719d9968d35", + "id": "3424ad4e994547d0a251f7135df35306", "orderNo": 1, - "value": "aaaaaaaaaaaa" + "value": "Food" }, { - "id": "66a28c757482c280b30db318b5922201", + "id": "68ce06f38d686faaa56b63b9d24d2a86", "orderNo": 2, - "value": "bbbbbbbbbb" - }, - { - "id": "14629777a4bda0e1d40044429aaf63f9", - "orderNo": 3, - "value": "cccccccccccccc" + "value": "Water" } ], "pageFlowModifier": false } }, { - "id": "358c65a9f3590235b3b9d019722f2372", - "orderNo": 3, + "id": "2ce584fc08829f270a55e2b957b072c1", + "orderNo": 11, "type": "question", "question": { - "id": "8666ad943291900f0e5b34bc14bb18dc", - "text": "division", - "type": "division", + "id": "be2f2711c2c5f869fa636fde360a9455", + "text": "Do you like your computer?", + "type": "radio", "required": true, - "divisionList": [ + "offeredAnswers": [ + { + "id": "589eabfe8af7673375f137eca83f194d", + "orderNo": 2, + "value": "No", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + }, + { + "id": "e2b88bc85951622b3b59901a77678255", + "orderNo": 2, + "value": "Yes", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } + } + ] + } + }, + { + "id": "e57dcdafc7b6a4f49d15869374ad0a2e", + "orderNo": 12, + "type": "question", + "question": { + "id": "719ef4f8afc21bf07ecfcd81b077d7b0", + "text": "What animal would you keep as a pet?", + "type": "checkbox", + "required": true, + "offeredAnswers": [ { - "id": "dc3c109e947b736c49415faf0b595091", + "id": "451cfffbb07ab6f201a08e3be739d534", "orderNo": 1, - "value": "aaaaaa" + "value": "Cat", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } }, { - "id": "476d950019a69252524ac00d2a39ef54", + "id": "992d824c43e4032b297a959bb2b0e925", "orderNo": 2, - "value": "bbbbb" + "value": "Dog", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } }, { - "id": "d9b54b9da75bdfe78d4cbc41d0cdf9e0", + "id": "c2a18d282713ea602f31073626f15ed5", "orderNo": 3, - "value": "cccccccc" + "value": "Cow", + "pageFlow": { + "nextPage": true, + "label": "mwForm.pageFlow.goToNextPage" + } } ], "pageFlowModifier": false, - "quantity": 100, - "unit": "%" + "otherAnswer": true } - } - ], - "namedPage": false - }, - { - "id": "5d9fc08eaac5739f574db0e5b86a6a36", - "number": 3, - "name": "Page name", - "description": null, - "pageFlow": { - "nextPage": true, - "label": "mwForm.pageFlow.goToNextPage" - }, - "elements": [ + }, { - "id": "99f0e2587c29cde3abb2ab2076fc375c", - "orderNo": 1, + "id": "f24eae2eee292456ad41c0ee6d5322a5", + "orderNo": 13, "type": "paragraph", "paragraph": { - "id": "12448073a8702376af0b427b63022926", - "html": "Lorem {{templateData}} ipsum dolor sit amet, consectetur adipiscing elit. Nullam quis nunc quis nisi lacinia commodo quis in urna. Maecenas dictum urna eget fringilla vehicula. Morbi congue id dolor vel volutpat. Aenean suscipit lectus velit, eget eleifend massa pretium quis. Cras quis pharetra nulla. Proin porttitor fermentum est, eu aliquam velit porttitor quis. Sed non bibendum odio, a pellentesque neque. Donec eu lectus vitae nisl ornare aliquet. Donec ornare felis non elit malesuada tincidunt. Praesent ipsum augue, venenatis in auctor vel, aliquet et augue. Ut efficitur elit eu elit fringilla, imperdiet suscipit libero consequat. Ut in metus libero. Nullam vestibulum, augue nec varius elementum, erat orci iaculis neque, quis varius ante leo eu lectus. Vestibulum eget ante enim. Nulla lobortis, felis sed mattis posuere, urna leo pharetra mi, ut elementum augue erat sed odio. In mattis, orci nec maximus fermentum, tellus lacus porta purus, sed scelerisque massa justo id nunc." + "id": "725240f307c6091116b698c3ec97aa2b", + "html": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam quis nunc quis nisi lacinia commodo quis in urna. Maecenas dictum urna eget fringilla vehicula. Morbi congue id dolor vel volutpat. Aenean suscipit lectus velit, eget eleifend massa pretium quis. Cras quis pharetra nulla. Proin porttitor fermentum est, eu aliquam velit porttitor quis. Sed non bibendum odio, a pellentesque neque. Donec eu lectus vitae nisl ornare aliquet. Donec ornare felis non elit malesuada tincidunt. Praesent ipsum augue, venenatis in auctor vel, aliquet et augue. Ut efficitur elit eu elit fringilla, imperdiet suscipit libero consequat. Ut in metus libero. Nullam vestibulum, augue nec varius elementum, erat orci iaculis neque, quis varius ante leo eu lectus. Vestibulum eget ante enim. Nulla lobortis, felis sed mattis posuere, urna leo pharetra mi, ut elementum augue erat sed odio. In mattis, orci nec maximus fermentum, tellus lacus porta purus, sed scelerisque massa justo id nunc." } }, { - "id": "2d9145a0b749ca85959268737c90029c", - "orderNo": 2, + "id": "791597697a9bfda41264a79dfc3865df", + "orderNo": 14, "type": "image", "image": { - "id": "e94d4dcdbc45d90d0561116518e13b77", - "align": "center", - "src": "lena.gif", - "caption": "Image caption" + "id": "22c56ce862e63ce07f74ddbe50fd446f", + "align": "left", + "src": "lena.gif" } }, { - "id": "1dfa4dc8242f7b98b5449d380fee1785", - "orderNo": 3, + "id": "bc898f0149fe91c7afb5dabbb7c41a4b", + "orderNo": 15, "type": "question", "question": { - "id": "7d8826e84a398532fbe78be646214eab", - "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit?", - "type": "textarea", + "id": "bcaf100bc048236e2939fe71cae38fb3", + "text": "How do you spend your time?", + "type": "division", "required": true, - "pageFlowModifier": false + "divisionList": [ + { + "id": "beddb9695d2b814d859ace81c26a58c7", + "orderNo": 1, + "value": "Awake" + }, + { + "id": "2699c939c2b1596030a6aba4edbbdafb", + "orderNo": 2, + "value": "Asleep" + } + ], + "pageFlowModifier": false, + "quantity": 100, + "unit": "%" } } ], - "namedPage": true + "namedPage": false, + "isFirst": true, + "isLast": true } ] } \ No newline at end of file diff --git a/demo/response-data.json b/demo/response-data.json index ba03eff..2c1385a 100644 --- a/demo/response-data.json +++ b/demo/response-data.json @@ -1,45 +1,56 @@ { - "ed9a53e5ebc4fd4cdf84686743c0b939": { - "answer": "short text answer" + "e2473fd90ef36ab5bae5f0a33cf01ea3": { + "answer": 10 }, - "46d605c6b29161e49918733ea2c21b10": { - "answer": "long text answer" + "17079f62650f74b378b1436aefbba299": { + "answer": "Bob" }, - "16a37f04b1f2c4ed9ccad0f90c202f3e": { - "selectedAnswer": "c1860469d05cb0be1ef6c254809c207e" + "4775dc2cbdc8da2e63811caf9bac33f5": { + "answer": "2016-05-20T07:00:00.000Z" }, - "3ba201eb2562dca36a5257ef3ff2be2d": { - "selectedAnswers": [ - "567678e87b794541a9e6f7e1376b562c" - ], - "other": "checkbox other answer" + "671fd9130b1e7ead23dd2e90555474c9": { + "answer": "1970-01-01T12:00:00.000Z" + }, + "67e855cec05b1c93ff57d376d798ec45": { + "answer": "bob@bob.com" + }, + "a333d8d16ee02341e72eb94629abfd98": { + "answer": "18" + }, + "15c42f5d490d68abf3c48e790ed508d6": { + "answer": "http://bob.com" + }, + "4c39312a94e066a856a195753832de05": { + "answer": "Bobbing for Apples" }, - "10b08afca4dff80e975f4910ee85ef3f": { - "48b09d72e6fb0d2a63985eef4018346e": "ace63d4001112c28e97b00ff67ceeeca", - "f35a6e5d1ce9407b5ece224198032cb6": "ace63d4001112c28e97b00ff67ceeeca" + "b6f584afe412f506eb56e922d84322e5": { + "36683a4385337df9ab6b580207272b5b": "223bbfa4fecc0900f21c8a79ead634a2", + "a5b1523d67c878e149d86f0ffe4bbc1b": "1f1b13a99fa798fc5deedb1238e0d92c" }, - "dc640ed493ba5a00d4a44f3a216cfa34": { + "3643ebd79db7a48115058b5ce75a74c8": { "priorityList": [ { "priority": 1, - "id": "c389bfb386b59483c7592719d9968d35" + "id": "68ce06f38d686faaa56b63b9d24d2a86" }, { "priority": 2, - "id": "14629777a4bda0e1d40044429aaf63f9" - }, - { - "priority": 3, - "id": "66a28c757482c280b30db318b5922201" + "id": "3424ad4e994547d0a251f7135df35306" } ] }, - "8666ad943291900f0e5b34bc14bb18dc": { - "dc3c109e947b736c49415faf0b595091": 10, - "476d950019a69252524ac00d2a39ef54": 30, - "d9b54b9da75bdfe78d4cbc41d0cdf9e0": 60 + "be2f2711c2c5f869fa636fde360a9455": { + "selectedAnswer": "589eabfe8af7673375f137eca83f194d" + }, + "719ef4f8afc21bf07ecfcd81b077d7b0": { + "selectedAnswers": [ + "992d824c43e4032b297a959bb2b0e925", + "451cfffbb07ab6f201a08e3be739d534", + "c2a18d282713ea602f31073626f15ed5" + ] }, - "7d8826e84a398532fbe78be646214eab": { - "answer": "Aenean non ante id turpis aliquam dignissim ut quis erat. Integer sed libero nunc." + "bcaf100bc048236e2939fe71cae38fb3": { + "beddb9695d2b814d859ace81c26a58c7": 60, + "2699c939c2b1596030a6aba4edbbdafb": 40 } } \ No newline at end of file diff --git a/dist/form-utils.min.js b/dist/form-utils.min.js index 9b35a28..ca5f2a6 100644 --- a/dist/form-utils.min.js +++ b/dist/form-utils.min.js @@ -1,2 +1,2 @@ angular.module("mwFormUtils",["mwFormUtils.responseUtils"]); -angular.module("mwFormUtils.responseUtils",[]).factory("mwFormResponseUtils",function(){var e={};return e.$getObjectByIdMap=function(e,t){var r={};return e?(e.forEach(function(e){var i=e;t&&(i=t(e)),r[e.id]=i}),r):r},e.$getOfferedAnswerByIdMap=function(t){return e.$getObjectByIdMap(t.offeredAnswers,function(e){return{id:e.id,value:e.value}})},e.$extractResponseForRadioOrCheckboxQuestion=function(t,r){var i=e.$getOfferedAnswerByIdMap(t),n={};return r.selectedAnswers?(n.selectedAnswers=[],r.selectedAnswers.forEach(function(e){n.selectedAnswers.push(i[e])})):r.selectedAnswer&&(n.selectedAnswer=i[r.selectedAnswer]),r.other&&(n.other=r.other),n},e.$extractResponseForPriorityQuestion=function(t,r){var i=[];if(!r.priorityList)return i;var n=e.$getObjectByIdMap(t.priorityList);return r.priorityList.forEach(function(e){var t=n[e.id];i.push({id:t.id,value:t.value,priority:e.priority})}),i},e.$extractResponseForDivisionQuestion=function(t,r){var i=[],n=e.$getObjectByIdMap(t.divisionList);return Object.getOwnPropertyNames(r).forEach(function(e){var t=r[e],o=n[e];o&&i.push({id:o.id,label:o.value,value:t})}),i},e.$extractResponseForGridQuestion=function(t,r){var i=[];if(!t.grid||!t.grid.rows)return i;var n=e.$getObjectByIdMap(t.grid.cols);return t.grid.rows.forEach(function(e){var t=r[e.id],o=null;t&&(o=n[t]);var s={row:{id:e.id,label:e.label},col:null};o&&(s.col={id:o.id,label:o.label}),i.push(s)}),i},e.extractResponse=function(t,r){return"text"==t.type||"textarea"==t.type?r.answer:"radio"==t.type||"checkbox"==t.type?e.$extractResponseForRadioOrCheckboxQuestion(t,r):"grid"==t.type?e.$extractResponseForGridQuestion(t,r):"priority"==t.type?e.$extractResponseForPriorityQuestion(t,r):"division"==t.type?e.$extractResponseForDivisionQuestion(t,r):null},e.mergeFormWithResponse=function(t,r){var i={};return angular.copy(t,i),i.pages.forEach(function(t){t.elements.forEach(function(t){var i=t.question;if(i){var n=r[i.id];n&&(i.response=e.extractResponse(i,n))}})}),i},e.getQuestionList=function(e,t){var r=[];return e.pages.forEach(function(e){e.elements.forEach(function(e){if(e.question){var i=e.question;t&&(i={},angular.copy(e.question,i)),r.push(i)}})}),r},e.getQuestionWithResponseList=function(t,r){var i=[];return e.getQuestionList(t,!0).forEach(function(t){var n=r[t.id];n?t.response=e.extractResponse(t,n):t.response=null,i.push(t)}),i},e.$$getHeader=function(e,t,r,i,n){var o="";return n&&((e||0===e)&&(o+=e+"."),(r||0===r)&&(o+=r+"."),o.length&&(o+=" ")),o+=t,i&&(o+=" ["+i+"]"),o},e.getResponseSheetHeaders=function(t,r){var i=[],n=0;return e.getQuestionList(t).forEach(function(t){n++;var o=1;if("text"==t.type||"textarea"==t.type||"radio"==t.type||"checkbox"==t.type)i.push(e.$$getHeader(n,t.text,null,null,r));else if("grid"==t.type){if(!t.grid)return;t.grid.rows.forEach(function(s){i.push(e.$$getHeader(n,t.text,o,s.label,r)),o++})}else if("priority"==t.type){if(!t.priorityList)return;t.priorityList.forEach(function(s){i.push(e.$$getHeader(n,t.text,o,s.value,r)),o++})}else if("division"==t.type){if(!t.divisionList)return;t.divisionList.forEach(function(s){i.push(e.$$getHeader(n,t.text,o,s.value,r)),o++})}}),i},e.getResponseSheetRow=function(t,r){var i="; ",n=[];if(!r)return n;for(var o=e.getQuestionWithResponseList(t,r),s=0;s