"
);
-
+
//removing random unit separator chars
contents = contents.replace(//g, "");
// add the HTML/HEAD/BODY tags...
document.getElementById(divId).innerHTML =/*html*/
- contents +
+ contents +
`
@@ -722,10 +722,10 @@ transform.render = async (obj, divId, previousResults = {}) => {
const response = await retrieve();
if (response.code === 200) {
const userData = response.data;
- console.log("retrieve module name===",moduleParams.questName);
+ console.log("retrieve module name===", moduleParams.questName);
if (userData[moduleParams.questName]) {
questObj = userData[moduleParams.questName];
- console.log("questObj===",questObj);
+ console.log("questObj===", questObj);
await restoreResults(questObj);
}
}
@@ -869,12 +869,12 @@ transform.render = async (obj, divId, previousResults = {}) => {
// });
document.getElementById("submitModalButton").onclick = () => {
- let lastBackButton =document.getElementById('lastBackButton');
- if (lastBackButton){
+ let lastBackButton = document.getElementById('lastBackButton');
+ if (lastBackButton) {
lastBackButton.remove();
}
- let submitButton =document.getElementById('submitButton');
- if (submitButton){
+ let submitButton = document.getElementById('submitButton');
+ if (submitButton) {
submitButton.remove();
}
submitQuestionnaire(moduleParams.renderObj.store, questName);
@@ -913,6 +913,14 @@ function unrollLoops(txt) {
disIfIDs = disIfIDs.map((x) => x.id);
let newIds = ids.map((x) => x.id);
+ // find all ids defined within the loop,
+ // note: textboxes are an outlier that needs
+ // to be fixed.
+ let idsInLoop = Array.from(x.txt.matchAll(/\|[\w\s=]*id=(\w+)|___\|\s*(\w+)|textbox:\s*(\w+)/g)).map(x => {
+ return x[1] ? x[1] : (x[2] ? x[2] : x[3])
+ })
+ console.log(idsInLoop)
+
// goto from 1-> max for human consumption... need <=
let loopText = "";
for (var loopIndx = 1; loopIndx <= x.cnt; loopIndx++) {
@@ -920,18 +928,25 @@ function unrollLoops(txt) {
// replace all instances of the question ids with id_#
ids.map(
(id) =>
- (currentText = currentText.replace(
- new RegExp("\\b" + id.id + "\\b", "g"),
- `${id.id}_${loopIndx}`
- ))
+ (currentText = currentText.replace(
+ new RegExp("\\b" + id.id + "\\b", "g"),
+ `${id.id}_${loopIndx}`
+ ))
);
ids.map(
(id) =>
- (currentText = currentText.replace(
- new RegExp("\\b" + id.id + "_", "g"),
- `${id.id}_${loopIndx}_`
- ))
+ (currentText = currentText.replace(
+ new RegExp("\\b" + id.id + "_", "g"),
+ `${id.id}_${loopIndx}_`
+ ))
);
+
+ //replace all idsInLoop in the loop with {$id_$loopIndx}
+ idsInLoop.forEach(id => {
+ currentText = currentText.replace(new RegExp(`${id}`, "g"), `${id}_${loopIndx}`);
+ })
+
+
// ids.map((id) => (currentText = currentText.replace(id.label, id.label.replace(id.id, id.id + "_" + loopIndx))));
// disIfIDs = disIfIDs.filter((x) => newIds.includes(x));