.
[HamExam.git] / statistic.py
blob71fd55787382c31d7f9522ef042df9d1325f82c9
1 #!/usr/bin/python
2 import sys, string
3 from xml.dom import minidom, Node
4 import os
6 class Statistic:
7 def __init__(self):
8 self.filename="DL-A-2007.stat.xml"
9 self.stat = minidom.parse (self.filename)
10 self.root = self.stat.documentElement
11 self.date = self.root.getAttribute ("date")
12 self.version = self.root.getAttribute ("version")
13 self.name = self.root.getAttribute ("name")
15 id=[]
16 c=[] #correct
17 cs=[]
18 ws=[]
19 w=[] #wrong
20 for q in self.root.getElementsByTagName("question"):
21 id.append (q.getAttribute ("id"))
22 c.append (q.getAttribute ("c"))
23 cs.append (q.getAttribute ("cs"))
24 ws.append (q.getAttribute ("ws"))
25 w.append (q.getAttribute ("w"))
26 a_code=[]
27 a_time=[]
28 a_when=[]
29 answers=[a_code,a_time,a_when]
30 for a in q.childNodes:
31 if a.nodeType == Node.ELEMENT_NODE:
32 a_code.append (a.getAttribute("answer_code"))
33 a_time.append (a.getAttribute("needed_time"))
34 a_when.append (a.getAttribute("datetime"))
36 print id[0],c[0],cs[0],ws[0],w[0],answers
39 #s=Statistic()
40 #print s.date,s.version,s.name