{!this.props.task ?
@@ -100,22 +130,18 @@ class BlocklyExample extends Component {
{`Reiche deine Blöcke ein, indem du auf den '${this.props.task ? 'Musterlösung einreichen' : 'Beispiel einreichen'}'-Button klickst.`}
: this.state.input ?
Die letzte Einreichung erfolgte um {this.state.input} Uhr. : null
: null}
+ {this.state.checked && !this.props.task ?
+
Anmerkung: Man kann den initialen Setup()- bzw. Endlosschleifen()-Block löschen. Zusätzlich ist es möglich u.a. nur einen beliebigen Block auszuwählen, ohne dass dieser als deaktiviert dargestellt wird.
+ : null}
{this.state.checked ? (() => {
- var initialXml = this.props.value;
- // check if value is valid xml;
- try{
- Blockly.Xml.textToDom(initialXml);
- }
- catch(err){
- initialXml = null;
- // this.props.setError(this.props.index, 'xml');
- }
- return (
+ return(
@@ -125,7 +151,8 @@ class BlocklyExample extends Component {
style={{marginTop: '5px', height: '40px'}}
variant='contained'
color='primary'
- onClick={() => {this.props.changeContent(this.props.index, 'xml', this.props.xml); this.setState({input: moment(Date.now()).format('LTS')})}}
+ disabled={this.state.disabled}
+ onClick={() => this.setXml()}
>
{this.props.task ? 'Musterlösung einreichen' : 'Beispiel einreichen'}
diff --git a/src/components/Tutorial/Builder/StepType.js b/src/components/Tutorial/Builder/StepType.js
index 910b2df..cf6d9ac 100644
--- a/src/components/Tutorial/Builder/StepType.js
+++ b/src/components/Tutorial/Builder/StepType.js
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
-import { changeContent } from '../../../actions/tutorialBuilderActions';
+import { changeContent, deleteProperty } from '../../../actions/tutorialBuilderActions';
import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
@@ -9,9 +9,15 @@ import FormControlLabel from '@material-ui/core/FormControlLabel';
class StepType extends Component {
+ onChange = (value) => {
+ this.props.changeContent(this.props.index, 'type', value);
+ // delete property 'xml', so that all used blocks are reset
+ this.props.deleteProperty(this.props.index, 'xml');
+ }
+
render() {
return (
- {this.props.changeContent(this.props.index, 'type', e.target.value)}}>
+ this.onChange(e.target.value)}>
}
@@ -31,7 +37,8 @@ class StepType extends Component {
}
StepType.propTypes = {
- changeContent: PropTypes.func.isRequired
+ changeContent: PropTypes.func.isRequired,
+ deleteProperty: PropTypes.func.isRequired
};
-export default connect(null, { changeContent })(StepType);
+export default connect(null, { changeContent, deleteProperty })(StepType);
diff --git a/src/components/Tutorial/Instruction.js b/src/components/Tutorial/Instruction.js
index a9858d7..739d798 100644
--- a/src/components/Tutorial/Instruction.js
+++ b/src/components/Tutorial/Instruction.js
@@ -28,6 +28,7 @@ class Instruction extends Component {
diff --git a/src/components/Tutorial/Tutorial.js b/src/components/Tutorial/Tutorial.js
index 1372ddb..f2a7bb7 100644
--- a/src/components/Tutorial/Tutorial.js
+++ b/src/components/Tutorial/Tutorial.js
@@ -42,7 +42,7 @@ class Tutorial extends Component {
var step = steps ? steps[this.props.activeStep] : null;
var name = step ? `${detectWhitespacesAndReturnReadableResult(tutorial.title)}_${detectWhitespacesAndReturnReadableResult(step.headline)}` : null;
return (
- !Number.isInteger(currentTutorialId) || currentTutorialId < 1 || currentTutorialId > tutorials.length ?
+ !Number.isInteger(currentTutorialId) || currentTutorialId < 1 || !tutorial ?
:
diff --git a/src/components/WorkspaceFunc.js b/src/components/WorkspaceFunc.js
index fd73a19..96f3cb4 100644
--- a/src/components/WorkspaceFunc.js
+++ b/src/components/WorkspaceFunc.js
@@ -125,7 +125,7 @@ class WorkspaceFunc extends Component {
this.state.file === 'xml' ? this.saveXmlFile() : this.getSvg()
}
else{
- this.setState({ saveFile: true, file: filetype, open: true, title: this.state.file === 'xml' ? 'Blöcke speichern' : 'Screenshot erstellen', content: `Bitte gib einen Namen für die Bennenung der ${this.state.file === 'xml' ? 'XML' : 'SVG'}-Datei ein und bestätige diesen mit einem Klick auf \'Eingabe\'.` });
+ this.setState({ saveFile: true, file: filetype, open: true, title: this.state.file === 'xml' ? 'Blöcke speichern' : 'Screenshot erstellen', content: `Bitte gib einen Namen für die Bennenung der ${this.state.file === 'xml' ? 'XML' : 'SVG'}-Datei ein und bestätige diesen mit einem Klick auf 'Eingabe'.` });
}
});
}