Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update question added, react-scroll lib added and many more #28

Merged
merged 4 commits into from
Dec 13, 2023
Merged
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
14 changes: 7 additions & 7 deletions Server/src/controllers/quiz.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const QuizResult = require("../models/Result.model.js");
const asyncHandler = require("./../services/asyncHandler.js");

/**********************************************************************
* @desc Create a quiz
* @desc Create a quiz with title, description and category
* @route POST /api/v1/quiz/create
* @access Private/Admin
* @kushwahramkumar2003
Expand Down Expand Up @@ -281,9 +281,9 @@ exports.getQuizForAttempt = asyncHandler(async (req, res) => {
});

/*************************************************************************
* @desc Submit quiz answers
* @route POST /api/quizzes/:id/submit
* @access Public
* @desc Submit quiz answers *
* @route POST /api/quizzes/:id/submit *
* @access Public *
*************************************************************************/
exports.submitQuizAnswers = asyncHandler(async (req, res) => {
const quizId = req.params.id;
Expand Down Expand Up @@ -334,9 +334,9 @@ exports.submitQuizAnswers = asyncHandler(async (req, res) => {
});

/*************************************************************************
* @desc Get quiz results
* @route GET /api/quizzes/:id/results
* @access Private/Admin
* @desc Get quiz results *
* @route GET /api/quizzes/:id/results *
* @access Private/Admin *
*************************************************************************/
exports.getQuizResults = asyncHandler(async (req, res) => {
try {
Expand Down
24 changes: 20 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"react-icons": "^4.12.0",
"react-redux": "^9.0.2",
"react-router-dom": "^6.19.0",
"react-scroll": "^1.9.0",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
20 changes: 20 additions & 0 deletions public/graduate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 3 additions & 26 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="./graduate.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
Expand All @@ -13,34 +13,11 @@
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="apple-touch-icon" href="./graduate.svg" />

<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Online-Quiz App</title>
<title>QuizGrad</title>
</head>
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
4 changes: 1 addition & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Login from "./pages/login/login.jsx";
import Signup from "./pages/signup/SignUp.jsx";
import Home from "./pages/home/Home.jsx";
import { Toaster } from "react-hot-toast";

import { Routes, Route } from "react-router-dom";

import "./App.css";
Expand All @@ -16,12 +16,10 @@ function App() {
<Route path="/" element={<Home />}></Route>
<Route exact path="/login" element={<Login />}></Route>
<Route exact path="/SignUp" element={<Signup />}></Route>

<Route exact path="/User" element={<UserPage />}></Route>
<Route exact path="/Admin" element={<Admin />}></Route>
<Route exact path="/quiz/edit/:quiz_id" element={<EditQuiz />}></Route>
</Routes>
<Toaster />
</div>
);
}
Expand Down
7 changes: 0 additions & 7 deletions src/Components/Admin/EditQuestion.jsx

This file was deleted.

44 changes: 32 additions & 12 deletions src/Components/Admin/QuestionCard.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from "react";
import React, { useState } from "react";
import { useMutation } from "@tanstack/react-query";
import toast from "react-hot-toast";
import { deleteQuestionByQuizId } from "../../services/quiz";
import Modal from "../modal/Modal";
import UpdateQuestion from "./UpdateQuestion";

const QuestionCard = ({
question,
Expand All @@ -11,6 +13,9 @@ const QuestionCard = ({
quizId,
setRefresh,
}) => {
const [isEdit, setIsEdit] = useState(false);


const { mutate, isLoading } = useMutation({
mutationFn: ({ questionId, quizId }) => {
return deleteQuestionByQuizId({
Expand All @@ -34,18 +39,33 @@ const QuestionCard = ({
};
return (
<div>
{isEdit && (
<Modal setIsOpen={setIsEdit}>
<UpdateQuestion
quizId={quizId}
question={question}
options={options}
questionId={questionId}
answer={answer}
setRefresh={setRefresh}
setIsEdit={setIsEdit}
/>
</Modal>
)}
<div>
<h3>{question}</h3>
<ul>
{options.map((option, index) => {
return <li key={questionId + index}>{option}</li>;
})}
</ul>
<p>Answer: {answer}</p>
</div>
<div>
<button>Edit</button>
<button onClick={deleteHandler}>Delete</button>
<div>
<h3>{question}</h3>
<ul>
{options.map((option, index) => {
return <li key={questionId + index}>{option}</li>;
})}
</ul>
<p>Answer: {answer}</p>
</div>
<div>
<button onClick={() => setIsEdit(true)}>Edit</button>
<button onClick={deleteHandler}>Delete</button>
</div>
</div>
</div>
);
Expand Down
Loading