commit
733290be22
|
@ -14,6 +14,7 @@ import './Simulateur.css'
|
|||
import {capitalise0} from '../utils'
|
||||
import Conversation from './conversation/Conversation'
|
||||
|
||||
import ReactPiwik from 'react-piwik';
|
||||
|
||||
let situationSelector = formValueSelector('conversation')
|
||||
|
||||
|
@ -62,6 +63,7 @@ export default class extends React.Component {
|
|||
sim = path =>
|
||||
R.path(R.unless(R.is(Array), R.of)(path))(this.rule.simulateur || {}),
|
||||
reinitalise = () => {
|
||||
ReactPiwik.push(['trackEvent', 'restart', '']);
|
||||
this.props.resetForm(this.name)
|
||||
this.props.startConversation(this.name)
|
||||
},
|
||||
|
|
|
@ -62,15 +62,19 @@ export let reduceSteps = (state, action) => {
|
|||
ReactPiwik.push(['trackEvent', 'answer', action.step+": "+situationGate(action.step)]);
|
||||
|
||||
let foldedSteps = [...state.foldedSteps, R.head(state.unfoldedSteps)],
|
||||
unfoldedSteps = buildNextSteps(situationGate, flatRules, newState.analysedSituation)
|
||||
unfoldedSteps = buildNextSteps(situationGate, flatRules, newState.analysedSituation),
|
||||
assumptionsMade = !R.isEmpty(softAssumptions),
|
||||
done = unfoldedSteps.length == 0
|
||||
|
||||
// The simulation is "over" - except we can now fill in extra questions
|
||||
// where the answers were previously given default reasonable assumptions
|
||||
if (unfoldedSteps.length == 0 && !R.isEmpty(softAssumptions)) {
|
||||
if (done && assumptionsMade) {
|
||||
let newSituation = intermediateSituation(state),
|
||||
reanalyse = analyseTopDown(flatRules,rootVariable)(newSituation),
|
||||
extraSteps = buildNextSteps(newSituation, flatRules, reanalyse)
|
||||
|
||||
ReactPiwik.push(['trackEvent', 'done', 'extra questions: '+extraSteps.length]);
|
||||
|
||||
return {
|
||||
...newState,
|
||||
foldedSteps,
|
||||
|
@ -79,6 +83,10 @@ export let reduceSteps = (state, action) => {
|
|||
}
|
||||
}
|
||||
|
||||
if (done) {
|
||||
ReactPiwik.push(['trackEvent', 'done', 'no more questions']);
|
||||
}
|
||||
|
||||
return {
|
||||
...newState,
|
||||
foldedSteps,
|
||||
|
|
Loading…
Reference in New Issue