-
Notifications
You must be signed in to change notification settings - Fork 0
/
Question7.js
142 lines (90 loc) · 3.02 KB
/
Question7.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import React, { Component } from "react";
import { PageHeader, ListGroup } from "react-bootstrap";
import AnswerOption from './AnswerOptions';
import "./Home.css";
const url = 'http://localhost:8085/qbank/qas/6'
export default class Question7 extends Component {
constructor(props) {
super(props);
this.state = {
error: null,
isLoaded: false,
selectedRadio: 'public',
QuestionAnswer: []
};
}
componentDidMount() {
fetch(url)
.then((response) => {
console.log(response);
return response.json();
})
.then((json) => {
this.setState({
qid: json.qid,
qtext: json.qtext,
point: json.marks,
ans: json.answer,
choices:json.options
});
});
}
// Note: it's important to handle errors here
// instead of a catch() block so that we don't swallow
// exceptions from actual bugs in components.
handleNext = (e) => {
e.preventDefault();
this.props.history.push('/question8')
}
handlePrevious = (e) => {
e.preventDefault();
this.props.history.push('/question6')
}
render() {
const { qid , qtext,point, ans ,choices} = this.state;
const replies = this.state.choices;
//const listItems = replies.map((number) =>
// {number}
//);
var names = this.state.choices;
return (
<div className="q2">
<div className="labels">
<label for="test">{this.state.qid} {this.state.qtext}</label>
</div>
<div>
<input type="radio" value="Srilanka"
checked={this.state.selectedOption === 'Srilanka'}
onChange={this.handleOptionChange} />
Srilanka
</div>
<div>
<input type="radio" value="Australia"
checked={this.state.selectedOption === 'Australia'}
onChange={this.handleOptionChange} />
Australia
</div>
<div>
<input type="radio" value="Asia"
checked={this.state.selectedOption === 'Asia'}
onChange={this.handleOptionChange} />
Asia
</div>
<div>
<input type="radio" value="Antartica"
checked={this.state.selectedOption === 'Antartica'}
onChange={this.handleOptionChange} />
Antartica
</div>
<div className="Navigation">
<button type="submit" className="btn btn-primary" onClick={this.handleNext} >
Next
</button>
<button type="submit" className="btn btn-primary" onClick={this.handlePrevious} >
Previous
</button>
</div>
</div>
);
}
}