name of tutorial workspace is automatically derived from the tutorial title and the step heading

This commit is contained in:
Delucse
2020-09-17 12:56:43 +02:00
parent 5c43ff4648
commit c85c96468c
4 changed files with 38 additions and 5 deletions
+16 -2
View File
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { workspaceName } from '../../actions/workspaceActions';
import BlocklyWindow from '../Blockly/BlocklyWindow';
import SolutionCheck from './SolutionCheck';
@@ -14,6 +15,18 @@ import Typography from '@material-ui/core/Typography';
class Assessment extends Component {
componentDidMount(){
// alert(this.props.name);
this.props.workspaceName(this.props.name);
}
componentDidUpdate(props){
if(props.name !== this.props.name){
// alert(this.props.name);
this.props.workspaceName(this.props.name);
}
}
render() {
var tutorialId = this.props.currentTutorialId;
var currentTask = this.props.step;
@@ -47,7 +60,8 @@ class Assessment extends Component {
Assessment.propTypes = {
currentTutorialId: PropTypes.number,
status: PropTypes.array.isRequired,
change: PropTypes.number.isRequired
change: PropTypes.number.isRequired,
workspaceName: PropTypes.func.isRequired
};
const mapStateToProps = state => ({
@@ -56,4 +70,4 @@ const mapStateToProps = state => ({
currentTutorialId: state.tutorial.currentId
});
export default connect(mapStateToProps, null)(withWidth()(Assessment));
export default connect(mapStateToProps, { workspaceName })(withWidth()(Assessment));