284 lines
16 KiB
Plaintext
284 lines
16 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="edu-class-container edu-position">
|
|
<p class="mb10 font-14">
|
|
<i class="fa fa-map-marker mr5 color-grey"></i>
|
|
<%= link_to @course.name, course_path(@course) %> > <%= link_to "试卷列表", exercise_index_path(:course_id => @course.id) %> > <%= link_to @exercise.exercise_name, student_exercise_list_exercise_path(@exercise) %> > <%= @exercise_user.user.show_real_name %>
|
|
</p>
|
|
<div class="edu-con-top clearfix user_bg_shadow bor-grey-e mb20">
|
|
<p class="ml15 fl color-grey3">
|
|
<% unless @exercise.is_public %>
|
|
<i class="fa fa-lock color-grey fl mt8 mr15 font-18"></i>
|
|
<% end %>
|
|
<%= @exercise.exercise_name %>
|
|
</p>
|
|
|
|
<span class="fr mr15 mt3 color-grey"><%= format_time @exercise_user.start_at %> 开始答题</span>
|
|
</div>
|
|
|
|
<% if !@exercise.try(:exercise_description).nil? && @exercise.try(:exercise_description) != "" %>
|
|
<div class="edu-con-top font-14 color-grey clearfix user_bg_shadow bor-grey-e mb20">
|
|
<pre class="exercise_que_title pl15 pr15"><%= @exercise.try(:exercise_description).html_safe%></pre>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div id="total_questions_score">
|
|
<%= render :partial => "exercise/total_questions_score" %>
|
|
</div>
|
|
|
|
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20">
|
|
<div class="clearfix pl15">
|
|
<span class="checkstatus_box_small post_btn_white mt10" style="border: 1px solid #CCCCCC;"></span><span class="fl mr20 font-12 mt3">已答</span>
|
|
<span class="checkstatus_box_small post_btn_grey mt10"></span><span class="fl mr20 font-12 mt3">未答</span>
|
|
</div>
|
|
<% if @exercise.question_random == 1 %>
|
|
<% question_list = @exercise.exercise_questions.shuffle %>
|
|
<% else %>
|
|
<% question_list = @exercise.exercise_questions %>
|
|
<% end %>
|
|
|
|
<div class="clearfix ml15 mt10 mb15">
|
|
<% question_list.each_with_index do |eq, index| %>
|
|
<a href="#mao<%= index + 1 %>" style="cursor:pointer" id="ex_commit_status_<%= eq.id %>" class="checkstatus_box_big <%= User.current.exercise_answer.where(:exercise_question_id => eq.id).count > 0 ? 'post_btn_white' : 'post_btn_grey' %>"><%= index + 1 %></a>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<div class="clearfix">
|
|
<% question_list.each_with_index do |exercise_question, i| %>
|
|
<div class="question_item_con font-14 user_bg_shadow bor-grey-e mb20 pt15">
|
|
<div class="clearfix pl15 pr15">
|
|
<p class="fl font-15" id="mao<%=i+1 %>">第<%= i + 1 %>题:<span class="color-orange03 ml10">[<%= exercise_question.question_type_name %>]</span><span class="ml10"><%= exercise_question.question_score %></span>分</p>
|
|
</div>
|
|
<div class="pl15 pr15 justify"><%= exercise_question.question_title.html_safe %></div>
|
|
<% case exercise_question.question_type %>
|
|
<% when 1 %>
|
|
<div class="pl15 pr15 mb15">
|
|
<% 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| %>
|
|
<li class="clearfix">
|
|
<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;
|
|
$("#ex_commit_status_<%= exercise_question.id %>").removeClass("post_btn_grey").addClass("post_btn_white");
|
|
}
|
|
else
|
|
{
|
|
obj.checked = false;
|
|
}
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
<input name="exercise_choice_<%= exercise_question.id %>" class="magic-radio fl mt5 magic-checkbox_show" id="exercise_<%= exercise_choice.id %>_exercise_choice_id" onclick="click_<%= exercise_choice.id %>(this);return false;" type="radio" <%= !@can_edit_excercise ? "disabled" : "" %> <%= answer_be_selected?(exercise_choice,User.current) ? "checked" : "" %>>
|
|
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id"><%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%></label>
|
|
</li>
|
|
<% end %>
|
|
</div>
|
|
<% when 2 %>
|
|
<div class="pl15 pr15 mb15">
|
|
<% 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| %>
|
|
<li class="clearfix">
|
|
<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)
|
|
{
|
|
$("#ex_commit_status_<%= exercise_question.id %>").removeClass("post_btn_grey").addClass("post_btn_white");
|
|
}
|
|
else
|
|
{
|
|
$("#ex_commit_status_<%= exercise_question.id %>").removeClass("post_btn_white").addClass("post_btn_grey");
|
|
}
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
<input name="exercise_choice_<%= exercise_question.id %>" class="magic-checkbox fl mt5 magic-checkbox_show" id="exercise_<%= exercise_choice.id %>_exercise_choice_id" onclick="click_<%= exercise_choice.id %>(this);return false;" type="checkbox" <%= !@can_edit_excercise ? "disabled" : "" %> <%= answer_be_selected?(exercise_choice,User.current) ? "checked" : "" %>>
|
|
<label class="fl color-grey3" for="exercise_<%= exercise_choice.id %>_exercise_choice_id"><%= convert_to_char((index+1).to_s)%> <%= exercise_choice.choice_text%></label>
|
|
</li>
|
|
<% end %>
|
|
</div>
|
|
<% when 3 %>
|
|
<div class="ml15 mr15 mb15 mt10">
|
|
<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 != ""){
|
|
$("#ex_commit_status_<%= exercise_question.id %>").removeClass("post_btn_grey").addClass("post_btn_white");
|
|
} else{
|
|
$("#ex_commit_status_<%= exercise_question.id %>").removeClass("post_btn_white").addClass("post_btn_grey");
|
|
}
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
<textarea placeholder="在此填入答案" class="pl15 task-height-40 with100" 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>
|
|
<% when 4 %>
|
|
<div class="ml15 mr15 mb15 mt10">
|
|
<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 != ""){
|
|
$("#ex_commit_status_<%= exercise_question.id %>").removeClass("post_btn_grey").addClass("post_btn_white");
|
|
} else{
|
|
$("#ex_commit_status_<%= exercise_question.id %>").removeClass("post_btn_white").addClass("post_btn_grey");
|
|
}
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,答题失败,请确认网络正常连接后再答题。");
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
<textarea class="task-height-150 with100 pl15" 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>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<% if @can_edit_excercise %>
|
|
<div class="">
|
|
<p class="fr mb20">
|
|
<a href="javascript:void(0)" style="width: 50px;" onclick="commit_exercise_f();" class="task-btn task-btn-orange">交卷</a>
|
|
</p>
|
|
</div>
|
|
<% 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 = "你是否确认提交?<br/>还有 " + dataObj.uncomplete_count + " 题未答,提交确定后将无法再修改答题<br/>";
|
|
}
|
|
} else{
|
|
if(dataObj.uncomplete_count == 0){
|
|
str = "你是否确认提交?<br/>提交确定后将无法再修改答题";
|
|
} else{
|
|
str = "你是否确认提交?<br/>还有 " + dataObj.uncomplete_count + " 题未答,提交确定后将无法再修改答题<br/>";
|
|
}
|
|
}
|
|
delete_confirm_box('<%= commit_exercise_exercise_path(@exercise) %>', str);
|
|
},
|
|
error: function () {
|
|
long_notice_box("网络异常,提交失败,请确认网络正常连接后再提交。");
|
|
}
|
|
});
|
|
}
|
|
</script> |