diff --git a/source/engine/generateQuestions.js b/source/engine/generateQuestions.js index 1e43c77ef..42a653926 100644 --- a/source/engine/generateQuestions.js +++ b/source/engine/generateQuestions.js @@ -126,6 +126,15 @@ export let buildNextSteps = (allRules, analysedSituation) => { D'autres variables pourront être regroupées aussi, car elles partagent un parent, mais sans fusionner leurs questions dans l'interface. Ce sont des **groupes de type _record_ ** */ + // This is effectively a missingVariables.groupBy(questionRequired) + // but "questionRequired" does not have a clear specification + // we could look up "what formula is this variable mentioned in, and does it have a question attached" + // the problem is that we parse rules "bottom up", we would therefore need to: + // - parse rules top-down, i.e. analysedSituations = map(treatRuleRoot, rules) + // (might be a problem later on in terms of "big" rulesets, but not now) + // - decorate each rule with "mentions / depends on the following rules" + // - provide a "is mentioned by" query + return R.pipe( R.keys, R.curry(findVariantsAndRecords)(allRules), diff --git a/source/reducers.js b/source/reducers.js index b37e79986..58d9e3ca7 100644 --- a/source/reducers.js +++ b/source/reducers.js @@ -5,10 +5,20 @@ import reduceReducers from 'reduce-reducers' import {reducer as formReducer, formValueSelector} from 'redux-form' import {rules} from 'Engine/rules' -import {analyse, buildNextSteps, generateGridQuestions, generateSimpleQuestions} from 'Engine/generateQuestions' +import {buildNextSteps, generateGridQuestions, generateSimpleQuestions} from 'Engine/generateQuestions' import computeThemeColours from 'Components/themeColours' -import { EXPLAIN_VARIABLE, POINT_OUT_OBJECTIVES} from './actions' -import { STEP_ACTION, START_CONVERSATION} from './actions' +import { STEP_ACTION, START_CONVERSATION, EXPLAIN_VARIABLE, POINT_OUT_OBJECTIVES, CHANGE_THEME_COLOUR} from './actions' + +import {analyseSituation} from 'Engine/traverse' + +let situationGate = state => + name => formValueSelector('conversation')(state, name) + +let analyse = rootVariable => R.pipe( + situationGate, + // une liste des objectifs de la simulation (des 'rules' aussi nommées 'variables') + analyseSituation(rules, rootVariable) +) export let reduceSteps = (state, action) => { @@ -51,7 +61,7 @@ export let reduceSteps = (state, action) => { } function themeColours(state = computeThemeColours(), {type, colour}) { - if (type == 'CHANGE_THEME_COLOUR') + if (type == CHANGE_THEME_COLOUR) return computeThemeColours(colour) else return state }