Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

Conflicts:
	app/views/layouts/_logined_header.html.erb
This commit is contained in:
huang 2016-12-30 17:33:18 +08:00
commit 17d4e45acc
110 changed files with 2324 additions and 206 deletions

View File

@ -500,6 +500,10 @@ class ApplicationController < ActionController::Base
#<23><>ȡ<EFBFBD>γ<EFBFBD>
def find_course
@course= Course.find(params[:id])
if @course.is_delete == 1 and !User.current.admin?
render_404
return
end
rescue ActiveRecord::RecordNotFound
render_404
end

View File

@ -67,6 +67,30 @@ class BoardsController < ApplicationController
else
render_403
end
elsif @contest
if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest)))
@boards = @contest.boards.includes(:last_message => :author).all
if @contest.boards.empty?
@board = @contest.boards.build
@board.name = " #{l(:label_board_contest) }"
@board.description = @contest.name.to_s
@board.project_id = -1
@board.course_id = -1
if @board.save
@boards = @contest.boards.includes(:last_message => :author).all
end
end
if params[:board_id]
@board = Board.find params[:board_id].to_i
else
unless @contest.boards.where("parent_id is NULL").empty?
@board = @contest.boards.where("parent_id is NULL").first
end
end
show and return
else
render_403
end
end
end
@ -116,6 +140,25 @@ class BoardsController < ApplicationController
else
@topics = [];
end
elsif @contest
if (@board)
@topic_count = @board.topics.count();
@topic_pages = 0 #(params[:page] ? params[:page].to_i + 1 : 0) *10
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all();
else
@board = @contest.boards.build
@board.name = " #{l(:label_board_contest) }"#self.name
@board.description = @contest.name.to_s
@board.project_id = -1
@board.course_id = -1
if @board.save
@topic_count = @board.topics.count();
@topic_pages = 0 #(params[:page] ? params[:page].to_i + 1 : 0) *10
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all();
else
@topics = []
end
end
end
#根据 赞+回复数排序
@ -162,6 +205,10 @@ class BoardsController < ApplicationController
@left_nav_type = 2
@params=params
render :action => 'show', :layout => 'base_courses'
elsif @contest
@left_nav_type = 4
@params=params
render :action => 'show', :layout => 'base_contests'
end
}
format.atom {
@ -296,6 +343,8 @@ private
@board = @project.boards.find(params[:id]) if params[:id]
elsif @course
@board = @course.boards.find(params[:id]) if params[:id]
elsif @contest
@board = @contest.boards.find(params[:id]) if params[:id]
end
rescue ActiveRecord::RecordNotFound
render_404

View File

@ -38,7 +38,7 @@ class ContestMembersController < ApplicationController
#status = 0 表示给学生发status = 1表示给老师发
course_join = ContestMessage.new(:user_id =>user_id, :contest_message_id=>User.current.id,:contest_id => @contest.id,:contest_message_type=>"JoinContest", :content => role_ids, :viewed => false, :status => 0)
course_join.save
ContestMessage.create(:user_id => User.current.id, :contest_message_id => user_id, :contest_message_id => @contest.id, :contest_message_type => "JoinContest",:content => role_ids, :viewed => false, :status => 1)
#ContestMessage.create(:user_id => User.current.id, :contest_message_id => user_id, :contest_message_id => @contest.id, :contest_message_type => "JoinContest",:content => role_ids, :viewed => false, :status => 1)
end
end
@contest.contest_members << members

View File

@ -93,11 +93,11 @@ class ContestantWorksController < ApplicationController
def show
#@score = student_work_score @work,User.current
@is_teacher = User.current.admin_of_contest?(@contest) || User.current.judge_of_contest?(@contest) || User.current.admin?
# if @homework.homework_detail_manual.comment_status == 2 && !@is_teacher && @work.user != User.current
# @student_work_scores = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").order("updated_at desc")
# else
# @student_work_scores = student_work_score_record(@work)
# end
if @contestwork.work_status == 3 && User.current.judge_of_contest?(@contest) && @contestwork.online_evaluation
@student_work_scores = @work.contestant_work_scores.where("user_id = #{User.current.id} and reviewer_role = 2").order("updated_at desc")
else
@student_work_scores = contestant_work_score_record(@work)
end
respond_to do |format|
format.js
end
@ -362,6 +362,54 @@ class ContestantWorksController < ApplicationController
end
end
def add_score
@is_last = params[:is_last] == "true"
@is_teacher = User.current.admin_of_contest?(@contest) || User.current.judge_of_contest?(@contest) || User.current.admin?
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
render_403 and return unless User.current.judge_of_contest?(@contest) && @contestwork.work_status == 3
@is_last_a = @work.contestant_work_scores.empty?
@new_score = ContestantWorkScore.new
@new_score.score = params[:score].to_i
@new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
@new_score.user_id = User.current.id
@new_score.contestant_work_id = @work.id
@new_score.reviewer_role = 2
# if User.current.admin?
# @new_score.reviewer_role = 1
# else
# role = User.current.members.where("course_id = ?",@course.id).first.roles.where("is_current = 1").first.name
# @new_score.reviewer_role = get_role_by_name(role)
# end
# if @score
# if @is_teacher
# @is_new = true
# @is_last_a = false
# else
# @is_new = false
# end
# else
# @is_new = true
# end
@new_score.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@new_score)
if @new_score.save
@contestwork.update_column('updated_at', Time.now)
update_contest_activity(@contestwork.class,@contestwork.id)
update_user_activity(@contestwork.class,@contestwork.id)
if @work.save
@work = @contestwork.contestant_works.select("contestant_works.*,contestant_works.work_score as score").where(:id => @work.id).first
@count = @contestwork.contestant_works.has_committed.count
@student_work_scores = contestant_work_score_record @work
respond_to do |format|
format.js
end
end
end
end
private
def hsd_committed_work?(user, homework)
sw = ContestantWork.where("user_id =? and work_id =?", user, homework).first

View File

@ -3,11 +3,13 @@ class ContestsController < ApplicationController
include ContestsHelper
helper :contest_members
helper :users
before_filter :find_contest, :only => [:show, :settings, :update, :contest_activities, :search_member, :private_or_public, :switch_role]
before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :search_member, :private_or_public, :switch_role, :set_invite_code_halt, :renew]
before_filter :is_logged, :only => [:index, :new, :create]
before_filter :is_admin?, :only => [:settings]
before_filter :is_admin?, :only => [:settings, :set_invite_code_halt, :destroy]
before_filter :is_member?, :only => [:show, :contest_activities]
layout "base_contests"
def show
@ -105,6 +107,10 @@ class ContestsController < ApplicationController
end
end
def destroy
@contest.update_attributes(:is_delete => true)
end
def private_or_public
@contest.update_attributes(:is_public => !@contest.is_public)
@ -169,8 +175,12 @@ class ContestsController < ApplicationController
end
case params[:agree]
when 'Y'
member = ContestMember.new(:user_id => apply_user.id)
Contest.find(applied_contest.contest_id).contest_members << member
if ContestMember.where(:user_id => apply_user.id).first.nil?
member = ContestMember.new(:user_id => apply_user.id)
Contest.find(applied_contest.contest_id).contest_members << member
else
member = ContestMember.where(:user_id => apply_user.id).first
end
contest_member_roles = member.contest_member_roles
if integer_ids.include?(14) && integer_ids.include?(13)
@ -181,8 +191,8 @@ class ContestsController < ApplicationController
end
ContestMessage.create(:user_id => apply_user.id, :contest_id => applied_contest.contest_id, :viewed => false,:contest_message_id=>User.current.id,:content=>applied_contest.role,:contest_message_type=>'ContestRequestDealResult',:status=>1)
applied_contest.applied_messages.update_all(:status => 1, :viewed => 1)
@msg.update_attributes(:status => 1, :viewed => 1)
applied_contest.applied_messages.update_all(:status => 1, :viewed => 1, :applied_user_id => User.current.id)
@msg.update_attributes(:status => 1, :viewed => 1, :applied_user_id => User.current.id)
applied_contest.update_attributes(:status => 1)
if integer_ids.include?(15)
ContestantForContest.create(:student_id => apply_user.id, :contest_id =>applied_contest.contest_id)
@ -190,8 +200,8 @@ class ContestsController < ApplicationController
when 'N'
ContestMessage.create(:user_id => apply_user.id, :contest_id => applied_contest.contest_id, :viewed => false,:contest_message_id=>User.current.id,:content=>applied_contest.role,:contest_message_type=>'ContestRequestDealResult',:status=>2)
applied_contest.applied_messages.update_all(:status => 2, :viewed => 1)
@msg.update_attributes(:status => 2, :viewed => 1)
applied_contest.applied_messages.update_all(:status => 2, :viewed => 1, :applied_user_id => User.current.id)
@msg.update_attributes(:status => 2, :viewed => 1, :applied_user_id => User.current.id)
applied_contest.update_attributes(:status => 2)
end
respond_to do |format|
@ -226,6 +236,23 @@ class ContestsController < ApplicationController
end
end
# 邀请码停用/启用
def set_invite_code_halt
if User.current.admin_of_contest?(@contest) || User.current.admin?
@contest.update_attribute('invite_code_halt', @contest.invite_code_halt == 0 ? 1 : 0)
end
end
# 恢复已删除的竞赛
def renew
if User.current.admin?
@contest.update_attributes(:is_delete => false)
redirect_to contest_path(@contest)
else
return 404
end
end
private
def find_contest
@ -234,6 +261,10 @@ class ContestsController < ApplicationController
return
end
@contest = Contest.find(params[:id])
if @contest.is_delete and !User.current.admin?
render_404
return
end
rescue ActiveRecord::RecordNotFound
render_404
end

View File

@ -82,6 +82,13 @@ class MessagesController < ApplicationController
format.js
format.html {render :layout => 'base_projects'}
end
elsif @contest
@left_nav_type = 4
respond_to do |format|
format.js
format.html { render :layout => 'base_contests' }
end
#render :action => "show", :layout => "base_courses"#by young
else
# @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page
# @replies = @topic.children.
@ -94,7 +101,7 @@ class MessagesController < ApplicationController
@organization = @org_subfield.organization
respond_to do |format|
format.js
format.html {render :layout => 'base_org'}
format.html { render :layout => 'base_org' }
end
end
end
@ -111,6 +118,8 @@ class MessagesController < ApplicationController
is_public = @project.is_public
elsif @course
is_public = @course.is_public
elsif @contest
is_public = @contest.is_public
end
# 公开项目/课程上传的资源是公开的,私有项目上传的是私有的
@message.save_attachments_containers(params[:attachments], User.current, is_public)
@ -128,6 +137,8 @@ class MessagesController < ApplicationController
redirect_to project_boards_path(@project)
elsif @course
redirect_to course_boards_path(@course, :board_id => @board.id)
elsif @contest
redirect_to contest_boards_path(@contest, :board_id => @board.id)
end
else
redirect_to board_message_url(@board, @message)
@ -138,9 +149,11 @@ class MessagesController < ApplicationController
redirect_to project_boards_path(@project, :flag => true)
elsif @course
redirect_to course_boards_path(@course, :board_id => @board.id, :flag => true)
elsif @contest
redirect_to contest_boards_path(@contest, :board_id => @board.id, :flag => true)
end
else
layout_file = @project ? 'base_projects' : 'base_courses'
layout_file = @project ? 'base_projects' : (@course ? 'base_courses' : 'base_contests')
render :action => 'new', :layout => layout_file
end
@ -149,7 +162,7 @@ class MessagesController < ApplicationController
@left_nav_type = 2
respond_to do |format|
format.html {
layout_file = @project ? 'base_projects' : 'base_courses'
layout_file = @project ? 'base_projects' : (@course ? 'base_courses' : 'base_contests')
render :layout => layout_file
}
end
@ -187,6 +200,7 @@ class MessagesController < ApplicationController
end
update_course_activity(@topic.class,@topic.id)
update_contest_activity(@topic.class,@topic.id)
update_user_activity(@topic.class,@topic.id)
update_forge_activity(@topic.class,@topic.id)
update_org_activity(@topic.class,@topic.id)
@ -226,6 +240,8 @@ class MessagesController < ApplicationController
(render_403; return false) unless @message.editable_by?(User.current)
elsif @course
(render_403; return false) unless @message.course_editable_by?(User.current)
elsif @contest
(render_403; return false) unless @message.contest_editable_by?(User.current)
else
(render_403; return false) unless @message.org_subfield_editable_by?(User.current)
end
@ -243,12 +259,16 @@ class MessagesController < ApplicationController
redirect_to project_path(@project)
elsif @course
redirect_to course_activity_path(@course)
elsif @contest
redirect_to contest_activities_contest_path(@contest)
end
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
if @project
redirect_to project_boards_path(@project)
elsif @course
redirect_to course_boards_path(@course)
elsif @contest
redirect_to contest_boards_path(@contest)
end
else
redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id))
@ -265,6 +285,9 @@ class MessagesController < ApplicationController
elsif @course
@left_nav_type = 2
layout_file = 'base_courses'
elsif @contest
@left_nav_type = 4
layout_file = 'base_contests'
elsif @org_subfield
@organization = @org_subfield.organization
layout_file = 'base_org'
@ -292,6 +315,8 @@ class MessagesController < ApplicationController
(render_403; return false) unless @message.destroyable_by?(User.current)
elsif @course
(render_403; return false) unless @message.course_destroyable_by?(User.current)
elsif @contest
(render_403; return false) unless @message.contest_destroyable_by?(User.current)
else
(render_403; return false) unless @message.org_subfield_editable_by?(User.current)
end
@ -322,6 +347,18 @@ class MessagesController < ApplicationController
else
redirect_to course_boards_path(@course)
end
elsif @contest
if params[:is_course] && params[:is_course].to_i == 0
redirect_to user_contest_community_path(User.current.id)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 0
redirect_to contest_activities_contest_path(@contest)
elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1
redirect_to contest_boards_path(@contest)
elsif @message.parent
redirect_to board_message_url(@board, @message.parent, :r => r)
else
redirect_to contest_boards_path(@contest)
end
elsif @org_subfield
if params[:is_board]
redirect_to organization_path(:id => @org_subfield.organization_id, :org_subfield_id => @org_subfield.id)
@ -400,8 +437,10 @@ class MessagesController < ApplicationController
@board = Board.find(params[:board_id])
if @board.project_id != -1 && @board.project_id != nil
@project = @board.project
elsif @board.course_id
elsif @board.course_id && @board.course_id != -1
@course = @board.course
elsif @board.contest_id
@contest = @board.contest
else
@org_subfield = @board.org_subfield
@organization = @org_subfield

View File

@ -4087,6 +4087,7 @@ class UsersController < ApplicationController
# 用户竞赛列表
def user_contestlist
# 我创建的竞赛
@contest_community = "竞赛"
@my_contests = @user.contests.where(:user_id => @user.id).order("created_at desc")
@my_contests_count = @my_contests.count
# 我参与的竞赛

View File

@ -2,8 +2,9 @@ class WorksController < ApplicationController
layout "base_contests"
before_filter :find_contest, :only => [:index,:new,:create]
before_filter :find_contestwork, :only => [:edit,:update,:destroy,:score_rule_set,:alert_open_student_works,:open_student_works,:set_score_open,:alert_score_open_modal]
before_filter :admin_of_contest, :only => [:new, :create, :edit, :update, :destroy,:score_rule_set,:alert_open_student_works,:open_student_works]
before_filter :find_contestwork, :only => [:edit,:update,:destroy,:score_rule_set,:open_contestant_works,:set_score_open,:alert_score_open_modal,
:set_score_rule]
before_filter :admin_of_contest, :only => [:new, :create, :edit, :update, :destroy,:score_rule_set,:open_contestant_works]
before_filter :member_of_contest, :only => [:index]
def index
@ -71,6 +72,13 @@ class WorksController < ApplicationController
homework.work_status = homework.publish_time > Date.today ? 0 : 1
work_detail_manual = WorkDetailManual.new
work_detail_manual.evaluation_start = homework.end_time + 7
work_detail_manual.evaluation_end = work_detail_manual.evaluation_start + 7
work_detail_manual.evaluation_num = 3
homework.work_detail_manual = work_detail_manual
#分组作业
if homework.work_type == 3
homework_detail_group = WorkDetailGroup.new
@ -81,6 +89,7 @@ class WorksController < ApplicationController
end
if homework.save
work_detail_manual.save if work_detail_manual
homework_detail_group.save if homework_detail_group
redirect_to works_path(:contest => @contest.id)
end
@ -101,7 +110,14 @@ class WorksController < ApplicationController
end
param_end_time = Time.parse(params[:homework_common][:end_time]).strftime("%Y-%m-%d")
homework_end_time = Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d")
work_detail_manual = @contestwork.work_detail_manual
if homework_end_time != param_end_time
eval_start = work_detail_manual.evaluation_start
if eval_start.nil? || (eval_start <= param_end_time && @contestwork.work_status <= 2)
work_detail_manual.evaluation_start = @contestwork.end_time + 7
work_detail_manual.evaluation_end = work_detail_manual.evaluation_start + 7
end
if homework_end_time > param_end_time
@contestwork.contestant_works.each do |st|
if param_end_time < Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
@ -129,6 +145,8 @@ class WorksController < ApplicationController
#status = false
if @contestwork.publish_time <= Date.today && @contestwork.work_status == 0
@contestwork.work_status = 1
elsif @contestwork.end_time < Date.today && @contestwork.work_status == 1
@contestwork.work_status = 2
#status = true
end
@ -146,6 +164,7 @@ class WorksController < ApplicationController
if @contestwork.save
@homework_detail_group.save if @homework_detail_group
work_detail_manual.save if work_detail_manual
@hw_status = params[:hw_status].to_i
if @hw_status == 1
@ -180,20 +199,80 @@ class WorksController < ApplicationController
def destroy
if @contestwork.destroy
respond_to do |format|
format.html {
format.js {
@hw_status = params[:hw_status].to_i
if @hw_status == 1
redirect_to user_contest_community_path(User.current.id)
elsif @hw_status == 2
redirect_to contest_path(@contest.id)
else
redirect_to works_path(:contest => @contest.id)
end
}
end
end
end
def alert_score_open_modal
if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
else
@user_activity_id = -1
end
@hw_status = params[:hw_status].to_i
end
def set_score_open
@contestwork.update_attribute('score_open', params[:score_open].to_i)
@user_activity_id = params[:user_activity_id].to_i
@hw_status = params[:hw_status].to_i
@is_teacher = User.current.admin? || User.current.admin_of_contest?(@contest)
end
def open_contestant_works
@contestwork.update_attributes(:is_open => !@contestwork.is_open)
@user_activity_id = params[:user_activity_id]
@hw_status = params[:hw_status].to_i
@is_teacher = User.current.admin? || User.current.admin_of_contest?(@contest)
end
def score_rule_set
if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
else
@user_activity_id = -1
end
@hw_status = params[:hw_status].to_i
end
def set_score_rule
# 未启动在线评审时才能更改评审参数
if @contestwork.work_status < 3
@contestwork.online_evaluation = params[:online_evaluation] ? 1 : 0
# 如果开启在线评审
if params[:online_evaluation]
work_detail_manual = @contestwork.work_detail_manual
work_detail_manual.evaluation_start = params[:evaluation_start]
work_detail_manual.evaluation_end = params[:evaluation_end]
work_detail_manual.evaluation_num = params[:evaluation_limit].to_i == 1 ? params[:evaluation_num] : -1
work_detail_manual.save
end
end
score_valid = params[:score_valid].to_i == 1 ? true : false
if score_valid != @contestwork.score_valid
@contestwork.score_valid = score_valid
@contestwork.contestant_works.has_committed.each do |c_work|
c_work.save
end
end
@contestwork.save
if params[:student_path] && params[:student_path] == "true"
redirect_to contestant_works_path(:work => @contestwork.id)
else
@user_activity_id = params[:user_activity_id].to_i
@hw_status = params[:hw_status].to_i
respond_to do |format|
format.js
end
end
end
private
#获取竞赛

View File

@ -3107,20 +3107,14 @@ module ApplicationHelper
else #学生显示提交作品、修改作品等按钮
work = cur_user_works_for_work homework
project = cur_user_projects_for_work homework
if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
if work.nil? && homework.work_status == 1
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
elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d")
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_red'
end
else
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id
if homework.work_status == 1 && work.user_id == User.current.id
link_to "修改作品(#{count})", edit_contestant_work_path(work.id),:class => 'c_blue'
else
link_to "查看作品(#{count})", contestant_works_path(:work =>homework.id, :tab => 2), :class => 'c_blue', :title => "不可修改作品"
@ -3968,6 +3962,8 @@ def get_cw_status contest_work
else
str += '<span class="red_homework_btn_cir ml5">作品补交中</span>'
end
elsif contest_work.work_status == 2
str += '<span class="red_homework_btn_cir ml5">提交已截止</span>'
end
str
end

View File

@ -13,4 +13,44 @@ module ContestantWorksHelper
end
str
end
#成绩计算
def set_final_score contestwork, contestant_work
if contestwork.online_evaluation
if contestwork.score_valid
if ContestantWorkScore.find_by_sql("SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id").count < 2
judge_score = ContestantWorkScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
else
judge_score = ContestantWorkScore.find_by_sql("SELECT (SUM(score)-MIN(score)-MAX(score))/(COUNT(score)-2) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
end
@work.work_score = judge_score.first.score.try(:round, 2).to_f
else
judge_score = ContestantWorkScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@work.work_score = judge_score.first.score.try(:round, 2).to_f
end
else
contestant_work.work_score = nil
end
end
#获取学生作品的评分记录:同一个评委只显示最后一次评分
def contestant_work_score_record work
sql = "SELECT MAX(id) id FROM contestant_work_scores WHERE reviewer_role = 2 AND score IS NOT NULL AND contestant_work_id = #{work.id} GROUP BY user_id"
tea_ts_ids = ContestantWorkScore.find_by_sql sql
tea_ts_ids = tea_ts_ids.empty? ? "(-1)" : "(" + tea_ts_ids.map{|tea| tea.id}.join(",") + ")"
scores = work.contestant_work_scores.where("score IS NULL or reviewer_role = 3 or id in #{tea_ts_ids}").order("updated_at desc")
return scores
end
#获取指定评分的角色
def student_work_score_role score
case score.reviewer_role
when 1
role = "管理员"
when 2
role = "评委"
when 3
role = "参赛者"
end
end
end

View File

@ -869,4 +869,20 @@ module UsersHelper
end
return user_ids
end
# 获取竞赛申请者的角色
def get_role_str role
str = ""
case role
when 1
str = "管理员"
when 2
str = "评委"
when 3
str = "参赛者"
when 4
str = "管理员、评委"
end
str
end
end

View File

@ -8,7 +8,7 @@ class AppliedContest < ActiveRecord::Base
has_many :applied_messages, :class_name => 'AppliedMessage', :as => :applied, :dependent => :destroy
after_create :send_appliled_message
# 仅仅给项目管理人员发送消息
# 仅仅给竞赛管理人员发送消息
def send_appliled_message
case self.role
when '13'
@ -17,11 +17,9 @@ class AppliedContest < ActiveRecord::Base
role = 2
when '15'
role = 3
else
role = 4
end
contest_managers(self.contest).each do |member|
self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => 0, :viewed => false, :applied_user_id => self.user_id, :role => role)
self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => 0, :viewed => false, :role => role)
end
# end
end

View File

@ -20,6 +20,7 @@ class Board < ActiveRecord::Base
belongs_to :project,:touch => true
belongs_to :course,:touch=>true
belongs_to :org_subfield, :touch => true
belongs_to :contest, :touch => true
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
@ -55,6 +56,8 @@ class Board < ActiveRecord::Base
@valid_parents ||= project.boards - self_and_descendants
elsif course
@valid_parents ||= course.boards - self_and_descendants
elsif contest
@valid_parents ||= contest.boards - self_and_descendants
end
end

View File

@ -26,6 +26,7 @@ class Comment < ActiveRecord::Base
# 课程/项目 消息
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
has_many :contest_messages, :class_name => 'ContestMessage', :as => :contest_message, :dependent => :destroy
#end
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
has_one :praise_tread_cache, as: :object, dependent: :destroy
@ -54,12 +55,22 @@ class Comment < ActiveRecord::Base
# ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
# end
end
elsif self.commented.contest
if self.author_id != self.commented.author_id
self.contest_messages << ContestMessage.new(:user_id => self.commented.author_id, :contest_id => self.commented.contest.id, :viewed => false)
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count
# if count == 0
# content = strip_html self.comments.html_safe, 200
# ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
# end
end
else # 项目相关
# if self.author_id != self.commented.author_id
# self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false)
# #content = strip_html self.comments.html_safe, 200
# #ws.comment_template self.commented.author_id, "blog_comment", self.id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
# end
end
end

View File

@ -13,6 +13,9 @@ class Contest < ActiveRecord::Base
has_many :users, :through => :members
has_many :contestants, :class_name => 'ContestantForContest', :source => :user
has_many :works
has_many :contestant_work_projects, :dependent => :destroy
has_many :boards, :dependent => :destroy, :order => "position ASC"
has_many :news, :dependent => :destroy, :include => :author
@ -24,7 +27,7 @@ class Contest < ActiveRecord::Base
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]*$/
before_destroy :delete_all_members
#after_create :act_as_contest_activity
after_create :create_board_sync
scope :visible, lambda {|*args| where(Contest.where("is_delete =?", 0).visible_condition(args.shift || User.current, *args)) }
@ -108,4 +111,19 @@ class Contest < ActiveRecord::Base
end
code
end
# 创建竞赛讨论区
def create_board_sync
@board = self.boards.build
#self.name=" #{l(:label_borad_course) }"
@board.name = " #{l(:label_board_contest) }"#self.name
@board.description = self.name.to_s
@board.project_id = -1
@board.course_id = -1
if @board.save
logger.debug "[Contest Model] ===> #{@board.to_json}"
else
logger.error "[Contest Model] ===> Auto create board when contest saved, because #{@board.full_messages}"
end
end
end

View File

@ -1,4 +1,5 @@
class ContestantWork < ActiveRecord::Base
include ContestantWorksHelper
belongs_to :work
belongs_to :user
belongs_to :project
@ -8,6 +9,9 @@ class ContestantWork < ActiveRecord::Base
has_many :contestant_work_scores, :dependent => :destroy
has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy
has_many :attachments, :dependent => :destroy
has_many :contestant_work_evaluation_distributions
before_save :set_work_score
scope :has_committed, lambda{where("work_status != 0 and work_status != 3")}
scope :no_copy, lambda{where("work_status != 3")}
@ -20,4 +24,8 @@ class ContestantWork < ActiveRecord::Base
self.contest_messages << ContestMessage.new(:user_id => self.user_id, :contest_id => self.work.contest_id, :viewed => false, :status => false)
end
end
def set_work_score
set_final_score self.work,self
end
end

View File

@ -0,0 +1,5 @@
class ContestantWorkEvaluationDistribution < ActiveRecord::Base
belongs_to :user
belongs_to :contestant_work
attr_accessible :user_id, :contestant_work_id
end

View File

@ -2,4 +2,6 @@ class ContestantWorkScore < ActiveRecord::Base
belongs_to :contestant_work
belongs_to :user
attr_accessible :comment, :reviewer_role, :score, :contestant_work_id, :user_id
has_many :journals_for_messages
end

View File

@ -86,7 +86,7 @@ class Message < ActiveRecord::Base
# after_create :add_author_as_watcher, :reset_counters!, :add_boards_count
after_update :update_messages_board, :update_activity
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score
after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message, :delay_message_send
after_create :act_as_course_activity, :act_as_forge_activity, :act_as_contest_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message, :delay_message_send
#before_save :be_user_score
scope :visible, lambda {|*args|
@ -188,6 +188,18 @@ class Message < ActiveRecord::Base
board.course
end
def contest
board.contest
end
def contest_editable_by?(usr)
usr && usr.logged? && (usr.admin_of_contest?(contest) || self.author == usr || usr.admin?)
end
def contest_destroyable_by?(usr)
usr && usr.logged? && (usr.admin_of_contest?(contest) || self.author == usr || usr.admin?)
end
def course_editable_by?(usr)
usr && usr.logged? && (usr.allowed_to?(:edit_messages, course) || (self.author == usr && usr.allowed_to?(:edit_own_messages, course)))
end
@ -223,6 +235,7 @@ class Message < ActiveRecord::Base
#动态的更新
def update_activity
update_course_activity(self.class, self.id)
update_contest_activity(self.class, self.id)
update_user_activity(self.class, self.id)
update_forge_activity(self.class, self.id)
update_org_activity(self.class, self.id)
@ -269,6 +282,13 @@ class Message < ActiveRecord::Base
end
end
#竞赛动态公共表记录
def act_as_contest_activity
if self.contest && self.parent_id.nil?
self.contest_acts << ContestActivity.new(:user_id => self.author_id,:contest_id => self.board.contest_id)
end
end
# 课程讨论区添加消息:
# 老师发帖所有人都能收到消息
# 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息
@ -324,6 +344,29 @@ class Message < ActiveRecord::Base
# end
end
end
elsif self.contest
if self.parent_id.nil? # 主贴
self.contest.contest_members.includes(:user).each do |m|
if self.author.admin_of_contest?(self.contest) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
#self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count
# if count == 0
# content = strip_html self.subject, 200
# ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
# end
end
end
else # 回帖
parent_author_id = Message.find(self.parent_id).author_id
if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
self.contest_messages << ContestMessage.new(:user_id => parent_author_id, :contest_id => self.board.contest_id, :viewed => false)
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count
# if count == 0
# content = strip_html self.content.html_safe, 200
# ws.comment_template parent_author_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
# end
end
end
end
end
@ -346,6 +389,25 @@ class Message < ActiveRecord::Base
self.delay.contain_messages_message(dm)
end
end
elsif self.contest
if self.parent_id.nil? # 发帖
dm = []
self.contest.contest_members.includes(:user).each do |m|
if self.author.admin_of_contest?(self.contest) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
dm << {contest_message_type:'Message',contest_message_id:self.id, :user_id => m.user_id,
:contest_id => self.board.contest_id, :viewed => false}
if dm.size >= 30
self.delay.contain_contest_messages_message(dm)
dm.clear
end
end
end
unless dm.empty?
self.delay.contain_contest_messages_message(dm)
end
end
end
end
@ -354,6 +416,10 @@ class Message < ActiveRecord::Base
CourseMessage.create(vs)
end
def contain_contest_messages_message vs
ContestMessage.create(vs)
end
#更新用户分数 -by zjc
def be_user_score
#新建message且无parent的为发帖

View File

@ -69,7 +69,7 @@ class News < ActiveRecord::Base
:author_key => :author_id
acts_as_watchable
after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send
after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send, :act_as_contest_message
after_update :update_activity
after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score
@ -216,6 +216,16 @@ class News < ActiveRecord::Base
end
end
def act_as_contest_message
if self.contest_id
self.contest.contest_members.each do | m|
if m.user_id != self.author_id
self.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => self.contest_id, :viewed => false)
end
end
end
end
def delay_news_send
if self.course
@ -240,7 +250,7 @@ class News < ActiveRecord::Base
vs = []
self.contest.contest_members.each do | m|
if m.user_id != self.author_id
vs << {course_message_type:'Contest',course_message_id:self.id, :user_id => m.user_id,
vs << {contest_message_type:'Contest',contest_message_id:self.id, :user_id => m.user_id,
:contest_id => self.contest_id, :viewed => false}
if vs.size >= 30

View File

@ -43,7 +43,8 @@ class Project < ActiveRecord::Base
end
end
has_many :student_work_projects,:dependent => :destroy
has_many :student_work_projects, :dependent => :destroy
has_many :contestant_work_projects, :dependent => :destroy
has_many :student_works
has_many :time_entry_activities
has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"

View File

@ -1063,6 +1063,7 @@ class User < Principal
# Admin users are authorized for anything else
return true if admin?
# 课程:作品关联项目的老师也可以访问私有项目
course_ids = context.student_work_projects.blank? ? "(-1)" : "(" + context.student_work_projects.map{|swp| swp.course_id}.join(",") + ")"
courses = Course.where("id in #{course_ids}")
courses.each do |course|
@ -1070,6 +1071,16 @@ class User < Principal
return true
end
end
# 竞赛:作品关联项目的管理员也可以访问私有项目
contest_ids = context.contestant_work_projects.map{|swp| swp.contest_id}
contests = Contest.where(:id => contest_ids)
contests.each do |contest|
if self.admin_of_contest?(contest)
return true
end
end
roles = roles_for_project(context)
return false unless roles
roles.any? {|role|

View File

@ -1,10 +1,12 @@
class Work < ActiveRecord::Base
# work_status 0未发布/挂起 1提交中 2提交截止 3启动在线评审 4评审结束
belongs_to :user
belongs_to :contest
attr_accessible :description, :end_time, :is_delete, :is_open, :name, :publish_time, :score_open, :work_status, :work_type, :contest_id, :user_id
include ApplicationHelper
has_one :work_detail_group, :dependent => :destroy
has_one :work_detail_manual, :dependent => :destroy
has_many :contestant_work_projects, :dependent => :destroy
has_many :contestant_works, :dependent => :destroy, :conditions => "is_delete != 1"
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
@ -60,10 +62,8 @@ class Work < ActiveRecord::Base
if self.work_status == 0
self.contest_messages.destroy_all
else
self.contest.contest_members.each do |m|
if m.user_id != self.user_id
self.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => self.contest_id, :viewed => false)
end
self.contest.contestants.each do |m|
self.contest_messages << ContestMessage.new(:user_id => m.student_id, :contest_id => self.contest_id, :viewed => false)
end
end
end

View File

@ -0,0 +1,4 @@
class WorkDetailManual < ActiveRecord::Base
belongs_to :work
attr_accessible :evaluation_end, :evaluation_num, :evaluation_start, :work_id
end

View File

@ -23,13 +23,18 @@ class ContestsService
else
if params[:invite_code].present?
role_ids = params[:role]
role_str = role_ids.join(",").to_s
#如果已经发送过消息了,那么就要给个提示
if AppliedContest.where(:contest_id => contest.id, :user_id => current_user.id, :role => role_str, :status => 0).count != 0
if AppliedContest.where(:contest_id => contest.id, :user_id => current_user.id, :status => 0).count != 0
@state = 7
else
AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_str, :status => 0)
if role_ids.size == 1
AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_ids[0], :status => 0)
else
role_ids.each do |role_id|
AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_id, :status => 0)
end
end
@state = 6
end
else

View File

@ -0,0 +1,80 @@
<div class = "cl"> </div>
<div id="course-boardlist">
<div class="listbox mt10" >
<p class="list-h2">讨论区列表</p>
<div class="category">
<span class="grayTxt ">排序:</span>
<%= link_to "时间", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 1 %>
<%= link_to "", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
<%= link_to "人气", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
<% if @type.to_i == 2 %>
<%= link_to "", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<% end %>
<div class="cl"></div>
</div>
<div class="bloglistbox">
<% if topics.any? %>
<% topics.each do |activity| %>
<div class="list-file">
<div><span class="item_list fl"></span>
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal fl" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal f1" %>
<% end %>
<% if activity.sticky == 1 %>
<span class="fl ml10 red-cir-btn">顶</span>
<% end%>
<% if activity.locked %>
<span class="fl ml10 green-cir-btn" title="已锁定">锁</span>
<% end %>
<%# u = User.where("id=?",activity.author_id).first%>
<div class="cl"></div>
</div>
<!--<div class="massages-content ml15">-->
<!--<%# if activity.parent_id.nil? %>-->
<!--<% content = activity.content %>-->
<!--<%# else %>-->
<!--<%# content = activity.parent.content %>-->
<!--<%# end %>-->
<!--<p><%#=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>content, :maxheight=>54, :maxwordsnum=>75, :maxwidth=>563} %></p>-->
<!--</div>-->
<div class="ml15 mt10">
<span class="grayTxt mr15">
发帖人:<%= link_to activity.author.show_name, user_path(activity.author), :class => "link-blue" %>
</span>
<span class="grayTxt">更新:<%= format_time(activity.children.any? ? activity.children.last[:created_on] : activity[:created_on] ) %></span>
<% all_comments = []%>
<% count=Message.where("root_id = #{activity.id}").count %>
<p class="list-info fr grayTxt"><span><%= count>0 ? "#{count}" : "0" %></span><span>回复</span><span>|</span><span><%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %></span><span>赞</span></p>
</div>
<div class="cl"></div>
</div>
<% end %>
<div>
<ul class="wlist" id="pages" >
<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
</ul>
<div class="cl"></div>
</div>
<% else %>
<div class="icons_tishi"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">没有数据可以显示!</p>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
//如果右边的博客列表比左边的高度低则将右边的高度设为与左边对齐
$(function(){
var leftHeight = $("#LSide").height()-$(".fontGrey5").height()-20;
var rightHeight = $(".homepageRight").height();
if (rightHeight < leftHeight){
var diffHeight = leftHeight - rightHeight;
var tmpHeight = $(".listbox").height()+diffHeight;
$(".listbox").css("height",tmpHeight);
}
});
</script>

View File

@ -0,0 +1,16 @@
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
$("#message_subject").focus();
});
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName">
编辑帖子
</div>
</div>
<%= render :partial => 'boards/contest_new',
:locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :contest => contest} %>
</div>

View File

@ -0,0 +1,194 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
<% end %>
<script type="text/javascript">
var first_click = true;
function nh_check_field(params){
var result=true;
if(!regexTopicSubject()) {
result=false;
return result;
}
if(params.content!=undefined){
if(params.content.isEmpty()){
result=false;
}
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html());
params.content.sync();
if(params.content.isEmpty())
{
params.contentmsg.text("描述不能为空");
params.contentmsg.css('color','#ff0000');
result=false;
}
else
{
params.contentmsg.text("填写正确");
params.contentmsg.css('color','#008000');
}
}
}
return result;
}
function init_homework_form(params){
params.form.submit(function(){
params.textarea.html(params.editor.html());
params.editor.sync();
var flag = false;
if(params.form.attr('data-remote') != undefined ){
flag = true
}
var is_checked = false;
is_checked = nh_check_field({
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
});
if(first_click && is_checked){
if(flag){
first_click = false;
return true;
}else{
first_click = false;
$(this)[0].submit();
return false;
}
}
return false;
});
}
function init_homework_editor(params){
params.textarea.removeAttr('placeholder');
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px",
items : ['code','emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','table', 'media', 'preview',"more"
],
afterChange:function(){//按键事件
var edit = this.edit;
var body = edit.doc.body;
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150));
},
afterCreate:function(){
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
//reset height
var edit = this.edit;
var body = edit.doc.body;
edit.html(params.textarea.innerHTML);
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
elocalStorage(message_content_editor,'topic_contest_<%=contest.id %>');
}
}).loadPlugin('paste');
return editor;
}
KindEditor.ready(function(K){
$("div[nhname='topic_form']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[nhname='topic_textarea']",params.div_form);
params.contentmsg = $("#message_content_span");
params.submit_btn = $("#new_message_submit_btn");
if(params.textarea.data('init') == undefined) {
params.editor = init_homework_editor(params);
message_content_editor = params.editor;
init_homework_form(params);
params.submit_btn.click(function () {
params.form.submit();
});
params.textarea.data('init', 1);
}
});
});
</script>
<%= error_messages_for 'message' %>
<div class="resources mt10">
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>
<input type="text" name="message[subject]" id="message_subject" class="InputBox w713" maxlength="128" onfocus="$('#topic_editor').show()" onkeyup="regexTopicSubject();" placeholder="发布帖子,请先输入帖子标题" value="<%= topic.subject%>" >
<p id="subjectmsg"></p>
</div>
<div id="topic_editor" style="display: none;">
<%if User.current.member_of_contest?(contest) %>
<div class="mt10">
<% if User.current.id == contest.user_id %>
<%= f.check_box :sticky, :value => topic.sticky %>
<%= label_tag 'message_sticky', l(:label_board_sticky) %>
<%= f.check_box :locked, :value => topic.locked %>
<%= label_tag 'message_locked', l(:label_board_locked) %>
<% end %>
<div class="cl"></div>
</div>
<% end %>
<div class="mt10">
<div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
<%= text_area :quote,:quote,:style => 'display:none' %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%#= f.kindeditor :content, :editor_id => 'message_content_editor',
:owner_id => topic.nil? ? 0: topic.id,
:owner_type => OwnerTypeHelper::MESSAGE,
:width => '100%',
:height => 300,
:minHeight=>300,
:class => 'talk_text fl',
:input_html => { :id => 'message_content',
:class => 'talk_text fl',
:maxlength => 5000 },
at_id: topic.id, at_type: topic.class.to_s
%>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='topic_textarea' name="message[content]"><%=topic.content %></textarea>
<div class="cl"></div>
<p id="message_content_span"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
</div>
<div class="cl"></div>
<div class="mt10">
<div class="fl" id="topic_attachments">
<%= render :partial => 'attachments/form_course', :locals => {:container => topic, :isReply => @isReply} %>
</div>
</div>
<div class="cl"></div>
<div class="mt5">
<%if !edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a>
<% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span>
<%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
<% end %>
</div>
<div class="cl"></div>
</div>
</div>
<%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %>
<!--<li>
<div class="ml55 fl" nhname="toolbar_container"></div>
<a href="javascript:void(0);" nhname="cancelbtn" class="grey_btn fr ml10"><%#= l(:button_cancel) %></a>
<a href="javascript:void(0);" nhname="submitbtn" class="blue_btn fr " style="margin-left: 55px">
<%#= l(:button_submit)%>
</a>
<div class="cl"></div>
</li>-->
</div>
</div>

View File

@ -0,0 +1,43 @@
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
function reset_topic(){
$("#message_subject").val("");
$("#subjectmsg").text("");
document.getElementById("message_sticky").checked=false;
document.getElementById("message_locked").checked=false;
$("#topic_attachments").html("<%= escape_javascript(render :partial => 'attachments/form_course', :locals => {:container => Message.new, :isReply => @isReply})%>");
message_content_editor.html("");
$("#topic_editor").toggle();
}
<% if @is_new%>
$(function(){
$("#message_subject").focus();
});
<%end%>
</script>
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner">
<div class="NewsBannerName break_word" style="width: 600px;">
<%= @board.parent_id.nil? ? "竞赛讨论区" : "#{@board.name}" %>
</div>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.admin_of_contest?(@board.contest)) %>
<%# if is_teacher %>
<%#= link_to "添加子栏目", settings_course_path(@board.course.id,'boards'), :class => "link-blue fr mt5" %>
<%# end %>
</div>
<div nhname="topic_form">
<% if User.current.logged? %>
<%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'},
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'contest_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :contest => @board.contest} %>
<% end %>
<% end %>
</div>
<%= render :partial=> 'contest_show_detail',:locals =>{:topics => @topics, :page => 0} %>
</div>

View File

@ -0,0 +1,8 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false) %>
<%= javascript_include_tag "create_kindeditor" %>
<% end %>
<% if @topics || topics %>
<%= render :partial => 'boards/contest_boardlist', :locals => {:topics => @topics ? @topics: topics , :is_course => 1, :is_board=>1} %>
<% end %>

View File

@ -36,6 +36,8 @@
<%= render :partial => 'project_show', locals: {:topics => @topics, :page => 0, project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_show', :locals => {:topics => @topics, :page => 0, :course => @course} %>
<% elsif @contest %>
<%= render :partial => 'contest_show', :locals => {:topics => @topics, :page => 0, :contest => @contest} %>
<% end %>

View File

@ -1,12 +1,14 @@
<%if @contest%>
<% if @create_member_error_messages%>
alert("<%= @create_member_error_messages%>");
notice_box("<%= @create_member_error_messages%>");
//alert("<%= @create_member_error_messages%>");
<% else %>
$('#game-setting-content-2').html('<%= escape_javascript(render :partial => 'contests/members') %>');
$("#admin_num").html("<%= contest_managers(@contest).count %>");
$("#judge_num").html("<%= contest_judges(@contest).count %>");
$("#contestant_num").html("<%= contest_contestants(@contest).count %>");
alert("添加成功");
notice_box("添加成功");
//alert("添加成功");
<% end%>
hideOnLoad();
<%end%>

View File

@ -1,3 +1,4 @@
hideModal();
$('#game-setting-content-2').html('<%= escape_javascript(render :partial => 'contests/members') %>');
$("#admin_num").html("<%= contest_managers(@contest).count %>");
$("#judge_num").html("<%= contest_judges(@contest).count %>");

View File

@ -0,0 +1,50 @@
<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_contestant_works_path(work.id),:id=>'add_score_'+work.id.to_s) do |f|%>
<li >
<span class="tit_fb"> 评价:</span>
<%= f.text_area 'user_message', :class => 'hwork_ping_text', :id => 'score_comment_'+work.id.to_s, :placeholder => l(:text_caracters_maximum,:count=>500),:maxlength => 500 %>
<div class="cl"></div>
</li>
<p id="hint_message_<%=work.id %>" style="margin-left: 65px;"></p>
<li >
<span class="tit_fb mt2"> 评分:</span>
<input type="number" name="score" id="score_<%= work.id%>" value="<%= (score.nil? || score.score.nil?) ? -1 : score.score%>" min="-1" max="100" size="4" data-units="dollars" />
<span class="ml5">分</span>
<span id="score_notice_span_<%= work.id%>" class="ml5 c_red" style="display: none;">未评分</span>
<div class="cl"></div></li>
<li >
<span class="tit_fb"> 批阅结果:</span>
<div>
<%= render :partial => 'student_work/student_work_attachment_form', :locals => {:work => work,:score => score} %>
</div>
<div class="cl"></div>
<span class="c_red ml5" style="display: none;" id="none_notice_<%= work.id%>">评语、评分、批阅结果至少有一个不为空。</span>
<a href="javascript:void(0);" id="work_submit_<%= work.id %>" class="blue_n_btn fr evaluation_submit" onclick="score_submit('<%=work.id %>');">提交</a>
<div class="cl"></div>
</li>
<% end%>
<script type="text/javascript">
var first_click_score = true;
function score_submit(id){
if ($.trim($('#score_comment_'+id).val()) == "") {
$('#hint_message_'+id).html("为了对参赛者的作品负责,请您务必填写评语");
$("#hint_message_"+id).css('color','#ff0000');
$("#score_comment_"+id).focus();
} else if (parseFloat($("#score_"+id).val()) == -1) {
$('#score_notice_span_'+id).html("请先评分");
$('#score_notice_span_'+id).show();
$("#score_"+id).focus();
}
else if(first_click_score) {
first_click_score = false;
$("#work_submit_"+id).parent().parent().submit();
$('#about_hwork_'+id).html('');
}
}
function submit_teacher_score(id){
if (first_click_score) {
first_click_score = false;
$("#work_submit_"+id).parent().parent().submit();
hideModal();
}
}
</script>

View File

@ -13,12 +13,12 @@
<% my_work = cur_user_works_for_work @contestwork %>
<% if !@is_teacher && !@is_judge && my_work.nil? && User.current.member_of_contest?(@contest) %>
<span class="f12 c_red">您尚未提交作品</span>
<% unless @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
<% if @contestwork.work_status == 1 && (@contestwork.work_type != 3 ||(@contestwork.work_type == 3 && !@contestwork.work_detail_group.base_on_project)) %>
<%=link_to "提交作品", new_contestant_work_path(:work => @contestwork.id),:class => 'blueCir ml5 f12' %>
<% end %>
<% elsif !@is_teacher && !@is_judge && my_work &&Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
<% elsif !@is_teacher && !@is_judge && my_work && @contestwork.work_status > 1 && !@stundet_works.empty?%>
<span class="f12 c_red">截止日期已过,已提交且不可修改</span>
<% elsif !@is_teacher && !@is_judge && my_work &&Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
<% elsif !@is_teacher && !@is_judge && my_work && @contestwork.work_status == 1 && !@stundet_works.empty?%>
<% if @contestwork.work_type == 3 %>
<span class="f12 c_red">组长已提交,组长还可修改</span>
<% else %>

View File

@ -0,0 +1,44 @@
<ul class="ping_box_ul <%= is_last ? '' : 'ping_line'%> fl">
<% show_real_name = @is_teacher || score.user == User.current || score.reviewer_role != 3 %>
<%= link_to image_tag(url_to_avatar(show_real_name ? score.user : ""), :width => "34", :height => "34"), show_real_name ? user_path(score.user) : "javascript:void(0)",:class => "ping_pic fl" %>
<% show_real_score = @contestwork.score_open || @is_teacher || score.contestant_work.user == User.current || score.user == User.current %>
<div class="pingBoxTit">
<%= link_to show_real_name ? score.user.show_name : "匿名", show_real_name ? user_path(score.user) : "javascript:void(0)", :title => show_real_name ? score.user.show_name : "匿评用户", :class => "linkBlue fl" %>
<span class="ml5 fl">
<%= student_work_score_role score%>
</span>
<% unless score.score.nil? %>
<span class="ml20 fl">评分:</span>
<a href="javascript:void(0);" class="c_orange fl" >
<%= show_real_score ? score.score : "**" %>分
</a>
<% end %>
<!--<a href="javascript:void(0);" class="fr linkBlue mr5" onclick="$('#add_score_reply_<%#= score.id%>').slideToggle();">回复</a>-->
<span class="fr c_grey mr20">
<%=format_time score.updated_at %>
</span>
<div class="cl mb5"></div>
<p class="break_word">
<%= score.comment%>
</p>
<div class="cl"></div>
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => score.attachments} %>
<div class="cl"></div>
<!--<div id="add_score_reply_<%#= score.id%>" class="undis">-->
<!--<%#= render :partial => 'add_score_reply',:locals => {:score => score,:is_last => is_last}%>-->
<!--</div>-->
<div class="cl"></div>
<!--<div id="replay_histroy_<%#= score.id%>">-->
<!--<%# score.journals_for_messages.order("created_on desc").each do |jour|%>-->
<!--<%# show_real_name = @is_teacher || score.reviewer_role != 3 || @contestwork.work_status != 3 %>-->
<!--<%#= render :partial => 'jour_replay',:locals => {:jour => jour, :show_real_name => show_real_name || jour.user == User.current}%>-->
<!--<%# end%>-->
<!--</div>-->
<div class="cl"></div>
</div>
</ul>

View File

@ -0,0 +1,8 @@
<%student_work_scores.each do |student_score|%>
<div id="work_score_<%= student_score.id%>">
<%= render :partial => 'contestant_work_score',:locals => {:score => student_score,:is_last => student_score == student_work_scores.last}%>
</div>
<% end%>
<% if is_member_work && student_work_scores.empty? && !@is_teacher %>
<p class="c_red" style="text-align: center">暂无评分</p>
<% end %>

View File

@ -15,7 +15,7 @@
<%=format_time work.commit_time %>
</li>
<% if work.user == User.current && Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") %>
<% if work.user == User.current && @contestwork.work_status == 1 %>
<!-- 我的作业 && 匿评作业 && 未开启匿评,显示编辑和删除按钮 -->
<li class="fr" >
<%= link_to("", contestant_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del",:title=>"删除") %>
@ -76,7 +76,7 @@
<div class="cl"></div>
</li>
<!--<li >-->
<!--<%# if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && !is_my_work)%>-->
<!--<%# if @contestwork.online_evaluation && User.current.judge_of_contest?(@contestwork.contest) && @contestwork.work_status == 3 %>-->
<!--&lt;!&ndash; 老师 || 开启匿评状态 && 不是当前用户自己的作品 &ndash;&gt;-->
<!--<div id="add_student_score_<%#= work.id%>" class="mt10 evaluation">-->
<!--<%#= render :partial => 'add_score',:locals => {:work => work,:score => score,:is_member_work => is_member_work}%>-->
@ -94,7 +94,7 @@
<!--<ul>-->
<!--<li >-->
<!--<%# if @is_teacher %>-->
<!--&lt;!&ndash; 老师 &ndash;&gt;-->
<!--<!-- 老师 -->-->
<!--<div id="add_student_score_<%#= work.id%>" class="mt10 evaluation">-->
<!--<%#= render :partial => 'add_score',:locals => {:work => work,:score => score,:is_member_work => is_member_work}%>-->
<!--</div>-->
@ -104,8 +104,8 @@
<!--</ul>-->
<% end %>
<!--<div class="ping_box fl" id="score_list_<%#= work.id%>" style="<%#= student_work_scores.empty? ? 'padding:0px;' : ''%>">-->
<!--<%#= render :partial => 'student_work_score_records', :locals => {:student_work_scores => student_work_scores, :is_member_work => is_member_work} %>-->
<!--<div class="ping_box fl" id="score_list_<%#= work.id%>" style="<%#= student_work_scores.empty? ? 'padding:0px;' : ''%>">-->
<!--<%#= render :partial => 'contestant_work_score_records', :locals => {:student_work_scores => student_work_scores, :is_member_work => is_member_work} %>-->
<!--</div>-->
<div class="cl"></div>
<!---ping_box end--->

View File

@ -7,7 +7,7 @@
</div>
<div class="homepagePostTitle hidden fl m_w505">
<% index = get_work_index(homework, is_teacher) %>
<%= link_to "<span class='fontBlue2'>题目#{index + 1}</span>".html_safe + homework.name,contestant_works_path(:work => homework.id),:class => "postGrey"%>
<%= link_to homework.name,contestant_works_path(:work => homework.id),:class => "postGrey"%>
</div>
<%=get_cw_status(homework).html_safe %>
<div class="cl"></div>

View File

@ -0,0 +1,18 @@
<% is_member_work = @contestwork.work_type == 3 && @work.contestant_work_projects.empty? %>
$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @new_score,:is_member_work => is_member_work}) %>");
$('#score_<%= @work.id%>').peSlider({range: 'min'});
<% score_open = @is_teacher || @contestwork.score_open == 1 || @work.user == User.current %>
$("#score_list_<%= @work.id%>").html("<%=escape_javascript(render :partial => 'contestant_work_score_records', :locals => {:student_work_scores => @student_work_scores, :is_member_work => is_member_work}) %>");
var num = $("#work_num_<%= @work.id%>").html();
$("#score_list_<%= @work.id%>").removeAttr("style");
<% if @contestwork.work_type == 3 %>
$("#student_work_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'contest_evaluation_un_group_work', :locals => {:student_work => @work}) %>");
<% else %>
$("tr[id='student_work_<%= @work.id%>']").replaceWith("<%= escape_javascript(render :partial => 'contest_evaluation_un_work',:locals => {:student_work => @work, :index => 1, :score_open => score_open}) %>");
$("#work_num_<%= @work.id%>").html(num);
<% end %>
$("#student_work_count").html("<%=@count %>");

View File

@ -98,14 +98,14 @@
<% end %>
<% hcommons.each_with_index do |homework_common,index |%>
<% if homework_common.id == @contestwork.id %>
<%="题目 #{hcommons.count - index}" %>
<%="提交 #{hcommons.count - index}" %>
<% end %>
<% end%>
</a>
<ul>
<% hcommons.each_with_index do |homework_common,index |%>
<li class="pr10">
<%= link_to "题目#{hcommons.count - index}#{homework_common.name}",student_work_index_path(:homework => homework_common.id)%>
<%= link_to "提交#{hcommons.count - index}#{homework_common.name}",contestant_works_path(:work => homework_common.id)%>
<%#= link_to "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
</li>
<% end%>
@ -143,7 +143,7 @@
<ul class="homework-detail-tab mb10 mt15 fb">
<li class="selected" id="student_work_tab1" onclick="HoverLi(1);">
<a href="javascript:void(0);" class="fontGrey3">题目信息</a>
<a href="javascript:void(0);" class="fontGrey3">提交信息</a>
</li>
<li onclick="HoverLi(2);" id="student_work_tab2">
<a href="javascript:void(0);" class="fontGrey3">作品列表</a>

View File

@ -43,7 +43,7 @@
<% when 'News' %>
<%= render :partial => 'users/contest_news', :locals => {:activity => act, :user_activity_id => activity.id, :is_contest => 1} %>
<% when 'Message' %>
<%#= render :partial => 'users/contest_message', :locals => {:activity => act, :user_activity_id => activity.id,:is_course=>1,:is_board=>0} %>
<%= render :partial => 'users/contest_message', :locals => {:activity => act, :user_activity_id => activity.id,:is_course=>1,:is_board=>0} %>
<% when 'Poll' %>
<%#= render :partial => 'users/contest_poll', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<% when 'JournalsForMessage' %>

View File

@ -3,7 +3,7 @@
<span class="sy_cgrey">&nbsp;&gt;&nbsp;</span>
<%= link_to @contest.name, contest_path(@contest), :class => "sy_cgrey" %>
</p>
<% if User.current.admin_of_contest?(@contest) %>
<% if User.current.admin_of_contest?(@contest) || User.current.admin? %>
<%= render :partial => "contests/mamager_setting" %>
<% end %>
@ -38,5 +38,22 @@
<% else %>
<%= link_to "加入竞赛",join_contest_contests_path(),:remote => true, :method => "get", :class => "fr sy_btn_blue mt28 ml10" %>
<% end %>
<span class="fr mt30 f16"> 邀请码:<span class="sy_corange"><%= @contest.invite_code %></span></span>
<div class="cl"></div>
<span class="fr mt30 f16"> 邀请码:
<span class="sy_corange">
<span class="sy_corange">
<% if @contest.invite_code_halt == 0 %>
<%=@contest.generate_invite_code %>
<% else %>
已停用
<% end %>
</span>
</span></span>
<div class="cl"></div>
<% if User.current.admin_of_contest?(@contest) || User.current.admin? %>
<div class="invite_code_tip_box fontGrey2" id="invite_code_tip_box" style="top: 160px;">
<em></em>
<span></span>
<p class="mt10 mb5"><%= @contest.invite_code_halt == 0 ? "请将邀请码告诉成员" : "邀请码已停用" %></p>
<p class="mb10"><%= @contest.invite_code_halt == 0 ? "他们可以主动加入" : "暂时停止成员主动加入" %></p>
</div>
<% end %>

View File

@ -75,7 +75,8 @@
<a href="javascript:void(0)" class="sy_btn_blue mr5" style="display: none;" onclick="$('#member-<%= member.id%>-roles-form').submit();">保存</a>
<a href="javascript:void(0)" class="sy_btn_grey mr5" style="display: none;" onclick="cancel_edit($(this), <%=member.id %>);">取消</a>
<% unless member.user == @contest.user %>
<%= delete_link contest_member_path(member),
<a href="javascript:void(0)" class="sy_btn_grey mr5" id="delete_member_<%=member.id %>" onclick="delete_confirm_box_2('<%=contest_member_path(member) %>', '<%= l(:label_delete_confirm)%>')">删除</a>
<%#= delete_link contest_member_path(member),
:remote => true,
:class => "sy_btn_grey mr5",
:id => "delete_member_#{member.id}",

View File

@ -3,9 +3,19 @@
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><%= link_to !@contest.is_public ? "设为公开" : "设为私有", {:controller => 'contests', :action => 'private_or_public', :id => @contest},:remote=>true,:confirm=>"您确定要设置为"+(!@contest.is_public ? "公开" : "私有")+"吗", :class => "postOptionLink" %></li>
<!--<li><a href="javascript:void(0);" class="postOptionLink">暂停加入</a></li>-->
<% if @contest.invite_code_halt == 0 %>
<li><a href="javascript:void(0);" class="postOptionLink" onclick="alert_halt_code();">暂停加入</a></li>
<% elsif @contest.invite_code_halt == 1 %>
<li><a href="<%=set_invite_code_halt_contest_path(@contest) %>" data-remote="true" class="postOptionLink">放开加入</a></li>
<% end %>
<li><%= link_to "配置", {:controller => 'contests', :action => 'settings', :id => @contest}, :class => "postOptionLink" %></li>
<!--<li><a href="javascript:void(0);" class="postOptionLink">删除</a></li>-->
<li>
<% if !@contest.is_delete %>
<a href="javascript:void(0);" class="postOptionLink" onclick="delete_confirm_box_2('<%=contest_path(@contest) %>', '您确定要删除该竞赛吗?<br/>删除后可联系系统管理员进行恢复')">删除</a>
<% else %>
<%=link_to "恢复竞赛", renew_contest_path(@contest), :class => "postOptionLink" %>
<% end %>
</li>
</ul>
</li>
</ul>

View File

@ -11,7 +11,7 @@
<li><%= link_to "作品动态", contest_activities_contest_path(@contest, :type => 'work'), :class => "homepagePostTypeAssignment postTypeGrey"%></li>
<li><%= link_to "通知动态", contest_activities_contest_path(@contest, :type => 'news'), :class => "homepagePostTypeNotice postTypeGrey"%></li>
<!--<li><%#= link_to "资源库动态", {:controller => "courses", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey"%></li>-->
<!--<li><%#= link_to "论坛动态", {:controller => "courses", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey"%></li>-->
<li><%= link_to "论坛动态", contest_activities_contest_path(@contest, :type => 'message'), :class => "homepagePostTypeForum postTypeGrey"%></li>
<!--<li><%#= link_to "留言动态", {:controller => "courses", :action => "show", :type => "journalsForMessage"}, :class => "homepagePostTypeMessage postTypeGrey"%></li>-->
<!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%></li>-->
</ul>

View File

@ -0,0 +1,2 @@
hideModal();
window.location.href = "<%=user_contest_community_path(User.current) %>";

View File

@ -0,0 +1,2 @@
$("#contest_base_info").html("<%= escape_javascript(render :partial => 'contests/contest_base_info') %>");
hideModal();

View File

@ -10,10 +10,10 @@
<div class="cl"></div>
<div>
<% if (@contest.description.nil? || @contest.description == "") && User.current.admin_of_contest?(@contest) %>
<% if (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) && User.current.admin_of_contest?(@contest) %>
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">请尽快补充竞赛说明,赢得更多参赛</p>
<% elsif (@contest.description.nil? || @contest.description == "") %>
<p class="sy_tab_con_p">请尽快补充竞赛说明,赢得更多参赛者的青睐吧~</p>
<% elsif (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) %>
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">尚未发布竞赛说明,敬请期待~</p>
<% else %>

View File

@ -16,18 +16,21 @@
<li class="navHomepageMenu fl">
<%= link_to "项目", user_project_community_path(User.current), :class => "c_white f16 db p10", :target => "_blank" %>
</li>
<li class="navHomepageMenu fl">
<%= link_to "竞赛", user_contest_community_path(User.current), :class => "c_white f16 db p10", :target => "_blank" %>
</li>
<% if hidden_unproject_infos %>
<!-- <li class="navHomepageMenu fl">
<%#= link_to "题库", user_homeworks_user_path(User.current), :class => "c_white f16 db p10"%>
</li>-->
<% memo = Memo.where(:id => 1168).first %>
<% unless memo.nil? %>
<li class="navHomepageMenu fl mr30">
<li class="navHomepageMenu fl mr20">
<%= link_to "贴吧", forums_path, :class =>"c_white f16 db p10", :target => "_blank" %>
</li>
<% end %>
<% else %>
<li class="navHomepageMenu fl mr40">
<li class="navHomepageMenu fl mr30">
<a href="<%= forums_path(:reorder_complex=>'desc')%>" target="_blank" class="c_white f16 db p10" >公共贴吧</a>
</li>
<% end %>

View File

@ -14,22 +14,30 @@
<ul class="user_navmore_txt">
<% if is_teacher %>
<li class="clear">
<%= link_to "作品",works_path(:contest => contest.id), :class => 'user_navmore_li fl', :target => '_blank' %>
<%= link_to "提交",works_path(:contest => contest.id), :class => 'user_navmore_li fl', :target => '_blank' %>
<%= link_to '+',works_path(:contest => contest.id,:is_new => 1), :class => 'user_navmore_add fl', :title => '发布作品',:target => '_blank' %>
</li>
<li class="clear">
<%= link_to "通知", contest_news_index_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
<%= link_to "+", new_contest_news_path(contest,:is_new=>1), :class => 'user_navmore_add fl', :title => '发布通知',:target => '_blank' %>
</li>
<li class="clear">
<%= link_to "论坛", contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
<%= link_to "+", contest_boards_path(contest, :flag => true, :is_new => 1), :class => 'user_navmore_add fl', :title => '发布帖子',:target => '_blank' %>
</li>
<% else %>
<li>
<%= link_to "作品",works_path(:contest => contest.id), :class => 'user_navmore_li', :target => '_blank' %>
<%= link_to "提交",works_path(:contest => contest.id), :class => 'user_navmore_li', :target => '_blank' %>
<div class="cl"></div>
</li>
<li>
<%= link_to "通知", contest_news_index_path(contest), :class => 'user_navmore_li',:target => '_blank' %>
<div class="cl"></div>
</li>
<li class="clear">
<%= link_to "论坛", contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
<div class="cl"></div>
</li>
<% end %>
<!--<li class="clear">-->
<!--<%#= link_to "论坛",contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>-->

View File

@ -10,7 +10,7 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','syllabus','css/moduel', 'css/user', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%>
<%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify','contest'%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%>
@ -47,7 +47,7 @@
<div class="user_leftnav ">
<% if hidden_unproject_infos %>
<ul class="users_accordion mb10">
<li id="user_01" class="user_icons_course">
<li id="user_01" class="user_icons_contest">
<%= link_to '竞赛',{:controller => "users", :action => "user_contestlist", :id => @user}, :id => "user_contest_list" %>
<font class="show-all-sub"><%= link_to '全部',{:controller => "users", :action => "user_contestlist", :id => @user}, :style => "color:#aaa;" %></font>
<% contests = @user.favorite_contests.visible.where("is_delete =?", 0).select("contests.*,(SELECT MAX(updated_at) FROM `contest_activities` WHERE contest_activities.contest_id = contests.id) AS a").order("a desc").limit(10) %>

View File

@ -12,7 +12,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus', 'css/moduel','css/contest'%>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify' %>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify','contest' %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
@ -40,11 +40,16 @@
</li>
<!--<li id="sy_03" class="sy_icons_boards"> <a href="">讨论区<span>26</span></a> <a href="javascript:void(0);" class="sy_class_add"></a></li>-->
<li id="sy_03" class="sy_icons_hwork">
<a href="<%= works_path(:contest => @contest) %>">作品<span><%= work_num%></span></a>
<a href="<%= works_path(:contest => @contest) %>">提交<span><%= work_num%></span></a>
<% if is_admin %>
<a href="<%= works_path(:contest => @contest.id,:is_new => 1) %>" class="sy_class_add"></a>
<% end %>
</li>
<li id="sy_04" class="sy_icons_boards">
<% count = @contest.boards.first ? (@contest.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", @contest.boards.first.id, nil).count) : 0 %>
<a href="<%=contest_boards_path(@contest) %>">讨论区<span><%=count %></span></a>
<%= link_to( "",contest_boards_path(@contest, :flag => true, :is_new => 1), :class => 'sy_class_add', :title =>"#{l(:label_message_new)}") if is_admin %>
</li>
<li id="sy_05" class="sy_icons_news">
<%= link_to "通知<span>#{@contest.news.count}</span>".html_safe, contest_news_index_path(@contest), :class => "sy_icons_feedback" %>
<% if is_admin %>
@ -110,6 +115,13 @@
}
<% end %>
});
function alert_halt_code(){
var htmlvalue = '<div id="muban_popup_box" style="width:400px;"><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">邀请码停用后,用户不能主动加入该竞赛了</p><p class="text_c mt10 f14">您是否确认停用</p><div class="cl"></div>'+
'<a href="<%=set_invite_code_halt_contest_path(@contest) %>" class="fr sy_btn_blue mr135 mt10" data-remote="true">确&nbsp;&nbsp;定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取&nbsp;&nbsp;消</a></div></div>';
pop_box_new(htmlvalue, 400, 180);
}
</script>
</html>

View File

@ -244,7 +244,7 @@
<%= link_to "竞赛社区", user_contest_community_path(User.current), :class => "fl" , :target => "_blank"%>
</h3>
<ul>
<li class="home-user-leftnav-li icons-class clear">
<li class="home-user-leftnav-li icons-contest clear">
<%= link_to user_contest_count > 0 ? "竞赛<span class='issues_nav_tag mr10 fr' style='line-height:18px;margin-top: 9px;'>#{user_contest_count}</span>".html_safe : "竞赛",
user_contest_community_path(User.current), :id => "user_contest_list", :target => "_blank" %>
</li>

View File

@ -0,0 +1,131 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
<% end %>
<script type="text/javascript">
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
</script>
<script>
function expand_reply(container,btnid){
var target = $(container).children();
var btn = $(btnid);
if(btn.data('init')=='0'){
btn.data('init',1);
btn.html('收起回复');
target.show();
}else{
btn.data('init',0);
btn.html('展开更多');
target.hide();
target.eq(0).show();
target.eq(1).show();
target.eq(2).show();
}
}
$(function() {
sd_create_editor_from_data(<%= @topic.id%>,null,"100%", "<%=@topic.class.to_s%>");
showNormalImage('message_description_<%= @topic.id %>');
});
</script>
<div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @topic.id%>').show();" onmouseout="$('#message_setting_<%= @topic.id%>').hide();">
<div class="postThemeContainer">
<div class="postDetailPortrait">
<%= link_to image_tag(url_to_avatar(@topic.author), :width => 50, :height => 50,:alt=>'图像' ), user_path(@topic.author) %>
</div>
<div class="postThemeWrap">
<% if User.current.logged? %>
<div class="homepagePostSetting" id="message_setting_<%= @topic.id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<%= link_to(
l(:button_edit),
{:action => 'edit', :id => @topic},
:class => 'postOptionLink'
) if @message.contest_editable_by?(User.current) %>
</li>
<li>
<%= link_to(
l(:button_delete),
{:action => 'destroy', :id => @topic},
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if @message.contest_destroyable_by?(User.current) %>
</li>
<li><%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{@message.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %></li>
</ul>
</li>
</ul>
</div>
<%end%>
<div class="postDetailTitle fl break_full_word">
<a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">主题: <%= @topic.subject%></a>
</div>
<div class="cl"></div>
<div class="postDetailCreater">
<%= link_to @topic.author.show_name, user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
</div>
<div class="postDetailDate mb5"><%= format_time( @topic.created_on)%></div>
<div class="cl"></div>
<div class="homepagePostIntro memo-content upload_img break_full_word ke-block" id="message_description_<%= @topic.id %>" >
<%= @topic.content.html_safe%>
</div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @topic} %>
</div>
</div>
<div class="cl"></div>
</div>
<div class="cl"></div>
<div class="homepagePostReply">
<div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复
<sapn class="mr15"><%= @reply_count>0 ? "#{@reply_count}" : "" %></sapn><span style="color: #cecece;">▪</span>
<span id="praise_count_<%=@topic.id %>">
<%=render :partial=> "praise_tread/praise", :locals => {:activity=>@topic, :user_activity_id=>@topic.id,:type=>"activity"}%>
</span>
</div>
</div>
<%# all_comments = []%>
<%# comments = get_all_children(all_comments, @topic) %>
<div class="" id="reply_div_<%= @topic.id %>">
<%= render :partial => "messages/contest_show_replies" %>
</div>
<div class="cl"></div>
<% if !@topic.locked? && User.current.logged? %>
<div class="talkWrapMsg" nhname="about_talk_reply">
<em class="talkWrapArrow"></em>
<div class="cl"></div>
<div class="talkConIpt ml5 mb10" id="reply<%= @topic.id %>">
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
<%= render :partial => 'form_course', :locals => {:f => f, :replying => true} %>
<%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'course_board_canel_message_replay();', :class => "grey_btn fr c_white mt10 mr5 ml10" %>
<%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'course_board_submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-left: 50px;" %>
<% end %>
<div class="cl"></div>
</div>
</div>
<% end %>
</div>
</div>
<script type="text/javascript">
$(function(){
$("#message_description_<%= @topic.id %> p,#message_description_<%= @topic.id %> span,#message_description_<%= @topic.id %> em").each(function(){
var postContent = $(this).html();
postContent = postContent.replace(/&nbsp;/g," ");
postContent= postContent.replace(/ {2}/g,"&nbsp; ");
postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;");
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
autoUrl('message_description_<%= @topic.id %>');
});
</script>

View File

@ -0,0 +1,60 @@
<% @replies.each do |reply| %>
<script type="text/javascript">
$(function(){
showNormalImage('reply_message_description_<%= reply.id %>');
autoUrl('reply_message_description_<%= reply.id %>');
});
</script>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
</div>
<div class="homepagePostReplyDes" onmouseover="$('#delete_reply_<%=reply.id %>').show();" onmouseout="$('#delete_reply_<%=reply.id %>').hide();">
<%= render :partial => 'users/message_contents', :locals => {:comment => reply, :type => 'Message', :user_activity_id => @topic.id}%>
<div class="homepagePostReplyContent upload_img break_word table_maxWidth" id="reply_message_description_<%= reply.id %>">
<%= reply.content.html_safe%>
</div>
<div class="orig_reply mb10 mt-10">
<div class="reply">
<span class="reply-right">
<span class="reply_praise_count_<%= reply.id %>">
<%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %>
</span>
<span style="position: relative" class="fr mr20">
<%= link_to(
l(:button_reply),
{:action => 'quote', :id => reply},
:remote => true,
:method => 'get',
:title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %>
<span id="reply_iconup_<%= reply.id %>" class="reply_iconup02" style="display: none"> ︿</span>
</span>
<%= link_to(
l(:button_delete),
{:action => 'destroy', :id => reply},
:method => :post,
:id => "delete_reply_#{reply.id}",
:class => 'fr mr20 undis',
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if reply.contest_destroyable_by?(User.current) %>
</span>
<div class="cl"></div>
</div>
</div>
<p id="reply_message_<%= reply.id%>"></p>
</div>
<div class="cl"></div>
</div>
<% end %>
<% if @limit_count > @page * @limit + 10 %>
<div id="more_message_replies">
<div class="detail_cont_hide clearfix">
<span class="orig_icon" >&darr; </span>
<span class="orig_icon" style="display:none;" > &uarr;</span>
<%= link_to '点击展开更多回复', board_message_path(@topic.board_id, @topic, :page => @page),:remote=>true %>
</div>
</div>
<% end %>

View File

@ -7,6 +7,8 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(re
<%elsif @course%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%elsif @contest%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/contest_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<% elsif @org_subfield %>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/org_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%end%>

View File

@ -24,6 +24,19 @@
:locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %>
<% end %>
</div>
<% elsif @message.contest %>
<div nhname="topic_form">
<%= form_for @message, {
:as => :message,
:url => {:action => 'edit',:is_course=>@is_course,:is_board=>@is_board},
:html => {:multipart => true,
:id => 'message-form',
:method => :post}
} do |f| %>
<%= render :partial => 'boards/contest_message_edit',
:locals => {:f => f, :edit_mode => true, :topic => @message, :contest => @message.contest} %>
<% end %>
</div>
<% elsif @message.board.org_subfield %>
<%= form_for @message, {
:as => :message,

View File

@ -7,6 +7,8 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(re
<%elsif @course%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%elsif @contest%>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/contest_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<% elsif @org_subfield %>
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/org_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
<%end%>

View File

@ -2,6 +2,8 @@
<%= render :partial => 'project_show', locals: {project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_show', locals: {course: @course} %>
<% elsif @contest %>
<%= render :partial => 'contest_show', locals: {contest: @contest} %>
<% else %>
<%= render :partial => 'org_subfield_show', :locals => {:org_subfield => @org_subfield} %>
<% end %>

View File

@ -1,7 +1,7 @@
<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_student_work_path(work.id),:id=>'add_score_'+work.id.to_s) do |f|%>
<li >
<span class="tit_fb"> 评价:</span>
<%= f.text_area 'user_message', :class => 'hwork_ping_text', :id => 'score_comment_'+work.id.to_s, :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %>
<%= f.text_area 'user_message', :class => 'hwork_ping_text', :id => 'score_comment_'+work.id.to_s, :placeholder => l(:text_caracters_maximum,:count=>500),:maxlength => 500 %>
<div class="cl"></div>
</li>
<p id="hint_message_<%=work.id %>" style="margin-left: 65px;"></p>

View File

@ -1,7 +1,7 @@
<% member = ContestMember.where("user_id = #{@user.id} and contest_id = #{contest.id}").first %>
<% if User.current == @user %>
<% if member %>
<%= link_to "", cancel_or_collect_user_path(@user, :contest => contest.id), :class => "#{member.is_collect == true ? 'icons_project_favorite mt3' : 'icons_project_star mt3'}", :target => '_blank', :remote => true, :title => "#{member.is_collect == true ? '点击将其从个人主页的项目列表中移除' : '点击将其添加至个人主页的项目列表中'}" %>
<%= link_to "", cancel_or_collect_user_path(@user, :contest => contest.id), :class => "#{member.is_collect == true ? 'icons_project_favorite mt3' : 'icons_project_star mt3'}", :target => '_blank', :remote => true, :title => "#{member.is_collect == true ? '点击将其从左侧导航的竞赛列表中移除' : '点击将其添加至左侧导航的竞赛列表中'}" %>
<% end %>
<% else %>
<% if member %>

View File

@ -11,8 +11,7 @@
<div>
<p class="fl sy_p_grey">
更新时间:<%= format_date(contest.updated_at) %> &nbsp;&nbsp;&nbsp;
<% contestUser = User.where("id=?", contest.user_id).first %>
单位:<%= contestUser.user_extensions.school_id.blank? ? "无" : contestUser.user_extensions.school.name %>
创建者:<%= contest.user.show_name %>
</p>
</div>
<div class="cl"></div>

View File

@ -0,0 +1,92 @@
<div class="resources mt10" id="user_activity_<%= user_activity_id%>" onmouseover="$('#message_setting_<%= user_activity_id%>').show();" onmouseout="$('#message_setting_<%= user_activity_id%>').hide();">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author, :host => Setting.host_user), :alt => "用户头像" %>
<%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word">
<%= link_to activity.author.show_name, user_path(activity.author, :host=>Setting.host_user), :class => "newsBlue mr15" %>
TO
<% str = is_course == 1 ? "#{activity.board.parent.nil? ? '竞赛讨论区' : activity.board.name}" : activity.contest.name.to_s+" | #{activity.board.parent.nil? ? '竞赛讨论区' : activity.board.name}" %>
<%= link_to str, contest_boards_path(activity.contest), :class => "newsBlue ml15"%>
</div>
<div class="homepagePostTitle hidden m_w530 fl">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<% else %>
<%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
<% end %>
</div>
<% if activity.sticky == 1 %>
<span class="sticky_btn_cir ml10">置顶</span>
<% end%>
<% if activity.locked %>
<span class="locked_btn_cir ml10 fl" title="已锁定">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
<% end %>
<div class="cl"></div>
<div class="homepagePostDate fl">
发帖时间:<%= format_time(activity.created_on) %>
</div>
<div class="homepagePostDate fl ml15">
更新时间:<%= format_time(ContestActivity.where("contest_act_type='#{activity.class}' and contest_act_id =#{activity.id}").first.updated_at) %>
</div>
<div class="cl"></div>
<% if activity.parent_id.nil? %>
<% content = activity.content %>
<% else %>
<% content = activity.parent.content %>
<% end %>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
<div class="cl"></div>
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
</div>
<% if User.current.logged? %>
<div class="homepagePostSetting" id="message_setting_<%= user_activity_id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<% if activity.author.id == User.current.id%>
<li>
<%= link_to(
l(:button_edit),
edit_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board),
:class => 'postOptionLink'
) if activity.contest_editable_by?(User.current) %>
</li>
<li>
<%= link_to(
l(:button_delete),
delete_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board),
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if activity.contest_destroyable_by?(User.current) %>
</li>
<% end %>
<li><%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{activity.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %></li>
</ul>
</li>
</ul>
</div>
<% end %>
</div>
<div class="cl"></div>
</div>
<div class="homepagePostReply">
<div id="activity_post_reply_<%=user_activity_id %>">
<%=render :partial => 'users/contest_message_post_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -0,0 +1,35 @@
<% all_replies = Message.where("root_id = #{activity.id}").reorder("created_on desc") %>
<% count = all_replies.count %>
<% no_children_comments = get_no_children_comments all_replies %>
<%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :expand_more =>no_children_comments[:three_more]} %>
<% if count > 0 %>
<div class="" id="reply_div_<%= user_activity_id %>">
<%= render :partial => 'users/message_replies', :locals => {:comments => no_children_comments[:no_children_comments], :user_activity_id => user_activity_id, :type => 'Message', :activity_id =>activity.id}%>
</div>
<% end %>
<% if !activity.locked? %>
<div class="homepagePostReplyContainer borderBottomNone minHeight48">
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %></div>
<div class="homepagePostReplyInputContainer mb10">
<% if User.current.logged? %>
<div nhname='new_message_<%= user_activity_id%>' style="display:none;">
<%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id},:method => "post", :remote => true) do |f|%>
<input type="hidden" name="quote[quote]" value="">
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<div nhname='toolbar_container_<%= user_activity_id%>'></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<div class="cl"></div>
<p nhname='contentmsg_<%= user_activity_id%>'></p>
<% end%>
<div class="cl"></div>
</div>
<% else %>
<%= render :partial => "users/show_unlogged" %>
<% end %>
<div class="cl"></div>
</div>
<div class="cl"></div>
</div>
<% end %>

View File

@ -8,20 +8,22 @@
<div class="homepagePostDes">
<div class="homepagePostTo break_word">
<%= link_to activity.user.show_name, user_path(activity.user,:host=>Setting.host_user), :class => "newsBlue mr15" %>
TO
<% if hw_status == 3 || hw_status == 2 %>
<%= link_to "作品", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%>
<% if hw_status == 3 %>
<% elsif hw_status == 2 %>
TO
<%= link_to "提交", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%>
<% else %>
<%= link_to activity.contest.name.to_s+" | 竞赛作品", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%>
TO
<%= link_to activity.contest.name.to_s+" | 竞赛提交", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%>
<% end %>
</div>
<div class="homepagePostTitle hidden fl m_w505"> <!--+"(作业名称)"-->
<% if hw_status == 3 || hw_status == 5 %>
<% index = get_work_index(activity, is_teacher) %>
<%= link_to "<span class='fontBlue2'>作品#{index+1}</span>".html_safe+activity.name,contestant_works_path(:work => activity.id),:class => "postGrey"%>
<% else %>
<%= link_to activity.name.to_s, contestant_works_path(:work => activity.id), :class => "postGrey"%>
<% end %>
<%# if hw_status == 3 || hw_status == 5 %>
<%# index = get_work_index(activity, is_teacher) %>
<%= link_to activity.name,contestant_works_path(:work => activity.id),:class => "postGrey"%>
<%# else %>
<%#= link_to activity.name.to_s, contestant_works_path(:work => activity.id), :class => "postGrey"%>
<%# end %>
</div>
<%=get_cw_status(activity).html_safe %>

View File

@ -49,7 +49,22 @@
<%= link_to "编 辑",edit_work_path(activity, :hw_status => hw_status), :class => "wpostOptionLink"%>
</li>
<li>
<%= link_to "删 除",work_path(activity, :hw_status => hw_status),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "wpostOptionLink" %>
<a href="javascript:void(0)" onclick="delete_confirm_box_2('<%=work_path(activity, :hw_status => hw_status) %>', '提交的作品将被全部清空<br/>是否确定删除?')" class="wpostOptionLink">删除</a>
</li>
<li>
<%= link_to("评分设置", score_rule_set_work_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "wpostOptionLink", :remote => true) %>
</li>
<% if (!activity.online_evaluation && !activity.is_open && activity.work_status == 2) || (activity.online_evaluation && activity.work_status == 4 && !activity.is_open) %>
<li>
<a href="javascript:void(0)" onclick="alert_open_contestant_works('<%= open_contestant_works_work_path(activity, :user_activity_id => user_activity_id,:hw_status=>hw_status)%>', false)" class="wpostOptionLink">公开作品</a>
</li>
<% elsif activity.is_open %>
<li>
<a href="javascript:void(0)" onclick="alert_open_contestant_works('<%= open_contestant_works_work_path(activity, :user_activity_id => user_activity_id,:hw_status=>hw_status)%>', true)" class="wpostOptionLink">取消公开</a>
</li>
<% end %>
<li>
<%= link_to("成绩公开范围", alert_score_open_modal_work_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "wpostOptionLink", :remote => true) %>
</li>
</ul>
</li>

View File

@ -60,7 +60,8 @@
<div class="cl"></div>
</div>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<div class="icons_tishi"><img src="/images/sy/icons_smile.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">没有数据可以显示!</p>
<% end %>
</div>
</div>

View File

@ -13,23 +13,12 @@
:class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
</span>
<span class="homepageNewsType fl">
<% if applied_contest.role
role_str = ""
if applied_contest.role.include?('13') && applied_contest.role.include?('14')
role_str = "管理员、评委"
elsif applied_contest.role.include?('13')
role_str = "管理员"
elsif applied_contest.role.include?('14')
role_str = "评委"
elsif applied_contest.role.include?('15')
role_str = "参赛者"
end
end %>
申请以<%= role_str %>的身份加入竞赛:
<%= message_user.user_extensions.school_id.blank? ? "" : "来自"+message_user.user_extensions.school.name+"" %>
申请以"<%= get_role_str ma.role %>"的身份加入竞赛:
</span>
</li>
<li class="messageInformationContents">
<% content = message_user.show_name + "申请成为班级\"" + "#{contest.name}" + "\"的" + role_str %>
<% content = message_user.show_name + "申请成为班级\"" + "#{contest.name}" + "\"的" + get_role_str(ma.role) %>
<%= link_to contest.name, contest_path(contest.id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank', :title => "#{content}" %>
</li>
@ -41,9 +30,9 @@
|
<%= link_to '拒绝',dealwith_apply_request_contest_path(contest,:agree=>'N',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%>
<% elsif ma.status == 1%> <!-- 同意 -->
已同意申请
<span title="<%= ma.applied_user_id ? User.find(ma.applied_user_id).show_name : '管理员' %>已同意"><%= ma.applied_user_id ? User.find(ma.applied_user_id).show_name : "管理员" %>已同意</span>
<% elsif ma.status == 2%> <!-- 拒绝 -->
已拒绝申请
<span title="<%= ma.applied_user_id ? User.find(ma.applied_user_id).show_name : '管理员' %>已拒绝"><%= ma.applied_user_id ? User.find(ma.applied_user_id).show_name : "管理员" %>已拒绝</span>
<%end %>
</span>
</li>

View File

@ -36,7 +36,7 @@
<span id="reply_iconup_<%=comment.id %>" class="reply_iconup02" style="display: none"> ︿</span>
</span>
<% end %>
<% if comment.course_destroyable_by?(User.current) || comment.destroyable_by?(User.current) %>
<% if comment.course_destroyable_by?(User.current) || comment.destroyable_by?(User.current) || comment.contest_destroyable_by?(User.current) %>
<%= link_to(
l(:button_delete),
delete_board_message_path(comment,:board_id =>comment.board.id, :user_activity_id => user_activity_id, :activity_id => activity_id),

View File

@ -90,7 +90,7 @@
<% when 'News' %>
<%= render :partial => 'contest_news', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<% when 'Message' %>
<%#= render :partial => 'contest_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_contest => 0, :is_board => 0} %>
<%= render :partial => 'contest_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_course => 0, :is_board => 0} %>
<% when 'Contest' %>
<%= render :partial => 'users/contest_create', :locals => {:activity => act, :user_activity_id => act.id} %>
<% when 'JournalsForMessage' %>

View File

@ -32,5 +32,191 @@
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<!--被管理员拉入竞赛-->
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 0 %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<%= link_to image_tag(url_to_avatar(User.find(ma.contest_message_id)), :width => "30", :height => "30"), user_path(ma.contest_message_id), :target => '_blank' %>
</li>
<li class="homepageNewsPubType fl">
<%=link_to User.find(ma.contest_message_id).show_name, user_path(User.find(ma.contest_message_id)), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="homepageNewsType fl">将您加入了竞赛:</span>
</li>
<li class="messageInformationContents">
<%= link_to ma.contest.name, contest_path(ma.contest), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
</li>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<!--被管理员拉入竞赛-->
<% elsif ma.contest_message_type == "JoinContest" and ma.status == 1 %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<div class="navHomepageLogo fl"><%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %></div>
</li>
<li class="homepageNewsPubType fl">
<span class="newsBlue homepageNewsPublisher">系统提示</span>
<span class="homepageNewsType fl">您增加了新的竞赛成员:</span>
</li>
<li class="messageInformationContents">
<%= link_to User.find(ma.contest_message_id).login+"("+(User.find(ma.contest_message_id).realname ? User.find(ma.contest_message_id).realname : User.find(ma.contest_message_id).login) +")",
{:controller => 'contests', :action => 'settings', :id => ma.contest_id, :tab=>'member'},
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:target => '_blank' %>
</li>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<!--被老师移出课程-->
<% elsif ma.contest_message_type == "RemoveFromContest" %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<%=link_to image_tag(url_to_avatar(User.find(ma.contest_message_id)), :width => "30", :height => "30"), user_path(ma.contest_message_id), :target => '_blank' %>
</li>
<li class="homepageNewsPubType fl">
<%=link_to User.find(ma.contest_message_id).show_name, user_path(User.find(ma.contest_message_id)), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="homepageNewsType fl">将您移出了竞赛:</span>
</li>
<li class="messageInformationContents">
<%= link_to ma.contest.name, contest_path(ma.contest), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
</li>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<!--发布竞赛题目-->
<% elsif ma.contest_message_type == "Work" && ma.status.nil? && ma.contest_message %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<%=link_to image_tag(url_to_avatar(ma.contest_message.user), :width => "30", :height => "30"), user_path(ma.contest_message.user), :target => '_blank' %>
</li>
<li class="homepageNewsPubType fl">
<%=link_to ma.contest_message.user.show_name, user_path(ma.contest_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="homepageNewsType fl">发布了竞赛题:</span>
</li>
<li class="messageInformationContents">
<% if User.current.contestant_of_contest?(ma.contest_message.contest) && cur_user_works_for_work(ma.contest_message).nil? %>
<%= link_to ma.contest_message.name, new_contestant_work_path(:work => ma.contest_message.id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "竞赛题:#{ma.contest_message.name}"
%>
<% else %>
<%= link_to ma.contest_message.name, contestant_works_path(:work => ma.contest_message.id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "竞赛题:#{ma.contest_message.name}"
%>
<% end %>
</li>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<!--竞赛截止时间快到了-->
<% elsif ma.contest_message_type == "Work" && ma.status == 1 && ma.contest_message %>
<ul class="homepageNewsList fl">
<div class="shortMessageWidth">
<li class="homepageNewsPortrait fl">
<%=link_to image_tag(url_to_avatar(ma.contest_message.user), :width => "30", :height => "30"), user_path(ma.contest_message.user), :target => '_blank' %>
</li>
<li class="homepageNewsPubType fl">
<%=link_to ma.contest_message.user.show_name, user_path(ma.contest_message.user),
:class => "newsBlue homepageNewsPublisher",
:title => "#{ma.contest_message.user.show_name}",
:target => '_blank' %>
<span class="homepageNewsType fl">发布的竞赛题:</span></li>
<li class="messageInformationContents">
<%= link_to ma.contest_message.name, contestant_works_path(:work => ma.contest_message.id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "竞赛题:#{ma.contest_message.name}"
%>
</li>
</div>
<li class="messageOperateContents fl" title="截止时间快到啦">截止时间快到啦</li>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<!--发布竞赛通知-->
<% elsif ma.contest_message_type == "News" && ma.contest_message %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<%=link_to image_tag(url_to_avatar(ma.contest_message.author), :width => "30", :height => "30"),user_path(ma.contest_message.author), :target => '_blank' %>
</li>
<li class="homepageNewsPubType fl">
<%=link_to ma.contest_message.author.try(:show_name), user_path(ma.contest_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="homepageNewsType fl">发布了竞赛通知:</span>
</li>
<li class="messageInformationContents">
<%= link_to ma.contest_message.title, {:controller => 'news', :action => 'show', :id => ma.contest_message.id },
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "#{ma.contest_message.title}"
%>
</li>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<!--回复了竞赛通知-->
<% elsif ma.contest_message_type == "Comment" && ma.contest_message %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<%=link_to image_tag(url_to_avatar(ma.contest_message.author), :width => "30", :height => "30"), user_path(ma.contest_message.author), :target => '_blank' %>
</li>
<li class="homepageNewsPubType fl">
<%=link_to User.find(ma.contest_message.author_id).show_name, user_path(ma.contest_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="homepageNewsType fl">回复了竞赛通知:</span>
</li>
<li class="messageInformationContents">
<%= link_to ma.contest_message.commented.title, {:controller => 'news', :action => 'show', :id => ma.contest_message.commented.id },
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" ,
:target => '_blank',
:title => "#{ma.contest_message.commented.title}"
%>
</li>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<!--发布/回复了竞赛帖子-->
<% elsif ma.contest_message_type == "Message" && !ma.nil? && !ma.contest_message.nil? %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">
<%=link_to image_tag(url_to_avatar(ma.contest_message.author), :width => "30", :height => "30"), user_path(ma.contest_message.author), :target => '_blank' %>
</li>
<li class="homepageNewsPubType fl">
<%=link_to ma.contest_message.author.try(:show_name), user_path(ma.contest_message.author), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="homepageNewsType fl">
<%= ma.contest_message.parent_id.nil? ? "发布了竞赛帖子:" : "回复了竞赛帖子:" %></span></li>
<% if ma.contest_message.parent_id.nil? %>
<li class="messageInformationContents">
<%= link_to ma.contest_message.subject, board_message_path(ma.contest_message.board_id, ma.contest_message.id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
:target => '_blank',
:title => "#{ma.contest_message.subject}"
%>
</li>
<% else %>
<li class="messageInformationContents">
<%= link_to message_content(ma.contest_message.content), board_message_path(ma.contest_message.board_id, ma.contest_message.parent_id),
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
</li>
<% end %>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% end %>

View File

@ -66,7 +66,7 @@
<%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
<span class="homepageNewsType fl">发布了班级作业:</span>
</li>
<li class="messageMediumContents fl">
<li class="messageInformationContents">
<% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %>
<%= link_to "作业标题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id),
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",

View File

@ -1,11 +1,11 @@
<% work = cur_user_works_for_work activity %>
<% if activity.work_type == 3 && User.current.contestant_of_contest?(activity.contest) && activity.work_detail_group.base_on_project %>
<% projects = cur_user_projects_for_work activity %>
<% if work.nil? && projects.nil? %>
<% if work.nil? && projects.nil? && activity.work_status == 1 %>
<div class="homepagePostSubmit">
<%=link_to "关联项目",new_student_work_project_contestant_works_path(:work => activity.id,:hw_status=>hw_status,:user_activity_id=>user_activity_id),remote: true,:class=> 'c_blue', :title=> '请各组长关联项目' %>
</div>
<% elsif work.nil? %>
<% elsif work.nil? && activity.work_status == 1 %>
<div class="homepagePostSubmit">
<%=link_to "取消关联",cancel_relate_project_contestant_works_path(:work => activity.id,:hw_status=>hw_status,:user_activity_id=>user_activity_id), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %>
</div>

View File

@ -12,7 +12,7 @@
<li><%= link_to @user == User.current ? "我的动态" : "他的动态", {:controller => "users", :action => "contest_community", :type => "current_user"}, :class => "homepagePostTypeMine postTypeGrey" %></li>
<li><%= link_to "作品动态", {:controller => "users", :action => "contest_community", :type => "contest_work"}, :class => "homepagePostTypeAssignment postTypeGrey" %></li>
<li><%= link_to "通知动态", {:controller => "users", :action => "contest_community", :type => "contest_news"}, :class => "homepagePostTypeNotice postTypeGrey" %></li>
<!--<li><%#= link_to "论坛动态", {:controller => "users", :action => "contest_community", :type => "contest_message"}, :class => "homepagePostTypeForum postTypeGrey" %></li>-->
<li><%= link_to "论坛动态", {:controller => "users", :action => "contest_community", :type => "contest_message"}, :class => "homepagePostTypeForum postTypeGrey" %></li>
<!--<li><%#= link_to "竞赛留言", {:controller => "users", :action => "contest_community", :type => "contest_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %></li>-->
<% end %>
</ul>

View File

@ -0,0 +1,6 @@
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',
:locals => {:user_activities => @user_activities,
:page => @page,
:type => @type,
:user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id),
:action => "contest_community"} )%>");

View File

@ -0,0 +1,42 @@
<div id="muban_popup_box" style="width:400px;">
<div class="muban_popup_top">
<h3 class="fl">成绩公开范围</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<%= form_for('new_form',:url =>{:controller => 'works',:action => 'set_score_open',:id => @contestwork.id,:user_activity_id => @user_activity_id, :hw_status => @hw_status},
:method => "post", :remote => true) do |f|%>
<div class="muban_popup_con clear">
<div class="clear mt15 ml20">
<ul class="pro_newsetting_con fl">
<li class="mb10 clear">
<ul class="fl">
<li class="clear">
<label class="fl ml5">请选择作品成绩的公开范围</label>
</li>
<li class="clear ml20">
<input type="radio" class="fl" id="open_to_all" <%= @contestwork.score_open ? "checked" : "" %> value="1" name="score_open"/>
<label for="open_to_all" class="fl ml5 fontGrey2">成绩对所有参赛者可见</label>
</li>
<li class="clear ml20">
<input type="radio" class="fl" id="open_to_me" <%= !@contestwork.score_open ? "checked" : "" %> value="0" name="score_open"/>
<label for="open_to_me" class="fl ml5 fontGrey2">成绩仅对自己可见</label>
</li>
</ul>
</li>
</ul>
<ul class="fl ml20">
<div class="popup_tip_box fontGrey2">
<em></em>
<span></span>
<p>管理员始终能看到所有成绩</p>
</div>
</ul>
<div class="cl"></div>
<a href="javascript:void(0);" class="fr sy_btn_blue mr20" onclick="$(this).parent().parent().parent().submit();">确定</a>
<a href="javascript:void(0);" class="fr sy_btn_grey mr5" onclick="hideModal();">取消</a>
</div>
</div>
<% end%>
</div>

View File

@ -0,0 +1,136 @@
<div id="muban_popup_box" style="width:600px;">
<div class="muban_popup_top">
<h3 class="fl">评分设置</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<%= form_for('new_form',:url =>{:controller => 'works',:action => 'set_score_rule',:work => homework.id,:student_path => student_path,:user_activity_id=>user_activity_id,:hw_status=>hw_status},:method => "post", :remote => !student_path) do |f|%>
<div class="muban_popup_con clear">
<div class="clear mt15 ml20">
<ul class="pro_newsetting_con fl">
<li class="clear">
<input type="checkbox" class="fl ml30" id="online_evaluation" name="online_evaluation" <%=homework.online_evaluation ? 'checked' : '' %> value="1"/>
<label class="pop_box_label_l fl text_l ml10">启用在线评审&nbsp;&nbsp;:&nbsp;</label>
<div class="cl"></div>
<ul class="clear">
<li class="clear mt10">
<label class="fl pop_box_label ml42">开启在线评审&nbsp;&nbsp;:&nbsp;&nbsp;</label>
<div class="calendar_div fl">
<input type="text" name="evaluation_start" id="evaluation_start_time" placeholder="开启评审日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.work_detail_manual.evaluation_start%>"/>
</div>
<div class="cl"></div>
<p id="homework_evaluation_start_time" class="ml53 c_red"></p>
</li>
<li class="clear mt10">
<label class="fl pop_box_label ml42">关闭在线评审&nbsp;&nbsp;:&nbsp;&nbsp;</label>
<div class="calendar_div fl">
<input type="text" name="evaluation_end" id="evaluation_end_time" placeholder="关闭评审日期" class="InputBox fl W120 calendar_input" readonly="readonly" value="<%= homework.work_detail_manual.evaluation_end%>"/>
</div>
<div class="cl"></div>
<p id="homework_evaluation_end_time" class="ml53 c_red"></p>
</li>
<li class="clear">
<label class="pop_box_label fl clear ml39">作品评审人数&nbsp;&nbsp;:&nbsp;</label>
<div class="cl"></div>
<ul class="clear ml90">
<li>
<input type="radio" class="fl" value="1" name="evaluation_limit" id="limit"/>
<label for="limit" class="fl ml5">限定</label>
<input type="text" name="evaluation_num" id="evaluation_num" maxlength="2" class="radio-width90 fl ml10" value="<%= homework.work_detail_manual.evaluation_num == -1 ? 3 : homework.work_detail_manual.evaluation_num%>"/>
<div class="cl"></div>
<p id="evaluation_num_notice" class="c_red"></p>
</li>
<li class="clear mt20">
<input type="radio" class="fl" value="0" name="evaluation_limit" id="no_limit"/>
<label for="no_limit" class="fl ml5">不限定</label>
</li>
</ul>
</li>
</ul>
</li>
<li class="mb10 clear">
<label class="pop_box_label_l fl ml30">最终得分&nbsp;&nbsp;:&nbsp;</label>
<div class="cl"></div>
<ul class="fl ml90">
<li class="clear mb10">
<input type="radio" class="fl" id="all_score_valid" value="1" name="score_valid"/>
<label for="score_valid" class="fl ml5">全部评分有效</label>
<div class="cl"></div>
</li>
<li class="clear">
<input type="radio" class="fl" id="score_valid" value="0" name="score_valid"/>
<label for="all_score_valid" class="fl ml5">最高分和最低分无效</label>
<div class="cl"></div>
</li>
</ul>
</li>
</ul>
<ul class="fl ml20">
<div class="popup_tip_box fontGrey2 mb10">
<em></em>
<span></span>
<p >允许评委对作品进行在线评审</p>
</div>
<div class="popup_tip_box fontGrey2 mb10">
<em></em>
<span></span>
<p >系统自动开启在线评审的时间</p>
</div>
<div class="popup_tip_box fontGrey2 mb25">
<em></em>
<span></span>
<p>系统自动关闭在线评审的时间</p>
</div>
<div class="popup_tip_box fontGrey2 mb10">
<em style="top: 10px;"></em>
<span style="top: 10px;"></span>
<p>参赛作品供指定数量的评委评审<br/>由系统随机分配<br/></p>
</div>
<div class="popup_tip_box fontGrey2 mb30">
<em></em>
<span></span>
<p>参赛作品供全部的评委评审</p>
</div>
<div class="popup_tip_box fontGrey2 mb10">
<em></em>
<span></span>
<p>全部评委给的评分取平均值</p>
</div>
<div class="popup_tip_box fontGrey2 mb10">
<em></em>
<span></span>
<p >全部评委给的评分去除一个最高分<br/>和一个最低分,再取平均值</p>
</div>
</ul>
<div class="cl"></div>
<a href="javascript:void(0);" class="fr sy_btn_blue mr80" onclick="submit_set_score_rule('<%= homework.end_time%>');">确定</a>
<a href="javascript:void(0);" class="fr sy_btn_grey mr5" onclick="hideModal();">取消</a>
</div>
</div>
<% end %>
</div>
<script>
$(function(){
<% if homework.score_valid %>
$("#all_score_valid").attr("checked", "checked");
<% else %>
$("#score_valid").attr("checked", "checked");
<% end %>
<% if homework.online_evaluation %>
$("#online_evaluation").attr("checked", "checked");
<% end %>
<% if homework.work_detail_manual.evaluation_num != -1 %>
$("#limit").attr("checked", "checked");
<% else %>
$("#no_limit").attr("checked", "checked");
<% end %>
// $("#online_evaluation").on('click', function(){
// if($("#online_evaluation").is(":checked")){
// $('#evaluation_start_time').datepicker(datepickerOptions);
// $('#evaluation_end_time').datepicker(datepickerOptions);
// }
// });
});
</script>

View File

@ -0,0 +1,2 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'works/alert_score_open_modal') %>";
pop_box_new(htmlvalue, 400, 200);

View File

@ -0,0 +1,8 @@
hideModal();
<% if @hw_status == 1 %>
window.location.href = "<%=user_contest_community_path(User.current.id) %>"
<% elsif @hw_status == 2 %>
window.location.href = "<%=contest_path(@contest.id) %>"
<% else %>
window.location.href = "<%=works_path(:contest => @contest.id) %>"
<% end %>

View File

@ -44,14 +44,14 @@
<div id="menu_r" class="NewsBannerName" style="margin-bottom: -10px;">
<ul class="menu_r b_w" style="padding-left: 0px; margin-top: -5px;">
<li>
<a href="javascript:void(0);" class="menu_arrow" style="font-size:16px; color:#4b4b4b; font-weight: normal; padding-left: 0px;">题目</a>
<a href="javascript:void(0);" class="menu_arrow" style="font-size:16px; color:#4b4b4b; font-weight: normal; padding-left: 0px;">提交</a>
<ul style="max-height:240px; overflow-y:auto; overflow-x:hidden;">
<% if @homework_commons.empty? %>
<li class="pr10" style="font-weight: normal; color: #888888; width: 120px; padding-left: 15px; padding-bottom: 5px;">目前尚未发布题目</li>
<li class="pr10" style="font-weight: normal; color: #888888; width: 120px; padding-left: 15px; padding-bottom: 5px;">目前尚未发布提交</li>
<% else %>
<% @homework_commons.each_with_index do |homework_common,index|%>
<li class="pr10">
<%= link_to "题目#{@homework_commons.count - index}#{homework_common.name}",contestant_works_path(:work => homework_common.id),:target=>"_blank"%>
<%= link_to "提交#{@homework_commons.count - index}#{homework_common.name}",contestant_works_path(:work => homework_common.id),:target=>"_blank"%>
</li>
<% end%>
<% end %>

View File

@ -0,0 +1,11 @@
hideModal();
<% if @hw_status == 5 %>
$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'contestant_works/work_post_brief', :locals => {:homework => @contestwork, :is_teacher => @is_teacher}) %>");
<% else %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work', :locals => {:activity => @contestwork,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
<% end %>
<% if @user_activity_id != @contestwork.id %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
<% else %>
sd_create_editor_from_data(<%= @contestwork.id%>,"","100%", "<%=@contestwork.class.to_s%>");
<% end %>

View File

@ -0,0 +1,27 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'works/set_score_rule',:locals => {:homework => @contestwork, :student_path => false, :user_activity_id => @user_activity_id,:hw_status => @hw_status}) %>";
pop_box_new(htmlvalue, 600, 450);
var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: 0, showOn: 'button', buttonImageOnly: true, buttonImage: '/images/public_icon.png', showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true};
$(function() {
<% if @contestwork.work_status < 3 %>
$('#evaluation_start_time').datepicker(datepickerOptions);
$('#evaluation_end_time').datepicker(datepickerOptions);
<% else %>
$("#online_evaluation").attr('disabled', 'disabled');
$("#limit").attr('disabled', 'disabled');
$("#no_limit").attr('disabled', 'disabled');
$("#evaluation_num").attr('disabled', 'disabled');
<% end %>
});
function set_score_rule_submit() {
if($("#late_penalty_num").val().trim() == ""){
$("#late_penalty_num").val("0");
}
if($("#absence_penalty_num").val().trim() == ""){
$("#absence_penalty_num").val("0");
}
if($("#appeal_penalty").val().trim() == ""){
$("#appeal_penalty").val("0");
}
$('#muban_popup_box').find('form').submit();
hideModal();
}

View File

@ -0,0 +1,11 @@
hideModal();
<% if @hw_status != 5 %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work', :locals => {:activity => @contestwork,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
<% if @user_activity_id != @contestwork.id %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
<% else %>
sd_create_editor_from_data(<%= @contestwork.id%>,"","100%", "<%=@contestwork.class.to_s%>");
<% end %>
<% else %>
$("#homework_post_brief").html("<%= escape_javascript(render :partial => 'contestant_works/work_post_brief', :locals => {:homework => @contestwork, :is_teacher => @is_teacher}) %>");
<% end %>

View File

@ -0,0 +1,10 @@
<% if @hw_status != 5 %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work', :locals => {:activity => @contestwork,:user_activity_id =>@user_activity_id,:hw_status=>@hw_status}) %>");
<% if @user_activity_id != @contestwork.id %>
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
<% else %>
sd_create_editor_from_data(<%= @contestwork.id%>,"","100%", "<%=@contestwork.class.to_s%>");
<% end %>
<% else %>
window.location.href = '<%=contestant_works_path(:work => @contestwork.id) %>';
<% end %>

View File

@ -1606,6 +1606,7 @@ zh:
label_CM: 管理员
label_judge: 评委
label_contestant: 参赛者
label_board_contest: 竞赛讨论区
#end

View File

@ -600,6 +600,7 @@ RedmineApp::Application.routes.draw do
member do
get 'retry_work'
post 'add_score'
end
end
@ -610,7 +611,11 @@ RedmineApp::Application.routes.draw do
end
member do
get 'alert_score_open_modal'
post 'set_score_open'
get 'open_contestant_works'
get 'score_rule_set'
post 'set_score_rule'
end
end
@ -628,6 +633,8 @@ RedmineApp::Application.routes.draw do
get 'contest_activities'
get 'private_or_public'
get "switch_role"
get 'set_invite_code_halt'
get 'renew'
end
resources :boards

View File

@ -0,0 +1,9 @@
class AlterAppliedContestMessage < ActiveRecord::Migration
def up
applied_messages = AppliedMessage.where(:applied_type => 'AppliedContest')
applied_messages.update_all(:applied_user_id => nil)
end
def down
end
end

View File

@ -0,0 +1,12 @@
class ChangeWorkColumn < ActiveRecord::Migration
def up
change_column :works, :score_open, :boolean, :default => false
add_column :works, :online_evaluation, :boolean, :default => false
add_column :works, :score_valid, :boolean, :default => true
Work.update_all(:score_open => 0)
end
def down
end
end

View File

@ -0,0 +1,17 @@
class CreateWorkDetailManuals < ActiveRecord::Migration
def change
create_table :work_detail_manuals do |t|
t.date :evaluation_start
t.date :evaluation_end
t.integer :evaluation_num
t.references :work
t.timestamps
end
add_index :work_detail_manuals, :work_id
Work.all.each do |work|
WorkDetailManual.create(:work_id => work.id, :evaluation_start => work.end_time + 7, :evaluation_end => work.end_time + 14, :evaluation_num => 3)
end
end
end

View File

@ -0,0 +1,11 @@
class CreateContestantWorkEvaluationDistributions < ActiveRecord::Migration
def change
create_table :contestant_work_evaluation_distributions do |t|
t.references :user
t.references :contestant_work
t.timestamps
end
add_index :contestant_work_evaluation_distributions, :user_id
end
end

View File

@ -0,0 +1,6 @@
#encoding=utf-8
class AddContestIdToBoards < ActiveRecord::Migration
def change
add_column :boards, :contest_id, :integer
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20161223030701) do
ActiveRecord::Schema.define(:version => 20161230061940) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -52,6 +52,18 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token"
add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id"
create_table "applied_contests", :force => true do |t|
t.integer "contest_id"
t.integer "user_id"
t.string "role"
t.integer "status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "applied_contests", ["contest_id"], :name => "index_applied_contests_on_contest_id"
add_index "applied_contests", ["user_id"], :name => "index_applied_contests_on_user_id"
create_table "applied_messages", :force => true do |t|
t.integer "user_id"
t.integer "applied_id"
@ -291,6 +303,7 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.integer "parent_id"
t.integer "course_id"
t.integer "org_subfield_id"
t.integer "contest_id"
end
add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id"
@ -325,16 +338,14 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids"
create_table "changesets", :force => true do |t|
t.integer "repository_id", :null => false
t.string "revision", :null => false
t.integer "repository_id", :null => false
t.string "revision", :null => false
t.string "committer"
t.datetime "committed_on", :null => false
t.datetime "committed_on", :null => false
t.text "comments"
t.date "commit_date"
t.string "scmid"
t.integer "user_id"
t.integer "project_id"
t.integer "type", :default => 0
end
add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on"
@ -485,12 +496,12 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.integer "user_id"
t.integer "contest_id"
t.integer "contest_message_id"
t.string "course_message_type"
t.boolean "viewed", :default => false
t.string "contest_message_type"
t.boolean "viewed", :default => false
t.text "content"
t.integer "status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "contest_messages", ["contest_id"], :name => "index_contest_messages_on_contest_id"
@ -506,6 +517,15 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
add_index "contestant_for_contests", ["contest_id"], :name => "index_contestant_for_contests_on_contest_id"
add_index "contestant_for_contests", ["student_id"], :name => "index_contestant_for_contests_on_student_id"
create_table "contestant_work_evaluation_distributions", :force => true do |t|
t.integer "user_id"
t.integer "contestant_work_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "contestant_work_evaluation_distributions", ["user_id"], :name => "index_contestant_work_evaluation_distributions_on_user_id"
create_table "contestant_work_projects", :force => true do |t|
t.integer "contest_id"
t.integer "work_id"
@ -595,6 +615,20 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.integer "container_id", :default => 0
end
create_table "course_class_post", :id => false, :force => true do |t|
t.integer "班级id", :default => 0, :null => false
t.string "班级名"
t.integer "帖子id", :default => 0, :null => false
t.integer "主贴id"
t.string "帖子标题", :default => "", :null => false
t.text "帖子内容"
t.integer "帖子用户id"
t.integer "帖子回复数", :default => 0, :null => false
t.integer "最后回帖id"
t.datetime "发帖时间", :null => false
t.datetime "帖子更新时间", :null => false
end
create_table "course_contributor_scores", :force => true do |t|
t.integer "course_id"
t.integer "user_id"
@ -663,8 +697,8 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.string "code"
t.integer "time"
t.string "extra"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "location"
t.string "term"
t.string "string"
@ -674,28 +708,27 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.string "class_period"
t.integer "school_id"
t.text "description"
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "lft"
t.integer "rgt"
t.integer "is_public", :limit => 1, :default => 1
t.integer "inherit_members", :limit => 1, :default => 1
t.integer "open_student", :default => 0
t.integer "outline", :default => 0
t.integer "publish_resource", :default => 0
t.integer "is_delete", :default => 0
t.integer "is_public", :limit => 1, :default => 1
t.integer "inherit_members", :limit => 1, :default => 1
t.integer "open_student", :default => 0
t.integer "outline", :default => 0
t.integer "publish_resource", :default => 0
t.integer "is_delete", :default => 0
t.integer "end_time"
t.string "end_term"
t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
t.integer "is_copy", :default => 0
t.integer "visits", :default => 0
t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
t.integer "is_copy", :default => 0
t.integer "visits", :default => 0
t.integer "syllabus_id"
t.string "invite_code"
t.string "qrcode"
t.integer "qrcode_expiretime", :default => 0
t.integer "professional_level_id", :limit => 1
t.integer "invite_code_halt", :limit => 1, :default => 0
t.integer "qrcode_expiretime", :default => 0
t.integer "invite_code_halt", :limit => 1, :default => 0
end
add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true
@ -770,11 +803,6 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "disciplines", :force => true do |t|
t.string "name"
t.integer "professional_level_id", :limit => 1
end
create_table "discuss_demos", :force => true do |t|
t.string "title"
t.text "body"
@ -900,11 +928,13 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.integer "exercise_status"
t.integer "user_id"
t.integer "time"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "publish_time"
t.datetime "end_time"
t.integer "show_result"
t.integer "question_random", :default => 0
t.integer "choice_random", :default => 0
end
create_table "first_pages", :force => true do |t|
@ -1093,10 +1123,6 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.datetime "updated_at", :null => false
end
create_table "innodb_monitor", :id => false, :force => true do |t|
t.integer "a"
end
create_table "invite_lists", :force => true do |t|
t.integer "project_id"
t.integer "user_id"
@ -1360,6 +1386,7 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.integer "course_id"
t.integer "sticky", :default => 0
t.integer "org_subfield_id"
t.integer "contest_id"
end
add_index "news", ["author_id"], :name => "index_news_on_author_id"
@ -1628,12 +1655,9 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
end
create_table "professional_levels", :force => true do |t|
t.integer "level"
end
create_table "professions", :force => true do |t|
t.string "name"
t.integer "discipline_id", :limit => 1
t.string "level"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "project_infos", :force => true do |t|
@ -1696,6 +1720,7 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.boolean "hidden_repo", :default => false, :null => false
t.integer "attachmenttype", :default => 1
t.integer "user_id"
t.integer "dts_test", :default => 0
t.string "enterprise_name"
t.integer "organization_id"
t.integer "project_new_type"
@ -1703,11 +1728,6 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.integer "forked_from_project_id"
t.integer "forked_count"
t.integer "publish_resource", :default => 0
t.integer "boards_count", :default => 0
t.integer "news_count", :default => 0
t.integer "acts_count", :default => 0
t.integer "journals_count", :default => 0
t.integer "boards_reply_count", :default => 0
t.integer "visits", :default => 0
t.integer "hot", :default => 0
t.string "invite_code"
@ -2105,8 +2125,8 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.string "title"
t.text "description"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "eng_name"
t.integer "syllabus_type"
t.integer "credit"
@ -2115,9 +2135,8 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.integer "practice_hours"
t.string "applicable_major"
t.string "pre_course"
t.integer "visits", :default => 0
t.integer "des_status", :default => 0
t.integer "professional_level_id", :limit => 1
t.integer "visits", :default => 0
t.integer "des_status", :default => 0
end
add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id"
@ -2492,6 +2511,17 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
add_index "work_detail_groups", ["work_id"], :name => "index_work_detail_groups_on_work_id"
create_table "work_detail_manuals", :force => true do |t|
t.date "evaluation_start"
t.date "evaluation_end"
t.integer "evaluation_num"
t.integer "work_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "work_detail_manuals", ["work_id"], :name => "index_work_detail_manuals_on_work_id"
create_table "workflows", :force => true do |t|
t.integer "tracker_id", :default => 0, :null => false
t.integer "old_status_id", :default => 0, :null => false
@ -2517,12 +2547,14 @@ ActiveRecord::Schema.define(:version => 20161223030701) do
t.date "end_time"
t.integer "work_type"
t.integer "contest_id"
t.boolean "is_delete", :default => false
t.boolean "score_open", :default => true
t.boolean "is_open", :default => false
t.boolean "is_delete", :default => false
t.boolean "score_open", :default => false
t.boolean "is_open", :default => false
t.integer "work_status"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "online_evaluation", :default => false
t.boolean "score_valid", :default => true
end
add_index "works", ["contest_id"], :name => "index_works_on_contest_id"

View File

@ -0,0 +1,20 @@
#coding=utf-8
namespace :contest_work_endtime do
desc "send a message for work deadline"
task :message => :environment do
puts "--------------------------------contest_work_endtime start"
contrast_time = Time.now - 86400
homework_commons = Work.where("end_time >=? and end_time <=?",contrast_time, Time.now)
homework_commons.each do |homework_common|
if ContestMessage.where("contest_message_type =? and contest_message_id =? and status =?", "Work", homework_common.id, 1).first.nil?
homework_common.contest.contestants.each do |s|
homework_common.contest_messages << ContestMessage.new(:user_id => s.student_id, :contest_id => homework_common.contest_id, :viewed => false, :status => true)
# 发送邮件通知
# Mailer.homework_endtime__added(homework_common, s.student_id).deliver
end
end
end
puts "--------------------------------contest_work_endtime end"
end
end

View File

@ -0,0 +1,71 @@
#coding=utf-8
namespace :contest_work_evaluation do
desc "start and end evaluation"
def get_assigned_contestant_works(judges, n, index, num)
judges[(index % num) .. ((index + n - 1) % num)]
end
# 获取竞赛的评委人员
def contest_judges contest
contest.contest_members.select{|cm| cm.roles.to_s.include?("Judge")}
end
#自动开启匿评的任务
task :start_evaluation => :environment do
Rails.logger.info("log--------------------------------contest_work_start_evaluation start")
puts "--------------------------------contest_work_start_evaluation start"
works = Work.where(:online_evaluation => true, :work_status => [1, 2])
work_ids = works.blank? ? "(-1)" : "(" + works.map{|work| work.id}.join(",") + ")"
puts "1111 #{work_ids}"
homework_detail_manuals = WorkDetailManual.where("evaluation_start <= '#{Date.today}' and work_id in #{work_ids}")
homework_detail_manuals.each do |homework_detail_manual|
puts "222 #{homework_detail_manual.evaluation_start}"
work = homework_detail_manual.work
contestant_works = work.contestant_works.has_committed
if homework_detail_manual.evaluation_num != -1
judges = contest_judges work.contest
n = homework_detail_manual.evaluation_num
n = (n < judges.size && n != -1) ? n : judges.size
contestant_works.each_with_index do |work, index|
user = work.user
assigned_judges = get_assigned_contestant_works(judges, n, index, judges.size)
assigned_judges.each do |h|
contestant_works_evaluation_distributions = ContestantWorkEvaluationDistribution.new(user_id: h.user_id, contestant_work_id: work.id)
contestant_works_evaluation_distributions.save
end
end
work.update_column('work_status', 3)
# 匿评开启消息邮件通知,# 所有人
#send_message_anonymous_comment(homework_common, 2)
contest = work.contest
contest.contest_members.each do |m|
work.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => 2)
end
else
end
end
Rails.logger.info("log--------------------------------contest_work_start_evaluation end")
puts "--------------------------------contest_work_start_evaluation end"
end
#自动关闭匿评的任务
task :end_evaluation => :environment do
works = Work.where(:online_evaluation => true, :work_status => 3)
homework_detail_manuals = WorkDetailManual.where(:evaluation_end => Date.today, :work_id => works.map{|work| work.id})
homework_detail_manuals.each do |homework_detail_manual|
work = homework_detail_manual.work
work.contestant_works.has_committed.each do |student_work|
student_work.save
end
work.update_column('work_status', 4)
# 匿评关闭消息通知 给所有人发
contest = work.contest
contest.contest_members.each do |m|
work.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => 3)
end
end
end
end

View File

@ -5,23 +5,32 @@ namespace :contest_work_publishtime do
task :publish => :environment do
puts "--------------------------------contest_work_publish start"
Rails.logger.info("log--------------------------------contest_work_publish start")
homework_commons = Work.where("publish_time = '#{Date.today}'")
homework_commons = Work.where("work_status = 0 and publish_time <= '#{Date.today}'")
homework_commons.each do |homework|
if homework.work_status == 0
homework.update_column('work_status', 1)
homework.update_attribute('work_status', 1)
contest = homework.contest
contest.contest_members.each do |m|
homework.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => contest.id, :viewed => false, :status => nil)
end
if homework.contest_acts.size == 0
homework.contest_acts << ContestActivity.new(:user_id => homework.user_id,:contest_id => homework.contest_id)
end
# 邮件通知
# Mailer.run.homework_added(homework)
contest = homework.contest
contest.contestants.each do |m|
homework.contest_messages << ContestMessage.new(:user_id => m.student_id, :contest_id => contest.id, :viewed => false, :status => nil)
end
if homework.contest_acts.size == 0
homework.contest_acts << ContestActivity.new(:user_id => homework.user_id,:contest_id => homework.contest_id)
end
# 邮件通知
# Mailer.run.homework_added(homework)
end
Rails.logger.info("log--------------------------------contest_work_publish end")
puts "--------------------------------contest_work_publish end"
end
task :end => :environment do
puts "--------------------------------contest_work_publish_end start"
Rails.logger.info("log--------------------------------contest_work_publish_end start")
homework_commons = Work.where("work_status = 1 and end_time <= '#{Date.today}'")
homework_commons.each do |homework|
homework.update_attribute('work_status', 2)
end
Rails.logger.info("log--------------------------------contest_work_publish_end end")
puts "--------------------------------contest_work_publish_end end"
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,4 +1,5 @@
//= require_directory ./rateable
//= require_directory ./rateable
//= require jquery.min
//= require jquery.infinitescroll
@ -1714,14 +1715,30 @@ function expand_course_list(id, target, btnid, count) {
}
}
//点击删除时的确认弹框
//点击删除时的确认弹框: 不走destroy方法
function delete_confirm_box(url, 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>'+
'<div class="clear mt15"><p class="text_c f16">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-remote="true">确定</a>'+
'<div class="clear mt15"><p class="text_c f16 fontGrey7">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-remote="true">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
}
//点击删除时的确认弹框: 走destroy方法
function delete_confirm_box_2(url, 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>'+
'<div class="clear mt15"><p class="text_c f14 fontGrey7">' + str + '</p><div class="cl"></div><a href="'+ url +'" class="fr sy_btn_blue mt10" style="margin-right: 92px;" data-method="delete" data-remote="true">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="hideModal();">取消</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
}
//提示框:只有一个确定按钮,点击关闭弹框
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>'+
'<div class="clear mt15"><p class="text_c f16">' + 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, 300, 140);
}
//删除组织成员
function ifDeleteOrgMember(id,name){
var htmlvalue = "</br><div style='width:550px;text-align:center'>您确定要删除"+name+"吗?</div></br><div style='width:164px; margin:0 auto; text-align:center'><a href='javascript:void(0);' class='Blue-btn fl' onclick='deleteOrgMember("+id+")'>确定</a><a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a></div>" +

Some files were not shown because too many files have changed in this diff Show More