你能帮我弄清楚我的智力竞赛节目视图有什么问题吗?

时间:2016-06-29 09:38:31

标签: ruby-on-rails

show视图中,我想显示所有多项选择问题和答案,并为每个问题添加correct-answerincorrect-answernormal-answer的css类显示答案以表示答案是1.用户正确回答2.用户未正确回答,或3.完全没有回答(用户选择了另一个答案选项)。在我的代码中,@submitted_quiz.submitted_answers包含用户输入的所有答案。

<% question.answers.each do |answer| %>
<% @submitted_quiz.submitted_answers.each do |submitted_answer| %>

<% if(submitted_answer.content == answer.content && submitted_answer.question.id == answer.question.id && submitted_answer.got_correct) %>
<li><span class ='correct-answer'><%= answer.content %> CORRECT </span></li>

<% elsif(submitted_answer.content == answer.content && submitted_answer.question.id == answer.question.id && submitted_answer.got_incorrect) %>
<li><span class ='incorrect-answer'><%= answer.content %> INCORRECT</span></li>

<% else %>
<li><span class ='normal-answer'> <%= answer.content %> NORMAL</span></li>

<% end #  if statement%>

<% end # submitted_answers.each do%>

<% end # question.answers.each do |answer|%>

我知道我做错了什么,但我似乎无法修复它。有什么想法吗?

0 个答案:

没有答案