Академический Документы
Профессиональный Документы
Культура Документы
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
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.
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.
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.
(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.
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.
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.
user
Interface
design
Aesthetic design
Content design
Navigation design
Architecture design
Component design
technology
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.
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.
<!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.
<!DOCTYPE html>
<html>
<head>
<title> HTML Test </title>
</head>
<body>
Developing an Online Examination System | Page | 16
CHAPTER THREE | Analysis and Design
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,
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.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.
(b) Registration
(c) Home
(d) Exam
(f) Result
(h) Ranking
(b) Home
(h) Result
(i) Ranking
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()
);
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>
</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($errors))
{
$id = $user->gdata("id",array("email"=>$email));
$_SESSION["id"]=$id;
$db->update("users",array("lasttime"=>time()),array("id"=>$id));
redir($site->url."/");
}
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 '
</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="";
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;
}
}
}
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>';
}
$sql = $db-
>select("questions","",array("sid"=>$sid),"rand()","0,".$sub["noq"]);
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>
<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()};
function myFunction() {
if (window.pageYOffset >= sticky) {
header.classList.add("sticky");
} else {
header.classList.remove("sticky");
}
}
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(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
{
<?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;
$_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>';
$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)
{
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
--
-- Database: `exam`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
--
-- 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`
--
--
-- 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'),
(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`
--
--
-- 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`
--
--
-- 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`
--
--
-- 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`);
--
-- 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`
(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;
}
?>
<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"> » New
Exam</a>
</div>
</div>
</div>';
echo '
<div class="panel panel-primary">
<div class="panel-heading">Results Area</div>
<div class="panel-body" style="padding: 2px;">';
if($sql->num_rows<100)
{
echo '
<div class="list-group">
<a href="results.php" class="list-group-item list-group-item-danger"> »
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> </td>
</tr>';
}
echo '
<tr>
</tr>';
echo '
</tbody>
</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");
$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($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("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>';
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>
<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> </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;
}
echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';
$tm=0; $sid=0;
while($sub=$sql->fetch_assoc())
{
$tm += $sub["noq"]*$sub["rm"];
$sid = $sub["id"];
}
}
}
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++;
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"]);
(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;
}
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;
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 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;
}
}
.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;
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;
-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
{
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;
}
.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;
}
}
(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")
),
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>
<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"> »
Manage Users</a>
<a href="subjects.php" class="list-group-item list-group-item-info"> »
Manage Levels</a>
<a href="questions.php" class="list-group-item list-group-item-danger">
» Manage Questions</a>
(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)
{
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";
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))
{
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"]),
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>';
}
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>';
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))
{
$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)
{
echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';
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($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",
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);
}
}
$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;
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"]))
{
$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)) {
echo '
<div class="panel panel-primary">
<div class="panel-heading">'.$title.'</div>
<div class="panel-body" style="padding: 5px;">';
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.";
}
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>';
}
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';
?>
(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;
}
}
}
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;">';
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>
</ul>';
}
else if(isset($sid))
{
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>
<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
<?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"];
}
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++;
}
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($admin->logout())
{
$_SESSION["message"]="You have been Logged out successfully.";
redir("login.php");
}
else
{
echo '<h4>Something is wrong. Contact with developer.</h4>';}?>
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.
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