Skip to content

Commit 8b71c49

Browse files
Merged Shreeya and Yash work
2 parents a16a3f2 + bcc8bba commit 8b71c49

File tree

3 files changed

+73
-63
lines changed

3 files changed

+73
-63
lines changed

App/Components/Quiz/QuizStudentPage.js

Lines changed: 65 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default class QuizStudentPage extends Component {
6464
this.props.currentQuiz
6565
) {
6666
console.log('Quiz has come to the foreground!');
67-
67+
6868
this.setState({opens: this.state.opens + 1});
6969
console.log(this.state.opens);
7070
}
@@ -127,68 +127,74 @@ export default class QuizStudentPage extends Component {
127127
this.setState({
128128
error: null,
129129
});
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-
});
179130
}
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+
});
180192
};
181193

182194
render() {
183195
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);
192198
return (
193199
<SafeAreaView style={styles.safeContainer}>
194200
{this.props.currentQuiz === false ? (
@@ -222,7 +228,6 @@ export default class QuizStudentPage extends Component {
222228
option: '',
223229
icon: '',
224230
error: null,
225-
opens: 0,
226231
});
227232
this.props.setQuizState();
228233
this.getCorrectAnswer().then(r => {
@@ -364,6 +369,7 @@ export default class QuizStudentPage extends Component {
364369
}
365370
}
366371
}
372+
367373
const styles = StyleSheet.create({
368374
safeContainer: {
369375
flex: 1,

App/Databases/Quiz.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Quiz {
3939
.then(snapshot => {
4040
if (snapshot.val()){
4141
const keys = Object.values(snapshot.val());
42+
console.log("Finding Issues")
43+
console.log(keys);
4244
ans = keys[0]
4345
}
4446
})

App/Databases/QuizResponses.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import database from '@react-native-firebase/database';
22
import moment from 'moment';
3+
import Quiz from './Quiz';
34

45
class QuizResponses {
56
coursePasscode: string;
@@ -34,6 +35,7 @@ class QuizResponses {
3435
answer,
3536
timestamp,
3637
name,
38+
quiz_response_time,
3739
url,
3840
opens,
3941
firstOpen,
@@ -48,6 +50,7 @@ class QuizResponses {
4850
answer: answer,
4951
timestamp: timestamp,
5052
name: name,
53+
quiz_response_time: quiz_response_time,
5154
opens: opens,
5255
firstOpen: firstOpen,
5356
})
@@ -63,8 +66,9 @@ class QuizResponses {
6366
answer,
6467
timestamp,
6568
name,
69+
quiz_response_time,
6670
opens,
67-
firstOpen
71+
firstOpen,
6872
) => {
6973
await this.reference
7074
.push()
@@ -76,6 +80,7 @@ class QuizResponses {
7680
answer: answer,
7781
timestamp: timestamp,
7882
name: name,
83+
quiz_response_time: quiz_response_time,
7984
opens: opens,
8085
firstOpen: firstOpen,
8186
})
@@ -121,9 +126,6 @@ class QuizResponses {
121126
const temp1 = moment.utc(keys['timestamp'], 'DD/MM/YYYY HH:mm:ss');
122127
const temp2 = moment.utc(endTime, 'DD/MM/YYYY HH:mm:ss');
123128

124-
125-
// reponse = abs(Start-keys[timestamps])
126-
127129
if (temp1 <= temp2 && temp1 >= temp) {
128130
let answer = keys['answer']
129131
.trim()

0 commit comments

Comments
 (0)