Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,5 @@ App/functions/MinutePaper/__pycache__
App/functions/MinutePaper/.pytest_cache

App/android/app/release/
App/functions/.runtimeconfig.json
App/ios/TLS/GoogleService-Info.plist
72 changes: 68 additions & 4 deletions App/Components/Feedback/FeedbackStudentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default class FeedbackStudentPage extends Component {
error: null,
loading: true,
kind: null,
firstOpen: 0,
date: '',
opens: 0,
};
this.getTopics = this.getTopics.bind(this);
this.studentResponses = this.studentResponses.bind(this);
Expand Down Expand Up @@ -74,16 +77,31 @@ export default class FeedbackStudentPage extends Component {
});
}

getStartTime = async () => {
const feedback = new Feedback();
await feedback
.getFeedbackDetails(this.state.course.passCode)
.then(value => {
console.log('Output line 82 FeedbackStudent.js' + value['startTime']);
this.setState({
date: value['startTime'],
});
});
};

submitFeedback = async () => {
var {responses} = this.state;
var err = false;

let msg = "";
console.log("Submit Feedback ",responses);
if (this.state.responses === -1 || !responses) {

err = true;
msg = "Please enter a response";
msg = 'Please enter a response';
}
if (this.state.kind == 2) {

responses = [...this.state.responses];
if(Array.isArray(this.state.responses)){
if (!responses[0] || !responses[1] ) {
Expand Down Expand Up @@ -114,12 +132,42 @@ export default class FeedbackStudentPage extends Component {
if (!err) {
Toast.show('Responses have been recorded!');
const feedbackResponse = new FeedbackResponses();
const timestamp = moment.utc(database().getServerTime()).format(
'DD/MM/YYYY HH:mm:ss',
);
const timestamp = moment
.utc(database().getServerTime())
.format('DD/MM/YYYY HH:mm:ss');
console.log(timestamp);

await this.getStartTime();

let temp = moment.utc(this.state.date, 'DD/MM/YYYY HH:mm:ss');
let temp1 = moment.utc(this.state.firstOpen, 'DD/MM/YYYY HH:mm:ss');
let temp3 = moment.utc(timestamp, 'DD/MM/YYYY HH:mm:ss');

console.log('Printing line-> 130, FeedbackStudentPage.js');
console.log(temp1, temp);

let date1 = new Date(temp);
let date2 = new Date(temp1);
let date3 = new Date(temp3)


const difference = date3.getTime() - date1.getTime();
const differenceOpen = date2.getTime() - date1.getTime();

let feedback_response_time = (difference / 60000) * 60;
feedback_response_time = feedback_response_time.toFixed(2);
console.log('Response Time added');
console.log(feedback_response_time);

let first_open_time = (differenceOpen / 60000) * 60;
first_open_time = first_open_time.toFixed(2);
console.log('Printing line-> 136, FeedbackStudentPage.js');
console.log(first_open_time);


console.log(this.state.responses);
const studentResponses = this.state.responses;

await feedbackResponse
.getFeedbackResponse(this.state.user.url, this.state.course.passCode)
.then(url => {
Expand All @@ -131,6 +179,8 @@ export default class FeedbackStudentPage extends Component {
this.state.user.email,
studentResponses,
timestamp,
first_open_time,
feedback_response_time,
)
.then(r => {
console.log('create');
Expand All @@ -144,6 +194,8 @@ export default class FeedbackStudentPage extends Component {
studentResponses,
timestamp,
url,
first_open_time,
feedback_response_time,
)
.then(r => {
console.log('update');
Expand Down Expand Up @@ -177,6 +229,18 @@ export default class FeedbackStudentPage extends Component {

render() {
if (!this.state.loading) {

if (this.props.currentFeedback && this.state.opens === 0) {
console.log('Printing line-> 202, FeedbackStudentPage.js');
const timestamp_first = moment
.utc(database().getServerTime())
.format('DD/MM/YYYY HH:mm:ss');

this.setState({firstOpen: timestamp_first});
this.setState({opens: this.state.opens + 1});
console.log(this.state.firstOpen);
}

return (
<SafeAreaView style={styles.safeContainer}>
{this.props.currentFeedback === false ? (
Expand Down
1 change: 1 addition & 0 deletions App/Components/Navigation/QuizStack.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {createStackNavigator} from '@react-navigation/stack';
import React, {Component} from 'react';
import QuizHomePage from '../Quiz/QuizHomePage';
import {useRoute} from '@react-navigation/native';

const Stack = createStackNavigator();

Expand Down
4 changes: 0 additions & 4 deletions App/Components/Quiz/QuizHomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ export default class QuizHomePage extends Component{
.on('value', snapshot => {
if (snapshot.val()){
const values = Object.values(snapshot.val())[0]
// console.log("Non moment")
console.log("serverTime: "+database().getServerTime())
// console.log(moment.utc(database().getServerTime()))
// console.log("startTime"+values['startTime'])
// console.log("endTime"+ values['endTime'])
const curr = moment.utc(database().getServerTime())
const startTime = moment.utc(values['startTime'], "DD/MM/YYYY HH:mm:ss")
const endTime = moment.utc(values['endTime'], "DD/MM/YYYY HH:mm:ss")
Expand Down
Loading