From 87bc677a8ca58373339e70a76af842e5521ccffc Mon Sep 17 00:00:00 2001 From: Anuneet Anand Date: Fri, 28 Jan 2022 21:09:25 +0530 Subject: [PATCH 01/11] Fixed Mailing System --- .gitignore | 2 + App/functions/README.md | 16 +++-- App/functions/firebase.json | 2 +- App/functions/index.js | 88 ++++++++------------------- App/ios/TLS.xcodeproj/project.pbxproj | 27 ++------ App/ios/TLS/Info.plist | 10 +-- 6 files changed, 46 insertions(+), 99 deletions(-) diff --git a/.gitignore b/.gitignore index f92c8cc..3af4703 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/App/functions/README.md b/App/functions/README.md index c46e36f..5a786cf 100644 --- a/App/functions/README.md +++ b/App/functions/README.md @@ -1,6 +1,6 @@ # Firebase cloud functions -Firebase cloud functions is a serverless framework that lets us run backend code in response to events by https requests. In this we use cloud funtions for features such as mailing, account deletion, notifications, etc. +Firebase cloud functions is a serverless framework that lets us run backend code in response to events by https requests. In this we use cloud funtions for features such as mailing, account deletion, notifications, etc. Run the following commands inside the functions folder. ## Deploying functions @@ -25,21 +25,27 @@ firebase use 4. Install dependencies ```sh -cd App/functions npm install -cd ../ ``` 5. Setup environment secrets. Right now environment secrets contain the email address, password and smtp provider. ```sh firebase functions:config:set mailingsystem.host="Your smtp provider" mailingsystem.email="Your Email" mailingsystem.password="Your password" +firebase functions:config:get > .runtimeconfig.json ``` -6. Deploy the functions to firebase +6. Test the functions locally (Comment out authentication) ```sh -firebase deploy --only:functions +npm run serve +npm start +``` + +7. Deploy the functions to firebase + +```sh +npm run deploy ``` ## Indexing diff --git a/App/functions/firebase.json b/App/functions/firebase.json index 2581f9f..ac63b9c 100644 --- a/App/functions/firebase.json +++ b/App/functions/firebase.json @@ -1,6 +1,6 @@ { "functions": { - "source": "functions" + "source": "." }, "emulators": { "functions": { diff --git a/App/functions/index.js b/App/functions/index.js index 86a3e06..c94bbbe 100644 --- a/App/functions/index.js +++ b/App/functions/index.js @@ -17,8 +17,6 @@ const nodemailer = require('nodemailer'); const moment = require('moment'); const url = 'https://testfortls.firebaseio.com/'; -// ADD CREDENTIALS BEFORE DEPLOYING - const transporter = nodemailer.createTransport({ host: functions.config().mailingsystem.host, auth: { @@ -37,8 +35,6 @@ function emailTemplate( quizCount, feedbackCount, ) { - console.log(type); - console.log(results); if (type === 'Feedback1') { avg_points = 0; sum = 0; @@ -56,22 +52,18 @@ function emailTemplate(

- Following is the results of Colour Scale on ${date} for course ${courseName} + Following are the results of Colour Scale Feedback conducted on ${date} for the course ${courseName}.

- -



-

- Regards, +
- Team ALT -

+
+

+ Regards, +
+ Team ALT +

@@ -83,18 +75,11 @@ function emailTemplate(

- Following is the results of Likert Scale on ${date} for course ${courseName} + Following are the results of Likert Scale Feedback conducted on ${date} for the course ${courseName}. The average response was ${avg_points}

-

Average Points : ${avg_points}

- +



Regards, @@ -112,7 +97,7 @@ function emailTemplate(

- Following are the results of Minute Paper on ${date} for course ${courseName} + Following are the results of Minute Paper Feedback conducted on ${date} for the course ${courseName}.

@@ -138,19 +123,10 @@ function emailTemplate(

- Following are the results of ${type} quiz on ${date} for course ${courseName} + Following are the results of ${type} Quiz conducted on ${date} for the course ${courseName}.

- - +





PFA. The CSV of answers submitted by the students. @@ -189,7 +165,7 @@ function emailTemplate(

- Following are the results of ${type} quiz on ${date} for course ${courseName} + Following are the results of ${type} Quiz conducted on ${date} for the course ${courseName}.

@@ -227,10 +203,6 @@ function emailTemplate(

- Respected Professor, -
-
-

PFA. List of Students registered for course ${courseName}
@@ -252,13 +224,10 @@ function emailTemplate(

- Respected Professor, -
-
Following are the details of the course ${courseName} :-

- The course pass code on the app - ${passCode} + The course passcode on the app - ${passCode}
Total Number of Quizzes - ${quizCount}
@@ -281,6 +250,7 @@ function emailTemplate( ` : ''; } + async function getURLFromPasscode(passCode) { const db_ref = admin .app() @@ -587,8 +557,8 @@ async function QuizResponseMailer( from: 'atlapp2021@gmail.com', to: email, subject: 'Quiz Responses : ' + courseName, - text: '.', - html: emailTemplate(courseName, date, '', results, type, 0, 0), + text: '', + html: emailTemplate(courseName, date, results, type, 0, 0), attachments: [ { filename: path, @@ -609,7 +579,6 @@ async function getAllStudentsforMail(passCode, startTime, endTime) { let vlist = null; let verifiedStudentList = null; let studentList = await getStudents(passCode); - // console.log(studentList) verifiedStudentList = studentList vlist = verifiedStudentList.map(student => { return student['key']; @@ -740,7 +709,6 @@ async function getFeedbackResponse(passCode, startTime, endTime, type) { } return ans; } - async function getFeedbackCSV(passCode, startTime, endTime) { let list = []; await admin @@ -770,7 +738,6 @@ async function getFeedbackCSV(passCode, startTime, endTime) { console.log(csvContent); return csvContent; } - async function getFBURLFromPasscode(passCode) { const db_ref = admin .app() @@ -800,7 +767,7 @@ async function FeedbackResponseMailer( email, ) { const courseName = await getCourseNameFromPasscode(passCode); - const date = startTime; + const date = startTime.replace(/\//g, '-').split(' ')[0]; try { @@ -810,7 +777,7 @@ async function FeedbackResponseMailer( from: 'atlapp2021@gmail.com', to: email, subject: 'Feedback Responses : ' + courseName, - text: '.', + text: '', html: emailTemplate(courseName, date, results, type, 0, 0), attachments: [ { @@ -837,7 +804,6 @@ async function FeedbackResponseMailer( return 'Error'; } } - async function getStudents(passCode) { const courseURL = await getURLFromPasscode(passCode); console.log('Inside getStudents for course: ' + courseURL); @@ -879,8 +845,6 @@ async function getStudents(passCode) { return studentList; } - - async function StudentListMailer(list, passCode, email) { const courseName = await getCourseNameFromPasscode(passCode); const path = `${courseName}.csv`; @@ -897,8 +861,8 @@ async function StudentListMailer(list, passCode, email) { from: 'atlapp2021@gmail.com', to: email, subject: 'List Of Students : ' + courseName, - text: '.', - html: emailTemplate(courseName, '', '', '', '', 0, 0), + text: '', + html: emailTemplate(courseName, '', '', '', 0, 0), attachments: [ { filename: path, @@ -945,8 +909,8 @@ async function CourseMailer(list, passCode, email, announcements, qc, fc) { from: 'atlapp2021@gmail.com', to: email, subject: 'Course Info : ' + courseName, - text: '.', - html: emailTemplate(courseName, '', '', '', 'Course', qc, fc), + text: '', + html: emailTemplate(courseName, '', '', 'Course', qc, fc), attachments: [ { filename: StudentPath, @@ -1036,7 +1000,6 @@ async function removeFromStudentList(courseKey) { return Promise.all(studentsToModify); } } - async function removeStudentFromCourses(studentID) { const db = admin.app().database(url); console.log('Removing Student from courses'); @@ -1058,13 +1021,11 @@ async function removeStudentFromCourses(studentID) { }); } } - async function deleteStudentHelper(studentID) { await deleteAllMatchingKey('KBCResponse', studentID, 'userID'); await deleteAllMatchingKey('FeedbackResponse', studentID, 'userID'); await removeStudentFromCourses(studentID); } - async function deleteFacultyHelper(facultyID) { console.log('Inside Delete Faculty Helper'); db = admin.app().database(url); @@ -1290,6 +1251,7 @@ exports.deleteFaculty = functions.https.onCall((data, context) => { console.log('Deleted Faculty:', key); }); }); + exports.quizNotification = functions.database .ref('InternalDb/KBC/{qid}') .onWrite(async (change, context) => { diff --git a/App/ios/TLS.xcodeproj/project.pbxproj b/App/ios/TLS.xcodeproj/project.pbxproj index dc40c85..0b4cf16 100644 --- a/App/ios/TLS.xcodeproj/project.pbxproj +++ b/App/ios/TLS.xcodeproj/project.pbxproj @@ -17,13 +17,11 @@ 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 2DCD954D1E0B4F2C00145EB5 /* TLSTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* TLSTests.m */; }; - 308F41862781D14300507556 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 308F41852781D14200507556 /* GoogleService-Info.plist */; }; - 308F41872781D14300507556 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 308F41852781D14200507556 /* GoogleService-Info.plist */; }; 5940416E05A19B5DD3A6F41D /* libPods-TLS-TLSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E8D5BE73E6A3D85F09D2E48E /* libPods-TLS-TLSTests.a */; }; 8C3911A469A19A968D62F58D /* libPods-TLS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DA35EA13167F9AAC586D61D /* libPods-TLS.a */; }; B931966AABF3D1AE18E90E61 /* libPods-TLS-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EBA1FC014A3D7EEE1C57D5EC /* libPods-TLS-tvOSTests.a */; }; - FBA16D86278B09B9005FD723 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = FBA16D85278B09B9005FD723 /* GoogleService-Info.plist */; }; - FBA16D87278B09B9005FD723 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = FBA16D85278B09B9005FD723 /* GoogleService-Info.plist */; }; + FB97F57A27A40FC5009600FC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = FB97F57927A40FC5009600FC /* GoogleService-Info.plist */; }; + FB97F57B27A40FC5009600FC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = FB97F57927A40FC5009600FC /* GoogleService-Info.plist */; }; FBE6FF69262CD61A00FFE5A0 /* AppIcons in Resources */ = {isa = PBXBuildFile; fileRef = FBE6FF68262CD61A00FFE5A0 /* AppIcons */; }; FBE6FF6A262CD61A00FFE5A0 /* AppIcons in Resources */ = {isa = PBXBuildFile; fileRef = FBE6FF68262CD61A00FFE5A0 /* AppIcons */; }; /* End PBXBuildFile section */ @@ -59,7 +57,6 @@ 2D02E47B1E0B4A5D006451C7 /* TLS-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "TLS-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 2D02E4901E0B4A5D006451C7 /* TLS-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "TLS-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 2DD3240D36455D4F29E6A119 /* libPods-TLS-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TLS-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 308F41852781D14200507556 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../../../Desktop/ALT_certificates/ALT_dev_imp/GoogleService-Info.plist"; sourceTree = ""; }; 4DA35EA13167F9AAC586D61D /* libPods-TLS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TLS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 5178CD80B26280E4FF86CF86 /* Pods-TLS-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TLS-tvOSTests.release.xcconfig"; path = "Target Support Files/Pods-TLS-tvOSTests/Pods-TLS-tvOSTests.release.xcconfig"; sourceTree = ""; }; 5275CEB45733BD6B91192931 /* Pods-TLS-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TLS-tvOS.debug.xcconfig"; path = "Target Support Files/Pods-TLS-tvOS/Pods-TLS-tvOS.debug.xcconfig"; sourceTree = ""; }; @@ -74,7 +71,7 @@ ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; EEEB1AC526394662009C6B3D /* TLS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = TLS.entitlements; path = TLS/TLS.entitlements; sourceTree = ""; }; F499858C4C33599391A775A6 /* Pods-TLS-tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TLS-tvOS.release.xcconfig"; path = "Target Support Files/Pods-TLS-tvOS/Pods-TLS-tvOS.release.xcconfig"; sourceTree = ""; }; - FBA16D85278B09B9005FD723 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; + FB97F57927A40FC5009600FC /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "TLS/GoogleService-Info.plist"; sourceTree = ""; }; FBE6FF68262CD61A00FFE5A0 /* AppIcons */ = {isa = PBXFileReference; lastKnownFileType = folder; path = AppIcons; sourceTree = ""; }; /* End PBXFileReference section */ @@ -138,10 +135,9 @@ 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.m */, 13B07FB51A68108700A75B9A /* Images.xcassets */, + FB97F57927A40FC5009600FC /* GoogleService-Info.plist */, 13B07FB61A68108700A75B9A /* Info.plist */, - FBA16D85278B09B9005FD723 /* GoogleService-Info.plist */, 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, - 308F41852781D14200507556 /* GoogleService-Info.plist */, 13B07FB71A68108700A75B9A /* main.m */, ); name = TLS; @@ -254,7 +250,6 @@ 7D0F1611347E4A0A09C91545 /* [CP] Copy Pods Resources */, 94B12B28E9D94BC734621E3A /* [CP-User] [RNFB] Core Configuration */, 1F05C4CBC89D26B372D0E54F /* [CP] Embed Pods Frameworks */, - 49054602414B41F08BE55CCB /* [CP-User] [NOTIFEE] Config */, ); buildRules = ( ); @@ -365,7 +360,7 @@ buildActionMask = 2147483647; files = ( 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, - FBA16D86278B09B9005FD723 /* GoogleService-Info.plist in Resources */, + FB97F57A27A40FC5009600FC /* GoogleService-Info.plist in Resources */, FBE6FF69262CD61A00FFE5A0 /* AppIcons in Resources */, 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, ); @@ -377,7 +372,7 @@ files = ( FBE6FF6A262CD61A00FFE5A0 /* AppIcons in Resources */, 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */, - FBA16D87278B09B9005FD723 /* GoogleService-Info.plist in Resources */, + FB97F57B27A40FC5009600FC /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -459,16 +454,6 @@ shellPath = /bin/sh; shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; }; - 49054602414B41F08BE55CCB /* [CP-User] [NOTIFEE] Config */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - name = "[CP-User] [NOTIFEE] Config"; - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "#!/usr/bin/env bash\n#\n# Copyright (c) 2016-present Invertase Limited & Contributors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this library except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\nset -e\n\n_MAX_LOOKUPS=2;\n_SEARCH_RESULT=''\n_RN_ROOT_EXISTS=''\n_CURRENT_LOOKUPS=1\n_JSON_ROOT=\"'ios'\"\n_JSON_FILE_NAME='notifee.config.json'\n_JSON_OUTPUT_BASE64='e30=' # { }\n_CURRENT_SEARCH_DIR=${PROJECT_DIR}\n_PLIST_BUDDY=/usr/libexec/PlistBuddy\n_TARGET_PLIST=\"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n_DSYM_PLIST=\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist\"\n\n# plist arrays\n_PLIST_ENTRY_KEYS=()\n_PLIST_ENTRY_TYPES=()\n_PLIST_ENTRY_VALUES=()\n\nfunction setPlistValue {\n echo \"info: setting plist entry '$1' of type '$2' in file '$4'\"\n ${_PLIST_BUDDY} -c \"Add :$1 $2 '$3'\" \"$4\" || echo \"info: '$1' already exists\"\n}\n\necho \"info: -> NOTIFEE build script started\"\necho \"info: 1) Locating ${_JSON_FILE_NAME} file:\"\n\nif [[ -z ${_CURRENT_SEARCH_DIR} ]]; then\n _CURRENT_SEARCH_DIR=$(pwd)\nfi;\n\nwhile true; do\n _CURRENT_SEARCH_DIR=$(dirname \"$_CURRENT_SEARCH_DIR\")\n if [[ \"$_CURRENT_SEARCH_DIR\" == \"/\" ]] || [[ ${_CURRENT_LOOKUPS} -gt ${_MAX_LOOKUPS} ]]; then break; fi;\n echo \"info: ($_CURRENT_LOOKUPS of $_MAX_LOOKUPS) Searching in '$_CURRENT_SEARCH_DIR' for a ${_JSON_FILE_NAME} file.\"\n _SEARCH_RESULT=$(find \"$_CURRENT_SEARCH_DIR\" -maxdepth 2 -name ${_JSON_FILE_NAME} -print | head -n 1)\n if [[ ${_SEARCH_RESULT} ]]; then\n echo \"info: ${_JSON_FILE_NAME} found at $_SEARCH_RESULT\"\n break;\n fi;\n _CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))\ndone\n\nif [[ ${_SEARCH_RESULT} ]]; then\n _JSON_OUTPUT_RAW=$(cat \"${_SEARCH_RESULT}\")\n _RN_ROOT_EXISTS=$(ruby -e \"require 'rubygems';require 'json'; output=JSON.parse('$_JSON_OUTPUT_RAW'); puts output[$_JSON_ROOT]\" || echo '')\n\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n _JSON_OUTPUT_BASE64=$(python -c 'import json,sys,base64;print(base64.b64encode(json.dumps(json.loads(open('\"'${_SEARCH_RESULT}'\"').read())['${_JSON_ROOT}'])))' || echo \"e30=\")\n fi\n\n _PLIST_ENTRY_KEYS+=(\"notifee_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\nelse\n _PLIST_ENTRY_KEYS+=(\"notifee_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n echo \"warning: A notifee.config.json file was not found.\"\nfi;\n\necho \"info: 2) Injecting Info.plist entries: \"\n\n# Log out the keys we're adding\nfor i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n echo \" -> $i) ${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\"\ndone\n\nfor plist in \"${_TARGET_PLIST}\" \"${_DSYM_PLIST}\" ; do\n if [[ -f ${plist} ]]; then\n for i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n setPlistValue \"${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\" \"${plist}\"\n done\n else\n echo \"warning: A Info.plist build output file was not found (${plist})\"\n fi\ndone\n\necho \"info: <- NOTIFEE build script finished\"\n"; - }; 5121F48C704374E0999C41E5 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/App/ios/TLS/Info.plist b/App/ios/TLS/Info.plist index e885562..c8f1b62 100644 --- a/App/ios/TLS/Info.plist +++ b/App/ios/TLS/Info.plist @@ -27,15 +27,7 @@ Editor CFBundleURLSchemes - com.googleusercontent.apps.50954815215-rcfk923tprhd56ak6j096cro9u784srs - - - - CFBundleTypeRole - Editor - CFBundleURLSchemes - - com.googleusercontent.apps.50954815215-rcfk923tprhd56ak6j096cro9u784srs + com.googleusercontent.apps.769962526895-2taa8n0lc8snoj8lu77cskv7tc5i4hmk From 12322d79be21675974b2515b4aab7e549caef97b Mon Sep 17 00:00:00 2001 From: Anuneet Anand Date: Sat, 5 Feb 2022 01:34:02 +0530 Subject: [PATCH 02/11] Fixed Email Pie Chart Bug --- App/functions/index.js | 9 +++++---- App/ios/TLS.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/App/functions/index.js b/App/functions/index.js index c94bbbe..214bd4d 100644 --- a/App/functions/index.js +++ b/App/functions/index.js @@ -35,6 +35,7 @@ function emailTemplate( quizCount, feedbackCount, ) { + console.log("Results: ", results); if (type === 'Feedback1') { avg_points = 0; sum = 0; @@ -56,7 +57,7 @@ function emailTemplate(

- +

@@ -75,11 +76,11 @@ function emailTemplate(

- Following are the results of Likert Scale Feedback conducted on ${date} for the course ${courseName}. The average response was ${avg_points} + Following are the results of Likert Scale Feedback conducted on ${date} for the course ${courseName}. The average response was ${avg_points}.

- +



Regards, @@ -126,7 +127,7 @@ function emailTemplate( Following are the results of ${type} Quiz conducted on ${date} for the course ${courseName}.

- +





PFA. The CSV of answers submitted by the students. diff --git a/App/ios/TLS.xcodeproj/project.pbxproj b/App/ios/TLS.xcodeproj/project.pbxproj index 0b4cf16..f955977 100644 --- a/App/ios/TLS.xcodeproj/project.pbxproj +++ b/App/ios/TLS.xcodeproj/project.pbxproj @@ -806,7 +806,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = TLS/TLS.entitlements; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 14; DEVELOPMENT_TEAM = 657J687DK4; ENABLE_BITCODE = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -836,7 +836,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = TLS/TLS.entitlements; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 14; DEVELOPMENT_TEAM = 657J687DK4; INFOPLIST_FILE = TLS/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 10.0; From 6f7b63b95bcd6dfcd0bd7ff9b18deef9f8ed1aee Mon Sep 17 00:00:00 2001 From: Yashdeep Prasad <45161513+HackGod2000@users.noreply.github.com> Date: Sun, 27 Feb 2022 14:48:57 +0530 Subject: [PATCH 03/11] changed URL scheme --- App/ios/TLS.xcodeproj/project.pbxproj | 12 ++++++------ App/ios/TLS/Info.plist | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/App/ios/TLS.xcodeproj/project.pbxproj b/App/ios/TLS.xcodeproj/project.pbxproj index f955977..006bf5b 100644 --- a/App/ios/TLS.xcodeproj/project.pbxproj +++ b/App/ios/TLS.xcodeproj/project.pbxproj @@ -17,11 +17,11 @@ 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 2DCD954D1E0B4F2C00145EB5 /* TLSTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* TLSTests.m */; }; + 30F4802827C01934006C60BB /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 30F4802727C01934006C60BB /* GoogleService-Info.plist */; }; + 30F4802927C01934006C60BB /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 30F4802727C01934006C60BB /* GoogleService-Info.plist */; }; 5940416E05A19B5DD3A6F41D /* libPods-TLS-TLSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E8D5BE73E6A3D85F09D2E48E /* libPods-TLS-TLSTests.a */; }; 8C3911A469A19A968D62F58D /* libPods-TLS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DA35EA13167F9AAC586D61D /* libPods-TLS.a */; }; B931966AABF3D1AE18E90E61 /* libPods-TLS-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EBA1FC014A3D7EEE1C57D5EC /* libPods-TLS-tvOSTests.a */; }; - FB97F57A27A40FC5009600FC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = FB97F57927A40FC5009600FC /* GoogleService-Info.plist */; }; - FB97F57B27A40FC5009600FC /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = FB97F57927A40FC5009600FC /* GoogleService-Info.plist */; }; FBE6FF69262CD61A00FFE5A0 /* AppIcons in Resources */ = {isa = PBXBuildFile; fileRef = FBE6FF68262CD61A00FFE5A0 /* AppIcons */; }; FBE6FF6A262CD61A00FFE5A0 /* AppIcons in Resources */ = {isa = PBXBuildFile; fileRef = FBE6FF68262CD61A00FFE5A0 /* AppIcons */; }; /* End PBXBuildFile section */ @@ -57,6 +57,7 @@ 2D02E47B1E0B4A5D006451C7 /* TLS-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "TLS-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 2D02E4901E0B4A5D006451C7 /* TLS-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "TLS-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 2DD3240D36455D4F29E6A119 /* libPods-TLS-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TLS-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 30F4802727C01934006C60BB /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 4DA35EA13167F9AAC586D61D /* libPods-TLS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TLS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 5178CD80B26280E4FF86CF86 /* Pods-TLS-tvOSTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TLS-tvOSTests.release.xcconfig"; path = "Target Support Files/Pods-TLS-tvOSTests/Pods-TLS-tvOSTests.release.xcconfig"; sourceTree = ""; }; 5275CEB45733BD6B91192931 /* Pods-TLS-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TLS-tvOS.debug.xcconfig"; path = "Target Support Files/Pods-TLS-tvOS/Pods-TLS-tvOS.debug.xcconfig"; sourceTree = ""; }; @@ -71,7 +72,6 @@ ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; EEEB1AC526394662009C6B3D /* TLS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = TLS.entitlements; path = TLS/TLS.entitlements; sourceTree = ""; }; F499858C4C33599391A775A6 /* Pods-TLS-tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TLS-tvOS.release.xcconfig"; path = "Target Support Files/Pods-TLS-tvOS/Pods-TLS-tvOS.release.xcconfig"; sourceTree = ""; }; - FB97F57927A40FC5009600FC /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "TLS/GoogleService-Info.plist"; sourceTree = ""; }; FBE6FF68262CD61A00FFE5A0 /* AppIcons */ = {isa = PBXFileReference; lastKnownFileType = folder; path = AppIcons; sourceTree = ""; }; /* End PBXFileReference section */ @@ -135,8 +135,8 @@ 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.m */, 13B07FB51A68108700A75B9A /* Images.xcassets */, - FB97F57927A40FC5009600FC /* GoogleService-Info.plist */, 13B07FB61A68108700A75B9A /* Info.plist */, + 30F4802727C01934006C60BB /* GoogleService-Info.plist */, 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, 13B07FB71A68108700A75B9A /* main.m */, ); @@ -360,7 +360,7 @@ buildActionMask = 2147483647; files = ( 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, - FB97F57A27A40FC5009600FC /* GoogleService-Info.plist in Resources */, + 30F4802827C01934006C60BB /* GoogleService-Info.plist in Resources */, FBE6FF69262CD61A00FFE5A0 /* AppIcons in Resources */, 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, ); @@ -372,7 +372,7 @@ files = ( FBE6FF6A262CD61A00FFE5A0 /* AppIcons in Resources */, 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */, - FB97F57B27A40FC5009600FC /* GoogleService-Info.plist in Resources */, + 30F4802927C01934006C60BB /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/App/ios/TLS/Info.plist b/App/ios/TLS/Info.plist index c8f1b62..f9b05a0 100644 --- a/App/ios/TLS/Info.plist +++ b/App/ios/TLS/Info.plist @@ -27,7 +27,7 @@ Editor CFBundleURLSchemes - com.googleusercontent.apps.769962526895-2taa8n0lc8snoj8lu77cskv7tc5i4hmk + com.googleusercontent.apps.50954815215-rcfk923tprhd56ak6j096cro9u784srs From bcc8bbafc1e10d7a4ca5cff0b0fac74dd74b3390 Mon Sep 17 00:00:00 2001 From: shreeya13garg <51780388+shreeya13garg@users.noreply.github.com> Date: Thu, 3 Mar 2022 16:18:15 +0530 Subject: [PATCH 04/11] Quiz Response Time added --- App/Components/Quiz/QuizStudentPage.js | 76 +++++++++++++++++--------- App/Databases/Quiz.js | 2 + App/Databases/QuizResponses.js | 12 ++-- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/App/Components/Quiz/QuizStudentPage.js b/App/Components/Quiz/QuizStudentPage.js index f980cd1..a036714 100644 --- a/App/Components/Quiz/QuizStudentPage.js +++ b/App/Components/Quiz/QuizStudentPage.js @@ -53,28 +53,52 @@ export default class QuizStudentPage extends Component { }) } + getStartTime = async () => { + const Kbc = new Quiz(); + await Kbc.getTiming(this.state.course.passCode).then(value => { + console.log("Output line 92 QuizStudentPage.js"+ value['startTime']); + this.setState({ + date: value['startTime'], + }); + }); + }; + + + submitResponse = async () => { const {option} = this.state; - + if (option === '') { - this.setState({ - error: "Please answer" - }) - } - else if(this.props.quizType==="numeric" && isNaN(parseFloat(option))) - { - this.setState({ - error: "Please Input a Numerical Response" - }) - } - else { - this.setState({ - error:null - }) - Toast.show('Answer has been recorded!'); - const kbcresponse = new QuizResponses() - const timestamp = moment.utc(database().getServerTime()).format("DD/MM/YYYY HH:mm:ss") + this.setState({ + error: 'Please answer', + }); + } else if (this.props.quizType === 'numeric' && isNaN(parseFloat(option))) { + this.setState({ + error: 'Please Input a Numerical Response', + }); + } else { + this.setState({ + error: null, + }); + Toast.show('Answer has been recorded!'); + const kbcresponse = new QuizResponses(); + const timestamp = moment + .utc(database().getServerTime()) + .format('DD/MM/YYYY HH:mm:ss'); + + console.log("Printing Output from QuizStudentpage.js in line 117"); + await this.getStartTime(); + console.log("Printing Output from QuizStudentpage.js in line 119 ->" + this.state.date); + console.log(this.state.date); + + var date1 = new Date(this.state.date); + var date2 = new Date(timestamp); + var difference = date2.getTime()-date1.getTime(); + var quiz_response_time=(difference/60000)*60 + quiz_response_time = quiz_response_time.toFixed(2); + console.log("Response Time added") + console.log(quiz_response_time); await kbcresponse.getResponse(this.state.user.url, this.state.course.passCode) .then((url) => { @@ -85,9 +109,10 @@ export default class QuizStudentPage extends Component { this.state.user.email, option, timestamp, - this.state.user.name + this.state.user.name, + quiz_response_time, ).then(r => { - console.log("update") + console.log("create") }) } else { kbcresponse.setResponse( @@ -97,9 +122,10 @@ export default class QuizStudentPage extends Component { option, timestamp, this.state.user.name, - url + quiz_response_time, + url, ).then(r => { - console.log("create") + console.log("update") }) } @@ -112,8 +138,8 @@ export default class QuizStudentPage extends Component { render() { if(!this.state.loading) { - console.log("Debugging"); - console.log(this.props.quizType); + // console.log("Debugging"); + // console.log(this.props.quizType); return( { this.props.currentQuiz === false @@ -130,7 +156,7 @@ export default class QuizStudentPage extends Component { correctAnswer={this.state.correctAnswer} date={this.state.date} quizType={this.props.quizType} - quizresultData={this.quizresultData} /> + quizresultData={this.quizresultData}/> : diff --git a/App/Databases/Quiz.js b/App/Databases/Quiz.js index a8cc6ee..32c9794 100644 --- a/App/Databases/Quiz.js +++ b/App/Databases/Quiz.js @@ -39,6 +39,8 @@ class Quiz { .then(snapshot => { if (snapshot.val()){ const keys = Object.values(snapshot.val()); + console.log("Finding Issues") + console.log(keys); ans = keys[0] } }) diff --git a/App/Databases/QuizResponses.js b/App/Databases/QuizResponses.js index 68c9be5..ba689f0 100644 --- a/App/Databases/QuizResponses.js +++ b/App/Databases/QuizResponses.js @@ -1,5 +1,6 @@ import database from '@react-native-firebase/database'; import moment from 'moment'; +import Quiz from './Quiz'; class QuizResponses { @@ -30,7 +31,7 @@ class QuizResponses { return ans } - setResponse = async (passCode, userID, userName, answer, timestamp, name, url) =>{ + setResponse = async (passCode, userID, userName, answer, timestamp, name, quiz_response_time, url) =>{ await database() .ref('InternalDb/KBCResponse/'+url) .set({ @@ -40,14 +41,15 @@ class QuizResponses { userID_passCode : userID+"_"+passCode, answer: answer, timestamp:timestamp, - name: name + name: name, + quiz_response_time: quiz_response_time, }) .then(()=>{ console.log("Response modified") }) } - createResponse = async (passCode, userID, userName, answer, timestamp, name) => { + createResponse = async (passCode, userID, userName, answer, timestamp, name,quiz_response_time) => { await this.reference .push() .set({ @@ -57,7 +59,8 @@ class QuizResponses { userID_passCode : userID+"_"+passCode, answer: answer, timestamp: timestamp, - name: name + name: name, + quiz_response_time: quiz_response_time, }) .then(() => { console.log('Response Created') @@ -199,6 +202,7 @@ class QuizResponses { else{ dict[answer] = 1 } + } }) ans = dict From a16a3f23c4796eb858b2f70a44704235d4575fb4 Mon Sep 17 00:00:00 2001 From: Yashdeep Prasad <45161513+HackGod2000@users.noreply.github.com> Date: Sat, 5 Mar 2022 02:29:56 +0530 Subject: [PATCH 05/11] Yash Quiz Variables done --- App/Components/Navigation/QuizStack.js | 1 + App/Components/Quiz/QuizHomePage.js | 4 - App/Components/Quiz/QuizStudentPage.js | 733 ++++++++++++++----------- App/Databases/QuizResponses.js | 345 +++++------- 4 files changed, 559 insertions(+), 524 deletions(-) diff --git a/App/Components/Navigation/QuizStack.js b/App/Components/Navigation/QuizStack.js index 80f7422..e2b5450 100644 --- a/App/Components/Navigation/QuizStack.js +++ b/App/Components/Navigation/QuizStack.js @@ -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(); diff --git a/App/Components/Quiz/QuizHomePage.js b/App/Components/Quiz/QuizHomePage.js index 975f0a5..b89dff3 100644 --- a/App/Components/Quiz/QuizHomePage.js +++ b/App/Components/Quiz/QuizHomePage.js @@ -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") diff --git a/App/Components/Quiz/QuizStudentPage.js b/App/Components/Quiz/QuizStudentPage.js index f980cd1..8122bc0 100644 --- a/App/Components/Quiz/QuizStudentPage.js +++ b/App/Components/Quiz/QuizStudentPage.js @@ -1,5 +1,13 @@ import React, {Component} from 'react'; -import {SafeAreaView, ScrollView, StyleSheet, View, TextInput, ActivityIndicator} from 'react-native'; +import { + SafeAreaView, + ScrollView, + StyleSheet, + View, + TextInput, + ActivityIndicator, + AppState, +} from 'react-native'; import {Text, Button} from 'react-native-elements'; import moment from 'moment'; import Options from './Options'; @@ -8,337 +16,434 @@ import CountDown from 'react-native-countdown-component'; import QuizResultGraph from './QuizResultGraph'; import Quiz from '../../Databases/Quiz'; import Toast from 'react-native-simple-toast'; -import database from "@react-native-firebase/database"; +import database from '@react-native-firebase/database'; import MultiCorrectOptions from './MultiCorrectOptions'; export default class QuizStudentPage extends Component { - constructor(props) { - super(props); - this.state = { - course : this.props.course, - user : this.props.user, - option : "", - icon : "", - error : null, - correctAnswer : "", - quizResults : false, - date : "", - results :"", - loading : true - }; - this.setOption = this.setOption.bind(this); - this.quizresultData = this.quizresultData.bind(this); - } - - quizresultData(resultData, quizNumber) { - this.setState({ - results: resultData - }) - } + constructor(props) { + super(props); + this.state = { + course: this.props.course, + user: this.props.user, + option: '', + icon: '', + error: null, + correctAnswer: '', + quizResults: false, + date: '', + results: '', + loading: true, + appState: AppState.currentState, + opens: 0, + firstOpen: '', + }; + this.setOption = this.setOption.bind(this); + this.quizresultData = this.quizresultData.bind(this); + } - setOption(value){ - this.setState({ - option : value, - icon : value, - }) - } + componentDidMount() { + this.appStateSubscription = AppState.addEventListener( + 'change', + nextAppState => { + if ( + this.state.appState.match(/inactive|background/) && + nextAppState === 'active' && + this.props.currentQuiz && + this.state.firstOpen === '' + ) { + console.log('Quiz has come to the foreground for First time!'); + this.setState({opens: this.state.opens + 1}); + console.log(this.state.opens); + const timestamp_first = moment + .utc(database().getServerTime()) + .format('DD/MM/YYYY HH:mm:ss'); + this.setState({firstOpen: timestamp_first}); + } else if ( + this.state.appState.match(/inactive|background/) && + nextAppState === 'active' && + this.props.currentQuiz + ) { + console.log('Quiz has come to the foreground!'); + + this.setState({opens: this.state.opens + 1}); + console.log(this.state.opens); + } + this.setState({appState: nextAppState}); + }, + ); + } - getCorrectAnswer = async () =>{ - const Kbc = new Quiz() - Kbc.getTiming(this.state.course.passCode).then(value => { - this.setState({ - correctAnswer : value["correctAnswer"], - date : value["startTime"] - }) - }) - } + componentWillUnmount() { + this.appStateSubscription = AppState.removeEventListener('change', () => { + console.log('componentHasUnmounted'); + }); + } - submitResponse = async () => { + quizresultData(resultData, quizNumber) { + this.setState({ + results: resultData, + }); + } - const {option} = this.state; + setOption(value) { + this.setState({ + option: value, + icon: value, + }); + } - if (option === '') { - this.setState({ - error: "Please answer" - }) - } - else if(this.props.quizType==="numeric" && isNaN(parseFloat(option))) - { - this.setState({ - error: "Please Input a Numerical Response" - }) - } - else { - this.setState({ - error:null - }) - Toast.show('Answer has been recorded!'); - const kbcresponse = new QuizResponses() - const timestamp = moment.utc(database().getServerTime()).format("DD/MM/YYYY HH:mm:ss") + getCorrectAnswer = async () => { + const Kbc = new Quiz(); + Kbc.getTiming(this.state.course.passCode).then(value => { + this.setState({ + correctAnswer: value['correctAnswer'], + date: value['startTime'], + }); + }); + }; - await kbcresponse.getResponse(this.state.user.url, this.state.course.passCode) - .then((url) => { - if (url === null) { - kbcresponse.createResponse( - this.state.course.passCode, - this.state.user.url, - this.state.user.email, - option, - timestamp, - this.state.user.name - ).then(r => { - console.log("update") - }) - } else { - kbcresponse.setResponse( - this.state.course.passCode, - this.state.user.url, - this.state.user.email, - option, - timestamp, - this.state.user.name, - url - ).then(r => { - console.log("create") - }) + getStartTime = async () => { + const Kbc = new Quiz(); + await Kbc.getTiming(this.state.course.passCode).then(value => { + console.log('Output line 92 QuizStudentPage.js' + value['startTime']); + this.setState({ + date: value['startTime'], + }); + }); + }; - } - }) + submitResponse = async () => { + const {option} = this.state; - } + if (option === '') { + this.setState({ + error: 'Please answer', + }); + } else if (this.props.quizType === 'numeric' && isNaN(parseFloat(option))) { + this.setState({ + error: 'Please Input a Numerical Response', + }); + } else { + this.setState({ + error: null, + }); + Toast.show('Answer has been recorded!'); + const kbcresponse = new QuizResponses(); + const timestamp = moment + .utc(database().getServerTime()) + .format('DD/MM/YYYY HH:mm:ss'); + console.log('Printing Output from QuizStudentpage.js in line 117'); + await this.getStartTime(); + console.log( + 'Printing Output from QuizStudentpage.js in line 119 ->' + + this.state.date, + ); + console.log(this.state.date); + await kbcresponse + .getResponse(this.state.user.url, this.state.course.passCode) + .then(url => { + if (url === null) { + kbcresponse + .createResponse( + this.state.course.passCode, + this.state.user.url, + this.state.user.email, + option, + timestamp, + this.state.user.name, + this.state.opens, + this.state.firstOpen, + ) + .then(r => { + console.log('create'); + }); + } else { + kbcresponse + .setResponse( + this.state.course.passCode, + this.state.user.url, + this.state.user.email, + option, + timestamp, + this.state.user.name, + url, + this.state.opens, + this.state.firstOpen, + ) + .then(r => { + console.log('update'); + }); + } + }); } + }; - render() { - if(!this.state.loading) - { - console.log("Debugging"); - console.log(this.props.quizType); - return( - - { this.props.currentQuiz === false - ? - this.state.quizResults === false - ? - - Wohoo! No current quiz! - - : - - - - - - : - - - In-Class Quiz - - - { - this.setState({ - quizResults : true, - option: "", - icon: "", - error: null - }) - this.props.setQuizState() - this.getCorrectAnswer().then(r=>{console.log("")}) - }} - digitStyle={{backgroundColor: 'white'}} - digitTxtStyle={{color: 'tomato'}} - timeToShow={['M', 'S']} - timeLabels={{m: 'Min', s: 'Sec'}} - /> - {this.props.quizType==="mcq" - ? - - - - {this.state.error ? - - {this.state.error} - : - } - -