Hari Document

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

ONLINE EXAMINATION SYSTEM

Submitted in partial fulfilment of the requirements for the degree of

BACHELOR OF SCIENCE IN COMPUTER SCIENCE

Submitted by

HARIHARAN K

(RegNo:20BSC114)

Under the Supervision and Guidance of

Mr.M.DHANASEKAR MCA., M.Phil., (Ph.D)

ASSISTANT PROFESSOR

DEPARTMENT OF COMPUTER SCIENCE

HINDUSTHAN COLLEGE OF ARTS & SCIENCE

(Autonomous)
(Affiliated to Bharathiar University)

Accredited by NAAC with ‘A++’ Grade


Behind Nava India, Coimbatore-641 028
APRIL 2023
CERTIFICATE
CERTIFICATE

This is to certify that the project work entitled “ONLINE EXAMINATION

SYSTEM”, submitted to HINDUSTHAN COLLEGE OF ARTS & SCIENCE partial

fulfilment of the requirement. for the award of the Bachelor of Science in Computer Science

is a record original work done by HARIHARAN (Reg no:20BSC114) and this project work

has not formed the basics for the award of any degree are similar title to any candidate of any

university.

Signature of Guide Head of the Department

Submitted for Project Viva-Voice Examination held on..............................

Internal Examiner External Examiner


DECLARATION
DECLARATION

I hereby declare that this project work entitled “ONLINE EXAMINATION

SYSTEM ” is a record of original work done by me during 2022-2023, under the supervision

and guidance of Mr.M.DHANASEKAR MCA., M.Phil., (Ph.D) Assistant Professor of

Computer Science, Hindusthan College of Arts & Science, Coimbatore and this project work

has not formed the basis of award of any Degree similar title to any candidate of any

university.

Place: Coimbatore Signature of the Candidate

Date: (HARIHARAN K)

ACKNOWLEDGEMENT
ACKNOWLEDGEMENT

Words cannot be expressed to show my gratitude to our trustee and Managing

Director Mrs. T. SARASWATHI KANNAIYAN, who was a very example in my life for

achieving goals.

I am greatly indebted to my Honorable Principal Dr.A.PONNUSAMY,

MSW.,MBA., DLL.,MPhil., Ph.D., Hindusthan College of Arts & Science, Coimbatore.

I Sincerely express my profound, thanks to our respected Professor & Head of the

Department Dr. R. RANGARAJ, M.Sc(CS)., M.Sc (Psy).,M.Phil.,Ph.D., for his fruitful

discussion constant support and timely valuable guidance and encouragement during my

project work.

My sincere thanks to our class tutor and project coordinator Mrs. A. KIRUTHIKA

MSC(CS).,M.Phil.,, Professor and all staff members of Department of Computer Science

for their supportive encouragement.

I am extremely grateful to my guide Mr.M.DHANASEKAR MCA.,M.Phil.,

(Ph.D) Department of Computer Science. who took keen interest in my work and put me on

the right path, through his valuable suggestions and timely help in each stage of my project.

I deem it is a special privilege to convey my everlasting thanks to whoever gave

permission to undergo my project work in a private organization.

All above I thank GOD and My Parent for all his blessings.
ABSTRACT
ABSTRACT

An online examination system is a software application that allows educational institutions,

organizations, and companies to conduct exams and assessments over the internet. This

system offers a variety of features to help automate the examination process, including

question banks, automatic grading, secure access, and reporting tools.

The system typically starts with an administrator who sets up the exam, adds questions to the

question bank, and sets the rules for the exam. Once the exam is ready, students or candidates

can log in to the system and take the exam. The system usually offers multiple types of

questions, such as multiple choice, true/false, short answer, and essay questions.

The online examination system has several advantages over traditional paper-based exams. It

saves time and resources, as there is no need to print or distribute paper copies of the exam. It

also eliminates the possibility of cheating or fraud, as the system can monitor the student's

activity during the exam and flag any suspicious behavior.

Moreover, it provides immediate feedback to students, allowing them to see their scores and

learn from their mistakes. The system can also generate reports and analytics, helping

instructors and administrators to evaluate the performance of students and identify areas for

improvement.
TABLE OF CONTENTS
TABLE OF CONTENTS

CHAPTER INDEX PAGE


NO

INTRODUCTION
1 1.1 ABOUT THE PROJECT 1
1.2 SCOPE
1.3 OBJECTIVES

SYSTEM ANALYSIS AND FEASIBILITY STUDY


2.1 PROBLEM DEFINITION 4
2 2.2 EXISTING SYSTEM
2.3 PROPOSED SYSTEM
2.4 FEASIBILITY STUDY
SYSTEM SPECIFICATION
3 3.1 HARDWARE CONFIGURATION 7
3.2 SOFTWARE SPECIFICATION
3.3 REQUIREMENT ANALYSIS
DESIGN AND DEVELOPMENT PROCESS
4.1 DATAFLOW DIAGRAM
4 4.2 INPUT DESIGN 17
4.3 OUTPUT DESIGN
SYSTEM TESTING AND IMPLEMENTATION
5 5.1 SYSTEM TESTING 21
5.2 TYPES OF TESTING
5.3 SYSTEM IMPLEMENTATION
6 CONCLUSION 24
7 SCOPE FOR FUTURE ENHANCEMENT 25
8 BIBLOGRAPHY 26
APPENDICES
9 SCREENSHOTS 27
SAMPLE CODING
INTRODUCTION
1. INTRODUCTION

1.1 About the Project

The Online Examination System is a digital platform designed to simplify the examination

process and provide a user-friendly interface for students, professors, and admins. This

system is developed using various programming languages such as Python, Django, CSS,

HTML, and JavaScript. The purpose of this documentation is to describe the scope,

objectives, and features of the Online Examination System.

1.2 Scope

The Online Examination System is a digital platform designed to cater to educational

institutions, where it can be used for conducting online exams for various subjects. The system

is designed to provide a hassle-free way of evaluating students, making the examination process

simplified, and allowing exams to be taken from anywhere and at any time. The system's scope

is vast, covering different types of exams such as multiple-choice, short-answer, and essay-type

questions, which can be scheduled and managed by the admin. The system aims to provide a

secure environment for exams and ensure the authenticity of results.

1.3 OBJECTIVES

The primary objective of the Online Examination System is to simplify the examination

process and provide a user-friendly interface for students, professors, and admins. The

system aims to provide a secure environment for exams and ensure the authenticity of results.

The platform also aims to reduce the workload of teachers and minimize paper wastage. The

system intends to provide an efficient method of conducting online exams that can be

accessed from anywhere, anytime.

1
Features:
The Online Examination System contains an admin side from where a user can take and

manage exams easily. The admin plays an essential role in the management of this system. In

this project, there is a separate interface for students, professors, and admins. The features of

the Online Examination System are as follows:

1. Secure login system for students, professors, and admins: The platform provides a

secure login system for students, professors, and admins, ensuring that only

authorized users can access the system.

2. Exam scheduling and management: The system provides an option to schedule exams

and set time limits for each exam, making it a time-based examination.

3. Various types of exams: The system supports various types of exams such as

multiple-choice, short-answer, and essay-type questions.

4. Instant result display: The system allows instant result display after the completion of

the exam, which helps students to assess their performance quickly.

5. Exam feedback for students: The platform provides feedback to students on their

exams, highlighting their strengths and areas of improvement.

6. User-friendly interface: The system provides a user-friendly interface for students,

professors, and admins, making it easy to access and use.

7. Minimal paper wastage: The system reduces paper wastage as all exams are

conducted online.

2
SYSTEM ANALYSIS AND FEASIBILITY STUDY

3
2. SYSTEM ANALYSIS AND FEASIBILITY STUDY

2.1 PROBLEM DEFINITION

The traditional method of conducting exams involves a lot of paperwork, is time-consuming, and is

prone to errors. It is also challenging to conduct exams in remote locations, and the authenticity of

the results is questionable. Hence, there is a need for a digital platform that can simplify the

examination process, provide a secure environment, and ensure the authenticity of results.

2.2 EXISTING SYSTEM

The existing system for conducting exams involves the use of paper-based exams, which are

time-consuming, require physical presence, and are prone to errors. The traditional method

also lacks the flexibility to conduct exams from remote locations, making it difficult for

students in different regions to appear for exams. The use of paper-based exams also leads to

a lot of paper wastage and makes the process of result management cumbersome. The

authenticity of the results is also questionable, as the exams are not always conducted under

secure conditions.

2.3 PROPOSED SYSTEM

The proposed Online Examination System is a digital platform designed to simplify the examination

process, provide a secure environment, and ensure the authenticity of results. The system is designed

to provide a hassle-free way of evaluating students, making the examination process simplified, and

allowing exams to be taken from anywhere and at any time. The platform provides a secure login

4
system for students, professors, and admins, ensuring that only authorized users can access the

system.

Advantages

1. Simplified Examination Process: The proposed system simplifies the examination

process, making it more user-friendly for students, professors, and admins.

2. Secure Environment: The platform provides a secure environment for exams, ensuring

the authenticity of results.

3. Anytime, Anywhere Access: The system allows exams to be taken from anywhere

and at any time, making it more flexible for students.

4. Reduced Paper Wastage: The system reduces paper wastage as all exams are

conducted online.

5. Efficient Result Management: The proposed system ensures efficient result

management, making it easier for teachers to manage and access results.

6. Feedback to Students: The platform provides feedback to students on their exams,

highlighting their strengths and areas of improvement.

2.4 FEASIBILITY STUDY

Before the development of the proposed Online Examination System, it is essential to

conduct a feasibility study to determine if the system is viable and feasible. The feasibility

study will analyze the technical, economic, and operational aspects of the proposed system

and determine if the system is worth investing in. Here is a breakdown of the feasibility

study:

5
Technical Feasibility:

The technical feasibility of the proposed system will analyze if the system can be developed

using the available technology and resources. It will consider the availability of hardware,

software, and technical expertise required to develop the system. In this case, the system is

developed using Python, Django, CSS, HTML, and JavaScript. These technologies are

readily available, and the necessary technical expertise can be obtained. Therefore, the

proposed system is technically feasible.

Economic Feasibility:

The economic feasibility of the proposed system will analyze if the system is financially

viable. It will consider the cost of developing the system, the benefits it offers, and the return

on investment (ROI). The development cost of the proposed system will include the cost of

hardware, software, technical expertise, and other expenses. However, the benefits of the

proposed system include reduced paper wastage, efficient result management, and improved

student feedback, among others. The ROI of the proposed system will be determined by

comparing the development cost with the benefits offered by the system. If the ROI is

positive, then the system is economically feasible.

Operational Feasibility:

The operational feasibility of the proposed system will analyse if the system can be integrated

into the existing operations of the organization. It will consider the ease of use, training

required, and compatibility with existing systems. In this case, the proposed system is

designed to integrate into the existing operations of the organization. It is user-friendly, and

the necessary training can be provided. The system is also compatible with existing systems.

Therefore, the proposed system is operationally feasible.

6
SYSTEM SPECIFICATION
7
3. SYSTEM SPECIFICATION

3.1 HARDWARE CONFIGURATION

Processor : Intel (R) core (TM) i3

RAM : 1 GB DDR Ram

Hard disk : 500 GB

Monitor : VGA/SVGA

Keyboard : Logitech

Mouse : Logitech (3 Buttons)

3.2 SOFTWARE SPECIFICATION

Operating System : Windows 7 or Linux or Mac OS

Front end : HTML, CSS

Back end : Django

Database : MongoDB Atlas

8
SOFTWARE DESCRIPTION

HTML

HTML tutorial or HTML 5 tutorial provides basic and advanced concepts of HTML. Our

HTML tutorial is developed for beginners and professionals. In our tutorial, every topic is given

step-by-step so that you can learn it in a very easy way. If you are new in learning HTML, then

you can learn HTML from basic to a professional level and after learning HTML with

CSS and JavaScript you will be able to create your own interactive and dynamic website. But

Now We will focus on HTML only in this tutorial.

The major points of HTML are given below:

o HTML stands for Hypertext Markup Language.

o HTML is used to create web pages and web applications. o HTML is widely

used language on the web. o We can create a static website by HTML only.

o Technically, HTML is a Markup language rather than a programming

language.

Applications of HTML

As mentioned before, HTML is one of the most widely used languages over the web. I'm

going to list few of them here:

• Web pages development - HTML is used to create pages which are rendered over the

web. Almost every page of the web is having html tags in it to render its details in

browser.

9
• Internet Navigation - HTML provides tags which are used to navigate from one page

to another and is heavily used in internet navigation.

• Responsive UI - HTML pages now-a-days works well on all platform, mobile, tabs,

desktop or laptops owing to responsive design strategy.

• Offline support HTML pages once loaded can be made available offline on the

machine without any need of internet.

• Game development- HTML5 has native support for rich experience and is now

useful in gaming development arena as well.

CSS

CSS tutorial or CSS 3 tutorial provides basic and advanced concepts of CSS

technology. Our CSS tutorial is developed for beginners and professionals. The major points

of CSS are given below:

o CSS stands for Cascading Style Sheet. o CSS is used to design HTML tags.

o CSS is a widely used language on the web.

o HTML, CSS, and JavaScript are used for web designing. It helps web designers to

apply style on HTML tags.

Why use CSS

These are the three major benefits of CSS:

1) Solves a big problem.

10
Before CSS, tags like font, color, background style, element alignments, border and size had to

be repeated on every web page. This was a very long process. For example: If you are

developing a large website where fonts and color information are added on every single page,

it will be become a long and expensive process. CSS was created to solve this problem. It was

a W3C recommendation.

2) Saves a lot of time

CSS style definitions are saved in external CSS files, so it is possible to change the entire

website by changing just one file.

3) Provide more attributes

CSS provides more detailed attributes than plain HTML to define the look and feel of the

website.

Django

Django is a web application framework written in Python programming language. It is based

on MVT (Model View Template) design pattern. The Django is very demanding due to its rapid

development feature. It takes less time to build application after collecting client requirement.

This framework uses a famous tag line: The web framework for perfectionists with

deadlines.

By using Django, we can build web applications in very less time. Django is designed in such

a manner that it handles much of configure things automatically, so we can focus on application

development only.

11
Popularity

Django is widely accepted and used by various well-known sites such as:

• Instagram

• Mozilla

• Disqus

• Pinterest

• Bitbucket

• The Washington Times

Features of Django

• Rapid Development

• Secure

• Scalable

• Fully loaded

• Versatile

• Open Source

• Vast and Supported Community

I. Rapid Development

Django was designed with the intention to make a framework which takes less time to build

web application. The project implementation phase is a very time taken but Django creates it

rapidly.

12
II. Secure

Django takes security seriously and helps developers to avoid many common security

mistakes, such as SQL injection, cross-site scripting, cross-site request forgery etc. Its user

authentication system provides a secure way to manage user accounts and passwords.

III. Scalable

Django is scalable in nature and has ability to switch from small quickly and flexibly to large

scale application project.

IV. Fully loaded

Django includes various helping task modules and libraries which can be used to handle

common Web development tasks. Django takes care of user authentication, content

administration, site maps, RSS feeds etc.

V. Versatile

Django is versatile in nature which allows it to build applications for different-different

domains. Now a days, Companies are using Django to build various types of applications like

content management systems, social networks sites or scientific computing platforms etc.

13
VI. Open Source

Django is an open-source web application framework. It is publicly available without cost. It

can be downloaded with source code from the public repository. Open source reduces the total

cost of the application development.

VII. Vast and Supported Community

Django is a one of the most popular web frameworks. It has widely supportive community

and channels to share and connect.

Database: MongoDB

MongoDB is a cross-platform, document-oriented database that provides, high

performance, high availability, and easy scalability. MongoDB works on concept of

collection and document.

Database

Database is a physical container for collections. Each database gets its own set of files on the

file system. A single MongoDB server typically has multiple databases.

Collection

Collection is a group of MongoDB documents. It is the equivalent of an RDBMS table. A

collection exists within a single database. Collections do not enforce a schema. Documents

within a collection can have different fields. Typically, all documents in a collection are of

similar or related purpose.

14
Document

A document is a set of key-value pairs. Documents have dynamic schema. Dynamic schema

means that documents in the same collection do not need to have the same set of fields or

structure, and common fields in a collection's documents may hold different types of data.

Advantages of MongoDB over RDBMS

• Schema less − MongoDB is a document database in which one collection

holds different documents. Number of fields, content and size of the document

can differ from one document to another.

• Structure of a single object is clear.

• No complex joins.

• Deep query-ability. MongoDB supports dynamic queries on documents using a

document-based query language that's nearly as powerful as SQL.

• Tuning.

• Ease of scale-out − MongoDB is easy to scale.

• Conversion/mapping of application objects to database objects not needed.

• Uses internal memory for storing the (windowed) working set, enabling faster

access of data.

Why Use MongoDB?

• Document Oriented Storage − Data is stored in the form of JSON style

documents.

• Index on any attribute


• Replication and high availability
15
• Rich queries

• Fast in-place updates

• Professional support by MongoDB

Where to Use MongoDB?

• Big Data

• Content Management and Delivery

• Mobile and Social Infrastructure

• User Data Management

• Data Hub

3.3 REQUIREMENT ANALISYS

Requirement analysis is an essential step in designing and developing an online examination

system. It helps to identify and define the functional and non-functional requirements of the

system, as well as the user needs and expectations. Here are some key requirements that

should be considered in the analysis:

Functional requirements:

• User registration and authentication

• User roles and permissions management

• Exam creation and management

• Question bank creation and management

• Exam scheduling and notifications

• Exam-taking interface and user experience

16
• Automatic grading and result calculation

• Exam reporting and analytics

• Integration with other systems (such as learning management systems)

Non-functional requirements:

• System performance and scalability

• System security and data privacy

• System reliability and availability

• System usability and accessibility

• System compatibility with different devices and browsers

User requirements:

• User-friendly and intuitive interface

• Clear instructions and guidelines

• Flexibility in exam-taking (such as timed exams or open-book exams)

• Access to exam results and feedback

• Technical support and assistance

17
SYSTEM DESIGN AND DEVELOPMENT PROCESS

18
4. SYSTEM DESIGN AND DEVELOPMENT PROCESS

4.1 Data Flow Diagram

19
4.2 Input Design

The input design of the Online Examination System is an essential aspect of the system's

usability and effectiveness. The input design determines how the user interacts with the

system and how the system processes the user's input. The input design must be intuitive,

efficient, and user-friendly to enhance the user experience. Here are some aspects of the input

design of the Online Examination System:

1. Login Page: The user will input their credentials, such as username and password, on

the login page to access the system. The login page should be secure and userfriendly.

2. Registration Page: The registration page is where new users can register to use the

system. The registration form should be simple and straightforward, requiring only

essential information.

3. Exam Creation Page: The exam creation page is where the admin can create new

exams. The page should be intuitive and easy to use, allowing the admin to add

questions and set parameters, such as time limits.

4. Exam Taking Interface: The exam taking interface is where students take exams. The

interface should be easy to navigate, and the questions should be presented clearly and

concisely.

20
4.3 Output Design

The output design of the Online Examination System determines how the system presents

information to the user. The output design must be clear, concise, and user-friendly to

enhance the user experience. Here are some aspects of the output design of the Online

Examination System:

1. Exam Results: After completing an exam, the system should present the results to the

student. The results should be presented clearly, showing the student's score and any

feedback or comments from the professor.

2. Exam Reports: The system should generate reports of the exams taken by students.

The reports should be easy to understand, providing insights into the performance of

the students.

3. User Management: The system should provide an interface for managing user

accounts. The interface should be easy to use, allowing the admin to add or remove

users as necessary.

4. System Alerts: The system should generate alerts for important events, such as new

exam creation or exam deadline reminders. The alerts should be clear and concise,

allowing the user to take appropriate action.

21
TESTING AND IMPLEMENTATION PHASE

22
5. TESTING AND IMPLEMENTATION PHASE

5.1 System Testing

After the source code has been completed, documented as related data structures.

Completed the project must undergo testing and validation where there is subtitle and definite

attempt to get errors.

The project developer treads lightly, designing and execution test that will demonstrates

that the program works rather than uncovering errors, unfortunately errors will be present and

if the project developer doesn’t find them, the user will find out.

The project developer is always responsible for testing the individual units i.e. modules

of the program. In many cases developer also conducts integration testing i.e. the testing step

that leads to the construction of the complete program structure.

5.2 TYPES OF TESTING

This project has undergone the following testing procedures to ensure its correctness.

• UNIT TESTING

• USER ACCEPTANCE TESTING

• INTEGRATION TESTING

• VALIDATION TESTING

23
UNIT TESTING

In unit testing, we must test the programs making up the system. For this reason, Unit testing

sometimes called as Program testing. The software units in a system are the modules and

routines that are assembled and integrated to perform a specific function, Unit testing first on

the modules independently of one another, to locate errors.

This enables us to detect errors in coding and logic that are contained with the module

alone. The testing was carried out during programming stage itself.

User Acceptance Testing

In these testing procedures the project is given to the customer to test whether all requirements

have been fulfilled and after the user is fully satisfied. The project is perfectly ready. If the user

makes request for any change and if they found any errors those all errors must be taken into

consideration and to be correct it to make a project a perfect project.

INTEGRATION TESTING

Integration testing is a systematic technique for constructing the program structure. While

at the same time conducting tests to uncover errors associated with interfacing. The objective

is to take unit tested modules and build a program structure that has been dictated by design.

In this integration testing it done using the main module and based on the type of

integration testing the subordinate tables and other criteria along with their path, is replaced

one at a time with actual modules. In the project, after integrating the modules such as purchase

and sales, they are tested with their integration in purchase returns and sales return.

24
VALIDATION TESTING

It is said that validation is successful when the software functions in a systematic manner

that can be reasonably accepted by the customers. This type of testing is very important because

it is the only way to check whether the requirements given by user have been completely

fulfilled. The input given to various forms are validated effectively. The validated input is given

for all modules. Each module is tested independently.

5.3 System Implementation

Implementation is the stage where the theoretical design is turned into a working system. The

most crucial stage in achieving a new successful system and in giving confidence on the new

system for the users that it will work efficiently and effectively. The system can be implemented

only after thorough testing is done and if it is found to work according to the specification. It

involves careful planning, investigation of the current system and its constraints on

implementation, design of methods to achieve the changeover and an evaluation of change over

methods apart from planning. Two major tasks of preparing the implementation are education

and training of the users and testing of the system. The more complex the system being

implemented, the more involved will be the systems analysis and design effort required just for

implementation. The implementation phase comprises of several activities. The required

hardware and software acquisition is carried out. The system may require some software to be

developed. Implementation is the final and important phase. The new system has been

implemented successfully is found to be working in the perfect working order it has satisfied

the users and now the users have switched to the new system from the manual system.

25
CONCLUSION
26
6. CONCLUSION

The Online Examination System is a digital platform that evaluates students in a

hassle-free way. The entire examination process is simplified, and exams can be taken from

anywhere, anytime. The system is developed using Python, Django, CSS, HTML, and

JavaScript. The project contains an admin side from where a user can take and manage exams

easily. The admin plays an important role in the management of this system. The system also

has separate interfaces for students, professors, and admin.

The input design and output design of the system are essential to ensure the system's usability

and effectiveness. The input design should be intuitive, efficient, and user-friendly, while the

output design should be clear, concise, and user-friendly.

27
SCOPE FOR FUTURE ENHANCEMENT

28
7. SCOPE FOR FUTURE ENHANCEMENT

The Online Examination System has a wide range of applications in the education sector. It

can be used by schools, colleges, universities, and other educational institutions. Here are

some future scope and enhancements that can be made to the system:

1. Integration with Learning Management Systems (LMS): The system can be integrated

with existing Learning Management Systems (LMS) to enhance the educational

experience.

2. Gamification of Exams: The system can include gamification elements to make the

exams more engaging and interactive for students.

3. AI-based Monitoring: The system can use AI-based monitoring to prevent cheating

and ensure the authenticity of the exams.

4. Integration with E-Learning Platforms: The system can be integrated with existing E-

Learning platforms to provide a comprehensive educational experience.

5. Mobile Application: The system can be developed into a mobile application, making

it more accessible to students and providing an easier user experience.

29
BIBLIOGRPAHY

30
8.BIBLIOGRAPHY

Textbook Reference:

• Jon Duckett, "HTML and CSS: Design and Build Websites"

• William S. Vincent, "Django for Beginners"

• David Flanagan, "JavaScript: The Definitive Guide"

• Antonio Mele, "Django 3 By Example - Build powerful and

reliable Python web applications from scratch."

• Kyle Banker, Peter Bakkum, Shaun Verch, and Doug Garrett,

"MongoDB in Action, 2nd Edition"

Website Reference:

• https://www.w3schools.com/mongodb/ •

https://www.mongodb.com/docs/

• https://docs.djangoproject.com/en/4.2/

• https://www.w3schools.com/html/

• https://www.w3schools.com/css/

• https://www.w3schools.com/js/

31
APPENDICES

32
9. Appendices

Screenshots

33
B) Sample Code

from django.shortcuts import render,redirect


from django.contrib.auth.models import User
from .models import *
from django.contrib.auth.models import Group
from student.models import *
from django.utils import timezone
from student.models import StuExam_DB,StuResults_DB
from questions.questionpaper_models import QPForm
from questions.question_models import QForm
from django.utils import timezone
from django.contrib.auth.decorators import login_required

def has_group(user, group_name):


group = Group.objects.get(name=group_name)
return True if group in user.groups.all() else False

@login_required(login_url='faculty-login')
def view_exams_prof(request):
prof = request.user
prof_user = User.objects.get(username=prof)
permissions = False
if prof:
permissions = has_group(prof,"Professor")
if permissions:
new_Form = ExamForm(prof_user)
if request.method == 'POST' and permissions:
form = ExamForm(prof_user,request.POST)
if form.is_valid():
exam = form.save(commit=False)
exam.professor = prof
exam.save()
form.save_m2m()
return redirect('view_exams')

34
exams = Exam_Model.objects.filter(professor=prof)
return render(request, 'exam/mainexam.html', {
'exams': exams, 'examform': new_Form, 'prof': prof,
})
else:
return redirect('view_exams_student')

@login_required(login_url='faculty-login')
def add_question_paper(request):
prof = request.user
prof_user = User.objects.get(username=prof)
permissions = False
if prof:
permissions = has_group(prof,"Professor")
if permissions:
new_Form = QPForm(prof_user)
if request.method == 'POST' and permissions:
form = QPForm(prof_user,request.POST)
if form.is_valid():
exam = form.save(commit=False)
exam.professor = prof_user
exam.save()
form.save_m2m()
return redirect('faculty-add_question_paper')

exams = Exam_Model.objects.filter(professor=prof)
return render(request, 'exam/addquestionpaper.html', {
'exams': exams, 'examform': new_Form, 'prof': prof,
})
else:
return redirect('view_exams_student')

@login_required(login_url='faculty-login')
def add_questions(request):
prof = request.user
prof_user = User.objects.get(username=prof)
permissions = False
if prof:
permissions = has_group(prof,"Professor")
if permissions:
new_Form = QForm()
if request.method == 'POST' and permissions:
form = QForm(request.POST)
if form.is_valid():
exam = form.save(commit=False)
exam.professor = prof_user
exam.save()
form.save_m2m()
return redirect('faculty-addquestions')

exams = Exam_Model.objects.filter(professor=prof)
return render(request, 'exam/addquestions.html', {
35
'exams': exams, 'examform': new_Form, 'prof': prof,
})
else:
return redirect('view_exams_student')

@login_required(login_url='faculty-login')
def view_previousexams_prof(request):
prof = request.user
student = 0
exams = Exam_Model.objects.filter(professor=prof)
return render(request, 'exam/previousexam.html', {
'exams': exams,'prof': prof
})

@login_required(login_url='login')
def student_view_previous(request):
exams = Exam_Model.objects.all()
list_of_completed = []
list_un = []
for exam in exams:
if StuExam_DB.objects.filter(examname=exam.name ,student=request.user).exists():
if StuExam_DB.objects.get(examname=exam.name,student=request.user).completed == 1:
list_of_completed.append(exam)
else:
list_un.append(exam)

return render(request,'exam/previousstudent.html',{
'exams':list_un,
'completed':list_of_completed
})

@login_required(login_url='faculty-login')
def view_students_prof(request):
students = User.objects.filter(groups__name = "Student")
student_name = []
student_completed = []
count = 0
dicts = {}
examn = Exam_Model.objects.filter(professor=request.user)
for student in students:
student_name.append(student.username)
count = 0
for exam in examn:
if StuExam_DB.objects.filter(student=student,examname=exam.name,completed=1).exists():
count += 1
else:
count += 0
student_completed.append(count)
i=0
for x in student_name:
dicts[x] = student_completed[i]
i+=1
36
return render(request, 'exam/viewstudents.html', {
'students':dicts
})

@login_required(login_url='faculty-login')
def view_results_prof(request):
students = User.objects.filter(groups__name = "Student")
dicts = {}
prof = request.user
professor = User.objects.get(username=prof.username)
examn = Exam_Model.objects.filter(professor=professor)
for exam in examn:
if StuExam_DB.objects.filter(examname=exam.name,completed=1).exists():
students_filter = StuExam_DB.objects.filter(examname=exam.name,completed=1)
for student in students_filter:
key = str(student.student) + " " + str(student.examname) + " " +
str(student.qpaper.qPaperTitle)
dicts[key] = student.score
return render(request, 'exam/resultsstudent.html', {
'students':dicts
})

@login_required(login_url='login')
def view_exams_student(request):
exams = Exam_Model.objects.all()
list_of_completed = []
list_un = []
for exam in exams:
if StuExam_DB.objects.filter(examname=exam.name ,student=request.user).exists():
if StuExam_DB.objects.get(examname=exam.name,student=request.user).completed == 1:
list_of_completed.append(exam)
else:
list_un.append(exam)

return render(request,'exam/mainexamstudent.html',{
'exams':list_un,
'completed':list_of_completed
})

@login_required(login_url='login')
def view_students_attendance(request):
exams = Exam_Model.objects.all()
list_of_completed = []
list_un = []
for exam in exams:
if StuExam_DB.objects.filter(examname=exam.name ,student=request.user).exists():
if StuExam_DB.objects.get(examname=exam.name,student=request.user).completed == 1:
list_of_completed.append(exam)
else:
list_un.append(exam)

return render(request,'exam/attendance.html',{
37
'exams':list_un,
'completed':list_of_completed
})

def convert(seconds):
min, sec = divmod(seconds, 60)
hour, min = divmod(min, 60)
min += hour*60
return "%02d:%02d" % (min, sec)

@login_required(login_url='login')
def appear_exam(request,id):
student = request.user
if request.method == 'GET':
exam = Exam_Model.objects.get(pk=id)
time_delta = exam.end_time - exam.start_time
time = convert(time_delta.seconds)
time = time.split(":")
mins = time[0]
secs = time[1]
context = {
"exam":exam,
"question_list":exam.question_paper.questions.all(),
"secs":secs,
"mins":mins
}
return render(request,'exam/giveExam.html',context)
if request.method == 'POST' :
student = User.objects.get(username=request.user.username)
paper = request.POST['paper']
examMain = Exam_Model.objects.get(name = paper)
stuExam = StuExam_DB.objects.get_or_create(examname=paper, student=student,qpaper =
examMain.question_paper)[0]

qPaper = examMain.question_paper
stuExam.qpaper = qPaper

qPaperQuestionsList = examMain.question_paper.questions.all()
for ques in qPaperQuestionsList:
student_question = Stu_Question(student=student,question=ques.question,
optionA=ques.optionA, optionB=ques.optionB,optionC=ques.optionC, optionD=ques.optionD,
answer=ques.answer)
student_question.save()
stuExam.questions.add(student_question)
stuExam.save()

stuExam.completed = 1
stuExam.save()
examQuestionsList =
StuExam_DB.objects.filter(student=request.user,examname=paper,qpaper=examMain.question_pap
er,questions__student = request.user)[0]
#examQuestionsList = stuExam.questions.all()
38
examScore = 0
list_i = examMain.question_paper.questions.all()
queslist = examQuestionsList.questions.all()
i=0
for j in range(list_i.count()):
ques = queslist[j]
max_m = list_i[i].max_marks
ans = request.POST.get(ques.question, False)
if not ans:
ans = "E"
ques.choice = ans
ques.save()
if ans.lower() == ques.answer.lower() or ans == ques.answer:
examScore = examScore + max_m
i+=1

stuExam.score = examScore
stuExam.save()
stu = StuExam_DB.objects.filter(student=request.user,examname=examMain.name)
results = StuResults_DB.objects.get_or_create(student=request.user)[0]
results.exams.add(stu[0])
results.save()
return redirect('view_exams_student')

@login_required(login_url='login')
def result(request,id):
student = request.user
exam = Exam_Model.objects.get(pk=id)
score =
StuExam_DB.objects.get(student=student,examname=exam.name,qpaper=exam.question_paper).sc
ore
return render(request,'exam/result.html',{'exam':exam,"score":score}

from django.shortcuts import render, redirect


from .models import StudentPreferenceModel
from django.contrib import messages
from django.contrib.auth import update_session_auth_hash
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth.decorators import login_required

@login_required(login_url='login')
def index(request):
exists = StudentPreferenceModel.objects.filter(user=request.user).exists()
student_preference = None

if request.method == 'GET':
var = "On"
if exists:
var="Off"
student_preference = StudentPreferenceModel.objects.get(user=request.user)
39
if student_preference.sendEmailOnLogin == True:
var = "On"
return
render(request,'studentPreferences/pref.html',{'student_preference':student_preference,'email_pre
f_value':var})

if request.method == 'POST':
if exists:
student_preference = StudentPreferenceModel.objects.get(user=request.user)
var = "Off"
pref = request.POST['email_pref']
if exists:
student_preference.sendEmailOnLogin = pref
student_preference.save()
else:
var = "On"
StudentPreferenceModel.objects.create(user = request.user, sendEmailOnLogin=pref)

student_preference = StudentPreferenceModel.objects.filter(user=request.user)
if pref == 'True':
var = "On"

messages.success(request,"Email Notifications are turned " + var)

return
render(request,'studentPreferences/pref.html',{'student_preference':student_preference,'email_pre
f_value':var})

@login_required(login_url='login')
def change_password(request):
if request.method == 'POST':
form = PasswordChangeForm(request.user, request.POST)
if form.is_valid():
user = form.save()
update_session_auth_hash(request, user)
messages.success(request, 'Your password was successfully updated!')
return redirect('login')
else:
messages.error(request, 'Please correct the error below.')
else:
form = PasswordChangeForm(request.user)
return render(request, 'studentPreferences/change_password.html', {
'form': form
})

from django.shortcuts import render,redirect


from django.contrib.auth.models import User
from .models import *
from django.contrib.auth.models import Group
from student.models import *
from django.utils import timezone
40
from student.models import StuExam_DB,StuResults_DB
from questions.questionpaper_models import QPForm
from questions.question_models import QForm
from django.utils import timezone
from django.contrib.auth.decorators import login_required

def has_group(user, group_name):


group = Group.objects.get(name=group_name)
return True if group in user.groups.all() else False

@login_required(login_url='faculty-login')
def view_exams_prof(request):
prof = request.user
prof_user = User.objects.get(username=prof)
permissions = False
if prof:
permissions = has_group(prof,"Professor")
if permissions:
new_Form = ExamForm(prof_user)
if request.method == 'POST' and permissions:
form = ExamForm(prof_user,request.POST)
if form.is_valid():
exam = form.save(commit=False)
exam.professor = prof
exam.save()
form.save_m2m()
return redirect('view_exams')

exams = Exam_Model.objects.filter(professor=prof)
return render(request, 'exam/mainexam.html', {
'exams': exams, 'examform': new_Form, 'prof': prof,
})
else:
return redirect('view_exams_student')

@login_required(login_url='faculty-login')
def add_question_paper(request):
prof = request.user
prof_user = User.objects.get(username=prof)
permissions = False
if prof:
permissions = has_group(prof,"Professor")
if permissions:
new_Form = QPForm(prof_user)
if request.method == 'POST' and permissions:
form = QPForm(prof_user,request.POST)
if form.is_valid():
exam = form.save(commit=False)
exam.professor = prof_user
exam.save()
form.save_m2m()
return redirect('faculty-add_question_paper')
41
exams = Exam_Model.objects.filter(professor=prof)
return render(request, 'exam/addquestionpaper.html', {
'exams': exams, 'examform': new_Form, 'prof': prof,
})
else:
return redirect('view_exams_student')

@login_required(login_url='faculty-login')
def add_questions(request):
prof = request.user
prof_user = User.objects.get(username=prof)
permissions = False
if prof:
permissions = has_group(prof,"Professor")
if permissions:
new_Form = QForm()
if request.method == 'POST' and permissions:
form = QForm(request.POST)
if form.is_valid():
exam = form.save(commit=False)
exam.professor = prof_user
exam.save()
form.save_m2m()
return redirect('faculty-addquestions')

exams = Exam_Model.objects.filter(professor=prof)
return render(request, 'exam/addquestions.html', {
'exams': exams, 'examform': new_Form, 'prof': prof,
})
else:
return redirect('view_exams_student')

@login_required(login_url='faculty-login')
def view_previousexams_prof(request):
prof = request.user
student = 0
exams = Exam_Model.objects.filter(professor=prof)
return render(request, 'exam/previousexam.html', {
'exams': exams,'prof': prof
})

@login_required(login_url='login')
def student_view_previous(request):
exams = Exam_Model.objects.all()
list_of_completed = []
list_un = []
for exam in exams:
if StuExam_DB.objects.filter(examname=exam.name ,student=request.user).exists():
if StuExam_DB.objects.get(examname=exam.name,student=request.user).completed == 1:
list_of_completed.append(exam)
else:
42
list_un.append(exam)

return render(request,'exam/previousstudent.html',{
'exams':list_un,
'completed':list_of_completed
})

@login_required(login_url='faculty-login')
def view_students_prof(request):
students = User.objects.filter(groups__name = "Student")
student_name = []
student_completed = []
count = 0
dicts = {}
examn = Exam_Model.objects.filter(professor=request.user)
for student in students:
student_name.append(student.username)
count = 0
for exam in examn:
if StuExam_DB.objects.filter(student=student,examname=exam.name,completed=1).exists():
count += 1
else:
count += 0
student_completed.append(count)
i=0
for x in student_name:
dicts[x] = student_completed[i]
i+=1
return render(request, 'exam/viewstudents.html', {
'students':dicts
})

@login_required(login_url='faculty-login')
def view_results_prof(request):
students = User.objects.filter(groups__name = "Student")
dicts = {}
prof = request.user
professor = User.objects.get(username=prof.username)
examn = Exam_Model.objects.filter(professor=professor)
for exam in examn:
if StuExam_DB.objects.filter(examname=exam.name,completed=1).exists():
students_filter = StuExam_DB.objects.filter(examname=exam.name,completed=1)
for student in students_filter:
key = str(student.student) + " " + str(student.examname) + " " +
str(student.qpaper.qPaperTitle)
dicts[key] = student.score
return render(request, 'exam/resultsstudent.html', {
'students':dicts
})

@login_required(login_url='login')
def view_exams_student(request):
43
exams = Exam_Model.objects.all()
list_of_completed = []
list_un = []
for exam in exams:
if StuExam_DB.objects.filter(examname=exam.name ,student=request.user).exists():
if StuExam_DB.objects.get(examname=exam.name,student=request.user).completed == 1:
list_of_completed.append(exam)
else:
list_un.append(exam)

return render(request,'exam/mainexamstudent.html',{
'exams':list_un,
'completed':list_of_completed
})

@login_required(login_url='login')
def view_students_attendance(request):
exams = Exam_Model.objects.all()
list_of_completed = []
list_un = []
for exam in exams:
if StuExam_DB.objects.filter(examname=exam.name ,student=request.user).exists():
if StuExam_DB.objects.get(examname=exam.name,student=request.user).completed == 1:
list_of_completed.append(exam)
else:
list_un.append(exam)

return render(request,'exam/attendance.html',{
'exams':list_un,
'completed':list_of_completed
})

def convert(seconds):
min, sec = divmod(seconds, 60)
hour, min = divmod(min, 60)
min += hour*60
return "%02d:%02d" % (min, sec)

@login_required(login_url='login')
def appear_exam(request,id):
student = request.user
if request.method == 'GET':
exam = Exam_Model.objects.get(pk=id)
time_delta = exam.end_time - exam.start_time
time = convert(time_delta.seconds)
time = time.split(":")
mins = time[0]
secs = time[1]
context = {
"exam":exam,
"question_list":exam.question_paper.questions.all(),
"secs":secs,
44
"mins":mins
}
return render(request,'exam/giveExam.html',context)
if request.method == 'POST' :
student = User.objects.get(username=request.user.username)
paper = request.POST['paper']
examMain = Exam_Model.objects.get(name = paper)
stuExam = StuExam_DB.objects.get_or_create(examname=paper, student=student,qpaper =
examMain.question_paper)[0]

qPaper = examMain.question_paper
stuExam.qpaper = qPaper

qPaperQuestionsList = examMain.question_paper.questions.all()
for ques in qPaperQuestionsList:
student_question = Stu_Question(student=student,question=ques.question,
optionA=ques.optionA, optionB=ques.optionB,optionC=ques.optionC, optionD=ques.optionD,
answer=ques.answer)
student_question.save()
stuExam.questions.add(student_question)
stuExam.save()

stuExam.completed = 1
stuExam.save()
examQuestionsList =
StuExam_DB.objects.filter(student=request.user,examname=paper,qpaper=examMain.question_pap
er,questions__student = request.user)[0]
#examQuestionsList = stuExam.questions.all()
examScore = 0
list_i = examMain.question_paper.questions.all()
queslist = examQuestionsList.questions.all()
i=0
for j in range(list_i.count()):
ques = queslist[j]
max_m = list_i[i].max_marks
ans = request.POST.get(ques.question, False)
if not ans:
ans = "E"
ques.choice = ans
ques.save()
if ans.lower() == ques.answer.lower() or ans == ques.answer:
examScore = examScore + max_m
i+=1

stuExam.score = examScore
stuExam.save()
stu = StuExam_DB.objects.filter(student=request.user,examname=examMain.name)
results = StuResults_DB.objects.get_or_create(student=request.user)[0]
results.exams.add(stu[0])
results.save()
return redirect('view_exams_student')

45
@login_required(login_url='login')
def result(request,id):
student = request.user
exam = Exam_Model.objects.get(pk=id)
score =
StuExam_DB.objects.get(student=student,examname=exam.name,qpaper=exam.question_paper).sc
ore
return render(request,'exam/result.html',{'exam':exam,"score":score})

from django.shortcuts import render,redirect


from django.views import View
from .forms import FacultyForm,FacultyInfoForm
from .models import FacultyInfo
from django.contrib import auth
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.mail import EmailMessage
import threading
from django.contrib.sites.shortcuts import get_current_site
from student.views import EmailThread
from django.contrib.auth.models import User
from django.contrib.auth.models import Group
from questions.views import has_group

@login_required(login_url='faculty-login')
def index(request):
return render(request,'faculty/index.html')

class Register(View):
def get(self,request):
faculty_form = FacultyForm()
faculty_info_form = FacultyInfoForm()
return
render(request,'faculty/register.html',{'faculty_form':faculty_form,'faculty_info_form':faculty_info_f
orm})

def post(self,request):
faculty_form = FacultyForm(data=request.POST)
faculty_info_form = FacultyInfoForm(data=request.POST)
email = request.POST['email']

if faculty_form.is_valid() and faculty_info_form.is_valid():


faculty = faculty_form.save()
faculty.set_password(faculty.password)
faculty.is_active = True
faculty.is_staff = True
faculty.save()

domain = get_current_site(request).domain
email_subject = 'Activate your Exam Portal Faculty account'

46
email_body = "Hi. Please contact the admin team of "+domain+". To register yourself as a
professor."+ ".\n\n You are receiving this message because you registered on " + domain +". If you
didn't register please contact support team on " + domain
fromEmail = 'noreply@exam.com'
email = EmailMessage(
email_subject,
email_body,
fromEmail,
[email],
)
student_info = faculty_info_form.save(commit=False)
student_info.user = faculty
if 'picture' in request.FILES:
student_info.picture = request.FILES['picture']
student_info.save()
messages.success(request,"Registered Succesfully. Check Email for confirmation")
EmailThread(email).start()
return redirect('faculty-login')
else:
print(faculty_form.errors,faculty_info_form.errors)
return
render(request,'faculty/register.html',{'faculty_form':faculty_form,'faculty_info_form':faculty_info_f
orm})

class LoginView(View):
def get(self,request):
return render(request,'faculty/login.html')
def post(self,request):
username = request.POST['username']
password = request.POST['password']
has_grp = False
if username and password:
user = auth.authenticate(username=username,password=password)
exis = User.objects.filter(username=username).exists()
if exis:
user_ch = User.objects.get(username=username)
has_grp = has_group(user_ch,"Professor")
if user and user.is_active and exis and has_grp:
auth.login(request,user)
messages.success(request,"Welcome, "+ user.username + ". You are
now logged in.")
return redirect('faculty-index')
elif not has_grp and exis:
messages.error(request,'You dont have permssions to login as faculty.
If You think this is a mistake please contact admin')
return render(request,'faculty/login.html')

else:
messages.error(request,'Invalid credentials')
return render(request,'faculty/login.html')

47
messages.error(request,'Please fill all fields')
return render(request,'faculty/login.html')

class LogoutView(View):
def post(self,request):
auth.logout(request)
messages.success(request,'Logged Out')
return redirect('faculty-login')

48

You might also like