Skip to content

Commit

Permalink
Moved general knowledge to a yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
fiqwrk committed Oct 28, 2017
1 parent f4c5e80 commit 611da3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 14 additions & 0 deletions lib/extreme_startup/general-knowledge.yaml
@@ -0,0 +1,14 @@
---
-
question: which year was Theresa May first elected as the Prime Minister of Great Britain
answer: 2016
-
question: which city is the Eiffel tower in
answer: Paris
-
question: what colour is a banana
answer: yellow
-
question: who played James Bond in the film Dr No
answer: Sean Connery

14 changes: 4 additions & 10 deletions lib/extreme_startup/question_factory.rb
Expand Up @@ -315,20 +315,14 @@ def correct_answer
class GeneralKnowledgeQuestion < Question
class << self
def question_bank
[
["in which year was Theresa May first elected as the Prime Minister of Great Britain", "2016"],
["which city is the Eiffel tower in", "Paris"],
["what currency did Spain use before the Euro", "peseta"],
["what colour is a banana", "yellow"],
["who played James Bond in the film Dr No", "Sean Connery"]
]
return YAML.load_file(File.join(File.dirname(__FILE__), "general-knowledge.yaml"))
end
end

def initialize(player)
question = GeneralKnowledgeQuestion.question_bank.sample
@question = question[0]
@correct_answer = question[1]
quiz_card = GeneralKnowledgeQuestion.question_bank.sample
@question = quiz_card["question"]
@correct_answer = quiz_card["answer"]
end

def as_text
Expand Down

0 comments on commit 611da3a

Please sign in to comment.