Created
October 17, 2013 21:42
-
-
Save shosanna/7032720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
questions = [{"text" => "Hlavni mesto San Marina?","answers" => ["Torino", "San Marino", "Vatikan", "Terst"], "correct" => 1},{"text" => "Kdy byl upalen mistr Jan Hus?", "answers" => ["6.7.1415", "6.6.1414", "6.8.1415", "5.7.1415"],"correct" => 0},{"text" => "Respektovani jineho presvedceni, jinych nazoru je:", "answers" => ["Ochota", "Tolerance", "Ucta", "Duvera"], "correct" => 1}, {"text" => "Telefoni cislo na Hasice je?", "answers" => ["150", "155", "156", "158"], "correct" => 0}, {"text" => "Ktere z nasledujicich slov patri do spisovne cestiny?", "answers" => ["sprtat", "vyhecovat", "unyly", "cimra"], "correct" => 2}, {"text" => "Ktery z nasledujicich jazyku pouziva AZBUKU?", "answers" => ["Bulharstina", "Litevstina", "Rectina", "Rumunstina"], "correct" => 0}, {"text" => "Ktere z nasledujicich slov cteme stejne jako piseme?", "answers" => ["Dialog", "Exhalace", "Pointa", "Atase"], "correct" => 3}, {"text" => "Jak se jmenoval vlastnim jmenem V.I.Lenin?", "answers" => ["Putin", "Rasputin", "Uljanov", "Onegin"], "correct" => 2}, {"text" => "Jak se jmenovala babicka Bozeny Nemcove?", "answers" => ["Palkova", "Pankova", "Patkova", "Nemcova"], "correct" => 1}] | |
score = 0 | |
questions.each do |question| | |
invalid_answer = true | |
while invalid_answer | |
puts question[“text”] | |
question[“answers”].each_with_index do |answer, index| | |
values = [“a”,”b”,”c”,”d”] | |
puts “#{values[index]}) #{answer}” | |
end | |
answer = gets.strip.downcase | |
values = [“a”,”b”,”c”,”d”] | |
if values.index(answer) | |
invalid_answer = false | |
if values.index(answer) == question[“correct”] | |
puts “Spravne!” | |
score += 1 | |
else | |
puts “Spatne” | |
correct_answ_index = question[“correct”] | |
correct_answ = question[“answers”][correct_answ_index] | |
puts “Spravna odpoved je #{correct_answ}” | |
end | |
else | |
puts “Spatny format, prosim odpovezte a,b,c nebo d” | |
end | |
end | |
end | |
puts “GRATULUJI! Ziskla jste #{score} bodu z 9" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment