368 lines
21 KiB
Plaintext
368 lines
21 KiB
Plaintext
<script type="text/javascript">
|
|
$(function(){
|
|
$("#RSide").removeAttr("id");
|
|
$("#homework_page_right").css("min-height",$("#courseLSide").height()-33);
|
|
$("#Container").css("width","1000px");
|
|
var end_time = <%=exercise.end_time.to_i%>;
|
|
getTime(end_time);
|
|
/*start_time = new Date();
|
|
start_time.setFullYear(<%#=exercise_user.start_at.year%>);
|
|
start_time.setMonth(<%#=exercise_user.start_at.month%>);
|
|
start_time.setDate(<%#=exercise_user.start_at.day%>);
|
|
start_time.setHours(<%#=exercise_user.start_at.hour%>);
|
|
start_time.setMinutes(<%#=exercise_user.start_at.min%>);
|
|
start_time.setSeconds(<%#=exercise_user.start_at.sec%>);
|
|
//alert(start_time);
|
|
end_time = start_time.getTime() + 1000*60*<%#=exercise.time %>;
|
|
getTime(end_time);*/
|
|
});
|
|
function getTime(end_time) {
|
|
//alert(end_time);
|
|
now = new Date();
|
|
var total_seconds = now.getTime()/1000 - end_time;
|
|
if (total_seconds > 0) {
|
|
$("#exercise_submit_btn").click();
|
|
return;
|
|
}
|
|
setTimeout("getTime("+end_time+");", 1000);
|
|
//start = new Date(start_time);
|
|
//end_time = start_time;
|
|
//var total_seconds = total_seconds - 1;
|
|
/*var hours = total_seconds / 60 / 60;
|
|
var hoursRound = Math.floor(hours);
|
|
var minutes = total_seconds /60 - (60 * hoursRound);
|
|
var minutesRound = Math.floor(minutes);
|
|
var seconds = total_seconds - (60 * 60 * hoursRound) - (60 * minutesRound);
|
|
var secondsRound = Math.round(seconds);
|
|
$("#rest_hours").html(hoursRound);
|
|
$("#rest_minutes").html(minutesRound);
|
|
$("#rest_seconds").html(secondsRound);*/
|
|
//if(total_seconds >0) {
|
|
//setTimeout("getTime("+end_time+");", 1000);
|
|
//}
|
|
}
|
|
</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 id="start_time" style="display: none"><%=exercise_user.start_at %></div>
|
|
<div class="fontGrey2">
|
|
<span class="mr100">开始时间:<%=Time.parse(h(exercise_user.start_at)).strftime("%Y-%m-%d %H:%M:%S")%></span>
|
|
<span class="mr100">截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S")%></span>
|
|
<% unless exercise.time == -1 %>
|
|
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
|
|
<% end %>
|
|
<!--
|
|
<span class="fr">剩余时长:<span class="c_red" id="rest_hours"></span> 小时 <span class="c_red" id="rest_minutes"></span> 分钟 <span class="c_red" id="rest_seconds"></span> 秒</span>
|
|
-->
|
|
</div>
|
|
<pre class="fontGrey2 font_cus" style="white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;"><%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%></pre>
|
|
<div class="cl"></div>
|
|
</div>
|
|
|
|
<% current_score = get_current_score exercise %>
|
|
<div id="total_questions_score" style="display: <%= exercise.exercise_questions.count != 0 ? '' : 'none' %>">
|
|
<%= render :partial => 'exercise/total_questions_score', :locals => {:exercise => exercise, :current_score => current_score} %>
|
|
</div>
|
|
|
|
<% mc_question_list = exercise.exercise_questions.where("question_type=1") %>
|
|
<% mcq_question_list = exercise.exercise_questions.where("question_type=2") %>
|
|
<% single_question_list = exercise.exercise_questions.where("question_type=3") %>
|
|
<% multi_question_list = exercise.exercise_questions.where("question_type=4") %>
|
|
<% if exercise.question_random == 1 %>
|
|
<% mc_question_list = mc_question_list.shuffle %>
|
|
<% mcq_question_list = mcq_question_list.shuffle %>
|
|
<% single_question_list = single_question_list.shuffle %>
|
|
<% multi_question_list =multi_question_list.shuffle %>
|
|
<% end %>
|
|
<div class="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
|
|
<h3 class="fontGrey3">单选题</h3>
|
|
<% mc_question_list.each_with_index do |exercise_question, list_index| %>
|
|
<div id="poll_questions_<%= exercise_question.id%>">
|
|
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mc_question_list.count ? '' : 'border_b' %>">
|
|
<div>
|
|
<div class="exercise_title">
|
|
第<%= list_index+1%>题:<%= exercise_question.question_title %> (<%= exercise_question.question_score %>分)
|
|
</div>
|
|
<div class="cl"></div>
|
|
<div class="exercise_inputs">
|
|
<table class="" style="width:100%;">
|
|
<tbody>
|
|
<% exercise_choices = exercise.choice_random == 1 ? exercise_question.exercise_choices.shuffle : exercise_question.exercise_choices.reorder("choice_position") %>
|
|
<% exercise_choices.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 == "ok")
|
|
{
|
|
obj.checked = true;
|
|
$("#question_answer_span_<%= exercise_question.id %>").addClass("bg_blue");
|
|
}
|
|
else
|
|
{
|
|
obj.checked = false;
|
|
}
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
<%= radio_button "exercise",exercise_question.id.to_s+"exercise_choice_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)%> <%= 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_with_index do |exercise_question,list_index| %>
|
|
<div id="poll_questions_<%= exercise_question.id%>">
|
|
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == mcq_question_list.count ? '' : 'border_b' %>">
|
|
<div>
|
|
<div class="exercise_title">
|
|
第<%= list_index+1%>题:<%= exercise_question.question_title %> (<%= exercise_question.question_score %>分)
|
|
</div>
|
|
<div class="cl"></div>
|
|
<div class="exercise_inputs">
|
|
<table class="" style="width:100%;">
|
|
<tbody>
|
|
<% exercise_choices = exercise.choice_random == 1 ? exercise_question.exercise_choices.shuffle : exercise_question.exercise_choices.reorder("choice_position") %>
|
|
<% exercise_choices.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 == "ok")
|
|
{
|
|
obj.checked = true;
|
|
}
|
|
else
|
|
{
|
|
obj.checked = false;
|
|
}
|
|
if(dataObj.is_answer)
|
|
{
|
|
$("#question_answer_span_<%= exercise_question.id %>").addClass("bg_blue");
|
|
}
|
|
else
|
|
{
|
|
$("#question_answer_span_<%= exercise_question.id %>").removeClass("bg_blue");
|
|
}
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
|
|
}
|
|
});
|
|
}
|
|
</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_excercise?"":"disabled=disabled" %> >
|
|
<%= convert_to_char((index+1).to_s)%> <%= 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_with_index do |exercise_question, list_index| %>
|
|
<div id="poll_questions_<%= exercise_question.id%>">
|
|
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == single_question_list.count ? '' : 'border_b' %>">
|
|
<div>
|
|
<div class="exercise_title">
|
|
第<%= list_index+1%>题:<%= exercise_question.question_title %> (<%= exercise_question.question_score %>分)
|
|
</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).val().trim()
|
|
},
|
|
success: function (data) {
|
|
var dataObj = eval(data);
|
|
obj.value = dataObj.text;
|
|
if(dataObj.text != ""){
|
|
$("#question_answer_span_<%= exercise_question.id %>").addClass("bg_blue");
|
|
} else{
|
|
$("#question_answer_span_<%= exercise_question.id %>").removeClass("bg_blue");
|
|
}
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
|
|
}
|
|
});
|
|
}
|
|
</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_excercise?"":"disabled=disabled" %>>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
<div class="testStatus" id="multi_question_list" style="display: <%=multi_question_list.count > 0 ? "" : "none" %>">
|
|
<h3 class="fontGrey3">问答题</h3>
|
|
<% multi_question_list.each_with_index do |exercise_question, list_index| %>
|
|
<div id="poll_questions_<%= exercise_question.id%>">
|
|
<div id="show_poll_questions_<%= exercise_question.id %>" class="<%= (list_index + 1) == multi_question_list.count ? '' : 'border_b' %>">
|
|
<div>
|
|
<div class="exercise_title">
|
|
第<%= list_index+1%>题:<%= exercise_question.question_title %> (<%= exercise_question.question_score %>分)
|
|
</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).val().trim()
|
|
},
|
|
success: function (data) {
|
|
var dataObj = eval(data);
|
|
obj.text = dataObj.text;
|
|
if(dataObj.text != ""){
|
|
$("#question_answer_span_<%= exercise_question.id %>").addClass("bg_blue");
|
|
} else{
|
|
$("#question_answer_span_<%= exercise_question.id %>").removeClass("bg_blue");
|
|
}
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
<textarea style="width: 693px; height: 90px; line-height: 30px; border: 1px solid #CBCBCB;" name="exercise_choice" placeholder="在此填入答案" onblur="onblur_<%= exercise_question.id %>(this);" <%= @can_edit_excercise?"":"disabled=disabled" %>><%= get_anwser_vote_text(exercise_question.id,User.current.id).html_safe %></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="testStatus">
|
|
<p class="f14 fontGrey3">答题情况</p>
|
|
<div class="mt5">
|
|
<span class="f14 mr10 fl">单选题:</span>
|
|
<% mc_question_list.each_with_index do |exercise_question, list_index| %>
|
|
<span id="question_answer_span_<%= exercise_question.id %>" class="fl mr10 question_answer_span <%= User.current.exercise_answer.where(:exercise_question_id => exercise_question.id).count > 0 ? 'bg_blue' : '' %>"><%= list_index + 1 %></span>
|
|
<% end %>
|
|
<div class="cl"></div>
|
|
</div>
|
|
<div class="mt5">
|
|
<span class="f14 mr10 fl">多选题:</span>
|
|
<% mcq_question_list.each_with_index do |exercise_question, list_index| %>
|
|
<span id="question_answer_span_<%= exercise_question.id %>" class="fl mr10 question_answer_span <%= User.current.exercise_answer.where(:exercise_question_id => exercise_question.id).count > 0 ? 'bg_blue' : '' %>"><%= list_index + 1 %></span>
|
|
<% end %>
|
|
<div class="cl"></div>
|
|
</div>
|
|
<div class="mt5">
|
|
<span class="f14 mr10 fl">填空题:</span>
|
|
<% single_question_list.each_with_index do |exercise_question, list_index| %>
|
|
<span id="question_answer_span_<%= exercise_question.id %>" class="fl mr10 question_answer_span <%= User.current.exercise_answer.where(:exercise_question_id => exercise_question.id).count > 0 ? 'bg_blue' : '' %>"><%= list_index + 1 %></span>
|
|
<% end %>
|
|
<div class="cl"></div>
|
|
</div>
|
|
<div class="mt5">
|
|
<span class="f14 mr10 fl">问答题:</span>
|
|
<% multi_question_list.each_with_index do |exercise_question, list_index| %>
|
|
<span id="question_answer_span_<%= exercise_question.id %>" class="fl mr10 question_answer_span <%= User.current.exercise_answer.where(:exercise_question_id => exercise_question.id).count > 0 ? 'bg_blue' : '' %>"><%= list_index + 1 %></span>
|
|
<% end %>
|
|
<div class="cl"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="ur_buttons">
|
|
<a href="javascript:void(0)" onclick="commit_exercise_f();" class="btn_blue_64_width" style="margin-left:105px;">马上提交</a>
|
|
</div>
|
|
<div class="cl"></div>
|
|
<!--contentbox end-->
|
|
</div>
|
|
<!--RSide end-->
|
|
</div>
|
|
|
|
<script>
|
|
function commit_exercise_f(){
|
|
var str = "";
|
|
$.ajax({
|
|
type: "get",
|
|
url: "<%= get_student_uncomplete_question_exercise_path(exercise) %>",
|
|
data: {},
|
|
success: function (data) {
|
|
var dataObj = eval(data);
|
|
if(dataObj.time_limit){
|
|
if(dataObj.uncomplete_count == 0){
|
|
str = "截止日期前您还可以继续答题<br/>是否确定提交";
|
|
} else{
|
|
str = "您还有 " + dataObj.uncomplete_count + " 题没有完成,截止日期前您还可以继续答题<br/>是否确定提交";
|
|
}
|
|
} else{
|
|
if(dataObj.uncomplete_count == 0){
|
|
str = "提交后将不能继续答题<br/>是否确定提交";
|
|
} else{
|
|
str = "您还有 " + dataObj.uncomplete_count + " 题没有完成,提交后将不能继续答题<br/>是否确定提交";
|
|
}
|
|
}
|
|
var htmlvalue = '<div id="muban_popup_box" style="width:380px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
|
|
'<div class="clear mt15"><p class="text_c f14 fontGrey7">' + str + '</p><div class="cl"></div><a href="<%= commit_exercise_exercise_path(exercise) %>" class="fr sy_btn_blue mt20" data-remote="true" style="margin-right: 132px;">确定</a>'+
|
|
'<a href="javascript:void(0);" class="fr sy_btn_grey mt20 mr10" onclick="hideModal();">取消</a></div></div>';
|
|
pop_box_new(htmlvalue, 380, 140);
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,提交失败,请确认网络正常连接后再提交。");
|
|
}
|
|
});
|
|
}
|
|
</script> |