OpenQP

Question Paper Management System

OpenQP generates Question Papers by selecting questions (based on some pre-defined algorithm)from a question bank. The questions are stored in LaTex format in a postgres RDBMS system, that can be accessed from remote computers. Some of the features of the system are:

Program Design

The backbone of the system is a Postgres RDBMS. A table named coursedetails stores the information about all the available courses. Each record of this table represents a course. Each Course has a Table to store the questions and related information. Name of the table is same as the course code. There is a corresponding ‘user’ (with same name) having access rights to it.

Name Data type Description
code varchar Coursecode.
name varchar Course name
subject varchar Subject
degree varchar Degree
syllabusYear varchar Syllabus year
semester varchar semester (First to Eighth)
texLanguage varchar typesetting language
qpmodel varchar Question paper moder 50 marks, 70 marks etc.
duration varchar Duration of the Exam
nmodules varchar Number of Modules(4 to 8), to divide the syllabus
Name Data type Description
qtext varchar Question in LaTex
atext varchar Answer etc. in LaTex
author varchar Author information
modnum int Module Number (Course material divided, upto 8 Modules)
qtype char(1) Question Type A: Short, B: medium, C: essay type
qnum int Question number, starts from 1, maximum is 99 (no gaps)
relations varchar Specify other questions having overlap with this one
mark int Mark
status varchar easy, medium, tough or inactive.
figname varchar name of the figure, if any
figure bytea Figure data, .jpg or .png file

Python programs

Python code has been written to create new courses, Edit their contents and to generate Question papers. Also there is a small program to initialize the database by creating the table named ‘coursedetails’. This program is used only once.

The Question paper generation is done by another Python program, which is called from a web server running PHP script.

Installation

Setting up the Postgres RDBMS

/etc/postgresql/12/main/pg_hba.conf   should have the following lines
local    all           all                     password
host     all           all      127.0.0.1/32   password
host     all           all      0.0.0.0/0      password

Modify /etc/postgresql/12/main/postgresql.conf , to have the line
listen_addresses = '*'          # what IP address(es) to listen on;

Two users named ‘dummy’ and ‘reader’ are created, to be used by all the Question banks. These steps are carried out using the ‘psql’ client program.

create user dummy with password 'dum123'
create user reader with password 'rea123'   # reader password changed later

Create a Database for each question bank. This example assumes the name of the database is ‘QB’. This design requires to create a ROLE having the same name. This ROLE (user) is assigned with a password to login.

$ psql                # replace QB with the database name
postgres=# create role QB with createrole  login password '******';
postgres=# create database QB;
postgres=# grant all on database QB to QB;
postgres=# \q

Initialisation of the Database

python3 initQbank.py hostname QB

Usage

The first step is to create a new course.

python3 Qadmin.py

Qeditor

Adding Questions to a Course.

Fill all the sections (M1 to M8 maximum). Verify it and export to the Database. The editing can be done only locally. To modify an existing Course;

Qeditor

Installation of the Nginx Web Server, PHP and postgres RDBMS

# Setting up OpenQP using nginx, postgresql and php on a newly installed Ubuntu 20.04 
# All commands are issued as root user, working directory is /root

# install the required debian packages
apt update
apt install joe nginx certbot python3-certbot-nginx postgresql php-common php-fpm php-pgsql python3-numpy texlive-xetex fonts-smc-rachana fonts-lohit-deva
apt install python3-psycopg2
apt install texlive-xetex
apt install texlive-lang-arabic
apt install fonts-sil-scheherazade
apt install fonts-smc-rachana
apt install fonts-deva
apt install fonts-lohit-deva

# firewall configuration
ufw default deny incoming; 
ufw default allow outgoing; 
ufw allow OpenSSH;
ufw allow 'Nginx Full';
ufw allow 5432/tcp
ufw enable;

# Nginx configuration files
joe /etc/nginx/sites-available/default

# This is the content of a working configuration file.
server {
    listen 80;
    listen [::]:80;
    root /var/www/html;
    index  index.php index.html index.htm;
    server_name openqp.scischool.in;

    # for PHP7.4 access
    location ~[^/]\.php(/|$) {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
	fastcgi_read_timeout 600;   
    }
}
-------------------------
copy the following files to /var/www/html

index.php
qgen.php
txtQgen.py

chown www-data:www-data /var/www/html   # write permission for web server

systemctl restart nginx

certbot --nginx -d openqp.scischool.in        # get the TLS certificate

Postgres configuration
# Set the postgres HBA configuration to allow a connection using IP protocol

/etc/postgresql/12/main/pg_hba.conf   should have the following lines
local    all           all                     password
host     all           all      127.0.0.1/32   password
host     all           all      0.0.0.0/0      password

Modify /etc/postgresql/12/main/postgresql.conf , to have the line
listen_addresses = '*'          # what IP address(es) to listen on;

systemctl restart postgresql

# Become the postgres user to create the moodle database and user.
sudo -su postgres

$ psql                # replace QB with the database name
postgres=# create role QB with createrole  login password '******';
postgres=# create database QB;
postgres=# grant all on database QB to QB;
postgres=# create user dummy with password 'dum123';
postgres=# create user ro with password 'ro123';
postgres=# \q