0% found this document useful (0 votes)
6 views103 pages

Mini Project

Uploaded by

harsha1puvvala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views103 pages

Mini Project

Uploaded by

harsha1puvvala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 103

Mini Project:Online Quiz Portal using Servlets,JSP ans Jdbc

Project Objective: Create an Online quiz portal, where users can explore
multiple quiz, attempt the quiz, and save their position on the learder board.
package com.demo.controller;
import java.io.IOException;
import java.util.List;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import com.demo.model.QuizListBean;
import com.demo.service.QuizListServiceImpl;
import com.demo.service.QuizListservice;
import jakarta.servlet.RequestDispatcher;

/**
* Servlet implementation class DashboardServletClass
*/
public class DashboardServletClass extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public DashboardServletClass() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
QuizListservice quizService=new QuizListServiceImpl();
List<QuizListBean> TotalQuizlist=quizService.retrive();
request.setAttribute("TotalQuizlist", TotalQuizlist);
if(!TotalQuizlist.isEmpty()) {
RequestDispatcher dispatcher=
request.getRequestDispatcher("Dashboard.jsp");
dispatcher.forward(request, response);
}else {
RequestDispatcher dispatcher=
request.getRequestDispatcher("error.jsp");
dispatcher.forward(request, response);
}

/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
// protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// doGet(request, response);
// }

package com.demo.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import com.demo.entites.QuizList;
import com.demo.service.QuizListServiceImpl;
import com.demo.service.QuizListservice;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/**
* Servlet implementation class DeleteQuizServlet
*/
public class DeleteQuizServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public DeleteQuizServlet() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String quizid=request.getParameter("quizId");
QuizList quiz=new QuizList();
quiz.setQuiz_id(quizid);
PrintWriter out=response.getWriter();
QuizListservice quizservice=new QuizListServiceImpl();

boolean delete;
try {
delete = quizservice.DeleteById(quiz);
if(delete) {
RequestDispatcher
rd=request.getRequestDispatcher("/dashboardpage");
rd.forward(request, response);
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}

package com.demo.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;

import com.demo.entites.QuizList;
import com.demo.model.QuizListBean;
import com.demo.service.QuizListServiceImpl;
import com.demo.service.QuizListservice;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/**
* Servlet implementation class GetById
*/
public class GetById extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public GetById() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String quizId=request.getParameter("quizId");
QuizList quiz=new QuizList();
quiz.setQuiz_id(quizId);
PrintWriter out=response.getWriter();
QuizListservice quizservice=new QuizListServiceImpl();
List<QuizListBean> TotalQuizlist;
try {
TotalQuizlist = quizservice.getById(quiz);
request.setAttribute("TotalQuizlist", TotalQuizlist);
if(!TotalQuizlist.isEmpty()) {
RequestDispatcher dispatcher=
request.getRequestDispatcher("Edit.jsp");
dispatcher.forward(request, response);
}else {
RequestDispatcher dispatcher=

request.getRequestDispatcher("error.jsp");
dispatcher.forward(request, response);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}

package com.demo.controller;

import java.io.IOException;
import java.io.PrintWriter;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import com.demo.entites.Users;
import com.demo.exception.AuthenticationException;
import com.demo.service.UserServiceImpl;
import com.demo.service.UsersService;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.http.HttpSession;

/**
* Servlet implementation class LoginServletClass
*/
public class LoginServletClass extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public LoginServletClass() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String username=request.getParameter("username");
String password=request.getParameter("password");

Users users=new Users();


users.setUsername(username);
users.setPassword(password);
PrintWriter out=response.getWriter();
UsersService userService=new UserServiceImpl();
try {
boolean auth=userService.authenticateUser(users);
if(auth) {

//out.println("<b> Login successfully");


HttpSession session=request.getSession();
session.setMaxInactiveInterval(10*60);
session.setAttribute("username", username);
RequestDispatcher
rd=request.getRequestDispatcher("HomePage.html");
rd.forward(request, response);
}
}catch(AuthenticationException e) {
out.println("<font color=red> Login Failed");
}
}

package com.demo.controller;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import com.demo.model.QuestionListBean;
import com.demo.service.QuestionServiceImpl;
import com.demo.service.Questionsservice;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/**
* Servlet implementation class QuestionListServletClass
*/
public class QuestionListServletClass extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public QuestionListServletClass() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
Questionsservice quizService=new QuestionServiceImpl();
try {
List<QuestionListBean> TotalQuestuinlist =
quizService.retrive();
request.setAttribute("TotalQuizlist", TotalQuestuinlist);
if(!TotalQuestuinlist.isEmpty()) {
RequestDispatcher dispatcher=
request.getRequestDispatcher("questions.jsp");
dispatcher.forward(request, response);
}else {
RequestDispatcher dispatcher=

request.getRequestDispatcher("error.jsp");
dispatcher.forward(request, response);
}
} catch (ClassNotFoundException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}

package com.demo.controller;

import java.io.IOException;

import com.demo.DAO.QuestionDAOImpl;
import com.demo.DAO.QuestionsDAO;
import com.demo.entites.Quizz;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/**
* Servlet implementation class SaveQuestionsServlet
*/
public class SaveQuestionsServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public SaveQuestionsServlet() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String question=request.getParameter("questions");
String op1=request.getParameter("option1");
String op2=request.getParameter("option2");
String op3=request.getParameter("option3");
String op4=request.getParameter("option4");
String crctans=request.getParameter("correctAnswer");
String quizId=request.getParameter("quizId");
String wt=request.getParameter("weightage");

Quizz quiz=new Quizz();


quiz.setCorrect_answer(crctans);
quiz.setQuestions(question);
quiz.setOption1(op1);
quiz.setOption2(op2);
quiz.setOption3(op3);
quiz.setOption4(op4);
quiz.setQuiz_id(quizId);
quiz.setWeightage(wt);

try {
// Call a DAO or service method to save the quiz question to the
database
QuestionsDAO quizDAO = new QuestionDAOImpl();
boolean isSaved = quizDAO.create(quiz);

if (isSaved) {
response.sendRedirect("Dashboard.jsp");
} else {
response.sendRedirect("error.jsp");
}
} catch (Exception e) {
e.printStackTrace();
response.sendRedirect("error.jsp");
}

/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
// protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// // TODO Auto-generated method stub
// doGet(request, response);
// }

package com.demo.controller;

import java.io.IOException;
import java.io.PrintWriter;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import com.demo.entites.QuizList;
import com.demo.service.QuizListServiceImpl;
import com.demo.service.QuizListservice;

/**
* Servlet implementation class updateServletClass
*/
public class updateServletClass extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public updateServletClass() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String quizid=request.getParameter("quizId");
String quizName=request.getParameter("quizName");
String quizcatogoty=request.getParameter("quizCategory");
String quizmarks=request.getParameter("quizTotalmarks");
int marks=Integer.parseInt(quizmarks);
QuizList quiz=new QuizList();
quiz.setQuiz_id(quizid);
quiz.setQuizes(quizName);
quiz.setCategories(quizcatogoty);
quiz.setTotalmarks(marks);
QuizListservice quizservice=new QuizListServiceImpl();
try {
boolean update=false;
update=quizservice.update(quiz);
if(update) {
RequestDispatcher
rd=request.getRequestDispatcher("Dashboard.jsp");
rd.forward(request, response);
}
}catch(Exception e) {
e.printStackTrace();
}
}

package com.demo.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import com.demo.entites.Users;
import com.demo.exception.AuthenticationException;
import com.demo.model.QuizListBean;
import com.demo.service.QuizListServiceImpl;
import com.demo.service.QuizListservice;
import com.demo.service.UserServiceImpl;
import com.demo.service.UsersService;

import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.http.HttpSession;

/**
* Servlet implementation class userLoginServlet
*/
public class userLoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public userLoginServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
String username=request.getParameter("username");
String password=request.getParameter("password");
Users users=new Users();
users.setUsername(username);
users.setPassword(password);
PrintWriter out=response.getWriter();
UsersService userService=new UserServiceImpl();
try {
boolean auth=userService.authenticatenormalUser(users);
if(auth) {

//out.println("<b> Login successfully");


HttpSession session=request.getSession();
session.setMaxInactiveInterval(10*60);
QuizListservice quizService=new
QuizListServiceImpl();
List<QuizListBean> TotalQuizlist=quizService.retrive();
request.setAttribute("TotalQuizlist", TotalQuizlist);
if(!TotalQuizlist.isEmpty()) {
RequestDispatcher dispatcher=
request.getRequestDispatcher("userhome.jsp");
dispatcher.forward(request, response);
}else {
RequestDispatcher dispatcher=

request.getRequestDispatcher("error.jsp");
dispatcher.forward(request, response);
}
}
}catch(AuthenticationException e) {
out.println("<font color=red> Login Failed");
}
}

/**
* @see HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}

}
package com.demo.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.demo.DAO.QuestionsDAO;
import com.demo.entites.QuizList;
import com.demo.entites.Quizz;
import com.demo.helper.ConnectionManager;

public class QuestionDAOImpl implements QuestionsDAO {


ConnectionManager connectionManager=new ConnectionManager();
@Override
public boolean create(Quizz quiz) throws ClassNotFoundException,
SQLException {
boolean created = false;
Connection contn = connectionManager.openConnection();
PreparedStatement statement = contn.prepareStatement("insert
into
quizz(quiz_id,questions,option1,option2,option3,option4,correct_answer,weig
htage) values(?,?,?,?,?,?,?,?)");
statement.setString(1, quiz.getQuiz_id());
statement.setString(2, quiz.getQuestions());
statement.setString(3, quiz.getOption1());
statement.setString(4, quiz.getOption2());
statement.setString(5, quiz.getOption3());
statement.setString(6, quiz.getOption4());
statement.setString(7, quiz.getCorrect_answer());
statement.setString(8, quiz.getWeightage());
int row = statement.executeUpdate();
while(row > 0)
{
created = true;
}
connectionManager.closeConnection();
return created;
}

@Override
public List<Quizz> retrive() throws ClassNotFoundException,
SQLException {
Connection connection =connectionManager.openConnection();
PreparedStatement
prepared=connection.prepareStatement("select
q.questions,q.option1,q.option2,q.option3,q.option4,q.s_no,q.correct_answer,
q.quiz_id from quizz q inner join quiz_list q1 on q.quiz_id=q1.quiz_id");
List<Quizz> question=new ArrayList<>();
Quizz q=new Quizz();
ResultSet rs=prepared.executeQuery();
while(rs.next()) {
q.setQuestions(rs.getString(1));
q.setOption1(rs.getString(2));
q.setOption2(rs.getString(3));
q.setOption4(rs.getString(4));
q.setS_no(rs.getInt(5));
q.setCorrect_answer(rs.getString(6));
q.setQuiz_id(rs.getString(7));
question.add(q);
}
return question;
}

@Override
public boolean deleteById(Quizz quizz) throws ClassNotFoundException,
SQLException {
boolean deleteUser=false;
try {
Connection connection=connectionManager.openConnection();
PreparedStatement
statement=connection.prepareStatement("DELETE FROM quizz WHERE s_no
= ?");
statement.setInt(1, quizz.getS_no());
int rows=statement.executeUpdate();
if(rows>0) {
deleteUser=true;
}else {
deleteUser=false;
}
}catch(Exception e) {
System.err.println(e);
}
return deleteUser;

@Override
public List<Quizz> getById(Quizz quizz) throws ClassNotFoundException,
SQLException {
List<Quizz> quizList = new ArrayList<>();
Connection connection=connectionManager.openConnection();
PreparedStatement
statemet=connection.prepareStatement("SELECT * FROM quizz WHERE s_no
= ?");
statemet.setInt(1, quizz.getS_no());
ResultSet result=statemet.executeQuery();
while(result.next()) {
Quizz q=new Quizz();
q.setQuiz_id(result.getString("quiz_id"));
q.setS_no(result.getInt("s_no"));
q.setQuestions(result.getString("questions"));
q.setOption1(result.getString("option1"));
q.setOption2(result.getString("option2"));
q.setOption3(result.getString("option3"));
q.setOption4(result.getString("option4"));
q.setCorrect_answer(result.getString("correct_answer"));
q.setWeightage(result.getString("weightage"));
quizList.add(q);
}
return quizList;
}

@Override
public boolean update(Quizz questionlist) throws
ClassNotFoundException, SQLException {
boolean updatequiz=false;
Connection connection=connectionManager.openConnection();
PreparedStatement
statement=connection.prepareStatement("update quizz set
questions=?,option1=?,option2=?,option3=?,option4=?,correct_answer=?,quiz
_id=?,weightage=?");
statement.setString(1, questionlist.getQuestions());
statement.setString(2, questionlist.getOption1());
statement.setString(3, questionlist.getOption2());
statement.setString(4, questionlist.getOption3());
statement.setString(5, questionlist.getOption4());
statement.setString(6, questionlist.getCorrect_answer());
statement.setString(7, questionlist.getQuiz_id());
statement.setString(8, questionlist.getWeightage());
int rows=statement.executeUpdate();
connectionManager.closeConnection();
if(rows>0) {
updatequiz=true;
}else {
updatequiz= false;
}
return updatequiz;
}

package com.demo.DAO;

import java.sql.SQLException;
import java.util.List;
import com.demo.entites.Quizz;

public interface QuestionsDAO {

public boolean create(Quizz quizz) throws


ClassNotFoundException,SQLException;
public List<Quizz> retrive() throws
ClassNotFoundException,SQLException;
public boolean deleteById(Quizz quizz)throws
ClassNotFoundException,SQLException;
public List<Quizz> getById(Quizz quizz) throws
ClassNotFoundException,SQLException;
public boolean update(Quizz quizList) throws
ClassNotFoundException,SQLException;
}

package com.demo.DAO;

import java.sql.SQLException;
import java.util.List;
import com.demo.entites.QuizList;
import com.demo.entites.Quizz;

public interface QuizDAO {

public boolean create(QuizList quizList) throws


ClassNotFoundException,SQLException;
public List<QuizList> retrive() throws
ClassNotFoundException,SQLException;
public boolean deleteById(QuizList quiz)throws
ClassNotFoundException,SQLException;
public List<QuizList> getById(QuizList quiz) throws
ClassNotFoundException,SQLException;
public boolean update(QuizList quizList) throws
ClassNotFoundException,SQLException;

package com.demo.DAO;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.demo.entites.QuizList;
import com.demo.helper.ConnectionManager;

public class QuizDAOImpl implements QuizDAO {


private ConnectionManager connectionManager=new
ConnectionManager();
@Override
public boolean create(QuizList quizList) throws ClassNotFoundException,
SQLException {
boolean userFound = false;
Connection contn = connectionManager.openConnection();
QuizList quiz=new QuizList();
PreparedStatement statement = contn.prepareStatement("insert
into quiz_list(quiz_id,quizes,catagory,total_marks) values(?,?,?,?)");
statement.setString(1, quiz.getQuiz_id());
statement.setString(2, quiz.getQuizes());
statement.setString(3, quiz.getCategories());
statement.setInt(4, quiz.getTotalmarks());
int row = statement.executeUpdate();
while(row > 0)
{
userFound = true;
}
connectionManager.closeConnection();
return userFound;
}

@Override
public List<QuizList> retrive() throws ClassNotFoundException,
SQLException {
Connection connection=connectionManager.openConnection();
Statement statement=connection.createStatement();
ResultSet result=statement.executeQuery("select * from
quiz_list");
List<QuizList> quizlist=new ArrayList<>();
while(result.next()) {
QuizList quiz=new QuizList();
quiz.setQuiz_id(result.getString(1));
quiz.setS_no(result.getInt(2));
quiz.setQuizes(result.getString(3));
quiz.setCategories(result.getString(4));
quiz.setTotalmarks(result.getInt(5));
quizlist.add(quiz);
}
connectionManager.closeConnection();
return quizlist;
}

@Override
public boolean deleteById(QuizList quiz) throws
ClassNotFoundException, SQLException {
boolean deleteUser=false;
try {
Connection connection=connectionManager.openConnection();
PreparedStatement
statement=connection.prepareStatement("DELETE FROM quiz_list WHERE
quiz_id = ?");
statement.setString(1, quiz.getQuiz_id());
int rows=statement.executeUpdate();
if(rows>0) {
deleteUser=true;
}else {
deleteUser=false;
}
}catch(Exception e) {
System.err.println(e);
}
return deleteUser;

@Override
public List<QuizList> getById(QuizList quiz) throws
ClassNotFoundException, SQLException {
List<QuizList> quizList = new ArrayList<>();
Connection connection=connectionManager.openConnection();
PreparedStatement
statemet=connection.prepareStatement("SELECT * FROM quiz_list WHERE
quiz_id = ?");
statemet.setString(1, quiz.getQuiz_id());
ResultSet result=statemet.executeQuery();
while(result.next()) {
QuizList q=new QuizList();
q.setQuiz_id(result.getString("quiz_id"));
q.setS_no(result.getInt("s_no"));
q.setQuizes(result.getString("quizes"));
q.setCategories(result.getString("catagory"));
q.setTotalmarks(result.getInt("total_marks"));
quizList.add(q);
}
return quizList;
}

@Override
public boolean update(QuizList quizList) throws
ClassNotFoundException, SQLException {
boolean updatequiz=false;
Connection connection=connectionManager.openConnection();
PreparedStatement
statement=connection.prepareStatement("update quiz_list set
quizes=?,catagory=?,total_marks=? where quiz_id=?");
statement.setString(1, quizList.getQuizes());
statement.setString(2, quizList.getCategories());
statement.setInt(3, quizList.getTotalmarks());
statement.setString(4, quizList.getQuiz_id());
int rows=statement.executeUpdate();
connectionManager.closeConnection();
if(rows>0) {
updatequiz=true;
}else {
updatequiz= false;
}
return updatequiz;

package com.demo.DAO;
import java.sql.SQLException;

import com.demo.entites.Users;

public interface UsersDAO {

public boolean authenticate(Users users) throws


ClassNotFoundException,SQLException;
public boolean authenticateNormalUser(Users users) throws
ClassNotFoundException,SQLException;
}

package com.demo.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.demo.entites.Users;
import com.demo.helper.ConnectionManager;

public class UsersDAOImpl implements UsersDAO {


private ConnectionManager connectionManager=new
ConnectionManager();
@Override
public boolean authenticate(Users users) throws
ClassNotFoundException, SQLException {
boolean userFound=false;
Connection connection=connectionManager.openConnection();
PreparedStatement statement=
connection.prepareStatement("select * from users where (username=? and
password=? ) and role=?");
statement.setString(1, users.getUsername());
statement.setString(2, users.getPassword() );
statement.setString(3, "1");
ResultSet resultset=statement.executeQuery();
while(resultset.next()) {
userFound=true;
}
return userFound;
}
@Override
public boolean authenticateNormalUser(Users users) throws
ClassNotFoundException, SQLException {
boolean userFound=false;
Connection connection=connectionManager.openConnection();
PreparedStatement statement=
connection.prepareStatement("select * from users where (username=? and
password=? ) and role=?");
statement.setString(1, users.getUsername());
statement.setString(2, users.getPassword() );
statement.setString(3, "0");
ResultSet resultset=statement.executeQuery();
while(resultset.next()) {
userFound=true;
}
return userFound;
}

}
package com.demo.entites;

import java.util.Objects;

public class QuizList {

private String quiz_id;


private int s_no;
private String quizes;
private String catagory;
private int totalmarks;

public QuizList() {}

public String getQuiz_id() {


return quiz_id;
}

public void setQuiz_id(String quiz_id) {


this.quiz_id = quiz_id;
}

public int getS_no() {


return s_no;
}
public void setS_no(int s_no) {
this.s_no = s_no;
}

public String getQuizes() {


return quizes;
}

public void setQuizes(String quizes) {


this.quizes = quizes;
}

public String getCategories() {


return catagory;
}

public void setCategories(String catagory) {


this.catagory = catagory;
}

public int getTotalmarks() {


return totalmarks;
}

public void setTotalmarks(int totalmarks) {


this.totalmarks = totalmarks;
}

@Override
public String toString() {
return "QuizList [quiz_id=" + quiz_id + ", s_no=" + s_no + ",
quizes=" + quizes + ", categories=" + catagory
+ ", totalmarks=" + totalmarks + "]";
}

@Override
public int hashCode() {
return Objects.hash(catagory, quiz_id, quizes, s_no, totalmarks);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
QuizList other = (QuizList) obj;
return Objects.equals(catagory, other.catagory) &&
Objects.equals(quiz_id, other.quiz_id)
&& Objects.equals(quizes, other.quizes) && s_no ==
other.s_no && totalmarks == other.totalmarks;
}

package com.demo.entites;

import java.util.Objects;

public class Quizz {


private int s_no;
private String questions;
private String option1;
private String option2;
private String option3;
private String option4;
private String correct_answer;
private String quiz_id;
private String weightage;

public String getWeightage() {


return weightage;
}

public void setWeightage(String weightage) {


this.weightage = weightage;
}

public Quizz() {}

public int getS_no() {


return s_no;
}

public void setS_no(int s_no) {


this.s_no = s_no;
}

public String getQuestions() {


return questions;
}

public void setQuestions(String questions) {


this.questions = questions;
}

public String getOption1() {


return option1;
}

public void setOption1(String option1) {


this.option1 = option1;
}

public String getOption2() {


return option2;
}

public void setOption2(String option2) {


this.option2 = option2;
}

public String getOption3() {


return option3;
}

public void setOption3(String option3) {


this.option3 = option3;
}

public String getOption4() {


return option4;
}

public void setOption4(String option4) {


this.option4 = option4;
}
public String getCorrect_answer() {
return correct_answer;
}

public void setCorrect_answer(String correct_answer) {


this.correct_answer = correct_answer;
}

public String getQuiz_id() {


return quiz_id;
}

public void setQuiz_id(String quiz_id) {


this.quiz_id = quiz_id;
}

@Override
public String toString() {
return "Quizz [s_no=" + s_no + ", questions=" + questions + ",
option1=" + option1 + ", option2=" + option2
+ ", option3=" + option3 + ", option4=" + option4 + ",
correct_answer=" + correct_answer + ", quiz_id="
+ quiz_id + ", weightage=" + weightage + "]";
}
@Override
public int hashCode() {
return Objects.hash(correct_answer, option1, option2, option3,
option4, questions, quiz_id, s_no, weightage);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Quizz other = (Quizz) obj;
return Objects.equals(correct_answer, other.correct_answer) &&
Objects.equals(option1, other.option1)
&& Objects.equals(option2, other.option2) &&
Objects.equals(option3, other.option3)
&& Objects.equals(option4, other.option4) &&
Objects.equals(questions, other.questions)
&& Objects.equals(quiz_id, other.quiz_id) && s_no ==
other.s_no
&& Objects.equals(weightage, other.weightage);
}
}

package com.demo.entites;

import java.util.Objects;

public class Users {

private String username;


private String password;
private String role;

public Users() {}

public String getUsername() {


return username;
}

public void setUsername(String username) {


this.username = username;
}

public String getPassword() {


return password;
}

public void setPassword(String password) {


this.password = password;
}

public String getRole() {


return role;
}

public void setRole(String role) {


this.role = role;
}

@Override
public String toString() {
return "Users [username=" + username + ", password=" +
password + ", role=" + role + "]";
}

@Override
public int hashCode() {
return Objects.hash(password, role, username);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Users other = (Users) obj;
return Objects.equals(password, other.password) &&
Objects.equals(role, other.role)
&& Objects.equals(username, other.username);
}

package com.demo.exception;

public class AuthenticationException extends Exception {

private String message;

public AuthenticationException(String message) {


this.message=message;
}

public String getMessage() {


return message;

package com.demo.helper;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionManager {


private Connection connection= null;
public Connection openConnection() throws ClassNotFoundException,
SQLException {
DataSource dataSource=new DataSource("db");
Class.forName(dataSource.getDriver());

connection=DriverManager.getConnection(dataSource.getUrl(),dataSource.get
Username(),dataSource.getPassword());
return connection;
}

public void closeConnection() throws SQLException {


connection.close();
}
}

package com.demo.helper;

import java.util.ResourceBundle;

public class DataSource {


private String Driver;
private String url;
private String username;
private String password;
public DataSource(String baseName) {
ResourceBundle
resourceBundle=ResourceBundle.getBundle(baseName);
this.Driver = resourceBundle.getString("driver");
this.url = resourceBundle.getString("url");;
this.username = resourceBundle.getString("username");
this.password = resourceBundle.getString("password");
}
public String getDriver() {
return Driver;
}
public String getUrl() {
return url;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}

}
package com.demo.model;

import java.sql.SQLException;
import java.util.List;
import java.util.Objects;

import com.demo.entites.Quizz;
import com.demo.service.QuestionServiceImpl;
import com.demo.service.Questionsservice;

public class QuestionListBean {

private String quizId;


private int sNo;
private String Questions;
private String Option1;
private String Option2;
private String Option3;
private String Option4;
private String CorrectAnswer;
private String weightage;

public QuestionListBean() {}

public String getWeightage() {


return weightage;
}

public void setWeightage(String weightage) {


this.weightage = weightage;
}

public String getQuizId() {


return quizId;
}

public void setQuizId(String quizId) {


this.quizId = quizId;
}

public int getsNo() {


return sNo;
}
public void setsNo(int sNo) {
this.sNo = sNo;
}

public String getQuestions() {


return Questions;
}

public void setQuestions(String questions) {


Questions = questions;
}

public String getOption1() {


return Option1;
}

public void setOption1(String option1) {


Option1 = option1;
}

public String getOption2() {


return Option2;
}

public void setOption2(String option2) {


Option2 = option2;
}

public String getOption3() {


return Option3;
}

public void setOption3(String option3) {


Option3 = option3;
}

public String getOption4() {


return Option4;
}

public void setOption4(String option4) {


Option4 = option4;
}

public String getCorrectAnswer() {


return CorrectAnswer;
}

public void setCorrectAnswer(String correctAnswer) {


CorrectAnswer = correctAnswer;
}
@Override
public String toString() {
return "QuestionListBean [quizId=" + quizId + ", sNo=" + sNo + ",
Questions=" + Questions + ", Option1="
+ Option1 + ", Option2=" + Option2 + ", Option3=" +
Option3 + ", Option4=" + Option4
+ ", CorrectAnswer=" + CorrectAnswer + ",
weightage=" + weightage + ", quizservice=" + quizservice
+ "]";
}

Questionsservice quizservice=new QuestionServiceImpl();

public List<QuestionListBean> retrive() throws ClassNotFoundException,


SQLException{
return quizservice.retrive();

public boolean create(Quizz quiz) {


return false;

}
}

package com.demo.model;

import java.util.List;

import com.demo.service.QuizListServiceImpl;
import com.demo.service.QuizListservice;

public class QuizListBean {


private String quizId;
private int serialNo;
private String quizNames;
private String quizCategories;
private int quizTotalmarks;

public QuizListBean() {}

public String getQuizId() {


return quizId;
}

public void setQuizId(String quizId) {


this.quizId = quizId;
}
public int getSerialNo() {
return serialNo;
}

public void setSerialNo(int serialNo) {


this.serialNo = serialNo;
}

public String getQuizNames() {


return quizNames;
}

public void setQuizNames(String quizNames) {


this.quizNames = quizNames;
}

public String getQuizCategories() {


return quizCategories;
}

public void setQuizCategories(String quizCategories) {


this.quizCategories = quizCategories;
}

public int getQuizTotalmarks() {


return quizTotalmarks;
}

public void setQuizTotalmarks(int quizTotalmarks) {


this.quizTotalmarks = quizTotalmarks;
}

@Override
public String toString() {
return "QuizListBean [quizId=" + quizId + ", serialNo=" + serialNo +
", quizNames=" + quizNames
+ ", quizCategories=" + quizCategories + ",
quizTotalmarks=" + quizTotalmarks + "]";
};

QuizListservice quizservice=new QuizListServiceImpl();

public List<QuizListBean> retrive(){


return quizservice.retrive();

package com.demo.service;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.demo.DAO.QuestionDAOImpl;
import com.demo.DAO.QuestionsDAO;
import com.demo.entites.QuizList;
import com.demo.entites.Quizz;
import com.demo.model.QuestionListBean;
import com.demo.model.QuizListBean;

public class QuestionServiceImpl implements Questionsservice{


QuestionsDAO quizDao=new QuestionDAOImpl();
@Override
public boolean create(Quizz quizz) throws ClassNotFoundException,
SQLException {
return quizDao.create(quizz);
}

@Override
public List<QuestionListBean> retrive() throws ClassNotFoundException,
SQLException {
List<QuestionListBean> QuestionBeanList=new ArrayList<>();
try {
List<Quizz> QuestionList=quizDao.retrive();
for(Quizz quiz:QuestionList) {
QuestionListBean QuestionListBean=new
QuestionListBean();
QuestionListBean.setQuizId(quiz.getQuiz_id());
QuestionListBean.setQuestions(quiz.getQuestions());
QuestionListBean.setOption1(quiz.getOption1());
QuestionListBean.setOption2(quiz.getOption2());
QuestionListBean.setOption3(quiz.getOption3());
QuestionListBean.setOption4(quiz.getOption4());
QuestionListBean.setsNo(quiz.getS_no());

QuestionListBean.setCorrectAnswer(quiz.getCorrect_answer());
QuestionBeanList.add(QuestionListBean);
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return QuestionBeanList;
}

@Override
public boolean deleteById(Quizz quizz) throws ClassNotFoundException,
SQLException {
return quizDao.deleteById(quizz);
}
@Override
public List<QuestionListBean> getById(Quizz quizz) throws
ClassNotFoundException, SQLException {
List<QuestionListBean> quizBeanList=new ArrayList<>();
try {
List<Quizz> quizList=quizDao.getById(quizz);
for(Quizz quiz1:quizList) {
QuestionListBean QuestionListBean=new
QuestionListBean();
QuestionListBean.setQuizId(quiz1.getQuiz_id());
QuestionListBean.setsNo(quiz1.getS_no());
QuestionListBean.setQuestions(quiz1.getQuestions());
QuestionListBean.setOption1(quiz1.getOption1());
QuestionListBean.setOption2(quiz1.getOption2());
QuestionListBean.setOption3(quiz1.getOption3());
QuestionListBean.setOption4(quiz1.getOption4());

QuestionListBean.setCorrectAnswer(quiz1.getCorrect_answer());

QuestionListBean.setWeightage(quiz1.getWeightage());
quizBeanList.add(QuestionListBean);
}
}catch(ClassNotFoundException e) {
e.printStackTrace();
}catch(SQLException e) {
e.printStackTrace();
}
return quizBeanList;
}

@Override
public boolean update(Quizz questions) throws ClassNotFoundException,
SQLException {
return quizDao.update(questions);
}

package com.demo.service;

import java.sql.SQLException;
import java.util.List;
import com.demo.entites.Quizz;
import com.demo.model.QuestionListBean;

public interface Questionsservice {


public boolean create(Quizz quizz) throws
ClassNotFoundException,SQLException;
public List<QuestionListBean> retrive() throws
ClassNotFoundException,SQLException;
public boolean deleteById(Quizz quizz)throws
ClassNotFoundException,SQLException;
public List<QuestionListBean> getById(Quizz quizz) throws
ClassNotFoundException,SQLException;
public boolean update(Quizz quizList) throws
ClassNotFoundException,SQLException;
}

package com.demo.service;

import java.sql.SQLException;
import java.util.List;

import com.demo.entites.QuizList;
import com.demo.model.QuizListBean;

public interface QuizListservice {


public List<QuizListBean> retrive();
public boolean DeleteById(QuizList quiz) throws
ClassNotFoundException,SQLException;
public List<QuizListBean> getById(QuizList quiz)throws SQLException;
public boolean update(QuizList quizList)throws ClassNotFoundException,
SQLException;

package com.demo.service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.demo.DAO.QuizDAO;
import com.demo.DAO.QuizDAOImpl;
import com.demo.entites.QuizList;
import com.demo.model.QuizListBean;

public class QuizListServiceImpl implements QuizListservice {


QuizDAO quizDAo=new QuizDAOImpl();
@Override
public List<QuizListBean> retrive() {

List<QuizListBean> quizBeanList=new ArrayList<>();


try {
List<QuizList> quizList=quizDAo.retrive();
for(QuizList quiz:quizList) {
QuizListBean quizListBean=new QuizListBean();
quizListBean.setQuizId(quiz.getQuiz_id());
quizListBean.setSerialNo(quiz.getS_no());
quizListBean.setQuizNames(quiz.getQuizes());
quizListBean.setQuizCategories(quiz.getCategories());
quizListBean.setQuizTotalmarks(quiz.getTotalmarks());
quizBeanList.add(quizListBean);
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return quizBeanList;
}
@Override
public boolean DeleteById(QuizList quiz) throws
ClassNotFoundException, SQLException {
return quizDAo.deleteById(quiz);
}
@Override
public List<QuizListBean> getById(QuizList quiz) throws SQLException {
List<QuizListBean> quizBeanList=new ArrayList<>();
try {
List<QuizList> quizList=quizDAo.getById(quiz);
for(QuizList quiz1:quizList) {
QuizListBean quizListBean=new QuizListBean();
quizListBean.setQuizId(quiz1.getQuiz_id());
quizListBean.setSerialNo(quiz1.getS_no());
quizListBean.setQuizNames(quiz1.getQuizes());

quizListBean.setQuizCategories(quiz1.getCategories());

quizListBean.setQuizTotalmarks(quiz1.getTotalmarks());
quizBeanList.add(quizListBean);
}
}catch(ClassNotFoundException e) {
e.printStackTrace();
}catch(SQLException e) {
e.printStackTrace();
}
return quizBeanList;
}
@Override
public boolean update(QuizList quizList) throws
ClassNotFoundException, SQLException {
return quizDAo.update(quizList);
}
}

package com.demo.service;

import java.sql.SQLException;

import com.demo.DAO.UsersDAO;
import com.demo.DAO.UsersDAOImpl;
import com.demo.entites.Users;
import com.demo.exception.AuthenticationException;

public class UserServiceImpl implements UsersService {


private UsersDAO usersDAO=new UsersDAOImpl();
@Override
public boolean authenticateUser(Users users) throws
AuthenticationException {
boolean userFound=false;
try {
userFound=usersDAO.authenticate(users);
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
if(!userFound) {
throw new AuthenticationException("Invalid username or
password");
}
return userFound;
}
@Override
public boolean authenticatenormalUser(Users users) throws
AuthenticationException {
boolean userFound=false;
try {
userFound=usersDAO.authenticateNormalUser(users);
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
if(!userFound) {
throw new AuthenticationException("Invalid username or
password");
}
return userFound;
}
}

package com.demo.service;

import com.demo.entites.Users;
import com.demo.exception.AuthenticationException;

public interface UsersService {

public boolean authenticateUser(Users users) throws


AuthenticationException;

public boolean authenticatenormalUser(Users users) throws


AuthenticationException;

}
///properties
///#connectivity information for mySQL
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/UsersDB
username=root
password=Phani@06

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="ISO-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create New Question</title>
<style>
/* General Styles */
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.form-container {
background-color: #fff;
padding: 30px;
border-radius: 10px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
width: 400px;
margin-top: 20px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 20px;
}

label {
font-size: 16px;
color: #333;
margin-top: 10px;
display: block;
}

input[type="text"], select {
width: 100%;
padding: 10px;
margin-top: 5px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
}

input[type="radio"] {
margin-right: 10px;
}
.options {
margin-bottom: 15px;
}

button {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

button:hover {
background-color: #45a049;
}

.footer {
text-align: center;
font-size: 12px;
color: #777;
margin-top: 20px;
}
</style>
</head>
<body>

<div class="form-container">
<h1>Create a New Question</h1>

<form action="savequestion" method="post">


<!-- Question Name -->
<label for="questions">Question Name</label>
<input type="text" id="questions" name="questions"
placeholder="Enter your question" required>

<!-- Options -->


<div class="options">
<label>Option 1</label>
<input type="text" name="option1" required>

<label>Option 2</label>
<input type="text" name="option2" required>

<label>Option 3</label>
<input type="text" name="option3" required>

<label>Option 4</label>
<input type="text" name="option4" required>
<label>Correct Answer</label>
<input type="text" name="correctAnswer" required>

<label>QuizID</label>
<input type="text" name="quizId" required>
</div>

<!-- Weightage -->


<label for="weightage">Weightage</label>
<input type="text" id="weightage" name="weightage"
placeholder="Enter weightage" required>

<!-- Submit Button -->


<button type="submit">Create Question</button>
</form>
</div>

</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Form</title>
<style>
/* General body styling */
body {
font-family: 'Arial', sans-serif;
background-color: #eaeff1;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

/* Container for the login form */


.login-container {
width: 360px;
padding: 30px 20px;
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Heading style */
.login-container h2 {
text-align: center;
color: #333;
margin-bottom: 20px;
}

/* Label style */
.login-container label {
display: block;
font-size: 14px;
color: #555;
margin-bottom: 6px;
}

/* Input field style */


.login-container input[type="text"],
.login-container input[type="password"] {
width: 100%;
padding: 12px 10px;
margin-bottom: 16px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 14px;
box-sizing: border-box;
}

/* Submit button style */


.login-container input[type="submit"] {
width: 100%;
padding: 12px;
background-color: #28a745;
color: #fff;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}

/* Hover effect for the button */


.login-container input[type="submit"]:hover {
background-color: #218838;
}

/* Paragraph style for sign-up link */


.login-container p {
text-align: center;
margin-top: 12px;
font-size: 14px;
}

.login-container p a {
color: #007bff;
text-decoration: none;
}
.login-container p a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="login-container">
<h2>Login</h2>
<form action="adminlogin" method="post">
<label for="username">Username</label>
<input type="text" id="username" name="username"
placeholder="Enter your username" required>

<label for="password">Password</label>
<input type="password" id="password" name="password"
placeholder="Enter your password" required>

<input type="submit" value="Login">


</form>
<p>Don't have an account? <a href="#">Sign up</a></p>
</div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" isELIgnored="false"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="f" %>

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Dashboard Table</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
padding: 20px;
}

table {
width: 80%;
margin: 0 auto;
border-collapse: collapse;
background-color: #ffffff;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}
th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}

th {
background-color: #4CAF50;
color: white;
}

tr:nth-child(even) {
background-color: #f2f2f2;
}

tr:hover {
background-color: #ddd;
}

.button {
padding: 6px 12px;
margin: 5px;
font-size: 14px;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
text-decoration: none;
}

.edit-button {
background-color: #4CAF50;
}

.delete-button {
background-color: #f44336;
}

.edit-button:hover {
background-color: #45a049;
}

.delete-button:hover {
background-color: #e53935;
}
</style>
</head>
<body>
<table cellspacing="2" cellpadding="2" border="2">
<thead>
<tr>
<th>Quiz Id</th>
<th>Quiz Name</th>
<th>Quiz category</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<c:forEach items="${TotalQuizlist}" var="quizlist">
<tr>
<td><c:out value="${quizlist.quizId}"/></td>
<td><c:out value="${f:toUpperCase(quizlist.quizNames)}"/></td>
<td><c:out value="${quizlist.quizCategories}"/></td>
<td>
<!-- Edit and Delete buttons -->
<a href="getbyid?quizId=${quizlist.quizId}" class="button edit-
button">Edit</a>
<a href="deletequiz?quizId=${quizlist.quizId}" class="button
delete-button">Delete</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=UTF-8"


pageEncoding="UTF-8" isELIgnored="false"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Edit Quiz</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
padding: 20px;
}

.form-container {
width: 50%;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}

h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}

.form-group {
margin-bottom: 15px;
}

label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}

input[type="text"], select {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}

.button {
display: inline-block;
padding: 10px 20px;
margin-top: 20px;
font-size: 16px;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
text-decoration: none;
background-color: #4CAF50;
}

.button:hover {
background-color: #45a049;
}

.cancel-button {
background-color: #f44336;
margin-left: 10px;
}

.cancel-button:hover {
background-color: #e53935;
}
</style>
</head>
<body>
<div class="form-container">
<h2>Edit Quiz</h2>
<!-- Accessing the first element of TotalQuizlist -->
<c:forEach items="${TotalQuizlist}" var="quiz" varStatus="status"
begin="0" end="0">
<form action="updatequiz" method="post">
<!-- Quiz ID (read-only) -->
<div class="form-group">
<label for="quizId">Quiz ID</label>
<input type="text" id="quizId" name="quizId" value="$
{quiz.quizId}" readonly>
</div>

<!-- Quiz Name -->


<div class="form-group">
<label for="quizName">Quiz Name</label>
<input type="text" id="quizName" name="quizName" value="$
{quiz.quizNames}" required>
</div>

<!-- Quiz Category -->


<div class="form-group">
<label for="quizCategory">Quiz Category</label>
<input type="text" id="quizCategory" name="quizCategory"
value="${quiz.quizCategories}" required>
</div>

<div class="form-group">
<label for="quizTotalmarks">Quiz total</label>
<input type="text" id="quizTotalmarks" name="quizTotalmarks"
value="${quiz.quizTotalmarks}" required>
</div>
<!-- Submit and Cancel buttons -->
<button type="submit" class="button">Update</button>
<a href="dashboard.jsp" class="button cancel-button">Cancel</a>
</form>
</c:forEach>
</div>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

</body>
</html>
<!DOCTYPE html>
<html lang="en" method="post">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
}

.sidebar {
width: 200px;
background-color: #333;
height: 100vh;
color: white;
padding-top: 20px;
position: fixed;
transition: width 0.3s ease;
}

.sidebar a {
text-decoration: none;
color: white;
padding: 10px 15px;
display: block;
}

.sidebar a:hover {
background-color: #575757;
}

.sidebar .submenu {
display: none;
margin-left: 20px;
}

.sidebar .submenu a {
padding-left: 30px;
}

.sidebar .active .submenu {


display: block;
}

.content {
margin-left: 220px;
padding: 20px;
width: 100%;
}

h1 {
text-align: center;
}

.dashboard-links {
margin-top: 20px;
}

.dashboard-links a {
display: block;
margin: 10px 0;
}

</style>
</head>
<body>

<!-- Sidebar -->


<div class="sidebar">
<h2 style="text-align: center;">Admin Panel</h2>
<a href="dashboardpage">Dashboard</a>

<!-- Question Manager with Sub-menu -->


<div class="question-manager">
<a href="javascript:void(0);" onclick="toggleSubmenu('question-
manager-submenu')">Question Manager</a>
<div id="question-manager-submenu" class="submenu">
<a href="questionlist">Question List</a>
<a href="AddQuestion.jsp">Add New Question</a>
</div>
</div>

<a href="#quiz-manager">Quiz Manager</a>


<a href="#logout">Logout</a>
</div>

<!-- Content Section -->


<div class="content">
<h1>Welcome to the Admin Dashboard</h1>
</div>

<script>
// Toggle the visibility of the submenu
function toggleSubmenu(id) {
var submenu = document.getElementById(id);
if (submenu.style.display === "block") {
submenu.style.display = "none";
} else {
submenu.style.display = "block";
}
}
// Function to load content dynamically into the content div (optional)
function loadContent(page) {
// Define the URL based on the page clicked
const url = "http://localhost:8085/Onine-Quiz-app/" + page;

// Use the Fetch API to make an AJAX request


fetch(url)
.then(response => response.text())
.then(data => {
// Insert the content into the content div
document.getElementById('content').innerHTML = data;
})
.catch(error => {
console.error('Error loading content:', error);
});
}
</script>

</body>
</html>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1" isELIgnored="false"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="f" %>

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Dashboard Table</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
margin: 0;
padding: 20px;
}

table {
width: 80%;
margin: 0 auto;
border-collapse: collapse;
background-color: #ffffff;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
}

th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}

th {
background-color: #4CAF50;
color: white;
}

tr:nth-child(even) {
background-color: #f2f2f2;
}

tr:hover {
background-color: #ddd;
}

.button {
padding: 6px 12px;
margin: 5px;
font-size: 14px;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
text-decoration: none;
}

.edit-button {
background-color: #4CAF50;
}

.delete-button {
background-color: #f44336;
}

.edit-button:hover {
background-color: #45a049;
}

.delete-button:hover {
background-color: #e53935;
}
</style>
</head>
<body>
<table cellspacing="2" cellpadding="2" border="2">
<thead>
<tr>
<th>S No</th>
<th>Question</th>
<th>Option-1</th>
<th>Option-2</th>
<th>Option-3</th>
<th>Option-4</th>
<th>Correct Answer</th>
<th>Action</th>

</tr>
</thead>
<tbody>
<c:forEach items="${TotalQuizlist}" var="quizlist">
<tr>
<td><c:out value="${quizlist.sNo}"/></td>
<td><c:out value="${quizlist.Questions}"/></td>
<td><c:out value="${quizlist.Option1}"/></td>
<td><c:out value="${quizlist.Option2}"/></td>
<td><c:out value="${quizlist.Option3}"/></td>
<td><c:out value="${quizlist.Option4}"/></td>
<td><c:out value="${quizlist.CorrectAnswer}"/></td>
<td>
<!-- Edit and Delete buttons -->
<a href="deletebyid?quizId=${quizlist.quizId}" class="button edit-
button">Edit</a>
<a href="deletequestion?quizId=${quizlist.quizId}" class="button
delete-button">Delete</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"


pageEncoding="ISO-8859-1" isELIgnored="false"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="f" %>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quiz List</title>
<style>
/* Basic reset */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}

/* Body styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

/* Container styling */
.container {
width: 80%;
margin: 20px;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
}

/* Heading styling */
h1 {
text-align: center;
color: #333;
margin-bottom: 20px;
}

/* Table styling */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}

th, td {
padding: 10px;
text-align: left;
border: 1px solid #ddd;
}

th {
background-color: #f9f9f9;

td {
background-color: #f9f9f9;
color: black;
}

/* Button styling */
.btn-start {
padding: 8px 15px;
background-color: red;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
text-align: center;
}

.btn-start:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h1>Quiz List</h1>
<table>
<thead>
<tr>
<th>Sr No</th>
<th>Quiz Title</th>
<th>Category</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<c:forEach items="${TotalQuizlist}" var="quizlist">
<tr>
<td><c:out value="${quizlist.serialNo}"/></td>
<td><c:out value="${f:toUpperCase(quizlist.quizNames)}"/></td>
<td><c:out value="${quizlist.quizCategories}"/></td>
<td>
<!-- Edit and Delete buttons -->
<a href="startquiz?quizId=${quizlist.quizId}" class="btn-
start">Start</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>

<script>
// JavaScript function to handle the "Start" button click
function startQuiz(quizId) {
alert('Starting quiz ' + quizId);
// You can replace this with redirection to the quiz page or logic to load the
quiz
}
</script>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Form</title>
<style>
/* Basic reset */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}

/* Body styling */
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

/* Login container */
.login-container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}

/* Login box styling */


.login-box {
background-color: #fff;
padding: 40px;
border-radius: 10px;
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
text-align: center;
width: 300px;
}

/* User icon styling */


.user-icon img {
width: 50px;
height: 50px;
border-radius: 50%;
margin-bottom: 20px;
}

/* Heading styling */
h2 {
margin-bottom: 20px;
font-size: 24px;
color: #333;
}

/* Textbox input fields */


.textbox {
margin-bottom: 20px;
}

.textbox input {
width: 100%;
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
outline: none;
}

/* Button styling */
.btn {
width: 100%;
padding: 10px;
font-size: 18px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

.btn:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-box">
<div class="user-icon">
<img src="avatar.png" alt="User Icon">
</div>
<h2>Login</h2>
<form action="userlogin" method="post">
<div class="textbox">
<input type="text" name="username" placeholder="Username"
required>
</div>
<div class="textbox">
<input type="password" name="password" placeholder="Password"
required>
</div>
<button type="submit" class="btn">Login</button>
</form>
</div>
</div>
</body>
</html>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy