I tried to do something as simple as possible. See:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
respostas = [
['a', 'b', 'c', 'd', 'e'],
['d', 'c', 'c', 'a', 'd'],
['d', 'c', 'd', 'b', 'a'],
['d', 'c', 'c', 'b', 'e']
];
gabarito = ['d', 'c', 'c', 'b', 'e']
for r_num, resposta in enumerate(respostas):
total = 0;
for g_num, valor in enumerate(gabarito):
# Se a posição do valor do gabarito é o mesmo da resposta e os valores iguais
if resposta[g_num] == valor:
#Suponhamos que cada acerto vale 2 pontos
total = total + 2;
print "O aluno %s tirou %d pontos" % (r_num, total)
When running the above code, the result should be:
O aluno 0 tirou 4 pontos
O aluno 1 tirou 6 pontos
O aluno 2 tirou 6 pontos
O aluno 3 tirou 10 pontos
Assuming you have some notion of python
, notice that the resposta[g_num]
snippet captures through the feedback index the value of one of the responses. This is because, in a template, there is a question number (which would be the index in our case), and therefore should hit both the question number and answer value at the same time.
That's what I got. I do not know if in this case the use of list
would be ideal.