diff --git a/src/components/courses/Course.js b/src/components/courses/Course.js index ebd9b29a..4f8234b1 100644 --- a/src/components/courses/Course.js +++ b/src/components/courses/Course.js @@ -3,13 +3,19 @@ import { Button, Grid, Icon, - Tooltip + Tooltip, + LinearProgress } from "@material-ui/core"; - /** * React component for navigating the course lessons and displaying lesson name and description */ class Lesson extends Component { + constructor(props) { + super(props); + this.state = { + currentProgress: 0 + }; + } /** * Load next lesson. Give a warning if there's any changes in the editor */ @@ -20,8 +26,8 @@ class Lesson extends Component { return; } this.props.courseActions.nextLesson(currentIndex, lessons[currentIndex + 1]); + this.setState({currentProgress: (((this.props.courses.currentIndex + 1) / (lessons.length - 1)) * 100)}); } - /** * Load previous lesson. Give a warning if there's any changes in the editor */ @@ -32,8 +38,8 @@ class Lesson extends Component { return; } this.props.courseActions.previousLesson(currentIndex, lessons[currentIndex - 1]); + this.setState({currentProgress: (((this.props.courses.currentIndex - 1) / (lessons.length - 1))*100)}); } - /** * Returns wheter the text in the editor match with the savedText * @returns {boolean} true if savedText is different from text in editor, false otherwise. @@ -43,17 +49,14 @@ class Lesson extends Component { try { let editor = window.ace.edit("ace-editor"); text = editor.getSession().getValue(); - } catch (err) { console.error(err); } - if (this.props.savedText === text) { return false; } return true; } - /** * @returns DOM Elements of button that go to previous or */ @@ -66,7 +69,9 @@ class Lesson extends Component {