Sunteți pe pagina 1din 58

Sagar Institute of Technology and Management

6th Km Stone, Faizabad Road, Barabanki - 225001 (U.P.) INDIA

Project on
ONLINE EXAMINATION SYSTEM

Developed by

Nivedita Branch and Year


Priya Mishra IT III year
Priya Rastogi
Sadhvi

Project Guide Project Coordinator

Mr. P.N.Shukla R.K. Pandey

Department Of Information Technology

1
Sagar Institute of Technology & Management
Founded By the Sagar Educational Society,Barabanki with affiliation from UttarPradesh
Technical University, Lucknow and is approved by AICTE,
Ministry of HRD, Govt of India
6th Km Stone, Faizabad Road, Barabanki - 225001 (U.P.) INDIA

CERTIFICATE

This is to certify that Ms. Nivedita, Ms. Priya Mishra, Ms.Priya Rastogi,
Ms.Sadhvi students of B.Tech IT IIIrd year
have completed their project on “On Line Examination System ” .

The statement made by candidate is correct to the best of my/our knowledge.

Their work is outstanding and the candidate have worked to my utmost


satisfaction.

2
Date Signature of Project Guide

ACKNOWLEDGEMENT

The present work would not have been possible without the guidance and help of
Mr.P.N.Shukla and we find it most pleasant to remember and record our obligation to
him. We must unreservedly acknowledge the deep gratitude to our project guide for his
persistent intellectual guidance. It has been matter of great pleasure for us to have worked
under an acadmecian of his repute.

We continue to be indebted to my colleagues and above contributers for their remarkable


assistance and guidance.

Regards

Nivedita
Priya Mishra
Priya Rastogi
Sadhvi

3
CONTENTS
Page
No.
CHAPTER 1: SYNOPSIS
1.1 Overview of Online Examination system

CHAPTER 2: REQUIREMENT ANALYSIS


2.1 Problem statement
2.2 Functional requirement
2.3 Non-functional requirement

CHAPTER 3: SYSTEM ANALYSIS AND PLANNING


3.1 Work breakdown structure
3.2 Dependency between task
3.3 Assign task duration

CHAPTER 4: SOFTWARE DESIGN 23-25


4.1 Data flow diagram
4.1.1Context level DFD
4.1.2 1-level DFD for Faculty
4.1.3 1- level DFD for Student
4.2 ER diagram

CHAPTER 5: COMPUTER HARDWARE AND SOFWARE TOOLS


5.1 Software Requirements
5.2 Hardware Requirements

CHAPTER 6: TESTING
CHAPTER 7: CODING 26-40

4
CHAPTER 8: CONCLUSIONS 41-42

CHAPTER 1

SYNOPSIS

1.1 OVERVIEW OF ONLINE EXAMINATION SYSTEM

We are developing an application entitled ‘Online Examination System’ for


Sagar Institute Of Technology And Management, Barabanki to conduct aptitude
tests and to make them more productive and result oriented. Institute decided to
take aptitude test in order to evaluate the ability and talent of students.
It is systematic and secure system. In order to use this examination software
fulfilled:
Student must have a valid id which is his/her roll number to login to the exam.
When one roll number is login then it’s not possible to re-login again and one
user can login at only-one system .When the student logins then the photo and
other personal detail shown at his/her screen till the exam is not ended. Student
is able to see only previous question and option to skip the question.

5
CHAPTER 2

REQUIREMENT ANALYSIS

2.1 Problem Statement

Faculty felt it was very cumbersome to evaluate aptitude test copies, award
marks and inform students about the result of the test within a few hours. A user
friendly On Line Examination System Software is developed to facilitate faculty
for seamless conduct of the aptitude test.

2.2 Functional Requirements

Following are the functional requirement of the software system:

1) Student must have a valid roll number which is used to login at the system
to start the examination.

2) When one roll number is login then it’s not possible to re-login again and
one student can login at only-one system.

3) When the student login then the roll number, name and photo shown at
his/her examination screen till the examination is not completed.

4) Student is able to see only previous question (just back) and option to skip
and review the question.

6
5) Student can see the result of the test at end of test.

6) 25 questions are randomly selected from the database


7) The test is a timed test, admin can change the duration of the test before it begins in
the code.

2.3 Non-Functional requirements


The non-functional requirements of the software system are:

• Maintainability:
System should be able to be maintained easily and with no special needs.
Most of the maintenance should be done automatically by the system with no
interaction by the user.

• Portability:
System must be able to run on different machines so that it can be better
used in all the machines.

• Extensibility:
System must be extensible so that future needs can be taken care off.

• Serviceability:
System must be able to provide durable rendering of its services by taking
care of all required possibilities.

7
CHAPTER 3

SYSTEM ANALYSIS AND PLANNING

3.1 Planning

Planning is deciding in advance what to do? How to do it? When to do it? And
who should do it? It bridges the gap from where the organization is to, where it
wants to be. The planning function involves establishing goals and arranging
them in logical order.

The steps in planning are:

• Create Work Breakdown Structure


• Create Dependencies Between Tasks

8
3.1 Work Break-Down Structure

Online Examination
System

Analysis Design Coding Testing Implementation

GUI Database M1 M2

M1 : Examination
Module
M2 : MIS Report
module

9
Analysis

Databa
se
3.2 Dependency
Design Between task
GUI

Coding

Testing

Implementation

3.2 Analysis

In system analysis we analyze all requirement and all specifications. There are
two phases in our project:

1. Requirements Gathering

We gather some major requirements as:

• First we interviewed the trainers (faculty) and student for


processing.
• Study the entire examination system to collect all possible
information.
• Measure all input data and then output requirement.

10
• Notice all functions required by user.

2. Analysis on gathered data

For clearly understand the requirements, we do this activity, some steps are:

• Understand exactly what is the problem?


• What are the possible solutions of the problem?
• What exactly the data input and exactly what data output?
• What complexity we may face during development?

11
CHAPTER 4

SOFTWARE DESIGN

Linear Sequential Model was used in designing of this software. This is some
time called the waterfall model; this suggests a systematic, sequential, approach
to software development that begins at the system level and progresses through
analysis, design, coding, testing and support.

4.1 Tools used

The different tools used in designing are:

• Data dictionary
• Data flow diagrams
• ER diagram

4.1.1 Data Dictionary

Data dictionary consists of description of all the data used in the system. It consists
of logical characteristics of current systems data stores including name, description,
aliases, contents and organization. Data dictionary serves as the basis for identifying
database requirements during system design. Data dictionary is a catalog, a
depositary of the elements in the system.

12
Info table:

Column name Data Type Constraints Description


Roll_no Varchar(10) Not Null Stores students
UPTU roll number
Name Varchar(50) Not null Stores name of
student
Branch Varchar(20) Stores branch of
student
Year Varchar(20) Stores year of
student
Id Varchar2(50) Primary key Stores Id

Password Varchar2(20) Not Null Stores password

Login Table:

Column name Data type (size) Description

Roll_no Varchar (10) Stores student roll number

Name Varchar(50) Stores student name

Question table:

Column Data type constraint Description


name (size)
q_id Varchar (2) Primary key Question number

13
question Varchar(MAX) Not null Question

corr_op Varchar(MAX) Not null Right answer of the


question
Op1 Varchar(MAX) Not null First choice

Op2 Varchar(MAX) Not null Second choice

Op3 Varchar(MAX) Not null Third choice

Op4 Varchar(MAX) Not null Fourth choice

Answer Table

Column Data type (size) constrain Description


name t
Roll_no Varchar(10) Not null Roll no of
students
name Varchar(50) Not null Name of
students
q_id number (2) Question
number
question Varchar(MAX) Not null Question

corr_op Varchar(1) Not null Right answer of the


question
Op1 Varchar(MAX) Not null First choice

op2 Varchar(MAX) Not null Second choice

op3 Varchar(MAX) Not null Third choice

op4 Varchar(MAX) Not null Fourth choice

marks Int(3) Marks obtained

User_op Varchar(1) Not null Option selected by


candidate

14
4.1.2Data Flow Diagrams

4.1.2.1 Context Level DFD

Login Request Candidate


Candidate Assessment
ONLINE
Acknowledge Acknowledge Report
Login
EXAMINATION
SYSTEM Candidate
Request
Examiner Performance
Acknowledge Report
Acknowledge

15
4.1.2.2 1-Level DFD for Examiner
Authentication

Login ADMIN
Login
Ack
Ack
Exam
Manage
ADMINISTRATOR Information Exam

Question
Record
Student
View
Record
Student
Record
Candidate Question
Information Detail

View
Questions ROLL_NUMBER QST

16
4.1.2.3 1-Level DFD for Student

Login Check Ack


CANDIDATE Availability LOGIN
Record Roll
Ack Number
Exam
Retrieve ROLL_NUMBER
start
Begin Exam
Exam Retrieve
QUESTION
Processing
Answer
Marked
Record Questions Questions
View Marks
Answer

check ANSWER
Evaluate
Marks
Answer

Total Marks
Result

17
4.1.3 ER Diagram

uname pwd name


Roll_number

1 n
E_chk MANAGES Info
1 1 1

SETS MAKE
HAS
question
n
ans n qno
login
1
choice1 question
Roll_number Roll_number
HAS
1 name
Choice2
1 qno
choice4 rans
answer question
choice3 marks
ans1
choice4
choice2 choice1
Choice3

18
CHAPTER 5

COMPUTER HARDWARE AND SOFTWARE TOOLS

5.1 Software requirements


• Asp.Net
• SQL Server
• Internet Browser
• Windows XP/2000

5.2 Hardware requirements


• 2 GB space on Hard Disk
• 256 MB RAM
• Pentium4 processor

5.1.1 ASP.Net

ASP.NET is a web application framework developed and marketed by Microsoft to allow


programmers to build dynamic web sites, web applications and web services. It was first
released in January 2002 with version 1.0 of the .NET Framework, and is the successor to
Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common
Language Runtime (CLR), allowing programmers to write ASP.NET code using any
supported .NET language. The ASP.NET SOAP extension framework allows ASP.NET
components to process SOAP messages.

19
.NET pages, known officially as "web forms", are the main building
block for application development.[8] Web forms are contained in files with an ".aspx"
extension; these files typically contain static (X)HTML markup, as well as markup defining
server-side Web Controls and User Controls where the developers place all the required
static and dynamic content for the web page. Additionally, dynamic code which runs on the
server can be placed in a page within a block <% -- dynamic code -- %> which is similar to
other web development technologies such as PHP, JSP, and ASP, but this practice is
generally discouraged except for the purposes of data binding since it requires more calls
when rendering the page.

Microsoft recommends dealing with dynamic program code by


using the code-behind model, which places this code in a separate file or in a specially
designated script tag. Code-behind files typically have names like MyPage.aspx.cs or
MyPage.aspx.vb while the page file is MyPage.aspx (same filename as the page file
(ASPX), but with the final extension denoting the page language). This practice is
automatic in Microsoft Visual Studio and other IDEs. When using this style of
programming, the developer writes code to respond to different events, like the page being
loaded, or a control being clicked, rather than a procedural walk through the document.

ASP.NET's code-behind model marks a departure from Classic


ASP in that it encourages developers to build applications with separation of presentation
and content in mind. In theory, this would allow a web designer, for example, to focus on
the design markup with less potential for disturbing the programming code that drives it.
This is similar to the separation of the controller from the view in model-view-controller
frameworks.

20
5.1.2 SQL Server 2005
Microsoft SQL Server is a relational model database server produced by Microsoft. Its
primary query languages are T-SQL and ANSI SQL. SQL Server 2005 (codenamed
Yukon), released in October 2005, is the successor to SQL Server 2000. It included native
support for managing XML data, in addition to
relational data. For this purpose, it defined an xml data type that could be used either as a
data type in database columns or as literals in queries. XML columns can be associated
with XSD schemas; XML data being stored is verified against the schema. XML is
converted to an internal binary data type before being stored in the database. Specialized
indexing methods were made available for XML data. XML data is queried using
XQuery;CLR Integration was the main features with this edition where one could write
SQL code as Managed Code these are those code which are being executed by
CLR(Common Language Runtime). SQL Server 2005 added some extensions to the T-
SQL language to allow embedding XQuery queries in T-SQL. In addition, it also defines a
new extension to XQuery, called XML DML, that allows query-based modifications to
XML data. SQL Server 2005 also allows a database server to be exposed over web services
using TDS packets encapsulated within SOAP (protocol) requests. When the data is
accessed over web services, results are returned as XML. For relational data, T-SQL has
been augmented with error handling features
(try/catch) and support for recursive queries (Common Table Expressions). SQL Server
2005 has also been enhanced with new indexing algorithms and better error recovery
systems. Data pages are checksummed for better error resiliency, and optimistic
concurrency support has been added for better performance. Permissions and access control
have been made more granular and the query processor handles concurrent execution of
queries in a more efficient way. Partitions on tables and indexes are supported natively, so
scaling out a database onto a cluster is easier. SQL CLR was introduced with SQL Server
2005 to let it integrate with the .NET Framework.

21
CHAPTER 6

TESTING

System testing is an expensive but critical process that can take as much as 50
percent of the budget for program development. The common view of testing
held by users is that it is performed to prove that there are no errors in the
program. Testing is the process of executing a program with the explicit
intention of finding errors that is, making the program fail. A successful test,
then is one that finds an error.

TESTING OBJECTIVES
The main objectives of testing are:
• Testing is a process of executing a program with the intent of finding an error.
• A goal test case is one that has a probability of finding an as yet
undiscovered error.
• A successful test is one that uncovers an as yet undiscovered error.

TESTING PRINCIPLE
The various testing principles are:
• All tests should be traceable to customer requirements.
• Test should be planned long before testing begins.
• The testing should begin “in the small” and progress towards testing “in
the large”.
• Exhaustive testing is not possible.
• To be most efficient, testing should be conducted by an independent
third party.

22
There are two general strategies for testing software:
• Code Testing
The code-testing strategy examines the logic of the program. In this kind
of testing, analyst develops test cases that result in executing every
instruction in the program or module; that is, every path through the
program is tested. A path is a specific combination of conditions that is
handled by the program

• Specification Testing
To perform specification testing, the analyst examines the specifications
stating what the program should do and how it should perform under various
conditions. Then test cases are developed for each condition or combination
of conditions and submitted for processing.
This strategy treats the program as if it were a black box; we do not look
into the program to study the code and is not concerned about whether every
instruction or path through the program is tested.

23
TESTING TECHNIQUES:

Types of testing

White box testing Black box testing

White box testing


Features of white box testing are:
• White Box testing which is performed early in the testing process
• .It guarantee that all the independent paths within the module have been
exercised at least once
• Exercise all logical decisions on their true and false sides.
• Execute all loops at their boundaries and within their operational
bounds.
• Exercise internal data structure to assure their validity

24
Black box testing
Features of white box testing are:
• Black box testing to be applied during later stage of testing.
• Black box testing focuses on the functional requirement of the software
• Incorrect or missing functions.
• Interface errors.
• Errors in the data structure or external database access.
• Performance errors.
• Initialization and termination errors

25
CHAPTER 7

CODING

7.1 The Login Window

7.1.1 HTML Coding


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb"
Inherits="Default4" %>

26
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body bgcolor="#d7e9fd">
<form id="form1" runat="server" method="post" >
<div style="height: 671px">
<asp:Panel ID="Panel1" runat="server" Height="133px"
Width="1264px">
<asp:ImageMap ID="ImageMap1" runat="server" Height="136px"
ImageUrl="~/Sitm_logo.gif" Width="186px">
</asp:ImageMap>
<asp:ImageMap ID="ImageMap2" runat="server" Height="138px"
ImageUrl="~/onilne_exam_banner.jpg" Width="1072px">
</asp:ImageMap>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" Height="429px"
Width="1223px"
Direction="LeftToRight" HorizontalAlign="Right">
<br />
<br />
<br />

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;

<asp:Label ID="Label1" runat="server" Font-Bold="True"


Text="New Here"></asp:Label>
&nbsp;&nbsp;
<asp:LinkButton ID="LinkButton1" runat="server" Font-
Bold="True">Sign Up</asp:LinkButton>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;

<br />
<br />
&nbsp;&nbsp;
<br />
<asp:Login ID="Login1" runat="server" BackColor="#FFFBD6"
BorderColor="#FFDFAD"
BorderPadding="4" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana"
Font-Size="Medium" ForeColor="#333333" Height="185px"
TextLayout="TextOnTop"
Width="312px" Font-Bold="False">
<CheckBoxStyle Font-Bold="True" Font-Size="Larger" />
<TextBoxStyle Font-Size="0.8em" Height="30px"
Width="200px" />
<LoginButtonStyle BackColor="White" BorderColor="#CC9966"
BorderStyle="Groove"
BorderWidth="1px" Font-Bold="True" Font-
Names="Verdana" Font-Size="Larger"
ForeColor="#990000" Height="25px" Width="100px" />

27
<InstructionTextStyle Font-Italic="True"
ForeColor="Black" />
<LabelStyle Font-Bold="True" Font-Size="Larger"
ForeColor="Black" />
<TitleTextStyle BackColor="#990000" Font-Bold="True"
Font-Size="0.9em"
ForeColor="White" />
</asp:Login>
</asp:Panel>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<br />
<br />
<br />
&nbsp;<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;&nbsp;

</div>
</form>
</body>
</html>

7.1.2 VB Script
Imports system.data
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Data.Common

Partial Class Default4

28
Inherits System.Web.UI.Page
Dim uname As String
Dim rno As String

Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As


System.Web.UI.WebControls.AuthenticateEventArgs) Handles
Login1.Authenticate
Dim Authenticated As Boolean = False
Authenticated =
SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password)
e.Authenticated = Authenticated
If (Authenticated = True) Then
Response.Redirect("homePage.aspx?name=" + uname + "&rollno="
+ rno)
End If
End Sub

Public Function SiteLevelCustomAuthenticationMethod(ByVal UserName As


String, ByVal Password As String) As Boolean
Dim boolReturnValue As Boolean = False
Dim cs As String = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=oles;Data Source=CC3-123"
Dim con As SqlClient.SqlConnection = New
SqlClient.SqlConnection(cs)
Dim comm As SqlClient.SqlCommand = New SqlClient.SqlCommand
Dim st As String = ("Select * From log where id='" +
Login1.UserName.ToString + "';")
comm = New SqlClient.SqlCommand(st, con)
Dim dr As SqlClient.SqlDataReader
con.Open()
dr = comm.ExecuteReader()
While (dr.Read())
If ((Login1.UserName = dr.GetString(2).ToString) And
(Login1.Password = dr.GetString(3).ToString)) Then
boolReturnValue = True
uname = dr.GetString(1)
rno = dr.GetString(0)
End If
dr.Close()
Return boolReturnValue
End While
End Function

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles LinkButton1.Click
Response.Redirect("register.aspx")
End Sub
End Class

29
7.2 Registration Form

7.2.1 HTML
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="register.aspx.vb" Inherits="_Default" %>

<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<div style="height: 947px; width: 1179px; font-family: 'Microsoft
Sans Serif'; font-size: inherit; font-weight: normal; color: #000000;
margin-left: 80px;">

&nbsp;<asp:ImageMap ID="ImageMap1" runat="server" Height="139px"


ImageUrl="~/Sitm_logo.gif" Width="171px">
</asp:ImageMap>
<asp:ImageMap ID="ImageMap2" runat="server" Height="137px"

30
ImageUrl="~/onilne_exam_banner.jpg" Width="959px">
</asp:ImageMap>
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp

<asp:Label ID="Label3" runat="server" Font-Bold="True"


Font-Names="Microsoft Sans Serif" Font-Size="X-Large"
ForeColor="Red"
Text="Registration Form"></asp:Label>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label4" runat="server" Font-Bold="True"
Text="Name"></asp:Label>
&nbsp;
<asp:TextBox ID="name" runat="server"
Width="182px"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp

<asp:Image ID="imgPicture" runat="server" Height="160px"


Width="120px" />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label5" runat="server" Font-Bold="True" Text="UPTU
Roll No"></asp:Label>
&nbsp;<asp:TextBox ID="rno" runat="server" Width="182px"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;

<asp:FileUpload ID="FileUpload1" runat="server" />


<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; <asp:Button ID="btnUpload" runat="server" Text="Upload"
Width="91px" />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label9" runat="server" Font-Bold="True"
Text="Branch"></asp:Label>
&nbsp;
<asp:DropDownList ID="branch" runat="server" Height="16px"
Width="182px">
<asp:ListItem>CS</asp:ListItem>
<asp:ListItem>IT</asp:ListItem>

31
<asp:ListItem>EC</asp:ListItem>
<asp:ListItem>EE</asp:ListItem>
<asp:ListItem>EEE</asp:ListItem>
<asp:ListItem>EN</asp:ListItem>
<asp:ListItem>ME</asp:ListItem>
</asp:DropDownList>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;

<asp:Label ID="lblOutput" runat="server"></asp:Label>


<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label10" runat="server" Font-Bold="True"
Text="Year"></asp:Label>
&nbsp;&nbsp;
<asp:DropDownList ID="year" runat="server" Height="16px"
Width="182px">
<asp:ListItem>I</asp:ListItem>
<asp:ListItem>II</asp:ListItem>
<asp:ListItem>III</asp:ListItem>
<asp:ListItem>IV</asp:ListItem>
</asp:DropDownList>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label6" runat="server" Font-Bold="True" Text="User
ID"></asp:Label>
&nbsp;
<asp:TextBox ID="id" runat="server" Width="182px"></asp:TextBox>
&nbsp;
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="id"
ErrorMessage="The User id already exists" Font-Size="Medium"
OnServerValidate="check"></asp:CustomValidator>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label7" runat="server" Font-Bold="True"
Text="Password"></asp:Label>
&nbsp;
<asp:TextBox ID="pswd" runat="server" Width="182px"
TextMode="Password"></asp:TextBox>
<br />
<br />
&nbsp;
<asp:Label ID="Label8" runat="server" Font-Bold="True" Text="Re-
Type Password"></asp:Label>
&nbsp;

32
<asp:TextBox ID="re_pswd" runat="server" Width="182px"
TextMode="Password"></asp:TextBox>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:CompareValidator ID="CompareValidator1" runat="server"
ErrorMessage="Password Mismatch" ControlToCompare="pswd"
ControlToValidate="re_pswd"></asp:CompareValidator>

<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
* All feilds are madatory to be filled<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; <asp:Label ID="Label11" runat="server"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:LinkButton ID="LinkButton1" runat="server">Click Here to
Login</asp:LinkButton>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Height="26px" Text="Submit"
Width="83px" />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</div>
</form>
</body>
</html>

7.2.2 VB Scripting
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Data.Common
Imports System.Drawing
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page

Sub check(ByVal objSource As Object, ByVal e As


ServerValidateEventArgs)

33
Dim cs As String = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=oles;Data Source=CC3-123"
Dim con As SqlClient.SqlConnection = New
SqlClient.SqlConnection(cs)
Dim comm As SqlClient.SqlCommand = New SqlClient.SqlCommand
Dim st As String = ("Select id from log;")
comm = New SqlClient.SqlCommand(st, con)
Dim dr As SqlClient.SqlDataReader
con.Open()
dr = comm.ExecuteReader()
While (dr.Read())
If (dr.GetString(0).ToString = id.Text) Then
e.IsValid = False
Else
e.IsValid = True
End If
End While
dr.Close()
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim ds As New DataSet
Dim cs As String
ds = New DataSet("log")
cs = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=oles;Data Source=CC3-123"
Dim con As SqlClient.SqlConnection = New
SqlClient.SqlConnection(cs)
Dim comm As SqlClient.SqlCommand = New SqlClient.SqlCommand()
comm.CommandType = CommandType.Text
Dim st As String = ("insert into
log(roll_no,name,id,pswd,branch,year) values('" + rno.Text + "','" +
name.Text + "','" + id.Text + "','" + pswd.Text + "','" + branch.Text +
"','" + year.Text + "');")
comm = New SqlClient.SqlCommand(st, con)
con.Open()
comm.ExecuteNonQuery()
Label11.Text = "Account Created Successfully"
con.Close()
End Sub

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles btnUpload.Click
' Initialize variables
Dim sSavePath As String
Dim sThumbExtension As String
Dim intThumbWidth As Integer
Dim intThumbHeight As Integer
' Set constant values
sSavePath = "images/"
sThumbExtension = "_thumb"
intThumbWidth = 160
intThumbHeight = 120
' If file field isnt empty
If (Not (FileUpload1.PostedFile) Is Nothing) Then
' Check file size (mustn�t be 0)

34
Dim myFile As HttpPostedFile = FileUpload1.PostedFile
Dim nFileLen As Integer = myFile.ContentLength
If (nFileLen = 0) Then
lblOutput.Text = "No file was uploaded."
Return
End If
' Check file extension (must be JPG)
If (System.IO.Path.GetExtension(myFile.FileName).ToLower <>
".jpg") Then
lblOutput.Text = "The file must have an extension of JPG"
Return
End If
' Read file into a data stream
Dim myData(nFileLen) As Byte
myFile.InputStream.Read(myData, 0, nFileLen)
' Make sure a duplicate file doesnt exist. If it does, keep
on appending an
' incremental numeric until it is unique
'Dim sFilename As String =
System.IO.Path.GetFileName(myFile.FileName)
Dim file_append As Integer = 0
' Save the stream to disk
Dim sFilename As String = rno.Text + ".jpg"
Dim newFile As System.IO.FileStream = New
System.IO.FileStream(Server.MapPath((sSavePath + sFilename)),
System.IO.FileMode.Create)
newFile.Write(myData, 0, myData.Length)
newFile.Close()
' Check whether the file is really a JPEG by opening it
Dim myCallBack As System.Drawing.Image.GetThumbnailImageAbort
= New System.Drawing.Image.GetThumbnailImageAbort(AddressOf
ThumbnailCallback)
Dim myBitmap As Bitmap
Try
myBitmap = New Bitmap(Server.MapPath((sSavePath +
sFilename)))
' If jpg file is a jpeg, create a thumbnail filename that
is unique.
file_append = 0
Dim sThumbFile As String = rno.Text + sThumbExtension +
".jpg"
While System.IO.File.Exists(Server.MapPath((sSavePath +
sThumbFile)))
file_append = (file_append + 1)
sThumbFile =
(System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) _
+ (file_append.ToString _
+ (sThumbExtension + ".jpg")))
End While
' Save thumbnail and output it onto the webpage
Dim myThumbnail As System.Drawing.Image =
myBitmap.GetThumbnailImage(intThumbWidth, intThumbHeight, myCallBack,
IntPtr.Zero)
myThumbnail.Save(Server.MapPath((sSavePath +
sThumbFile)))
imgPicture.ImageUrl = (sSavePath + sThumbFile)
' Displaying success information

35
lblOutput.Text = "File uploaded successfully!"
' Destroy objects
myThumbnail.Dispose()
myBitmap.Dispose()
Catch errArgument As ArgumentException
' The file wasn't a valid jpg file
lblOutput.Text = "The file wasn't a valid jpg file."
System.IO.File.Delete(Server.MapPath((sSavePath +
sFilename)))
End Try
End If
End Sub

Public Function ThumbnailCallback() As Boolean


Return False
End Function

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles LinkButton1.Click
Response.Redirect("login.aspx")
End Sub

End Class

7.3 Logging For Exam

36
37
7.3.1 VB Scripting
Partial Class Default3
Inherits System.Web.UI.Page
Dim rno As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Me.Load
rno = Request.QueryString("rollno")
Label1.Text = Request.QueryString("name")
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Button1.Click
Response.Redirect("exam.aspx?rollno=" + rno + "&username=" +
Label1.Text)
End Sub
End Class

38
7.3.2 Exam Screen

39
40
7.3.3 HTML Coding
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="exam.aspx.vb"
Inherits="_Default" %>

<%@ Register assembly="System.Web.Extensions, Version=3.5.0.0,


Culture=neutral, PublicKeyToken=31bf3856ad364e35"
namespace="System.Web.UI" tagprefix="asp" %>

<!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 runat="server">
<title>Untitled Page</title>
</head>
<body style="table-layout: fixed" bgcolor="#ffcc66">
<form id="form1" runat="server" method="post" >
<div style="font-weight: bold">
<asp:Panel ID="Panel2" runat="server" BackColor="#C0C0FF"
Height="138px" Width="1303px" Direction="LeftToRight"
HorizontalAlign="Left" Wrap="False">

41
<asp:Image ID="Image1" runat="server" Height="138px"
ImageUrl="~/Sitm_logo.gif" Width="160px" />
<asp:ImageMap ID="ImageMap1" runat="server" Height="137px"
ImageUrl="~/onilne_exam_banner.jpg"
Width="1136px">
</asp:ImageMap></asp:Panel>
&nbsp;<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" OnTick ="Timer1_Tick"
Interval ="1000">
</asp:Timer>
</div>
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;RollNumber<asp:TextBox
ID="TextBox1" runat="server" Width="89px"></asp:TextBox>
&nbsp; &nbsp; &nbsp; Name<asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode


="Conditional" >
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;
Date&nbsp;&nbsp;<asp:Label ID="Label3" runat="server" Font-Bold="True"
Font-Size="Medium"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TimeRemaining&nbsp;
<asp:Label
ID="Label4" runat="server" Font-
Bold="True" Font-Size="Medium" >5</asp:Label>

&nbsp; minutes

</ContentTemplate>
</asp:UpdatePanel>
<br />
<br />
<br />
Question
<asp:Label ID="Label1" runat="server" Font-
Bold="True"></asp:Label>
of

42
<asp:Label ID="Label2" runat="server" Text="5" Font-
Bold="True"></asp:Label>
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;
<br />
<asp:Panel ID="Panel1" runat="server" BackColor="#FFC0C0"
Height="344px" Width="1303px" Direction="LeftToRight"
HorizontalAlign="Left">
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
<table style="width: 1235px; height: 221px">
<tr>
<td style="width: 127px; height: 108px">
Question</td>
<td style="width: 968px; height: 108px">
<asp:Label ID="ques" runat="server"
Height="130px" Width="966px"></asp:Label></td>
<td style="width: 203px; height: 108px">
<asp:ImageMap ID="ImageMap2" runat="server"
Height="127px" Width="197px">
</asp:ImageMap></td>
</tr>
<tr>
<td style="width: 127px; height: 40px;">
<asp:RadioButton ID="RadioButton1" runat="server"
GroupName="ans" Text="(A)" /></td>
<td style="width: 968px; height: 40px;">
<asp:Label ID="op1" runat="server" Height="40px"
Width="966px"></asp:Label></td>
<td style="width: 203px; height: 40px;">
<asp:HiddenField ID="q_id" runat="server" />
</td>
</tr>
<tr>
<td style="width: 127px; height: 40px;">
<asp:RadioButton ID="RadioButton2" runat="server"
GroupName="ans" Text="(B)" /></td>
<td style="width: 968px; height: 40px;">
<asp:Label ID="op2" runat="server" Height="40px"
Width="966px"></asp:Label></td>
<td style="width: 203px; height: 40px;">
<asp:HiddenField ID="corr_op" runat="server" />
</td>
</tr>
<tr>
<td style="width: 127px; height: 40px;">
<asp:RadioButton ID="RadioButton3" runat="server"
GroupName="ans" Text="(C)" /></td>
<td style="width: 968px; height: 40px;">
<asp:Label ID="op3" runat="server" Height="40px"
Width="966px"></asp:Label></td>
<td style="width: 203px; height: 40px;">
</td>
</tr>

43
<tr>
<td style="width: 127px; height: 40px;">
<asp:RadioButton ID="RadioButton4" runat="server"
GroupName="ans" Text="(D)" /></td>
<td style="width: 968px; height: 40px;">
<asp:Label ID="op4" runat="server" Height="40px"
Width="966px"></asp:Label></td>
<td style="width: 203px; height: 40px;">
</td>
</tr>
</table>
</asp:Panel>

<asp:Panel ID="Panel3" runat="server" BackColor="#C0FFC0"


Height="103px" Width="1303px" Direction="LeftToRight"
HorizontalAlign="Left">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
&nbsp; &nbsp;&nbsp;
<asp:Button ID="first" runat="server" Font-Bold="True"
Height="40px" Text="First"
Width="100px" />
<asp:Button ID="p_ques" runat="server" Font-Bold="True"
Height="40px" Text="Previous "
Width="100px" />
<asp:Button ID="submit" runat="server" Font-Bold="True"
Height="40px" Text="Submit"
Width="100px" />
<asp:Button ID="n_ques" runat="server" Font-Bold="True"
Height="40px" Text="Next"
Width="100px" />
<asp:Button ID="last" runat="server" Font-Bold="True"
Height="40px" Text="Last" Width="100px" />
<asp:Button ID="Button1" runat="server" Height="40px"
Text="Exit"
Width="100px" Font-Bold="True" />
</asp:Panel>
</form>
</body>
</html>

7.3.4 VB Scripting
Imports system.data
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Data.Common

Partial Class _Default


Inherits System.Web.UI.Page
Dim ds As New DataSet
Dim cs As String
Dim index As Integer

44
Dim tleft As Integer
Public Function disp() As Boolean
q_id.Value = ds.Tables(0).Rows(index).Item(0)
q_id.DataBind()
ques.Text = ds.Tables(0).Rows(index).Item(1)
ques.DataBind()
op1.Text = ds.Tables(0).Rows(index).Item(2)
op1.DataBind()
op2.Text = ds.Tables(0).Rows(index).Item(3)
op2.DataBind()
op3.Text = ds.Tables(0).Rows(index).Item(4)
op3.DataBind()
op4.Text = ds.Tables(0).Rows(index).Item(5)
op4.DataBind()
corr_op.Value = ds.Tables(0).Rows(index).Item(6)
corr_op.DataBind()
Label1.Text = index + 1
End Function

Public Function next_ques() As Boolean


index = Me.ViewState("Index")
index += 1
If index > ds.Tables(0).Rows.Count - 1 Then
index = 0
End If
Me.ViewState("Index") = index
disp()
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
End Function

Protected Sub Page_Load(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Me.Load
tleft = 60
Timer1.Enabled = True
Label3.Text = Date.Today.ToLongDateString
MsgBox("Dear Candidate Please Hurry Only 5 minutes Left",
MsgBoxStyle.OkOnly, " ")
MsgBox("Time is Up!!!!", MsgBoxStyle.OkOnly, " ")
TextBox1.Text = Request.QueryString("rollno")
TextBox2.Text = Request.QueryString("username")
ImageMap2.ImageUrl = "~/images/" + TextBox1.Text + ".jpg"
Dim st As String = ("select * from ques ;")
Dim ap As SqlClient.SqlDataAdapter = New
SqlClient.SqlDataAdapter()
Dim dt As DataTable = New DataTable()
cs = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=oles;Data Source=CC3-123"
Dim con As SqlClient.SqlConnection = New
SqlClient.SqlConnection(cs)
Dim comm As SqlClient.SqlCommand = New SqlClient.SqlCommand
comm.CommandText = CommandType.Text
con.Open()
ap = New SqlClient.SqlDataAdapter(st, con)
ap.Fill(ds)

45
q_id.Value = ds.Tables(0).Rows(0).Item(0)
q_id.DataBind()
ques.Text = ds.Tables(0).Rows(0).Item(1)
ques.DataBind()
op1.Text = ds.Tables(0).Rows(0).Item(2)
op1.DataBind()
op2.Text = ds.Tables(0).Rows(0).Item(3)
op2.DataBind()
op3.Text = ds.Tables(0).Rows(0).Item(4)
op3.DataBind()
op4.Text = ds.Tables(0).Rows(0).Item(5)
op4.DataBind()
corr_op.Value = ds.Tables(0).Rows(0).Item(6)
corr_op.DataBind()
Label1.Text = index + 1
End Sub

Protected Sub first_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles first.Click
Dim index As Integer
index = 0
Me.ViewState("Index") = index
disp()
End Sub

Protected Sub p_ques_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles p_ques.Click
index = Me.ViewState("Index")
index -= 1

If index < 0 Then


index = ds.Tables(0).Rows.Count - 1
End If
Me.ViewState("Index") = index
disp()
End Sub

Protected Sub submit_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles submit.Click
Dim ans As String
Dim marks As Integer
Dim co As String
co = corr_op.Value
ans = " "
If (RadioButton1.Checked = True) Then
ans = "a"
ElseIf (RadioButton2.Checked = True) Then
ans = "b"
ElseIf (RadioButton3.Checked = True) Then
ans = "c"
ElseIf (RadioButton4.Checked = True) Then
ans = "d"
End If
Dim result As Integer = String.Compare(co.Trim.ToString,
ans.Trim.ToString)
If (result = 0) Then
marks = 1

46
Else
marks = 0
End If
Dim ds As New DataSet
Dim cs As String
ds = New DataSet("answer")
cs = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=oles;Data Source=CC3-123"
Dim con As SqlClient.SqlConnection = New
SqlClient.SqlConnection(cs)
Dim comm As SqlClient.SqlCommand = New SqlClient.SqlCommand()
comm.CommandType = CommandType.Text
Dim st As String = ("insert into
answer(q_id,question,roll_no,name,op1,op2,op3,op4,corr_op,user_op,marks)
values(" + q_id.Value + ",'" + ques.Text + "','" + TextBox1.Text + "','"
+ TextBox2.Text + "','" + op1.Text + "','" + op2.Text + "','" + op3.Text
+ "','" + op4.Text + "','" + corr_op.Value + "','" + ans.ToString + "',"
+ (Integer.Parse(marks)).ToString + ") ;")
comm = New SqlClient.SqlCommand(st, con)
con.Open()
'MsgBox(con.State.ToString)
comm.ExecuteNonQuery()
con.Close()
next_ques()
End Sub

Protected Sub n_ques_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles n_ques.Click
next_ques()
End Sub

Protected Sub last_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles last.Click
Dim index As Integer
index = Me.ViewState("Index")
index = ds.Tables(0).Rows.Count - 1
Me.ViewState("Index") = index
disp()
End Sub

Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
Label4.Text = "UpdatePanel1 refreshed at: " & _
DateTime.Now.ToLongTimeString()
If (Integer.Parse(Label4.Text) <= 5) Then
MsgBox("Dear Candidate Please Hurry Only 5 minutes Left",
MsgBoxStyle.OkOnly, " ")
End If
If (Integer.Parse(Label4.Text) = 0) Then
MsgBox("Time is Up!!!!", MsgBoxStyle.OkOnly, " ")
End If
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim result As Integer

47
result = MsgBox("Are you sure you want to exit",
MsgBoxStyle.YesNo, "Exit")
If (result = MsgBoxResult.Yes) Then
Response.Redirect("result.aspx?name=" + TextBox2.Text +
"&rollno=" + TextBox1.Text)
Else
End If
End Sub
End Class

7.4 Result Window

7.4.1 HTML Coding


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="result.aspx.vb"
Inherits="_Default" %>

<!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 runat="server">
<title>Untitled Page</title>

48
</head>
<body>
<form id="form1" runat="server">
<div style="height: 1022px">

<asp:Image ID="Image1" runat="server" Height="140px"


ImageUrl="~/Sitm_logo.gif"
Width="173px" />
<asp:Image ID="Image2" runat="server" Height="140px"
ImageUrl="~/onilne_exam_banner.jpg" Width="1014px" />
<br />
<br />
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
<asp:Label ID="Label1" runat="server" Font-Size="XX-Large"
ForeColor="Red"
Text="Result"></asp:Label>
<br />
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
<asp:Label ID="Label2" runat="server" Font-Size="Large"
Text="Name"></asp:Label>
&nbsp;<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label3" runat="server" Font-Size="Large"
Text="Roll Number"></asp:Label>
&nbsp;<asp:TextBox ID="txtrollno" runat="server"></asp:TextBox>
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Image ID="Image3" runat="server" Height="135px"
Width="156px" />
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
<asp:Label ID="Label4" runat="server" Font-Size="Large" Text="Total
Questions"></asp:Label>
&nbsp;<asp:TextBox ID="txttotalQues" runat="server"></asp:TextBox>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
<asp:Label ID="Label5" runat="server" Font-Size="Large"
Text="Correct Questions"></asp:Label>
&nbsp;<asp:TextBox ID="txtcorrQues" runat="server"></asp:TextBox>
<br />

49
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
<asp:Label ID="Label6" runat="server" Font-Size="Large"
Text="Incorrect Questions"></asp:Label>
&nbsp;<asp:TextBox ID="txtIncorrQues" runat="server"></asp:TextBox>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
<asp:Label ID="Label7" runat="server" Font-Size="Large"
Text="Marks"></asp:Label>
&nbsp;<asp:TextBox ID="txtmarks" runat="server"></asp:TextBox>
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
<asp:Label ID="Label8" runat="server" Font-Size="Large"
Text="Status"></asp:Label>
&nbsp;<asp:TextBox ID="txtstatus" runat="server"></asp:TextBox>

<br />
<br />
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
<asp:Button ID="Button1" runat="server" Height="33px" Text="Show
Result"
Width="122px" />

</div>
</form>
</body>
</html>

7.4.2 VB Scripting
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Data.Common
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Me.Load
txtname.Text = Request.QueryString("name")
txtrollno.Text = Request.QueryString("rollno")
Image3.ImageUrl = "~/images/" + txtrollno.Text + ".jpg"
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim ds As New DataSet
Dim cs As String

50
ds = New DataSet("answer")
cs = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=oles;Data Source=CC3-123"
Dim con As SqlClient.SqlConnection = New
SqlClient.SqlConnection(cs)
Dim comm As SqlClient.SqlCommand = New SqlClient.SqlCommand()
comm.CommandType = CommandType.Text
Dim st As String = ("select sum(marks) from answer where name='"
+ txtname.Text + "' and roll_no='" + txtrollno.Text + "' ;")
comm = New SqlClient.SqlCommand(st, con)
Dim dr As SqlClient.SqlDataReader
con.Open()
dr = comm.ExecuteReader()
While (dr.Read())
txtmarks.Text = dr.GetValue(0).ToString
End While
con.Close()
txttotalQues.Text = "20"
txtcorrQues.Text = txtmarks.Text
txtIncorrQues.Text = Integer.Parse(txttotalQues.Text) -
Integer.Parse(txtcorrQues.Text)
If (Integer.Parse(txtmarks.Text) >= 12) Then
txtstatus.ForeColor = Drawing.Color.Green
txtstatus.Text = "Pass"
Else
txtstatus.ForeColor = Drawing.Color.Red
txtstatus.Text = "Fail"
End If
End Sub
End Class

51
7.5 Question Entry Form for Examiner

7.5.1 HTML
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>

<!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 runat="server">
<title>Untitled Page</title>
<style type="text/css">
.style3
{
width: 122px;
height: 78px;
}
.style4
{
width: 1022px;
height: 78px;
}

52
.style5
{
height: 78px;
}
.style21
{
width: 122px;
height: 35px;
}
.style22
{
width: 1022px;
height: 35px;
}
.style23
{
height: 35px;
}
.style24
{
width: 122px;
height: 36px;
}
.style25
{
width: 1022px;
height: 36px;
}
.style26
{
height: 36px;
}
.style27
{
width: 122px;
height: 38px;
}
.style28
{
width: 1022px;
height: 38px;
}
.style29
{
height: 38px;
}
</style>
</head>
<body bgcolor="#c4e1ff">
<form id="form1" runat="server">
<div>

<asp:Image ID="Image1" runat="server" Height="144px"


ImageUrl="~/Sitm_logo.gif"
Width="150px" />
<asp:ImageMap ID="ImageMap1" runat="server" Height="142px"
ImageUrl="~/onilne_exam_banner.jpg" Width="1037px">

53
</asp:ImageMap>

</div>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Label ID="Label1" runat="server" Font-Bold="True"
Text="Question Id"></asp:Label>
&nbsp;<asp:TextBox ID="q_id" runat="server" Width="53px"></asp:TextBox>
</p>
<table style="width: 100%; height: 246px;">
<tr>
<td class="style3">
<asp:Label ID="Label2" runat="server"
Text="Question"></asp:Label>
</td>
<td class="style4">
<asp:TextBox ID="ques" runat="server" Height="80px"
Width="1020px"></asp:TextBox>
</td>
<td class="style5">
</td>
</tr>
<tr>
<td class="style21">
<asp:RadioButton ID="RadioButton1" runat="server" Font-
Bold="True" Text="(A)" />
</td>
<td class="style22" width="42px">
<asp:TextBox ID="op1" runat="server" Height="42px"
Width="1022px"></asp:TextBox>
</td>
<td class="style23">
</td>
</tr>
<tr>
<td class="style24">
<asp:RadioButton ID="RadioButton2" runat="server" Font-
Bold="True" Text="(B)" />
</td>
<td class="style25" width="42px">
<asp:TextBox ID="op2" runat="server" Height="42px"
Width="1020px"></asp:TextBox>
</td>
<td class="style26">
</td>
</tr>
<tr>

54
<td class="style27">
<asp:RadioButton ID="RadioButton3" runat="server" Font-
Bold="True" Text="(C)" />
</td>
<td class="style28" width="42px">
<asp:TextBox ID="op3" runat="server" Height="42px"
Width="1021px"></asp:TextBox>
</td>
<td class="style29">
</td>
</tr>

<tr>
<td class="style27">
<asp:RadioButton ID="RadioButton4" runat="server" Font-
Bold="True" Text="(D)" />
</td>
<td class="style28" width="42px">
<asp:TextBox ID="op4" runat="server" Height="42px"
Width="1022px"></asp:TextBox>
</td>
<td class="style29">
</td>
</tr>

</table>
<p>
&nbsp;</p>
<p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="Button1" runat="server" Height="37px" Text="Submit"
Width="86px" />
</p>
</form>
</body>
</html>

7.5.2 VB Scripting
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Data.Common
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim ans As String
If (RadioButton1.Checked = True) Then
ans = "a"
ElseIf (RadioButton2.Checked = True) Then
ans = "b"
ElseIf (RadioButton3.Checked = True) Then

55
ans = "c"
ElseIf (RadioButton4.Checked = True) Then
ans = "d"
End If
Dim ds As New DataSet
Dim cs As String
ds = New DataSet("question")
cs = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=oles;Data Source=CC3-123"
Dim con As SqlClient.SqlConnection = New
SqlClient.SqlConnection(cs)
Dim comm As SqlClient.SqlCommand = New SqlClient.SqlCommand()
comm.CommandType = CommandType.Text
Dim st As String = ("insert into question values(" + q_id.Text +
",'" + ques.Text + "','" + op1.Text + "','" + op2.Text + "','" + op3.Text
+ "','" + op4.Text + "','" + ans.ToString + "') ;")
comm = New SqlClient.SqlCommand(st, con)
con.Open()
comm.ExecuteNonQuery()
con.Close()
End Sub
End Class

56
CHAPTER 8

CONCLUSIONS

a) Result: This software generates result of the examination of all the students.
This result is very handy for our Director at the time of Valediction. He may
discuss the result in one to one basis and advice for further improvement if any.
b) Time saving approach: Time is of essence in an objective type on line test.
This software was expressly designed with that intrinsic objective in view. All
the operations are managed through click of mouse only. This saves time
appreciably.
c) Timer: The application is timed . The student gets a time limit to complete
test. When 5 minute time is left the student is alarmed about the remainig time.
When the time goes up the exam screen is closed and result is shown.

Future Enhancement
The next version will be developed with a feedback option for student and
assessment of examination using higher version of Microsoft Visual Basic and
SQL Server. Student’s performance report can be generated through graphical
representation. Negative Marking concept can be applied in result evaluation.

REFERENCES

57
Websites:
For developing this project we have taken some valuable helps from the
following websites and books:

1. www.daniweb.com
2. www.w3schools.com
3. www.wikipedia.org
4. www.draftlogic.com
Books:
1. ASP.NET 2.0 Web Programming with VB 2005
2. Build Your Own ASP.NET Website Using C# & VB.NET

58

S-ar putea să vă placă și