MCQ Exam Sys and Source Code
MCQ Exam Sys and Source Code
MCQ Exam Sys and Source Code
SYNOPSIS REPORT ON
IN PARTIAL FULFILMENT OF
Award of the Degree of
MASTER OF COMPUTER APPLICATION
SUBMITTED TO
THROUGH
3. Problem Statement
5. Objectives
6. Technology used
7. Conclusion
8. Bibliography
MCQ EXAM SYSTEM
MCQ Exam System is a complete system that is beneficial for both teachers
and students. With this site, an administrator can allow authorized access to users
that include faculty and students. Faculties are those who register on the site and
take exams in their respective courses on time. teachers can add questions to the
exam by selecting the available settings.
The tests added by faculties are available to students who can attempt the test and
get scores then and there. The aim of the system is to provide a system that saves
both the effort and time of the teachers and the students.
The system named MCQ Exams System is application software, which aims to
provide services to institutions and provide them with an option to self-select
eligible students.
Problem Statement
The MCQ exam system can automatically add the marks allotted to each question to
determine the total marks for the question. A time limit may be fixed for the
examination. It also allows going to specific questions based on previous answers. It
is an easy and convenient way to conduct and attend exams which saves a lot of
time and effort.
Scope
Objectives
This MCQ Examination system is to enable user with its functionality of user-
friendly dashboard.
Multiple Type Questions in many formats.
Examiner analysis all student result in one dashboard.
The important objective of this software is to allow student take the exam at
their own place.
This Project is saved papers and save teaches and student times and it’s cost
saving system.
System Configuration
Software Requirements
OS : MS WINDOWS XP / 7 / 8 / 10 / 11
Environment : Java Runtime Environment 1.5
Front end : Java, swing
Back end : Excel Database
Hardware Requirements
import com.oes.app.Application;
Application.java
package com.oes.app;
import java.util.List;
import java.util.Optional;
import com.oes.data.StudentData;
import com.oes.pages.LoginPage;
import com.oes.pojos.Student;
private Application() {
studentData = new StudentData();
}
ErrorMessage.java
package com.oes.constants;
FilePaths.java
package com.oes.constants;
import java.io.File;
}
ResultStatus.java
package com.oes.constants;
QuestionsData.java
package java.lang;
import java.lang.annotation.Native;
import java.lang.invoke.MethodHandles;
import java.lang.constant.Constable;
import java.lang.constant.ConstantDesc;
import java.util.Objects;
import java.util.Optional;
import jdk.internal.misc.CDS;
import jdk.internal.misc.VM;
import jdk.internal.vm.annotation.IntrinsicCandidate;
@jdk.internal.ValueBased
public final class Integer extends Number
implements Comparable<Integer>, Constable, ConstantDesc {
@SuppressWarnings("unchecked")
public static final Class<Integer> TYPE = (Class<Integer>) Class.getPrimitiveClass("int");
static final char[] digits = {
'0' , '1' , '2' , '3' , '4' , '5' ,
'6' , '7' , '8' , '9' , 'a' , 'b' ,
'c' , 'd' , 'e' , 'f' , 'g' , 'h' ,
'i' , 'j' , 'k' , 'l' , 'm' , 'n' ,
'o' , 'p' , 'q' , 'r' , 's' , 't' ,
'u' , 'v' , 'w' , 'x' , 'y' , 'z'
};
if (COMPACT_STRINGS) {
byte[] buf = new byte[33];
boolean negative = (i < 0);
int charPos = 32;
if (!negative) {
i = -i;
}
if (negative) {
buf[--charPos] = '-';
}
private static void formatUnsignedInt(int val, int shift, byte[] buf, int len) {
int charPos = len;
int radix = 1 << shift;
int mask = radix - 1;
do {
buf[--charPos] = (byte)Integer.digits[val & mask];
val >>>= shift;
} while (charPos > 0);
}
private static void formatUnsignedIntUTF16(int val, int shift, byte[] buf, int len) {
int charPos = len;
int radix = 1 << shift;
int mask = radix - 1;
do {
StringUTF16.putChar(buf, --charPos, Integer.digits[val & mask]);
val >>>= shift;
} while (charPos > 0);
}
@IntrinsicCandidate
public static String toString(int i) {
int size = stringSize(i);
if (COMPACT_STRINGS) {
byte[] buf = new byte[size];
getChars(i, size, buf);
return new String(buf, LATIN1);
} else {
byte[] buf = new byte[size * 2];
StringUTF16.getChars(i, size, buf);
return new String(buf, UTF16);
}
}
if (negative) {
buf[--charPos] = (byte)'-';
}
return charPos;
}
if (s == null) {
throw new NumberFormatException("Cannot parse null string");
}
if (len > 0) {
char firstChar = s.charAt(0);
if (firstChar < '0') { // Possible leading "+" or "-"
if (firstChar == '-') {
negative = true;
limit = Integer.MIN_VALUE;
} else if (firstChar != '+') {
throw NumberFormatException.forInputString(s, radix);
}
public static int parseInt(CharSequence s, int beginIndex, int endIndex, int radix)
throws NumberFormatException {
Objects.requireNonNull(s);
Objects.checkFromToIndex(beginIndex, endIndex, s.length());
if (i < endIndex) {
char firstChar = s.charAt(i);
if (firstChar < '0') { // Possible leading "+" or "-"
if (firstChar == '-') {
negative = true;
limit = Integer.MIN_VALUE;
} else if (firstChar != '+') {
throw NumberFormatException.forCharSequence(s, beginIndex,
endIndex, i);
}
i++;
if (i == endIndex) { // Cannot have lone "+" or "-"
throw NumberFormatException.forCharSequence(s, beginIndex,
endIndex, i);
}
}
int multmin = limit / radix;
int result = 0;
while (i < endIndex) {
// Accumulating negatively avoids surprises near MAX_VALUE
int digit = Character.digit(s.charAt(i), radix);
if (digit < 0 || result < multmin) {
throw NumberFormatException.forCharSequence(s, beginIndex,
endIndex, i);
}
result *= radix;
if (result < limit + digit) {
throw NumberFormatException.forCharSequence(s, beginIndex,
endIndex, i);
}
i++;
result -= digit;
}
return negative ? result : -result;
} else {
throw NumberFormatException.forInputString("", radix);
}
}
public static int parseInt(String s) throws NumberFormatException {
return parseInt(s,10);
}
public static int parseUnsignedInt(CharSequence s, int beginIndex, int endIndex, int radix)
throws NumberFormatException {
Objects.requireNonNull(s);
Objects.checkFromToIndex(beginIndex, endIndex, s.length());
if (len > 0) {
char firstChar = s.charAt(start);
if (firstChar == '-') {
throw new
NumberFormatException(String.format("Illegal leading minus sign " +
"on unsigned string %s.", s));
} else {
if (len <= 5 || // Integer.MAX_VALUE in Character.MAX_RADIX is 6 digits
(radix == 10 && len <= 9)) { // Integer.MAX_VALUE in base 10 is 10 digits
return parseInt(s, start, start + len, radix);
} else {
long ell = Long.parseLong(s, start, start + len, radix);
if ((ell & 0xffff_ffff_0000_0000L) == 0) {
return (int) ell;
} else {
throw new
NumberFormatException(String.format("String value %s exceeds " +
"range of unsigned int.", s));
}
}
}
} else {
throw new NumberFormatException("");
}
}
static {
// high value may be configured by property
int h = 127;
String integerCacheHighPropValue =
VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
if (integerCacheHighPropValue != null) {
try {
h = Math.max(parseInt(integerCacheHighPropValue), 127);
// Maximum array size is Integer.MAX_VALUE
h = Math.min(h, Integer.MAX_VALUE - (-low) -1);
} catch( NumberFormatException nfe) {
// If the property cannot be parsed into an int, ignore it.
}
}
high = h;
private IntegerCache() {}
}
@IntrinsicCandidate
public static Integer valueOf(int i) {
if (i >= IntegerCache.low && i <= IntegerCache.high)
return IntegerCache.cache[i + (-IntegerCache.low)];
return new Integer(i);
}
@IntrinsicCandidate
public int intValue() {
return value;
}
@Override
public int hashCode() {
return Integer.hashCode(value);
}
if (nm.isEmpty())
throw new NumberFormatException("Zero length string");
char firstChar = nm.charAt(0);
// Handle sign, if present
if (firstChar == '-') {
negative = true;
index++;
} else if (firstChar == '+')
index++;
try {
result = parseInt(nm, index, nm.length(), radix);
result = negative ? -result : result;
} catch (NumberFormatException e) {
// If number is Integer.MIN_VALUE, we'll end up here. The next line
// handles this case, and causes any genuine format error to be
// rethrown.
String constant = negative ? ("-" + nm.substring(index))
: nm.substring(index);
result = parseInt(constant, radix);
}
return result;
}
// Bit twiddling
public static int highestOneBit(int i) {
return i & (MIN_VALUE >>> numberOfLeadingZeros(i));
}
@IntrinsicCandidate
public static int numberOfLeadingZeros(int i) {
// HD, Count leading 0's
if (i <= 0)
return i == 0 ? 32 : 0;
int n = 31;
if (i >= 1 << 16) { n -= 16; i >>>= 16; }
if (i >= 1 << 8) { n -= 8; i >>>= 8; }
if (i >= 1 << 4) { n -= 4; i >>>= 4; }
if (i >= 1 << 2) { n -= 2; i >>>= 2; }
return n - (i >>> 1);
}
@IntrinsicCandidate
public static int numberOfTrailingZeros(int i) {
// HD, Count trailing 0's
i = ~i & (i - 1);
if (i <= 0) return i & 32;
int n = 1;
if (i > 1 << 16) { n += 16; i >>>= 16; }
if (i > 1 << 8) { n += 8; i >>>= 8; }
if (i > 1 << 4) { n += 4; i >>>= 4; }
if (i > 1 << 2) { n += 2; i >>>= 2; }
return n + (i >>> 1);
}
@IntrinsicCandidate
public static int bitCount(int i) {
// HD, Figure 5-2
i = i - ((i >>> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
i = (i + (i >>> 4)) & 0x0f0f0f0f;
i = i + (i >>> 8);
i = i + (i >>> 16);
return i & 0x3f;
}
return reverseBytes(i);
}
@IntrinsicCandidate
public static int reverseBytes(int i) {
return (i << 24) |
((i & 0xff00) << 8) |
((i >>> 8) & 0xff00) |
(i >>> 24);
}
@Override
public Optional<Integer> describeConstable() {
return Optional.of(this);
}
@Override
public Integer resolveConstantDesc(MethodHandles.Lookup lookup) {
return this;
}
@java.io.Serial
@Native private static final long serialVersionUID = 1360826667806852920L;
}
ResultData.java
package com.oes.data;
import java.util.Map;
import org.apache.commons.collections4.map.HashedMap;
import com.oes.app.Application;
import com.oes.constants.FilePaths;
import com.oes.pojos.Result;
import com.oes.pojos.Student;
XlsWriter xlsWriter;
public ResultsData() {
xlsWriter = new XlsWriter(FilePaths.OES_XLS_FILE, "results");
}
StudentData.java
package com.oes.data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections4.map.HashedMap;
import com.oes.constants.FilePaths;
import com.oes.pojos.Student;
XlsReader oesXlsReader;
XlsWriter xlsWriter;
public StudentData() {
oesXlsReader = new XlsReader(FilePaths.OES_XLS_FILE, "student");
xlsWriter = new XlsWriter(FilePaths.OES_XLS_FILE, "student");
}
}
return list;
}
/**
* @author Kaushal
* @param student - object of Student class (the student to be added to XLS file)
* @return true - if student is added to XLS data successfully,
* false - if error while adding the student data
*/
public boolean addStudent(Student student) {
Map<Integer, String> studentData = new HashedMap<Integer, String>();
studentData.put(0, String.valueOf(getAllStudents().size() + 1));
studentData.put(1, student.getFirstName());
studentData.put(2, student.getLastName());
studentData.put(3, student.getQualification());
studentData.put(4, student.getMobile());
studentData.put(5, student.getEmail());
studentData.put(6, student.getPassword());
XlsReader.java
package com.oes.data;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Map;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
XSSFWorkbook workbook;
XSSFSheet sheet;
String filePath;
String sheetName;
switch (type) {
case NUMERIC:
return String.valueOf(cell.getNumericCellValue());
case STRING:
return cell.getStringCellValue();
default:
return "Unsupported Cell Type";
}
}
XlsWriter.java
package com.oes.data;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
XSSFWorkbook workbook;
XSSFSheet sheet;
String filePath;
String sheetName;
ExamPage.java
package com.oes.pages;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EmptyBorder;
import com.oes.data.ResultsData;
import com.oes.pojos.Exam;
import com.oes.pojos.Option;
import com.oes.pojos.Question;
import com.oes.pojos.Result;
private ExamPage() {
super();
exam = new Exam();
name = "OES - Online Exam";
width = 400;
height = 400;
panel = new JPanel();
optionA = new JRadioButton("a");
optionB = new JRadioButton("b");
optionC = new JRadioButton("c");
optionD = new JRadioButton("d");
currentQuestion = exam.getCurrentQuestion();
init();
}
return qoPanel;
}
return qPanel;
}
endButtonPanel.add(endButton, BorderLayout.LINE_END);
return endButtonPanel;
}
prevBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
prevButtonPressed();
}
});
nextBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
nextButtonPressed();
}
});
return buttonPanel;
}
//options
exam.getCurrentQuestion().getOptions().forEach( option -> updateOPanel(option));
updateRadioButtonSelection();
switch (option.getName().toLowerCase()) {
case "a":
optionALabel.setText(option.getValue());
break;
case "b":
optionBLabel.setText(option.getValue());
break;
case "c":
optionCLabel.setText(option.getValue());
break;
case "d":
optionDLabel.setText(option.getValue());
break;
default:
break;
}
}
if(exam.getCurrentQuestion().isAnswered()) {
switch (exam.getCurrentQuestion().getUserSelectedOption().getName()) {
case "a":
optionA.setSelected(true);
break;
case "b":
optionB.setSelected(true);
break;
case "c":
optionC.setSelected(true);
break;
case "d":
optionD.setSelected(true);
break;
default:
break;
}
}
}
optionB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
System.out.println("Option B --- selected.");
exam.getCurrentQuestion().setUserSelectedOption(getOption("b"));
}
});
optionC.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
System.out.println("Option C --- selected.");
exam.getCurrentQuestion().setUserSelectedOption(getOption("c"));
}
});
optionD.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
System.out.println("Option D --- selected.");
exam.getCurrentQuestion().setUserSelectedOption(getOption("d"));
}
});
}
LoginPage.java
package com.oes.pages;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import com.oes.app.Application;
private LoginPage() {
super();
name = "OES - Login";
width = 400;
height = 200;
panel = new JPanel();
usernameInput = new JTextField(10); // accepts upto 10 characters
passwordInput = new JPasswordField(10);
loginBtn = new JButton("Login");
registerBtn = new JButton("Sign up");
init();
}
registerBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
close();
RegisterPage.getInstance().open();
}
});
}
panel.add(loginBtn);
panel.add(registerBtn);
panel.setLayout(new GridLayout(3,2, 20, 30));
panel.setBorder(new EmptyBorder(10, 10, 20, 10));
}
Page.java
package com.oes.pages;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public Page() {
}
RegisterPage.java
package com.oes.pages;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import com.oes.constants.ErrorMessages;
import com.oes.data.StudentData;
import com.oes.pojos.Student;
private RegisterPage() {
super();
name = "OES - Register";
width = 400;
height = 500;
panel = new JPanel();
panel = new JPanel();
firstNameInput = new JTextField(10);
lastNameInput = new JTextField(10);
qualificationInput = new JTextField(20);
mobileInput = new JTextField(10);
emailInput = new JTextField(20);
passwordInput = new JTextField(10);
cancelBtn = new JButton("Cancel");
registerBtn = new JButton("Register");
studentData = new StudentData();
init();
}
if(isAdded) {
display(ErrorMessages.REGISTRATION_SUCCESSFUL);
close();
LoginPage.getInstance().open();
}else {
display(ErrorMessages.REGISTRATION_FAILURE);
}
}
});
cancelBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//TODO: cancel the student registration
close();
LoginPage.getInstance().open();
}
});
}
panel.add(lastNameLabel);
panel.add(lastNameInput);
panel.add(qualitificationLabel);
panel.add(qualificationInput);
panel.add(mobileLabel);
panel.add(mobileInput);
panel.add(emailLabel);
panel.add(emailInput);
panel.add(passwordLabel);
panel.add(passwordInput);
panel.add(registerBtn);
panel.add(cancelBtn);
ResultPage.java
package com.oes.pages;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import com.oes.app.Application;
import com.oes.pojos.Result;
private ResultPage() {
super();
name = "OES - Results";
width = 400;
height = 400;
panel = new JPanel();
logoutBtn = new JButton("Logout");
init();
}
nameTextField.setEditable(false);
percentTextField.setEditable(false);
statusTextField.setEditable(false);
resultPanel.add(nameLabel);
resultPanel.add(nameTextField);
resultPanel.add(percentLabel);
resultPanel.add(percentTextField);
resultPanel.add(statusLabel);
resultPanel.add(statusTextField);
return resultPanel;
}
panel.add(resultLabel, BorderLayout.NORTH);
panel.add(getResultPanel(), BorderLayout.CENTER);
panel.add(logoutBtn, BorderLayout.SOUTH);
nameTextField.setText(Application.getInstance().getLoggedInStudent().getFirstName());
percentTextField.setText(result.getPercent()+"%");
statusTextField.setText(result.getStatus().toString());
}
WelcomePage.java
package com.oes.pages;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import com.oes.app.Application;
private WelcomePage() {
super();
name = "OES - Welcome";
width = 400;
height = 400;
panel = new JPanel();
startExamBtn = new JButton("Start Exam");
init();
}
String formatedName =
getFormatedName(Application.getInstance().getLoggedInStudent().getFirstName());
String welcomeMessage = formatedName;
JLabel welcomeLabel = new JLabel(welcomeMessage);
panel.add(welcomeLabel, BorderLayout.NORTH);
panel.add(getExamRulesPanel(), BorderLayout.CENTER);
panel.add(startExamBtn, BorderLayout.SOUTH);
rulePanel.add(ruleLabel, BorderLayout.CENTER);
return rulePanel;
}
Exam.java
package com.oes.pojos;
import java.util.List;
import java.util.stream.Collectors;
import com.oes.data.QuestionData;
Student student;
List<Question> questions;
Question currentQuestion;
int currentQuestionIndex;
int totalQuestionCount;
int attemptedQuestionCount;
int passedQuestionCount;
public Exam() {
this(new QuestionData().getAllQuestions());
}
Options.java
package com.oes.pojos;
@Override
public String toString() {
return "Option [name=" + name + ", value=" + value +
"]";
}
Questions.java
package com.oes.pojos;
import java.util.ArrayList;
import java.util.List;
int id;
String question;
List<Option> options;
Option answer;
boolean isAnswered;
Option userSelectedOption;
public Question() {
isAnswered = false;
options = new ArrayList<Option>();
}
@Override
public String toString() {
return "Question [id=" + id + ", question=" + question + ", options=" + options + ",
answer=" + answer + "]";
}
}
Result.java
package com.oes.pojos;
import com.oes.constants.ResultStatus;
int passCount;
int totalCount;
int percent;
ResultStatus status;
Student.java
package com.oes.pojos;
public Student() {
}
@Override
public String toString() {
return "Student [id=" + id + ", firstName=" + firstName
+ ", lastName=" + lastName + ", qualification="
+ qualification + ", mobile=" + mobile + ",
email=" + email + ", password=" + password + "]";
}
}
Conclusion
This project is MCQ Exam System has come to its final stage. The system has been
developed with much care that it is free of errors and at the same time this project
is less time consuming.
The most important thing is that the system is robust. And also, provision is
provided for future developments in the system. The entered system is secured. The
MCQ system will be approved and successfully implemented.
Bibliography
Reference books:
Websites:
www.javatpoint.com
https://en.wikipedia.org/wiki/EExam
https://sppuexam.in/login