From 1e2c31b4fd0c02d4152ab277369f1b6bfee3743f Mon Sep 17 00:00:00 2001 From: Rhythm1027 <95673596+Rhythm1027@users.noreply.github.com> Date: Sun, 21 Jan 2024 20:00:01 +0530 Subject: [PATCH] Added quiz and content page --- client/package-lock.json | 43 ++++++++++ client/package.json | 1 + client/src/App.js | 17 +++- client/src/components/ContentPage.jsx | 109 ++++++++++++++++++++++++++ client/src/components/Quiz.jsx | 75 ++++++++++++++++++ client/src/components/QuizPage.css | 7 ++ client/src/components/QuizPage.jsx | 78 ++++++++++++++++++ client/src/components/navbar.jsx | 5 ++ private.key | 51 ++++++++++++ private.key.pub | 1 + server/.env | 52 +++++++++++- server/models/post.js | 6 +- server/models/user.js | 2 +- server/package-lock.json | 85 ++++++++++++-------- 14 files changed, 491 insertions(+), 41 deletions(-) create mode 100644 client/src/components/ContentPage.jsx create mode 100644 client/src/components/Quiz.jsx create mode 100644 client/src/components/QuizPage.css create mode 100644 client/src/components/QuizPage.jsx create mode 100644 private.key create mode 100644 private.key.pub diff --git a/client/package-lock.json b/client/package-lock.json index 59e575f..6cb1490 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -8,6 +8,7 @@ "name": "client", "version": "0.1.0", "dependencies": { + "@google/generative-ai": "^0.1.3", "@sentry/react": "^6.1.0", "@sentry/tracing": "^6.1.0", "@testing-library/jest-dom": "^5.11.9", @@ -2208,6 +2209,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@google/generative-ai": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@google/generative-ai/-/generative-ai-0.1.3.tgz", + "integrity": "sha512-Cm4uJX1sKarpm1mje/MiOIinM7zdUUrQp/5/qGPAgznbdd/B9zup5ehT6c1qGqycFcSopTA1J1HpqHS5kJR8hQ==", + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", @@ -13153,6 +13162,12 @@ "resolved": "https://registry.npmjs.org/joi-browser/-/joi-browser-13.4.0.tgz", "integrity": "sha512-TfzJd2JaJ/lg/gU+q5j9rLAjnfUNF9DUmXTP9w+GfmG79LjFOXFeM7hIFuXCBcZCivUDFwd9l1btTV9rhHumtQ==" }, + "node_modules/jquery": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz", + "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==", + "peer": true + }, "node_modules/js-sdsl": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz", @@ -14432,6 +14447,17 @@ "node": ">=4" } }, + "node_modules/popper.js": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz", + "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==", + "deprecated": "You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/postcss": { "version": "8.4.21", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz", @@ -20446,6 +20472,11 @@ } } }, + "@google/generative-ai": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@google/generative-ai/-/generative-ai-0.1.3.tgz", + "integrity": "sha512-Cm4uJX1sKarpm1mje/MiOIinM7zdUUrQp/5/qGPAgznbdd/B9zup5ehT6c1qGqycFcSopTA1J1HpqHS5kJR8hQ==" + }, "@humanwhocodes/config-array": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", @@ -28499,6 +28530,12 @@ "resolved": "https://registry.npmjs.org/joi-browser/-/joi-browser-13.4.0.tgz", "integrity": "sha512-TfzJd2JaJ/lg/gU+q5j9rLAjnfUNF9DUmXTP9w+GfmG79LjFOXFeM7hIFuXCBcZCivUDFwd9l1btTV9rhHumtQ==" }, + "jquery": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.7.1.tgz", + "integrity": "sha512-m4avr8yL8kmFN8psrbFFFmB/If14iN5o9nw/NgnnM+kybDJpRsAynV2BsfpTYrTRysYUdADVD7CkUUizgkpLfg==", + "peer": true + }, "js-sdsl": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz", @@ -29440,6 +29477,12 @@ } } }, + "popper.js": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz", + "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==", + "peer": true + }, "postcss": { "version": "8.4.21", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz", diff --git a/client/package.json b/client/package.json index 848be7e..ac243bf 100644 --- a/client/package.json +++ b/client/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { + "@google/generative-ai": "^0.1.3", "@sentry/react": "^6.1.0", "@sentry/tracing": "^6.1.0", "@testing-library/jest-dom": "^5.11.9", diff --git a/client/src/App.js b/client/src/App.js index 2dd8c13..89439cf 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -2,9 +2,12 @@ import "./App.css"; import React, { Component } from "react"; import jwtDecode from "jwt-decode"; import { Route, Switch, Redirect } from "react-router-dom"; - +import ContentPage from "./components/ContentPage.jsx"; +import QuizPage from "./components/QuizPage.jsx"; +import Quiz from "./components/Quiz.jsx"; import http from "./services/httpService"; import { api } from "./config.js"; + import Dashboard from "./components/dashboard"; import Jumotron from "./components/common/jumbotron"; import NotFound from "./components/not-found"; @@ -39,6 +42,18 @@ class App extends Component { } + /> + } + /> + } + /> + } /> { + const ques=`Question ${index+1}: ${item.Question}`; + const ans=`answer :${item.Correct_Answer}`; + console.log(ques); + + item.Options.forEach((curOption,index1)=>{ + console.log(`${String.fromCharCode(97+index1) }) ${curOption}`); + }) + + // console.log(ans); + }) + + } + + } + + const handleSubmit=()=>{ + run(userSearch,"Content"); + setQuizSearch(`Generate 4 medium-level MCQ questions on ${userSearch} along with options. Also, mention the correct answer at the end of all questions along with the question number. Please generate questions and answers in the JSON format given below:'Question: .....Options: ....Correct_Answer: ....'ALERT: Don't use any markdowns. Give output in JSON format. Enclose all the questions in an additional curly brace.`) + run(quizSearch,"Quiz") + setUserSearch(""); + quizSearch(""); + + } + + + + return ( + <> + {/*
Hello World
*/} +
+ setUserSearch(e.target.value)} + /> + + + +