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]

print ','.join(map(str, [float(i) / len(sys.argv[1:]) for i in totals]))
Example #2
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
	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:
Example #4
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(
Example #5
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)
	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
					difference[1] = z.time #time 2
	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
Example #8
0
import libxml2
import sys
import quiz_library

print '-------------------- test load_quiz_log'

log_list = quiz_library.load_quiz_log(sys.argv[1])

for x in log_list:
    if isinstance(x, quiz_library.Answer):
        print 'Answer:', x.index, x.path, x.result, x.answer, x.time
    else:
        print 'Display:', x.index, x.path, x.time

print '-------------------- test compute_question_count'

question_count = quiz_library.compute_question_count(log_list)
print question_count

print '-------------------- test compute_mark_list'

mark_list = quiz_library.compute_mark_list(log_list)
print mark_list
import libxml2
import sys
import quiz_library

print '-------------------- test load_quiz_log'

log_list = quiz_library.load_quiz_log(sys.argv[1])

for x in log_list:
	if isinstance(x, quiz_library.Answer):
		print 'Answer:', x.index, x.path, x.result, x.answer, x.time
	else:
		print 'Display:', x.index, x.path, x.time

print '-------------------- test compute_question_count'

question_count = quiz_library.compute_question_count(log_list)
print question_count

print '-------------------- test compute_mark_list'

mark_list = quiz_library.compute_mark_list(log_list)
print mark_list