Date post: | 09-Feb-2016 |
Category: |
Documents |
Upload: | mario-tanner |
View: | 224 times |
Download: | 0 times |
ONLINE EXAMINATION
PORTAL
By :
Gurjot Singh
Computer Science & Engineering- 1
00313202712
Submitted to:
Mr. Gaurav Sandhu
Ms. Bhavneet Kaur
Department of Computer Science & Engineering
Guru Tegh Bahadur Institute of Technology
GuruGobindSinghIndraprasthaUniversity
Dwarka, New Delhi
Year 2014-2015
GURJOT SINGH(00313202712) Page 1
ABSTRACT
Online examination is an internet based questionnaire. The questions can be categorized according to type, topic etc. The test is compiled with questions from different libraries. Tests are created on a random basis per student. Online examination helps students and its mission is to offer a quick and easy way to appear for the exam. It also provides the results immediately after the exam. The user can write the exam only with a valid user name and password. This examination consists of multiple choice questions and no. of options for each question out of which one is correct.
GURJOT SINGH(00313202712) Page 2
GURJOT SINGH(00313202712) Page 3
CONTENTS-
1. INTRODUCTION PG 5
2.SRS PG7
3. CODE PG12
4. RESULT PG75
5.SUMMARY PG76
6.FUTURE SCOPE PG77
7. SCREEN SHOTS PG78
GURJOT SINGH(00313202712) Page 4
INTRODUCTION1. JAVA LANGUAGE
Java is a general-purpose, concurrent, class-based, object-oriented computer programming language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java applications are typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture. Java was originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation). The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them.
James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. The language was initially called Oak after an oak tree that stood outside Gosling's office and was later renamed Java, from Java coffee, said to be consumed in large quantities by the language's creators. Gosling aimed to implement a virtual machine and a language that had a familiar C/C++ style of notation.
There were five primary goals in the creation of the Java language:
1. It should be "simple, object-oriented and familiar"2. It should be "robust and secure"3. It should be "architecture-neutral and portable"4. It should execute with "high performance"5. It should be "interpreted, threaded, and dynamic"
GURJOT SINGH(00313202712) Page 5
One characteristic of Java is portability, which means that computer programs written in the Java language must run similarly on any hardware/operating-system platform. This is achieved by compiling the Java language code to an intermediate representation called Java bytecode, instead of directly to platform-specific machine code. Java bytecode instructions are analogous to machine code, but they are intended to be interpreted by a virtual machine (VM) written specifically for the host hardware. End-users commonly use a Java Runtime Environment (JRE) installed on their own machine for standalone Java applications, or in a Web browser for Java applets.
2. ONLINE EXAMINATION OnlineExams is being launched because a need for a destination that is beneficial for both institutes and students. With this site, institutes can register and host online exams. Students can give exams and view their results. This site is an attempt to remove the existing flaws in the manual system of conducting exams.
Online Exams System fulfils the requirements of the institutes to conduct the exams online. They do not have to go to any software developer to make a separate site for being able to conduct exams online. They just have to register on the site and enter the exam details and the lists of the students which can appear in the exam.Students can give exam without the need of going to any physical destination. They can view the result at the same time.Thus the purpose of the site is to provide a system that saves the efforts and time of both the institutes and the students.
GURJOT SINGH(00313202712) Page 6
SOFTWARE REQUIREMENTS SPECIFICTIONS(SRS)
1. INTRODUCTION
1.1 PURPOSE
The purpose of site CheckTech is to take test in an efficient manner and no time wasting for checking the paper.
The main objective of this test is to efficiently evaluate the candidate thoroughly through a fully automated system that not only saves lot of time but also gives fast results.
For students they give papers according to their convenience and time.
1.2 SCOPE
GURJOT SINGH(00313202712) Page 7
Scope of this project is very broad in terms of other manually taking exams
Few of them are:-
This can be used in educational institutions as well as in corporate world.
No restriction that examiner has to be present when the candidate takes the test.
1.3 FEATURES:
Secure Easy to use Reliable and accurate No need of examiner
1.4 OVERVIEW
The test application created for taking test has following stages
Login Test Result Adding , Deleting and Modifying of questions (only
admin functionality) Show previous exams history
GURJOT SINGH(00313202712) Page 8
2. TECHNOLOGIES USED Front end as: JAVA Advanced
Back hand as: Oracle database express edition
Querying language: SQL plus
3. SYSTEM SPECIFICATIONS 3.1 Hardware requirements
In hardware requirement we require all those components which will provide us the platform for the development of the project. The minimum hardware required for the development of this project is as follows—
Operating System: Any OS with JRE 1.4 or above installed.
Processor : Pentium 4, 1 GHz or higher RAM : 256 MB or higher Hard Drive: 10 GB or higher.
GURJOT SINGH(00313202712) Page 9
These all are the minimum hardware requirement required for our project. We want to make our project to be used in any. Type of computer therefore we have taken minimum configuration to a large extent.256 MB ram is used so that we can execute our project in a least possible RAM.10 GB hard disk is used because project takes less space to be executed or stored. Therefore minimum hard disk is used. Others enhancements are according to the needs.
3.2 Software requirements Software’s can be defined as programs which run on our computer .it act as petrol in the vehicle. It provides the relationship between the human and a computer. It is very important to run software to function the computer. Various softwares are needed in this project for its development.
●Operating system—Windows 7 ●Others—Java Runtime System,Apache tomcat 7.0
We will be using visual basic as our front hand because it is easier to use and provides features to the users which is used for the development of the project.
GURJOT SINGH(00313202712) Page 10
4 USE CASE DIAGRAM
GURJOT SINGH(00313202712) Page 11
CODELOGIN.JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Login</title>
<link href="../styles.css" rel="stylesheet" />
</head>
<body>
<%@include file="/header.html"%>
<table width="100%" height="600px">
<tr>
<td valign="top"><b>TechCheck.Com</b> provides online
examination system that enables you to asses your knowledge of Java
Language.
<p /> All the you have to do is register for free and login to take
the exam.
<p /> Each exam contains 5 questions with multiple answers. Choose
GURJOT SINGH(00313202712) Page 12
the right answer and procede to next questions.
<p /> You also have option to nagivate through questions back and
forth.
<p /> At anytime you can see history of your exams, which provides
information about your previous exams.
<p /> <img src="../def.jpg " width="900" height="600">
</td>
<td width="20%" style="background-color: transparent;" valign="top">
<h2>Login</h2>
<form action="login.jsp" method="post">
<table>
<tr>
<td>Username :</td>
<td><input type="text" size="10" name="uname"
value="${param.uname}" width="150px" /></td>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" size="10" name="pwd"
width="150px" /></td>
</tr>
</table>
<p />
GURJOT SINGH(00313202712) Page 13
<input type="submit" value="Login" />
<p />
<a href="register.jsp">Register As New User</a>
<jsp:useBean id="user" class="beans.UserBean" scope="session" />
<jsp:setProperty name="user" property="*" />
<%
if (user.getUname().length() > 0)
if (!user.login())
out.println("<h4>Username or password is incorrect! Try again.");
else if(user.getUname().equals("admin"))
{ session.setAttribute("uname",user.getUname());
response.sendRedirect("../admin.jsp");
}
else
{
session.setAttribute("uname", user.getUname());
response.sendRedirect("../home.jsp");
}
%>
</form>
</td>
</tr>
GURJOT SINGH(00313202712) Page 14
</table>
</body>
</html>
REGISTER.JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Registeration</title>
<link href="../styles.css" rel="stylesheet"/>
</head>
<body>
<%@include file="../header.html"%>
<h2>Registration</h2>
<form action="registerfinal.jsp" method="post">
<table>
<tr>
<td>Username : </td>
<td><input type="text" size="10" name="uname" width="150px"/> </td>
</tr>
<tr>
<td>Password : </td>
GURJOT SINGH(00313202712) Page 15
<td><input type="password" size="10" name="pwd" width="150px"/> </td>
</tr>
<tr>
<td>Confirm Password : </td>
<td><input type="password" size="10" name="pwd2" width="150px"/> </td>
</tr>
<tr>
<td>Email Address : </td>
<td><input type="text" size="30" name="email"/> </td>
</tr>
</table>
<p/>
<input type="submit" value="Register" />
<input type="reset" value="Clear All"/>
</form>
</body>
</html>
GURJOT SINGH(00313202712) Page 16
REGISTERFINAL.JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Registeration</title>
<link href="../styles.css" rel="stylesheet"/>
</head>
<body>
<%@include file="../header.html"%>
<h2>Registration</h2>
<jsp:useBean id="user" class="beans.UserBean" scope="session"/>
<jsp:setProperty name="user" property="*" />
<%
boolean done = user.register();
if ( done )
out.println("Registration is successful! <p/>Click <a href='login.jsp'>here</a> to login.");
else
GURJOT SINGH(00313202712) Page 17
out.println("Registration is NOT successful! <p/>Please try again!");
%>
</body>
</html>
ADDQUES.JSP
<%@ 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">
<title>ADDING A QUESTION</title>
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<%@include file="header.html"%>
<h4>ADD A QUESTION</h4>
<form action="addquesimpl.jsp">
<table border=2>
<tr><td>ENTER QUESTION</td><td>:</td><td><input type=text name=t1></td></tr>
<tr><td>ENTER OPTION1</td><td>:</td><td><input type=text name=t2></td></tr>
<tr><td>ENTER OPTION2</td><td>:</td><td><input type=text name=t3></td></tr>
<tr><td>ENTER OPTION3</td><td>:</td><td><input type=text name=t4></td></tr>
<tr><td>ENTER OPTION4</td><td>:</td><td><input type=text name=t5></td></tr>
<tr><td>ENTER CORRECT OPTION NO.</td><td>:</td><td><input type=text name=t6></td></tr>
GURJOT SINGH(00313202712) Page 18
<tr><td><input type="submit" value=submit></td><td><input type="reset" value=reset></td></tr>
</table>
</form>
</body>
</html>
GURJOT SINGH(00313202712) Page 19
ADDQUESIMPL.JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import= "java.sql.*"%>
<!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">
<title>ADD QUESTION IMPLEMENTATION</title>
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<%@include file="header.html"%>
<%
int maxq=0;
String u1=request.getParameter("t1");
String u2=request.getParameter("t2");
String u3=request.getParameter("t3");
String u4=request.getParameter("t4");
String u5=request.getParameter("t5");
String u6=request.getParameter("t6");
try
GURJOT SINGH(00313202712) Page 20
{Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","asdf");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select max(qid) from questions");
if(rs.next())
{ maxq = rs.getInt(1);
}
maxq++;
st.executeQuery("insert into questions values('"+maxq+"','"+u1+"','"+u2+"','"+u3+"','"+u4+"','"+u5+"','"+u6+"')");
out.println("value inserted successfully");
con.close();
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</body>
</html>
GURJOT SINGH(00313202712) Page 21
ADMIN.JSP
<%@ 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">
<title> admin login</title>
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<%@include file="../header.html"%>
<h4>Welcome, ${uname}</h4>
<table cellpadding="5pt">
<tr>
<td><center> <a href="addques.jsp" class="myButton">Add a Question</a></center><br><br><br><br><br><br><br><br></td>
</tr>
<tr>
<td><center> <a href="display.jsp" class="myButton">Modify or Delete a Question</a></center></td>
GURJOT SINGH(00313202712) Page 22
</tr>
</table>
</body>
</html>
GURJOT SINGH(00313202712) Page 23
CANCELEXAM.JSP
<%
session.removeAttribute("count");
session.removeAttribute("questions");
session.removeAttribute("qno");
response.sendRedirect("home.jsp");
%>
GURJOT SINGH(00313202712) Page 24
DELETE.JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*"%>
<!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">
<title>Insert title here</title>
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<%@include file="header.html"%>
<%
try
{ String s=request.getParameter("q");
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","asdf");
PreparedStatement ps=con.prepareStatement("delete from questions where qid='"+s+"'");
GURJOT SINGH(00313202712) Page 25
ps.executeQuery();
out.println("value deleted");
out.println("<a href=display.jsp>go back</a>");
con.close();
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</body>
</html>
GURJOT SINGH(00313202712) Page 26
DISPLAY.JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import= "java.sql.*"%>
<!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">
<title>QUESTIONS IN DATABASE</title>
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<%@include file="header.html"%>
<%
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","asdf");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from questions");
while(rs.next())
GURJOT SINGH(00313202712) Page 27
{
out.println("<table border=2 class=triple>"+
"<tr><td>"+rs.getString("qid")+"</td>"+
"<td>"+rs.getString("question")+"</td>"+
"<td>"+rs.getString("ans1")+"</td>"+
"<td>"+rs.getString("ans2")+"</td>"+
"<td>"+rs.getString("ans3")+"</td>"+
"<td>"+rs.getString("ans4")+"</td>"+
"<td>"+rs.getString("cans")+"</td>"+
"<td><a href=edit.jsp?q="+rs.getString("qid")+"><input type=submit value=modify></a></td>"+
"<td><a href=delete.jsp?q="+rs.getString("qid")+"><input type=submit value=delete></a></td></tr>");
out.println("</table>");
}
con.close();
}
catch(Exception e)
{
out.println(e.getMessage());
}
%>
</body>
GURJOT SINGH(00313202712) Page 28
</html>
DISPLAYQUESTION.JSP
<%@page import="beans.Question"%>
<%@page contentType="text/html" pageEncoding="UTF-8"
import="java.util.*"%>
<!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=UTF-8">
<title>Examination</title>
<link href="styles.css" rel="stylesheet" />
<script type="text/javascript" >
var tim;
var min =0;
var sec = 20;
function f2()
{
if (parseInt(sec) > 0)
{
sec = parseInt(sec) - 1;
if(parseInt(min)==0)
{
GURJOT SINGH(00313202712) Page 29
document.getElementById("showtime").innerHTML = "Time Left : " + sec+" Seconds";
}
else
{
document.getElementById("showtime").innerHTML = "Time Left : "+min+" Minutes, " + sec+" Seconds";
}
tim = setTimeout("f2()", 1000);
}
else
{
if (parseInt(sec) == 0)
{
if (parseInt(min) == 0)
{
location.href = 'examresult.jsp';
}
else
{
min = parseInt(min) - 1;
sec = 59;
if(parseInt(min)==0)
{
document.getElementById("showtime").innerHTML = "Time Left : " +sec+" Seconds";
GURJOT SINGH(00313202712) Page 30
}
else
{
document.getElementById("showtime").innerHTML = "Time Left : "+min+" Minutes, " + sec+" Seconds";
}
tim = setTimeout("f2()", 1000);
}
}
}
}</script>
</head>
<body onload="f2()">
<%@include file="header.html"%>
<table>
<tr>
<td>Welcome, ${uname}</td>
<td><div id="showtime" style="font-size: large color:black ; ">time</div></td>
</tr>
</table>
<p />
<% String ans1=null;
String action = request.getParameter("action");
ArrayList<beans.Question> questions = (ArrayList<beans.Question>) session.getAttribute("questions");
Integer s=(Integer)session.getAttribute("count");
GURJOT SINGH(00313202712) Page 31
if(s==0)
{ for(Question q:questions)
{
ans1="u";
q.setAnswer(ans1);
}
session.setAttribute("count", 1);
}
int qno = (Integer) session.getAttribute("qno");
if (action != null) {
// process the current result
String ans = request.getParameter("ans");
if ( ans == null )
ans = "u"; // unanswered question
questions.get(qno).setAnswer(ans);
if ( action.equals("Finish"))
{
response.sendRedirect("examresult.jsp");
}
if ( action.equals("Next")) // user clicked on Next button
qno ++;
else
if (action.equals("Previous"))
GURJOT SINGH(00313202712) Page 32
qno --;
}
beans.Question q = questions.get(qno);
session.setAttribute("qno",qno);
%>
<form action="displayquestion.jsp">
<b><font size="3px">Question No : <%= qno + 1 %></font></b>
<pre>
<b><font size="5px"> <%=q.getQuestion()%></font></b>
</pre>
<p />
<input type="radio" name="ans" value="1">
<%= q.getAns1()%>
<p />
<input type="radio" name="ans" value="2">
<%= q.getAns2()%>
<p />
<input type="radio" name="ans" value="3">
<%= q.getAns3()%>
<p />
<input type="radio" name="ans" value="4">
<%= q.getAns4()%>
<p />
<%
if ( qno == beans.ExamBean.NOQ -1 )
GURJOT SINGH(00313202712) Page 33
out.println("<input type='submit' value='Finish' name='action'/>");
else
out.println("<input type='submit' value='Next' name='action'/>");
if ( qno > 0)
out.println("<input type='submit' value='Previous' name='action'/>");
%>
<p />
<a href="cancelexam.jsp">Cancel Exam And Return To Home Page </a>
</form>
</body>
</html>
GURJOT SINGH(00313202712) Page 34
EDIT.JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*"%>
<!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">
<title>Insert title here</title>
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<%@include file="header.html"%>
<%
try
{ String s=request.getParameter("q");
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","asdf");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from questions");
while(rs.next())
GURJOT SINGH(00313202712) Page 35
{ String h=rs.getString("qid");
session.setAttribute("abc",h);
System.out.println("abc "+session.getAttribute("abc"));
if(s.equals(h))
{System.out.println(""+rs.getString("question"));
out.println("<form action=update.jsp>"+
"<table border=2>"+"<tr><td>"+"qid:</td><td>"+rs.getString("qid")+"</tr></td>"+
"<tr><td>"+"Question:</td><td>"+"<textarea name=q1>"+rs.getString("question")+"</textarea></td></tr>"+
"<tr><td>"+"ANS1:</td><td>"+"<textarea name=q2>"+rs.getString("ans1")+"</textarea></td></tr>"+
"<tr><td>"+"ANS2:</td><td>"+"<textarea name=q3>"+rs.getString("ans2")+"</textarea></td></tr>"+
"<tr><td>"+"ANS3:</td><td>"+"<textarea name=q4>"+rs.getString("ans3")+"</textarea></td></tr>"+
"<tr><td>"+"ANS4:</td><td>"+"<textarea name=q5>"+rs.getString("ans4")+"</textarea></td></tr>"+
"<tr><td>"+"CANS:</td><td>"+"<input type=text name=q6 value="+rs.getString("cans")+"></td></tr>"+
"<tr><td><input type=submit value=change></td></tr>");
out.println("</table>");
break;
}
}
con.close();
}
catch(Exception e)
GURJOT SINGH(00313202712) Page 36
{
out.println(e.getMessage());
}
%>
</body>
</html>
GURJOT SINGH(00313202712) Page 37
EXAMHISTORY.JSP
<%@page import="beans.Examination"%>
<%@page import="beans.ExamBean"%>
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.util.*,beans.*"%>
<!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=UTF-8">
<title>Exams History</title>
<link href="styles.css" rel="stylesheet"/>
</head>
<body>
<%@include file="header.html"%>
<h4>Welcome, ${uname} </h4>
<h2>Examinations History </h2>
<%
ArrayList<beans.Examination> exams = beans.ExamBean.getExamsHistory( session.getAttribute("uname").toString());
%>
<table cellpadding="5pt" border="1">
<tr style="background-color:black;color:white;font:700 verdana">
<th>Date Of Exam </th>
GURJOT SINGH(00313202712) Page 38
<th>Marks </th>
</tr>
<%
for(Examination e : exams)
{
out.println("<tr><td>" + e.getDexam() + "</td><td>" + e.getScore() + "</td></tr>");
}
%>
</table>
<p/>
<a href="home.jsp">Go Back</a>
</body>
</html>
GURJOT SINGH(00313202712) Page 39
EXAMRESULT.JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Exam Result</title>
<link href="styles.css" rel="stylesheet"/>
</head>
<body>
<%@include file="header.html"%>
<h4>Welcome, ${uname} </h4>
<%
int score = beans.ExamBean.processResult( (java.util.ArrayList<beans.Question>) session.getAttribute("questions"));
// store data in database
beans.ExamBean.storeResult( session.getAttribute("uname").toString(),score);
%>
<h2>Exam Result </h2>
You have scored <span style="font-size:15pt"> <%=score %> </span> marks in your exam.
GURJOT SINGH(00313202712) Page 40
<p/>
That gives you a percentage of <span style="font-size:15pt"> <%= (score / (double) beans.ExamBean.NOQ) * 100.0 %> </span> % in your exam.
<p/>
<a href="home.jsp">Click Here To Proccede </a>
</body>
</html>
GURJOT SINGH(00313202712) Page 41
HEADER.HTML
<link href="styles.css" rel="stylesheet" />
<h1>TechCheck</h1>
GURJOT SINGH(00313202712) Page 42
HOME.JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Login</title>
<link href="/styles.css" rel="stylesheet" />
</head>
<body>
<%@include file="header.html"%>
<h4>Welcome, ${uname}</h4>
<table cellpadding="5pt">
<tr>
<td><center> <a href="takeexam.jsp" class="myButton">take exam</a>
</center>
<br><br><br><br></td></tr>
<tr>
<td> <center><a href="examhistory.jsp" class="myButton">exam history</a></center><br><br><br><br></td>
</tr>
<tr>
GURJOT SINGH(00313202712) Page 43
<td><center> <a href="logout.jsp" class="myButton">logout</a></center></td>
</tr>
</table>
</body>
</html>
GURJOT SINGH(00313202712) Page 44
LOGOUT.JSP
<%
session.invalidate();
response.sendRedirect("all/login.jsp");
%>
GURJOT SINGH(00313202712) Page 45
TAKEEXAM.JSP
<%@page contentType="text/html" pageEncoding="UTF-8" import ="java.util.*"%>
<!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=UTF-8">
<title>Take Exam</title>
<link href="styles.css" rel="stylesheet"/>
</head>
<body>
<%@include file="header.html"%>
<h4>Welcome, ${uname} </h4>
<%
ArrayList<beans.Question> questions = beans.ExamBean.getQuestions();
session.setAttribute("questions", questions);
session.setAttribute("count",0);
session.setAttribute("qno", 0);
session.setAttribute("starttime", new Date());
response.sendRedirect("displayquestion.jsp");
%>
</body>
GURJOT SINGH(00313202712) Page 46
</html>
UPDATE.JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import= "java.sql.*"%>
<!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">
<title>MODIFY A QUESTION</title>
<link href="styles.css" rel="stylesheet" />
</head>
<body>
<%@include file="header.html"%>
<% Connection con=null;
try
{ String s=(String)session.getAttribute("abc");
String s1=request.getParameter("q1");
String s2=request.getParameter("q2");
String s3=request.getParameter("q3");
String s4=request.getParameter("q4");
String s5=request.getParameter("q5");
String s6=request.getParameter("q6");
System.out.println("id "+s);
GURJOT SINGH(00313202712) Page 47
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
System.out.println(s4);
System.out.println(s5);
System.out.println(s6);
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","asdf");
Statement st=con.createStatement();
//ResultSet rs=st.executeQuery("select * from questions");
//while(rs.next())
//{ String h=rs.getString("qid");
// if(s.equals(h))
// {
st.executeQuery("update questions set question='"+s1+"',ans1='"+s2+"',ans2='"+s3+"',ans3='"+s4+"',ans4='"+s5+"',cans='"+s6+"' where qid='"+s+"'");
out.println("updation done ");
out.println("<a href=display.jsp>go back</a>");
//}
// }
}
catch(Exception e)
{
GURJOT SINGH(00313202712) Page 48
out.println(e.getMessage());
}
finally
{con.close();
}
%>
</body>
</html>
GURJOT SINGH(00313202712) Page 49
STYLESHEET
STYLES.CSS
h1 {
margin:0px;
font-family:arial;
font-size:20pt;
font-weight:700;
color:white;
background-color:#2c272b;
}
body {
margin:0px;
font-family:verdana;
font-size:10pt;
background-image: url("abc.jpg");
}
.triple td
{width:10%;
word-break: break-all;
}
table
{width:100%;
GURJOT SINGH(00313202712) Page 50
}
.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #0a0a0a;
-webkit-box-shadow:inset 0px 1px 0px 0px #0a0a0a;
box-shadow:inset 0px 1px 0px 0px #0a0a0a;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #131314), color-stop(1, #7f838a));
background:-moz-linear-gradient(top, #131314 5%, #7f838a 100%);
background:-webkit-linear-gradient(top, #131314 5%, #7f838a 100%);
background:-o-linear-gradient(top, #131314 5%, #7f838a 100%);
background:-ms-linear-gradient(top, #131314 5%, #7f838a 100%);
background:linear-gradient(to bottom, #131314 5%, #7f838a 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#131314', endColorstr='#7f838a',GradientType=0);
background-color:#131314;
-moz-border-radius:9px;
-webkit-border-radius:9px;
border-radius:9px;
border:1px solid #0a0a0a;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:arial;
font-size:13px;
font-weight:bold;
padding:20px 100px;
GURJOT SINGH(00313202712) Page 51
text-decoration:none;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #7f838a), color-stop(1, #131314));
background:-moz-linear-gradient(top, #7f838a 5%, #131314 100%);
background:-webkit-linear-gradient(top, #7f838a 5%, #131314 100%);
background:-o-linear-gradient(top, #7f838a 5%, #131314 100%);
background:-ms-linear-gradient(top, #7f838a 5%, #131314 100%);
background:linear-gradient(to bottom, #7f838a 5%, #131314 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#7f838a', endColorstr='#131314',GradientType=0);
background-color:#7f838a;
}
.myButton:active {
position:relative;
top:1px;
}
GURJOT SINGH(00313202712) Page 52
\\\\\\BEANS PACKAGE
USERBEAN.JAVA
package beans;
import dao.ExamDAO;
import java.util.ArrayList;
public class ExamBean
{
public static int NOQ = 5;
public static int TOTAL;
public static int getTOTAL()
{
return ExamDAO.countQues();
}
public static void setTOTAL(int tOTAL)
{
GURJOT SINGH(00313202712) Page 53
TOTAL = tOTAL;
}
public static ArrayList<Question> getQuestions()
{
return ExamDAO.getQuestions();
}
public static int processResult(ArrayList<Question> questions) {
int count = 0;
for(Question q : questions)
{
if (q.getAnswer().equals(q.getCans()))
count ++;
}
return count;
}
public static ArrayList<Examination> getExamsHistory(String uname)
{
return ExamDAO.getExamsHistory(uname);
}
public static void storeResult(String uname,int score)
{
ExamDAO.storeResults(uname,score);
GURJOT SINGH(00313202712) Page 54
}
}
EXAMINATION.JAVA
package beans;
public class Examination {
public Examination( String dexam, String score)
{
this.dexam = dexam;
this.score = score;
}
private String dexam,score;
public String getDexam()
{
return dexam;
}
public void setDexam(String dexam) {
this.dexam = dexam;
}
public String getScore()
{
GURJOT SINGH(00313202712) Page 55
return score;
}
public void setScore(String score)
{
this.score = score;
}
}
GURJOT SINGH(00313202712) Page 56
QUESTION.JAVA
package beans;
public class Question {
private String qid, question, ans1, ans2, ans3, ans4, cans, answer;
public String getAnswer()
{
return answer;
}
public void setAnswer(String answer)
{
this.answer = answer;
}
public String getAns1()
{
return ans1;
}
public void setAns1(String ans1)
{
GURJOT SINGH(00313202712) Page 57
this.ans1 = ans1;
}
public String getAns2()
{
return ans2;
}
public void setAns2(String ans2)
{
this.ans2 = ans2;
}
public String getAns3()
{
return ans3;
}
public void setAns3(String ans3)
{
this.ans3 = ans3;
}
public String getAns4()
{
return ans4;
}
GURJOT SINGH(00313202712) Page 58
public void setAns4(String ans4)
{
this.ans4 = ans4;
}
public String getCans()
{
return cans;
}
public void setCans(String cans)
{
this.cans = cans;
}
public String getQid()
{
return qid;
}
public void setQid(String qid)
{
this.qid = qid;
}
public String getQuestion()
GURJOT SINGH(00313202712) Page 59
{
return question;
}
public void setQuestion(String question)
{
this.question = question;
}
public Question(String qid, String question, String ans1, String ans2, String ans3, String ans4, String cans)
{
this.qid = qid;
this.question = question;
this.ans1 = ans1;
this.ans2 = ans2;
this.ans3 = ans3;
this.ans4 = ans4;
this.cans = cans;
}
public Question() {
}
}
GURJOT SINGH(00313202712) Page 60
USERBEAN.JAVA
package beans;
import dao.UserDAO;
public class UserBean {
private String uname = "", pwd = "", email, dor;
public String getDor()
{
return dor;
}
public void setDor(String dor)
{
this.dor = dor;
}
public String getEmail()
{
return email;
GURJOT SINGH(00313202712) Page 61
}
public void setEmail(String email)
{
this.email = email;
}
public String getPwd()
{
return pwd;
}
public void setPwd(String pwd)
{
this.pwd = pwd;
}
public String getUname()
{
return uname;
}
public void setUname(String uname)
{
this.uname = uname;
}
GURJOT SINGH(00313202712) Page 62
public boolean register()
{
return UserDAO.register((uname), pwd, email);
}
public boolean login()
{
return UserDAO.login(uname, pwd);
}
}
GURJOT SINGH(00313202712) Page 63
////DAO PACKAGE
DBUTIL.JAVA
package dao;
import java.sql.Connection;
import java.sql.DriverManager;
public class DBUtil {
public static Connection getConnection()
{
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","hr","asdf");
return con;
}
catch(Exception ex) {
System.out.println(ex.getMessage());
return null;
}
}
GURJOT SINGH(00313202712) Page 64
public static void close(Connection con)
{
try {
con.close();
}
catch(Exception ex) {
}
}
}
GURJOT SINGH(00313202712) Page 65
EXAMDAO.JAVA
package dao;
import beans.ExamBean;
import beans.Examination;
import beans.Question;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
public class ExamDAO {
public static int countQues()
{int count=0;
try
{Connection con2=null;
con2=DBUtil.getConnection();
Statement st=con2.createStatement();
ResultSet rs=st.executeQuery("select count(*) from questions");
if(rs.next())
{count=rs.getInt(1);
GURJOT SINGH(00313202712) Page 66
}
DBUtil.close(con2);
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
}
return count;
}
public static boolean quesFound(int q)
{ int flag=0;
Connection con3=null;
try
{
con3=DBUtil.getConnection();
Statement st=con3.createStatement();
ResultSet rs=st.executeQuery("select * from questions");
while(rs.next())
{ if(q==rs.getInt("qid"))
{flag=1;
break;
}
}
GURJOT SINGH(00313202712) Page 67
if(flag==0)
{ return false;
}
else
{return true;
}
}
catch (Exception ex)
{
System.out.println(ex.getMessage());
return false;
}
finally {
DBUtil.close(con3);
}
}
public static ArrayList<Question> getQuestions()
{
// create an array of random numbers based on the number of question we have in the database.
int[] qnos = new int[ExamBean.NOQ];
int qno, i = 0;
while (i < 5)
GURJOT SINGH(00313202712) Page 68
{
qno = (int) Math.round(Math.random() * ExamBean.getTOTAL());
boolean found = false;
for (int n : qnos)
{
if (n == qno)
{
found = true;
}
}
if ((!found)&&(quesFound(qno)))
{
qnos[i] = qno;
i++;
}
}
for (int n : qnos)
{
System.out.println(n);
}
Connection con = null;
PreparedStatement ps = null;
try {
con = DBUtil.getConnection();
StringBuffer qs = new StringBuffer("");
GURJOT SINGH(00313202712) Page 69
for (int n : qnos)
{
qs.append(n + ",");
}
qs.delete(qs.length() - 1, qs.length()); // delete extra ,
String query = "select * from questions where qid in (" + qs + ")";
System.out.println(query);
ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
ArrayList<Question> questions = new ArrayList<Question>();
while (rs.next())
{
Question q = new Question(rs.getString("qid"), rs.getString("question"), rs.getString("ans1"), rs.getString("ans2"),
rs.getString("ans3"), rs.getString("ans4"), rs.getString("cans"));
questions.add(q);
System.out.println("Questions id " + q.getQid());
}
return questions;
} catch (Exception ex)
{
System.out.println(ex.getMessage());
return null;
GURJOT SINGH(00313202712) Page 70
} finally
{
DBUtil.close(con);
}
} // end of getQuestions()
public static ArrayList<Examination> getExamsHistory (String uname) {
Connection con = null;
PreparedStatement ps = null;
try {
con = DBUtil.getConnection();
ps = con.prepareStatement("select * from exams where uname = ?");
ps.setString(1,uname);
ResultSet rs = ps.executeQuery();
ArrayList<Examination> exams = new ArrayList<Examination>();
while (rs.next())
{
Examination e= new Examination( rs.getString("dexam"), rs.getString("score"));
exams.add(e);
}
return exams;
} catch (Exception ex)
{
System.out.println(ex.getMessage());
return null;
} finally
GURJOT SINGH(00313202712) Page 71
{
DBUtil.close(con);
}
} // end of getExamsHistory
public static void storeResults(String uname, int score) {
Connection con = null;
PreparedStatement ps = null;
try
{
con = DBUtil.getConnection();
ps = con.prepareStatement("insert into exams (uname, dexam, score) values( ?,sysdate,?)");
ps.setString(1,uname);
ps.setInt(2,score);
ps.executeUpdate();
} catch (Exception ex)
{
System.out.println(ex.getMessage());
} finally
{
DBUtil.close(con);
}
} // end of storeResults
}
GURJOT SINGH(00313202712) Page 72
USERDAO.JAVA
package dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class UserDAO {
public static boolean register(String uname, String pwd, String email) {
Connection con = null;
PreparedStatement ps = null;
try {
con = DBUtil.getConnection();
ps = con.prepareStatement("insert into users values(?,?,?, sysdate)");
ps.setString(1, uname);
ps.setString(2, pwd);
ps.setString(3, email);
if (ps.executeUpdate() == 1) {
return true;
} else {
return false;
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
GURJOT SINGH(00313202712) Page 73
return false;
} finally {
DBUtil.close(con);
}
}
public static boolean login(String uname, String pwd) {
Connection con = null;
PreparedStatement ps = null;
try {
con = DBUtil.getConnection();
ps = con.prepareStatement("select * from users where uname = ? and pwd = ?");
ps.setString(1, uname);
ps.setString(2, pwd);
ResultSet rs = ps.executeQuery();
if (rs.next()) // found
{
return true;
} else {
return false;
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
return false;
} finally {
DBUtil.close(con);
}
GURJOT SINGH(00313202712) Page 74
}}
Result And Observation
After completion of the project and successful implementation of the software, we were able to register a user with information like username, password .
User can login the software with the correct password and username combination and after the completion of the login home page will be visible to the user. But if the user is admin then it takes it to admin page
The user is tested through various sets of question which the user have to answer and corresponding to that question , the answers are stored in the database. Then the user answers are compared with the correct answers which are stored in the database , and corresponding to that user score card is displayed at the end. Any number of question can be added to the database also the admin can modify and delete existing questions.
GURJOT SINGH(00313202712) Page 75
Summary and conclusionThe site Techcheck.com is an online exam portal . Currently it focuses on java based mcq. But it can easily be operated by a person without having knowledge of java. It has simple admin functionality for updating the data base. So without using any queries even a person not knowing anything about coding can easily modify the database. With the help of this system users can also easily give exam by using their login id and password also they can view their previous exam history.
GURJOT SINGH(00313202712) Page 76
FUTURE SCOPE
There always a room for improvement in any software package, however good and efficient it may be done. But the most important thing is that it should be flexible to accept further modifications. In future this software may be extended to include features such as:
1. We can study the progress of students in various sections like aptitude and communication skills and then suggestions can be generated accordingly about areas to focus, various strengths and weaknesses.
2. Apart from textual questions we can add audio clips and video clippings on which questions are to be answered
GURJOT SINGH(00313202712) Page 77
SCREENSHOTS
GURJOT SINGH(00313202712) Page 78
GURJOT SINGH(00313202712) Page 79
GURJOT SINGH(00313202712) Page 80
GURJOT SINGH(00313202712) Page 81
GURJOT SINGH(00313202712) Page 82
GURJOT SINGH(00313202712) Page 83
GURJOT SINGH(00313202712) Page 84