From 8d752e04304c8e2aa9cc145e90d7a4d90790c6fe Mon Sep 17 00:00:00 2001
From: Delucse <46593742+Delucse@users.noreply.github.com>
Date: Mon, 28 Sep 2020 15:41:17 +0200
Subject: [PATCH] precondition for each tutorial is at least one instruction
and one task
---
src/actions/tutorialBuilderActions.js | 9 ++++++---
src/components/Tutorial/Builder/Builder.js | 9 ++++++++-
src/components/Tutorial/Builder/Id.js | 2 +-
src/components/Tutorial/Builder/StepType.js | 10 +++++++---
4 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/src/actions/tutorialBuilderActions.js b/src/actions/tutorialBuilderActions.js
index e7f2c7a..f200cf0 100644
--- a/src/actions/tutorialBuilderActions.js
+++ b/src/actions/tutorialBuilderActions.js
@@ -169,7 +169,7 @@ export const setSubmitError = () => (dispatch, getState) => {
if(builder.id === undefined || builder.title === ''){
dispatch(setError(undefined, 'title'));
}
- builder.steps.map((step, i) => {
+ var type = builder.steps.map((step, i) => {
step.id = i+1;
if(i === 0){
if(step.requirements && step.requirements.length > 0){
@@ -195,15 +195,18 @@ export const setSubmitError = () => (dispatch, getState) => {
if(step.text === undefined || step.text === ''){
dispatch(setError(i, 'text'));
}
- return null;
+ return step.type;
});
+ if(!(type.filter(item => item === 'task').length > 0 && type.filter(item => item === 'instruction').length > 0)){
+ dispatch(setError(undefined, 'type'));
+ }
};
export const checkError = () => (dispatch, getState) => {
dispatch(setSubmitError());
var error = getState().builder.error;
- if(error.id || error.title){
+ if(error.id || error.title || error.type){
return true;
}
for(var i = 0; i < error.steps.length; i++){
diff --git a/src/components/Tutorial/Builder/Builder.js b/src/components/Tutorial/Builder/Builder.js
index 35f435a..1c6c819 100644
--- a/src/components/Tutorial/Builder/Builder.js
+++ b/src/components/Tutorial/Builder/Builder.js
@@ -19,11 +19,15 @@ import Button from '@material-ui/core/Button';
import Backdrop from '@material-ui/core/Backdrop';
import CircularProgress from '@material-ui/core/CircularProgress';
import Divider from '@material-ui/core/Divider';
+import FormHelperText from '@material-ui/core/FormHelperText';
const styles = (theme) => ({
backdrop: {
zIndex: theme.zIndex.drawer + 1,
color: '#fff',
+ },
+ errorColor: {
+ color: theme.palette.error.dark
}
});
@@ -138,9 +142,12 @@ class Builder extends Component {
-
+
{/*Tutorial-Builder-Form*/}
+ {this.props.error.type ?
+ {`Ein Tutorial muss mindestens jeweils eine Instruktion und eine Aufgabe enthalten.`}
+ : null}
diff --git a/src/components/Tutorial/Builder/Id.js b/src/components/Tutorial/Builder/Id.js
index f36bc70..08d8aab 100644
--- a/src/components/Tutorial/Builder/Id.js
+++ b/src/components/Tutorial/Builder/Id.js
@@ -58,7 +58,7 @@ class Id extends Component {
render() {
return (
-