1 import questions
, statistic
9 if self
.method
== "BadQuestions":
12 qid
= self
.FindBadQuestion()
13 self
.s
.badquestion
.pop (self
.s
.badquestion
.index (qid
))
14 elif self
.method
== "GoodQuestions":
16 print "Good questions"
17 qid
= self
.FindGoodQuestion()
18 self
.s
.goodquestion
.pop (self
.s
.goodquestion
.index (qid
))
19 elif self
.method
== "NewQuestions":
22 qid
= self
.FindNewQuestion()
23 self
.s
.newquestion
.pop (self
.s
.newquestion
.index (qid
))
25 qid
= self
.FindAnyQuestion()
28 print "Question id:",qid
30 self
.q
.AskQuestion (qid
)
32 self
.question
= self
.q
.question
33 self
.answera
= self
.q
.answera
34 self
.answerb
= self
.q
.answerb
35 self
.answerc
= self
.q
.answerc
36 self
.answerd
= self
.q
.answerd
37 self
.answercorrect
= self
.q
.answercorrect
38 self
.hint
= self
.q
.hint
39 self
.correct
, self
.wrong
, self
.correct_successive
, self
.wrong_successive
= self
.s
.ThisQuestion (self
.id)
41 self
.time0
= time
.time()
43 def EvalQuestion(self
, answer
):
44 if self
.q
.correct
== answer
:
50 print "Answer was:",answer
51 print "Correct was:",self
.q
.correct
53 self
.time1
= time
.time()
54 dt
= self
.time1
-self
.time0
56 tt
= self
.s
.IncreaseCounter (self
.id, c
, self
.q
.RealAnswer(answer
), dt
)
58 self
.s
.goodquestion
.append(self
.id)
60 self
.s
.badquestion
.append(self
.id)
64 def Method(self
,method
="AnyQuestion"):
67 def FindAnyQuestion(self
):
68 return r
.sample(self
.q
.questions
,1)[0]
70 def FindNewQuestion(self
):
71 return r
.sample(self
.s
.newquestion
,1)[0]
73 def FindBadQuestion(self
):
74 return r
.sample(self
.s
.badquestion
,1)[0]
76 def FindGoodQuestion(self
):
77 return r
.sample(self
.s
.newquestion
,1)[0]
82 def CategorizeQuestions(self
):
84 print "Categorize questions"
85 for q
in self
.q
.questions
:
86 if not (q
[0] in self
.s
.goodquestion
):
87 if not (q
[0] in self
.s
.badquestion
):
88 if not (q
[0] in self
.s
.newquestion
):
89 self
.s
.newquestion
.append (q
[0])
91 print "total, good, bad, new:",len(self
.q
.questions
),len(self
.s
.goodquestion
),len(self
.s
.badquestion
),len(self
.s
.newquestion
)
93 def __init__(self
,method
="BadQuestions",catalog
="TechnikA"):
94 if catalog
== "TechnikA":
95 stat
= "TechnikA/DL-A-2007.stat.xml"
96 elif catalog
== "TechnikE":
97 stat
= "TechnikE/DL-E-2007.stat.xml"
98 elif catalog
== "BetriebAE":
99 stat
= "BetriesAE/FIXMEtat.xml" #FIXME
101 self
.question_dir
= catalog
+"/www.oliver-saal.de/software/afutrainer/download/"
102 self
.hint_dir
= catalog
+"/"
103 quest
= self
.question_dir
+ "questions.xml"
105 self
.q
= questions
.Questions(filename
=quest
)
106 self
.s
= statistic
.Statistic(filename
=stat
)
108 self
.CategorizeQuestions()