@@ -64,7 +64,7 @@ export default class QuizStudentPage extends Component {
64
64
this . props . currentQuiz
65
65
) {
66
66
console . log ( 'Quiz has come to the foreground!' ) ;
67
-
67
+
68
68
this . setState ( { opens : this . state . opens + 1 } ) ;
69
69
console . log ( this . state . opens ) ;
70
70
}
@@ -127,68 +127,74 @@ export default class QuizStudentPage extends Component {
127
127
this . setState ( {
128
128
error : null ,
129
129
} ) ;
130
- Toast . show ( 'Answer has been recorded!' ) ;
131
- const kbcresponse = new QuizResponses ( ) ;
132
- const timestamp = moment
133
- . utc ( database ( ) . getServerTime ( ) )
134
- . format ( 'DD/MM/YYYY HH:mm:ss' ) ;
135
-
136
- console . log ( 'Printing Output from QuizStudentpage.js in line 117' ) ;
137
- await this . getStartTime ( ) ;
138
- console . log (
139
- 'Printing Output from QuizStudentpage.js in line 119 ->' +
140
- this . state . date ,
141
- ) ;
142
- console . log ( this . state . date ) ;
143
- await kbcresponse
144
- . getResponse ( this . state . user . url , this . state . course . passCode )
145
- . then ( url => {
146
- if ( url === null ) {
147
- kbcresponse
148
- . createResponse (
149
- this . state . course . passCode ,
150
- this . state . user . url ,
151
- this . state . user . email ,
152
- option ,
153
- timestamp ,
154
- this . state . user . name ,
155
- this . state . opens ,
156
- this . state . firstOpen ,
157
- )
158
- . then ( r => {
159
- console . log ( 'create' ) ;
160
- } ) ;
161
- } else {
162
- kbcresponse
163
- . setResponse (
164
- this . state . course . passCode ,
165
- this . state . user . url ,
166
- this . state . user . email ,
167
- option ,
168
- timestamp ,
169
- this . state . user . name ,
170
- url ,
171
- this . state . opens ,
172
- this . state . firstOpen ,
173
- )
174
- . then ( r => {
175
- console . log ( 'update' ) ;
176
- } ) ;
177
- }
178
- } ) ;
179
130
}
131
+
132
+ Toast . show ( 'Answer has been recorded!' ) ;
133
+ const kbcresponse = new QuizResponses ( ) ;
134
+ const timestamp = moment
135
+ . utc ( database ( ) . getServerTime ( ) )
136
+ . format ( 'DD/MM/YYYY HH:mm:ss' ) ;
137
+
138
+ console . log ( 'Printing Output from QuizStudentpage.js in line 117' ) ;
139
+ await this . getStartTime ( ) ;
140
+ console . log (
141
+ 'Printing Output from QuizStudentpage.js in line 119 ->' +
142
+ this . state . date ,
143
+ ) ;
144
+ console . log ( this . state . date ) ;
145
+
146
+ var date1 = new Date ( this . state . date ) ;
147
+ var date2 = new Date ( timestamp ) ;
148
+ var difference = date2 . getTime ( ) - date1 . getTime ( ) ;
149
+ var quiz_response_time = ( difference / 60000 ) * 60 ;
150
+ quiz_response_time = quiz_response_time . toFixed ( 2 ) ;
151
+ console . log ( 'Response Time added' ) ;
152
+ console . log ( quiz_response_time ) ;
153
+
154
+ await kbcresponse
155
+ . getResponse ( this . state . user . url , this . state . course . passCode )
156
+ . then ( url => {
157
+ if ( url === null ) {
158
+ kbcresponse
159
+ . createResponse (
160
+ this . state . course . passCode ,
161
+ this . state . user . url ,
162
+ this . state . user . email ,
163
+ option ,
164
+ timestamp ,
165
+ this . state . user . name ,
166
+ quiz_response_time ,
167
+ this . state . opens ,
168
+ this . state . firstOpen ,
169
+ )
170
+ . then ( r => {
171
+ console . log ( 'create' ) ;
172
+ } ) ;
173
+ } else {
174
+ kbcresponse
175
+ . setResponse (
176
+ this . state . course . passCode ,
177
+ this . state . user . url ,
178
+ this . state . user . email ,
179
+ option ,
180
+ timestamp ,
181
+ this . state . user . name ,
182
+ quiz_response_time ,
183
+ url ,
184
+ this . state . opens ,
185
+ this . state . firstOpen ,
186
+ )
187
+ . then ( r => {
188
+ console . log ( 'update' ) ;
189
+ } ) ;
190
+ }
191
+ } ) ;
180
192
} ;
181
193
182
194
render ( ) {
183
195
if ( ! this . state . loading ) {
184
- // console.log(
185
- // 'The following is being printed from QuizStudentPage.js -> line no: 131, Printing AppState ' +
186
- // this.state.appState,
187
- // );
188
- // console.log(
189
- // 'The following is being printed from QuizStudentPage.js -> line no: 132, Printing App opens ' +
190
- // this.state.opens,
191
- // );
196
+ // console.log("Debugging");
197
+ // console.log(this.props.quizType);
192
198
return (
193
199
< SafeAreaView style = { styles . safeContainer } >
194
200
{ this . props . currentQuiz === false ? (
@@ -222,7 +228,6 @@ export default class QuizStudentPage extends Component {
222
228
option : '' ,
223
229
icon : '' ,
224
230
error : null ,
225
- opens : 0 ,
226
231
} ) ;
227
232
this . props . setQuizState ( ) ;
228
233
this . getCorrectAnswer ( ) . then ( r => {
@@ -364,6 +369,7 @@ export default class QuizStudentPage extends Component {
364
369
}
365
370
}
366
371
}
372
+
367
373
const styles = StyleSheet . create ( {
368
374
safeContainer : {
369
375
flex : 1 ,
0 commit comments