在线测验学生答题时可点击保存也可点击提交

This commit is contained in:
cxt 2015-12-15 15:21:52 +08:00
parent 0b25f36a7f
commit 0deffdba33
5 changed files with 13 additions and 32 deletions

View File

@ -522,12 +522,9 @@ class ExerciseController < ApplicationController
# @score = 100
if @uncomplete_question.count < 1
# 查看是否有已提交记录
eu = get_exercise_user(@exercise.id, User.current.id)
eu.user_id = User.current.id
eu.exercise_id = @exercise.id
eu.score = @score
if eu.save
#redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
cur_exercise_user.score = @score
if cur_exercise_user.save
#redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
@status = 0 #提交成功
else
@status = 2 #未知错误
@ -535,6 +532,7 @@ class ExerciseController < ApplicationController
else
@status = 1 #有未做得必答题
end
@save = params[:save].to_i if params[:save]
respond_to do |format|
format.js
end

View File

@ -1,12 +1,15 @@
<div id="popbox" style="text-align: center;margin-top: 25px">
<% if status == 0 && exercise.time != -1%>
<% if @save == 1 %>
<h3 style="font-weight: normal;color: green">保存成功,测验日期截止前您还可以继续答题。</h3>
<%= link_to "确定", exercise_index_path(:course_id => @course.id),:class => 'commit'%>
<% elsif status == 0 && exercise.time != -1%>
<h3 style="font-weight: normal;color: green">提交成功!您的分数是:<%=@score %>分。</h3>
<%= link_to "确定", exercise_path(),:class => 'commit'%>
<% elsif status == 0 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S") %>
<h3 style="font-weight: normal;color: green">提交成功!</h3>
<h3 style="font-weight: normal;color: green">提交成功,测验日期截止前您还可以修改,祝您考高分。</h3>
<%= link_to "确定", exercise_index_path(:course_id => @course.id),:class => 'commit'%>
<% elsif status == 1 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
<h3 style="font-weight: normal;color: red">保存成功!</h3>
<h3 style="font-weight: normal;color: red">提交成功,您还有未完成的题目,测验日期截止前您还可以继续答题,祝您考高分。</h3>
<%= link_to "确定",exercise_index_path(:course_id => @course.id),:class => 'commit'%>
<% elsif status == 1 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") <= Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
<h3 style="font-weight: normal;color: red">时间已到!</h3>

View File

@ -3,10 +3,6 @@
$("#RSide").removeAttr("id");
$("#homework_page_right").css("min-height",$("#LSide").height()-30);
$("#Container").css("width","1000px");
<%uncomplete_question =get_uncomplete_question(exercise, User.current) %>;
<% if (uncomplete_question.count < 1) %>
$("#exercise_submit_btn").html("提交");
<% end %>
var end_time = <%=exercise.end_time.to_i%>;
getTime(end_time);
/*start_time = new Date();
@ -104,11 +100,6 @@
{
obj.checked = false;
}
if(dataObj.complete == 1) {
$("#exercise_submit_btn").html("提交");
} else {
$("#exercise_submit_btn").html("保存");
}
}
});
}
@ -163,11 +154,6 @@
{
obj.checked = false;
}
if(dataObj.complete == 1) {
$("#exercise_submit_btn").html("提交");
} else {
$("#exercise_submit_btn").html("保存");
}
}
});
}
@ -210,11 +196,6 @@
success: function (data) {
var dataObj = eval(data);
obj.value = dataObj.text;
if(dataObj.complete == 1) {
$("#exercise_submit_btn").html("提交");
} else {
$("#exercise_submit_btn").html("保存");
}
}
});
@ -228,8 +209,8 @@
<% end %>
</div>
<div class="ur_buttons">
<%= link_to "保存",commit_exercise_exercise_path(exercise),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %>
<%= link_to "提交",commit_exercise_exercise_path(exercise),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %>
<%= 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 %>
</div>
<div class="cl"></div>
<!--contentbox end-->

View File

@ -1,6 +1,5 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status,:exercise =>@exercise}) %>');
showModal('ajax-modal', '270px');
$('#ajax-modal').css('height','110px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='hidden_atert_form();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");

View File

@ -145,7 +145,7 @@ a:hover.btn_pu{ background:#3cb761;}
/*问卷提交时弹出框*/
.alert_box{width:250px;height:180px;position:fixed !important;z-index:100;left:60%;top:65%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.commit{height: 28px;display: block;width: 80px;color: #fff !important;background: #15bccf;text-align: center;padding-top: 4px;margin-left: 60px;margin-top: 4px;margin-right: 10px;}
.commit{font-size: 1.2em;height: 28px;display: block;width: 80px;color: #fff !important;background: #15bccf;text-align: center;padding-top: 4px;margin-left: 70px;margin-top: 4px;margin-right: 10px;}
/******确定弹框***********/
.poll_alert_form{width:140px;height:180px;position:fixed;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.polls_alert_btn_box{width: 100%;margin: 0 auto;padding-left: 45px;}