Wednesday, February 20, 2013

A simple Python based tool for preparing randomized multi-set multiple choice question papers

A simple Python based tool for preparing randomized multi-set multiple choice question papers
Scipy.in 2012, IIT-BPecha Kucha Presentation
December 27-29 2012
Ashish Sharma

The Problem
 A class full of students
 So much to teach
 Frequent, continuous evaluations – QUIZES
 Multiple choice or objective type questions
 Not enough invigilators
 Time constraints
 Quality of evaluations

The Solution
 Randomized multiple choice question papers – orders of questions and answers
 Python - for the randomized text manipulation
 The input is a set of three text (txt or tex) files containing – the questions and the answers,  the header and the footer
 The output is a chosen number question papers containing the same sets of questions and answer choices – both randomly differentiated in terms of order

The Code (download the zip file here: for text & for latex) – imports
import sys, random
import fileinput
from subprocess import call
........
infilename = sys.argv[1]
...........
for line in fileinput.input( infilename ):
...........
random.seed()
...........
call(['latex', outfilename + ".tex"])

A Typical Session – for text only
$ ./otqpr.py

Usage: ./otqpr.py infile.[txt/tex] N
N being the number of versions to be created.
infileH.[txt/tex] and infileF.[txt/tex] must exist to define the header and the footer

$ ls
in1F.txt  in1H.txt  in1.txt  otqpr.py

$ ./otqpr.py in1.txt 3

$ ls
in1F.txt  in1H.txt  in1_OUTV0.txt  in1_OUTV1.txt  in1_OUTV2.txt  in1.txt  otqpr.py

A Typical Session – for latex input$ ./otqpr.py

Usage: ./otqpr.py infile.[txt/tex] N
N being the number of versions to be created.
infileH.[txt/tex] and infileF.[txt/tex] must exist to define the header and the footer

$ ls
Fig2.eps in1F.tex  in1H.tex  in1.tex  otqpr.py

$ ./otqpr.py in1.tex 3

$ ls
Fig2.eps in1F.tex  in1H.tex in1_OUTV0.pdf in1_OUTV1.pdf in1_OUTV2.pdf in1.tex otqpr.py

Typical Outputs – formatted .txt files
VERSION 1
Q. 1: The reason we are not crushed under the atmospheric pressure is
(A) the pressure inside us is almost same as the atmospheric pressure (B) the pressure is too small (C) we are strong enough (D) the resulting force is too small
Q. 2: A force can be providing
(A) neither a push nor a pull (B) either a push or a pull (C) only a pull (D) only a push

VERSION 2
Q. 1: The reason we are not crushed under the atmospheric pressure is
(A) we are strong enough (B) the pressure is too small (C) the pressure inside us is almost same as the atmospheric pressure (D) the resulting force is too small
Q. 4: A force can be providing
(A) neither a push nor a pull (B) either a push or a pull (C) only a push (D) only a pull


Thanks!

No comments:

Post a Comment