From f3a8dccd06c170510b29d70255a60cdeccc97877 Mon Sep 17 00:00:00 2001
From: Roosted7 <thomasroos@live.nl>
Date: Tue, 1 May 2018 16:32:40 +0200
Subject: [PATCH] Fix exam unable to change bug

---
 client/index.jsx      | 2 +-
 client/views/Exam.jsx | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/client/index.jsx b/client/index.jsx
index 7e7c9dee6..f68e6f890 100644
--- a/client/index.jsx
+++ b/client/index.jsx
@@ -119,7 +119,7 @@ class App extends React.Component {
                     <Switch>
                         <Route exact path="/" component={Home} />
                         <Route path="/exams/:examID" render={({match}) => 
-                            <Exam exam={exam} urlID={match.params.examID} changeExam={this.changeExam} updateSubmission={this.updateSubmission}/> }/>
+                            <Exam exam={exam} urlID={match.params.examID} updateExam={this.updateExam} updateSubmission={this.updateSubmission}/> }/>
                         <Route path="/exams" render={({history}) => 
                             <AddExam updateExamList={() => this.menu.current.updateExamList()} changeURL={history.push} /> }/>
                         <Route path="/students" render={() => 
diff --git a/client/views/Exam.jsx b/client/views/Exam.jsx
index 86d6e4f56..a85f415c0 100644
--- a/client/views/Exam.jsx
+++ b/client/views/Exam.jsx
@@ -31,7 +31,8 @@ class Exams extends React.Component {
 
     state = {
         yaml: "",
-        pdfs: []
+        pdfs: [],
+        examID: null
     };
 
     putYaml = () => {
@@ -97,6 +98,7 @@ class Exams extends React.Component {
     }
     componentDidUpdate = (prevProps) => {
         if (prevProps.exam.id != this.props.exam.id) this.updatePDFs()
+        if (prevProps.urlID !== this.props.urlID) this.props.updateExam(this.props.urlID)
     }
 
     componentWillUnmount = () => {
-- 
GitLab