From e7723487c9eb7c193f1f4ed40fe64fc0290e4a04 Mon Sep 17 00:00:00 2001 From: Delucse <46593742+Delucse@users.noreply.github.com> Date: Fri, 11 Sep 2020 17:47:05 +0200 Subject: [PATCH] next step button or tutorial-overview button after solving task --- src/components/Tutorial/SolutionCheck.js | 39 ++++--- src/components/Tutorial/TutorialBody.js | 128 ----------------------- 2 files changed, 27 insertions(+), 140 deletions(-) delete mode 100644 src/components/Tutorial/TutorialBody.js diff --git a/src/components/Tutorial/SolutionCheck.js b/src/components/Tutorial/SolutionCheck.js index 87f65cb..b012af2 100644 --- a/src/components/Tutorial/SolutionCheck.js +++ b/src/components/Tutorial/SolutionCheck.js @@ -1,7 +1,9 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; -import { tutorialCheck } from '../../actions/tutorialActions'; +import { tutorialCheck, tutorialStep } from '../../actions/tutorialActions'; + +import { withRouter } from 'react-router-dom'; import Compile from '../Compile'; @@ -55,6 +57,7 @@ class SolutionCheck extends Component { } render() { + const steps = tutorials.filter(tutorial => tutorial.id === this.props.currentTutorialId)[0].steps; return (
@@ -71,16 +74,27 @@ class SolutionCheck extends Component { {this.state.msg.text} {this.state.msg.type === 'success' ? -
- - +
+ + {this.props.activeStep === steps.length-1 ? + + : + + }
: null} @@ -98,6 +112,7 @@ class SolutionCheck extends Component { SolutionCheck.propTypes = { tutorialCheck: PropTypes.func.isRequired, + tutorialStep: PropTypes.func.isRequired, currentTutorialId: PropTypes.number, activeStep: PropTypes.number.isRequired, xml: PropTypes.string.isRequired @@ -109,4 +124,4 @@ const mapStateToProps = state => ({ xml: state.workspace.code.xml }); -export default connect(mapStateToProps, { tutorialCheck })(withStyles(styles, {withTheme: true})(SolutionCheck)); +export default connect(mapStateToProps, { tutorialCheck, tutorialStep })(withStyles(styles, {withTheme: true})(withRouter(SolutionCheck))); diff --git a/src/components/Tutorial/TutorialBody.js b/src/components/Tutorial/TutorialBody.js deleted file mode 100644 index f59cfd9..0000000 --- a/src/components/Tutorial/TutorialBody.js +++ /dev/null @@ -1,128 +0,0 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import { tutorialId, tutorialStep } from '../../actions/tutorialActions'; - -import Breadcrumbs from '../Breadcrumbs'; -import StepperHorizontal from './StepperHorizontal'; -import StepperVertical from './StepperVertical'; -import Instruction from './Instruction'; -import Assessment from './Assessment'; -import NotFound from '../NotFound'; - -import tutorials from './tutorials.json'; - -import withWidth, { isWidthUp } from '@material-ui/core/withWidth'; -import Card from '@material-ui/core/Card'; -import Button from '@material-ui/core/Button'; - -class Tutorial extends Component { - - componentDidMount(){ - this.props.tutorialId(Number(this.props.match.params.tutorialId)); - } - - componentDidUpdate(props, state){ - if(props.currentTutorialId !== Number(this.props.match.params.tutorialId)){ - this.props.tutorialId(Number(this.props.match.params.tutorialId)); - } - } - - componentWillUnmount(){ - this.props.tutorialId(null); - } - - render() { - var currentTutorialId = this.props.currentTutorialId; - var tutorial = tutorials.filter(tutorial => tutorial.id === currentTutorialId)[0]; - var step = tutorial.steps[this.props.activeStep]; - - const Tutorial2 = () => ( -
- - - - -
- - -
- {step.type === 'instruction' ? - - : } - -
- - -
-
-
-
- ); - return ( - !Number.isInteger(currentTutorialId) || currentTutorialId < 1 || currentTutorialId > tutorials.length ? - - : - - ); - }; -} - -Tutorial.propTypes = { - tutorialId: PropTypes.func.isRequired, - currentTutorialId: PropTypes.number, - status: PropTypes.array.isRequired, - change: PropTypes.number.isRequired, - activeStep: PropTypes.number.isRequired -}; - -const mapStateToProps = state => ({ - change: state.tutorial.change, - status: state.tutorial.status, - currentTutorialId: state.tutorial.currentId, - activeStep: state.tutorial.activeStep -}); - -export default connect(mapStateToProps, { tutorialId, tutorialStep })(withWidth()(Tutorial)); - - - -// -// - -// -// {/* width of vertical stepper is 30px*/} -// -// -// -// -// -// -//
-// {this.props.level === 'instruction' ? -// : null } -// {this.props.level === 'assessment' ? -// -// -// -// -// -// -// -// Hier könnte die Problemstellung stehen. -// -//
-// -//
-//
-//
-// : null } -//
-//
-//