Sie sind auf Seite 1von 14

Online Examination System

Project Description
This project uses SQL Server database and J2EE. With this stand, administrator user of online exam system
creates trainees, trainers. Trainer user create questions, Tests, Schedules, etc.

Abstract
The purpose of the system is to develop Online Examination System., used to test the Domain knowledge
of the students, and employees with respect to the particular technology. The manual procedure used for
conducting exam is time consuming process and error prone due to human limitations. The System
purpose is to completely automate the old manual procedure of conducting exam to Online Web Based
Examination System.

Project Implementation:

Home.jsp :
<%@ page contentType="text/html; charset=utf-8" language="java"
import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TCS Test</title>
<script type="text/javascript" src="9lessons.js"></script>
<script type="text/javascript">

var ck_username = /^[A-Za-z0-9_]{1,20}$/;


function validate(form){
var username = form.username.value;
var password = form.password.value;
var errors = [];

if (!ck_username.test(username)) {
errors[errors.length] = "You valid UserName no special char .";
}

if (!ck_password.test(password)) {
errors[errors.length] = "You must enter a valid Password min 6
char.";
}

if (errors.length > 0) {
reportErrors(errors);
return false;
}

return true;
}

function reportErrors(errors){
var msg = "Please Enter Valide Data...\n";
for (var i = 0; i<errors.length; i++) {
var numError = i + 1;
msg += "\n" + numError + ". " + errors[i];
}
alert(msg);
}
</script>

</head>
<body>
<h1 align="center"><strong>Tata Consultancy
Service</strong></h1>
<form name="login" action="login" method="post"
name="login" id="login" onSubmit="return validate(this);">

<p> Username :
<input type="text" name="username"
id="username" />

</p>
<p>Password :
<input type="text" name="password"
id="password" />

</p>
<blockquote>
<blockquote>
<p>
<input type="submit" name="submit"
id="submit" value="Submit" onclick="validate()"/>

</p>

<p />
</form>

</body>
</html>

instructions.jsp

<%@ page import="java.util.Random;"%>


<%@ page contentType="text/html; charset=utf-8" language="java"
import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Instructions</title>
</head>

<body>
<% String username=request.getParameter("refno");%>
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:OnlineTest";
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt = con.createStatement();
int max = 35;
int[] temp = new int[max + 1];
for (int idx = 1; idx <= 35; idx++) {
temp[idx] = idx;
}
int t, x;
Random randomGenerator = new Random();
for (int idx = 1; idx < 35; ++idx) {
x = randomGenerator.nextInt(max - 1);
x = x + 1;
t = temp[max];
temp[max] = temp[x];
temp[x] = t;
max--;
}
stmt.execute("create table " + username + "(sno
numeric,qno numeric,choice numeric,cor_ans numeric,mark numeric);");
for (int idx = 1; idx <= 35; idx++) {
stmt.executeUpdate("insert into " + username + "
values ('" + idx + "','" + temp[idx] + "',0,0,0)");
}
con.close();

catch(Exception e)
{
System.out.println(e);
}
%>
<h3>Username : <%= request.getParameter("refno")%>
</h3>
<h3>Password :<%= request.getParameter("dob")
%></h3>
<hr />
<h3>Instructions : </h3>
<p> <strong>1.</strong>  The test has only one section with 35
objective type questions. </p>
<p><strong>2.</strong>  On the right top corner you will have a
timer <span id="IL_AD3">counting</span> down and links to questions
of that section. From the timer you can see the time left for that
section and through the questions links you can move to any questions
within that section only. </p>
<p><strong>3.</strong> After answering a questions click the Submit
button to register your answer. You can always come back and change it
within the stipulated time. </p>
<p><strong>4.</strong> EXIT button takes you out of the section. So
click it ONLY after you have attempted all questions of a section.
</p>
<p><strong>5.</strong> After you finish answering CLICK EXIT. DON’T
close the main window WITHOUT clicking EXIT! </p>
<p><strong>6.</strong> For each wrong answer 1/3 of the mark will be
deduced.</p>
<p><strong>7. </strong>Your score will be displayed out of <strong>100
</strong>when you exit the test.</p>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="Home.jsp">
<p />
<label />
<input type="checkbox" name="accept" id="accept"
/>
I read the above instructions clearly and accept
it</p>
<input type="submit" name="submit"
id="submit" value="Start Test" />
</blockquote></blockquote></form>
<p>&nbsp;</p>
</body>
</html>

Test.jsp:

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


import="java.sql.*" errorPage=""%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Page</title>
<% Integer n=0; int quesFetch=1;int ans=0;int mark=0; %>
<% String ans1=null;%>
<% String ans2=null;%>
<% String ans3=null;%>
<% String ans4=null;%>
<% int ret=1;%>
<script language="javascript" type="text/javascript">
function log()
{
document.form1.qno.value=document.form1.dupqno.value;
document.form1.submit();
}
</script>
</head>

<body onload="init()" ondragstart="return false" onselectstart="return


false">
<% String username=(String)session.getAttribute("username");%>
<% String name=null;%>
<%
boolean flag=false;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:OnlineTest";
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from
user_details");
while(rs.next())
{
name=rs.getString(1);
if(username.compareToIgnoreCase(rs.getString(2))==0)
{
flag=true;
break;
}
}
if(!flag)name="Not Found";
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
%>
Welcome,<%= name%>
<p>Today :
<!-- #BeginDate format:Sw1a -->30 September, 2010 3:54 PM<!--
#EndDate -->
</p>
<p>Q.<%try { n=
Integer.parseInt(request.getParameter("qno"));if(n>35)n=n
%35;}catch(Exception e){n=1;} out.print(n); %></p>
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:OnlineTest";
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from " +
username + "");
while(rs.next())
{
if(n==rs.getInt(1))
{quesFetch=rs.getInt(2);break;}
}
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
%>
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:OnlineTest";
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from " +
username + "");
String q=request.getParameter("pre");
String a=request.getParameter("answer");
String ca=request.getParameter("ans");
String m=request.getParameter("mark");
if(q!=null && a!=null)
{
rs.absolute(Integer.parseInt(q));
rs.updateInt(3, Integer.parseInt(a));
rs.updateInt(4,Integer.parseInt(ca));
rs.updateInt(5,Integer.parseInt(m));
rs.updateRow();
}
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
%>
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:OnlineTest";
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR
_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from
questions");
rs.absolute(quesFetch);
out.println(rs.getString(2));
ans1=rs.getString(3);
ans2=rs.getString(4);
ans3=rs.getString(5);
ans4=rs.getString(6);
ans=rs.getInt(7);
mark=rs.getInt(8);
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
%>
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:OnlineTest";
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from " +
username + "");
while(rs.next())
{
if(n==rs.getInt(1))
{quesFetch=rs.getInt(2);break;}
}
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
%>
<%
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:OnlineTest";
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("select * from " +
username + "");
rs.absolute(n);
ret=rs.getInt(3);
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
%>
<form id="form1" name="form1" method="post" action="test.jsp">
<input type="hidden" name="qno" value="" />
<input type="hidden" name="pre" value="<%= n%>" />
<input type="hidden" name="dupqno" value="<%= n+1%>" />
<input type="hidden" name="ans" value="<%= ans%>" />
<input type="hidden" name="mark" value="<%= mark%>" />
<p></p>
<p></p>
<p>
<label>
<input type=radio name="answer" style=display:none; value="0"
checked=checked />
<% if(ret==0) { %>
<input type=radio name="answer" style=display:none; value="0"
checked=checked /><br />
<input type="radio" name="answer" value="1" id="answer_0"
/><%= ans1%><br />
<input type="radio" name="answer" value="2" id="answer_1" /><
%= ans2%><br />
<input type="radio" name="answer" value="3" id="answer_2" /><
%= ans3%><br />
<input type="radio" name="answer" value="4" id="answer_3" /><
%= ans4%><br />
<% } if(ret==1) { %>
<input type=radio name="answer" style=display:none;
value="0" /><br />
<input type="radio" name="answer" value="1" id="answer_0"
checked="checked"/><%= ans1%><br />
<input type="radio" name="answer" value="2" id="answer_1" /><
%= ans2%><br />
<input type="radio" name="answer" value="3" id="answer_2" /><
%= ans3%><br />
<input type="radio" name="answer" value="4" id="answer_3" /><
%= ans4%><br />
<% }if(ret==2){ %>
<input type=radio name="answer" style=display:none;
value="0" />
<input type="radio" name="answer" value="1" id="answer_0" /><
%= ans1%><br />
<input type="radio" name="answer" value="2" id="answer_1"
checked="checked"/><%= ans2%><br />
<input type="radio" name="answer" value="3" id="answer_2" /><
%= ans3%><br />
<input type="radio" name="answer" value="4" id="answer_3" /><
%= ans4%><br />
<% }if(ret==3){ %>
<input type=radio name="answer" style=display:none;
value="0" />
<input type="radio" name="answer" value="1" id="answer_0"/><
%= ans1%><br />
<input type="radio" name="answer" value="2" id="answer_1" /><
%= ans2%><br />
<input type="radio" name="answer" value="3" id="answer_2"
checked="checked"/><%= ans3%><br />
<input type="radio" name="answer" value="4" id="answer_3" /><
%= ans4%><br />
<% }if(ret==4){ %>
<input type=radio name="answer" style=display:none;
value="0" />
<input type="radio" name="answer" value="1" id="answer_0" /><
%= ans1%><br />
<input type="radio" name="answer" value="2" id="answer_1" /><
%= ans2%><br />
<input type="radio" name="answer" value="3" id="answer_2" /><
%= ans3%><br />
<input type="radio" name="answer" value="4" id="answer_3"
checked="ckecked"/><%= ans4%><br />
<% } %>
</label>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p />
<label />
<input type="reset" value="Reset" />
<input type="button" name="Submit " id="Submit "
value="Submit Answer & Go Next" onclick="log()"/>
<input type="button" name="next" id="next"
value="Next" onclick="log()"/>
</p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp; </p>
</body>
</html>

Register.jsp :

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


import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" media="all"
href="jsDatePick_ltr.min.css" />
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>

<script type="text/javascript">
window.onload = function(){
new JsDatePick({
useMode:2,
target:"inputField",
dateFormat:"%d-%M-%Y"
});
};
</script>
<title>Register</title>
</head>
<body ondragstart="return false" onselectstart="return false">
<form id="form1" name="form1" method="post"
action="registration">
<label>
<blockquote>
<blockquote>
<p>Name :
<input type="text" name="name" id="name" />
</p>
</blockquote>
</blockquote>
</label>
<label>Reference Number :
<input type="text" name="refno" id="refno" />
</label>
<p>
<label>
<blockquote>
<blockquote>
<p>Degree
:
<input type="text" name="degree"
id="degree" />
</p>
</blockquote>
</blockquote>
</label>
</p>
<p>
<label>
<blockquote>
<p>College Name :
<input type="text" name="college"
id="college" />
</p>
</blockquote>
</label>
</p>
<p>
<label>Year of Completed/Passing :
<input type="text" name="passyear" id="passyear"
/>
</label>
</p>
<p>
<label>
<blockquote>
<blockquote>
<p>Date of Birth
:
<input type="text" size="12" name="dob"
id="inputField" />

</p>
</blockquote>
</blockquote>
</label>
</p>
<p>
<label>
<blockquote>
<blockquote>
<p>Mobileno :
<input type="text" name="mobile"
id="mobile" />
</p>
</blockquote>
</blockquote>
</label>
</p>
<p>
<label>
<blockquote>
<blockquote>
<p>Mail ID
:
<input type="text" name="email" id="email"
/>
</p>
</blockquote>
</blockquote>
</label>
</p>
<p>
<label>
<blockquote>
<p>Address Line 1 :
<input type="text" name="addline1"
id="addline1" />
</p>
</blockquote>
</label>
</p>
<p>
<label>
<blockquote>
<p>Address Line 2
:
<input type="text" name="addline2"
id="addline2" />
</p>
</blockquote>
</label>
</p>
<p>
<label>
<blockquote>
<blockquote>
<p>District :
<input type="text" name="district"
id="district" />
</p>
</blockquote>
</blockquote>
</label>
</p>
<p>
<label>
<blockquote>
<blockquote>
<p>Pin Code
:
<input type="text" name="pincode"
id="pincode" />
</p>
</blockquote>
</blockquote>
</label>
</p>
<p>
<label>
<blockquote>
<blockquote>
<p>University
:
<input type="text" name="university"
id="university" />
</p>
</blockquote>
</blockquote>
</label>
</p>
<p>
<label>
<input type="checkbox" name="accept" id="accept"
/>
I agree to the Company's rules and
regulation</label>
</p>
<p>
<label>
<blockquote>
<blockquote>
<blockquote>
<p>
<input type="submit" name="submit" id="submit"
value="Submit" />
</p>
</blockquote>
</blockquote></form>
<blockquote>
</body>
</html>

Output Screenshots :

Das könnte Ihnen auch gefallen