adjustments do mongoDB output

This commit is contained in:
Delucse
2020-11-27 17:21:42 +01:00
parent 28720edeea
commit a2c571c1e7
9 changed files with 36 additions and 35 deletions
+3 -3
View File
@@ -25,10 +25,10 @@ class Assessment extends Component {
}
render() {
var tutorialId = this.props.tutorial.id;
var tutorialId = this.props.tutorial._id;
var currentTask = this.props.step;
var status = this.props.status.filter(status => status.id === tutorialId)[0];
var taskIndex = status.tasks.findIndex(task => task.id === currentTask.id);
var status = this.props.status.filter(status => status._id === tutorialId)[0];
var taskIndex = status.tasks.findIndex(task => task._id === currentTask._id);
var statusTask = status.tasks[taskIndex];
return (
+1 -1
View File
@@ -67,7 +67,7 @@ class Requirement extends Component {
{tutorialIds.map((tutorialId, i) => {
// title must be provided together with ids
// var title = tutorials.filter(tutorial => tutorial.id === tutorialId)[0].title;
var status = this.props.status.filter(status => status.id === tutorialId)[0];
var status = this.props.status.filter(status => status._id === tutorialId)[0];
var tasks = status.tasks;
var error = status.tasks.filter(task => task.type === 'error').length > 0;
var success = status.tasks.filter(task => task.type === 'success').length / tasks.length
+2 -2
View File
@@ -50,9 +50,9 @@ const styles = (theme) => ({
class StepperHorizontal extends Component {
render() {
var tutorialId = this.props.tutorial.id;
var tutorialId = this.props.tutorial._id;
var tutorialIndex = this.props.currentTutorialIndex;
var status = this.props.status.filter(status => status.id === tutorialId)[0];
var status = this.props.status.filter(status => status._id === tutorialId)[0];
var tasks = status.tasks;
var error = tasks.filter(task => task.type === 'error').length > 0;
var success = tasks.filter(task => task.type === 'success').length / tasks.length;
+4 -4
View File
@@ -61,7 +61,7 @@ class StepperVertical extends Component {
}
componentDidUpdate(props){
if (props.tutorial.id !== Number(this.props.match.params.tutorialId)) {
if (props.tutorial._id !== this.props.match.params.tutorialId) {
this.props.tutorialStep(0);
}
}
@@ -69,7 +69,7 @@ class StepperVertical extends Component {
render() {
var steps = this.props.steps;
var activeStep = this.props.activeStep;
var tutorialStatus = this.props.status.filter(status => status.id === this.props.tutorial.id)[0];
var tutorialStatus = this.props.status.filter(status => status._id === this.props.tutorial._id)[0];
return (
<div style={{marginRight: '10px'}}>
<Stepper
@@ -79,13 +79,13 @@ class StepperVertical extends Component {
classes={{root: this.props.classes.verticalStepper}}
>
{steps.map((step, i) => {
var tasksIndex = tutorialStatus.tasks.findIndex(task => task.id === step.id);
var tasksIndex = tutorialStatus.tasks.findIndex(task => task._id === step._id);
var taskType = tasksIndex > -1 ? tutorialStatus.tasks[tasksIndex].type : null;
var taskStatus = taskType === 'success' ? 'Success' : taskType === 'error' ? 'Error' : 'Other';
return (
<Step key={i}>
<Tooltip title={step.headline} placement='right' arrow >
<div style={i === activeStep ? {padding: '5px 0'} : {padding: '5px 0', cursor: 'pointer'}} onClick={i === activeStep ? null : () => {this.props.tutorialStep(i)}}>
<div style={i === activeStep ? {padding: '5px 0'} : {padding: '5px 0', cursor: 'pointer'}} onClick={i === activeStep ? null : () => {console.log(i); this.props.tutorialStep(i)}}>
<StepLabel
StepIconComponent={'div'}
classes={{
+2 -3
View File
@@ -26,7 +26,7 @@ class Tutorial extends Component {
}
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));
}
@@ -45,7 +45,6 @@ class Tutorial extends Component {
}
render() {
console.log(this.props.tutorial);
return (
<div>
{this.props.isLoading ? null :
@@ -57,7 +56,7 @@ class Tutorial extends Component {
var name = `${detectWhitespacesAndReturnReadableResult(tutorial.title)}_${detectWhitespacesAndReturnReadableResult(step.headline)}`;
return(
<div>
<Breadcrumbs content={[{ link: '/tutorial', title: 'Tutorial' }, { link: `/tutorial/${this.props.tutorial.id}`, title: tutorial.title }]} />
<Breadcrumbs content={[{ link: '/tutorial', title: 'Tutorial' }, { link: `/tutorial/${this.props.tutorial._id}`, title: tutorial.title }]} />
<StepperHorizontal />
+2 -2
View File
@@ -78,14 +78,14 @@ class TutorialHome extends Component {
<h1>Tutorial-Übersicht</h1>
<Grid container spacing={2}>
{this.props.tutorials.map((tutorial, i) => {
var status = this.props.status.filter(status => status.id === tutorial.id)[0];
var status = this.props.status.filter(status => status._id === tutorial._id)[0];
var tasks = status.tasks;
var error = status.tasks.filter(task => task.type === 'error').length > 0;
var success = status.tasks.filter(task => task.type === 'success').length / tasks.length
var tutorialStatus = success === 1 ? 'Success' : error ? 'Error' : 'Other';
return (
<Grid item xs={12} sm={6} md={4} xl={3} key={i} style={{}}>
<Link to={`/tutorial/${tutorial.id}`} style={{ textDecoration: 'none', color: 'inherit' }}>
<Link to={`/tutorial/${tutorial._id}`} style={{ textDecoration: 'none', color: 'inherit' }}>
<Paper style={{ height: '150px', padding: '10px', position: 'relative', overflow: 'hidden' }}>
{tutorial.title}
<div className={clsx(this.props.classes.outerDiv)} style={{ width: '160px', height: '160px', border: 0 }}>