generate JSON-file
This commit is contained in:
		
							parent
							
								
									111b924988
								
							
						
					
					
						commit
						28ced177bd
					
				| @ -154,6 +154,7 @@ export const setSubmitError = () => (dispatch, getState) => { | ||||
|     dispatch(setError(undefined, 'title')); | ||||
|   } | ||||
|   for(var i = 0; i < builder.steps.length; i++){ | ||||
|     builder.steps[i].id = i+1; | ||||
|     if(i === 0 && builder.steps[i].hardware.length < 1){ | ||||
|       dispatch(setError(i, 'hardware')); | ||||
|     } | ||||
| @ -170,12 +171,12 @@ export const checkError = () => (dispatch, getState) => { | ||||
|   dispatch(setSubmitError()); | ||||
|   var error = getState().builder.error; | ||||
|   if(error.id || error.title){ | ||||
|     return false; | ||||
|     return true; | ||||
|   } | ||||
|   for(var i = 0; i < error.steps.length; i++){ | ||||
|     if(Object.keys(error.steps[i]).length > 0){ | ||||
|       return false | ||||
|       return true | ||||
|     } | ||||
|   } | ||||
|   return true; | ||||
|   return false; | ||||
| } | ||||
|  | ||||
| @ -4,7 +4,6 @@ import { connect } from 'react-redux'; | ||||
| import { workspaceName } from '../../actions/workspaceActions'; | ||||
| 
 | ||||
| import BlocklyWindow from '../Blockly/BlocklyWindow'; | ||||
| import SolutionCheck from './SolutionCheck'; | ||||
| import CodeViewer from '../CodeViewer'; | ||||
| import WorkspaceFunc from '../WorkspaceFunc'; | ||||
| 
 | ||||
| @ -45,7 +44,7 @@ class Assessment extends Component { | ||||
|           <Grid item xs={12} md={6} lg={4} style={isWidthDown('sm', this.props.width) ? {height: 'max-content'} : {}}> | ||||
|             <Card style={{height: 'calc(50% - 30px)', padding: '10px', marginBottom: '10px'}}> | ||||
|               <Typography variant='h5'>Arbeitsauftrag</Typography> | ||||
|               <Typography>{currentTask.text1}</Typography> | ||||
|               <Typography>{currentTask.text}</Typography> | ||||
|             </Card> | ||||
|             <div style={isWidthDown('sm', this.props.width) ? {height: '500px'} : {height: '50%'}}> | ||||
|               <CodeViewer /> | ||||
|  | ||||
| @ -3,6 +3,10 @@ import PropTypes from 'prop-types'; | ||||
| import { connect } from 'react-redux'; | ||||
| import { checkError } from '../../../actions/tutorialBuilderActions'; | ||||
| 
 | ||||
| import { saveAs } from 'file-saver'; | ||||
| 
 | ||||
| import { detectWhitespacesAndReturnReadableResult } from '../../../helpers/whitespace'; | ||||
| 
 | ||||
| import Breadcrumbs from '../../Breadcrumbs'; | ||||
| import Id from './Id'; | ||||
| import Title from './Textfield'; | ||||
| @ -12,6 +16,22 @@ import Button from '@material-ui/core/Button'; | ||||
| 
 | ||||
| class Builder extends Component { | ||||
| 
 | ||||
|   submit = () => { | ||||
|     var isError = this.props.checkError(); | ||||
|     if(isError){ | ||||
|       alert('Error'); | ||||
|     } | ||||
|     else{ | ||||
|       var tutorial = { | ||||
|         id: this.props.id, | ||||
|         title: this.props.title, | ||||
|         steps: this.props.steps | ||||
|       } | ||||
|       var blob = new Blob([JSON.stringify(tutorial)], { type: 'text/json' }); | ||||
|       saveAs(blob, `${detectWhitespacesAndReturnReadableResult(tutorial.title)}.json`); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|   render() { | ||||
|     return ( | ||||
| @ -29,7 +49,7 @@ class Builder extends Component { | ||||
|         )} | ||||
| 
 | ||||
| 
 | ||||
|         <Button variant='contained' color='primary' onClick={() => {var error = this.props.checkError(); alert(error);}}>Tutorial-Vorlage erstellen</Button> | ||||
|         <Button variant='contained' color='primary' onClick={() => this.submit()}>Tutorial-Vorlage erstellen</Button> | ||||
| 
 | ||||
| 
 | ||||
|       </div> | ||||
|  | ||||
| @ -18,7 +18,7 @@ class Instruction extends Component { | ||||
|     return ( | ||||
|       <div> | ||||
|         <Typography variant='h4' style={{marginBottom: '5px'}}>{step.headline}</Typography> | ||||
|         <Typography style={isHardware ? {} : {marginBottom: '5px'}}>{step.text1}</Typography> | ||||
|         <Typography style={isHardware ? {} : {marginBottom: '5px'}}>{step.text}</Typography> | ||||
|         {isHardware ? | ||||
|           <Hardware picture={step.hardware}/> : null} | ||||
|         {areRequirements > 0 ? | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user