diff --git a/src/actions/tutorialActions.js b/src/actions/tutorialActions.js index 31e3b6e..b741c3e 100644 --- a/src/actions/tutorialActions.js +++ b/src/actions/tutorialActions.js @@ -11,11 +11,8 @@ export const tutorialChange = () => (dispatch) => { export const tutorialCheck = (status, step) => (dispatch, getState) => { var tutorialsStatus = getState().tutorial.status; var id = getState().tutorial.currentId; - var activeStep = getState().tutorial.activeStep; - var steps = tutorials.filter(tutorial => tutorial.id === id)[0].steps; - var tasks = steps.filter(step => step.type === 'task'); - var tasksIndex = tasks.indexOf(steps[activeStep]); var tutorialsStatusIndex = tutorialsStatus.findIndex(tutorialStatus => tutorialStatus.id === id); + var tasksIndex = tutorialsStatus[tutorialsStatusIndex].tasks.findIndex(task => task.id === step.id); tutorialsStatus[tutorialsStatusIndex].tasks[tasksIndex] = { ...tutorialsStatus[tutorialsStatusIndex].tasks[tasksIndex], type: status @@ -34,9 +31,8 @@ export const storeTutorialXml = (code) => (dispatch, getState) => { var steps = tutorials.filter(tutorial => tutorial.id === id)[0].steps; if(steps[activeStep].type === 'task'){ var tutorialsStatus = getState().tutorial.status; - var tasks = steps.filter(step => step.type === 'task'); - var tasksIndex = tasks.indexOf(steps[activeStep]); var tutorialsStatusIndex = tutorialsStatus.findIndex(tutorialStatus => tutorialStatus.id === id); + var tasksIndex = tutorialsStatus[tutorialsStatusIndex].tasks.findIndex(task => task.id === steps[activeStep].id); tutorialsStatus[tutorialsStatusIndex].tasks[tasksIndex] = { ...tutorialsStatus[tutorialsStatusIndex].tasks[tasksIndex], xml: code diff --git a/src/components/Tutorial/Assessment.js b/src/components/Tutorial/Assessment.js index f15f79b..3e2db26 100644 --- a/src/components/Tutorial/Assessment.js +++ b/src/components/Tutorial/Assessment.js @@ -14,13 +14,11 @@ class Assessment extends Component { render() { var tutorialId = this.props.currentTutorialId; - var steps = this.props.steps; var currentTask = this.props.step; - var tasks = steps.filter(task => task.type === 'task'); - var taskIndex = tasks.indexOf(currentTask); var status = this.props.status.filter(status => status.id === tutorialId)[0]; - var statusTask = status.tasks[taskIndex] - + var taskIndex = status.tasks.findIndex(task => task.id === currentTask.id); + var statusTask = status.tasks[taskIndex]; + return (