Skip to content

Commit

Permalink
Dev scope loop starts with external element (#713)
Browse files Browse the repository at this point in the history
* manage variables of loops starting with external-element

* update version

* add clg to understand loss of Scope

* allow temporary clg

* remove console.log

* Update package.json
  • Loading branch information
BulotF authored Jan 2, 2024
1 parent 41f2323 commit d18ae76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 36 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pogues",
"version": "1.5.4",
"version": "1.5.5-rc3",
"description": "Outil de conception et de test de questionnaires.",
"repository": {
"type": "git",
Expand Down
52 changes: 17 additions & 35 deletions src/model/transformations/collected-variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
} from 'constants/pogues-constants';

const { COLLECTED } = VARIABLES_TYPES;
const { QUESTION, SEQUENCE, SUBSEQUENCE, LOOP } = COMPONENT_TYPE;
const { QUESTION, SEQUENCE, SUBSEQUENCE, LOOP, EXTERNAL_ELEMENT } =
COMPONENT_TYPE;
const { TABLE, MULTIPLE_CHOICE } = QUESTION_TYPE_ENUM;
const { LIST } = DIMENSION_FORMATS;

Expand Down Expand Up @@ -185,37 +186,25 @@ function findQuestionInLoop(componentsStore) {
.forEach(component => {
let LoopQuestions = [];
if (componentsStore[component.initialMember]) {
if (componentsStore[component.initialMember].type === SEQUENCE) {
if (
componentsStore[component.initialMember].weight !==
componentsStore[component.finalMember].weight
if (
componentsStore[component.initialMember].type === SEQUENCE ||
componentsStore[component.initialMember].type === EXTERNAL_ELEMENT
) {
for (
let i = componentsStore[component.initialMember].weight;
i <= componentsStore[component.finalMember].weight;
i++
) {
for (
let i = componentsStore[component.initialMember].weight;
i <= componentsStore[component.finalMember].weight;
i++
) {
const sequence = Object.values(componentsStore).find(
element => element.type === SEQUENCE && element.weight === i,
const sequence = Object.values(componentsStore).find(
element => element.type === SEQUENCE && element.weight === i,
);
if (sequence) {
LoopQuestions = LoopQuestions.concat(
getQuestionFromSequence(componentsStore, sequence.id),
);
if (sequence) {
LoopQuestions = LoopQuestions.concat(
getQuestionFromSequence(componentsStore, sequence.id),
);
}
}
} else {
LoopQuestions = LoopQuestions.concat(
getQuestionFromSequence(
componentsStore,
componentsStore[component.initialMember].id,
),
);
}
} else if (
componentsStore[component.initialMember].weight !==
componentsStore[component.finalMember].weight
) {
} else {
for (
let i = componentsStore[component.initialMember].weight;
i <= componentsStore[component.finalMember].weight;
Expand All @@ -234,13 +223,6 @@ function findQuestionInLoop(componentsStore) {
);
}
}
} else {
LoopQuestions = LoopQuestions.concat(
getQuestionFromSubSequence(
componentsStore,
componentsStore[component.initialMember].id,
),
);
}
}

Expand Down

0 comments on commit d18ae76

Please sign in to comment.