Вы находитесь на странице: 1из 100

ABSTRACT

Education is the backbone of a nation. No country can develop without education. The main
goal of this online examination system is to effectively evaluate the student thoroughly
through a totally automated system that not only reduce the required time but also obtain fast
and accurate results. Students can participate exam through online. This project provides
facility to conduct online examination world-wide. Administrator has a privilege to create,
modify, & delete particular questions from specific levels. Student must need to login for
participating examination by email & password. For new student he /she must need to
complete registration to login this site. Then student can be able to participate in the exam.
When start exam the timer will start automatically and show the student how much time left.
Questions are being displayed randomly from question bank. Student is given a limited time
to answer the questions and after the time expiry the answer paper is disabled automatically
and answers is sent to the examiner. There are three level exist in this project. If students can
not get 70% mark in the first level, they can not participate in the second level. If students
can not get 70% mark in the second level, they can not participate in the third level. Rank list
is created by those students who will get 70% mark in the third level. After completing the
examination student can see their results and ranks. This project reduces paper works. It is
helpful for both students and teachers. This project can allows multiple number of students
participate in the exam at the same time in the world.

i
Table of Contents

(i) Abstract…………………………………………………….....………………………….i

CHAPTER ONE
1. Introduction
1.1 Overview..................................................................................................................... 2
1.2 Project Description……………………………………….…………………............. 2
1.3 Project Objective……………………………………….…………………………… 3

CHAPTER TWO
2. Project Management
2.1 Planning and Scheduling……………….…………………………………………….5
2.3 Process Flow ……………..……………………………………..…………………....5
2.2 Risk Management ……...………………...………………………………………......5

CHAPTER THREE
3. Analysis and Design
3.1 Feasibility Study……………………………………………………………………....8
3.1.1 Economic Feasibility…. ……………………………………………………....8
3.1.2 Technical Feasibility… …………………………………..………………….. .8
3.1.3 Behavioral Feasibility…… ………………………………………………….. .9
3.2 Proposed System …...………….……………………………………………………..9
3.3 Design Concepts ………………………….…...……..………………………...…......9
3.4 Use Case Diagram ………………………...…………………………………………11
3.5 Data Flow Diagram ……………………..…………………………………………... 12
3.6 Entity Relationship Diagram …………………………………………………..…….13
3.7 Design Pyramid .…………………………………………………………………….. 14
3.8 Implementation Tools …..…………………………………...…………………….. 15
3.8.1 Notepad++ Editor…………………………………………………………... 15
3.8.2 Web browser…………………………………..………..…………………... 15
3.8.3 Xampp Server………………………………………………………………. 15
3.8.4 DBMS ……………………………………………………………………… 15

ii
3.8.5 PHP …………………………………………..………..…………………… 16
3.8.6 HTML ……………………………………………………………………… 16
3.8.7 CSS ………………………………………………………………………… 17
3.8.8 JAVASCRIPT ………………………………………..………….………..... 17
3.9 System Specifications …….………………………………...……………………... 18
3.9.1 Hardware Requirements ……………………………………………………. 18
3.9.2 Software Requirements ………………………………..…………………… 18
3.10 Database Overview......................................……………………………….……… 19
3.11 Testing ……………………….…...……..………………………...….................... 19
3.12 Output Screen………………………………………………………………………20
3.12.1 User Panel… …………………………………………..…………………… 20
3.12.2 Admin Panel… ………………………...……………………………………23
3.13 Code………...………………………………………………………………………27
3.13.1 User Panel Code………………………………………..…………………… 27
3.13.2 Admin Panel Code………………..........…………………………………… 65

CHAPTER FOUR
4. Conclusion
4.1 Conclusion............................……………………………….…………………….… 96
4.2 References.......................……………..…………………….…………………….… 97

iii
CHAPTER ONE | Introduction

CHAPTER ONE
Introduction

Developing an Online Examination System | Page | 1


CHAPTER ONE | Introduction

Chapter Overview
In this chapter we will introduce about our project overview, project description and project
objective. In section 1.1 we will discuss about project overview, in section 1.2 we will discuss
about of our project description and in section 1.3 we will discuss about our project objectives.

1.1 Overview
Online examination system is a web-based examination system where examinations are given
online. Some of the problems faced during manual examination systems are the delays occurred
in result processing, filing poses a problem, filtering of records is difficult. The chance of loss
of records is high also record searching is difficult. Maintenance of the system is also very
difficult and takes lot of time and effort. Online examination is one of the crucial parts for
online education system. It is efficient, fast enough and reduces the large amount of material
resource. Students can participate exam through online. They can view the result after
completing exam. This web application provides facility to conduct online examination world-
wide.

1.2 Project Description


Students can participate exam through online. They can view the result after completing exam.
There are two panel in this project. One is Admin panel and another is User panel.

In Admin panel Admin need to login this site by entering username and password. After login
admin can add question, edit question and delete question from question bank. Admin can edit
and delete level. Admin can also see the student results, ranks and manage and delete user.

In User panel, student must need email id and password to participate the examination. For
new student he /she must need to complete registration by entering some information such as
email id, password, full name, gender and mobile number to login this site. After completing
the registration then students could be able to participate the examination. When start exam the
timer will start automatically and show the student how much time left. Questions are being
displayed randomly from question bank. Student is given a limited time to answer the questions
and after the time expiry the answer paper is disabled automatically and answers is sent to the
examiner. . There are three level exist in this project. If students can not get 70% mark in the
first level, they can not participate in the second level. If students can not get 70% mark in the
Developing an Online Examination System | Page | 2
CHAPTER ONE | Introduction

second level, they can not participate in the third level. Rank list is created by those students
who will get 70% mark in the third level. After completing the examination student can see
their results and ranks.

1.3 Project Objective


The main goal of this online examination system is to effectively evaluate the student
thoroughly through a totally automated system that not only reduce the required time but also
obtain fast and accurate results. Online examination system is user-friendly. A responsive
design is an approach where the web designer wants to reach an optimal web experience for a
wide range of devices. A responsive site scales with the size of the screen without sacrificing
the text readability or usability of the user interface. Having to check all answers is very time-
consuming. So, having the answers checked automatically and instantly will eventually pay
off. It’s less work for the creator of the exam and participants don’t have to wait too long for
getting the results of their exams. Some of the problems faced during manual examination
systems are the delays occurred in result processing, filing poses a problem, filtering of records
is difficult. The chance of loss of records is high also record searching is difficult. Maintenance
of the system is also very difficult and takes lot of time and effort. Online examination is one
of the crucial parts for online education system. It is efficient, fast enough and reduces the large
amount of material resource.

Developing an Online Examination System | Page | 3


CHAPTER TWO | Project Management

CHAPTER TWO
Project Management

Developing an Online Examination System | Page | 4


CHAPTER TWO | Project Management

Chapter Overview
In this chapter we will introduce about planning and scheduling, process flow and risk
management. In section 2.1 we will discuss about planning and scheduling, in section 2.2 we
will discuss about process flow and in section 2.3 we will discuss risk management.

2.1 Planning and Scheduling


Project planning and scheduling is a part of project management. The project planning stage
requires several inputs, including conceptual proposals, project schedules. The development of
this project is not successfully done without proper planning and scheduling. Project planning
and scheduling is very important stage for us.
(a) Analysis: The maximum time for analysis phase of this project is 1 month.
(b) Design: The maximum time for design phase of this project is 2 months.
(c) Implementation: The maximum time for implementation phase of this project is 3 months.

2.2 Process Flow


We have used iterative process flow for this project development. Iterative model is a software
development process. Iterative development is a way of breaking down the software
development of a large application into smaller chunks. In iterative development, feature code
is designed, developed and tested in repeated cycles. With each iteration, additional features
can be designed, developed and tested until there is a fully functional software application
ready to be deployed to customers. In an iterative model we come back previous stage during
development. In iterative model we can only create a high-level design of the application before
we actually begin to build the product and define the design solution for the entire product. In
iterative model we can get the reliable user feedback. By working iteratively, the project team
goes through a cycle where they evaluate with each iteration, and determine what changes are
needed to produce a satisfactory end product.

2.3 Risk Management


A common definition of risk is an uncertain event that if it occurs, can have a positive or
negative effect on a project’s goals. It helps us to achieve the project’s objectives, thus ensuring
the successful completion of the project. For successful development of this project we have to
need to identify the possible risk. The possible risk for this project is described in below:

Developing an Online Examination System | Page | 5


CHAPTER TWO | Project Management

(a) The probability of moving away our-self from this project before it is finish is low.
(b) The probability of user acceptance is great.
(c) The probability of requirement can't come in the time is low.
(d) The probability of marketing the product system is great.
(e) The probability of technology components aren't fit for purpose of this project is low.
(f) The probability of selecting low quality requirements are low.
(g) The probability of take wrong decisions are low.
(h) The probability of does not complete this project within a limited time is low.

Developing an Online Examination System | Page | 6


CHAPTER THREE | Analysis and Design

CHAPTER THREE
Analysis and Design

Developing an Online Examination System | Page | 7


CHAPTER THREE | Analysis and Design

Chapter Overview
In this chapter, we will introduce about feasibility study, proposed system, design concepts,
use case diagram, data flow diagram, entity relationship diagram, web app design pyramid,
implementation tools, system specifications, database overview, testing, output screen and
code. In section 3.1 we will discuss about feasibility study, in section 3.2 we will discuss about
proposed system, in section 3.3 we will discuss about design concepts, in section 3.4 we will
discuss about use case diagram, in section 3.5 we will discuss about data flow diagram, in
section 3.6 we will discuss about entity relationship diagram, in section 3.7 we will discuss
about design pyramid, in section 3.8 we will discuss about implementation tools, in section 3.9
we will discuss about system specifications, in section 3.10 we will discuss about database
overview, in section 3.11 we will discuss about testing, in section 3.12 we will discuss about
output screen and in section 3.13 we will discuss about code.

3.1 Feasibility Study


A feasibility study is an analysis of how successfully a project can be completed. Feasibility
study is conducted once the problem is clearly understood. During the study, the problem
definition is solved and all aspects of problem to be included in the system are determined. The
purpose of feasibility is not to solve the problem but to determine if the problem is worth
solving.
There are three types of feasibility study for this project is described in below:

3.1.1 Economic Feasibility


Development of this project is highly economically feasible. The purpose of assessing
economical feasibility is to identify the financial benefits and cost associated with the
development of the system. Economic feasibility is often known as the cost benefit analysis.
The manual system is highly cost driven due to the high labour costs. This project is automated
system and it does not require labour cost. Thus this project is economically feasible.

3.1.2 Technical Feasibility


Technical feasibility is concerned with specifying equipment and software that will satisfy the
user requirement. This project is technical feasible because it does not require any additional
hardware or software. The interface for this project is developed using the existing resources.

Developing an Online Examination System | Page | 8


CHAPTER THREE | Analysis and Design

3.1.3 Behavioral Feasibility


Behavioral feasibility reveals that whether the system is acceptable by user or not. Behavioral
feasibility of this project estimates the reaction of the User staff towards the development of
the computerized system. For the successful implementation of any system, the users must be
impressed that the new system is for his benefit. This project is automated system and user get
results instantly. So this project is behaviorally feasible.

3.2 Proposed System


This project is used to conduct online examination. The students can sit at individual terminals
and login to participate the examination in the given duration. For new user he /she must need
to complete registration by entering some information such as email id, password, full name,
gender and mobile number to login this site. After completing the registration then student
could be able to participate the examination. The questions are displayed randomly from
question bank. When start exam the timer will start automatically and show the student how
much time left. Student is given a limited time to answer the questions and after the time expiry
the answer paper is disabled automatically and answers is sent to the examiner. There are three
level exist in this project. If students can not get 70% mark in the first level, they can not
participate in the second level. If students can not get 70% mark in the second level, they can
not participate in the third level. Rank list is created by those students who will get 70% mark
in the third level. After completing the examination student can see their results and ranks. This
project display the result immediately and also store it in database. This project provides the
administrator with a facility to add question, edit question and delete question from question
bank. Admin can also see the student results, ranks and manage user.

3.3 Design Concepts


Design is the only way to accurately translate the customer’s requirements into finished
software or a system. Design is the place where quality is fostered in development. Software
design is a process through which requirements are translated into a representation of software.
Once the software requirements have been analyzed and specified the software design involves
three technical activities - design, coding, implementation and testing that are required to build

Developing an Online Examination System | Page | 9


CHAPTER THREE | Analysis and Design

and verify the software. The design activities are of main importance in this phase, because in
this activity, decisions ultimately affecting the success of the software implementation and its
ease of maintenance are made. These decisions have the final bearing upon reliability and
maintainability of the system. Software design is conducted in two steps. Preliminary design is
concerned with the transformation of requirements into data. The most creative and challenging
phase of the system is design. This project designs provides a web-based interface. It is the
graphical user interface. The term design describes a final system and the process by which it
is developed. It includes the construction of programs and program testing. The first step is
determine how the output is to be produced and in what format. Samples of the outputs are also
presented. Second, input data and database have to be designed to meet the requirements of the
proposed output.

We have designed use case diagram, data flow diagram and entity relationship diagram for
developing this project.

Developing an Online Examination System | Page | 10


CHAPTER THREE | Analysis and Design

3. 4 Use Case Diagram

Figure 3.4: Use Case Diagram of Online Examination

Developing an Online Examination System | Page | 11


CHAPTER THREE | Analysis and Design

3.5 Data Flow Diagram

Figure 3.5: DFD of Online Examination System

Developing an Online Examination System | Page | 12


CHAPTER THREE | Analysis and Design

3.6 Entity Relationship Diagram

Figure 3.6: ER Diagram of Online Examination System

Developing an Online Examination System | Page | 13


CHAPTER THREE | Analysis and Design

3.7 Design Pyramid


We have used the following design pyramid for this project design:

user

Interface
design

Aesthetic design

Content design

Navigation design

Architecture design

Component design

technology

Figure 3.7: Design pyramid of Online Examination System

Developing an Online Examination System | Page | 14


CHAPTER THREE | Analysis and Design

3.8 Implementation Tools


We have used the following implementation tools for our project developing:

3.8.1 Notepad++ Editor


We have used notepad++ editor for writing code of this project. Notepad++ has line
numbering, which is always useful to have when editing source code or configuration files. It
provides to change the size of the font, zooming in and out. It provides a facility to search and
replace letter or word or sentence. It provides a facility to work with multiple open files in a
single window.

3.8.2 Web Browser


We have used web browser to run the project and check the input output. One of the most
important qualities a browser should have is the ability to load Web pages quickly. It provides
a facility to work with multiple tabs in a single window. In xampp server, Php error reporting
is enabled by default, which helps when debugging scripts.

3.8.3 Xampp Server


We have used xampp server to run the project and check the input output without internet
connection. Xampp server provides a facility to create new database, delete database and
modify differents database tables.

3.8.4 DBMS
We have used database management system for back-end design of this project. A database
can be defined as a collection of coherent, meaningful data which is available to many users
for different purposes. For example, patient information. A database management system
defines the way to manage the data in such a database. Management of data involves both
defining structures for storage of information and providing mechanisms for the manipulation
of information. In addition the database system must ensure the safety of the information
stored, despite system crashes or attempts at unauthorized access.

Developing an Online Examination System | Page | 15


CHAPTER THREE | Analysis and Design

3.8.5 PHP
We have used PHP for front-end design of this project. PHP is a server-side scripting language
designed primarily for web development but also used as a general-purpose programming
language. Originally created by Rasmus Lerdorf in 1994.It is commonly used to extract data
out of a database on the web server and present it on the web page.

The following "Hello, World!" program is written in PHP code embedded in


an HTML document:

<!DOCTYPE html>
<html>
<head>
<title> PHP Test </title>
</head>
<body>
<?php echo ‘<p> Hello World </p>’; ?>
</body>
</html>

3.8.6 HTML
We have used HTML for front-end design of this project. Hyper Text Markup
Language (HTML) is the standard markup language for creating web pages and web
applications. With Cascading Style Sheets (CSS), and JavaScript, it forms a triad of cornerstone
technologies for the World Wide Web. Web browsers receive HTML documents from
a webserver or from local storage and render them into multimedia web pages. HTML
describes the structure of a web page semantically and originally included cues for the
appearance of the document.

The following "Hello, World!" program is written in HTML:

<!DOCTYPE html>
<html>
<head>
<title> HTML Test </title>
</head>
<body>
Developing an Online Examination System | Page | 16
CHAPTER THREE | Analysis and Design

<p> Hello World </p>


</body>
</html>

3.8.7 CSS
We have used CSS for front-end design of this project. Cascading Style Sheets (CSS) is a style
sheet language used for designing web pages and web applications. CSS is designed primarily
to enable the separation of document content from document presentation, including aspects
such as the layout, colors, and fonts. This separation can improve content accessibility, provide
more flexibility and control in the specification of presentation characteristics, enable multiple
HTML pages to share formatting by specifying the relevant CSS in a separate .css file, and
reduce complexity and repetition in the structural content.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
#xyz { color: red; }
</style>
</head>
<body>
<p id="xyz" style="color: blue;"> To demonstrate specificity </p>
</body>
</html>

3.8.8 JAVASCRIPT
We have used JAVASCRIPT for front-end design of this project. JavaScript (JS) is a scripting
languages, primarily used on the Web. It is used to enhance HTML pages and is commonly
found embedded in HTML code. JavaScript is one of the three core technologies of World
Wide Web content production; the majority of websites employ it, and all modern Web
browsers support it without the need for plug-ins. JavaScript is prototype-based with first-class
functions, making it a multi-paradigm language, supporting object-oriented, imperative,

Developing an Online Examination System | Page | 17


CHAPTER THREE | Analysis and Design

and functional programming styles. It has an API for working with text, arrays, dates
and regular expressions.

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>
<h2>JavaScript in Head</h2>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Try it</button>
</body> </html>

3.9 System Specifications


This project does not require high configurations of computer. It requires normal configurations
of the computer. The systems requirements for the proposed project “Online Examination” is
mentioned following.

3.9.1 Hardware Requirements


(a) Pentium-IV (Processor).
(b) 1 GB Ram
(c) 512 KB Cache Memory
(d) Hard disk 10 GB
(e) Microsoft Compatible Key Board

3.9.2 Software Requirements


(a) Operating System : Windows
(e) Web Server: Apache Server

Developing an Online Examination System | Page | 18


CHAPTER THREE | Analysis and Design

3.10 Database Overview


This project is made of five database tables...
(a) Admin
Admin table is used to store the information about admin, such as id, username, role,
password, name and department.
(b) Question
Question table is used to store the information about question, such as question id, subject
id, question, option A, option B, option C, option D and correct answer.
(c) Result
Result table is used to store the information about result, such as question id, user id, subject
id, marks, time, total question, marks per right answer, marks per wrong answer, right
answer and wrong answer.
(d) Level
Level table is used to store the information about level, such as level id, level name, total
question, marks per right answer, marks per wrong answer and time.
(e) User
User table is used to store the information about user, such as id, name, gender, email,
password and mobile number.

3.11 Testing
Testing is a process of executing a program with the intent of finding an error. Testing is a
crucial element of software quality assurance and presents ultimate review of specification,
design and coding. System Testing is an important phase. Testing represents an interesting
anomaly for the software. A good test case is one that has a high probability of finding an as
undiscovered error.
We have tested this project in proposed system specifications computer. At first we have
installed xampp software in our computer. Then we have installed a web browser. Then we
have run xampp and web browser. Then we have typed http://localhost/phpmyadmin in our
web browser. Then we have created database name and import .sql file. Then we have typed
http://localhost/exam to run this project user panel and type http://localhost/exam/admin to run
this project admin panel. This project has worked properly. We have not found any types of
error in this project.

Developing an Online Examination System | Page | 19


CHAPTER THREE | Analysis and Design

3.12 Output Screen


Output screen of Online Examination System is given below:
3.12.1 User Panel
(a) Login

(b) Registration

Developing an Online Examination System | Page | 20


CHAPTER THREE | Analysis and Design

(c) Home

(d) Exam

(e) Start Exam

Developing an Online Examination System | Page | 21


CHAPTER THREE | Analysis and Design

(f) Result

(g) View Result

(h) Ranking

Developing an Online Examination System | Page | 22


CHAPTER THREE | Analysis and Design

3.12.2 Admin Panel


(a) Login

(b) Home

(c) Manage Levels

Developing an Online Examination System | Page | 23


CHAPTER THREE | Analysis and Design

(d) Add Question

(e) Edit Question

Developing an Online Examination System | Page | 24


CHAPTER THREE | Analysis and Design

(f) Delete Question

(g) Manage User

(h) Result

Developing an Online Examination System | Page | 25


CHAPTER THREE | Analysis and Design

(i) Ranking

Developing an Online Examination System | Page | 26


CHAPTER THREE | Analysis and Design

3.13 Code
3.13.1 User Panel Code

(a) register.php

<?php
include "init.php";
if($user->is_user()){
redir($site->url);
exit;
}
$site->title = "Registration";
include 'header.php';

include (ROOTDIR."/includes/class.register.php");
$register = new Register();
?>
<div class="col-lg-2 col-md-2 hidden-xs hidden-sm"></div>
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
<?php
echo '
<div class="panel panel-primary">
<div class="panel-heading">Registration Form</div>
<div class="panel-body" style="padding: 5px;">';
if(isset($_POST["email"],$_POST["pwd"],$_POST["pwd2"]))
{
extract($_POST);
$errors=array();
if($register->is_email($email)) $errors[] = "Email is already registered.";
if(!$register->valid_email($email)) $errors[] = "Invalid Email.";
if(strlen($pwd2)<4) $errors[] = "Password must be atleast 4 words.";
if($pwd!=$pwd2) $errors[] = "Both Password are not matched.";
if(strlen($name)<1) $errors[] = "Full Name is empty.";
if(strlen($gender)<1) $errors[] = "Gender is empty.";
if(strlen($mobile)<1) $errors[] = "Mobile number is empty.";

if(empty($errors))
{
$pwdhash = password_hash($pwd, PASSWORD_DEFAULT);
$arr =
array("email"=>$email,"password"=>$pwdhash,"name"=>$name,"gender"=>$gender,
"mobile"=>$mobile,"time_created"=>time(),"lasttime"=>time()

Developing an Online Examination System | Page | 27


CHAPTER THREE | Analysis and Design

);

if($db->insert("users",$arr,""))
{
$_SESSION["id"]=$user->gdata("id",array("email"=>$email));
$_SESSION["message"] = "You have registered successfully!";
redir($site->url."/index.php");
}
else
{
echo "CRITICAL_DB_ERROR!";
}
}
else
{
echo '<pre>';
foreach($errors as $err) echo $err.'<br/>';
echo '</pre>';
}
}

$form->show("post","",
array(
array("multiText",
array("email","Email")
),
array("multiPass",
array("pwd","Password"),
array("pwd2","Password Again")
),
array("multiText",
array("name","Full Name"),
array("gender","Gender"),
array("mobile","Mobile Number")
)
),
array("value"=>"Sign Up")
);

echo '
<div class="form-group">
<a href="'.$site->url.'/login.php">Already Registered ? Log In Now</a>

Developing an Online Examination System | Page | 28


CHAPTER THREE | Analysis and Design

</div>';

echo '
</div>
</div';

include 'footer.php';
?>

(b) login.php
<?php
include "init.php";
if($user->is_user()){
redir($site->url);
exit;
}
$site->title = "Log In to System";
include 'header.php';

echo '
<div class="panel panel-primary">
<div class="panel-heading">Log In</div>
<div class="panel-body" style="padding: 5px;">';

if(isset($_POST["email"],$_POST["pwd"])){

$email = post("email");
$pwd = post("pwd");

if(empty($email) OR strlen($email)<1) $errors[] = "Email is empty!";


if(empty($pwd) OR strlen($pwd)<1) $errors[] = "Password is empty!";
if(!$user->login($email,$pwd)) $errors[] = "Email or password is wrong!";

if(empty($errors))
{
$id = $user->gdata("id",array("email"=>$email));
$_SESSION["id"]=$id;
$db->update("users",array("lasttime"=>time()),array("id"=>$id));
redir($site->url."/");
}

Developing an Online Examination System | Page | 29


CHAPTER THREE | Analysis and Design

else {
echo '<pre>';
foreach($errors as $err) echo $err.'<br/>';
echo '</pre>';
}
}

$form->show("post","",
array(
array("multiText",
array("email","Email")
),
array("multiPass",
array("pwd","Password")
)
),
array("value"=>"Log IN")
);

echo '<br/>Or <a href="'.$site->url.'/register.php"><button type="submit" class="btn


btn-primary">Register Now</button></a>';

echo '
</div>
</div';
include 'footer.php';
?>

(c) exam.php
<?php
include 'init.php';
if(!$user->is_user())
{
redir($site->url."/login.php");
exit;
}
if(isset($_GET["act"]))
$act = get("act");
else
$act="";

Developing an Online Examination System | Page | 30


CHAPTER THREE | Analysis and Design

if(isset($_GET["sid"]))
{
$sid=get("sid");
$sql = $db->select("subjects","",array("id"=>$sid));
if($sql->num_rows==1)
{
$sub = $sql->fetch_assoc();
}
else
{
echo '<h3>Level Not Found</h3>';
exit;
}
}

if($act=="rules" && isset($sid)) {


redir("?act=start&sid=".$sid);
}
else if($act=="start" && isset($sid)) {
$title = "Exam: ".$sub["name"];
}
else {
$title = "Choose Level";
}
$site->title = $title;
include 'header.php';
echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';
if($act=="res" && isset($sid) && count($_POST)>0)
{
extract($_POST);
if($_SESSION["ekey"]!=$ekey)
{
$_SESSION["message"] = "Session has been expired. Try Again.";
redir("?act=rules&id=".$sid);
}
$ra=0; $wa=0;
foreach($_SESSION["rans"] as $i=>$v)
{
if(!isset($ans[$i]) || empty($ans[$i]))

Developing an Online Examination System | Page | 31


CHAPTER THREE | Analysis and Design

}
else if($ans[$i]==$v)
{
$ra++;
}
else
{
$wa++;
}
}

$marks = $sub["rm"]*$ra-$sub["wm"]*$wa;

$inarr = array("uid"=>$user->id,"sid"=>$sid,"marks"=>$marks,"et"=>(time()-
$_SESSION["time"]),

"time"=>time(),"tq"=>$sub["noq"],"rm"=>$sub["rm"],
"wm"=>$sub["wm"],"ra"=>$ra,"wa"=>$wa
);

$up = $db->insert("results",$inarr);
if($up)
{
unset($_SESSION["ekey"]);
$_SESSION["message"] = "Exam complete. Here is your result.";
redir("results.php?act=view&id=".$db->insert_id);
}
else
{
echo '<pre>Error in Database.<br/>Contact with administrator</pre>';
}

else if($act=="start" && isset($sid))


{

$sql = $db-
>select("questions","",array("sid"=>$sid),"rand()","0,".$sub["noq"]);
echo '

Developing an Online Examination System | Page | 32


CHAPTER THREE | Analysis and Design

<ul class="list-group">
<li class="list-group-item list-group-item-warning">Level Name: <font
color="black">'.$sub["name"].'</font></li>
<li class="list-group-item list-group-item-warning">Total Questions:
<font color="black">'.$sql->num_rows.'</font></li>
<li class="list-group-item list-group-item-warning">Questions to Show
in Test: <font color="black">'.$sub["noq"].'</font></li>
<li class="list-group-item list-group-item-warning">Marks per Right
Answer: <font color="black">'.$sub["rm"].'</font></li>
<li class="list-group-item list-group-item-warning">Marks per Wrong
Answer: <font color="black">'.$sub["wm"].'</font></li>
<li class="list-group-item list-group-item-warning">Time Limit: <font
color="black">'.tf_full($sub["time"]).'</font></li>
</ul>';

if($sql->num_rows<1)
{
echo '<h4>No Question Found. You can not participate. Please go back
and select another level.<h4>';
}
else
{
echo '
<div class="header" id="myHeader">
<div style="margin: 20px">
<button type="button" class="btn btn-warning btn-lg"
id="rm_time_show" style="display:none">'.tf_full($sub["time"]).' Remaining</button>
</div>
</div>';
?>
<script type="text/javascript">
window.onscroll = function() {myFunction()};

var header = document.getElementById("myHeader");


var sticky = header.offsetTop;

function myFunction() {
if (window.pageYOffset >= sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}

Developing an Online Examination System | Page | 33


CHAPTER THREE | Analysis and Design

}
var rm_time = <?=$sub["time"]?>;
var rm_show = document.getElementById("rm_time_show");
rm_show.style.display = "inline";
var dan=false;
if(!dan && rm_time<300)
{
dan=true;
rm_show.classList.remove("btn-warning");
rm_show.classList.add("btn-danger");
}
setInterval(function () {

if(!dan && rm_time<300)


{
dan=true;
rm_show.classList.remove("btn-warning");
rm_show.classList.add("btn-danger");
}

rm_show.innerHTML = ''+tf_full(rm_time)+' Remaining</button>';


rm_time--;

if(rm_time==0)
{
var ques = document.getElementById("ques");
ques.submit();
}
}, 1000);

function tf_full(t)
{
if(t<60)
{
return t +' Sec';
}
if(t<3600)
{
return parseInt(t/60)+' Min '+tf_full(t%60);
}
else
{

Developing an Online Examination System | Page | 34


CHAPTER THREE | Analysis and Design

return parseInt(t/3600)+' Hour '+tf_full(t%3600);


}
}
</script>

<?php
echo '
<form method="post" action="?act=res&sid='.$sid.'" id="ques">
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>Question</th>
<th>Options</th>
</tr>
</thead>
<tbody>';

$i = 0;
while($result = $sql->fetch_assoc())
{
$i++;
$rans[$result["id"]] = $result["ans"];
echo '
<tr>
<td>'.$i.'</td>
<td>'.$result["ques"].'</td>
<td>
<input type="radio" name="ans['.$result["id"].']" value="a"> (a)
'.$result["op_a"].'<br/>
<input type="radio" name="ans['.$result["id"].']" value="b"> (b)
'.$result["op_b"].'<br/>
<input type="radio" name="ans['.$result["id"].']" value="c"> (c)
'.$result["op_c"].'<br/>
<input type="radio" name="ans['.$result["id"].']" value="d"> (d)
'.$result["op_d"].'
</td>
</tr>';

}
$ekey = md5(microtime());
$_SESSION["rans"] = $rans;

Developing an Online Examination System | Page | 35


CHAPTER THREE | Analysis and Design

$_SESSION["ekey"] = $ekey;
$_SESSION["time"] = time();

echo '
<tr>
<td><input type="hidden" name="ekey" value="'.$ekey.'" /></td>
<td><button type="submit" class="btn btn-primary btn-block
btn-lg">Submit</button></td>
</tr>
</tbody>
</table>
</form>';

}
}

else
{

$sql = $db->select("subjects","","");
if($sql->num_rows<1)
{
echo '<h4>No Level Found.<h4>';
}
else
{
echo '
<table class="table table-bordered">
<thead>
<tr>
<th>Level Name</th>
<th>Total Ques.</th>
<th>Marks per RA</th>
<th>Minus Marks per WA</th>
<th>Full Marks</th>
<th>Time Limit</th>
<th>Actions</th>
</tr>
</thead>
<tbody>';

Developing an Online Examination System | Page | 36


CHAPTER THREE | Analysis and Design

$psid = 0;
while($result = $sql->fetch_assoc())
{
$sid = $result['id'];
if($psid==0)
{
$dis = false;
}
else
{
$res = $db->query("SELECT
MAX((marks*100)/(tq*rm)) as percent FROM results WHERE uid=$user->id AND
sid=$psid");
if($res->num_rows<1)
{
$dis = true;
}
else
{
$res = $res->fetch_assoc();
if($res["percent"] < 70)
{
$dis = true;
}
else
{
$dis = false;
}
}
}

echo '
<tr>
<td>'.$result["name"].'</td>
<td>'.$result["noq"].'</td>
<td>'.$result["rm"].'</td>
<td>'.$result["wm"].'</td>
<td>'.($result["noq"]*$result["rm"]).'</td>
<td>'.tf_full($result["time"]).'</td>
<td>';
if($dis)
{

Developing an Online Examination System | Page | 37


CHAPTER THREE | Analysis and Design

echo '<button class="btn btn-sm btn-warning disabled" style="font-size:


15px">Participate</button>';
}
else
{
echo '<a href="?act=rules&sid='.$result["id"].'" class="btn btn-sm btn-
warning" role="button" style="font-size: 15px">Participate</a>';
}

echo '</td>
</tr>';

$psid = $sid;

}
echo '
</tbody>
</table>';
}
}
echo '
</div>
</div>';

include 'footer.php';
?>

(d) exam.sql
-- phpMyAdmin SQL Dump
-- version 4.7.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 29, 2018 at 10:34 AM
-- Server version: 10.1.22-MariaDB
-- PHP Version: 7.1.4

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";


SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";

Developing an Online Examination System | Page | 38


CHAPTER THREE | Analysis and Design

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT


*/;
/*!40101 SET
@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION
*/;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `exam`
--

-- --------------------------------------------------------

--
-- Table structure for table `admin`
--

CREATE TABLE `admin` (


`id` int(10) UNSIGNED NOT NULL,
`username` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
`role` tinyint(4) NOT NULL DEFAULT '0',
`password` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`department` varchar(100) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `admin`
--

INSERT INTO `admin` (`id`, `username`, `role`, `password`, `name`, `department`) VALUES
(1, 'admin', 1,
'$2y$10$EkDD.WJLCEk46Z1pfbOCvuDH51EvS/Fehpt.WjD.FGzpRGKHP4YXW', 'Md.
Mahmudul Hasan', 'CSE');

-- --------------------------------------------------------

--
-- Table structure for table `questions`
--

Developing an Online Examination System | Page | 39


CHAPTER THREE | Analysis and Design

CREATE TABLE `questions` (


`id` int(11) NOT NULL,
`sid` int(11) NOT NULL,
`ques` text COLLATE utf8_unicode_ci NOT NULL,
`op_a` text COLLATE utf8_unicode_ci NOT NULL,
`op_b` text COLLATE utf8_unicode_ci NOT NULL,
`op_c` text COLLATE utf8_unicode_ci NOT NULL,
`op_d` text COLLATE utf8_unicode_ci NOT NULL,
`ans` varchar(1) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `questions`
--

INSERT INTO `questions` (`id`, `sid`, `ques`, `op_a`, `op_b`, `op_c`, `op_d`, `ans`) VALUES
(1, 1, 'Alpha (α) particles are helium (He) nucleus with a charge of ?', 'e', '2e', '3e', '4e', 'b'),
(2, 1, 'When two light nuclei combine to form a heavier nucleus, process is said to be ?', 'nuclear
fission', 'nuclear fusion', 'nuclear power', 'nuclear transmutation', 'b'),
(3, 1, 'Elements which emit natural radioactivity are known as ?', 'radio elements', 'active
elements', 'radioactive elements', 'nuclear elements', 'c'),
(4, 1, 'A circuit which implements AND operation is ?', 'AND gate', 'OR gate', 'NOT gate',
'NOR gate', 'a'),
(5, 1, ' Electric motors works on principle of ?', 'capacitors', 'friction', 'couple', 'torque', 'd'),
(6, 1, ' Gamma (γ) radiation are fast moving', 'electrons', 'protons', 'photons', 'neutrons', 'c'),
(7, 1, ' In air, alpha particles have range of', 'few centimeters', 'several thousand meters', 'several
hundred meters', 'several meters', 'a'),
(8, 1, ' ENuclei with atomic number 1 to 82 are', 'stable', 'unstable', 'moderately stable',
'radioactive', 'a'),
(9, 1, ' Elements whose atomic number is greater than 82 are naturally', 'unstable nuclei', 'stable
nuclei', 'positive nuclei', 'negative nuclei', 'a'),
(10, 1, ' Mass of neutron and proton is', 'equal', 'unequal', 'zero', 'undetermined', 'a'),
(11, 2, 'Metals difficult to oxidize are called', 'weak metals', 'strong metals', 'noble metals', 'none
of above', 'c'),
(12, 2, 'On contact with oxygen, Rubidium forms', 'normal oxide', 'per oxide', 'super oxide',
'none of above', 'c'),
(13, 2, 'Most metallic among following is', 'Na', 'K', 'AI', 'B', 'b'),
(14, 2, 'Free radicals are electrically', 'positively charged', 'negatively charged', 'can be both A
and B', 'neutral', 'd'),
(15, 2, 'Temperature at which solid starts melting is called', 'boiling point', 'freezing point',
'melting point', 'none of above', 'c'),

Developing an Online Examination System | Page | 40


CHAPTER THREE | Analysis and Design

(16, 2, 'Sodium metal is soft due to', 'weak metallic bond', 'strong metallic bond', 'large size',
'small size', 'a'),
(17, 2, 'Bromine is a non-metal in', 'solid state', 'liquid state', 'gaseous state', 'plasma state', 'b'),
(18, 2, ' Non-metals are poor conductors of', 'heat', 'electricity', 'both A and B', 'none of above',
'c'),
(19, 2, 'Loss of hydrogen atoms by an element is called', 'hydrogenation', 'oxidation', 'reduction',
'sublimation', 'b'),
(20, 2, 'Galvanic cells are also named as', 'electrolytic cells', 'battery cells', 'Daniel cells', 'john
cells', 'c'),
(21, 3, 'Plants receive their nutrients mainly from ?', 'atmosphere', 'chlorophyll', 'light', 'soil',
'd'),
(22, 3, 'Bamboo is classified as', 'bush', 'tree', 'grass', 'weed', 'c'),
(23, 3, 'Plants synthesis protein from', 'Starch', 'Sugar', 'Fatty acids', 'Amino acids', 'd'),
(24, 3, 'The richest source of vitamin D is ', 'Cheese', 'Milk', 'Spinach', 'Cod liver oil', 'd'),
(25, 3, 'Which is not a part of blood ?', 'RBC', 'Placenta', 'WBC', 'Plasma', 'b'),
(26, 3, 'Antibiotic penicillin was discovered by ', 'Joseph', 'Alexander', 'Aristotle',
'Theophrastus', 'b'),
(27, 3, 'Food can be more tastier and digestible through ', 'Fermentation', 'Fertilization',
'Oxidation', 'Reduction', 'a'),
(28, 3, 'Fermentation is a ', 'Continuous process', 'Discontinuous process', 'Long process',
'Difficult process', 'b'),
(29, 3, ' Considering bread production, fermentation is caused by ', 'carbolic acid', 'carbon
dioxide', 'methane', 'ethane', 'b'),
(30, 3, 'Watson and crick model of DNA was proposed in ', '1953', '1955', '1944', '1954', 'a');

-- --------------------------------------------------------

--
-- Table structure for table `results`
--

CREATE TABLE `results` (


`id` int(11) NOT NULL,
`uid` int(11) NOT NULL,
`sid` int(11) NOT NULL,
`marks` decimal(10,2) NOT NULL,
`et` int(10) UNSIGNED NOT NULL,
`time` bigint(11) NOT NULL,
`tq` int(11) NOT NULL,
`rm` decimal(5,2) NOT NULL,
`wm` decimal(5,2) NOT NULL,
`ra` int(11) NOT NULL,

Developing an Online Examination System | Page | 41


CHAPTER THREE | Analysis and Design

`wa` int(11) NOT NULL


) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `results`
--

INSERT INTO `results` (`id`, `uid`, `sid`, `marks`, `et`, `time`, `tq`, `rm`, `wm`, `ra`, `wa`)
VALUES
(2, 1, 1, '2.50', 11, 1524976290, 5, '1.00', '0.25', 3, 2);

-- --------------------------------------------------------

--
-- Table structure for table `subjects`
--

CREATE TABLE `subjects` (


`id` int(11) NOT NULL,
`name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`noq` int(10) UNSIGNED NOT NULL,
`rm` decimal(5,2) UNSIGNED NOT NULL,
`wm` decimal(5,2) UNSIGNED NOT NULL,
`time` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `subjects`
--

INSERT INTO `subjects` (`id`, `name`, `noq`, `rm`, `wm`, `time`) VALUES
(1, 'Level 1', 5, '1.00', '0.25', 120),
(2, 'Level 2', 5, '1.00', '0.25', 120),
(3, 'Level 3', 5, '1.00', '0.25', 120);

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

Developing an Online Examination System | Page | 42


CHAPTER THREE | Analysis and Design

CREATE TABLE `users` (


`id` int(11) NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`gender` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`mobile` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`time_created` bigint(20) NOT NULL,
`lasttime` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `name`, `gender`, `email`, `password`, `mobile`, `time_created`,
`lasttime`) VALUES
(1, 'mizan', 'Male', 'mizanur@gmail.com',
'$2y$10$svFW1VrqlFo6zlkiEmZFUONN85spBWx88W1y1wjuwnzmJp.h7u0ry',
'8801788112233', 1499663471, 1521220461);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `admin`
--
ALTER TABLE `admin`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `questions`
--
ALTER TABLE `questions`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `results`
--
ALTER TABLE `results`
ADD PRIMARY KEY (`id`);

Developing an Online Examination System | Page | 43


CHAPTER THREE | Analysis and Design

--
-- Indexes for table `subjects`
--
ALTER TABLE `subjects`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD UNIQUE KEY `id` (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admin`
--
ALTER TABLE `admin`
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `questions`
--
ALTER TABLE `questions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31;
--
-- AUTO_INCREMENT for table `results`
--
ALTER TABLE `results`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `subjects`
--
ALTER TABLE `subjects`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`

Developing an Online Examination System | Page | 44


CHAPTER THREE | Analysis and Design

MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,


AUTO_INCREMENT=3;COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;


/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

(e) header.php
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml xml; charset=utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<title><?=strip_tags($site->title)?></title>
<meta name="robots" content="noindex,nofollow"/>
<?php
if(isset($head) && !empty($head))
{
foreach($head as $meta)
echo $meta;
}
?>

<link rel="icon" href="<?=$site->url?>/favicon.png" type="image/png"/>


<link rel="stylesheet" href="<?=$site->url?>/css/bootstrap.mod.css">
<link rel="stylesheet" href="<?=$site->url?>/css/normalize.css">
<link rel="stylesheet" href="<?=$site->url?>/css/styles.css" type="text/css"/>
<script type="text/javascript" src="<?=$site->url?>/js/main.js"></script>
</head>
<body>
<div class="container" id="maincon" style="padding: auto;">

<div style="background: #323232; height: auto; width: auto;">


<div class="col-xs-12 sideboxHeading" style="height: auto;">
<p style="color: #ffffff;
font-family: Comic sans MS; font-weight: bold; font-size: 23px; text-align: center;"><?=$site-
>name?></a>
</div>
</div>
<div class="col-xs-12 footer-menu" style="min-height: 45px;">

Developing an Online Examination System | Page | 45


CHAPTER THREE | Analysis and Design

<span><a href="<?=$site->url?>">Home</a></span>
<span><a href="<?=$site->url?>/exam.php">Exam</a></span>
<span><a href="<?=$site->url?>/results.php">Results</a></span>
<span><a href="<?=$site->url?>/ranking.php">Ranking</a></span>
<?php if($user->is_user()) { echo '<span><a href="'.$site-
>url.'/logout.php">Logout</a></span>'; } ?>
</div>

(f) index.php
<?php
include 'init.php';
$site->title = "Online Examination";
include "header.php";
if(!$user->is_user())
{
$_SESSION["message"]='You must be logged in or <a href="'.$site-
>url.'/register.php"><b><i>Register</i></b></a> first.';
redir($site->url."/login.php");
exit;
}

echo '
<div class="panel panel-primary">
<div class="panel-heading">Exam Area</div>
<div class="panel-body" style="padding: 2px;">
<div class="list-group">
<a href="exam.php" class="list-group-item list-group-item-danger"> &#187; New
Exam</a>
</div>
</div>
</div>';

$sql = "SELECT r.id,r.sid,s.name,r.time,r.marks,r.tq,r.rm,r.wm,r.ra,r.wa From results as r


INNER JOIN subjects as s ON r.sid=s.id WHERE uid=$user->id ORDER BY id DESC LIMIT
0,10";
$sql = $db->query($sql);

echo '
<div class="panel panel-primary">
<div class="panel-heading">Results Area</div>
<div class="panel-body" style="padding: 2px;">';

Developing an Online Examination System | Page | 46


CHAPTER THREE | Analysis and Design

if($sql->num_rows<100)
{
echo '
<div class="list-group">
<a href="results.php" class="list-group-item list-group-item-danger"> &#187;
Result</a>
</div>';
}
else
{
echo '
<table class="table table-bordered">
<thead>
<tr>
<th>Date</th>
<th>Level</th>
<th>Your Marks</th>
<th>Full Marks</th>
<th>Actions</th>
</tr>
</thead>
<tbody>';
while($result = $sql->fetch_assoc())
{
echo '
<tr>
<td>'.date("d-m-Y H:i:s A",$result["time"]).'</td>
<td><a href="results.php?sid='.$result["sid"].'">'.$result["name"].'</a></td>
<td>'.$result["marks"].'</td>
<td>'.($result["tq"]*$result["rm"]).'</td>
<td><a href="results.php?act=view&id='.$result["id"].'" class="btn btn-sm btn-
info" role="button" style="font-size: 15px">View</a>&nbsp;</td>
</tr>';

}
echo '
<tr>

</tr>';
echo '
</tbody>

Developing an Online Examination System | Page | 47


CHAPTER THREE | Analysis and Design

</table>';
}

echo '
</div>
</div>';
include "footer.php";
?>

(g) result.php

<?php
include 'init.php';
if(!$user->is_user())
{
redir($site->url."/login.php");
exit;
}

if(isset($_GET["act"]))
$act = get("act");
else
$act="";

if(isset($_GET["id"]))
{
$id=get("id");
$sql = $db->select("results","",array("id"=>$id,"uid"=>$user->id));
if($sql->num_rows==1)
{
$res = $sql->fetch_assoc();
}
else
{
echo '<h3>Result Not Found</h3>';
exit;
}
}
if(isset($_GET["sid"]))
{
$sid=get("sid");

Developing an Online Examination System | Page | 48


CHAPTER THREE | Analysis and Design

$sql = $db->select("subjects","",array("id"=>$sid));
if($sql->num_rows==1)
{
$sub = $sql->fetch_assoc();
}
else
{
echo '<h3>Level Not Found</h3>';
exit;
}
}
if($act=="view" && isset($id)) {
$title = "View Result";
}
else if(isset($sid)) {
$title = "View Result of different Level";
}
else {
$title = "Show Results";
}
$site->title = $title;
include 'header.php';

echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';

if($act=="view" && isset($id))


{
$sql = $db->select("results","",array("id"=>$id,"uid"=>$user->id));

if($sql->num_rows<1)
{
echo '<h3>Result Not Found</h3>';
exit;
}

$res = $sql->fetch_assoc();

$sql = $db->select("subjects","",array("id"=>$res["sid"]));
$sub = $sql->fetch_assoc();

Developing an Online Examination System | Page | 49


CHAPTER THREE | Analysis and Design

$sql = $db->select("results","",array("sid"=>$res["sid"]),"marks/(tq*rm)
DESC","0,1");
$hi = $sql->fetch_assoc();

$perc = ($res["marks"]*100)/($res["tq"]*$res["rm"]);
echo '
<ul class="list-group">
<li class="list-group-item list-group-item-warning">Level Name: <font
color="black">'.$sub["name"].'</font></li>
<li class="list-group-item list-group-item-warning">Total Questions:
<font color="black">'.$res["tq"].'</font></li>
<li class="list-group-item list-group-item-warning">Marks per Right
Answer: <font color="black">'.$res["rm"].'</font></li>
<li class="list-group-item list-group-item-warning">Marks per Wrong
Answer: <font color="black">'.$res["wm"].'</font></li>
<li class="list-group-item list-group-item-warning">Full Marks: <font
color="black">'.($res["tq"]*$res["rm"]).'</font></li>
<li class="list-group-item list-group-item-warning">Your Answer:
Right: <font color="black">'.$res["ra"].'</font> / Wrong: <font
color="black">'.$res["wa"].'</font> / No Answer: <font color="black">'.($res["tq"]-
$res["ra"]-$res["wa"]).'</font></li>
<li class="list-group-item list-group-item-warning">Your Marks: <font
color="black">'.$res["marks"].' ('.number_format($perc,2,'.','').'%)</font></li>
<li class="list-group-item list-group-item-warning">Ellapsed Time:
<font color="black">'.tf_full($res["et"]).'</font></li>
</ul>';

if($perc<70)
{
echo '<div class="well">You are not eligible for next level.You have to
get 70% marks to participate next level</div>';
}
else
{
echo '<div class="well">You are eligible for next level.</div>';

Developing an Online Examination System | Page | 50


CHAPTER THREE | Analysis and Design

else
{

//$sql = $db->select("results","",array("uid"=>$user->id));
$sql = "SELECT r.id,r.sid,s.name,r.et,r.time,r.marks,r.tq,r.rm,r.wm,r.ra,r.wa
From results as r INNER JOIN subjects as s ON r.sid=s.id WHERE uid=$user->id";
$sql = $db->query($sql);

if($sql->num_rows<1)
{
echo '<h4>No Result Found.'.$db->error.'<h4>';
}
else
{
echo '
<table class="table table-bordered">
<thead>
<tr>
<th>Date</th>
<th>Level</th>
<th>Your Marks</th>
<th>Time(S)</th>
<th>Full Marks</th>
<th>T.Q.</th>
<th>R.M.</th>
<th>W.M.</th>
<th>R.A.</th>
<th>W.A.</th>
<th>Actions</th>
</tr>
</thead>
<tbody>';
while($result = $sql->fetch_assoc())
{
echo '
<tr>
<td>'.date("d-m-Y H:i:s A",$result["time"]).'</td>
<td>'.$result["name"].'</td>
<td>'.$result["marks"].'</td>
<td>'.tf_short($result["et"]).'</td>

Developing an Online Examination System | Page | 51


CHAPTER THREE | Analysis and Design

<td>'.($result["tq"]*$result["rm"]).'</td>
<td>'.$result["tq"].'</td>
<td>'.$result["rm"].'</td>
<td>'.$result["wm"].'</td>
<td>'.$result["ra"].'</td>
<td>'.$result["wa"].'</td>
<td><a href="?act=view&id='.$result["id"].'" class="btn btn-sm btn-info"
role="button" style="font-size: 15px">View</a>&nbsp;</td>
</tr>';

}
echo '
</tbody>
</table>';
}
}
echo '
</div>
</div>';
include 'footer.php';
?>

(h) ranking.php

<?php
include 'init.php';
if(!$user->is_user())
{
$_SESSION["message"]='You must be logged in or <a href="'.$site-
>url.'/register.php"><b><i>Register</i></b></a> first.';
redir($site->url."/login.php");
exit;
}

$title = "View Ranking";


$site->title = $title;
include 'header.php';

echo '
<div class="panel panel-primary">

Developing an Online Examination System | Page | 52


CHAPTER THREE | Analysis and Design

<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';

$sql = "SELECT * FROM subjects WHERE 1 ORDER BY id ASC LIMIT 0,3";


$sql = $db->query($sql);
if($sql->num_rows<1)
{
echo '<h3>No Subject</h3>';
exit;
}

$tm=0; $sid=0;

while($sub=$sql->fetch_assoc())
{
$tm += $sub["noq"]*$sub["rm"];
$sid = $sub["id"];
}

$q1 = "SELECT DISTINCT uid FROM results WHERE sid=$sid AND


(marks*100)/(tq*rm)>=70";
if($db->query($q1)->num_rows<1)
{
echo 'No Qualified User Found';
exit;
}
$sql = "SELECT r.*,name,email FROM results as r INNER JOIN users as u ON r.uid=u.id
WHERE sid<=$sid AND uid IN ($q1) ORDER BY marks DESC,et ASC";
$sql = $db->query($sql);
$m = array(); $t = array(); $s=array();
while($res=$sql->fetch_assoc())
{
extract($res);
if(!isset($s[$uid][$sid]))
{
if(!isset($m[$uid])) $m[$uid] = 0;
if(!isset($t[$uid])) $t[$uid] = 0;
$m[$uid] += $marks;
$t[$uid] += $et;
$n[$uid] = $name;
$p[$uid] = $email;
$s[$uid][$sid] = true;

Developing an Online Examination System | Page | 53


CHAPTER THREE | Analysis and Design

}
}

foreach($m as $k=>$v)
{
$usr[] =
array("id"=>$k,"name"=>$n[$k],"email"=>$p[$k],"marks"=>$m[$k],"et"=>$t[$k]);
}

usort($usr, "cmp");

echo '
<table class="table table-bordered">
<thead>
<tr>
<th>Rank</th>
<th>User</th>
<th>Email</th>
<th>Total Marks</th>
<th>Marks Obtained</th>
<th>Time(S)</th>
</tr>
</thead>
<tbody>';
$i=1;
foreach($usr as $uid=>$res)
{
echo '
<tr';
if($uid==$user->id)
echo ' class="success"';
echo '>
<td>'.$i.'</td>
<td>'.$res["name"].'</td>
<td>'.$res["email"].'</td>
<td>'.$tm.'</a></td>
<td>'.$res["marks"].'</td>
<td>'.$res["et"].'</td>
</tr>';
$i++;

Developing an Online Examination System | Page | 54


CHAPTER THREE | Analysis and Design

echo '
</tbody>
</table>';

echo '
</div>
</div>';

include 'footer.php';

function cmp($a,$b)
{
if($a["marks"]<$b["marks"])
return 1;
else if($a["marks"]>$b["marks"])
-1;
else
{
if($a["et"]<$b["et"])
return -1;
else if($a["et"]>$b["et"])
return 1;
else
return 0;
}
}
?>

(i) footer.php
<div class="clearfix"></div>
<div align="center"><div class="sideboxHeader">""</div></div>
</div>
</body>
</html>

(j) logout.php
<?php
include "init.php";
if(isset($_SESSION["id"])){
unset($_SESSION["id"]);

Developing an Online Examination System | Page | 55


CHAPTER THREE | Analysis and Design

$_SESSION["message"]="You have been logged out successfully";


redir($site->url."/login.php");
}
else {
redir($site->url."/login.php");
}
?>

(k) style.css

body {
background:#eee;
}
a:hover {
text-decoration: none;
}
h1
{
font-size: 18px;
}
.sticky {
position: fixed;
top: 0;
width: 100%
}
img
{
border: none;
margin: 0.5px;
vertical-align: middle;
}
blockquote
{
border-left:2px solid #ddd;
margin:0 0 0 5px;
padding-left:5px;
}
ul, ol
{
margin-left: 40px;
}

Developing an Online Examination System | Page | 56


CHAPTER THREE | Analysis and Design

p, li
{margin: 0 0 10px;}
h1, h2, h3, p
{
margin: 0 0 1px 0;
padding: 0;
}
ul, ol
{
margin-top: 0;
margin-bottom: 5px;
margin-left:10px;
padding: 0;
}
hr
{
color: #999999;
height: 1px;
}

#maincon {
font-family: "Trebuchet MS",Arial,Helvetica,SolaimanLipi,Siyam Rupali,Droid
Sans,Segoe UI,Open Sans,Tahoma,Arialsans-serif;
margin:0 auto;background:#fff;padding:0px;color:#444;font-size:15px;overflow-
wrap:break-word;
}
.sideboxHeading {
text-align:center;
padding:6px;
background-color:#029E98;
font-weight:bold;
font-size:17px;
color:#FFF;
text-shadow:0 0 5px #6E6D6D,0 0 15px #FFF;
}

.sideboxHeader {
text-align:center;
padding:6px;
background-color:white;
font-weight:bold;

Developing an Online Examination System | Page | 57


CHAPTER THREE | Analysis and Design

font-size:17px;
color:white;
text-shadow:0 0 5px #6E6D6D,0 0 15px #FFF;
}
.title {
text-align:center;
margin: 1px 0;
padding:6px;
background-color:#029E98;
font-weight:bold;
font-size:17px;
color:#FFF;
text-shadow:0 0 5px #6E6D6D,0 0 15px #FFF;
}
.footer{background: #222; color: blue;padding-left: 4px; padding: 10px; border-top: 2px solid
#00bfff; text-align: center;}

.footer-menu{background: blue; color: #fff;padding-left: 4px; padding: 10px; text-align:


center;}

.footer-menu span a{background: SlateBlue; color: #fff; padding: 6px; padding-bottom: 6px;
margin: 1px;}

.footer-menu span:hover a{
background: #00bfff; color: #fff; transition: 1s; border-radius: 20px 20px 20px;text-
decoration:none;
}

.lines{background:#fff;padding:5px;color:#444;border-bottom:1px solid #eee;}


.lines a{color:blue;}.lines:before{content:"» "}
.lines b{color:#0563a4;}
/* including for compatibility */
.page
{
background-color: #9E9E9E;
color: #FFFFFF!important;
display: inline-block;
padding: 4px 8px;
margin: 2px;
text-decoration: none!important;
cursor: pointer;
border-radius: 2px;

Developing an Online Examination System | Page | 58


CHAPTER THREE | Analysis and Design

}
.link
{
background: url(/images/arrow.png) no-repeat right center;
background-color: #FFFFFF;
border: 1px solid #DBDBDB;
border-radius: 4px;
margin: 0px;
}
.link:hover
{
background: url(/images/arrow.png) no-repeat right center;
background-color: #DBDBDB;
border:1px solid #DBDBDB;
border-radius:4px;
margin:0px;
}
.link a
{
color: #000000;
display: block;
padding-left: 3px;
padding-top: 8px;
padding-bottom: 8px;
text-decoration: none;
}
.alignleft
{
float: left;
margin-right: 1em;
margin-bottom: 1em;
}
.alignright
{
float: right;
margin-left: 1em;
margin-bottom: 1em;
}
.aligncenter
{
display: block;
margin-left: auto;

Developing an Online Examination System | Page | 59


CHAPTER THREE | Analysis and Design

margin-right: auto;
}

.small
{
font-size: 10px;
line-height: 2;
}
.hide
{
display: none;
}
.clear
{
clear: both;
float: none;
}
.table-title,.content
{
color: #777777;
font-size: 1em;
line-height: 1.5;
margin: 10px;
text-shadow: 1px 1px 2px #FFFFFF;
}
.table-title
{
margin-top:20px;
}
#groupp
{
background-color: #FFFFFF;
border-left: 1px solid #CCCCCC;
border-right: 1px solid #CCCCCC;
overflow: hidden;
margin: 1px;
padding: 2px;
-webkit-border-top-left-radius: 0.3em;
-webkit-border-top-right-radius: 0.3em;
-webkit-border-bottom-left-radius: 0.3em;
-webkit-border-bottom-right-radius: 0.3em;
-moz-border-radius-top-left: 0.3em;

Developing an Online Examination System | Page | 60


CHAPTER THREE | Analysis and Design

-moz-border-radius-top-right: 0.3em;
-moz-border-radius-bottom-left: 0.3em;
-moz-border-radius-bottom-right: 0.3em;
border-top-left-radius: 0.3em;
border-top-right-radius: 0.3em;
border-bottom-left-radius: 0.3em;
border-bottom-right-radius: 0.3em;
}
.group
{
background:#f8f8f8;
border:1px solid #e7e7e7;
padding:9px 15px;
margin-bottom:10px;}

.title-divider
{
color: #999999;
font-size: 10px;
font-weight: normal;
margin:0 -15px 10px -15px;
}
.title-divider span
{
background-color: #FFFFFF;
margin:0 0 0 10px;
padding: 0 5px;
}
.notification
{
background-color: #FFFDC2;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
margin: 10px 0;
padding: 10px;
}
#navigation-top
{
display: none;
}
.pagination

Developing an Online Examination System | Page | 61


CHAPTER THREE | Analysis and Design

{
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
border-width: 0 1px 1px;
clear: both;
margin: 0 10px;
overflow: hidden;
}
.pagination span
{
display: none;
}
.pagination span.next,.pagination span.prev
{
display: block;
width: 50%;
}
.pagination span.prev
{
float: right;
}
.pagination span.next
{
float: left;
}

.pagination .next a,.pagination .prev a


{
border: 5px solid #FFFFFF;
display: block;
height: 1.5em;
overflow: hidden;
text-decoration: none;
}
.pagination .next a,ul.table.disclosure .pagination .next a
{
border-right: 1px solid #DDDDDD;
border-left: 0;
padding-left: 35px;
}
.pagination .prev a,ul.table.disclosure .pagination .prev a
{

Developing an Online Examination System | Page | 62


CHAPTER THREE | Analysis and Design

border-left:1px solid #FFFFFF;


border-right:0;
padding-right:35px;
text-align:right;
}
#next-prev-bottom,#navigation-bottom
{
display:none;
}
.subheader
{
background:#f8f8f8;
border:1px solid #e7e7e7;
padding:9px 15px;
margin-bottom:10px}
.description {
padding-left : 5px;
padding-right : 5px;
}
.lastest {
padding-left : 15px;
padding-top : 10px;
}
.dllink {
background-color:#F6F6F5;
border: 1px solid #dbdbdb;
border-radius:4px;margin:2px;
font-family:'Play', sans-serif;
padding: 5px;
}
.dllink:hover{
background-color:#F1F1F1;
border:1px solid #dbdbdb;
border-radius:4px;
margin:2px;
box-shadow:0 0 4px #ADADAD,0 0 12px #ADADAD;
font-family:'Play', sans-serif;
}
.dllink a:hover {
text-decoration:none; padding: 2px; background: #999; border-radius: 2px;
font-family:'Play', sans-serif;
}

Developing an Online Examination System | Page | 63


CHAPTER THREE | Analysis and Design

.didl { color: #ff0000; padding: 2px 3px; margin:0 0 2px; display:inline-block; border-
radius:10px; border: 2px solid #0099ff; float:right;}
.didl a { color: black; padding: 2px 3px; margin:0 0 2px; display:inline-block; border-
radius:10px; font-weight:bold; }
.didl1 { color: #ff0000; padding: 2px 3px; margin:0 0 2px; display:inline-block; border-
radius:10px; border: 2px solid #0099ff; float:right;}
.didl1 a { color: black; padding: 2px 3px; margin:0 0 2px; display:inline-block; border-
radius:10px; font-weight:bold; }
.didl1 span { color: black; padding: 2px 3px; margin:0 0 2px; display:inline-block; border-
radius:10px; font-weight:bold; }

#loader-icon {
text-align:center;margin: 20px;background: url(../images/LoaderIcon.gif) no-repeat center;
}
#ajaxloader {
text-align:center;
position: relative;
margin: 30px;
background: #ffaabb;
padding: 20px;
}

(l) main.js
function confirmation(text, url)
{
var chk = confirm(text);
if(chk)
{
window.location.href = url;
}
}

Developing an Online Examination System | Page | 64


CHAPTER THREE | Analysis and Design

3.13.2 Admin Panel Code

(a) login.php

<?php
$lp=1;
include "init.php";
if($admin->is_admin()){
redir($site->aurl);
exit;
}
$site->title = "Log In to System";
include 'header.php';
echo '
<div class="panel panel-primary">
<div class="panel-heading">Log In</div>
<div class="panel-body" style="padding: 5px;">';

if( issetMulti($_POST,array("username","password")) )
{
$user = post("username");
$pass = post("password");
$errors=array();
if(empty($user) OR strlen($user)<1) $errors[] = "Username is empty";
if(empty($pass) OR strlen($pass)<1) $errors[] = "Password is empty";
if(!$admin->login($user,$pass)) $errors[] = "Wrong Username or Password";
if(empty($errors))
{
$id = $admin->gdata("id",array("username"=>$user));
$_SESSION["adminid"]=$id;
redir($site->aurl);
}
else {
showErrors($errors);
}
}

$form->show("post","",
array(
array("multiText",
array("username","Username")
),

Developing an Online Examination System | Page | 65


CHAPTER THREE | Analysis and Design

array("multiPass",
array("password","Password")
)
)
);
echo '
</div>
</div';

include 'footer.php';
?>

(b) header.php
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml xml; charset=utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<title><?=strip_tags($site->title)?></title>
<meta name="robots" content="noindex,nofollow"/>
<?php
if(isset($head) && !empty($head))
{
foreach($head as $meta)
echo $meta;
}
?>
<link rel="icon" href="<?=$site->url?>/favicon.png" type="image/png"/>
<link rel="stylesheet" href="<?=$site->url?>/css/bootstrap.mod.css">
<link rel="stylesheet" href="<?=$site->url?>/css/normalize.css">
<link rel="stylesheet" href="<?=$site->url?>/css/styles.css" type="text/css"/>
<script type="text/javascript" src="<?=$site->url?>/js/main.js"></script>
</head>
<body>
<div class="container" id="maincon" style="padding: auto;">

<div style="background: #323232; height: auto; width: auto;">


<div class="col-xs-12 sideboxHeading" style="height: auto;">
<p style="color: #ffffff;
font-family: Comic sans MS; font-weight: bold; font-size: 23px; text-align: center;"><?=$site-
>name?></a>
</div>

Developing an Online Examination System | Page | 66


CHAPTER THREE | Analysis and Design

</div>
<div class="col-xs-12 footer-menu" style="min-height: 45px;">
<span><a href="<?=$site->aurl?>">Home</a></span>
<span><a href="<?=$site->aurl?>/users.php">Users</a></span>
<span><a href="<?=$site->aurl?>/subjects.php">Levels</a></span>
<span><a href="<?=$site->aurl?>/questions.php">Questions</a></span>
<span><a href="<?=$site->aurl?>/results.php">Results</a></span>
<span><a href="<?=$site->aurl?>/ranking.php">Ranking</a></span>
<?php if($admin->is_admin()) { echo '<span><a href="'.$site-
>aurl.'/logout.php">Logout</a></span>'; } ?>
</div>
<div class="clearfix"></div>
<?php
if(isset($_SESSION["message"]))
{
echo '<pre><center>'.$_SESSION["message"].'</center></pre>';
unset($_SESSION["message"]);
}
else
{
//echo '<br/>';
}
?>

(c) index.php

<?php
include 'init.php';
$site->title = $site->name.' :: Admin Area'; //Edit Homepage Title
include 'header.php';
echo '
<div class="panel panel-primary">
<div class="panel-heading">Admin Area</div>
<div class="panel-body" style="padding: 2px;"><div class="list-group">
<a href="users.php" class="list-group-item list-group-item-danger"> &#187;
Manage Users</a>
<a href="subjects.php" class="list-group-item list-group-item-info"> &#187;
Manage Levels</a>
<a href="questions.php" class="list-group-item list-group-item-danger">
&#187; Manage Questions</a>

Developing an Online Examination System | Page | 67


CHAPTER THREE | Analysis and Design

<a href="results.php" class="list-group-item list-group-item-info"> &#187;


View Results</a>
<a href="ranking.php" class="list-group-item list-group-item-info"> &#187;
View Ranking</a>
</div></div>
</div>';
include 'footer.php';
?>

(d) subjects.php

<?php
include 'init.php';
if(isset($_GET["act"]))
$act = get("act");
else
$act="";
if(isset($_GET["id"]))
{
$id=get("id");
$sql = $db->select("subjects","",array("id"=>$id));
if($sql->num_rows==1)
{
$sub = $sql->fetch_assoc();
}
else
{
echo '<h3>Level Not Found</h3>';
exit;
}
}
if($act=="add") {
$title = "Add a new Level";
}
else if($act=="delete" && isset($id))
{
$error = array();
if(empty($error))
{
$del = $db->delete("subjects",array("id"=>$id));
if($del)
{

Developing an Online Examination System | Page | 68


CHAPTER THREE | Analysis and Design

$_SESSION["message"] = $sub["name"]." has been Deleted


Successfully.";
}
else
{
$_SESSION["message"] = "Error in Database. Can not delete course.
".$db->error;
}
redir("?");
}
else
{
echo 'Level <i>'.$sub["name"].'</i> can not be deleted. Because-<br/>';
showErrors($error);
}

exit;
}
else if($act=="edit" && isset($id)) {
$title = "Edit ".$sub["name"];
}
else if($act=="view" && isset($id)) {
$title = "Showing ".$sub["name"];
}
else {
$title = "Manage Level";
}
$site->title = $title;
include 'header.php';
echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';

if($act=="add")
{
if(count($_POST)>0)
{
extract($_POST);
$error = array();
if(empty($name)) $error[] = "Level Name can not be empty";
if(empty($noq)) $error[] = "No of Questions can not be empty";

Developing an Online Examination System | Page | 69


CHAPTER THREE | Analysis and Design

if(empty($rm)) $error[] = "Marks per Right Answer can not be empty";


if(empty($wm)) $error[] = "Marks per Wrong Answer can not be
empty";
if(empty($time) || !is_numeric($time)) $error[] = "Time can not be
empty";

if(empty($error))
{
$up = $db
>insert("subjects",array("name"=>$name,"noq"=>$noq,"rm"=>$rm,"wm"=>$wm,"time"=>$
time));
if($up)
{
$_SESSION["message"] = "<i>".$name."</i> has been
added Successfully.";
}
else
{
$_SESSION["message"] = "Error in Database. Can not
add Level. ".$db->error;
}
redir("?");
}
else
{
showErrors($error);
}
}

$form->show("post","",
array(
array("multiText",
array("name","Subject Name"),
array("noq","Number of Questions to Show in Test"),
array("rm","Marks per Right Answers"),
array("wm","Marks per Wrong Answers"),
array("time","Time Limit (in seconds)")
)
)
);
}
else if($act=="edit" && isset($id))

Developing an Online Examination System | Page | 70


CHAPTER THREE | Analysis and Design

{
if(count($_POST)>0)
{
extract($_POST);
$error = array();
if(empty($name)) $error[] = "Level Name can not be empty";
if(empty($noq)) $error[] = "No of Questions can not be empty";
if(empty($rm)) $error[] = "Marks per Right Answer can not be empty";
if(empty($wm)) $error[] = "Marks per Wrong Answer can not be
empty";
if(empty($time) || !is_numeric($time)) $error[] = "Time can not be
empty";

if(empty($error))
{
$up = $db-
>update("subjects",array("name"=>$name,"noq"=>$noq,"rm"=>$rm,"wm"=>$wm,"time"=>
$time),array("id"=>$id));
if($up)
{
$_SESSION["message"] = "<i>".$name."</i> has been
edited Successfully.";
}
else
{
$_SESSION["message"] = "Error in Database. Can not
edit Level. ".$db->error;
}
redir("?");
}
else
{
showErrors($error);
}
}

$form->show("post","",
array(
array("multiText",
array("name","Subject Name",$sub["name"]),
array("noq","Number of Questions to Show in
Test",$sub["noq"]),

Developing an Online Examination System | Page | 71


CHAPTER THREE | Analysis and Design

array("rm","Marks per Right Answer",$sub["rm"]),


array("wm","Marks per Wrong Answer",$sub["wm"]),
array("time","Time Limit (in seconds)",$sub["time"])
)
)
);
}

else if($act=="view" && isset($id))


{
$sql = $db->select("questions","",array("sid"=>$id),"id DESC");
echo '
<ul class="list-group">
<li class="list-group-item list-group-item-warning">Level Name: <font
color="black">'.$sub["name"].'</font></li>
<li class="list-group-item list-group-item-warning">Total Questions:
<font color="black">'.$sql->num_rows.'</font></li>
<li class="list-group-item list-group-item-warning">Questions to Show
in Test: <font color="black">'.$sub["noq"].'</font></li>
<li class="list-group-item list-group-item-warning">Marks per Right
Answer: <font color="black">'.$sub["rm"].'</font></li>
<li class="list-group-item list-group-item-warning">Marks per Wrong
Answer: <font color="black">'.$sub["wm"].'</font></li>
</ul>';
echo '
<div class="btn-group btn-group-justified">
<a href="questions.php?act=add&sid='.$id.'" class="btn btn-primary">Add
New Question</a>
<a href="?act=edit&id='.$id.'" class="btn btn-warning">Edit Level</a>
<div class="btn-group">
<button type="button" onclick="confirmation(\'Are You Sure Want to
Delete?\',\'?act=delete&id='.$id.'\')" class="btn btn-danger">Delete Level</button>
</div>
</div>
<br/>';
if($sql->num_rows<1)
{
echo '<h4>No Question Found. Please <a
href="questions.php?act=add&sid='.$id.'">add a Question</a> first.<h4>';
}
else
{

Developing an Online Examination System | Page | 72


CHAPTER THREE | Analysis and Design

echo '
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>Question</th>
<th>Options</th>
<th>Right Answer</th>
<th>Actions</th>
</tr>
</thead>
<tbody>';

$i = 0;
while($result = $sql->fetch_assoc())
{
$i++;
echo '
<tr>
<td>'.$i.'</td>
<td>'.$result["ques"].'</td>
<td>(a) '.$result["op_a"].'<br/>(b) '.$result["op_b"].'<br/>(c)
'.$result["op_c"].'<br/>(d) '.$result["op_d"].'</td>
<td>('.$result["ans"].') '.$result["op_".$result["ans"]].'</td>
<td><a href="questions.php?act=edit&sid='.$id.'&id='.$result["id"].'"
class="btn btn-sm btn-warning" role="button" style= "font-size: 15px">Edit</a><button
type="button" onclick="confirmation(\'Are You Sure Want to
Delete?\',\'questions.php?act=delete&sid='.$id.'&id='.$result["id"].'\')" class="btn btn-sm btn-
danger" style= "font-size: 15px">Delete</button></td>
</tr>';}
echo '
</tbody>
</table>';
}}
else
{
$sql = $db->select("subjects","","");
if($sql->num_rows<1)
{
echo '<h4>No Level Found. Please <a href="?act=add">add a
Level</a> first.<h4>';
}

Developing an Online Examination System | Page | 73


CHAPTER THREE | Analysis and Design

else
{echo '
<table class="table table-bordered">
<thead>
<tr>
<th>Level Name</th>
<th>Total Ques.</th>
<th>Ques. to Show</th>
<th>Marks /RA</th>
<th>Minus Marks /WA</th>
<th>Time(S)</th>
<th>Actions</th>
</tr>
</thead>
<tbody>';
while($result = $sql->fetch_assoc())
{
$s = $db->select("questions","id",array("sid"=>$result["id"]));
echo '
<tr>
<td>'.$result["name"].'</td>
<td>'.$s->num_rows.'</td>
<td>'.$result["noq"].'</td>
<td>'.$result["rm"].'</td>
<td>'.$result["wm"].'</td>
<td>'.tf_short($result["time"]).'</td>
<td><a href="?act=view&id='.$result["id"].'" class="btn btn-sm btn-info"
role="button" style=" font-size:15px">View</a><a href="?act=edit&id='.$result["id"].'"
class="btn btn-sm btn-warning" role="button" style=" font-size:15px">Edit</a><button
type="button" onclick="confirmation(\'Are You Sure Want to
Delete?\',\'?act=delete&id='.$result["id"].'\')" class="btn btn-sm btn-danger" style=" font-
size:15px">Delete</button></td>
</tr>';
}
echo '
</tbody>
</table>';
}
}
echo '
</div>
</div>';

Developing an Online Examination System | Page | 74


CHAPTER THREE | Analysis and Design

include 'footer.php';
?>

(e) question.php

<?php
include 'init.php';
if(isset($_GET["act"]))
$act = get("act");
else
$act="";
if(isset($_GET["id"]))
{
$id=get("id");
$sql = $db->select("questions","",array("id"=>$id));
if($sql->num_rows==1)
{
$ques = $sql->fetch_assoc();
}
else
{
echo '<h3>Question Not Found</h3>';
exit;
}
}
if(isset($_GET["sid"]))
{
$sid=get("sid");
$sql = $db->select("subjects","",array("id"=>$sid));
if($sql->num_rows==1)
{
$sub = $sql->fetch_assoc();
}
else
{
if($act=="delete" && isset($id))
{

Developing an Online Examination System | Page | 75


CHAPTER THREE | Analysis and Design

$error = array();

if(empty($error))
{
$del = $db->delete("questions",array("id"=>$id));
if($del)
{
$_SESSION["message"] = " Question has been Deleted
Successfully.";
}
else
{
$_SESSION["message"] = "Error in Database. Can not delete
course. ".$db->error;
}
redir("?");
}
else
{
echo 'Level<i>'.$sub["name"].'</i> can not be deleted. Because-<br/>';
showErrors($error);
}

exit;
}
}
}
if($act=="add" && isset($sid))
{
$title = "Add a new Question in ".$sub["name"];
}
else if($act=="delete" && isset($id))
{

$error = array();

if(empty($error))
{
$del = $db->delete("questions",array("id"=>$id));
if($del)
{

Developing an Online Examination System | Page | 76


CHAPTER THREE | Analysis and Design

$_SESSION["message"] = $ques["ques"]." has been Deleted


Successfully.";
}
else
{
$_SESSION["message"] = "Error in Database. Can not delete
course. ".$db->error;
}
redir("subjects.php?act=view&id=".$sid);
}
else
{
echo 'Question <i>'.$ques["ques"].'</i> can not be deleted. Because-
<br/>';
showErrors($error);
}
exit;
}
else if($act=="edit" && isset($id)) {
$title = "Edit ".$ques["ques"];
}
else {
$title = "Manage Questions";
}
$site->title = $title;
include 'header.php';

echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';

if($act=="add" && isset($sid))


{

if(count($_POST)>0)
{
extract($_POST);
$error = array();
if(empty($ques)) $error[] = "Question can not be empty";
if(empty($op_a)) $error[] = "Option A can not be empty";
if(empty($op_b)) $error[] = "Option B can not be empty";

Developing an Online Examination System | Page | 77


CHAPTER THREE | Analysis and Design

if(empty($op_c)) $error[] = "Option C can not be empty";


if(empty($op_d)) $error[] = "Option D can not be empty";
if(empty($ans)) $error[] = "Right Answer can not be empty";

//if($db->select("questions","id",array("sid"=>$sid,"ques"=>$ques))-
>num_rows>0)
//$error[] = "Question has been already added before";

if(empty($error))
{
$up = $db-
>insert("questions",array("sid"=>$sid,"ques"=>$ques,"op_a"=>$op_a,"op_b"=>$op_b,"op_c
"=>$op_c,"op_d"=>$op_d,"ans"=>$ans));
if($up)
{
$_SESSION["message"] = "<i>".$ques."</i> has been
added Successfully.";
}
else
{
$_SESSION["message"] = "Error in Database. Can not
add Question. ".$db->error;
}
redir("subjects.php?act=view&id=".$sid);
}
else
{
showErrors($error);
}
}

$form->show("post","",
array(
array("multiText",
array("ques","Question"),
array("op_a","Option A"),
array("op_b","Option B"),
array("op_c","Option C"),
array("op_d","Option D")
),
array("multiSelect",

Developing an Online Examination System | Page | 78


CHAPTER THREE | Analysis and Design

array("ans","Right Answer",false,array("Option
A","Option B","Option C","Option D"),array("a","b","c","d"))
)
)
);
}
else if($act=="edit" && isset($id))
{

if(count($_POST)>0)
{
extract($_POST);
$error = array();
if(empty($ques)) $error[] = "Question can not be empty";
if(empty($op_a)) $error[] = "Option A can not be empty";
if(empty($op_b)) $error[] = "Option B can not be empty";
if(empty($op_c)) $error[] = "Option C can not be empty";
if(empty($op_d)) $error[] = "Option D can not be empty";
if(empty($ans)) $error[] = "Right Answer can not be empty";

if(empty($error))
{
$up = $db-
>update("questions",array("sid"=>$sid,"ques"=>$ques,"op_a"=>$op_a,"op_b"=>$op_b,"op_
c"=>$op_c,"op_d"=>$op_d,"ans"=>$ans),array("id"=>$id));
if($up)
{
$_SESSION["message"] = "<i>".$ques."</i> has been
edited Successfully.";
}
else
{
$_SESSION["message"] = "Error in Database. Can not
edit Question. ".$db->error;
}
redir("subjects.php?act=view&id=".$sid);
}
else
{
showErrors($error);
}
}

Developing an Online Examination System | Page | 79


CHAPTER THREE | Analysis and Design

$form->show("post","",
array(
array("multiText",
array("ques","Question",$ques["ques"]),
array("op_a","Option A",$ques["op_a"]),
array("op_b","Option B",$ques["op_b"]),
array("op_c","Option C",$ques["op_c"]),
array("op_d","Option D",$ques["op_d"])
),
array("multiSelect",
array("ans","Right Answer",false,array("Option
A","Option B","Option C","Option D"),array("a","b","c","d"),$ques["ans"])
)
)
);
}

else
{

$sql = $db->select("questions","","");
if($sql->num_rows<1)
{
echo '<h4>No Question Found.<h4>';
}
else
{
echo '
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>Question</th>
<th>Options</th>
<th>Right Answer</th>
<th>Actions</th>
</tr>
</thead>
<tbody>';

$i=0;

Developing an Online Examination System | Page | 80


CHAPTER THREE | Analysis and Design

while($result = $sql->fetch_assoc())
{
$i++;
echo '
<tr>
<td>'.$i.'</td>
<td>'.$result["ques"].'</td>
<td>(a) '.$result["op_a"].'<br/>(b) '.$result["op_b"].'<br/>(c)
'.$result["op_c"].'<br/>(d) '.$result["op_d"].'</td>
<td>('.$result["ans"].') '.$result["op_".$result["ans"]].'</td>
<td><a
href="questions.php?act=edit&sid='.$result["sid"].'&id='.$result["id"].'" class="btn btn-sm
btn-warning" role="button" style= "font-size: 15px">Edit</a><button type="button"
onclick="confirmation(\'Are You Sure Want to
Delete?\',\'questions.php?act=delete&sid='.$result["sid"].'&id='.$result["id"].'\')" class="btn
btn-sm btn-danger" style= "font-size: 15px">Delete</button></td>
</tr>';

}
echo '
</tbody>
</table>';
}
}
echo '
</div>
</div>';

include 'footer.php';
?>

(f) users.php

<?php
include 'init.php';
if(isset($_GET["act"]))
$act = get("act");
else
$act="";

if(isset($_GET["id"]))

Developing an Online Examination System | Page | 81


CHAPTER THREE | Analysis and Design

{
$id=get("id");
$sql = $db->select("users","",array("id"=>$id));
if($sql->num_rows==1)
{
$usr = $sql->fetch_assoc();
}
else
{
echo '<h3>User Not Found</h3>';
exit;
}
}
if($act=="delete" && isset($id))
{

$error = array();

if(empty($error))
{
$del = $db->delete("users",array("id"=>$id));
if($del)
{
$_SESSION["message"] = $usr["name"]." has been Deleted
Successfully.";
}
else
{
$_SESSION["message"] = "Error in Database. Can not delete
user. ".$db->error;
}
redir("?");
}
else
{
echo 'User <i>'.$usr["name"].'</i> can not be deleted. Because-<br/>';
showErrors($error);
}

exit;
}
else if($act=="edit" && isset($id)) {

Developing an Online Examination System | Page | 82


CHAPTER THREE | Analysis and Design

$title = "Edit ".$usr["name"];


}
else if($act=="view" && isset($id)) {
$title = "View <i>".$usr["name"]."</i>";
}
else {
$title = "Manage Users";
}
$site->title = $title;
include 'header.php';

echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';

if($act=="edit" && isset($id))


{

if(count($_POST)>0)
{
extract($_POST);
$error =array();
if(empty($name)) $error[] = "Name can not be empty";
if(empty($gender)) $error[] = "Gender can not be empty";
if(empty($email)) $error[] = "Email can not be empty";
if(empty($mobile)) $error[] = "Mobile Number can not be empty";

if(empty($error))
{
$colarr =
array("name"=>$name,"email"=>$email,"mobile"=>$mobile,"gender"=>$gender);
if(!empty($password))
{
$colarr["password"] =
password_hash($password,PASSWORD_DEFAULT);
}
$up = $db->update("users",$colarr,array("id"=>$id));
if($up)
{
$_SESSION["message"] = "<i>".$name."</i> has been
edited Successfully.";

Developing an Online Examination System | Page | 83


CHAPTER THREE | Analysis and Design

}
else
{
$_SESSION["message"] = "Error in Database. Can not
edit user. ".$db->error;
}
redir("?act=edit&id=".$id);
}
else
{
showErrors($error);
}
}

$form->show("post","",
array(
array("multiText",
array("name","Full Name",$usr["name"]),
array("email","Email",$usr["email"]),
array("mobile","Mobile Number",$usr["mobile"])
),
array("multiSelect",

array("gender","Gender",false,array("Male","Female"),"",$usr["gender"])
),
array("multiText",
array("password","Password (Keep it blank if you don't
want to change)")
)
)
);
}

else
{

$sql = $db->select("users","","");

if($sql->num_rows<1)
{
echo '<h4>No User Found.<h4>';

Developing an Online Examination System | Page | 84


CHAPTER THREE | Analysis and Design

}
else
{
echo '
<table class="table table-bordered">
<thead>
<tr>
<th>Email</th>
<th>Name</th>
<th>Gender</th>
<th>Mobile</th>
<th>Last Login</th>
<th>Delete</th>
</tr>
</thead>
<tbody>';
while($result = $sql->fetch_assoc())
{
echo '
<tr>
<td>'.$result["email"].'</td>
<td>'.$result["name"].'</td>
<td>'.$result["gender"].'</td>
<td>'.$result["mobile"].'</td>
<td>'.date("F j, Y H:i:s A",$result["lasttime"]).'</td>
<td><button type="button" onclick="confirmation(\'Are You Sure Want
to Delete?\',\'?act=delete&id='.$result["id"].'\')" class="btn btn-sm btn-danger" style= "font-
size: 15px">Delete</button></td>
</tr>';

}
echo '
</tbody>
</table>';
}
}
echo '
</div>
</div>';
include 'footer.php';
?>

Developing an Online Examination System | Page | 85


CHAPTER THREE | Analysis and Design

(g) results.php

<?php
include 'init.php';
if(isset($_GET["act"]))
$act = get("act");
else
$act="";

if(isset($_GET["id"]))
{
$id=get("id");
$sql = $db->select("results","",array("id"=>$id));
if($sql->num_rows==1)
{
$res = $sql->fetch_assoc();
}
else
{
echo '<h3>Result Not Found</h3>';
exit;
}
}

if($act=="delete" && isset($id))


{
$error = array();
if(empty($error))
{
$del = $db->delete("results",array("id"=>$id));
if($del)
{
$_SESSION["message"] = " Result has been Deleted
Successfully.";
}
else
{
$_SESSION["message"] = "Error in Database. Can not delete
course. ".$db->error;

Developing an Online Examination System | Page | 86


CHAPTER THREE | Analysis and Design

}
redir("?");
}
else
{
echo 'Level <i>'.$sub["name"].'</i> can not be deleted. Because-<br/>';
showErrors($error);
}

exit;
}

if(isset($_GET["sid"]))
{
$sid=get("sid");
$sql = $db->select("subjects","",array("id"=>$sid));
if($sql->num_rows==1)
{
$sub = $sql->fetch_assoc();
}
else
{
echo '<h3>Level Not Found</h3>';
exit;
}
}
if($act=="view" && isset($id)) {
$title = "View Result";
}
else if(isset($sid)) {
$title = "View Results of ".$sub["name"];
}
else {
$title = "View Results";
}
$site->title = $title;
include 'header.php';

echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';

Developing an Online Examination System | Page | 87


CHAPTER THREE | Analysis and Design

if($act=="view" && isset($id))


{
$sql = $db->select("results","",array("id"=>$id));

if($sql->num_rows<1)
{
echo '<h3>Result Not Found</h3>';
exit;
}

$res = $sql->fetch_assoc();

$sql = $db->select("subjects","",array("id"=>$res["sid"]));
$sub = $sql->fetch_assoc();

$sql = $db->select("users","",array("id"=>$res["uid"]));
$usr = $sql->fetch_assoc();

$sql = $db->select("results","",array("sid"=>$res["sid"]),"marks/(tq*rm)
DESC","0,1");
$hi = $sql->fetch_assoc();

echo '
<ul class="list-group">
<li class="list-group-item list-group-item-warning">User Name: <a
href="users.php?act=view&id='.$res["uid"].'">'.$usr["name"].'</a></li>
<li class="list-group-item list-group-item-warning">Level Name: <a
href="subjects.php?act=view&id='.$res["sid"].'">'.$sub["name"].'</a></li>
<li class="list-group-item list-group-item-warning">Total Questions:
<font color="black">'.$res["tq"].'</font></li>
<li class="list-group-item list-group-item-warning">Marks per Right
Answer: <font color="black">'.$res["rm"].'</font></li>
<li class="list-group-item list-group-item-warning">Marks per Wrong
Answer: <font color="black">'.$res["wm"].'</font></li>
<li class="list-group-item list-group-item-warning">Full Marks: <font
color="black">'.($res["tq"]*$res["rm"]).'</font></li>
<li class="list-group-item list-group-item-warning">Your Answer:
Right: <font color="black">'.$res["ra"].'</font> / Wrong: <font
color="black">'.$res["wa"].'</font> / No Answer: <font color="black">'.($res["tq"]-
$res["ra"]-$res["wa"]).'</font></li>

Developing an Online Examination System | Page | 88


CHAPTER THREE | Analysis and Design

<li class="list-group-item list-group-item-warning">Your Marks: <font


color="black">'.$res["marks"].'</font></li>

</ul>';
}
else if(isset($sid))
{

$sql = "SELECT r.id,r.uid,u.name as


uname,r.time,r.marks,r.tq,r.rm,r.wm,r.ra,r.wa From results as r INNER JOIN users as u ON
r.uid=u.id WHERE r.sid=$sid";
$sql = $db->query($sql);

if($sql->num_rows<1)
{
echo '<h4>No Result Found.'.$db->error.'<h4>';
}
}
else
{
//$sql = $db->select("results","",array("uid"=>$user->id));
$sql = "SELECT r.id,r.uid,r.sid,s.name as sname, u.name as
uname,r.time,r.marks,r.tq,r.rm,r.wm,r.ra,r.wa From results as r INNER JOIN subjects as s ON
r.sid=s.id INNER JOIN users as u ON r.uid=u.id";
$sql = $db->query($sql);

if($sql->num_rows<1)
{
echo '<h4>No Result Found.'.$db->error.'<h4>';
}
else
{
echo '
<table class="table table-bordered">
<thead>
<tr>
<th>Date</th>
<th>User</th>
<th>Level</th>
<th>Your Marks</th>
<th>Full Marks</th>
<th>T.Q.</th>

Developing an Online Examination System | Page | 89


CHAPTER THREE | Analysis and Design

<th>R.M.</th>
<th>W.M.</th>
<th>R.A.</th>
<th>W.A.</th>
<th>Actions</th>
</tr>
</thead>
<tbody>';
while($result = $sql->fetch_assoc())
{
echo '
<tr>
<td>'.date("d-m-Y H:i:s A",$result["time"]).'</td>
<td>'.$result["uname"].'</td>
<td>'.$result["sname"].'</td>
<td>'.$result["marks"].'</td>
<td>'.($result["tq"]*$result["rm"]).'</td>
<td>'.$result["tq"].'</td>
<td>'.$result["rm"].'</td>
<td>'.$result["wm"].'</td>
<td>'.$result["ra"].'</td>
<td>'.$result["wa"].'</td>
<td><a href="?act=view&id='.$result["id"].'" class="btn btn-sm btn-info"
role="button" style= "font-size: 15px">View</a><button type="button"
onclick="confirmation(\'Are You Sure Want to Delete?\',\'?act=delete&id='.$result["id"].'\')"
class="btn btn-sm btn-danger" style=" font-size:15px">Delete</button></td>
</tr>';

}
echo '
</tbody>
</table>';
}
}
echo '
</div>
</div>';
include 'footer.php';
?>

(h) ranking.php

Developing an Online Examination System | Page | 90


CHAPTER THREE | Analysis and Design

<?php
include 'init.php';
$title = "View Ranking";
$site->title = $title;
include 'header.php';
echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';
$sql = "SELECT * FROM subjects WHERE 1 ORDER BY id ASC LIMIT 0,3";
$sql = $db->query($sql);
if($sql->num_rows<1)
{
echo '<h3>No Subject</h3>';
exit;
}
$tm=0; $sid=0;

while($sub=$sql->fetch_assoc())
{
$tm += $sub["noq"]*$sub["rm"];
$sid = $sub["id"];
}

$q1 = "SELECT DISTINCT uid FROM results WHERE sid=$sid AND


(marks*100)/(tq*rm)>=70";
if($db->query($q1)->num_rows<1)
{
echo 'No Qualified User Found';
exit;
}
$sql = "SELECT r.*,name,email FROM results as r INNER JOIN users as u ON r.uid=u.id
WHERE sid<=$sid AND uid IN ($q1) ORDER BY marks DESC,et ASC";
$sql = $db->query($sql);
$m = array(); $t = array(); $s=array();
while($res=$sql->fetch_assoc())
{
extract($res);
if(!isset($s[$uid][$sid]))
{
if(!isset($m[$uid])) $m[$uid] = 0;

Developing an Online Examination System | Page | 91


CHAPTER THREE | Analysis and Design

if(!isset($t[$uid])) $t[$uid] = 0;
$m[$uid] += $marks;
$t[$uid] += $et;
$n[$uid] = $name;
$p[$uid] = $email;
$s[$uid][$sid] = true;
}
}
foreach($m as $k=>$v)
{
$usr[] =
array("id"=>$k,"name"=>$n[$k],"email"=>$p[$k],"marks"=>$m[$k],"et"=>$t[$k]);
}

usort($usr, "cmp");

echo '
<table class="table table-bordered">
<thead>
<tr>
<th>Rank</th>
<th>User</th>
<th>Email</th>
<th>Total Marks</th>
<th>Marks Obtained</th>
<th>Time(S)</th>
</tr>
</thead>
<tbody>';
$i=1;
foreach($usr as $uid=>$res)
{
echo '
<tr>
<td>'.$i.'</td>
<td>'.$res["name"].'</td>
<td>'.$res["email"].'</td>
<td>'.$tm.'</a></td>
<td>'.$res["marks"].'</td>
<td>'.$res["et"].'</td>
</tr>';
$i++;

Developing an Online Examination System | Page | 92


CHAPTER THREE | Analysis and Design

}
echo '
</tbody>
</table>';

echo '
</div>
</div>';
include 'footer.php';
function cmp($a,$b)
{
if($a["marks"]<$b["marks"])
return 1;
else if($a["marks"]>$b["marks"])
-1;
else
{
if($a["et"]<$b["et"])
return -1;
else if($a["et"]>$b["et"])
return 1;
else
return 0;
}
}
?>

(i) footer.php

<div class="clearfix"></div>
<div align="center"><div class="sideboxHeader">""</div></div>
</div>
</body>
</html>

(j) logout.php

<?php
include "init.php";

Developing an Online Examination System | Page | 93


CHAPTER THREE | Analysis and Design

if($admin->logout())
{
$_SESSION["message"]="You have been Logged out successfully.";
redir("login.php");
}
else
{
echo '<h4>Something is wrong. Contact with developer.</h4>';}?>

Developing an Online Examination System | Page | 94


CHAPTER FOUR | Conclusion

CHAPTER FOUR
Conclusion

Developing an Online Examination System | Page | 95


CHAPTER FOUR | Conclusion

Chapter Overview
In this chapter we will introduce about the conclusion of this project and reference. In section
4.1 we will discuss about the conclusion of this project and in section 4.2 we will see reference.

4.1 Conclusion
Online examination system is a user friendly system, which is very easy and convenient to use.
The system is complete in the sense that it is operational and it is tested by entering data and
getting the reports in proper order. But there is always a scope for improvement and
enhancement. During the development of this, coding standards are followed for easy
maintainability and extensibility. The project was successfully designed and is tested for
accuracy and quality.

The following conclusions can be deduced from the development of the project:
(a) Automation of the entire system improves the efficiency.
(b) It provides a friendly graphical user interface which proves to be better when compared to
the existing system.
(c) It gives appropriate access to the authorized users depending on their permissions.
(d) It effectively overcomes the delay in communications.
(e) Updating of information becomes so easier.
(f) System security, data security and reliability are the striking features.

Developing an Online Examination System | Page | 96


CHAPTER FOUR | Conclusion

4.2 References
[1] http://exam2win.com/online-tests/bank/economy/2
[2] https://www.ukessays.com/essays/computer-science/overview-on-developing-an-online-
examination-system-computer-science-essay.php
[3] https://www.researchgate.net/publication/317306939_Online_Examination_System
[4] https://www.slideshare.net/shaitaana1/online-examination-system-32350542
[5] http://www.icmab.org.bd/index.php/programs-events/563-online-examination-
registration-introduced

Developing an Online Examination System | Page | 97

Вам также может понравиться