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