1 import questions
, statistic
9 if self
.method
== "BadQuestions":
12 qid
= self
.FindBadQuestion()
13 elif self
.method
== "GoodQuestions":
15 print "Good questions"
16 qid
= self
.FindGoodQuestion()
17 elif self
.method
== "NewQuestions":
20 qid
= self
.FindNewQuestion()
22 qid
= self
.FindAnyQuestion()
25 print "Question id:",qid
27 self
.q
.AskQuestion (qid
)
29 self
.question
= self
.q
.question
30 self
.answera
= self
.q
.answera
31 self
.answerb
= self
.q
.answerb
32 self
.answerc
= self
.q
.answerc
33 self
.answerd
= self
.q
.answerd
34 self
.answercorrect
= self
.q
.answercorrect
35 self
.hint
= self
.q
.hint
36 self
.correct
, self
.wrong
, self
.correct_successive
, self
.wrong_successive
= self
.s
.ThisQuestion (self
.id)
38 self
.time0
= time
.time()
40 def EvalQuestion(self
, answer
):
41 if self
.q
.correct
== answer
:
47 print "Answer was:",answer
48 print "Correct was:",self
.q
.correct
50 self
.time1
= time
.time()
51 dt
= self
.time1
-self
.time0
53 self
.s
.IncreaseCounter (self
.id, c
, self
.q
.RealAnswer(answer
), dt
)
57 def Method(self
,method
="AnyQuestion"):
60 def FindAnyQuestion(self
):
61 return r
.sample(self
.q
.questions
,1)[0]
63 def FindNewQuestion(self
):
64 return r
.sample(self
.s
.newquestion
,1)[0]
66 def FindBadQuestion(self
):
67 return r
.sample(self
.s
.badquestion
,1)[0]
69 def FindGoodQuestion(self
):
70 return r
.sample(self
.s
.newquestion
,1)[0]
75 def CategorizeQuestions(self
):
77 print "Categorize questions"
78 for q
in self
.q
.questions
:
79 if not (q
[0] in self
.s
.goodquestion
):
80 if not (q
[0] in self
.s
.badquestion
):
81 if not (q
[0] in self
.s
.newquestion
):
82 self
.s
.newquestion
.append (q
[0])
84 print "total, good, bad, new:",len(self
.q
.questions
),len(self
.s
.goodquestion
),len(self
.s
.badquestion
),len(self
.s
.newquestion
)
86 def __init__(self
,method
="BadQuestions",catalog
="TechnikA"):
87 if catalog
== "TechnikA":
88 stat
= "TechnikA/DL-A-2007.stat.xml"
89 elif catalog
== "TechnikE":
90 stat
= "TechnikE/DL-E-2007.stat.xml"
91 elif catalog
== "BetriebAE":
92 stat
= "BetriesAE/FIXMEtat.xml" #FIXME
94 self
.question_dir
= catalog
+"/www.oliver-saal.de/software/afutrainer/download/"
95 self
.hint_dir
= catalog
+"/"
96 quest
= self
.question_dir
+ "questions.xml"
98 self
.q
= questions
.Questions(filename
=quest
)
99 self
.s
= statistic
.Statistic(filename
=stat
)
101 self
.CategorizeQuestions()