From 329d859dad8a9ebdd77a6842bc0b0a19b07dcebd Mon Sep 17 00:00:00 2001 From: jnarang Date: Sun, 3 Mar 2019 11:15:49 +0530 Subject: [PATCH 1/2] Refractor: Update readme.md --- README.md | 26 +++++++++++++++++++ .../QuestionsAnsPage/QuestionsAnsPage.js | 9 ++++--- client/src/settings.js | 4 +-- data/Module/moduleData.json | 8 +++--- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9038728..cadbf9b 100755 --- a/README.md +++ b/README.md @@ -77,6 +77,32 @@ $ nodemon server/server.js ``` + + ### Test localhost app on mobile device + To run the localhost app on your mobile you need to be connected with same wifi network, once you are connected you can run following command: + ``` + $ HOST=0.0.0.0 npm start + + ``` + + + It will run the react app but data won't load unless you change some configuration in settings.js. + + + In settings.js you will find "config = { baseUrl: 'http://localhost:9000' };", you need to replace 'localhost' with your inet address. + + Example: config = { baseUrl: 'http://:9000' }; + + To check you inet address open your terminal and run ifconfig and check for inet address. + + Example: inet addr:192.168.1.22 + + inet addr:192.168.1.10 + + To open this react app on mobile : + + Open your browser and type :Port number on which you are running the react app. + ### Diagnosis ``` diff --git a/client/src/pages/QuestionsAnsPage/QuestionsAnsPage.js b/client/src/pages/QuestionsAnsPage/QuestionsAnsPage.js index d26056b..a38dd94 100644 --- a/client/src/pages/QuestionsAnsPage/QuestionsAnsPage.js +++ b/client/src/pages/QuestionsAnsPage/QuestionsAnsPage.js @@ -84,7 +84,6 @@ export class QuestionsAnsPage extends React.Component { //Handle proceed button click, answer-info dialog box rendering, option click and check for correctAns handleProceedNext = () => { - const { questionId } = this.state; this.setState((prevState) => ({ showAnswer: !prevState.showAnswer, selectedCard: null, @@ -95,9 +94,6 @@ export class QuestionsAnsPage extends React.Component { this.handleNextClick(); this.handleClickOpen(); this.checkCorrectAnswer(); - if (questionId === this.getTotalQuestions()) { - this.handleUpdateScore(); - } }; handleClick = () => { @@ -150,6 +146,11 @@ export class QuestionsAnsPage extends React.Component { //Hide AnswerInfo popup and show the points scored and also checks for parScoreStatus. handleClose = () => { this.checkParScoreStatus(); + const { questionId } = this.state; + if (questionId === this.getTotalQuestions()) { + this.handleUpdateScore(); + } + this.setState((prevState) => ({ open: false, showAnswer: !prevState.showAnswer diff --git a/client/src/settings.js b/client/src/settings.js index 64438df..e9271a5 100644 --- a/client/src/settings.js +++ b/client/src/settings.js @@ -1,9 +1,9 @@ let config = {}; if (process.env.NODE_ENV === 'development') { - // config = { baseUrl: 'http://localhost:9000' }; + config = { baseUrl: 'http://localhost:9000' }; // 192.168.13.86 is ip of network you are connected to change it with your ip address. - config = { baseUrl: 'http://192.168.13.86:9000' }; + // config = { baseUrl: 'http://192.168.13.86:9000' }; } else if (process.env.NODE_ENV === 'production') { config = { baseUrl: '' }; } diff --git a/data/Module/moduleData.json b/data/Module/moduleData.json index e47baf2..659fa64 100644 --- a/data/Module/moduleData.json +++ b/data/Module/moduleData.json @@ -228,13 +228,13 @@ "id": 1, "question": "level2 question1", "options": [ "level2 A", "level2 B", "level2 C", "level2 D" ], - "correct_answer": [ 0, 1 ] + "correct_answer": [ 0 ] }, { "id": 2, "question": "level2 question2", "options": [ "level2 X", "level2 Y", "level2 Z", "level2 A" ], - "correct_answer": [ 0, 1 ] + "correct_answer": [ 0 ] } ] }, @@ -250,13 +250,13 @@ "id": 1, "question": "level3 question1", "options": [ "level3 A", "level3 B", "level3 C", "level3 D" ], - "correct_answer": [ 0, 1 ] + "correct_answer": [ 0 ] }, { "id": 2, "question": "level3 question2", "options": [ "level3 X", "level3 Y", "level3 Z", "level3 A" ], - "correct_answer": [ 0, 1 ] + "correct_answer": [ 0 ] } ] } From 61a4233cda7ae3a175877c18b37df20e56c2064a Mon Sep 17 00:00:00 2001 From: jnarang Date: Sun, 3 Mar 2019 11:19:09 +0530 Subject: [PATCH 2/2] Refractor: Update readme.md --- README.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cadbf9b..abc10e8 100755 --- a/README.md +++ b/README.md @@ -79,9 +79,18 @@ ``` ### Test localhost app on mobile device - To run the localhost app on your mobile you need to be connected with same wifi network, once you are connected you can run following command: + To run the localhost app on your mobile you need to be connected with same wifi network and you need to check your inet address. + + To check you inet address open your terminal and run " $ ifconfig " and check for inet address. + + Example: inet addr:192.168.1.22 + + inet addr:192.168.1.10 + + + Once you are connected you can run following command: ``` - $ HOST=0.0.0.0 npm start + $ HOST=:Port Number npm start ``` @@ -93,12 +102,7 @@ Example: config = { baseUrl: 'http://:9000' }; - To check you inet address open your terminal and run ifconfig and check for inet address. - - Example: inet addr:192.168.1.22 - inet addr:192.168.1.10 - To open this react app on mobile : Open your browser and type :Port number on which you are running the react app.