##回答よろしくお願いします????
https://gyazo.com/0d0cf94922a7eafd4149cd038eea98a7
上記のように表示されているのですが
下記のように、すべて表示されるのではなく、4件ずつ表示する場合はどのようにすればいいのでしょう?
一問目
1 xxx
2 aaa
3 bbb
4 ccc
二問目
1 bweq
2 wrwr
3 ret
4 rtet]
##code
def test_group if params['groups_info'].present? ids=params['groups_info'].split(",") @words = Word.where(group_id:ids) if params['option'] == "通常" @question = 'question' @answer = 'answer' else @question = 'answer' @answer = 'question' end if params["test_mode"]=="選択" @val=[] @words.each do|word| Word.all.sample(3).each do|q| puts @val<<q end @val<<word end render 'selection_question' else render 'question' end end end
現在の問題はselection_questionの表示部分なので、selection_questionだけ
<div class="row"> <div class="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2"> <div class="panel panel-default"> <div class="panel-heading"> <h1>Q&A</h1> </div> <div class="panel-body"> <%= form_tag(action: :create) do %> <%= hidden_field_tag "count", @words.count %> <% @words.each.with_index(1)do |word, n| %> <%if params['test_option'] == "練習"%> <label for=<%= "#{n}"%>><%= "#{n}問目"%>:<%= eval("word.#{@question}")%> (正答: <%= eval("word.#{@answer}") %>)</label><br> <%else%> <label for=<%= "#{n}"%>><%= "#{n}問目"%>:<%= eval("word.#{@question}")%></label><br> <%end%> <%@val.each_slice(4) do|val|%> <ul> <%val.each do|wq|%> <li><label><%= "#{}"%><%=wq.answer%><%=radio_button_tag "#{n}",wq.answer%></label><br></li> <%end%> </ul> <%end%> <%= hidden_field_tag "answer#{n}", eval("word.#{@answer}") %> <% end %> <%= submit_tag "Answer", class: "btn btn-large btn-primary" %> <% end %> </div> </div> </div> </div>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。