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
1 change: 1 addition & 0 deletions Untitled Diagram.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="app.diagrams.net" modified="2022-11-25T05:27:14.676Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" etag="PL_oels7fWCJHnOmJEM4" version="20.6.0" type="github" pages="2"><diagram id="o3e1TwByA-OSzVVfAwpE" name="Page-1">5VpNc+I4EP0te6A2OZCyZTDmOMlmdw47VVuTw5yFLWwlsuTIMob59duyJfwFhNkNgWEuwW61vl4/PXVDRt5Duv5L4iz5IiLCRsiJ1iPvjxFC84kPf7VhUxt8a4gljWqT2xie6HdijI6xFjQiecdRCcEUzbrGUHBOQtWxYSlF2XVbCtadNcMxGRieQsyG1m80UkltDaZOY/9MaJzYmV3HtKTYOhtDnuBIlC2T9zjyHqQQqn5K1w+EaewsLnW/P/e0bhcmCVfHdPjy1fGn46/R+nn6LXlG8yJ+eh1P61FWmBVmw2axamMRIBEAYl6FVImIBcfssbHeS1HwiOhpHHhrfP4WIgOjC8ZnotTGRBcXSoApUSkzrfWceqK9ezOmXBQyJAc2ZDmCZUzUAb/JNgLAXCJSouQG+knCsKKr7jqw4VC89WtghgeD9A+g7g5Q14tFzmtBckUFH8Sgi3CZUEWeMlwBUcKx24XmikhF1ofxHO7fdPB8Q1pzaj3L6rI5A64ldtLi/8Q5EWSzayPq/yWg6fqPoFw1gZv1A4d6AakPhunVi8l2Gf89TJNBmHBGYSSY83UQsDd43I3WO7B62gMHzY9ktX8qVttb7npoHRypv/Oz6i/6VWF395yQj8E92AG7z2C99zA+1llcgmVuNuC/Fjo1ui/UUne0r/AUm8+qZ55h3omcdQwFE3LkfdK7ixc3cNJg0Y79uK2GgHy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5lkGII4wIwXfjaRvOxllzEsMEWIWETdFfNMKkRf2Z2eOPQONEZ7ZM5UmJnqyAIiER3w0gZ2k4C8E5tqN0vwBWc6d5aeO+HvF2CxOQ4VsCEvJt/oTe9826nBfu08vG87NPjt2+ZktYqXasVouVpgAiyYgyucCExzwjbNmjd4KXWQR1Hkta/ZwfnOcK/AOIlZKXlMgllGDKlDcsxbaLbxdQZz26UwUVvBQhnNie7auSISIGPDUx6BSRlQw8BRSVDBTACNLteCVE1VTczetplwPF/HtUcG4qfAAVZjcVGh7cq6owv6nQ8OBdUwW9zIEKzyUUSHlWTOTYJRRhlZNm4zt5DRhTSRiNMzkOJVkgJuKoRCAQ9qfpnZKhAuxAnbHqkmHp43nXH9ndwZwMjmvXPFcVWxOWLlC0sKf4W47NzzNlrQee+5otUxuVNjK53zbInml7PXT2cY2lA8/WIcFbTwv/qh0SHO2QRneCkNZ7l7cy54t89s7XdcGYvMzW+l+/j9xxH7kH2sg+0Ebe2drInZDcMNtSatjec1lfn+9I2Aje2XXWzshJUbzy/qsE/51x1xozfujDdVnGvQnjPG8/+w3nUhBTAx+HRv9idSvN/pet8Q3+e53lXw==</diagram></mxfile>
76 changes: 72 additions & 4 deletions components/Acc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,47 @@ import AccordionDetails from '@mui/material/AccordionDetails';
import Typography from '@mui/material/Typography';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import {Button} from '@mui/material';
import { useTimer } from 'react-timer-hook';
import { data } from 'autoprefixer';




export default function Acc(props){
const {
seconds,
minutes,
hours,
days,
isRunning,
start,
pause,
resume,
restart,
} = useTimer(props.timestamp);

const emitter=(e)=>{
(async () => {
const stamp=new Date();
const rawResponse = await fetch('/api/set_answer',
{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},

body: JSON.stringify({ans:props.question.answer,timestamp:stamp.toUTCString(),time:15})
}
);
const content = await rawResponse.json();

console.log(content);
})();
}



return(
<div>
<Accordion sx={{m:2}}>
Expand All @@ -16,13 +55,42 @@ export default function Acc(props){
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography>Question {props.question.number}</Typography>
<Typography >Question {props.question.number}</Typography>
</AccordionSummary>
<AccordionDetails>
<Typography>
{props.question.question}

<div className='flex justify-center'>
<div>
<div className='bg-transparent flex mt-2 m-4 justify-center items-center w-[50px] h-[50px] rounded-full outline outline-4 outline-violet-900'>
<span className='select-none text-black text-[30px]'>{seconds}</span>
</div>

</div>
</div>

<Typography variant={'h1'}>
{props.question.question}



</Typography>
<Button onClick={()=>{props.emitter(props.question)}} >start</Button>
<div className="mt-6">

<div className='text-center text-[20px] text-white-500 content-center mt-8 flex flex-wrap justify-around'>

<div id={0} className={`bg-indigo-500 cursor-pointer select-none p-1 md:p-2 w-[250px] md:m-4 m-3 rounded-md`}>{props.question.options[0]}</div>
<div id={1} className={`bg-yellow-400 cursor-pointer select-none p-1 md:p-2 w-[250px] md:m-4 m-3 rounded-md`}>{props.question.options[1]}</div>
<div id={2} className={`bg-pink-400 cursor-pointer select-none p-1 md:p-2 w-[250px] md:m-4 m-3 rounded-md`}>{props.question.options[2]}</div>
<div id={3} className={`bg-fuchsia-400 cursor-pointer select-none p-1 md:p-2 w-[250px] md:m-4 m-3 rounded-md`}>{props.question.options[3]}</div>


</div>
</div>
<Button onClick={()=>{
const tt=new Date();
tt.setSeconds(tt.getSeconds()+15);
restart(tt)
emitter(props.question)}} >start</Button>
</AccordionDetails>
</Accordion>
</div>
Expand Down
41 changes: 29 additions & 12 deletions components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,34 @@ import { useAuthState } from "react-firebase-hooks/auth";

function Login(){
const login_a=useAppContext()
const [login_status,setLoginstatus]=useState("Login to Start test Fast!")
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [user, loading, error] = useAuthState(auth);
const navigate = useRouter();
function loginHandler(){
signInWithGoogle();
}
function myloginHandler(){
(async () => {
const rawResponse = await fetch('/api/validate_user', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({email:email,opt:password})
});
const content = await rawResponse.json();
if(content.result==="success")
{login_a.setEmail(email);
navigate.push("/nickname");}
else{
setLoginstatus("Failed to login");
}
console.log(content);
})();
}
useEffect(() => {
if (loading) {
console.log('Loading')
Expand All @@ -33,33 +54,29 @@ login_a.setEmail(user.email);
<div className='sm:p-16 p-2 flex relative justify-around'>
<div className='m-4 z-50'>
<Image src={logo} className='mt-4' alt='Loading'/>
<div className='text-[30px] text-violet-800'>Login</div>
<p className='my-2 text-gray-600'>Login to Start test Fast!</p>
<div onClick={myloginHandler} className='text-[30px] text-violet-800'>Login</div>
<p className='my-2 text-gray-600'>{login_status}</p>
<label className='text-[15px]'>Email*</label>
<div className='outline outline-1 outline-gray-400 rounded-2xl mt-2'>
<input type='text' value={email}
onChange={(e) => setEmail(e.target.value)} className='cursor-pointer outline outline-0 m-2 mx-4 bg-transparent' placeholder='Enter your email address' />
</div>
<label className='text-[15px]'>Password*</label>
<div className='outline outline-1 outline-gray-400 rounded-2xl mt-2'>
<input type='password' value={password}
<input type='text' value={password}
onChange={(e) => setPassword(e.target.value)} className='cursor-pointer outline outline-0 m-2 mx-4 bg-transparent' placeholder='Enter your password' />
</div>
<div className='flex justify-between my-2'>
<div className='text-gray-900'>
Remember me
</div>
<div>
<input type='checkbox' className='mr-4' />
</div>


</div>
<div className='cursor-pointer rounded-2xl bg-gradient-to-r from-[#8cabff] to-[#7c5cff] text-center text-white text-[20px] p-1 my-3'><button onClick={() => logInWithEmailAndPassword(email, password)}>Login</button></div>
<div className='cursor-pointer rounded-2xl bg-gradient-to-r from-[#8cabff] to-[#7c5cff] text-center text-white text-[20px] p-1 my-3'><button onClick={myloginHandler}>Login</button></div>
<div onClick={loginHandler} className='cursor-pointer flex outline outline-2 rounded-2xl outline-gray-300 items-center justify-center'>
<Image src={google} className='h-[16px] m-2' alt='Loading'
<Image src={google} className='h-[20px] m-4' alt='Loading'
/>
<div>Continue with Google</div>
</div>
<div className='cursor-pointer rounded-2xl outline outline-1 p-2 hover:text-white hover:bg-gradient-to-r from-[#8cabff] to-[#7c5cff] hover:from my-4 text-violet-900 text-[15px] text-center outline-[#7c5cff]'>Register</div>

</div>
<div className='ml-4 md:relative absolute z-40'>
<Image src={shark} className='h-[500px] opacity-30 md:opacity-100 blur-md md:blur-none' alt='Loading'/>
Expand Down
29 changes: 21 additions & 8 deletions components/Question.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ function Questions(props) {
const[selected,setSelected]=useState(-1);
const [colors,setColors]=useState(["bg-white","bg-white","bg-white","bg-white"]);
const [isOver,setOver]=useState(false);
const [button_color,setButtoncolor]=useState("green")
const [clickTime,setClicktime]=useState(15);
const [button_state,setButtonstate]=useState({color:"green",text:"submit"})
const[question,setQuestion]=useState({count:"1" ,number:'1',question:'What the fastest train in the India and what is its maximum speed or operating speed?',options:['Vande Bharat,130','Rajdhani Express ,120','Duranto Express,130','Bulllet Train,230']})

function MyTimer( {expiryTimestamp} ) {
const {
seconds,
isRunning,
} = useTimer({ expiryTimestamp, onExpire:() => {
setOver(true);
setButtoncolor("green")
setButtonstate({color:"sky",text:"request question"})
}});

const handleClick=async (e)=>{
Expand All @@ -33,7 +34,7 @@ function Questions(props) {
}
const handleSubmit=async(e)=>{
setOver(true);

if(button_state.color==="green"){
(async () => {
const rawResponse = await fetch('/api/send_answer', {
method: 'POST',
Expand All @@ -47,7 +48,19 @@ function Questions(props) {

console.log(content);
})();
setButtoncolor('purple')
setButtonstate({color:"purple",text:"submitted"})}
if(button_state.color==="sky"){
(async () => {
const rawResponse = await fetch('/api/request_question', { });
const content = await rawResponse.json();
if(content.count==="0") return;
setButtonstate({color:"green",text:"submit"});
setQuestion(content);
resetStates();
console.log(content);
})();

}
}

// useEffect(()=>(console.log(selected)),[selected])
Expand All @@ -63,13 +76,13 @@ function Questions(props) {
</div>
</div>
<div className="mt-6">
<h1 className='text-white font-bold sm:text-[30px] text-[20px] text-center'>{props.question.question}</h1>
<h1 className='text-white font-bold sm:text-[30px] text-[20px] text-center'>{question.question}</h1>
<div className='text-center text-[20px] text-violet-500 content-center mt-8 flex flex-wrap justify-around'>
{props.question.options.map((option,id)=>{
{question.options.map((option,id)=>{
return (<div key={id} onClick={handleClick} id={id} className={`${colors[id]} cursor-pointer select-none p-1 md:p-2 w-[250px] md:m-4 m-3 rounded-md`}>{option}</div>
)
})}
<div onClick={handleSubmit} className={`bg-${button_color}-400 cursor-pointer select-none p-1 md:p-2 w-[250px] md:m-4 m-3 rounded-md`}>Submit</div>
<div onClick={handleSubmit} className={`bg-${button_state.color}-400 cursor-pointer select-none p-1 md:p-2 w-[250px] md:m-4 m-3 rounded-md`}>{button_state.text}</div>
</div>
</div>
</div>
Expand Down
87 changes: 58 additions & 29 deletions pages/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,86 @@ import Accord from '../components/Accordination';
import {Paper,Input} from '@mui/material';
import Acc from '../components/Acc';
import { useEffect,useState } from 'react';
import io from 'socket.io-client'
import { Timer } from '@mui/icons-material';
let socket;

const data=[
{number:'1',question:"which is the world's biggest real estate company?",options:["L and T","McDonalds","Reliance","DLF"],ans:"McDonalds"},
{number:'2',question:"which Indian movie has the highest worldwide collection?",options:["Dangal","3 Idiots","Bajrangi Bhaijaan","PK"],ans:"Dangal"},
{number:'3',question:"Who was the first female president of India?",options:["Sushma Swaraj","Droupadi Murmu","Pratibha Patil","Sarojini Naidu"],ans:"Pratibha Patil"},
{number:'4',question:"who is the golden investor of 2k22 hillfair?",options:["Unacademy","SJVNL","Dayal Sweets","Byjus"],ans:"Unacademy"},
{number:'5',question:"'Nabha Sparsham Deeptam' is the motto of which military unit of india? ",options:["Coast Guard","Air Force","Air Force","Navy"],ans:"Air Force"},
{number:'6',question:"what is the full form of GDP?",options:["Growth Domestic Price","Growth Daily Product","Gross Daily Product","Gross Domestic Product"],ans:"Gross Domestic Product"},
{number:'7',question:"When is the ‘National Girl Child Day’ celebrated annually in India?",options:["21 March","14 November","24 January","5 December"],ans:"24 January"},
{number:'8',question:"Who has been appointed new Prime Minister of United Kingdom?",options:["Boris Johnson","Rishi Sunak","Angela Merkel","Byjus"],ans:"Rishi Sunak"},
{number:'9',question:"which company has the tag line of 'zindagi ke sath bhi zindagi ke baad bhi'?",options:["LIC","Bajaj Finance","SBI","HDFC"],ans:"LIC"},
{number:'10',question:"What was the theme of Hill'fair 2022? ",options:["Mirage-Ocean of mystique","Ocean-Mirage of Pharoah","Pharaoh-Ocean of mystique","Mirage-oasis of mystique"],ans:"Mirage-oasis of mystique"},
{number:'11',question:"The name 'PARAM' is an Indian Technology, what is it ?",options:["Supercomputer","Submarine","Rocket","Helicopter"],ans:"Supercomputer"},
{number:'12',question:"which of these colours are not present in olympic rings?",options:["Red","Green","Blue","orange"],ans:"orange"},
{number:'13',question:"Which stock market crash was biggest in the history?",options:["1994","1992","1991","1983"],ans:"1992"},
{number:'14',question:"What is the full form of LCD?",options:["liquid crystal display","liquid crystal diode","lithium crystal diode","large crystal device"],ans:"liquid crystal display"},
{number:'15',question:"Company with biggest market capitalization in India?",options:["Tata","Adani","Reliance","Unilever"],ans:"Reliance"},
{number:'16',question:"When was E-Cell NIT Hamirpur formed? ",options:["2017","2018","2019","2008"],ans:"2018"},
{number:'17',question:"which is the oldest stock exchange in asia? ",options:["bse","nse","cse(colombo)","cse(bejing)"],ans:"Supercomputer"},
{number:'18',question:"What was the most-watched series on Netflix in 2019?",options:["Squid Games","stranger things","Never Have I ever","Breaking Bad"],ans:"stranger things"},
{number:'19',question:"which brand of tata group is indulged in jewellery related business ?",options:["kalyan ","PC Jewelers ","tanishq","BlueStone"],ans:"tanishq"},
{number:'20',question:"Latest Indian Unicorn>?",options:["Molbio Diagnostics","OneCard","Shiprocket","Helicopter"],ans:"Molbio Diagnostics"},


]

export default function Home(){
const [timer,setTimer]=useState(15);
useEffect(() => {
socketInitializer();

return () => {
console.log("This will be logged on unmount");
}
})

const socketInitializer = async () => {
await fetch('/api/socket');
socket = io()

socket.on('connect', () => {
console.log('connected')
})


}
const handleUpdate=(e)=>{
setTimer(e.target.value)
}


const [Questions,setQuestions]=useState([
{number:'1',question:'What the fastest train in the India and what is its maximum speed or operating speed?',
options:['Vande Bharat,130','Rajdhani Express ,120','Duranto Express,130','Bulllet Train,230']}, {number:'2',question:'hat the fastest train in the India and what is its maximum speed or operating speed?',options:['Vande Bharat,130','Rajdhani Express ,120','Duranto Express,130','Bulllet Train,230']},
{number:'3',question:'at the fastest train in the India and what is its maximum speed or operating speed?',options:['Vande Bharat,130','Rajdhani Express ,120','Duranto Express,130','Bulllet Train,230']}]);
const emitter=(e)=>{
console.log(e);
const time = new Date();
time.setSeconds(time.getSeconds() + parseInt(timer));
e.time=time
e.colors=["bg-white","bg-white","bg-white","bg-white"]
socket.emit('input-change',JSON.stringify( e));
(async () => {
const rawResponse = await fetch('/api/update_question_state',
{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({state:""})
}
);
const content = await rawResponse.json();

console.log(content);
})();
}
// useEffect(()=>{
// (async () => {
// const rawResponse = await fetch('/api/showq' );
// const content = await rawResponse.json();
// setQuestions(content);
// //console.log(content);
// })();
// })

const questions=[
{number:'1',question:'What the fastest train in the India and what is its maximum speed or operating speed?',
options:['Vande Bharat,130','Rajdhani Express ,120','Duranto Express,130','Bulllet Train,230']},

const time = new Date();
time.setSeconds(time.getSeconds() + 300);


{number:'2',question:'hat the fastest train in the India and what is its maximum speed or operating speed?',options:['Vande Bharat,130','Rajdhani Express ,120','Duranto Express,130','Bulllet Train,230']},
{number:'3',question:'at the fastest train in the India and what is its maximum speed or operating speed?',options:['Vande Bharat,130','Rajdhani Express ,120','Duranto Express,130','Bulllet Train,230']}
]
const questions=data


return (
<Paper sx={{p:5}}>
{questions.map((data,id)=>{
return (<Acc emitter={emitter} key={id} question={data}/>)
return (<Acc timestamp={time} emitter={emitter} key={id} question={data}/>)
})}
<Input value={timer} onChange={handleUpdate} >{timer}</Input>

Expand Down
10 changes: 4 additions & 6 deletions pages/api/addq.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ const prisma = new PrismaClient()

export default async function handler (req, res){
const {body}=req;
const user = await prisma.question.create(
const user = await prisma.questions.create(
{
data:{
question:body.question,
number:body.number,
state:"inactive",
time:"",
option:{
create:{
data:[
...body.option
]
}
create:body.options
}
}
});
Expand Down
Loading