/app/views/user/notes/_question_with_answer.erb
Ruby HTML | 147 lines | 137 code | 5 blank | 5 comment | 36 complexity | dac05fce8f350d86cb7e59cf4fdf99ee MD5 | raw file
- <div class="part_div">
- <div class="part_question">
- <% unless question_with_answer[1].elements['title'].nil? or question_with_answer[1].elements['title'].text.nil? or question_with_answer[1].elements['title'].text == "" %>
- <% if question_with_answer[1].elements['title'].text.length > 250 %>
- <div class="chank_yw"><a href="javascript:void(0);" onclick="openwindow(<%= question_with_answer[0].attributes["id"] %>);">查看全文</a></div>
- <% end %>
- <div class="part_q_text part_q_sl">
- <% title = question_with_answer[1].elements["title"].text
- if title.length > 250 %>
- <div class="question_text_div">
- <% if title =~ /<mp3>/ %>
- <%= truncate_u(title.split("<mp3>")[0].to_s.html_safe.gsub(/<[^{><}]*>/, ""), 180, "......").to_s.html_safe %>
- <% else %>
- <%= truncate_u(title.to_s.html_safe.gsub(/<[^{><}]*>/, ""), 180, "......").to_s.html_safe %>
- <% end %>
- </div>
- <% else
- if title =~ /<mp3>/ %>
- <div class="question_text_div" style="word-wrap:break-word; word-break:break-all;">
- <%= title.split("<mp3>")[0].to_s.html_safe %>
- </div>
- <div id="mp3_<%= question_with_answer[0].attributes["id"] %>">
- <input type="hidden" id="mp3_value_<%= question_with_answer[0].attributes["id"] %>"
- value="<%= Constant::BACK_SERVER_PATH %><%= title.split("<mp3>")[1] %>" />
- </div>
- <% else %>
- <div class="question_text_div" style="word-wrap:break-word; word-break:break-all;">
- <%= title.to_s.html_safe %>
- </div>
- <% end
- end %>
- <div style="display:none;" id="title_<%= question_with_answer[0].attributes["id"] %>">
- <%= question_with_answer[1].elements["title"].text.to_s.html_safe %>
- </div>
- <%= render :partial=>"/common/more_blanks", :object=> question_with_answer[1] %>
- </div>
- <% end %>
- <!--题目内容-->
- <% attrs_str = question_with_answer[0].elements["questionattrs"].text
- attrs_array = attrs_str.split(";-;") unless attrs_str.nil?
- correct_type = question_with_answer[0].attributes["correct_type"]
- answer = question_with_answer[0].elements["answer"]
- answers = []
- answer.text.split(";|;").collect { |item| answers << item.strip } unless answer.nil? or answer.text.nil?
- user_answer = question_with_answer[0].elements["user_answer"]
- user_answers = []
- user_answer.text.split(";|;").collect {|item| user_answers << item.strip } unless user_answer.nil? or user_answer.text.nil?
- is_right = false
- all_answer = answers | user_answers
- is_right = true if all_answer == answers and answers - user_answers == [] %>
- <div class="p_question_list <% if is_right %>question_yes<% else %>question_no<% end %>">
- <!--[if IE 6]><table><tr><td valign="top"><![endif]-->
- <div class="p_q_l_left"></div>
- <!--[if IE 6]></td><td><![endif]-->
- <div class="p_q_l_right_s">
- <% unless question_with_answer[0].elements["description"].nil? or question_with_answer[0].elements['description'].text.nil? or
- question_with_answer[0].elements['description'].text == "" %>
- <% if correct_type.to_i == Problem::QUESTION_TYPE[:MORE_BLANKS] %>
- <div class="q_drag_con" style="word-wrap:break-word; word-break:break-all;">
- <p><%= question_with_answer[0].elements["description"].text.to_s.html_safe.
- gsub("problem_x_dropplace", "problem_#{question_with_answer[0].attributes["id"]}_dropplace") %>
- </p>
- <script type="text/javascript">
- droppable_result('<%= answers.join(",") %>', '<%= user_answers.join(",") %>', <%= question_with_answer[0].attributes["id"] %>);
- </script>
- </div>
- <% else %>
- <div class="question_title" style="word-wrap:break-word; word-break:break-all;">
- <%= question_with_answer[0].elements["description"].text.to_s.html_safe %>
- </div>
- <% end %>
- <% end %>
- <% if (correct_type.to_i == Problem::QUESTION_TYPE[:MORE_CHOSE] or
- correct_type.to_i == Problem::QUESTION_TYPE[:SINGLE_CHOSE]) %>
- <ul class="chooseQuestion">
- <% (0..attrs_array.length-1).each do |i|
- is_answer = answers.include?(attrs_array[i].strip)
- is_user_answer=user_answers.include?(attrs_array[i].strip) %>
- <li <% if is_answer %> class="correctRight_bg" <% end %>>
- <% if correct_type.to_i == Problem::QUESTION_TYPE[:MORE_CHOSE] %>
- <input type="checkbox" disabled name="question_attr_<%= question_with_answer[0].attributes["id"].to_i %>"
- id="question_attr_<%= i %>" <% if is_user_answer %>checked="true"<% end %> />
- <% elsif correct_type.to_i == Problem::QUESTION_TYPE[:SINGLE_CHOSE] %>
- <input type="radio" disabled name="question_attr_<%= question_with_answer[0].attributes["id"].to_i %>"
- id="question_attr_<%= i %>" <% if is_user_answer %>checked="true"<% end %> />
- <% end %>
- <%= attrs_array[i] %>
- </li>
- <% end if attrs_array and attrs_array.any? %>
- </ul>
- <% elsif correct_type.to_i == Problem::QUESTION_TYPE[:JUDGE] %>
- <ul class="chooseQuestion">
- <li <% if answers[0].to_i==1 %>class="correctRight_bg"<% end %>>
- <input type="radio"<% if user_answer==1.to_s %> checked="true"<% end %> disabled /><label>对</label>
- </li>
- <li <% if answers[0].to_i==0 %>class="correctRight_bg"<% end %>>
- <input type="radio" <% if user_answer==0.to_s %> checked="true"<% end %> disabled /><label>错</label>
- </li>
- </ul>
- <% elsif correct_type.to_i == Problem::QUESTION_TYPE[:SINGLE_CALK] %>
- <div class="answer_text">
- <% height = "22px"
- width = "110px"
- if user_answers[0].to_s.length > 20 and user_answers[0].to_s.length <= 28
- width = (user_answers[0].to_s.length * 10).to_s + "px"
- elsif user_answers[0].to_s.length > 28
- width = "95%"
- if user_answers[0].to_s.length > 30
- height = (22 * (user_answers[0].to_s.length/30 + 1)).to_s + "px"
- end
- end
- %>
- <textarea disabled cols="" rows=""
- style="width:<%= width %>; height:<%= height %>;"><%= user_answers[0].to_s %></textarea>
- </div>
- <% elsif correct_type.to_i == Problem::QUESTION_TYPE[:CHARACTER] %>
- <div class="answer_textarea">
- <textarea disabled cols="" rows=""><%= user_answers[0].to_s %></textarea>
- </div>
- <% elsif correct_type.to_i == Problem::QUESTION_TYPE[:MORE_BLANKS] %>
- <div class="answer_text">
- <textarea disabled cols="" rows="" style="width:50%;height:24px;"><%= user_answers[0].to_s %></textarea>
- </div>
- <% end %>
- </div>
- <!--[if IE 6]> </td></tr></table><![endif]-->
- <div class="clear"></div>
- </div>
- </div>
- </div>
- <div style="display:none;"
- id="user_answers_<%= question_with_answer[0].attributes["id"] %>"><%= user_answers.join(",") %></div>
- <!--答案-->
- <div class="nb_r_daan">
- <h3><%= correct_type.to_i == Problem::QUESTION_TYPE[:CHARACTER] ? "参考答案:" : "正确答案:" %>
- <span id="answer_<%= question_with_answer[0].attributes["id"] %>"><%= answers.join("<br/>").to_s.html_safe %></span>
- </h3>
- <% analysis = question_with_answer[0].elements["analysis"] %>
- <% unless analysis.nil? or analysis.text.nil? or analysis.text == "" %>
- <p>解析:<%= analysis.text.to_s.html_safe %></p>
- <% end %>
- </div>