Note : You really don’t want to use this software. It is a system designed for research purposes and looking at working of codes for automated data generation.
While teaching some subjects at the Master’s level, I realized that most often marks are not exactly what determines the students. In this case the marks were just arbitrary numbers we assigned to exams based on their everyday performance as well as their experiences relative to the field of study.
So I got the urge to write a program that would arbitrarily assign marks to questions then adds all that up to get to a pre-determined total. This program was created over a day of not finding anything to do and wanting to test out how believable enough a random marks assigner would be.
Let me start with the result (output) of the code that will given a little later and talk about the result.
1 -> [10, 5]
2 -> [5, 10]
3 -> [3]
4 -> [5]
5 -> [5]
6 -> [5]
7 -> [5]
8 -> [8]
9 -> [6]
10 -> [7]
11 -> [5, 5, 5, 5]
[10, 5, 5, 10, 3, 5, 5, 5, 5, 8, 6, 7, 5, 5, 5, 5] 94
From the above, it states that Question 1 had 2 sub-questions, 1 of 10 marks and other of 5 marks. If one looks at question 11, then there are 4 sub-questions of 5 marks each.
The paper is supposed to be marked for a total of 94. [10, 5, 5, 10, 3, 5, 5, 5, 5, 8, 6, 7, 5, 5, 5, 5] is the marks assignment that the software comes up with to get to the 94.
Below is code in its entirety. All code was written in Python 2.7 on Linux Mint.
import random
def generateMarksList():
givenFullMarks = 94
marksDispersal = [[10, 5], [5, 10], [6], [5], [5], [6], [6], [8], [6], [8], [5, 5, 5, 5]]
marksAssign = [1, 2, 3]
marksBlock = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 4]
marksDispersal = sum(marksDispersal, [])
finalAssign = []
if sum(marksDispersal) > givenFullMarks:
while sum(marksAssign) != givenFullMarks:
marksAssign = []
for i in marksDispersal:
if i != 0:
marksAssign.append(random.randint(int(0.6 * i), i))
else:
marksAssign.append(i)
else:
marks = "Marks dispersal is not above given full marks"
startMarker = 0
endMarker = 0
for i in marksBlock:
endMarker = endMarker + i
tempList = marksAssign[startMarker: endMarker]
finalAssign.append(tempList)
startMarker = startMarker + i
for i, j in enumerate(finalAssign):
print i + 1, " -> ", j
print "\n"
print marksAssign, sum(marksAssign)
if __name__ == "__main__":
generateMarksList()
print "Demo!!!..."
The magic in this code happens in the generateMarksList function. Here marks are calculated per question and assigned to a finalAssign variable to get a total of the total marks assigned. This is a bruteforce method where marks start to go upwards from 0 to get to a value that will get the total to given one.
Each mark assigned is allowed to have some leeway in how the marks are assigned to not give full marks to questions if and when possible.
I later used this marks generator to create datasets for my student cluster generator, that has been posted as a blog here — http://www.prjoshi.com/?p=11