From 2d29b8d7bd64e2e0f2b6b2861b48fc3501ceb9e1 Mon Sep 17 00:00:00 2001
From: Delucse <46593742+Delucse@users.noreply.github.com>
Date: Fri, 27 Nov 2020 13:31:03 +0100
Subject: [PATCH 1/2] load tutorial only once
---
src/actions/tutorialActions.js | 6 ++++--
src/components/Tutorial/Tutorial.js | 9 +++------
src/components/Tutorial/TutorialHome.js | 1 -
src/data/tutorials.js | 22 +++++++++++-----------
4 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/src/actions/tutorialActions.js b/src/actions/tutorialActions.js
index 58e67d4..0358d5f 100644
--- a/src/actions/tutorialActions.js
+++ b/src/actions/tutorialActions.js
@@ -18,13 +18,14 @@ export const getTutorial = (id) => (dispatch, getState) => {
type: GET_TUTORIAL,
payload: tutorial
});
+ dispatch(returnSuccess(res.data.message, res.status));
});
})
.catch(err => {
- dispatch({type: TUTORIAL_PROGRESS});
if(err.response){
dispatch(returnErrors(err.response.data.message, err.response.status, 'GET_TUTORIAL_FAIL'));
}
+ dispatch({type: TUTORIAL_PROGRESS});
});
};
@@ -43,13 +44,14 @@ export const getTutorials = () => (dispatch, getState) => {
payload: tutorials
});
dispatch({type: TUTORIAL_PROGRESS});
+ dispatch(returnSuccess(res.data.message, res.status));
});
})
.catch(err => {
- dispatch({type: TUTORIAL_PROGRESS});
if(err.response){
dispatch(returnErrors(err.response.data.message, err.response.status, 'GET_TUTORIALS_FAIL'));
}
+ dispatch({type: TUTORIAL_PROGRESS});
});
};
diff --git a/src/components/Tutorial/Tutorial.js b/src/components/Tutorial/Tutorial.js
index 784d2a4..e524f6d 100644
--- a/src/components/Tutorial/Tutorial.js
+++ b/src/components/Tutorial/Tutorial.js
@@ -22,17 +22,14 @@ class Tutorial extends Component {
componentDidMount() {
this.props.getTutorial(this.props.match.params.tutorialId);
- // this.props.tutorialId(Number(this.props.match.params.tutorialId));
}
componentDidUpdate(props, state) {
- if (props.tutorial && props.tutorial.id && !props.isLoading && Number(props.tutorial.id) !== Number(this.props.match.params.tutorialId)) {
+ if(this.props.tutorial && !this.props.isLoading && this.props.tutorial.id != this.props.match.params.tutorialId) {
this.props.getTutorial(this.props.match.params.tutorialId);
- // this.props.tutorialId(Number(this.props.match.params.tutorialId));
}
if(this.props.message.id === 'GET_TUTORIAL_FAIL'){
alert(this.props.message.msg);
- this.props.clearMessages();
}
}
@@ -45,11 +42,11 @@ class Tutorial extends Component {
}
render() {
- console.log(this.props.tutorial);
return (
{this.props.isLoading ? null :
- !this.props.tutorial ?
+ !this.props.tutorial ?
+ this.props.message.id === 'GET_TUTORIAL_FAIL' ?
: null
: (() => {
var tutorial = this.props.tutorial;
var steps = this.props.tutorial.steps;
diff --git a/src/components/Tutorial/TutorialHome.js b/src/components/Tutorial/TutorialHome.js
index b010e2f..80fd35b 100644
--- a/src/components/Tutorial/TutorialHome.js
+++ b/src/components/Tutorial/TutorialHome.js
@@ -58,7 +58,6 @@ class TutorialHome extends Component {
componentDidUpdate(props, state) {
if(this.props.message.id === 'GET_TUTORIALS_FAIL'){
alert(this.props.message.msg);
- this.props.clearMessages();
}
}
diff --git a/src/data/tutorials.js b/src/data/tutorials.js
index 21dc6ca..5857167 100644
--- a/src/data/tutorials.js
+++ b/src/data/tutorials.js
@@ -1,11 +1,11 @@
-let tutorials = [
- require('./tutorial/ErsteSchritte.json'),
- require('./tutorial/Schleifen.json'),
- require('./tutorial/Wenn-DannBedingungen.json'),
- require('./tutorial/VerwendungVonVariablen.json'),
- require('./tutorial/SendenVonMesswertenUeberLoRa.json'),
- require('./tutorial/AnzeigeVonMesswertenAufDemDisplay.json'),
- require('./tutorial/MesswerteAnDieOpenSenseMapSenden.json')
-]
-
-module.exports = tutorials;
+// let tutorials = [
+// require('./tutorial/ErsteSchritte.json'),
+// require('./tutorial/Schleifen.json'),
+// require('./tutorial/Wenn-DannBedingungen.json'),
+// require('./tutorial/VerwendungVonVariablen.json'),
+// require('./tutorial/SendenVonMesswertenUeberLoRa.json'),
+// require('./tutorial/AnzeigeVonMesswertenAufDemDisplay.json'),
+// require('./tutorial/MesswerteAnDieOpenSenseMapSenden.json')
+// ]
+//
+// module.exports = tutorials;
From 47f0ebb80dc8c6db5dacf79c6d1ccc2bcddc2d75 Mon Sep 17 00:00:00 2001
From: Delucse <46593742+Delucse@users.noreply.github.com>
Date: Tue, 1 Dec 2020 14:37:32 +0100
Subject: [PATCH 2/2] restriction of workspace functions in context tutorials
---
src/components/Tutorial/Assessment.js | 2 +-
src/components/WorkspaceFunc.js | 86 ++++++++++++++-------------
2 files changed, 47 insertions(+), 41 deletions(-)
diff --git a/src/components/Tutorial/Assessment.js b/src/components/Tutorial/Assessment.js
index 3f62941..19fea9b 100644
--- a/src/components/Tutorial/Assessment.js
+++ b/src/components/Tutorial/Assessment.js
@@ -34,7 +34,7 @@ class Assessment extends Component {
return (
{currentTask.headline}
-
+
- {!this.props.solutionCheck ?
+ {!this.props.assessment ?
{ this.setState({ file: true, open: true, saveFile: false, title: 'Projekt benennen', content: 'Bitte gib einen Namen für das Projekt ein und bestätige diesen mit einem Klick auf \'Eingabe\'.' }) }}>
{this.props.name && !isWidthDown('xs', this.props.width) ? {this.props.name} : null}
@@ -266,7 +266,7 @@ class WorkspaceFunc extends Component {
: null}
- {this.props.solutionCheck ? : }
+ {this.props.assessment ? : }
-
-
{ this.uploadXmlFile(e.target.files[0]) }}
- id="open-blocks"
- type="file"
- />
-
-
-
-
-
-
-
-
-
- { this.createFileName('svg'); }}
- >
-
-
-
+ {!this.props.assessment?
+
+
{ this.uploadXmlFile(e.target.files[0]) }}
+ id="open-blocks"
+ type="file"
+ />
+
+
+
+
+
+
+
+
+ : null}
+ {!this.props.assessment?
+
+ { this.createFileName('svg'); }}
+ >
+
+
+
+ : null}
-
- this.shareBlocks()}
- >
-
-
-
+ {!this.props.assessment?
+
+ this.shareBlocks()}
+ >
+
+
+
+ :null}
Dein Link wurde erstellt.