In my quiz i have created a questions table with numbers it is used for whether the question is answered or not. if it answered the visited column in answer table goes to 1 or else 0 as
+----+--------+--------------+---------+---------------+------------+-------+---------+
| id | answer | questions_id | user_id | exam_group_id | modules_id | marks | visited |
+----+--------+--------------+---------+---------------+------------+-------+---------+
| 1 | ans2 | 8 | 3 | 1 | 1 | 0 | 1 |
| 2 | NULL | 9 | 3 | 1 | 1 | 0 | 0 |
| 3 | NULL | 6 | 3 | 1 | 1 | 0 | 0 |
| 4 | ans1 | 5 | 3 | 1 | 2 | 1 | 1 |
| 5 | NULL | 4 | 3 | 1 | 2 | 0 | 0 |
| 6 | NULL | 3 | 3 | 1 | 2 | 0 | 0 |
+----+--------+--------------+---------+---------------+------------+-------+---------+
and i checked the questions based on visited in my view page as like
<% @slno = 0 %>
<ul class="student_list">
<% @questions.each do |s| %>
<% @slno = @slno + 1 %>
<% if ((Answer.find_by_sql["SELECT visited from answers where questions_id=#{s.id}"]) == 1) %>
<li class="student_names">
<a href="#" id="<%=s.id%>" class="student-link" > <%= @slno %></a>
</li>
<% else %>
<li class="student_names2">
<a href="#" id="<%=s.id%>" class="student-link2" > <%= @slno %></a>
</li>
<% end %>
<% end %>
</ul>
but it gives the error as wrong number of arguments (0 for 1)