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
3 changes: 3 additions & 0 deletions Online Quiz System/WebContent/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:

Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions Online Quiz System/WebContent/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>
bluebook</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
35 changes: 35 additions & 0 deletions Online Quiz System/WebContent/adminduties.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>welcome admin</title>
<script language="javascript">
function change(url)
{
window.navigate(url);
}
</script>
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo">
<h1><a href="#">Computerization of Blue Book</a></h1>
<h2><a href="http://www.freecsstemplates.org/">Online Quiz</a></h2>
</div>
<!-- end div#logo -->
</div>
<center>
<h1>WELCOME ADMINISTRATOR</h1>
<hr><br/><br/>
<input type="button" value="START QUIZ" onclick="change('./startquiz.jsp')"><br/><br/>
<input type="button" value="DELETE ALL PREVIOUS RESULTS" onclick="change('./endquiz.jsp')"><br/><br/>
<input type="button" value=" QUIT " onclick="window.close()"><br/><br/>
</center>
</body>
</html>
63 changes: 63 additions & 0 deletions Online Quiz System/WebContent/adminlogin.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
<title>welcome admin</title>
<script language="javascript">
function fun()
{
var us=document.getElementById("id").value;
var psw=document.getElementById("psw").value;
if((us=="admin")&&(psw="admin"))
{
document.getElementById("err").style.visibility="hidden";
return true;
}
else
{
document.getElementById("err").style.visibility="visible";
document.getElementById("id").value="";
document.getElementById("psw").value="";
document.getElementById("id").focus();
return false;
}
}
</script>
</head>
<body onload="document.getElementById('id').focus()">
<div id="wrapper">
<div id="header">
<div id="logo">
<h1><a href="#">Computerization of Blue Book</a></h1>
<h2><a href="http://www.freecsstemplates.org/">Online Quiz</a></h2>
</div>
<!-- end div#logo -->
</div>
<center>
<h1>ADMINISTRATOR LOGIN</h1>
<hr>
</center>
<form action="./adminduties.jsp">
<table align="center" cellpadding="5">
<tr>
<th>User Name:</th><td><input type="text" name="id" id="id"></td>
</tr>
<tr>
<th>Password:</th><td><input type="password" name="psw" id="psw"></td>
</tr>
<tr>
<th colspan="2"><input type="submit" value=" Login " onclick="return fun()">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" value=" Cancel "></th>
</tr>
<tr>
<th colspan="2" id="err" style="visibility:hidden">Sorry!! Invalid user name / password..</th>
</tr>
</table>
</form>
</body>
</html>
117 changes: 117 additions & 0 deletions Online Quiz System/WebContent/checkanswer.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" import="java.sql.*,vdb.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%!
Connection con = null;
ResultSet rs=null,rs2=null;
int marks=0;
%>
<%
System.out.println("entered checkanswer.jsp");
String quesno=request.getParameter("ques");
System.out.println("prev ques no:"+quesno);
String ans=request.getParameter("q");
System.out.println("prev answer="+ans);
int teamno=Integer.parseInt(request.getParameter("teamno"));
System.out.println("Previous teamno="+teamno);
int marksperq=Integer.parseInt(session.getAttribute("marksperq").toString());
int negscore=Integer.parseInt(session.getAttribute("negscore").toString());
session.setAttribute("prevteam",String.valueOf(teamno));
%>
<html>
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo">
<h1><a href="#">Computerization of Blue Book</a></h1>
<h2><a href="http://www.freecsstemplates.org/">Online Quiz</a></h2>
</div>
<!-- end div#logo -->
</div>
<form name="f1">
<input type="text" name="ques" value="<%=quesno%>" id="ques">
<input type="text" name="team" value="<%=teamno%>" id="team">
</form>
</body>
</html>
<%
try
{
con=Db.connect();
System.out.println("set team status=no");
String q1="update teams set status='no' where teamname="+teamno;
Db.update(con,q1);
//get prev marks of team
System.out.println("get prev marks of team");
String q2="select marks from teams where teamname="+teamno;
rs=Db.getSelected(con,q2);
if(rs.next())//if team exists
{
//get marks
marks=rs.getInt(1);
System.out.println("prev marks="+marks);
//get correct answer from db
System.out.println("get correct ans from db");
String q3="select answer from questions where qno="+quesno;
rs2=Db.getSelected(con,q3);
if(rs2.next())//if question exists
{
//get answer
String correctans=rs2.getString(1);
System.out.println("correctanswer is="+correctans);
//compare answers
if(correctans.equals(ans))
{
//if answer is correct
System.out.println("correct answer");
//adding score
marks=marks+marksperq;
System.out.println("New marks="+marks);
}
else
{
//wrong answer
System.out.println("wrong answer");
if((marks>0)&&((marks-negscore)>=0))
{
//reducing score
System.out.println("reducing score");
marks=marks-negscore;
}
else
{
//do nothing bcoz marks are already 0
System.out.println("do nothing");
}
System.out.println("New marks="+marks);
}
//now update database with new score
System.out.println("update db with new score");
String q4="update teams set marks="+marks+",status='no' where teamname="+teamno;
Db.update(con,q4);
System.out.println("end of updation");
%>
<jsp:forward page="./next.jsp"></jsp:forward>
<%
}
else
{
System.out.println("question not found");
}
}
else
{
System.out.println("team not exists");
}

}
catch(Exception e){
System.out.println(e);
}
System.out.println("end of checkanswer.jsp");
%>
Loading