A course elective preference collection and allocation system built for the Post-Graduate Program in Software Enterprise Management (PGSEM) at the Indian Institute of Management, Bangalore (IIM-B).
Students submit prioritized course preferences through a web interface. The allocation engine then assigns courses using a multi-factor ranking algorithm that considers seniority, course priority, and CGPA.
Allocation Process and Rules — the original instructions page explaining how the system works, with worked examples.
This system was developed in 2006-2007 and used for quarterly elective allocation cycles starting Q4 2005-06 and continuing for a few years. The codebase is ~5,200 SLOC of Perl across 21 files. The original version control was CVS; this repository was reconstructed from those CVS archives in 2026 with proper commit history, conventional commit messages, and PII removed.
- Sankaranarayanan Viswanathan (@kvsankar)
- Abhay Ghaisas (@abhayghaisas)
┌─────────────────────────────────────────────────┐
│ Web Interface │
│ electives.cgi summary.cgi feedback.cgi ... │
└──────────────────────┬──────────────────────────┘
│ CGI / DBI
┌────────┴────────┐
│ MySQL (pgsem) │
└────────┬────────┘
│ reads choices from DB / files
┌────────┴────────┐
│ elec.pl │ ← allocation engine
│ (batch mode) │
└────────┬────────┘
│ reads
┌──────────┬───────┴───────┬──────────────┐
│ │ │ │
courses.txt students.txt choices.txt project_students.txt
| File | Purpose |
|---|---|
elec.pl |
Core allocation engine — reads input files, runs the algorithm, writes results |
electives.cgi |
Main CGI web app — student login, preference submission, results display |
Elec.pm |
Shared module — data structures and loaders for courses, students, choices |
ElecConfig.pm |
Configuration module — reads config.txt key-value pairs |
ElecUtils.pm |
Utility functions — err_print(), skip_line() |
summary.cgi |
Admin summary of submitted preferences by course |
summarytext.cgi |
Plain-text variant of summary |
feedback.cgi |
Student feedback collection |
feedbackresults.cgi |
Display collected feedback |
p3results.cgi |
Phase 3 allocation results display |
passcode.cgi |
Generate and email login passcodes |
dblog.cgi |
Admin view of database log entries |
project.cgi |
Project assignment management |
graduation.cgi |
Convocation/graduation candidate management |
graduation-profiles.cgi |
Individual graduation profile display |
mailresults.pl |
Email allocation results to students |
sendmails.pl |
Bulk email sending utility |
sendphaseonemails.pl |
Phase 1 opening notification emails |
genstudents.pl |
Test data generator for student roll numbers |
parselog.pl |
Log file parser |
pgsem-schema.sql |
MySQL database schema (authcode, choices, changes, log) |
The system uses a three-phase allocation process:
Students submit the number of courses they plan to take and a prioritized list of preferences (non-binding). This data is used to schedule classes and minimize conflicts.
Students submit binding preferences. The engine allocates courses based on:
- Seniority (
older_and_lazy_rule): Earlier batch students who haven't completed >=93 credits get priority. Students who missed Phase 1 or Phase 2A lose seniority. - Course priority: Within a seniority bucket, students who ranked a course higher get priority.
- CGPA: Tie-breaker within the same seniority and priority level.
- Roll number: Final tie-breaker (lower roll number wins).
A student gets a course unless:
- They've been allocated all courses they requested
- Their CGPA limits them (< 2.75 → max 3 courses; < 2.75 with project → max 2)
- A higher-priority course was already allocated in the same time slot
- The course reached its capacity cap
Students can request to add, drop, or swap courses subject to capacity and schedule constraints.
A snapshot of the allocation engine's Excel output showing per-course student rankings, priorities, and allocation status (student names masked).
All data files use semicolon-delimited fields. Lines starting with #
are comments; blank lines are skipped.
# code; name; instructor; cap; slot; status; site; barred
CS101; Data Structures; Prof. Sharma; 60; 1; A; B;
FIN201; Corporate Finance; Prof. Rao; 50; 2; A; B+C;
- status:
A(active),D(dropped),N(not available) - site:
B(Bangalore),C(Chennai),B+C(distributed) - barred: year (e.g.,
2005) — batch barred from this course
# rollno; name; email; cgpa; credits; site
2004101; Student Name; student@example.com; 3.45; 72; B
# rollno; ncourses; comma-separated-courses (priority order)
2004101; 3; CS101,FIN201,MKT301
Note: the course list is comma-separated within the third semicolon-delimited field.
# one roll number per line
2004105
2004110
phase=2
adminpassword=changeme
datasource=DBI:mysql:database=pgsem;host=localhost
dblogin=pgsem
dbpassword=changeme
quarter_str=2006-07 Quarter 2 (September - November 2006)
quarter_starts_str=Sep. 2006
send_email=0
pop_required=0
deadline=2006-08-20
moodle_url=http://localhost/moodle
max_cgpa=4.0
min_cgpa_four_courses=2.75
min_credits=0
credits_pass=93
current_year=2004
max_courses=4
default_cap=65
default_mincap=15
default_status=A
default_site=B
default_cgpa=4.0
give_priority_to_seniors=1
give_priority_to_cgpa=1
- Perl 5.x with modules:
DBI,Spreadsheet::WriteExcel,POSIX - MySQL (for the web interface; not required for batch allocation)
cd test/
PERL5LIB=.. perl ../elec.plThis reads from the current directory:
config.txt— allocation parameterscourses-internal.txt— course catalog (internal format with single-site rows)students.txt— student rosterchoices.txt— submitted preferencesproject-students.txt— students doing projectschoices-p1.txt— Phase 1 participant roll numbersp2a-students.txt,p2-students.txt— Phase 2 participant lists
Output goes to stdout and allocation-internal.txt. An Excel workbook
(allocation.xls) is also generated if Spreadsheet::WriteExcel is
installed.
- Create the MySQL database:
mysql < pgsem-schema.sql - Configure
config.txtwith database credentials - Deploy CGI scripts to a web server with CGI support
- Access
electives.cgithrough the browser
The project includes a CI pipeline (GitHub Actions)
and a complete set of synthetic test fixtures in test/.
The test/ directory contains everything needed to run the allocation
engine without a database: 10 courses, 21 synthetic students across
3 batches (2003–2005), and realistic preference data. The data is
designed to exercise:
- Seniority ranking: 2003 batch students are allocated before 2004, then 2005
- Seniority loss: student 2003106 has >=93 credits and loses seniority privilege
- Schedule conflict detection: courses sharing the same time slot cannot both be allocated to one student
- CGPA-based tie-breaking: within the same seniority and priority
- Project student handling: project students get one fewer elective slot
On every push and pull request, CI runs three checks:
- Syntax check —
perl -con all.pl,.pm, and.cgifiles - Allocation test — runs the engine against test fixtures and verifies allotments, course/student output sections, seniority ordering, schedule conflict detection, and Excel workbook generation
- PII scan — ensures no student email addresses or data files are present in the repository
.
├── Elec.pm # Core data module
├── ElecConfig.pm # Configuration reader
├── ElecUtils.pm # Utility functions
├── elec.pl # Allocation engine (batch)
├── electives.cgi # Web interface (CGI)
├── pgsem-schema.sql # Database schema
├── test/ # Test fixtures (synthetic data, no PII)
│ ├── config.txt # Sample configuration
│ ├── courses.txt # Sample courses (display format)
│ ├── courses-internal.txt # Sample courses (allocation format)
│ ├── students.txt # 21 synthetic students across 3 batches
│ ├── choices.txt # Synthetic preferences
│ ├── choices-p1.txt # Phase 1 participant list
│ ├── p2a-students.txt # Phase 2A participant list
│ ├── p2-students.txt # Phase 2 participant list
│ └── project-students.txt # Students doing projects
├── docs/ # GitHub Pages site
│ ├── index.html
│ └── electives-allocation.html
├── sankara.net/ # Original project website (archived)
│ ├── electives-allocation.html
│ └── pgsem/
└── [other CGI scripts and utilities]
The original allocation rules and instructions page is hosted via GitHub Pages at https://iimb-pgsem.github.io/electives/
- main: Full CVS history (Jan 2006 – Mar 2007), 132 commits
- deployment-fork: Fork from Aug 2006 adapted for Linux web hosting,
adds
ConfigDir.pm,images.cgi,.htaccess
This work was supported by Professor Rajendra K Bandi, ex PGSEM Chairperson at IIM Bangalore (LinkedIn, Chanakya University).
MIT — Copyright (c) 2006-2007 Sankaranarayanan Viswanathan and Abhay Ghaisas.
