1 from . import UserInterface
4 class CommandLineInterface (UserInterface):
7 question = self.get_question()
10 print(question.prompt)
13 a = answer.strip().lower()
14 if a in ['q', 'quit']:
17 if a in ['?', 'help']:
19 print(question.prompt)
23 correct = self.process_answer(question=question, answer=answer)
29 def display_results(self):
31 for question in self.quiz:
32 for answer in self.answers.get(question.id, []):
33 self.display_result(question=question, answer=answer)
36 def display_result(self, question, answer):
41 print('question: {}'.format(question.prompt))
42 print('you answered: {}'.format(answer['answer']))
43 print('which was: {}'.format(correct))
46 def display_totals(self):
47 answered = self.answers.get_answered(questions=self.quiz)
48 correctly_answered = self.answers.get_correctly_answered(
51 lc = len(correctly_answered)
52 print('answered {} of {} questions'.format(la, len(self.quiz)))
53 print(('of the answered questions, {} ({:.2f}) were answered correctly'
54 ).format(lc, float(lc)/la))