Created
October 17, 2013 17:54
-
-
Save shosanna/7029333 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
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