Skip to content

Commit

Permalink
Refractor: Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jatin-narang committed Mar 3, 2019
1 parent 20a6225 commit 329d859
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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://<inet address>: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 <inet address>:Port number on which you are running the react app.

### Diagnosis

```
Expand Down
9 changes: 5 additions & 4 deletions client/src/pages/QuestionsAnsPage/QuestionsAnsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -95,9 +94,6 @@ export class QuestionsAnsPage extends React.Component {
this.handleNextClick();
this.handleClickOpen();
this.checkCorrectAnswer();
if (questionId === this.getTotalQuestions()) {
this.handleUpdateScore();
}
};

handleClick = () => {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions client/src/settings.js
Original file line number Diff line number Diff line change
@@ -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: '' };
}
Expand Down
8 changes: 4 additions & 4 deletions data/Module/moduleData.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
}
]
},
Expand All @@ -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 ]
}
]
}
Expand Down

0 comments on commit 329d859

Please sign in to comment.