没有登录平台或者没有加入竞赛的用户在点击作品提交时,请给出相应的提示

This commit is contained in:
cxt 2017-02-27 14:12:49 +08:00
parent dd1badcdc0
commit 6329578f9b
2 changed files with 75 additions and 51 deletions

View File

@ -3123,77 +3123,85 @@ module ApplicationHelper
#根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量 #根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量
def user_for_homework_common homework,is_teacher,work def user_for_homework_common homework,is_teacher,work
count = homework.student_works.has_committed.count count = homework.student_works.has_committed.count
if User.current.member_of_course?(homework.course) if User.current.logged?
if is_teacher #老师显示作品数量 if User.current.member_of_course?(homework.course)
link_to "作品(#{count})", student_work_index_url_in_org(homework.id, 2), :class => "c_blue" if is_teacher #老师显示作品数量
else #学生显示提交作品、修改作品等按钮 link_to "作品(#{count})", student_work_index_url_in_org(homework.id, 2), :class => "c_blue"
work = cur_user_works_for_homework homework else #学生显示提交作品、修改作品等按钮
project = cur_user_projects_for_homework homework work = cur_user_works_for_homework homework
if work.nil? && homework.end_time >= Time.now project = cur_user_projects_for_homework homework
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1 if work.nil? && homework.end_time >= Time.now
link_to "提交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品' if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
else link_to "提交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品'
link_to "提交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
end
elsif work.nil? && homework.end_time < Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "补交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品'
else
link_to "补交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_red'
end
else
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 && StudentWorksEvaluationDistribution.where("student_work_id = #{work.id}").count > 0 #匿评作业,且作业状态不是在开启匿评之前
if homework.homework_type != 3
link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "开启匿评后不可修改作品"
else else
work_ids = "(" + homework.student_works.has_committed.map(&:id).join(",") + ")" link_to "提交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
if User.current.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count > 0 end
elsif work.nil? && homework.end_time < Time.now
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "补交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品'
else
link_to "补交作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_red'
end
else
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 && StudentWorksEvaluationDistribution.where("student_work_id = #{work.id}").count > 0 #匿评作业,且作业状态不是在开启匿评之前
if homework.homework_type != 3
link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "开启匿评后不可修改作品" link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "开启匿评后不可修改作品"
else else
link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "匿评开启后提交的作品不参与匿评" work_ids = "(" + homework.student_works.has_committed.map(&:id).join(",") + ")"
if User.current.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count > 0
link_to "作品匿评", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "开启匿评后不可修改作品"
else
link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "匿评开启后提交的作品不参与匿评"
end
end end
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "匿评已结束"
elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
link_to "修改作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
elsif homework.end_time >= Time.now && work.user_id == User.current.id
link_to "修改作品(#{count})", edit_student_work_url_without_domain(work.id),:class => 'c_blue'
else
link_to "查看作品(#{count})", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "作业截止后不可修改作品"
end end
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
link_to "查看作品(#{count})",student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "匿评已结束"
elsif homework.homework_type == 2 && homework.end_time >= Time.now#编程作业不能修改作品
link_to "修改作品(#{count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
elsif homework.end_time >= Time.now && work.user_id == User.current.id
link_to "修改作品(#{count})", edit_student_work_url_without_domain(work.id),:class => 'c_blue'
else
link_to "查看作品(#{count})", student_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "作业截止后不可修改作品"
end end
end end
else
link_to "作品(#{count})", "javascript:void(0)", :class => "c_blue", :onclick => "notice_sure_box('您不是班级成员,不能提交作品<br/>请先从老师处获取邀请码后加入班级,再提交作品')"
end end
else else
link_to "作品(#{count})",student_work_index_url_in_org(homework.id, 2),:class => "c_blue" link_to "作品(#{count})", "javascript:void(0)", :class => "c_blue", :onclick => "login_notice_box('#{signin_url_without_domain}');"
end end
end end
#根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量 #根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量
def user_for_contest_work homework,is_contestant,work def user_for_contest_work homework,is_contestant,work
count = homework.contestant_works.has_committed.count count = homework.contestant_works.has_committed.count
if User.current.member_of_contest?(homework.contest) if User.current.logged?
if !is_contestant #老师显示作品数量 if User.current.member_of_contest?(homework.contest)
link_to "作品(#{count})", contestant_works_path(:work =>homework.id, :tab => 2), :class => "c_blue" if !is_contestant #老师显示作品数量
else #学生显示提交作品、修改作品等按钮 link_to "作品(#{count})", contestant_works_path(:work =>homework.id, :tab => 2), :class => "c_blue"
work = cur_user_works_for_work homework else #学生显示提交作品、修改作品等按钮
project = cur_user_projects_for_work homework work = cur_user_works_for_work homework
if work.nil? && homework.work_status == 1 project = cur_user_projects_for_work homework
if homework.work_type ==3 && project.nil? && homework.work_detail_group.base_on_project if work.nil? && homework.work_status == 1
link_to "提交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品' if homework.work_type ==3 && project.nil? && homework.work_detail_group.base_on_project
link_to "提交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品'
else
link_to "提交作品(#{count})", new_contestant_work_path(:work => homework.id),:class => 'c_blue'
end
else else
link_to "提交作品(#{count})", new_contestant_work_path(:work => homework.id),:class => 'c_blue' if homework.work_status == 1 && work.user_id == User.current.id
end link_to "修改作品(#{count})", edit_contestant_work_path(work.id),:class => 'c_blue'
else else
if homework.work_status == 1 && work.user_id == User.current.id link_to "查看作品(#{count})", contestant_works_path(:work =>homework.id, :tab => 2), :class => 'c_blue', :title => "不可修改作品"
link_to "修改作品(#{count})", edit_contestant_work_path(work.id),:class => 'c_blue' end
else
link_to "查看作品(#{count})", contestant_works_path(:work =>homework.id, :tab => 2), :class => 'c_blue', :title => "不可修改作品"
end end
end end
else
link_to "作品(#{count})", "javascript:void(0)", :class => "c_blue", :onclick => "notice_sure_box('您不是参赛者,不能提交作品<br/>请加入竞赛,待审批通过后再提交作品')"
end end
else else
link_to "作品(#{count})",contestant_works_path(:work =>homework.id, :tab => 2),:class => "c_blue" link_to "作品(#{count})", "javascript:void(0)", :class => "c_blue", :onclick => "login_notice_box('#{signin_url_without_domain}');"
end end
end end

View File

@ -6,6 +6,14 @@
/* Redmine - project management software /* Redmine - project management software
Copyright (C) 2006-2013 Jean-Philippe Lang */ Copyright (C) 2006-2013 Jean-Philippe Lang */
//未登录弹框提示
function login_notice_box(url){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="'+ url +'" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">您还没有登录,不能提交作品<br/>请登录</p><div class="cl"></div>'+
'<a href="'+ url +'" class="fr sy_btn_blue mt10 mr10" style="margin-right: 124px;">知道了</a></div></div>';
pop_box_new(htmlvalue, 300, 170);
}
//动态高度控制 //动态高度控制
function description_show_hide(id){ function description_show_hide(id){
showNormalImage('activity_description_'+id); showNormalImage('activity_description_'+id);
@ -1765,6 +1773,14 @@ function delete_confirm_box_3(url, str){
pop_box_new(htmlvalue, 300, 140); pop_box_new(htmlvalue, 300, 140);
} }
//提示框:只有一个按钮,点击关闭弹框
function notice_sure_box(str){
var htmlvalue = '<div id="muban_popup_box" style="width:350px;"><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">' + str + '</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10 mr10" onclick="hideModal();" style="margin-right: 124px;">知道了</a></div></div>';
pop_box_new(htmlvalue, 350, 140);
}
//提示框:只有一个确定按钮,点击关闭弹框 //提示框:只有一个确定按钮,点击关闭弹框
function notice_box(str){ function notice_box(str){
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+ var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+