Ejemplo n.º 1
0
	All the log_files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
	sys.exit()

else:
	answerTime = 0
	answerIndex = 0
	#displayIndex = 0

	# declare a list to store differences of display time
	displayTime = [0] * quiz_library.compute_question_count(quiz_library.load_quiz_log(sys.argv[1]))

	# declare a list to store the display time difference
	timeDifference = [0] * quiz_library.compute_question_count(quiz_library.load_quiz_log(sys.argv[1]))

	# declare a list to store the average time of each question
	avgTime = [0] * quiz_library.compute_question_count(quiz_library.load_quiz_log(sys.argv[1]))

	for i in range(1, len(sys.argv)):
		# loop every list to get information of display time
		for j in quiz_library.load_quiz_log(sys.argv[i]):
			if isinstance(j,quiz_library.Display):
				# get every display time and check whether it is the last display 
				if displayTime[int(j.index)] <= int(j.time) and displayTime[int(j.index)] != 0:
					specialCase = 0
				# store the display time if it is not the last one
Ejemplo n.º 2
0
import libxml2
import sys
import quiz_library

"""
purpose
	Accept 1 or more log file names on the command line.
	For each log file
		write to standard output the course mark for the log file,
		in CSV format
preconditions
	Each command-line argument is the name of a legal, readable quiz log file.

	All of the log files have the same number of questions.
"""

# handle command line arguments
if len(sys.argv) < 2:
    print "Syntax:", sys.argv[0], "quiz_log_file ..."
    sys.exit()
else:
    # loop the list according to the input
    for i in range(len(sys.argv) - 1):
        mark = 0
        for j in quiz_library.compute_mark_list(quiz_library.load_quiz_log(sys.argv[i + 1])):
            # calculate mark according to the result in the list
            mark = mark + int(j)
        courseMark = sys.argv[i + 1] + "," + str(mark)
        print courseMark
Ejemplo n.º 3
0
import quiz_library

'''
purpose
	Accept 1 or more log file names on the command line.
	For each log file
		write to standard output the course mark for the log file,
		in CSV format
preconditions
	Each command-line argument is the name of a legal, readable quiz log file.

	All of the log files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
	sys.exit()

# iterate through all command line arguments counting the number of correct answers
for i in range(1,len(sys.argv)):
	quiz_mark = 0
	log_list = quiz_library.load_quiz_log(sys.argv[i])
	mark_list = quiz_library.compute_mark_list(log_list)

	# count the correct results
	for mark in mark_list:
		if mark == 1:
			quiz_mark += 1

	print sys.argv[i] + "," + str(quiz_mark)
Ejemplo n.º 4
0
import libxml2
import sys
import quiz_library
'''
purpose
	Accept 1 or more log file names on the command line.
	For each log file
		write to standard output the course mark for the log file,
		in CSV format
preconditions
	Each command-line argument is the name of a legal, readable quiz log file.

	All of the log files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
    print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
    sys.exit()

l = 1
while (l < len(sys.argv)):
    k = 0
    log_list = quiz_library.load_quiz_log(sys.argv[l])
    marker = quiz_library.compute_mark_list(log_list)
    for x in range(0, len(marker)):
        if (marker[x] == 1):
            k = k + 1
    print sys.argv[l] + "," + str(k)
    l = l + 1
preconditions
	Each command-line argument is the name of a readable and
	legal quiz log file.

	All the log_files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
    print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
    sys.exit()

totals = []

for f in sys.argv[1:]:
    data = quiz_library.load_quiz_log(f)
    if not totals:
        totals = [0] * (quiz_library.compute_question_count(data))
    start = [None] * (quiz_library.compute_question_count(data))
    counter = 0
    for el in data:
        if isinstance(el, quiz_library.Answer) and type(el.result) != int:
            continue
        if el.index != counter:
            if start[counter] != None:
                totals[counter] += el.time - start[counter]
            counter = el.index
        if start[counter] == None:
            start[counter] = el.time
        if el == data[-1]:
            totals[counter] += el.time - start[counter]
Ejemplo n.º 6
0
	All the log_files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
    print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
    sys.exit()

else:
    answerTime = 0
    answerIndex = 0
    #displayIndex = 0

    # declare a list to store differences of display time
    displayTime = [0] * quiz_library.compute_question_count(
        quiz_library.load_quiz_log(sys.argv[1]))

    # declare a list to store the display time difference
    timeDifference = [0] * quiz_library.compute_question_count(
        quiz_library.load_quiz_log(sys.argv[1]))

    # declare a list to store the average time of each question
    avgTime = [0] * quiz_library.compute_question_count(
        quiz_library.load_quiz_log(sys.argv[1]))

    for i in range(1, len(sys.argv)):
        # loop every list to get information of display time
        for j in quiz_library.load_quiz_log(sys.argv[i]):
            if isinstance(j, quiz_library.Display):
                # get every display time and check whether it is the last display
                if displayTime[int(j.index)] <= int(
Ejemplo n.º 7
0
	The pass ratio for a question is the number of passes
	divided by the number of passes + fails.
preconditions
	Each command-line argument is the name of a
	readable and legal quiz log file.

	All the log_files have the same number of questions.
'''

# check number of command line arguments
if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
	sys.exit()

ls=[]
lspass=[]

for f in sys.argv[1:]:
	marks=quiz_library.compute_mark_list(quiz_library.load_quiz_log(f))
	if not ls:
		ls=[0]*len(marks)
		lspass=[0]*len(marks)
	for i,j in enumerate(marks):
		if j:
			lspass[i]+=1
		ls[i]+=1

ls=[str(i/float(j)) for i,j in zip(lspass,ls)]

print ','.join(ls)
Ejemplo n.º 8
0
preconditions
	Each command-line argument is the name of a readable and
	legal quiz log file.

	All the log_files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
	sys.exit()

# Determine the maximum number of questions evaluated
max_questions = -1
for n in sys.argv[1:]:
	log_list = quiz_library.load_quiz_log(n)
	if (quiz_library.compute_question_count(log_list)>max_questions):
		max_questions=quiz_library.compute_question_count(log_list)
# Create lists of corresponding size, tracking the total time for each question, and the number of students who tried each question
totalTime = [0.0]*max_questions
numPeople = [0.0]*max_questions

for n in sys.argv[1:]:
	# Iterate through each log element in the given log_list, and record the time spent on each question.
	log_list = quiz_library.load_quiz_log(n)
	myTime = [0.0]*quiz_library.compute_question_count(log_list)

	lastIndex = 0
	timeStamp = 0
	firstInstance = True
	for x in log_list:
import libxml2
import sys
import quiz_library

'''
purpose
	Accept 1 or more log file names on the command line.
	For each log file
		write to standard output the course mark for the log file,
		in CSV format
preconditions
	Each command-line argument is the name of a legal, readable quiz log file.

	All of the log files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
	sys.exit()

for n in sys.argv[1:]:
	# Simply summate the number of marks obtained from each question.
	print n+","+str(sum(quiz_library.compute_mark_list(quiz_library.load_quiz_log(n))))
Ejemplo n.º 10
0
	For each log file, compute the total time taken for each question. 

	Write to standard output, the average time spent for each question.
preconditions
	Each command-line argument is the name of a readable and
	legal quiz log file.

	All the log_files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
	sys.exit()

number_of_questions = quiz_library.compute_question_count(quiz_library.load_quiz_log(sys.argv[1]))
time_taken_list = [0.0] * number_of_questions

# iterate through all command line arguments
for i in range(1,len(sys.argv)):
	log_list = quiz_library.load_quiz_log(sys.argv[i])

	initial_time = None
	current_index = None

	# sum the time spent on each question (computed as time where question 2 is displayed minus time where question 1 is displayed)
	for item in log_list:
		if isinstance(item, quiz_library.Display):
			if initial_time is not None:
				elapsed_time = item.time - initial_time
				time_taken_list[current_index] += float(elapsed_time)
	All the log_files have the same number of questions.
'''

# check number of command line arguments
if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
	sys.exit()

passes = []
fails = []

for n in sys.argv[1:]:
	index_ = 0
	# Determine whether the question was passed or failed by the current student
	# And increment the corresponding pass/fail counter
	for x in quiz_library.compute_mark_list(quiz_library.load_quiz_log(n)):
		if (index_+1>len(passes)):
			passes.append(0)
			fails.append(0)
		if (x!=0 and x!=None):
			passes[index_]+=1.0
		else:
			fails[index_]+=1.0
		index_+=1

output = ""
index_ = 0
for n in passes:
	# Calculate the average pass ratio for each question.
	output += str((passes[index_])/(passes[index_]+fails[index_]))
	if (index_!=len(passes)-1):
Ejemplo n.º 12
0
	readable and legal quiz log file.

	All the log_files have the same number of questions.
'''

# check number of command line arguments
if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
	sys.exit()
else:

	marks = 0
	ratio = ''
	
	# loop the list according to the input
	for i in range(len(quiz_library.compute_mark_list(quiz_library.load_quiz_log(sys.argv[1])))):
		for j in range(len(sys.argv) - 1):
			marks = marks + int(quiz_library.compute_mark_list(quiz_library.load_quiz_log(sys.argv[j + 1]))[i])

		# calculate the ratio and store the result to string ratio	
		ratio = ratio + ',' + str(float(marks) / (len(sys.argv) - 1))

		# initialize marks
		marks = 0
	
	# print the ratio
	i = 1
	finalRatio = ''
	while i in range(len(ratio)):
		finalRatio = finalRatio + ratio[i]
		i = i + 1
Ejemplo n.º 13
0
import libxml2
import sys
import quiz_library
'''
purpose
	Accept 1 or more log file names on the command line.
	For each log file
		write to standard output the course mark for the log file,
		in CSV format
preconditions
	Each command-line argument is the name of a legal, readable quiz log file.

	All of the log files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
    print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
    sys.exit()
else:
    # loop the list according to the input
    for i in range(len(sys.argv) - 1):
        mark = 0
        for j in quiz_library.compute_mark_list(
                quiz_library.load_quiz_log(sys.argv[i + 1])):
            # calculate mark according to the result in the list
            mark = mark + int(j)
        courseMark = sys.argv[i + 1] + "," + str(mark)
        print courseMark
	For each log file, compute the total time taken for each question. 

	Write to standard output, the average time spent for each question.
preconditions
	Each command-line argument is the name of a readable and
	legal quiz log file.

	All the log_files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...' #must have legal arguments supplied on the command line
	sys.exit()

initQ = quiz_library.load_quiz_log(sys.argv[1]) #since it is guarenteed that each log_file will have the same number
q = quiz_library.compute_question_count(initQ)  #of questions, initialize the question counter to the fist file.


for y in range(0, q): #goes through each question in the log files
	time = []
	for x in range(1, len(sys.argv)): #for each question, goes through all the log_files
		difference = [0, 0]
		log_list = quiz_library.load_quiz_log(sys.argv[x])
		for z in log_list:
			if int(z.index) == y and isinstance(z, quiz_library.Display): #the first 'Display' object
				if difference[0] == 0:                                #of a given question
					difference[0] = z.time #time 1

			elif int(z.index) == (y+1) and isinstance(z, quiz_library.Display): #the 'Display' objct of
				if difference[1] == 0:                                      #the next question
Ejemplo n.º 15
0
import libxml2
import sys
import quiz_library
'''
purpose
	Accept 1 or more log file names on the command line.
	For each log file
		write to standard output the course mark for the log file,
		in CSV format
preconditions
	Each command-line argument is the name of a legal, readable quiz log file.

	All of the log files have the same number of questions.
'''

# handle command line arguments
if len(sys.argv) < 2:
    print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
    sys.exit()

for f in sys.argv[1:]:
    print f + ',' + str(
        quiz_library.compute_mark_list(quiz_library.load_quiz_log(f)).count(1))
Ejemplo n.º 16
0
	print 'Syntax:', sys.argv[0], 'quiz_log_file ...'
	sys.exit()


passRatioList = []
totalQuestions = 0
length = len(sys.argv) - 1



'''
Loop through each question and continue to do so until the number of 
evaluated questions equals the total number of questions across the XML files
'''

while totalQuestions != quiz_library.compute_question_count(quiz_library.load_quiz_log(sys.argv[length])):
	correctQs = 0.0
	
	for q in sys.argv[1:]:
		count = 0		
		log_string = quiz_library.load_quiz_log(q)
		
		for x in log_string:
		
			if isinstance(x, quiz_library.Answer):	
				if int(x.index) == totalQuestions:
					#print "The result of x is " + str(x.result)					
					if str(x.result) == "1":
						count = 1
		if count == 1:
			correctQs+= 1