socialforge/app/views/exercise/_exercise_student.html.erb

178 lines
9.4 KiB
Plaintext

<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#homework_page_right").css("min-height",$("#LSide").height()-30);
$("#Container").css("width","1000px");
});
</script>
<div class="homepageRight mt0 ml10">
<div class="resources">
<div class="testStatus"><!--头部显示 start-->
<h1 class="ur_page_title" id="polls_name_h"><%= exercise.exercise_name%></h1>
<div class="fontGrey2">
<span class="mr130">开始时间:<%=format_time(exercise_user.start_at.to_s) %></span>
<span class="mr130">测验时长:<%=exercise.time %>分钟</span>
<span class="fr">剩余时长:<span class="c_red">1</span>&nbsp;小时&nbsp;<span class="c_red">30</span>&nbsp;分钟&nbsp;<span class="c_red">0</span>&nbsp;秒</span>
</div>
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
<div class="cl"></div>
<div class="cl"></div>
</div>
<% mc_question_list = exercise_questions.where("question_type=1") %>
<% mcq_question_list = exercise_questions.where("question_type=2") %>
<% single_question_list = exercise_questions.where("question_type=3") %>
<div class="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">单选题</h3>
<% mc_question_list.each do |exercise_question| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div>
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
<%= exercise_question.question_title %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<tr>
<td>
<label>
<script>
function click_<%= exercise_choice.id %>(obj)
{
$.ajax({
type: "post",
url: "<%= commit_answer_exercise_path(exercise) %>",
data: {
exercise_choice_id: <%= exercise_choice.id %>,
exercise_question_id: <%= exercise_question.id %>
},
success: function (data) {
var dataObj = eval(data);
if(dataObj.text == "true")
{
obj.checked = true;
}
else
{
obj.checked = false;
}
}
});
}
</script>
<%= radio_button "poll_vote","poll_answer_id",exercise_choice.id,:class=>"ur_radio",:onclick =>"click_#{exercise_choice.id}(this);return false;",:checked => answer_be_selected?(exercise_choice,User.current),:disabled => !@can_edit_excercise %>
<%= convert_to_char((index+1).to_s)%>&nbsp;&nbsp;<%= exercise_choice.choice_text%>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
<% end %>
</div>
<div class="testStatus" id="mcq_question_list" style="display: <%=mcq_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">多选题</h3>
<% mcq_question_list.each do |exercise_question| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div>
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
<%= exercise_question.question_title %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<tbody>
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<tr>
<td>
<label>
<script>
function click_<%= exercise_choice.id %>(obj)
{
$.ajax({
type: "post",
url: "<%= commit_answer_exercise_path(exercise) %>",
data: {
exercise_choice_id: <%= exercise_choice.id %>,
exercise_question_id: <%= exercise_question.id %>
},
success: function (data) {
var dataObj = eval(data);
if(dataObj.text == "true")
{
obj.checked = true;
}
else
{
obj.checked = false;
}
}
});
}
</script>
<input class="ur_radio" type="checkbox" onclick="click_<%= exercise_choice.id %>(this);return false;" <%= answer_be_selected?(exercise_choice,User.current) ? "checked":"" %> <%= @can_edit_poll?"":"disabled=disabled" %> >
<%= convert_to_char((index+1).to_s)%>&nbsp;&nbsp;<%= exercise_choice.choice_text%>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div><!--多选题显示 end-->
</div>
</div>
<% end %>
</div>
<div class="testStatus" id="single_question_list" style="display: <%=single_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">填空题</h3>
<% single_question_list.each do |exercise_question| %>
<div id="poll_questions_<%= exercise_question.id%>">
<div id="show_poll_questions_<%= exercise_question.id %>">
<div>
<div class="testEditTitle"> 第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)<br />
<%= exercise_question.question_title %>
</div>
<div class="cl"></div>
<div>
<script>
function onblur_<%= exercise_question.id %>(obj)
{
$(window).unbind('beforeunload');
$.ajax({
type: "post",
url: "<%= commit_answer_exercise_path(exercise) %>",
data: {
exercise_question_id: <%= exercise_question.id %> ,
answer_text: obj.value
},
success: function (data) {
var dataObj = eval(data);
// obj.value = dataObj.text;
}
});
}
</script>
<input class="fillInput" placeholder="在此填入答案" type="text" value="<%= get_anwser_vote_text(exercise_question.id,User.current.id).html_safe %>" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>>
</div>
</div>
</div>
</div>
<% end %>
</div>
<div class="ur_buttons">
<%= link_to l(:button_submit),commit_exercise_exercise_path(exercise), :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %>
</div>
<div class="cl"></div>
<!--contentbox end-->
</div>
<!--RSide end-->
</div>