学生提交作品后弹出作品信息的确认框

This commit is contained in:
cxt 2015-11-06 10:24:29 +08:00
parent 5e9cc27c11
commit cab8c02113
3 changed files with 29 additions and 22 deletions

View File

@ -168,6 +168,7 @@ class StudentWorkController < ApplicationController
def create
if params[:student_work]
@submit_result = true
student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
student_work ||= StudentWork.new
student_work.name = params[:student_work][:name]
@ -183,7 +184,6 @@ class StudentWorkController < ApplicationController
else
student_work.late_penalty = 0
end
if student_work.save
course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework.id}").first
if course_activity
@ -198,21 +198,13 @@ class StudentWorkController < ApplicationController
@student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
respond_to do |format|
format.js
=begin
format.html {
flash[:notice] = l(:notice_successful_create)
redirect_to student_work_index_url(:homework => @homework.id)
}
=end
end
return
end
end
@submit_result = false
respond_to do |format|
format.html {
flash[:notice] = l(:notice_failed_create)
redirect_to new_student_work_url(:homework => @homework.id)
}
format.js
end
end

View File

@ -1,6 +1,6 @@
<div id="popbox02">
<div class="ni_con">
<span class="f16 fontBlue fb">您上传的作品信息</span>
<span class="f16 fontBlue fb">确认刚刚上传的作品信息</span>
<p class="f14 mt5">
<span class="fb">作品名称:</span><%=@student_work.name%>
</p>
@ -10,7 +10,7 @@
<p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.count == 0%>
<%= "无附件"%>
<span class="fl c_red"><%= "无附件"%></span>
<% else %>
<div class="fl">
<% @student_work.attachments.each do |attachment| %>
@ -21,9 +21,15 @@
</p>
<div class="cl"></div>
<div class="ni_btn mt10">
<a href="javascript:" class="tijiao" onclick="clickOK('<%= student_work_index_url(:homework => @homework.id)%>');" style="margin-bottom: 15px; margin-left: 55px;" >
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px; margin-left: 55px;" >
确&nbsp;&nbsp;定
</a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function clickOK() {
window.location.href = '<%= student_work_index_url(:homework => @homework.id)%>';
}
</script>

View File

@ -1,7 +1,16 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/work_information') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");
<% if @submit_result%>
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/work_information') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");
<% else %>
window.location.href = '<%= new_student_work_url(:homework => @homework.id)%>';
<% end %>
function clickCanel() {
hideModal('#popbox02');
window.location.href = '<%= student_work_index_url(:homework => @homework.id)%>';
}