.
[HamExam.git] / framework.py
blob74206a5a13ce18fb9fa24e203c832e93239fb693
1 import questions, statistic
2 import random as r
4 class Framework:
5 def AskQuestion(self):
6 if self.method == "BadQuestions":
7 qid = self.FindBadQuestion()
8 elif self.method == "GoodQuestions":
9 qid = self.FindGoodQuestion()
10 elif self.method == "NewQuestions":
11 qid = self.FindNewQuestion()
12 else:
13 qid = self.FindAnyQuestion()
15 self.q.AskQuestion (qid)
16 self.id = qid
17 self.question = self.q.question
18 self.answera = self.q.answera
19 self.answerb = self.q.answerb
20 self.answerc = self.q.answerc
21 self.answerd = self.q.answerd
22 self.answercorrect = self.q.answercorrect
23 self.hint = self.q.hint
24 self.correct, self.wrong = self.s.ThisQuestion (self.id)
26 def EvalQuestion(self, answer):
27 if self.q.correct == answer:
28 c = True
29 else:
30 c = False
32 self.s.IncreaseCounter (self.id, c, answer)
34 return c
36 def FindAnyQuestion(self):
37 nq = int (r.random()*self.q.nquestions)
38 return self.q.questions[nq][0]
40 def FindNewQuestion(self):
41 return
43 def FindBadQuestion(self):
44 return
46 def FindGoodQuestion(self):
47 return
49 def __init__(self):
50 self.q = questions.Questions()
51 self.s = statistic.Statistic()
52 self.method = ""