checking the Blocks with the solution using the XML strings

This commit is contained in:
Delucse
2020-09-10 13:46:31 +02:00
parent f14508a5ca
commit ab016610bd
6 changed files with 102 additions and 8 deletions
+7 -3
View File
@@ -8,6 +8,7 @@ import * as Blockly from 'blockly/core';
import Compile from '../Compile';
import { tutorials } from './tutorials';
import { checkXml } from './compareXml';
import { withStyles } from '@material-ui/core/styles';
import IconButton from '@material-ui/core/IconButton';
@@ -49,7 +50,7 @@ class SolutionCheck extends Component {
check = () => {
const workspace = Blockly.getMainWorkspace();
var msg = tutorials[this.props.currentTutorialId].test(workspace);
var msg = checkXml(tutorials[this.props.currentTutorialId].solution, this.props.xml);
this.props.tutorialCheck(msg.type);
this.setState({ msg, open: true });
}
@@ -97,13 +98,16 @@ class SolutionCheck extends Component {
};
}
SolutionCheck.propTypes = {
tutorialCheck: PropTypes.func.isRequired,
currentTutorialId: PropTypes.number
currentTutorialId: PropTypes.number,
xml: PropTypes.string.isRequired
};
const mapStateToProps = state => ({
currentTutorialId: state.tutorial.currentId
currentTutorialId: state.tutorial.currentId,
xml: state.workspace.code.xml
});
export default connect(mapStateToProps, { tutorialCheck })(withStyles(styles, {withTheme: true})(SolutionCheck));