From: ga rg Date: 2007-12-21T12:03:22+09:00 Subject: Random Positioning of Radio Form Items? I made a short multiple choice quiz in ruby using erb in an rhtml page. I have an array of arrays: @allanswers = [["thailand", "jamaica", "nairobi", "indonesia"], ["lincoln", "kennedy", "roosevelt", "reagan"], ["brazil", "canada", "columbia", "peru"], ["nelson", "bart", "kennedy", "jack"]] and then I want to have the multiple choice options in a random order. Meaning that every time a person refreshes the page, the order of the choices changes. <% 4.times do |num|%> <%=first%>
<%end%> where @allanswers is the array of arrays. @questionNum is an iterator in the code elsewhere The obvious problem with this method is that the rand(num) ends up giving duplicate options. What elegant solution can you think for this problem? Basically, I just want to get random but unique numbers. Thank you for reading. -- Posted via http://www.ruby-forum.com/.