2015-11-19 17:18:58 +08:00
|
|
|
<script type="text/javascript">
|
|
|
|
$(function(){
|
|
|
|
$("#RSide").removeAttr("id");
|
2016-07-22 15:32:37 +08:00
|
|
|
$("#homework_page_right").css("min-height",$("#courseLSide").height()-33);
|
2015-11-19 17:18:58 +08:00
|
|
|
$("#Container").css("width","1000px");
|
2015-11-27 10:15:25 +08:00
|
|
|
var end_time = <%=exercise.end_time.to_i%>;
|
2015-11-26 16:57:51 +08:00
|
|
|
getTime(end_time);
|
2015-11-20 17:25:03 +08:00
|
|
|
/*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);*/
|
2015-11-19 17:18:58 +08:00
|
|
|
});
|
2015-11-20 17:25:03 +08:00
|
|
|
function getTime(end_time) {
|
|
|
|
//alert(end_time);
|
2015-11-20 15:12:07 +08:00
|
|
|
now = new Date();
|
2015-11-26 16:57:51 +08:00
|
|
|
var total_seconds = now.getTime()/1000 - end_time;
|
2015-11-26 17:20:17 +08:00
|
|
|
if (total_seconds > 0) {
|
2015-11-26 16:57:51 +08:00
|
|
|
$("#exercise_submit_btn").click();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setTimeout("getTime("+end_time+");", 1000);
|
2015-11-20 15:12:07 +08:00
|
|
|
//start = new Date(start_time);
|
|
|
|
//end_time = start_time;
|
2015-11-20 17:25:03 +08:00
|
|
|
//var total_seconds = total_seconds - 1;
|
2015-11-26 16:57:51 +08:00
|
|
|
/*var hours = total_seconds / 60 / 60;
|
2015-11-20 14:34:09 +08:00
|
|
|
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);
|
2015-11-26 16:57:51 +08:00
|
|
|
$("#rest_seconds").html(secondsRound);*/
|
2015-11-20 17:25:03 +08:00
|
|
|
//if(total_seconds >0) {
|
2015-11-26 16:57:51 +08:00
|
|
|
//setTimeout("getTime("+end_time+");", 1000);
|
2015-11-20 17:25:03 +08:00
|
|
|
//}
|
2015-11-20 12:54:41 +08:00
|
|
|
}
|
2015-11-19 17:18:58 +08:00
|
|
|
</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>
|
2015-11-20 15:12:07 +08:00
|
|
|
<div id="start_time" style="display: none"><%=exercise_user.start_at %></div>
|
2015-11-19 21:19:18 +08:00
|
|
|
<div class="fontGrey2">
|
2015-11-26 16:57:51 +08:00
|
|
|
<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>
|
2015-11-26 14:47:52 +08:00
|
|
|
<% unless exercise.time == -1 %>
|
|
|
|
<span class="fr">测验时长:<%=exercise.time %>分钟</span>
|
|
|
|
<% end %>
|
2015-11-20 17:25:03 +08:00
|
|
|
<!--
|
2015-11-20 14:34:09 +08:00
|
|
|
<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>
|
2015-11-20 17:25:03 +08:00
|
|
|
-->
|
2015-11-19 17:18:58 +08:00
|
|
|
</div>
|
|
|
|
<div class="testDesEdit mt5"><%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%></div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
</div>
|
2015-11-20 15:12:07 +08:00
|
|
|
<% mc_question_list = exercise.exercise_questions.where("question_type=1").shuffle %>
|
|
|
|
<% mcq_question_list = exercise.exercise_questions.where("question_type=2").shuffle %>
|
|
|
|
<% single_question_list = exercise.exercise_questions.where("question_type=3").shuffle %>
|
2015-11-19 17:18:58 +08:00
|
|
|
<div class="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
|
|
|
|
<h3 class="fontGrey3">单选题</h3>
|
2015-11-20 14:34:09 +08:00
|
|
|
<% mc_question_list.each_with_index do |exercise_question, list_index| %>
|
2015-11-19 17:18:58 +08:00
|
|
|
<div id="poll_questions_<%= exercise_question.id%>">
|
|
|
|
<div id="show_poll_questions_<%= exercise_question.id %>">
|
|
|
|
<div>
|
2015-11-20 15:12:07 +08:00
|
|
|
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %> (<%= exercise_question.question_score %>分)
|
2015-11-19 17:18:58 +08:00
|
|
|
</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>
|
2015-11-19 21:19:18 +08:00
|
|
|
<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);
|
2015-11-20 12:54:41 +08:00
|
|
|
if(dataObj.text == "ok")
|
2015-11-19 21:19:18 +08:00
|
|
|
{
|
|
|
|
obj.checked = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
obj.checked = false;
|
|
|
|
}
|
2015-12-29 16:31:19 +08:00
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
|
2015-11-19 21:19:18 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
2015-11-20 14:34:09 +08:00
|
|
|
<%= 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 %>
|
2015-11-19 17:18:58 +08:00
|
|
|
<%= 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>
|
2015-11-20 14:34:09 +08:00
|
|
|
<% mcq_question_list.each_with_index do |exercise_question,list_index| %>
|
2015-11-19 17:18:58 +08:00
|
|
|
<div id="poll_questions_<%= exercise_question.id%>">
|
|
|
|
<div id="show_poll_questions_<%= exercise_question.id %>">
|
|
|
|
<div>
|
2015-11-20 15:12:07 +08:00
|
|
|
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %> (<%= exercise_question.question_score %>分)
|
2015-11-19 17:18:58 +08:00
|
|
|
</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>
|
2015-11-19 21:19:18 +08:00
|
|
|
<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);
|
2015-11-20 12:54:41 +08:00
|
|
|
if(dataObj.text == "ok")
|
2015-11-19 21:19:18 +08:00
|
|
|
{
|
|
|
|
obj.checked = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
obj.checked = false;
|
|
|
|
}
|
2015-12-29 16:31:19 +08:00
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
|
2015-11-19 21:19:18 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
2015-11-20 12:54:41 +08:00
|
|
|
<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" %> >
|
2015-11-19 17:18:58 +08:00
|
|
|
<%= 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>
|
2015-11-20 14:34:09 +08:00
|
|
|
<% single_question_list.each_with_index do |exercise_question, list_index| %>
|
2015-11-19 17:18:58 +08:00
|
|
|
<div id="poll_questions_<%= exercise_question.id%>">
|
|
|
|
<div id="show_poll_questions_<%= exercise_question.id %>">
|
|
|
|
<div>
|
2015-11-20 15:12:07 +08:00
|
|
|
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %> (<%= exercise_question.question_score %>分)
|
2015-11-19 17:18:58 +08:00
|
|
|
</div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
<div>
|
2015-11-19 21:19:18 +08:00
|
|
|
<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);
|
2015-11-20 15:12:07 +08:00
|
|
|
obj.value = dataObj.text;
|
2015-12-29 16:31:19 +08:00
|
|
|
},
|
|
|
|
error: function () {
|
|
|
|
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
|
2015-11-19 21:19:18 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
2015-11-26 16:57:51 +08:00
|
|
|
<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" %>>
|
2015-11-19 17:18:58 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
2015-11-19 21:19:18 +08:00
|
|
|
<div class="ur_buttons">
|
2015-12-15 15:21:52 +08:00
|
|
|
<%= link_to "保存",commit_exercise_exercise_path(exercise,:save => 1),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:format => 'js',:remote=>true %>
|
|
|
|
<%= link_to "提交",commit_exercise_exercise_path(exercise), :data => {:confirm => "您确定要提交吗?"},:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:20px;",:format => 'js',:remote=>true %>
|
2015-11-19 21:19:18 +08:00
|
|
|
</div>
|
2015-11-19 17:18:58 +08:00
|
|
|
<div class="cl"></div>
|
|
|
|
<!--contentbox end-->
|
|
|
|
</div>
|
|
|
|
<!--RSide end-->
|
|
|
|
</div>
|