Merge branch 'cxt_course' into develop
Conflicts: app/controllers/users_controller.rb app/helpers/application_helper.rb app/views/users/_user_activities.html.erb db/schema.rb
This commit is contained in:
commit
e86bd6728e
1
Gemfile
1
Gemfile
|
@ -75,6 +75,7 @@ group :development, :test do
|
|||
gem "test-unit", "~>3.0"
|
||||
end
|
||||
gem 'rspec-rails', '~> 3.0'
|
||||
gem 'factory_girl_rails'
|
||||
end
|
||||
|
||||
# Gems used only for assets and not required
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -1,2 +0,0 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the contest_members controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the contestant_works controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,4 +0,0 @@
|
|||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the contests controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the works controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -430,6 +430,8 @@ class ApplicationController < ActionController::Base
|
|||
@course = Course.find(params[:course_id])
|
||||
elsif params[:org_subfield_id]
|
||||
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
|
||||
elsif params[:contest_id]
|
||||
@contest = Contest.find(params[:contest_id])
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
|
|
|
@ -28,6 +28,7 @@ class CommentsController < ApplicationController
|
|||
if !@news.org_subfield_id.nil?
|
||||
@org_subfield = OrgSubfield.find(@news.org_subfield_id)
|
||||
end
|
||||
@contest = Contest.find(@news.contest_id) if @news.contest_id
|
||||
@comment = Comment.new
|
||||
#@project ? @comment.comments = params[:comment][:comments] : @comment.comments = params[:comment]
|
||||
if params[:user_activity_id]
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
#encoding=utf-8
|
||||
class ContestMembersController < ApplicationController
|
||||
helper :users
|
||||
helper :contest_members
|
||||
helper :contests
|
||||
|
||||
before_filter :find_contest_member, :only => [:update, :destroy]
|
||||
|
||||
def create
|
||||
@contest = Contest.find(params[:contest])
|
||||
if params[:membership] && @contest
|
||||
@create_member_error_messages = "角色不能留空" unless params[:membership][:role_ids]
|
||||
@create_member_error_messages = "用户不能留空" unless params[:membership][:user_ids]
|
||||
members = []
|
||||
|
||||
if params[:membership][:user_ids] && params[:membership][:role_ids]
|
||||
attrs = params[:membership].dup
|
||||
user_ids = attrs.delete(:user_ids)
|
||||
role_ids = params[:membership][:role_ids]
|
||||
user_ids.each do |user_id|
|
||||
member = ContestMember.new(:user_id => user_id)
|
||||
members << member
|
||||
|
||||
contest_member_roles = member.contest_member_roles
|
||||
if role_ids.include?('14') && role_ids.include?('13')
|
||||
contest_member_roles << ContestMemberRole.new(:role_id => 13)
|
||||
contest_member_roles << ContestMemberRole.new(:role_id => 14, :is_current => 0)
|
||||
else
|
||||
contest_member_roles << ContestMemberRole.new(:role_id => role_ids[0].to_i)
|
||||
end
|
||||
|
||||
if role_ids.include?('15')
|
||||
ContestantForContest.create(:student_id => user_id, :contest_id => @contest.id)
|
||||
end
|
||||
|
||||
#给新成员和老师发送加入课程的消息,发送者id放在CourseMessage的course_message_id字段中
|
||||
#course_message_type设置为JoinCourse
|
||||
#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)
|
||||
end
|
||||
end
|
||||
@contest.contest_members << members
|
||||
|
||||
members = @contest.member_principals.includes(:roles, :principal).all.sort
|
||||
end
|
||||
@roles = Role.where("id in (13, 14, 15)")
|
||||
respond_to do |format|
|
||||
format.html { redirect_to_settings_in_courses }
|
||||
format.js { @members = members;}
|
||||
format.api {
|
||||
@member = members.first
|
||||
if @member.valid?
|
||||
render :action => 'show', :status => :created, :location => membership_url(@member)
|
||||
else
|
||||
render_validation_errors(@member)
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def contest_member_autocomplete
|
||||
@contest = Contest.find(params[:contest])
|
||||
@flag = params[:flag] || false
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if params[:membership]
|
||||
new_role_ids = params[:membership][:role_ids]
|
||||
if new_role_ids.size != 0 && new_role_ids != @contest_member.contest_member_roles.map{|ro| ro.role_id.to_s}
|
||||
destroy_member_roles = @contest_member.contest_member_roles
|
||||
if destroy_member_roles.any?
|
||||
destroy_member_roles.each(&:destroy)
|
||||
end
|
||||
contest_member_roles = @contest_member.contest_member_roles
|
||||
if new_role_ids.include?('14') && new_role_ids.include?('13')
|
||||
contest_member_roles << ContestMemberRole.new(:role_id => 13)
|
||||
contest_member_roles << ContestMemberRole.new(:role_id => 14, :is_current => 0)
|
||||
else
|
||||
contest_member_roles << ContestMemberRole.new(:role_id => new_role_ids[0].to_i)
|
||||
end
|
||||
joined = ContestantForContest.where('student_id = ? and contest_id = ?', @contest_member.user_id, @contest.id)
|
||||
joined.each do |join|
|
||||
join.destroy
|
||||
end
|
||||
|
||||
if new_role_ids.include?('15')
|
||||
ContestantForContest.create(:student_id => @contest_member.user_id, :contest_id => @contest.id)
|
||||
end
|
||||
end
|
||||
|
||||
@contest_member.save
|
||||
@members = @contest.member_principals.includes(:roles, :principal).all.sort
|
||||
@roles = Role.where("id in (13, 14, 15)")
|
||||
@member = @contest.contest_members.new
|
||||
end
|
||||
|
||||
saved = @member.save
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_contest_path(@contest) }
|
||||
format.js
|
||||
format.api {
|
||||
if saved
|
||||
render_api_ok
|
||||
else
|
||||
render_validation_errors(@member)
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if request.delete? && @contest_member.deletable?
|
||||
@contest_member.destroy
|
||||
|
||||
joined = ContestantForContest.where('student_id = ? and contest_id = ?', @contest_member.user_id, @contest.id)
|
||||
joined.each do |join|
|
||||
join.destroy
|
||||
end
|
||||
@roles = Role.where("id in (13, 14, 15)")
|
||||
@members = @contest.member_principals.includes(:roles, :principal).all.sort
|
||||
#移出课程发送消息
|
||||
ContestMessage.create(:user_id => @contest_member.user_id, :contest_id => @contest.id, :contest_message_type => "RemoveFromContest", :viewed => false, :contest_message_id => User.current.id)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_contest_path(@contest) }
|
||||
format.js
|
||||
format.api {
|
||||
if @contest_member.destroyed?
|
||||
render_api_ok
|
||||
else
|
||||
head :unprocessable_entity
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_contest_member
|
||||
@contest_member = ContestMember.find params[:id]
|
||||
@contest = @contest_member.contest
|
||||
end
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
class ContestNotificationController < ApplicationController
|
||||
layout 'contest_base'
|
||||
def show
|
||||
@notification = ContestNotification.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,408 @@
|
|||
#encoding: utf-8
|
||||
class ContestantWorksController < ApplicationController
|
||||
layout "base_contests"
|
||||
include ContestantWorksHelper
|
||||
include ApplicationHelper
|
||||
require 'bigdecimal'
|
||||
require "base64"
|
||||
before_filter :find_contestwork, :only => [:new, :index, :create, :new_student_work_project,:student_work_project,:cancel_relate_project,
|
||||
:delete_work,:search_contest_students,:work_canrepeat,:add_group_member,:change_project]
|
||||
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment]
|
||||
before_filter :member_of_contest, :only => [:new, :create, :show]
|
||||
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
||||
before_filter :admin_of_contest, :only => []
|
||||
before_filter :is_logged, :only => [:index]
|
||||
|
||||
def new
|
||||
#更新消息
|
||||
noEvaluation = @contestwork.contest_messages.where("user_id =? and viewed =?", User.current.id, 0)
|
||||
noEvaluation.update_all(:viewed => true)
|
||||
|
||||
@user = User.current
|
||||
@student_work = ContestantWork.new
|
||||
respond_to do |format|
|
||||
format.html{ render :layout => "base_contests"}
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
# 作业消息状态更新?
|
||||
work_messages = ContestMessage.where(:user_id => User.current.id, :viewed => 0, :contest_message_id => @contestwork.id, :contest_message_type => "Work")
|
||||
work_messages.update_all(:viewed => true)
|
||||
studentwork_messages = ContestMessage.where(:user_id => User.current.id, :viewed => 0, :contest_id => @contestwork.contest, :contest_message_type => "ContestantWork")
|
||||
studentwork_messages.update_all(:viewed => true)
|
||||
# 作品打分消息状态更新
|
||||
#studentworks_scores = ContestMessage.where("user_id =? and contest_id =? and contest_message_type =? and viewed =?", User.current.id, @contestwork.contest, "StudentWorksScore", 0)
|
||||
#studentworks_scores.update_all(:viewed => true)
|
||||
# 作品评论消息状态更新
|
||||
#journals_for_teacher = ContestMessage.where("user_id =? and contest_id =? and contest_message_type =? and viewed =?", User.current.id, @contestwork.contest, "JournalsForMessage", 0)
|
||||
#journals_for_teacher.update_all(:viewed => true)
|
||||
|
||||
##################################################################################################################
|
||||
@order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name].to_s.strip || "",params[:group]
|
||||
@homework_commons = @contest.works.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
|
||||
@all_homework_commons = @contest.works.order("created_at desc")
|
||||
@is_teacher = User.current.admin_of_contest?(@contest) || User.current.admin?
|
||||
@is_judge = User.current.judge_of_contest?(@contest)
|
||||
|
||||
@show_all = false
|
||||
|
||||
if @is_teacher || @is_judge
|
||||
# if @order == 'lastname'
|
||||
# @stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
|
||||
# elsif @order == 'student_id'
|
||||
# @stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
|
||||
# else
|
||||
@stundet_works = @contestwork.contestant_works.no_copy.select("contestant_works.*,contestant_works.work_score as score").includes(:user => {:user_extensions => []}, :project => {}, :contestant_work_scores => {}).order("#{@order} #{@b_sort}")
|
||||
#end
|
||||
@show_all = true
|
||||
elsif User.current.member_of_contest?(@contest)
|
||||
if @contestwork.work_type == 3
|
||||
pro = @contestwork.contestant_work_projects.where(:user_id => User.current.id).first
|
||||
if pro.nil?
|
||||
@stundet_works = []
|
||||
else
|
||||
@stundet_works = @contestwork.contestant_works.select("contestant_works.*,contestant_works.work_score as score").where(:id => pro.contestant_work_id)
|
||||
end
|
||||
else
|
||||
@stundet_works = @contestwork.contestant_works.select("contestant_works.*,contestant_works.work_score as score").where(:user_id => User.current.id)
|
||||
end
|
||||
else
|
||||
render_403
|
||||
return
|
||||
end
|
||||
@student_work_count = @contestwork.contestant_works.has_committed.select("contestant_works.*,contestant_works.work_score as score").order("#{@order} #{@b_sort}").count
|
||||
|
||||
@score = @b_sort == "desc" ? "asc" : "desc"
|
||||
@is_focus = params[:is_focus] ? params[:is_focus].to_i : 0
|
||||
# 消息传过来的ID
|
||||
@message_student_work_id = params[:student_work_id]
|
||||
@left_nav_type = 3
|
||||
@tab = params[:tab].to_i
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
# format.xls {
|
||||
# filename = "#{@contest.user.lastname.to_s + @contest.user.firstname}_#{@contest.name}_#{@contestwork.name}#{l(:excel_homework_list)}.xls"
|
||||
# send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
|
||||
# :filename => filename_for_content_disposition(filename))
|
||||
# }
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
# 提交作品前先判断是否已经提交
|
||||
@has_commit = false;
|
||||
if hsd_committed_work?(User.current.id, @contestwork.id)
|
||||
@work = ContestantWork.where("user_id =? and work_id =?", User.current.id, @contestwork.id).first
|
||||
@has_commit = true;
|
||||
#flash[:notice] = l(:notice_successful_create)
|
||||
#redirect_to edit_student_work_url(params[:student_work])
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
return
|
||||
end
|
||||
if params[:student_work]
|
||||
@submit_result = true
|
||||
student_work = ContestantWork.find(params[:student_work_id]) if params[:student_work_id]
|
||||
student_work ||= ContestantWork.new
|
||||
student_work.name = params[:student_work][:name] == "#{@contestwork.name}的作品提交(可修改)" ? "#{@contestwork.name}的作品提交" : params[:student_work][:name]
|
||||
student_work.description = params[:student_work][:description]
|
||||
student_work.work_id = @contestwork.id
|
||||
student_work.user_id = User.current.id
|
||||
student_work.commit_time = Time.now
|
||||
student_work.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(student_work)
|
||||
if @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project
|
||||
@student_work_project = @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").first
|
||||
student_work.project_id = @student_work_project.project_id
|
||||
end
|
||||
#提交作品时,计算是否迟交
|
||||
student_work.work_status = Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") ? 2 : 1
|
||||
|
||||
if student_work.save
|
||||
if @contestwork.work_type == 3
|
||||
if @contestwork.work_detail_group.base_on_project
|
||||
@student_work_project.contestant_work_id = student_work.id
|
||||
@student_work_project.save
|
||||
else
|
||||
stu_project = ContestantWorkProject.new(:work_id => @contestwork.id, :contestant_work_id => student_work.id, :project_id => student_work.project_id, :user_id => student_work.user_id, :is_leader => 1, :contest_id => @contestwork.contest_id)
|
||||
stu_project.save
|
||||
end
|
||||
members = params[:group_member_ids].split(',')
|
||||
for i in 1 .. members.count-1
|
||||
stu_work = ContestantWork.new(:name => student_work.name, :description => student_work.description,:user_id =>members[i].to_i, :work_id => @contestwork.id, :project_id => student_work.project_id, :work_status => 3, :commit_time => student_work.commit_time)
|
||||
if stu_work.save
|
||||
stu_project = ContestantWorkProject.new(:work_id => @contestwork.id, :contestant_work_id => student_work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0, :contest_id => @contestwork.contest_id)
|
||||
stu_project.save
|
||||
end
|
||||
end
|
||||
end
|
||||
@contestwork.update_column(:updated_at, Time.now)
|
||||
update_contest_activity(@contestwork.class,@contestwork.id)
|
||||
update_user_activity(@contestwork.class,@contestwork.id)
|
||||
|
||||
contest_message = ContestMessage.new(:user_id =>User.current.id,:content=>"new",:contest_message_id=>student_work.id,:contest_id => @contest.id,:contest_message_type=>"ContestantWork", :status => 9) #作品提交记录
|
||||
contest_message.save
|
||||
|
||||
@student_work = ContestantWork.where(work_id: @contestwork.id, user_id: User.current.id).first
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
@submit_result = false
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = User.current
|
||||
if Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") #编程作业不能修改作业|| 截止日期已到不能修改作业
|
||||
render_403
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html{ render :layout => "base_contests"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if params[:student_work]
|
||||
@submit_result = true
|
||||
@work.name = params[:student_work][:name]
|
||||
@work.description = params[:student_work][:description]
|
||||
@work.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@work)
|
||||
if @work.save
|
||||
#如果学生作品被打分后修改,应该给老师提示
|
||||
#send_message_to_teacher(@work)
|
||||
if @contestwork.work_type == 3
|
||||
@student_work_project = @contestwork.contestant_work_projects.where("user_id=?",User.current.id).first
|
||||
student_work_projects = @contestwork.contestant_work_projects.where("contestant_work_id=? and is_leader =?",@work.id,0)
|
||||
user_ids = student_work_projects.empty? ? "(-1)" : "(" + student_work_projects.map{|stu|stu.user_id}.join(",") + ")"
|
||||
student_works = @contestwork.contestant_works.where("user_id in #{user_ids}")
|
||||
student_works.delete_all
|
||||
student_work_projects.delete_all
|
||||
members = params[:group_member_ids].split(',')
|
||||
for i in 1 .. members.count-1
|
||||
stu_work = ContestantWork.new(:name => @work.name, :description => @work.description,:user_id=> members[i].to_i, :work_id => @contestwork.id, :project_id => @work.project_id, :work_status => 3, :commit_time => @work.commit_time)
|
||||
if stu_work.save
|
||||
stu_project = ContestantWorkProject.new(:work_id => @contestwork.id, :contestant_work_id => @work.id, :project_id => stu_work.project_id == 0 ? -1 : stu_work.project_id, :user_id => members[i].to_i, :is_leader => 0, :contest_id => @contestwork.contest_id)
|
||||
stu_project.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
contest_message = ContestMessage.new(:user_id =>User.current.id,:content=>"edit",:contest_message_id=>@work.id,:contest_id => @contest.id,:contest_message_type=>"ContestantWork", :status => 9) #作品提交记录
|
||||
contest_message.save
|
||||
@student_work = @work
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
=begin
|
||||
respond_to do |format|
|
||||
format.html{redirect_to edit_student_work_url(@work)}
|
||||
end
|
||||
=end
|
||||
@submit_result = false
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @contestwork.work_type == 3
|
||||
pros = @work.contestant_work_projects.where("is_leader = 0")
|
||||
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
|
||||
student_works = @contestwork.contestant_works.where("user_id in #{user_ids}")
|
||||
student_works.delete_all
|
||||
pros.delete_all
|
||||
|
||||
project = @work.contestant_work_projects.where("is_leader = 1").first
|
||||
if @contestwork.work_detail_group.base_on_project
|
||||
project.update_attributes(:contestant_work_id => nil)
|
||||
else
|
||||
project.destroy
|
||||
end
|
||||
end
|
||||
@work.destroy
|
||||
@work.attachments.destroy_all
|
||||
#@work.student_works_scores.destroy_all
|
||||
@work.contest_messages.destroy_all
|
||||
#@work.student_work_tests.destroy_all
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to contestant_works_path(:work => @contestwork.id)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def delete_work
|
||||
@work = ContestantWork.where("user_id =? and work_id =?", User.current.id, @contestwork.id).first
|
||||
if @work
|
||||
@work.destroy
|
||||
if @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project
|
||||
pros = @work.contestant_work_projects.where("is_leader = 0")
|
||||
pros.each do |pro|
|
||||
pro.destroy
|
||||
end
|
||||
project = @work.contestant_work_projects.where("is_leader = 1").first
|
||||
project.update_attributes(:contestant_work_id => nil)
|
||||
elsif @contestwork.work_type == 3 && !@contestwork.work_detail_group.base_on_project
|
||||
@work.contestant_work_projects.each do |pro2|
|
||||
pro2.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
redirect_to works_path(:contest => @contestwork.contest_id)
|
||||
end
|
||||
|
||||
def retry_work
|
||||
if @contestwork.work_type == 3
|
||||
pros = @work.contestant_work_projects.where("is_leader = 0")
|
||||
user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
|
||||
student_works = @contestwork.contestant_works.where("user_id in #{user_ids}")
|
||||
student_works.delete_all
|
||||
pros.delete_all
|
||||
|
||||
project = @work.contestant_work_projects.where("is_leader = 1").first
|
||||
if @contestwork.work_detail_group.base_on_project
|
||||
project.update_attributes(:contestant_work_id => nil)
|
||||
else
|
||||
project.destroy
|
||||
end
|
||||
end
|
||||
@work.destroy
|
||||
@work.attachments.destroy_all
|
||||
@work.contest_messages.destroy_all
|
||||
|
||||
@student_work = ContestantWork.new
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#查找竞赛中的参赛者
|
||||
def search_contest_students
|
||||
name = ""
|
||||
unless params[:name].nil?
|
||||
name = params[:name]
|
||||
end
|
||||
if !@contestwork.work_detail_group.base_on_project
|
||||
all_student_ids = "(" + @contestwork.contest.contestants.map{|student| student.student_id}.join(",") + ")"
|
||||
else
|
||||
pro = Project.find @contestwork.contestant_work_projects.where("user_id=?",User.current.id).first.project_id
|
||||
all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")"
|
||||
end
|
||||
all_students = User.where("id in #{all_student_ids}")
|
||||
student_work_id = @contestwork.contestant_work_projects.where("user_id=? and contestant_work_id is not null",User.current.id).first.nil? ? -1 : @contestwork.contestant_work_projects.where("user_id=?",User.current.id).first.contestant_work_id
|
||||
@commit_student_ids = @contestwork.contestant_works.where("id != #{student_work_id}").map{|student| student.user_id}
|
||||
@users = searchstudent_by_name all_students,name
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def new_student_work_project
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
@hw_status = params[:hw_status].to_i
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#创建作业的关联项目
|
||||
def student_work_project
|
||||
@project = ContestantWorkProject.new
|
||||
@project.work_id = @contestwork.id
|
||||
@project.project_id = params[:projectName].to_i
|
||||
@project.user_id = User.current.id
|
||||
@project.is_leader = 1
|
||||
@project.contest_id = @contestwork.contest_id
|
||||
if @project.save
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
@hw_status = params[:hw_status].to_i
|
||||
@is_teacher = User.current.admin_of_contest?(@contestwork.contest) || User.current.admin?
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 取消关联项目
|
||||
def cancel_relate_project
|
||||
relate_pro = ContestantWorkProject.where("user_id = #{User.current.id} and work_id = #{@contestwork.id}").first
|
||||
if relate_pro.destroy
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
@hw_status = params[:hw_status].to_i
|
||||
@is_teacher = User.current.admin_of_contest?(@contestwork.contest) || User.current.admin?
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def hsd_committed_work?(user, homework)
|
||||
sw = ContestantWork.where("user_id =? and work_id =?", user, homework).first
|
||||
sw.nil? ? result = false : result = true
|
||||
result
|
||||
end
|
||||
|
||||
#获取题目
|
||||
def find_contestwork
|
||||
@contestwork = Work.find params[:work]
|
||||
@contest = @contestwork.contest
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
#获取作品
|
||||
def find_work
|
||||
@work = ContestantWork.find params[:id]
|
||||
@contestwork = @work.work
|
||||
@contest = @contestwork.contest
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
#是不是当前竞赛的成员
|
||||
#当前竞赛成员才可以看到作品列表
|
||||
def member_of_contest
|
||||
render_403 unless User.current.member_of_contest?(@contest) || User.current.admin?
|
||||
end
|
||||
|
||||
#判断是不是当前作品的提交者
|
||||
#提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品
|
||||
def author_of_work
|
||||
render_403 unless User.current.admin? || User.current.id == @work.user_id
|
||||
end
|
||||
|
||||
def admin_of_contest
|
||||
render_403 unless User.current.admin_of_contest?(@contest) || User.current.admin?
|
||||
end
|
||||
|
||||
def is_logged
|
||||
redirect_to signin_path unless User.current.logged?
|
||||
end
|
||||
end
|
|
@ -1,187 +0,0 @@
|
|||
class ContestnotificationsController < ApplicationController
|
||||
# GET /contestnotifications
|
||||
# GET /contestnotifications.json
|
||||
layout 'base_newcontest'
|
||||
default_search_scope :contestnotifications
|
||||
model_object Contestnotification
|
||||
# before_filter :find_model_object, :except => [:new, :create, :index]
|
||||
# before_filter :find_contest_from_association, :except => [:new, :create, :index]
|
||||
before_filter :find_contest_by_contest_id, :only => [:new, :create]
|
||||
before_filter :find_contest
|
||||
before_filter :find_author
|
||||
# before_filter :authorize, :except => [:index]
|
||||
before_filter :find_optional_contest, :only => [:index]
|
||||
accept_rss_auth :index
|
||||
accept_api_auth :index
|
||||
|
||||
before_filter :access_edit_destroy, only: [:edit ,:update, :destroy]
|
||||
|
||||
def find_author
|
||||
@user = @contest.author
|
||||
render_404 if @user.nil?
|
||||
end
|
||||
def find_contest
|
||||
@contest = Contest.find(params[:contest_id])
|
||||
render_404 if @contest.nil?
|
||||
end
|
||||
|
||||
|
||||
def index
|
||||
|
||||
# @contestnotifications = Contestnotification.all
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html # index.html.erb
|
||||
# format.json { render json: @contestnotifications }
|
||||
# end
|
||||
|
||||
### begin ###
|
||||
case params[:format]
|
||||
when 'xml', 'json'
|
||||
@offset, @limit = api_offset_and_limit
|
||||
else
|
||||
@limit = 10
|
||||
end
|
||||
|
||||
scope = @contest ? @contest.contestnotifications.visible : Contestnotifications.visible
|
||||
|
||||
@contestnotifications_count = scope.count
|
||||
@contestnotifications_pages = Paginator.new @contestnotifications_count, @limit, params['page']
|
||||
@offset ||= @contestnotifications_pages.offset
|
||||
@contestnotificationss = scope.all(:include => [:author, :contest],
|
||||
:order => "#{Contestnotification.table_name}.created_at DESC",
|
||||
:offset => @offset,
|
||||
:limit => @limit)
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@contestnotification = Contestnotification.new # for adding news inline
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
format.atom { render_feed(@contestnotificationss, :title => (@contest ? @contest.name : Setting.app_title) + ": #{l(:label_contest_notification)}") }
|
||||
end
|
||||
### end ###
|
||||
end
|
||||
|
||||
# GET /contestnotifications/1
|
||||
# GET /contestnotifications/1.json
|
||||
def show
|
||||
@contestnotification = Contestnotification.find(params[:id])
|
||||
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html # show.html.erb
|
||||
# format.json { render json: @contestnotification }
|
||||
# end
|
||||
@notificationcomments = @contestnotification.notificationcomments
|
||||
@notificationcomments.reverse! if User.current.wants_notificationcomments_in_reverse_order?
|
||||
render :layout => 'base_newcontest'
|
||||
|
||||
end
|
||||
|
||||
# GET /contestnotifications/new
|
||||
# GET /contestnotifications/new.json
|
||||
def new
|
||||
# @contestnotification = Contestnotification.new
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html # new.html.erb
|
||||
# format.json { render json: @contestnotification }
|
||||
# end
|
||||
@contestnotification = Contestnotification.new(:contest => @contest, :author => User.current)
|
||||
render :layout => 'base_newcontest'
|
||||
end
|
||||
|
||||
# GET /contestnotifications/1/edit
|
||||
def edit
|
||||
@contestnotification = Contestnotification.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /contestnotifications
|
||||
# POST /contestnotifications.json
|
||||
def create
|
||||
# @contestnotification = Contestnotification.new(params[:contestnotification])
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @contestnotification.save
|
||||
# format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully created.' }
|
||||
# format.json { render json: @contestnotification, status: :created, location: @contestnotification }
|
||||
# else
|
||||
# format.html { render action: "new" }
|
||||
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
@contestnotification = Contestnotification.new(:contest => @contest, :author => User.current)
|
||||
@contestnotification.safe_attributes = params[:contestnotification]
|
||||
@contestnotification.save_attachments(params[:attachments])
|
||||
if @contestnotification.save
|
||||
render_attachment_warning_if_needed(@contestnotification)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to contest_contestnotifications_url(@contest)
|
||||
else
|
||||
layout_file = 'base_newcontest'
|
||||
render :action => 'new', :layout => layout_file
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /contestnotifications/1
|
||||
# PUT /contestnotifications/1.json
|
||||
def update
|
||||
# @contestnotification = Contestnotification.find(params[:id])
|
||||
#
|
||||
# respond_to do |format|
|
||||
# if @contestnotification.update_attributes(params[:contestnotification])
|
||||
# format.html { redirect_to @contestnotification, notice: 'Contestnotification was successfully updated.' }
|
||||
# format.json { head :no_content }
|
||||
# else
|
||||
# format.html { render action: "edit" }
|
||||
# format.json { render json: @contestnotification.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
@contestnotification = Contestnotification.find(params[:id])
|
||||
@contestnotification.safe_attributes = params[:contestnotification]
|
||||
@contestnotification.save_attachments(params[:attachments])
|
||||
if @contestnotification.save
|
||||
render_attachment_warning_if_needed(@contestnotification)
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to contest_contestnotification_url(@contestnotification.contest, @contestnotification)
|
||||
else
|
||||
render :action => 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /contestnotifications/1
|
||||
# DELETE /contestnotifications/1.json
|
||||
def destroy
|
||||
# @contestnotification = Contestnotification.find(params[:id])
|
||||
# @contestnotification.destroy
|
||||
#
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to contestnotifications_url }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
@contestnotification = Contestnotification.find(params[:id])
|
||||
@contestnotification.destroy
|
||||
redirect_to contest_contestnotifications_url(@contest)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_optional_contest
|
||||
return true unless params[:id]
|
||||
@contest = Contest.find(params[:id])
|
||||
# authorize
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def access_edit_destroy
|
||||
if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)
|
||||
return true
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,736 +1,243 @@
|
|||
# fq
|
||||
# class BidsController < ApplicationController
|
||||
class ContestsController < ApplicationController
|
||||
layout "contest_base"
|
||||
|
||||
menu_item :respond
|
||||
menu_item :project, :only => :show_project
|
||||
menu_item :application, :only => :show_softapplication
|
||||
menu_item :attendingcontests, :only => :show_attendingcontest
|
||||
menu_item :contestnotifications, :only => :index
|
||||
|
||||
before_filter :can_show_contest, :except => [] # modified by alan
|
||||
|
||||
# modified by longjun
|
||||
before_filter :find_contest, :only => [
|
||||
:show_contest, :show_project, :show_softapplication,
|
||||
:show_attendingcontest, :index, :set_reward_project,
|
||||
:set_reward_softapplication, :create, :destroy, :more,
|
||||
:back, :add, :add_softapplication, :new,:show_results,
|
||||
:set_reward, :show_contest_project, :show_contest_user, :watcherlist,
|
||||
:join_in_contest, :unjoin_in_contest, :new_join, :settings
|
||||
]
|
||||
# end longjun
|
||||
|
||||
# added by fq
|
||||
before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest]
|
||||
# end
|
||||
before_filter :require_login,:only => [:set_reward, :destroy, :add, :new ]
|
||||
|
||||
helper :watchers
|
||||
helper :attachments
|
||||
helper :projects
|
||||
helper :words
|
||||
|
||||
include AttachmentsHelper
|
||||
include ApplicationHelper
|
||||
|
||||
|
||||
def index
|
||||
render_404 unless params[:name]
|
||||
# @contests = Contest.visible
|
||||
# @contests ||= []
|
||||
@offset, @limit = api_offset_and_limit(:limit => 10)
|
||||
#@contests = Contest.visible
|
||||
#@contests = @contests.like(params[:name]) if params[:name].present?
|
||||
@is_search = params[:name] ? true:false
|
||||
@contests = Contest.visible.where("name like '%#{params[:name]}%'")
|
||||
if params[:contests_search]
|
||||
(redirect_to contests_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
|
||||
end
|
||||
@contest_count = @contests.count
|
||||
@contest_pages = Paginator.new @contest_count, @limit, params['page']
|
||||
|
||||
@offset ||= @contest_pages.reverse_offset
|
||||
if params[:contest_sort_type].present?
|
||||
case params[:contest_sort_type]
|
||||
when '0'
|
||||
# modified by longjun
|
||||
# never use unless and else, 将下面重复操作模块化,放在private下
|
||||
# unless @offset == 0
|
||||
# if @offset != 0
|
||||
# @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse
|
||||
# else
|
||||
# limit = @contest_count % @limit
|
||||
# limit = @limit if limit == 0
|
||||
# @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse
|
||||
|
||||
@contests = index_page_sort(@offset, @limit, @contest_count, @contests, 'contests.commit')
|
||||
# end
|
||||
@s_state = 0
|
||||
when '1'
|
||||
|
||||
@contests = index_page_sort(@offset, @limit, @contest_count, @contests, 'contests.created_on')
|
||||
@s_state = 1
|
||||
# modified by longjun
|
||||
# 目前只有 0, 1 两个sort_type
|
||||
# when '2'
|
||||
else
|
||||
# end longjun
|
||||
|
||||
@contests = index_page_sort(@offset, @limit, @contest_count, @contests, '')
|
||||
@s_state = 0
|
||||
end
|
||||
else
|
||||
# modified by longjun
|
||||
# never use unless and else
|
||||
# unless @offset == 0
|
||||
if @offset != 0
|
||||
@contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @contest_count % @limit
|
||||
limit = @limit if limit == 0
|
||||
@contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
@s_state = 1
|
||||
end
|
||||
end
|
||||
|
||||
def search
|
||||
redirect_to action: 'index',name:params[:name]
|
||||
end
|
||||
|
||||
def homework
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@bids = @course.homeworks.order('deadline DESC')
|
||||
@bids = @bids.like(params[:name]) if params[:name].present?
|
||||
@bid_count = @bids.count
|
||||
@bid_pages = Paginator.new @bid_count, @limit, params['page']
|
||||
|
||||
@offset ||= @bid_pages.reverse_offset
|
||||
# modified by longjun
|
||||
# never use unless and else
|
||||
# unless @offset == 0
|
||||
if @offset != 0
|
||||
@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
||||
else
|
||||
limit = @bid_count % @limit
|
||||
@bids = @bids.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
render :layout => 'base_courses'
|
||||
|
||||
end
|
||||
|
||||
|
||||
def show_contest
|
||||
@user = @contest.author
|
||||
@jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
#@limit = 10
|
||||
#@feedback_count = @jours.count
|
||||
#@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
#@offset ||= @feedback_pages.offset
|
||||
#@jour = @jours[@offset, @limit]
|
||||
@jour = paginateHelper @jours,10
|
||||
@state = false
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
def join_in_contest
|
||||
if params[:contest_password] == @contest.password
|
||||
JoinInCompetition.create(:user_id => User.current.id, :competition_id => @contest.id)
|
||||
@state = 0
|
||||
else
|
||||
@state = 1
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
|
||||
end
|
||||
end
|
||||
|
||||
def unjoin_in_contest
|
||||
|
||||
joined = JoinInCompetition.where('competition_id = ? and user_id = ?', @contest.id, User.current.id)
|
||||
|
||||
joined.each do |join|
|
||||
join.delete
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def show_participator
|
||||
render :layout => 'base_newcontest'
|
||||
|
||||
end
|
||||
|
||||
|
||||
def settings
|
||||
if @contest.author.id == User.current.id
|
||||
@contest = Contest.find(params[:id])
|
||||
render :layout => 'base_newcontest'
|
||||
else
|
||||
render_403 :message => :notice_not_contest_setting_authorized
|
||||
end
|
||||
end
|
||||
|
||||
# Added by Longjun
|
||||
def destroy_contest
|
||||
@contest = Contest.find(params[:id])
|
||||
if @contest.author_id == User.current.id || User.current.admin?
|
||||
|
||||
@contest.destroy
|
||||
redirect_to welcome_contest_url
|
||||
else
|
||||
render_403 :message => :notice_not_contest_delete_authorized
|
||||
end
|
||||
|
||||
end
|
||||
# end
|
||||
|
||||
def show_contest_project
|
||||
contests = Contest.where('parent_id = ?', @contest.id)
|
||||
@projects = []
|
||||
|
||||
# Modified by longjun
|
||||
# 用 arr.each 替换 for [ according to the style guide ]
|
||||
|
||||
# for contest in contests
|
||||
# @projects += contest.contesting_projects
|
||||
# end
|
||||
|
||||
contests.each do |contest|
|
||||
@projects += contest.contesting_projects
|
||||
end
|
||||
|
||||
# end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
def show_contest_softapplication
|
||||
contests = Contest.where('parent_id = ?', @contest.id)
|
||||
@softapplications = []
|
||||
|
||||
# Modified by Longjun
|
||||
# for contest in contests
|
||||
# @softapplications += contest.contesting_softapplications
|
||||
|
||||
|
||||
contests.each do |contest|
|
||||
@softapplications += contest.contesting_softapplications
|
||||
end
|
||||
|
||||
# end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def show_contest_user
|
||||
contests = Contest.find(:all)
|
||||
@users = []
|
||||
|
||||
# Modified by Longjun
|
||||
# for contest in contests
|
||||
# for project in contest.projects
|
||||
# @users += project.users
|
||||
# end
|
||||
|
||||
|
||||
contests.each do |contest|
|
||||
contest.projects.each do |project|
|
||||
@users += project.users
|
||||
end
|
||||
end
|
||||
# end
|
||||
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
|
||||
end
|
||||
end
|
||||
#显示参赛的项目
|
||||
def show_project
|
||||
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
@option = []
|
||||
# @contesting_project_count = @contesting_project_all.count
|
||||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
|
||||
# Modified by Longjun
|
||||
# 将两个判断语句合并
|
||||
# unless membership.project.project_type==1
|
||||
# if User.current.allowed_to?(:quote_project, membership.project)
|
||||
# @option << membership.project
|
||||
# end
|
||||
# end
|
||||
if membership.project.project_type != 1 && User.current.allowed_to?(:quote_project, membership.project)
|
||||
@option << membership.project
|
||||
|
||||
end
|
||||
# end
|
||||
|
||||
end
|
||||
@user = @contest.author
|
||||
@contesting_project = @contest.contesting_projects.all
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
@contesting_project.each do |pro|
|
||||
if pro.project && pro.project.project_status
|
||||
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||
@temp << pro
|
||||
end
|
||||
end
|
||||
@temp
|
||||
end
|
||||
@contesting_project = @temp
|
||||
else
|
||||
|
||||
@temp = []
|
||||
@contesting_project.each do |pro|
|
||||
# modified by longjun
|
||||
# if pro.project && pro.project.project_status
|
||||
# @temp << pro
|
||||
# end
|
||||
@temp << pro if pro.project && pro.project.project_status
|
||||
# end longjun
|
||||
@temp
|
||||
end
|
||||
if @temp.size > 0
|
||||
@contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
||||
end
|
||||
end
|
||||
@contesting_project = paginateHelper(@contesting_project)
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
############
|
||||
##显示参赛的应用
|
||||
def show_softapplication
|
||||
|
||||
# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
# @option = []
|
||||
|
||||
# @user = @contest.user
|
||||
@softapplication = Softapplication.all
|
||||
@contesting_softapplication = @contest.contesting_softapplications
|
||||
|
||||
@contesting_softapplication = paginateHelper(@contesting_softapplication, 10)
|
||||
|
||||
# @temp = []
|
||||
# @softapplicationt.each do |pro|
|
||||
# if pro.project && pro.project.project_status
|
||||
# @temp << pro
|
||||
# end
|
||||
# @temp
|
||||
|
||||
# if @temp.size > 0
|
||||
# @contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
||||
# end
|
||||
# end
|
||||
# respond_to do |format|
|
||||
# format.html {
|
||||
# render :layout => 'base_newcontest'
|
||||
# }
|
||||
# format.api
|
||||
# end
|
||||
##########################
|
||||
@contest = Contest.find_by_id(params[:id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
###我要参赛
|
||||
def show_attendingcontest
|
||||
##取出参赛项目--项目列表
|
||||
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
@option = []
|
||||
# @contesting_project_count = @contesting_project_all.count
|
||||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless membership.project.project_type==1
|
||||
#拥有编辑项目权限的可将该项目参赛
|
||||
if User.current.allowed_to?(:quote_project, membership.project)
|
||||
@option << membership.project
|
||||
end
|
||||
end
|
||||
end
|
||||
@user = @contest.author
|
||||
@contesting_project = @contest.contesting_projects.all
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
@contesting_project.each do |pro|
|
||||
if pro.project && pro.project.project_status
|
||||
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||
@temp << pro
|
||||
end
|
||||
end
|
||||
@temp
|
||||
end
|
||||
@contesting_project = @temp
|
||||
else
|
||||
|
||||
@temp = []
|
||||
@contesting_project.each do |pro|
|
||||
# modified by longjun
|
||||
# if pro.project && pro.project.project_status
|
||||
# @temp << pro
|
||||
# end
|
||||
@temp << pro if pro.project && pro.project.project_status
|
||||
# end longjun
|
||||
@temp
|
||||
end
|
||||
if @temp.size > 0
|
||||
@contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
||||
end
|
||||
end
|
||||
# 取出参赛应用 --应用列表
|
||||
@softapplication = Softapplication.all
|
||||
@contesting_softapplication = @contest.contesting_softapplications.
|
||||
joins("LEFT JOIN softapplications ON contesting_softapplications.softapplication_id=softapplications.id").
|
||||
joins("LEFT JOIN (
|
||||
SELECT * FROM seems_rateable_cached_ratings
|
||||
WHERE cacheable_type='Softapplication' AND DIMENSION = 'quality') AS cached
|
||||
ON cached.cacheable_id=softapplications.id").
|
||||
order("cached.avg").reverse_order
|
||||
@contesting_softapplication = paginateHelper @contesting_softapplication, 10
|
||||
|
||||
|
||||
#引用base_newcontest整体样式
|
||||
@contest = Contest.find_by_id(params[:id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
###end
|
||||
|
||||
def show_notification
|
||||
@contest = Contest.find_by_id(params[:id])
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
render :layout => 'base_newcontest'
|
||||
}
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def set_reward_project
|
||||
@c_p = nil
|
||||
@contesting_project_id = nil
|
||||
|
||||
if params[:set_reward_project][:reward]&&((User.current.id==@contest.author_id)||User.current.admin)
|
||||
# @bid_id = params[:id]
|
||||
@contesting_project_id = params[:set_reward_project][:c_id]
|
||||
@c_p = ContestingProject.find_by_id(@contesting_project_id)
|
||||
|
||||
# 把字段存进表中
|
||||
@c_p.update_reward(params[:set_reward_project][:reward].to_s)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def set_reward_softapplication
|
||||
@c_sa = nil
|
||||
@contesting_softapplication_id = nil
|
||||
|
||||
if params[:set_reward_softapplication][:reward]&&((User.current.id==@contest.author_id)||User.current.admin)
|
||||
# @bid_id = params[:id]
|
||||
@contesting_softapplication_id = params[:set_reward_softapplication][:c_id]
|
||||
@c_sa = ContestingSoftapplication.find_by_id(@contesting_softapplication_id)
|
||||
|
||||
# 把字段存进表中
|
||||
@c_sa.update_reward(params[:set_reward_softapplication][:reward].to_s)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
###添加已创建的参赛项目
|
||||
def add
|
||||
project = Project.find(params[:contest])
|
||||
contest_message = params[:contest_for_save][:contest_message]
|
||||
if ContestingProject.where("project_id = ? and contest_id = ?", project.id, @contest.id).size == 0
|
||||
# modified by longjun, create 写错了
|
||||
# if ContestingProject.cerate_contesting(@contest.id, project.id, contest_message)
|
||||
if ContestingProject.create_contesting(@contest.id, project.id, contest_message)
|
||||
# end longjun
|
||||
|
||||
flash.now[:notice] = l(:label_bidding_contest_succeed)
|
||||
end
|
||||
else
|
||||
flash.now[:error] = l(:label_bidding_fail)
|
||||
end
|
||||
|
||||
@contesting_project = paginateHelper @contest.contesting_projects
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
###添加已发布的参赛应用
|
||||
def add_softapplication
|
||||
softapplication = Softapplication.find(params[:contest])
|
||||
contest_message = params[:contest_for_save][:contest_message]
|
||||
if ContestingSoftapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0
|
||||
if ContestingSoftapplication.create_softapplication_contesting(@contest.id, softapplication.id, contest_message)
|
||||
flash.now[:notice] = l(:label_release_add_contest_succeed)
|
||||
end
|
||||
else
|
||||
flash.now[:error] = l(:label_add_contest_succeed_fail)
|
||||
end
|
||||
|
||||
@contesting_softapplication = paginateHelper @contest.contesting_softapplications
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
## 新建留言
|
||||
def create
|
||||
|
||||
if params[:contest_message][:message].size>0
|
||||
if params[:reference_content]
|
||||
message = params[:contest_message][:message] + "\n" + params[:reference_content]
|
||||
else
|
||||
message = params[:contest_message][:message]
|
||||
end
|
||||
refer_user_id = params[:contest_message][:reference_user_id].to_i
|
||||
@contest.add_jour(User.current, message, refer_user_id)
|
||||
end
|
||||
@user = @contest.author
|
||||
@jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
@contest.set_commit(@feedback_count)
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
##删除留言
|
||||
def destroy
|
||||
@user = @contest.author
|
||||
if User.current.admin? || User.current.id == @user.id
|
||||
JournalsForMessage.delete_message(params[:object_id])
|
||||
end
|
||||
@jours = @contest.journals_for_messages.reverse
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
|
||||
@contest.set_commit(@feedback_count)
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
##引用留言
|
||||
def new
|
||||
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
|
||||
if @jour
|
||||
user = @jour.user
|
||||
text = @jour.notes
|
||||
else
|
||||
user = @contest.author
|
||||
text = @contest.description
|
||||
end
|
||||
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
||||
@content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> "
|
||||
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
||||
@id = user.id
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
##新建竞赛
|
||||
def new_contest
|
||||
@contest = Contest.new
|
||||
@contest.safe_attributes = params[:contest]
|
||||
end
|
||||
|
||||
##提交创建的竞赛
|
||||
def create_contest
|
||||
@contest = Contest.new
|
||||
@contest.name = params[:contest][:name]
|
||||
@contest.description = params[:contest][:description]
|
||||
@contest.budget = params[:contest][:budget]
|
||||
@contest.deadline = params[:contest][:deadline]
|
||||
@contest.password = params[:contest][:password]
|
||||
@contest.author_id = User.current.id
|
||||
@contest.commit = 0
|
||||
if @contest.save
|
||||
unless @contest.watched_by?(User.current)
|
||||
if @contest.add_watcher(User.current)
|
||||
flash[:notice] = l(:label_contesting_created_succeed)
|
||||
end
|
||||
end
|
||||
redirect_to show_contest_contest_url(@contest)
|
||||
else
|
||||
@contest.safe_attributes = params[:contest]
|
||||
render :action => 'new_contest'
|
||||
end
|
||||
end
|
||||
|
||||
##更新竞赛配置信息
|
||||
def update_contest
|
||||
@contest = Contest.find(params[:id])
|
||||
@contest.name = params[:contest][:name]
|
||||
@contest.description = params[:contest][:description]
|
||||
|
||||
@contest.budget = params[:contest][:budget]
|
||||
@contest.deadline = params[:contest][:deadline]
|
||||
@contest.password = params[:contest][:password]
|
||||
@contest.author_id = User.current.id
|
||||
@contest.commit = 0
|
||||
if @contest.save
|
||||
unless @contest.watched_by?(User.current)
|
||||
if @contest.add_watcher(User.current)
|
||||
flash[:notice] = l(:label_contesting_updated_succeed)
|
||||
end
|
||||
end
|
||||
redirect_to show_contest_contest_url(@contest)
|
||||
|
||||
else
|
||||
@contest.safe_attributes = params[:contest]
|
||||
render :action => 'new_contest'
|
||||
end
|
||||
end
|
||||
|
||||
def more
|
||||
@jour = @contest.journals_for_messages
|
||||
@jour.each_with_index {|j,i| j.indice = i+1}
|
||||
@state = true
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
||||
def back
|
||||
@jour = @contest.journals_for_messages
|
||||
@jour.each_with_index {|j,i| j.indice = i+1}
|
||||
@state = false
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
end
|
||||
|
||||
def set_reward
|
||||
@b_p = nil
|
||||
@contesting_project_id = nil
|
||||
|
||||
if params[:set_reward][:reward]&&((User.current.id==@contest.author_id)||User.current.admin)
|
||||
# @contest_id = params[:id]
|
||||
@contesting_project_id = params[:set_reward][:b_id] #[:b_id]???
|
||||
@b_p = ContestingProject.find_by_id(@contesting_project_id)
|
||||
|
||||
# 把字段存进表中
|
||||
@b_p.update_reward(params[:set_reward][:reward].to_s)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
def watcherlist
|
||||
render :layout => 'base_newcontest'
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
|
||||
def find_contest
|
||||
if params[:id]
|
||||
@contest = Contest.find(params[:id])
|
||||
@user = @contest.author
|
||||
end
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
#验证是否显示竞赛
|
||||
def can_show_contest
|
||||
@first_page = FirstPage.find_by_page_type('project')
|
||||
if @first_page.show_contest == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
# added by longjun
|
||||
# 将index页面中分页排序的方法抽离出来
|
||||
def index_page_sort(offset, limit, contest_count, contests, contest_sort_by)
|
||||
# modified by longjun
|
||||
# never use unless and else
|
||||
# unless @offset == 0
|
||||
if offset != 0
|
||||
contests = contests.reorder(contest_sort_by).offset(offset).limit(limit).all.reverse
|
||||
else
|
||||
limit = contest_count % limit
|
||||
limit = limit if limit == 0
|
||||
contests = contests.reorder(contest_sort_by).offset(offset).limit(limit).all.reverse
|
||||
end
|
||||
contests
|
||||
end
|
||||
end
|
||||
|
||||
#encoding=utf-8
|
||||
class ContestsController < ApplicationController
|
||||
|
||||
include ContestsHelper
|
||||
helper :contest_members
|
||||
|
||||
before_filter :find_contest, :only => [:show, :settings, :update, :contest_activities, :search_member, :private_or_public, :switch_role]
|
||||
before_filter :is_logged, :only => [:index, :new, :create]
|
||||
layout "base_contests"
|
||||
|
||||
def show
|
||||
@left_nav_type = 1
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def contest_activities
|
||||
#更新创建课程消息状态
|
||||
contest_request_messages = ContestMessage.where(:user_id => User.current.id, :contest_id => @contest.id, :contest_message_type => "ContestRequestDealResult", :viewed => false)
|
||||
contest_request_messages.update_all(:viewed => true)
|
||||
|
||||
contest_activities = @contest.contest_activities
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
if params[:type].present?
|
||||
case params[:type]
|
||||
when "work"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'Work'").order('updated_at desc')
|
||||
when "news"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'News'").order('updated_at desc')
|
||||
when "message"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'Message'").order('updated_at desc')
|
||||
when "poll"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'Poll'").order('updated_at desc')
|
||||
when "attachment"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'Attachment'").order('updated_at desc')
|
||||
when "journalsForMessage"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'JournalsForMessage'").order('updated_at desc')
|
||||
when "news"
|
||||
@contest_activities = contest_activities.where("contest_act_type = 'News'").order('updated_at desc')
|
||||
else
|
||||
@contest_activities = contest_activities.order('updated_at desc')
|
||||
end
|
||||
else
|
||||
@contest_activities = contest_activities.order('updated_at desc')
|
||||
end
|
||||
@contest_activities_count = @contest_activities.count
|
||||
@contest_activities = @contest_activities.limit(10).offset(@page * 10)
|
||||
@type = params[:type]
|
||||
|
||||
@left_nav_type = 2
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
if User.current.login?
|
||||
@contest = Contest.new
|
||||
render :layout => 'new_base'
|
||||
else
|
||||
redirect_to signin_url
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@contest = Contest.new
|
||||
@contest.name = params[:contest][:name]
|
||||
params[:contest][:is_public] ? @contest.is_public = 1 : @contest.is_public = 0
|
||||
@contest.user_id = User.current.id
|
||||
if @contest && @contest.save
|
||||
#unless User.current.admin?
|
||||
member = ContestMember.new(:user_id => User.current.id)
|
||||
|
||||
@contest.contest_members << member
|
||||
ContestMemberRole.create(:contest_member_id => member.id, :role_id => 13)
|
||||
|
||||
@contest.contest_acts << ContestActivity.new(:user_id => @contest.user_id,:contest_id => @contest.id)
|
||||
respond_to do |format|
|
||||
format.html {redirect_to contest_url(@contest)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@contest.name = params[:contest][:name]
|
||||
@contest.description = params[:contest][:description]
|
||||
# @project.organization_id = params[:organization_id]
|
||||
params[:contest][:is_public] == "on" ? @contest.is_public = 1 : @contest.is_public = 0
|
||||
@contest.save_attachments(params[:attachments])
|
||||
begin
|
||||
if @contest.save
|
||||
respond_to do |format|
|
||||
format.html{redirect_to contest_path(@contest)}
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
@message = e.message
|
||||
end
|
||||
end
|
||||
|
||||
def private_or_public
|
||||
@contest.update_attributes(:is_public => !@contest.is_public)
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#设置竞赛公开或私有
|
||||
def set_contest_attribute
|
||||
contest_id = params[:contest].to_i
|
||||
@contest = Contest.find(contest_id)
|
||||
@user = User.find(params[:user_id])
|
||||
@contest.is_public? ? @contest.update_attribute(:is_public, false) : @contest.update_attribute(:is_public, true)
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def settings
|
||||
if params[:tab] && params[:tab] == 'boards'
|
||||
@tab = 2
|
||||
else
|
||||
@tab = 0
|
||||
end
|
||||
@member ||= @contest.contest_members.new
|
||||
@roles = Role.where("id in (13, 14, 15)")
|
||||
@members = @contest.member_principals.includes(:roles, :principal).all.sort
|
||||
end
|
||||
|
||||
def join_contest
|
||||
|
||||
end
|
||||
|
||||
def join_contest_multi_role
|
||||
if User.current.logged?
|
||||
cs = ContestsService.new
|
||||
@user = User.current
|
||||
join = cs.join_contest_roles params,@user
|
||||
@state = join[:state]
|
||||
@contest = join[:contest]
|
||||
else
|
||||
@state = 5 #未登录
|
||||
end
|
||||
@object_id = @contest.id if @contest
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
#处理加入竞赛成为管理员、评委、参赛者的请求
|
||||
#status 1 同意 2 拒绝
|
||||
def dealwith_apply_request
|
||||
@msg = AppliedMessage.find(params[:msg_id])
|
||||
#AppliedMessage role 13 管理员 14 评委 15 参赛者
|
||||
applied_contest = @msg.applied
|
||||
apply_user = User.find(applied_contest.user_id)
|
||||
ids = applied_contest.role.split(",") # [@msg.content] msg content保存的是申请的职位角色
|
||||
integer_ids = []
|
||||
ids.each do |role_id|
|
||||
integer_ids << role_id.to_i
|
||||
end
|
||||
case params[:agree]
|
||||
when 'Y'
|
||||
member = ContestMember.new(:user_id => apply_user.id)
|
||||
Contest.find(applied_contest.contest_id).contest_members << member
|
||||
|
||||
contest_member_roles = member.contest_member_roles
|
||||
if integer_ids.include?(14) && integer_ids.include?(13)
|
||||
contest_member_roles << ContestMemberRole.new(:role_id => 13)
|
||||
contest_member_roles << ContestMemberRole.new(:role_id => 14, :is_current => 0)
|
||||
else
|
||||
contest_member_roles << ContestMemberRole.new(:role_id => integer_ids[0])
|
||||
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.update_attributes(:status => 1)
|
||||
if integer_ids.include?(15)
|
||||
ContestantForContest.create(:student_id => apply_user.id, :contest_id =>applied_contest.contest_id)
|
||||
end
|
||||
|
||||
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.update_attributes(:status => 2)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def switch_role
|
||||
members = @contest.contest_members.where("user_id = #{params[:user_id]}")
|
||||
unless members.blank?
|
||||
curr_role = ContestMemberRole.find_by_contest_member_id_and_role_id(members.first.id, params[:curr_role])
|
||||
tar_role = ContestMemberRole.find_by_contest_member_id_and_role_id(members.first.id, params[:tar_role])
|
||||
unless (curr_role.nil? || tar_role.nil?)
|
||||
curr_role.update_column('is_current', 0)
|
||||
tar_role.update_column('is_current', 1)
|
||||
end
|
||||
end
|
||||
redirect_to contest_path(@contest)
|
||||
end
|
||||
|
||||
def search_member
|
||||
if User.current.admin_of_contest?(@contest) || User.current.admin?
|
||||
q = "#{params[:name].strip}"
|
||||
@roles = Role.givable.all[11..13]
|
||||
if q.nil? || q == ""
|
||||
@members = @contest.member_principals.includes(:roles, :principal).all.sort
|
||||
else
|
||||
@members = searchmember_by_name(@contest.member_principals.includes(:roles, :principal).all.sort,q)
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_contest
|
||||
if params[:id].to_i < 780
|
||||
render_403
|
||||
return
|
||||
end
|
||||
@contest = Contest.find(params[:id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def is_logged
|
||||
redirect_to signin_path unless User.current.logged?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -73,7 +73,7 @@ class HomeworkCommonController < ApplicationController
|
|||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'new_base_user'}
|
||||
format.html{render :layout => 'base_course_community'}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,6 +42,8 @@ class NewsController < ApplicationController
|
|||
@limit = 10
|
||||
end
|
||||
|
||||
@contest = Contest.find(params[:contest_id]) if params[:contest_id]
|
||||
|
||||
# modify by nwb
|
||||
if params[:course_id] && @course==nil
|
||||
@course = Course.find(params[:course_id])
|
||||
|
@ -69,6 +71,84 @@ class NewsController < ApplicationController
|
|||
format.api
|
||||
format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
|
||||
end
|
||||
elsif @contest
|
||||
if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest)))
|
||||
@order, @b_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||
|
||||
#确定 sort_type 1升序 2 降序
|
||||
if @order.to_i == @type.to_i
|
||||
@b_sort = @b_sort.to_i == 1 ? 2 : 1
|
||||
else
|
||||
@b_sort = 2
|
||||
end
|
||||
|
||||
sort_name = "updated_at"
|
||||
|
||||
sort_type = @b_sort == 1 ? "asc" : "desc"
|
||||
|
||||
#scope = News.find_by_sql("select a.*,b.updated_at from news a, course_activities b where a.course_id = 532 and a.course_id = b.course_id and b.course_act_id = a.id ) ")
|
||||
|
||||
scope = @contest.news if @contest
|
||||
# @newss = scope.all(:include => [:author, :contest], :order => "#{News.table_name}.created_on DESC")
|
||||
#
|
||||
# @page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
news_page = 0 #@page *10
|
||||
# @news_count = @newss.count
|
||||
# @is_new = params[:is_new]
|
||||
@q = params[:subject]
|
||||
if params[:subject].nil? || params[:subject].blank?
|
||||
scope_order = scope.reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on #{sort_type}").offset(news_page).includes(:author,:course).all()
|
||||
else
|
||||
scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").reorder("#{News.table_name}.sticky DESC, #{News.table_name}.#{sort_name} #{sort_type}").offset(news_page).includes(:author,:contest).all()
|
||||
end
|
||||
|
||||
scope_order.each do |topic|
|
||||
topic[:updated_at] = topic.contest_acts.first.updated_at
|
||||
#topic[:updated_at] = CourseActivity.where("course_act_type='#{topic.class}' and course_act_id =#{topic.id}").first.updated_at
|
||||
end
|
||||
|
||||
#根据 赞+回复数排序
|
||||
if @order.to_i == 2
|
||||
@type = 2
|
||||
scope_order.each do |topic|
|
||||
topic[:infocount] = get_praise_num(topic) + topic.comments.count
|
||||
if topic[:infocount] < 0
|
||||
topic[:infocount] = 0
|
||||
end
|
||||
end
|
||||
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:infocount] <=> y[:infocount] } : scope_order = scope_order.sort{|x,y| y[:infocount] <=> x[:infocount] }
|
||||
scope_order = sort_by_sticky scope_order
|
||||
scope_order = sortby_time_countcommon_hassticky scope_order,sort_name
|
||||
else
|
||||
@type = 1
|
||||
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:updated_at] <=> y[:updated_at] } : scope_order = scope_order.sort{|x,y| y[:updated_at] <=> x[:updated_at] }
|
||||
scope_order = sort_by_sticky scope_order
|
||||
end
|
||||
|
||||
@newss = scope_order
|
||||
|
||||
#分页
|
||||
@limit = 15
|
||||
@is_remote = true
|
||||
@atta_count = @newss.count
|
||||
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
@newss = paginateHelper @newss,@limit
|
||||
@is_new = params[:is_new]
|
||||
|
||||
#@newss = paginateHelper scope_order,10
|
||||
@left_nav_type = 5
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@news = News.new
|
||||
render :layout => 'base_contests'
|
||||
}
|
||||
format.js
|
||||
format.api
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
elsif @course
|
||||
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
||||
@order, @b_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
|
||||
|
@ -190,6 +270,15 @@ class NewsController < ApplicationController
|
|||
format.html {render :layout => 'base_courses'}
|
||||
end
|
||||
end
|
||||
elsif @news.contest_id
|
||||
@contest = Contest.find(@news.contest_id)
|
||||
if @contest
|
||||
@left_nav_type = 4
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'base_contests'}
|
||||
end
|
||||
end
|
||||
elsif @project
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
@ -255,6 +344,22 @@ class NewsController < ApplicationController
|
|||
#layout_file = 'base_courses'
|
||||
#render :action => 'new', :layout => layout_file
|
||||
end
|
||||
elsif @contest
|
||||
@news = News.new(:contest => @contest, :author => User.current)
|
||||
#render :layout => 'base_courses'
|
||||
@news.safe_attributes = params[:news]
|
||||
@news.save_attachments(params[:attachments])
|
||||
if @news.save
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
|
||||
end
|
||||
render_attachment_warning_if_needed(@news)
|
||||
else
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html{redirect_to contest_news_index_path(@contest)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -310,10 +415,15 @@ class NewsController < ApplicationController
|
|||
if @news.org_subfield_id
|
||||
@org_subfield = OrgSubfield.find(@news.org_subfield_id)
|
||||
@organization = @org_subfield.organization
|
||||
elsif @news.contest_id
|
||||
@contest = Contest.find(@news.contest_id)
|
||||
end
|
||||
if @course
|
||||
@left_nav_type = 4
|
||||
render :layout => "base_courses"
|
||||
elsif @contest
|
||||
@left_nav_type = 4
|
||||
render :layout => "base_contests"
|
||||
elsif @org_subfield
|
||||
render :layout => 'base_org'
|
||||
end
|
||||
|
@ -335,6 +445,8 @@ class NewsController < ApplicationController
|
|||
def destroy
|
||||
if @news.org_subfield_id
|
||||
@org_subfield = OrgSubfield.find(@news.org_subfield_id)
|
||||
elsif @news.contest_id
|
||||
@contest = Contest.find(@news.contest_id)
|
||||
end
|
||||
@news.destroy
|
||||
# modify by nwb
|
||||
|
@ -342,6 +454,8 @@ class NewsController < ApplicationController
|
|||
redirect_to project_news_index_url(@project)
|
||||
elsif @course
|
||||
redirect_to course_news_index_url(@course)
|
||||
elsif @contest
|
||||
redirect_to contest_news_index_url(@contest)
|
||||
elsif @org_subfield
|
||||
redirect_to organization_path(@org_subfield.organization, :org_subfield_id => @org_subfield.id)
|
||||
end
|
||||
|
|
|
@ -133,6 +133,8 @@ class PraiseTreadController < ApplicationController
|
|||
@obj = Contest.find_by_id(id)
|
||||
when 'Syllabus'
|
||||
@obj = Syllabus.find_by_id(id)
|
||||
when 'Work'
|
||||
@obj = Work.find_by_id(id)
|
||||
else
|
||||
@obj = nil
|
||||
end
|
||||
|
|
|
@ -11,6 +11,8 @@ class ShieldActivitiesController < ApplicationController
|
|||
ShieldActivity.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i)
|
||||
elsif params[:course_id]
|
||||
ShieldActivity.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Course', :shield_id => params[:course_id].to_i)
|
||||
elsif params[:contest_id]
|
||||
ShieldActivity.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Contest', :shield_id => params[:contest_id].to_i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -37,6 +39,10 @@ class ShieldActivitiesController < ApplicationController
|
|||
ShieldActivity.where("container_type='User' and container_id=#{params[:user_id].to_i} and shield_type='Course' and shield_id=#{params[:course_id]}").each do |act|
|
||||
act.destroy
|
||||
end
|
||||
elsif params[:contest_id]
|
||||
ShieldActivity.where(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Contest', :shield_id => params[:contest_id].to_i).each do |act|
|
||||
act.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1344,22 +1344,6 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
def searchstudent_by_name users, name
|
||||
mems = []
|
||||
if name != ""
|
||||
name = name.to_s.downcase
|
||||
users.each do |m|
|
||||
username = m.lastname.to_s.downcase + m.firstname.to_s.downcase
|
||||
if(m.login.to_s.downcase.include?(name) || m.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
|
||||
mems << m
|
||||
end
|
||||
end
|
||||
else
|
||||
mems = users
|
||||
end
|
||||
mems
|
||||
end
|
||||
|
||||
def hsd_committed_work?(user, homework)
|
||||
sw = StudentWork.where("user_id =? and homework_common_id =? and work_status != 0", user, homework).first
|
||||
sw.nil? ? result = false : result = true
|
||||
|
|
|
@ -39,10 +39,10 @@ class UsersController < ApplicationController
|
|||
:unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
:anonymous_evaluation_list,:unfinished_test_list, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:unapproval_applied_list, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,:user_contestlist,
|
||||
:user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
|
||||
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list,
|
||||
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community]
|
||||
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community]
|
||||
before_filter :auth_user_extension, only: :show
|
||||
#before_filter :rest_user_score, only: :show
|
||||
#before_filter :select_entry, only: :user_projects
|
||||
|
@ -177,9 +177,9 @@ class UsersController < ApplicationController
|
|||
@is_project = params[:is_project]
|
||||
|
||||
case params[:type]
|
||||
when 'HomeworkCommon'
|
||||
when 'HomeworkCommon', 'Work'
|
||||
@reply = JournalsForMessage.find params[:reply_id]
|
||||
@type = 'HomeworkCommon'
|
||||
@type = params[:type]
|
||||
if params[:user_activity_id]
|
||||
@user_activity_id = params[:user_activity_id]
|
||||
else
|
||||
|
@ -1641,6 +1641,13 @@ class UsersController < ApplicationController
|
|||
@all_count = @user.favorite_projects.visible.count
|
||||
end
|
||||
|
||||
# 竞赛社区左侧列表展开
|
||||
def user_contests4show
|
||||
@page = params[:page].to_i + 1
|
||||
@courses = @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).offset(@page * 10)
|
||||
@all_count = @user.favorite_contests.visible.where("is_delete =?", 0).count
|
||||
end
|
||||
|
||||
def user_course_activities
|
||||
lastid = nil
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
|
@ -1873,7 +1880,7 @@ class UsersController < ApplicationController
|
|||
@applied_message_alls << mess
|
||||
end
|
||||
elsif (message_all.message_type == "AppliedMessage" )
|
||||
if (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1 && AppliedMessage.where("applied_id = #{mess.applied_id} and status != 1").count == 0) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 )
|
||||
if (mess.applied_type == "AppliedContest" && mess.status == 0) || (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 )
|
||||
@applied_message_alls << mess
|
||||
end
|
||||
elsif message_all.message_type == "CourseMessage"
|
||||
|
@ -2084,7 +2091,7 @@ class UsersController < ApplicationController
|
|||
@message_alls << mess
|
||||
end
|
||||
elsif (message_all.message_type == "AppliedMessage" )
|
||||
if (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1 && AppliedMessage.where("applied_id = #{mess.applied_id} and status != 1").count == 0) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 )
|
||||
if (mess.applied_type == "AppliedContest" && mess.status == 0) || (mess.applied_type == "StudentWorksScoresAppeal" && mess.status == 0) || (mess.applied_type == "AppliedProject" && mess.status == 1) || ( mess.applied_type == "ApplyAddSchools" && ApplyAddSchools.where(:school_id => mess.applied_id, :status => 0).count != 0 )
|
||||
@message_alls << mess
|
||||
end
|
||||
elsif message_all.message_type == "CourseMessage"
|
||||
|
@ -2229,6 +2236,61 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# 竞赛社区
|
||||
def contest_community
|
||||
shield_contest_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Contest'").map(&:shield_id)
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
user_contest_ids = (@user.favorite_contests.visible.where("is_delete = 0").map{|contest| contest.id}-shield_contest_ids).empty? ? "(-1)" : "(" + (@user.favorite_contests.visible.map{|contest| contest.id}-shield_contest_ids).join(",") + ")"
|
||||
contest_types = "('Message','News','Work','Contest','JournalsForMessage')"
|
||||
container_type = ''
|
||||
act_type = ''
|
||||
|
||||
if params[:type].present?
|
||||
case params[:type]
|
||||
when "contest_work"
|
||||
container_type = 'Contest'
|
||||
act_type = 'Work'
|
||||
when "contest_news"
|
||||
container_type = 'Contest'
|
||||
act_type = 'News'
|
||||
when "contest_message"
|
||||
container_type = 'Contest'
|
||||
act_type = 'Message'
|
||||
when "contest_journals"
|
||||
container_type = 'Contest'
|
||||
act_type = 'JournalsForMessage'
|
||||
when "current_user"
|
||||
container_type = 'Principal'
|
||||
act_type = 'Principal'
|
||||
when "all"
|
||||
container_type = 'all'
|
||||
act_type = 'all'
|
||||
end
|
||||
end
|
||||
if container_type != '' && container_type != 'all'
|
||||
if container_type == 'Contest'
|
||||
sql = "container_type = '#{container_type}' and container_id in #{user_contest_ids} and act_type = '#{act_type}'"
|
||||
elsif container_type == 'Principal' && act_type == 'Principal'
|
||||
sql = "user_id = #{@user.id} and (container_type = 'Contest' and container_id in #{user_contest_ids} and act_type in #{contest_types})"
|
||||
end
|
||||
if User.current != @user
|
||||
sql += " and user_id = #{@user.id}"
|
||||
end
|
||||
else
|
||||
sql = "(container_type = 'Contest' and container_id in #{user_contest_ids} and act_type in #{contest_types})"
|
||||
if container_type != 'all' && User.current != @user
|
||||
sql = "user_id = #{@user.id} and(" + sql + ")"
|
||||
end
|
||||
end
|
||||
@user_activities_count = UserActivity.where("#{sql}").order('updated_at desc').count
|
||||
@user_activities = UserActivity.where("#{sql}").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
@type = params[:type]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'base_contest_community'}
|
||||
end
|
||||
end
|
||||
|
||||
def show_old
|
||||
pre_count = 10 #limit
|
||||
# Time 2015-02-04 11:46:34
|
||||
|
@ -3984,7 +4046,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#收藏班级/项目
|
||||
#收藏班级/项目/竞赛
|
||||
def cancel_or_collect
|
||||
if params[:project]
|
||||
@project = Project.find params[:project]
|
||||
|
@ -3992,20 +4054,39 @@ class UsersController < ApplicationController
|
|||
elsif params[:course]
|
||||
@course = Course.find params[:course]
|
||||
member = Member.where("user_id = #{@user.id} and course_id = #{@course.id}")
|
||||
elsif params[:contest]
|
||||
@contest = Contest.find params[:contest]
|
||||
member = ContestMember.where("user_id = #{@user.id} and contest_id = #{@contest.id}")
|
||||
end
|
||||
unless member.empty?
|
||||
member.first.update_attribute(:is_collect, member.first.is_collect == 0 ? 1 : 0)
|
||||
member.first.update_attribute(:is_collect, member.first.is_collect == false ? 1 : 0)
|
||||
end
|
||||
if @project
|
||||
@projects = @user.favorite_projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)
|
||||
elsif @course
|
||||
@courses = @user.favorite_courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10)
|
||||
elsif @contest
|
||||
@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)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
# 用户竞赛列表
|
||||
def user_contestlist
|
||||
# 我创建的竞赛
|
||||
@my_contests = @user.contests.where(:user_id => @user.id).order("created_at desc")
|
||||
@my_contests_count = @my_contests.count
|
||||
# 我参与的竞赛
|
||||
my_all_contests = @user.contest_members.where(:user_id => @user.id).blank? ? "(-1)" : "(" + @user.contest_members.where(:user_id => @user.id).map{ |cm| cm.contest_id }.join(",") + ")"
|
||||
@my_joined_contests = Contest.where("id in #{my_all_contests} and user_id != #{@user.id}").order("created_at desc")
|
||||
@my_joined_contests_count = @my_joined_contests.count
|
||||
respond_to do |format|
|
||||
format.html {render :layout => 'base_contest_community'}
|
||||
end
|
||||
end
|
||||
|
||||
def user_projectlist
|
||||
@order, @c_sort, @type, @list_type = 1, 2, 1, 1
|
||||
#limit = 5
|
||||
|
|
|
@ -362,6 +362,70 @@ class WordsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#题目的回复
|
||||
def leave_contest_work_message
|
||||
if User.current.logged?
|
||||
@user = User.current
|
||||
@contestwork = Work.find(params[:id])
|
||||
if params[:homework_message].size>0 && User.current.logged? && @user
|
||||
feedback = Work.add_work_jour(@user, params[:homework_message], params[:id], @contestwork.id)
|
||||
if (feedback.errors.empty?)
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
||||
end
|
||||
@contestwork.update_column('updated_at', Time.now)
|
||||
update_contest_activity(@contestwork.class,@contestwork.id)
|
||||
update_user_activity(@contestwork.class,@contestwork.id)
|
||||
respond_to do |format|
|
||||
format.js{
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
@hw_status = params[:hw_status].to_i if params[:hw_status]
|
||||
@is_teacher = User.current.admin_of_contest?(@contestwork.contest) || User.current.admin?
|
||||
}
|
||||
end
|
||||
else
|
||||
flash[:error] = feedback.errors.full_messages[0]
|
||||
end
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
#题目的二级回复
|
||||
def reply_to_contest_work
|
||||
if User.current.logged?
|
||||
@user = User.current
|
||||
reply = JournalsForMessage.find params[:id].to_i
|
||||
@contestwork = Work.find reply.jour_id
|
||||
if params[:reply_message].size>0 && User.current.logged? && @user
|
||||
options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i, :root_id => reply.root_id}
|
||||
feedback = Work.add_work_jour(@user, params[:reply_message], reply.jour_id, reply.root_id, options)
|
||||
if (feedback.errors.empty?)
|
||||
if params[:asset_id]
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
||||
end
|
||||
@contestwork.update_column('updated_at', Time.now)
|
||||
update_contest_activity(@contestwork.class,@contestwork.id)
|
||||
update_user_activity(@contestwork.class,@contestwork.id)
|
||||
respond_to do |format|
|
||||
format.js{
|
||||
@user_activity_id = params[:user_activity_id].to_i
|
||||
@hw_status = params[:hw_status].to_i if params[:hw_status]
|
||||
@is_teacher = User.current.admin_of_contest?(@contestwork.contest) || User.current.admin?
|
||||
}
|
||||
end
|
||||
else
|
||||
flash[:error] = feedback.errors.full_messages[0]
|
||||
end
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
#课程大纲的二级回复
|
||||
def reply_to_syllabus
|
||||
if User.current.logged?
|
||||
|
|
|
@ -0,0 +1,223 @@
|
|||
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 :member_of_contest, :only => [:index]
|
||||
|
||||
def index
|
||||
search = "%#{params[:search].to_s.strip.downcase}%"
|
||||
@new_homework = Work.new
|
||||
@new_homework.contest = @contest
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
@is_teacher = User.current.logged? && (User.current.admin? || User.current.admin_of_contest?(@contest))
|
||||
if @is_teacher
|
||||
@homework_commons = @contest.works.where("name like '%#{search}%'").order("created_at desc")
|
||||
else
|
||||
@homework_commons = @contest.works.where("name like '%#{search}%' and publish_time <= '#{Date.today}'").order("created_at desc")
|
||||
end
|
||||
@is_new = params[:is_new]
|
||||
|
||||
@homeworks = paginateHelper @homework_commons,10
|
||||
#设置at已读
|
||||
ids = @homeworks.inject([]) do |ids, homework|
|
||||
jids = homework.journals_for_messages.map(&:id)
|
||||
jids ? ids + jids : ids
|
||||
|
||||
# homework.delay.set_jour_viewed
|
||||
end
|
||||
unless ids.empty?
|
||||
User.current.at_messages.where(viewed: false,
|
||||
at_message_type: 'JournalsForMessage',
|
||||
at_message_id: ids).update_all(viewed: true)
|
||||
end
|
||||
|
||||
@left_nav_type = 3
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
if User.current.logged?
|
||||
if params[:homework_common]
|
||||
homework = Work.new
|
||||
homework.name = params[:homework_common][:name]
|
||||
homework.description = params[:homework_common][:description]
|
||||
homework.end_time = params[:homework_common][:end_time] || Date.today
|
||||
if params[:homework_common][:publish_time] == ""
|
||||
homework.publish_time = Date.today
|
||||
else
|
||||
homework.publish_time = params[:homework_common][:publish_time]
|
||||
end
|
||||
homework.work_type = params[:homework_type].to_i || 1
|
||||
#homework.late_penalty = 0
|
||||
#homework.teacher_priority = 1
|
||||
homework.user_id = User.current.id
|
||||
homework.contest_id = @contest.id
|
||||
|
||||
homework.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(homework)
|
||||
|
||||
homework.work_status = homework.publish_time > Date.today ? 0 : 1
|
||||
|
||||
#分组作业
|
||||
if homework.work_type == 3
|
||||
homework_detail_group = WorkDetailGroup.new
|
||||
homework.work_detail_group = homework_detail_group
|
||||
homework_detail_group.min_num = params[:min_num].to_i
|
||||
homework_detail_group.max_num = params[:max_num].to_i
|
||||
homework_detail_group.base_on_project = params[:base_on_project].to_i
|
||||
end
|
||||
|
||||
if homework.save
|
||||
homework_detail_group.save if homework_detail_group
|
||||
redirect_to works_path(:contest => @contest.id)
|
||||
end
|
||||
end
|
||||
else
|
||||
render_403
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if params[:homework_common]
|
||||
@contestwork.name = params[:homework_common][:name]
|
||||
@contestwork.description = params[:homework_common][:description]
|
||||
if params[:homework_common][:publish_time] == ""
|
||||
@contestwork.publish_time = Date.today
|
||||
else
|
||||
@contestwork.publish_time = params[:homework_common][:publish_time]
|
||||
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")
|
||||
if homework_end_time != param_end_time
|
||||
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")
|
||||
st.work_status = 2
|
||||
st.save
|
||||
end
|
||||
end
|
||||
else
|
||||
@contestwork.contestant_works.where("work_status = 2").each do |st|
|
||||
if param_end_time >= Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d")
|
||||
st.work_status = 1
|
||||
st.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@contestwork.end_time = params[:homework_common][:end_time] || Time.now
|
||||
if params[:homework_type] && params[:homework_type].to_i != @contestwork.work_type
|
||||
if @contestwork.work_type == 3
|
||||
@contestwork.work_detail_group.destroy if @contestwork.work_detail_group
|
||||
end
|
||||
end
|
||||
@contestwork.work_type = params[:homework_type].to_i || @contestwork.work_type
|
||||
|
||||
#status = false
|
||||
if @contestwork.publish_time <= Date.today && @contestwork.work_status == 0
|
||||
@contestwork.work_status = 1
|
||||
#status = true
|
||||
end
|
||||
|
||||
@contestwork.save_attachments(params[:attachments])
|
||||
render_attachment_warning_if_needed(@contestwork)
|
||||
|
||||
#分组作业
|
||||
if @contestwork.work_type == 3
|
||||
@contestwork.work_detail_group ||= WorkDetailGroup.new
|
||||
@homework_detail_group = @contestwork.work_detail_group
|
||||
@homework_detail_group.min_num = params[:min_num].to_i if params[:min_num]
|
||||
@homework_detail_group.max_num = params[:max_num].to_i if params[:max_num]
|
||||
@homework_detail_group.base_on_project = params[:base_on_project] ? 1 : 0
|
||||
end
|
||||
|
||||
if @contestwork.save
|
||||
@homework_detail_group.save if @homework_detail_group
|
||||
|
||||
@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)
|
||||
elsif @hw_status == 5
|
||||
redirect_to contestant_works_path(:work => @contestwork.id)
|
||||
else
|
||||
redirect_to works_path(:contest => @contest.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = User.current
|
||||
@hw_status = params[:hw_status].to_i
|
||||
@homework = @contestwork
|
||||
if @hw_status != 1
|
||||
@left_nav_type = 3
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_contests'}
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_contest_community'}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @contestwork.destroy
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
@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
|
||||
|
||||
private
|
||||
|
||||
#获取竞赛
|
||||
def find_contest
|
||||
@contest = Contest.find params[:contest]
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
#获取题目
|
||||
def find_contestwork
|
||||
@contestwork = Work.find params[:id]
|
||||
@work_detail_group = @contestwork.work_detail_group
|
||||
@contest = @contestwork.contest
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
#是不是管理员
|
||||
def admin_of_contest
|
||||
render_403 unless User.current.admin_of_contest?(@contest) || User.current.admin?
|
||||
end
|
||||
|
||||
#当前用户是不是竞赛的成员
|
||||
def member_of_contest
|
||||
render_403 unless @contest.is_public==1 || User.current.member_of_contest?(@contest) || User.current.admin?
|
||||
end
|
||||
|
||||
end
|
|
@ -52,6 +52,17 @@ class ZipdownController < ApplicationController
|
|||
else
|
||||
zipfile = {:message => "no file"}
|
||||
end
|
||||
elsif params[:obj_class] == "Work"
|
||||
homework = Work.find params[:obj_id]
|
||||
render_403 if User.current.admin_of_contest?(homework.contest)
|
||||
file_count = 0
|
||||
homework.contestant_works.map { |work| file_count += work.attachments.count}
|
||||
if file_count > 0
|
||||
zipfile = zip_homework_common homework
|
||||
else
|
||||
zipfile = {:message => "no file"}
|
||||
end
|
||||
|
||||
else
|
||||
logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!"
|
||||
end
|
||||
|
@ -159,6 +170,33 @@ class ZipdownController < ApplicationController
|
|||
}]
|
||||
end
|
||||
|
||||
def zip_contest_work homework_common
|
||||
bid_homework_path = []
|
||||
digests = []
|
||||
homework_common.contestant_works.each do |work|
|
||||
unless work.attachments.empty?
|
||||
out_file = zip_student_work_by_user(work)
|
||||
|
||||
bid_homework_path << out_file.file_path
|
||||
digests << out_file.file_digest
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
homework_id = homework_common.id
|
||||
user_id = homework_common.user_id
|
||||
out_file = find_or_pack(homework_id, user_id, digests.sort){
|
||||
zipping("#{Time.now.to_i}_#{homework_common.name}.zip",
|
||||
bid_homework_path, OUTPUT_FOLDER)
|
||||
}
|
||||
[{files:[out_file.file_path], count: 1, index: 1,
|
||||
real_file: out_file.file_path,
|
||||
file: File.basename(out_file.file_path),
|
||||
base64file: encode64(File.basename(out_file.file_path)),
|
||||
size:(out_file.pack_size / 1024.0 / 1024.0).round(2)
|
||||
}]
|
||||
end
|
||||
|
||||
def zip_homework_by_user(homework_attach)
|
||||
homeworks_attach_path = []
|
||||
not_exist_file = []
|
||||
|
@ -216,6 +254,39 @@ class ZipdownController < ApplicationController
|
|||
|
||||
end
|
||||
|
||||
def zip_student_work_by_user(work)
|
||||
homeworks_attach_path = []
|
||||
not_exist_file = []
|
||||
# 需要将所有homework.attachments遍历加入zip
|
||||
digests = []
|
||||
work.attachments.each do |attach|
|
||||
if File.exist?(attach.diskfile)
|
||||
homeworks_attach_path << attach.diskfile
|
||||
digests << attach.digest
|
||||
else
|
||||
not_exist_file << attach.filename
|
||||
digests << 'not_exist_file'
|
||||
end
|
||||
end
|
||||
|
||||
#单个文件的话,不需要压缩,只改名
|
||||
out_file = nil
|
||||
if homeworks_attach_path.size == 1
|
||||
out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){
|
||||
des_path = "#{OUTPUT_FOLDER}/#{make_zip_name(work)}_#{File.basename(homeworks_attach_path.first)}"
|
||||
FileUtils.cp homeworks_attach_path.first, des_path
|
||||
des_path
|
||||
}
|
||||
else
|
||||
out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){
|
||||
zipping("#{make_zip_name(work)}.zip",
|
||||
homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file)
|
||||
}
|
||||
end
|
||||
out_file
|
||||
|
||||
end
|
||||
|
||||
|
||||
def find_or_pack(homework_id, user_id, digests)
|
||||
raise "please given a pack block" unless block_given?
|
||||
|
|
|
@ -37,6 +37,21 @@ module ApplicationHelper
|
|||
# super
|
||||
# end
|
||||
|
||||
# 获取竞赛的管理人员
|
||||
def contest_managers contest
|
||||
contest.contest_members.select{|cm| cm.roles.to_s.include?("ContestManager")}
|
||||
end
|
||||
|
||||
# 获取竞赛的评委人员
|
||||
def contest_judges contest
|
||||
contest.contest_members.select{|cm| cm.roles.to_s.include?("Judge")}
|
||||
end
|
||||
|
||||
# 获取竞赛的参赛人员
|
||||
def contest_contestants contest
|
||||
contest.contest_members.select{|cm| cm.roles.to_s.include?("Contestant")}
|
||||
end
|
||||
|
||||
# 字符串加密
|
||||
def aes_encrypt(key, encrypted_string)
|
||||
aes = OpenSSL::Cipher::Cipher.new("AES-128-ECB")
|
||||
|
@ -53,7 +68,6 @@ module ApplicationHelper
|
|||
aes.key = key
|
||||
aes.update([dicrypted_string].pack('H*')) << aes.final
|
||||
end
|
||||
|
||||
# 获取多种类型的user用户名
|
||||
def user_message_username user
|
||||
user.try(:show_name)
|
||||
|
@ -2849,9 +2863,16 @@ module ApplicationHelper
|
|||
end
|
||||
technical_title
|
||||
end
|
||||
|
||||
# 用户竞赛总数
|
||||
def user_contest_count
|
||||
count = @user.favorite_contests.visible.where("is_delete =?", 0).count
|
||||
return count
|
||||
end
|
||||
|
||||
# 用户项目总数
|
||||
def user_project_count
|
||||
@my_projects = @user.projects.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC")
|
||||
@my_projects = @user.projects.visible.where("status != 9")
|
||||
@my_project_total = @my_projects.count
|
||||
end
|
||||
|
||||
|
@ -3047,6 +3068,40 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
#根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量
|
||||
def user_for_contest_work homework,is_contestant,work
|
||||
count = homework.contestant_works.has_committed.count
|
||||
if User.current.member_of_contest?(homework.contest)
|
||||
if !is_contestant #老师显示作品数量
|
||||
link_to "作品(#{count})", contestant_works_path(:work =>homework.id, :tab => 2), :class => "c_blue"
|
||||
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 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
|
||||
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 => "作业截止后不可修改作品"
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
link_to "作品(#{count})",contestant_works_path(:work =>homework.id, :tab => 2),:class => "c_blue"
|
||||
end
|
||||
end
|
||||
|
||||
#根据传入作业确定显示为提交作品、补交作品、查看作品等
|
||||
def student_for_homework_common homework
|
||||
if User.current.allowed_to?(:as_teacher, homework.course)
|
||||
|
@ -3131,6 +3186,24 @@ module ApplicationHelper
|
|||
homework.student_work_projects.where("user_id = ?",User.current).first
|
||||
end
|
||||
|
||||
#获取当前用户在指定题目下提交的作业的集合
|
||||
def cur_user_works_for_work homework
|
||||
work = homework.contestant_works.where("user_id = ? && work_status != 0",User.current).first
|
||||
if homework.work_type == 3
|
||||
pro = homework.contestant_work_projects.where("user_id = #{User.current.id}").first
|
||||
if pro.nil? || pro.contestant_work_id == "" || pro.contestant_work_id.nil?
|
||||
work = nil
|
||||
else
|
||||
work = ContestantWork.find pro.contestant_work_id
|
||||
end
|
||||
end
|
||||
work
|
||||
end
|
||||
#获取当前用户在指定题目下关联的项目的集合
|
||||
def cur_user_projects_for_work work
|
||||
work.contestant_work_projects.where("user_id = ?",User.current).first
|
||||
end
|
||||
|
||||
#获取当前作业的提交截止时间/互评截止时间
|
||||
def cur_homework_end_time homework
|
||||
str = ""
|
||||
|
@ -3317,6 +3390,14 @@ int main(int argc, char** argv){
|
|||
ss.html_safe
|
||||
end
|
||||
|
||||
#竞赛动态的更新
|
||||
def update_contest_activity type, id
|
||||
contest_activity = ContestActivity.where("contest_act_type=? and contest_act_id =?", type.to_s, id).first
|
||||
if contest_activity
|
||||
contest_activity.updated_at = Time.now
|
||||
contest_activity.save
|
||||
end
|
||||
end
|
||||
#课程动态的更新
|
||||
def update_course_activity type, id
|
||||
course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", type.to_s, id).first
|
||||
|
@ -3415,6 +3496,17 @@ def student_work_index_url_in_org(homework_id, tab = 1, is_focus = '', show_work
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def contestant_work_index_url_in_org(work_id, tab = 1, is_focus = '', show_work_id = '')
|
||||
if is_focus != ''
|
||||
Setting.protocol + "://" + Setting.host_name + "/contestant_work?work=" + work_id.to_s + "&tab=" + tab.to_s + "&is_focus=" + is_focus.to_s
|
||||
elsif show_work_id != ''
|
||||
Setting.protocol + "://" + Setting.host_name + "/contestant_work?work=" + work_id.to_s + "&tab=" + tab.to_s + "&show_work_id=" + show_work_id.to_s
|
||||
else
|
||||
Setting.protocol + "://" + Setting.host_name + "/contestant_work?work=" + work_id.to_s + "&tab=" + tab.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def course_url_in_org(course_id)
|
||||
Setting.protocol + "://" + Setting.host_name + "/courses/" + course_id.to_s
|
||||
end
|
||||
|
@ -3773,6 +3865,17 @@ def message_content content
|
|||
content
|
||||
end
|
||||
|
||||
def get_work_index(hw,is_teacher)
|
||||
if is_teacher
|
||||
works = hw.contest.works.order("created_at asc")
|
||||
else
|
||||
works = hw.contest.works.where("publish_time <= '#{Date.today}'").order("created_at asc")
|
||||
end
|
||||
hw_ids = works.map{|hw| hw.id} if !works.empty?
|
||||
index = hw_ids.index(hw.id)
|
||||
return index
|
||||
end
|
||||
|
||||
def get_hw_index(hw,is_teacher)
|
||||
if is_teacher
|
||||
homeworks = hw.course.homework_commons.order("created_at asc")
|
||||
|
@ -3823,6 +3926,23 @@ def get_hw_status homework_common
|
|||
str
|
||||
end
|
||||
|
||||
def get_cw_status contest_work
|
||||
str = ""
|
||||
if contest_work.work_status == 0 && contest_work.publish_time.nil?
|
||||
str += '<span class="grey_homework_btn_cir ml5">挂起</span>'
|
||||
elsif contest_work.work_status == 0
|
||||
str += '<span class="grey_homework_btn_cir ml5">未发布</span>'
|
||||
elsif contest_work.work_status == 1
|
||||
if Time.parse(contest_work.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
|
||||
str += '<span class="green_homework_btn_cir ml5">作品提交中</span>'
|
||||
else
|
||||
str += '<span class="red_homework_btn_cir ml5">作品补交中</span>'
|
||||
end
|
||||
end
|
||||
str
|
||||
end
|
||||
|
||||
|
||||
def get_group_member_names work
|
||||
result = ""
|
||||
unless work.nil?
|
||||
|
@ -3907,6 +4027,54 @@ def homework_type_option
|
|||
type
|
||||
end
|
||||
|
||||
# 竞赛题目类型
|
||||
def work_type_option
|
||||
type = []
|
||||
option0 = []
|
||||
option0 << "请选择竞赛类型"
|
||||
option0 << 0
|
||||
option1 = []
|
||||
option1 << "普通竞赛"
|
||||
option1 << 1
|
||||
# option2 = []
|
||||
# option2 << "编程作业"
|
||||
# option2 << 2
|
||||
option3 = []
|
||||
option3 << "团队竞赛"
|
||||
option3 << 3
|
||||
type << option0
|
||||
type << option1
|
||||
#type << option2
|
||||
type << option3
|
||||
type
|
||||
end
|
||||
|
||||
# 当前用户可见的某竞赛下的作品数
|
||||
def visable_contest_work contest
|
||||
if User.current.admin? || User.current.admin_of_contest?(contest)
|
||||
work_num = contest.works.count
|
||||
else
|
||||
work_num = contest.works.where("publish_time <= '#{Date.today}'").count
|
||||
end
|
||||
work_num
|
||||
end
|
||||
|
||||
def searchstudent_by_name users, name
|
||||
mems = []
|
||||
if name != ""
|
||||
name = name.to_s.downcase
|
||||
users.each do |m|
|
||||
username = m.lastname.to_s.downcase + m.firstname.to_s.downcase
|
||||
if(m.login.to_s.downcase.include?(name) || m.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
|
||||
mems << m
|
||||
end
|
||||
end
|
||||
else
|
||||
mems = users
|
||||
end
|
||||
mems
|
||||
end
|
||||
|
||||
def add_reply_adapter obj, options
|
||||
#modify by nwb
|
||||
#添加对课程留言的支持
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#encoding=utf-8
|
||||
module ContestMembersHelper
|
||||
|
||||
def find_user_not_in_current_contest_by_name contest
|
||||
if params[:q] && params[:q].lstrip.rstrip != ""
|
||||
scope = Principal.active.sorted.not_member_of_contest(contest).like(params[:q])
|
||||
else
|
||||
scope = []
|
||||
end
|
||||
principals = paginateHelper scope,10
|
||||
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals', :class => 'sy_new_tchlist')
|
||||
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options|
|
||||
link_to text, host_with_protocol + "/contest_members/contest_member_autocomplete?" + parameters.merge(:q => params[:q],:flag => true,:contest=> contest, :format => 'js').to_query, :remote => true
|
||||
}
|
||||
s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "contest_member_pagination_links" )
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
#encoding: utf-8
|
||||
module ContestantWorksHelper
|
||||
|
||||
def get_status status
|
||||
str = ""
|
||||
case status
|
||||
when 0
|
||||
str = "未提交"
|
||||
when 1
|
||||
str = "已提交"
|
||||
when 2
|
||||
str = "迟交"
|
||||
end
|
||||
str
|
||||
end
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module ContestnotificationsHelper
|
||||
end
|
|
@ -1,206 +1,79 @@
|
|||
#enconding:utf-8
|
||||
# fq
|
||||
module ContestsHelper
|
||||
|
||||
def render_notes(contest, journal, options={})
|
||||
content = ''
|
||||
removable = User.current == journal.user || User.current == contest.author
|
||||
links = []
|
||||
if !journal.notes.blank?
|
||||
links << link_to(image_tag('comment.png'),
|
||||
{:controller => 'contests', :action => 'new', :id => contest, :journal_id => journal},
|
||||
:remote => true,
|
||||
:method => 'post',
|
||||
:title => l(:button_quote)) if options[:reply_links]
|
||||
if removable
|
||||
url = {:controller => 'contests',
|
||||
:action => 'destroy',
|
||||
:object_id => journal,
|
||||
:id => contest}
|
||||
links << ' '
|
||||
links << link_to(image_tag('delete.png'), url,
|
||||
:remote => true, :method => 'delete', :class => "delete", :title => l(:button_delete))
|
||||
end
|
||||
|
||||
# 获取动态列表名称
|
||||
def get_acts_list_type type
|
||||
case type
|
||||
when "work"
|
||||
l(:label_homework_acts)
|
||||
when "news"
|
||||
l(:label_news_acts)
|
||||
when "attachment"
|
||||
l(:label_attachment_acts)
|
||||
when "message"
|
||||
l(:label_message_acts)
|
||||
when "journalsForMessage"
|
||||
l(:label_journalsForMessage_acts)
|
||||
when "poll"
|
||||
l(:label_poll_acts)
|
||||
else
|
||||
l(:label_all_cats)
|
||||
end
|
||||
content << content_tag('div', links.join(' ').html_safe, :class => 'contextual') unless links.empty?
|
||||
content << textilizable(journal.notes)
|
||||
css_classes = "wiki"
|
||||
content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes)
|
||||
end
|
||||
|
||||
def link_to_in_place_notes_editor(text, field_id, url, options={})
|
||||
onclick = "$.ajax({url: '#{url_for(url)}', type: 'get'}); return false;"
|
||||
link_to text, '#', options.merge(:onclick => onclick)
|
||||
|
||||
# 判断当前用户是否为竞赛管理员
|
||||
def is_contest_manager?(user_id, contest_id)
|
||||
@result = false
|
||||
mem = ContestMember.where("user_id = ? and contest_id = ?",user_id, contest_id)
|
||||
unless mem.blank?
|
||||
@result = mem.first.roles.to_s.include?("ContestManager") ? true : false
|
||||
end
|
||||
return @result
|
||||
end
|
||||
|
||||
# this method is used to get all projects that tagged one tag
|
||||
# added by william
|
||||
def get_contests_by_tag(tag_name)
|
||||
Contest.tagged_with(tag_name).order('updated_on desc')
|
||||
|
||||
# 获取竞赛的管理人员
|
||||
def contest_managers contest
|
||||
contest.contest_members.select{|cm| cm.roles.to_s.include?("ContestManager")}
|
||||
end
|
||||
|
||||
#added by huang
|
||||
def sort_contest_enterprise(state, project_type)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type)))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), calls_path(:contest_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), calls_path(:contest_sort_type => '0', :project_type => project_type)))
|
||||
|
||||
# 获取竞赛的评委人员
|
||||
def contest_judges contest
|
||||
contest.contest_members.select{|cm| cm.roles.to_s.include?("Judge")}
|
||||
end
|
||||
|
||||
# 获取竞赛的参赛人员
|
||||
def contest_contestants contest
|
||||
contest.contest_members.select{|cm| cm.roles.to_s.include?("Contestant")}
|
||||
end
|
||||
|
||||
def searchmember_by_name members, name
|
||||
#searchPeopleByRoles(project, StudentRoles)
|
||||
mems = []
|
||||
if name != ""
|
||||
name = name.to_s.downcase
|
||||
members.each do |m|
|
||||
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
|
||||
if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
|
||||
mems << m
|
||||
end
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs_enterprise")
|
||||
end
|
||||
#end
|
||||
|
||||
|
||||
|
||||
#huang
|
||||
def sort_contest(state)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}))
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}, :class=>"selected"), :class=>"selected")
|
||||
|
||||
when 1
|
||||
content << content_tag('li', link_to(l(:label_sort_by_time), {controller: 'contests', action: 'index' ,:contest_sort_type => '1'}, :class=>"selected"), :class=>"selected")
|
||||
content << content_tag('li', link_to(l(:label_sort_by_active), {controller: 'contests', action: 'index' ,:contest_sort_type => '0'}))
|
||||
else
|
||||
mems = members
|
||||
end
|
||||
content = content_tag('ul', content)
|
||||
content_tag('div', content, :class => "tabs")
|
||||
end
|
||||
#end
|
||||
|
||||
# def course_options_for_select(courses)
|
||||
# # <option value = '0'>#{l(:label_choose_reward)}</option>
|
||||
# html = ''
|
||||
# courses.each do |course|
|
||||
# html << "<option value = #{course.id}>"
|
||||
# html << course.name
|
||||
# html << "</option>"
|
||||
# end
|
||||
# html.html_safe
|
||||
# end
|
||||
|
||||
|
||||
# used to get the reward and handle the value which can be used to display in views
|
||||
# added by william
|
||||
def get_prize(c_project)
|
||||
c_project.get_reward
|
||||
mems
|
||||
end
|
||||
|
||||
def get_prize(c_softapplication)
|
||||
c_softapplication.get_reward
|
||||
end
|
||||
|
||||
def count_contest_project
|
||||
contests = Contest.find(:id)
|
||||
@projects = []
|
||||
# Modified by longjun
|
||||
# for contest in contests
|
||||
contests.each do |contest|
|
||||
# end longjun
|
||||
@projects += contest.contesting_projects
|
||||
def zh_contest_role role
|
||||
if role == "ContestManager"
|
||||
result = l(:label_CM)
|
||||
elsif role == "Judge"
|
||||
result = l(:label_judge)
|
||||
elsif role == "Contestant"
|
||||
result = l(:label_contestant)
|
||||
elsif role == "Manager"
|
||||
result = l(:field_admin)
|
||||
elsif role.include?("ContestManager") && role.include?("Judge")
|
||||
result = l(:label_CM) + " " + l(:label_judge)
|
||||
end
|
||||
@projects.count
|
||||
result
|
||||
end
|
||||
|
||||
def count_contest_softapplication
|
||||
contests = Contest.find(:id)
|
||||
@softapplications = []
|
||||
# Modified by alan
|
||||
# for contest in contests
|
||||
contests.each do |contest|
|
||||
# end alan
|
||||
@softapplications += contest.contesting_softapplications
|
||||
end
|
||||
@projects.count
|
||||
end
|
||||
|
||||
|
||||
def count_contest_user
|
||||
contests = Contest.find(:id)
|
||||
@users = []
|
||||
# Modified by alan
|
||||
# for contest in contests
|
||||
contests.each do |contest|
|
||||
|
||||
contest.projects.each do |project|
|
||||
|
||||
@users += project.users
|
||||
end
|
||||
end
|
||||
# end alan
|
||||
|
||||
@users.count
|
||||
end
|
||||
|
||||
def count_contest_softapplication_user
|
||||
contests = Contest.find(:id)
|
||||
@users = []
|
||||
# Modified by alan
|
||||
# for contest in contests
|
||||
contests.each do |contest|
|
||||
|
||||
contest.projects.each do |softapplications|
|
||||
# for project in contest.softapplications
|
||||
@users += softapplication.users
|
||||
end
|
||||
end
|
||||
@users.count
|
||||
end
|
||||
def im_watching_student_id? contest
|
||||
people = []
|
||||
people << contest.author
|
||||
# case bid.reward_type # 天煞的bid分了三用途,里面各种hasmany还不定能用!
|
||||
# when 1
|
||||
# when 2
|
||||
# bid.join_in_contests.each do |jic|
|
||||
# people << jic.user
|
||||
# end
|
||||
# when 3
|
||||
# people += bid.courses.first.users.to_a
|
||||
# else
|
||||
# raise 'bids_helper: unknow bid type' # 出了错看这里!不知道的抛异常,省的找不到出错的地方!
|
||||
# end
|
||||
|
||||
contest.join_in_contests.each do |jic|
|
||||
people << jic.user
|
||||
end
|
||||
people.include?(User.current)
|
||||
end
|
||||
|
||||
# def select_option_helper option
|
||||
# tmp = Hash.new
|
||||
# tmp={"" => ""}
|
||||
# option.each do |project|
|
||||
# tmp[project.name] = project.identifier
|
||||
# end
|
||||
# tmp
|
||||
# end
|
||||
def select_option_app_helper options
|
||||
tmp = Hash.new
|
||||
options.each do |option|
|
||||
tmp[option.name] = option.id
|
||||
end
|
||||
tmp
|
||||
end
|
||||
|
||||
#作品分类下拉框
|
||||
def work_type_opttion
|
||||
type = []
|
||||
#work_types = WorksCategory.all
|
||||
WorksCategory.all.each do |work_type|
|
||||
option = []
|
||||
option << work_type.category
|
||||
option << work_type.category
|
||||
type << option
|
||||
end
|
||||
type
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,4 +11,5 @@ module OwnerTypeHelper
|
|||
SYLLABUS = 10
|
||||
ArticleHomepage = 11
|
||||
PROJECT = 12
|
||||
CONTEST = 13
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module WorksHelper
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
class AppliedContest < ActiveRecord::Base
|
||||
include ContestsHelper
|
||||
belongs_to :contest
|
||||
belongs_to :user
|
||||
#status :0 新建 1 已批准 2 拒绝
|
||||
attr_accessible :role, :status, :contest_id, :user_id
|
||||
|
||||
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'
|
||||
role = 1
|
||||
when '14'
|
||||
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)
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
|
@ -1,136 +1,111 @@
|
|||
class Contest < ActiveRecord::Base
|
||||
attr_accessible :author_id, :budget, :commit, :deadline, :description, :name, :password
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
|
||||
has_many :contesting_projects, :dependent => :destroy
|
||||
has_many :projects, :through => :contesting_projects
|
||||
has_many :contesting_softapplications, :dependent => :destroy
|
||||
has_many :softapplications, :through => :contesting_softapplications, :dependent => :destroy
|
||||
has_many :projects_member, :class_name => 'User', :through => :projects
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
has_many :join_in_competitions, foreign_key: 'competition_id', :dependent => :destroy
|
||||
has_many :join_in_contests, class_name: 'JoinInCompetition', foreign_key: 'competition_id', :dependent => :destroy
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
has_one :praise_tread_cache, as: :object, dependent: :destroy
|
||||
has_many :contestnotifications, :dependent => :destroy, :include => :author
|
||||
|
||||
|
||||
|
||||
|
||||
acts_as_attachable
|
||||
|
||||
NAME_LENGTH_LIMIT = 60
|
||||
DESCRIPTION_LENGTH_LIMIT = 250
|
||||
validates :name, length: {maximum: NAME_LENGTH_LIMIT}, presence: true
|
||||
validates :description, length: {maximum: DESCRIPTION_LENGTH_LIMIT}
|
||||
validates :author_id, presence: true
|
||||
validates :budget, presence: true
|
||||
validates :deadline, format: {:with =>/^[1-9][0-9]{3}\-0?[1-9]|1[12]\-0?[1-9]|[12]\d|3[01]$/}
|
||||
validate :validate_user
|
||||
after_create :act_as_activity
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
nil
|
||||
}
|
||||
|
||||
scope :like, lambda {|arg|
|
||||
if arg.blank?
|
||||
where(nil)
|
||||
else
|
||||
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||
where("LOWER(id) LIKE :p OR LOWER(name) LIKE :p OR LOWER(description) LIKE :p", :p => pattern)
|
||||
end
|
||||
}
|
||||
|
||||
acts_as_watchable
|
||||
acts_as_taggable
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_requirement)} ##{o.id}: #{o.name}" },
|
||||
:description => :description,
|
||||
:author => :author,
|
||||
:url => Proc.new {|o| {:controller => 'contests', :action => 'show_contest', :id => o.id}}
|
||||
|
||||
acts_as_activity_provider :find_options => {:include => [:projects, :author]},
|
||||
:author_key => :author_id
|
||||
|
||||
safe_attributes 'name',
|
||||
'description',
|
||||
'budget',
|
||||
'deadline',
|
||||
'password'
|
||||
|
||||
|
||||
def add_jour(user, notes, reference_user_id = 0, options = {})
|
||||
if options.count == 0
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
|
||||
else
|
||||
jfm = self.journals_for_messages.build(options)
|
||||
jfm.save
|
||||
jfm
|
||||
end
|
||||
end
|
||||
|
||||
# modified by longjun
|
||||
# 这个函数没有用到
|
||||
# def self.creat_contests(budget, deadline, name, description=nil)
|
||||
# self.create(:author_id => User.current.id, :budget => budget,
|
||||
# :deadline => deadline, :name => name, :description => description, :commit => 0)
|
||||
# end
|
||||
# end longjun
|
||||
|
||||
def update_contests(budget, deadline, name, description=nil)
|
||||
if(User.current.id == self.author_id)
|
||||
self.name = name
|
||||
self.budget = budget
|
||||
self.deadline = deadline
|
||||
self.description = description
|
||||
self.save
|
||||
end
|
||||
end
|
||||
|
||||
def delete_contests
|
||||
unless self.nil?
|
||||
if User.current.id == self.author_id
|
||||
self.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Closes open and locked project versions that are completed
|
||||
def close_completed_versions_contest
|
||||
Version.transaction do
|
||||
versions.where(:status => %w(open locked)).all.each do |version|
|
||||
if version.completed?
|
||||
version.update_attribute(:status, 'closed')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def set_commit(commit)
|
||||
self.update_attribute(:commit, commit)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_user
|
||||
errors.add :author_id, :invalid if author.nil? || !author.active?
|
||||
end
|
||||
|
||||
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.author_id)
|
||||
end
|
||||
|
||||
def validate_contest_manager(user_id)
|
||||
unless user_id.nil?
|
||||
if self.author_id == user_id
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
class Contest < ActiveRecord::Base
|
||||
attr_accessible :description, :invite_code, :invite_code_halt, :is_delete, :is_public, :name, :user_id, :visits
|
||||
|
||||
include ContestsHelper
|
||||
|
||||
belongs_to :user
|
||||
has_many :contest_members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
|
||||
has_many :memberships, :class_name => 'ContestMember'
|
||||
has_many :member_principals, :class_name => 'ContestMember',
|
||||
:include => :principal,
|
||||
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
|
||||
has_many :principals, :through => :member_principals, :source => :principal
|
||||
has_many :users, :through => :members
|
||||
has_many :contestants, :class_name => 'ContestantForContest', :source => :user
|
||||
has_many :works
|
||||
|
||||
has_many :news, :dependent => :destroy, :include => :author
|
||||
|
||||
has_many :contest_acts, :class_name => 'ContestActivity',:as =>:contest_act ,:dependent => :destroy
|
||||
has_many :contest_activities
|
||||
has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy
|
||||
|
||||
acts_as_attachable
|
||||
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]*$/
|
||||
|
||||
before_destroy :delete_all_members
|
||||
#after_create :act_as_contest_activity
|
||||
|
||||
scope :visible, lambda {|*args| where(Contest.where("is_delete =?", 0).visible_condition(args.shift || User.current, *args)) }
|
||||
|
||||
# 删除竞赛所有成员
|
||||
def delete_all_members
|
||||
if self.contest_members && self.contest_members.count > 0
|
||||
me, mr = ContestMember.table_name, ContestMemberRole.table_name
|
||||
connection.delete("DELETE FROM #{mr} WHERE #{mr}.contest_member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.contest_id = #{id})")
|
||||
ContestMember.delete_all(['contest_id = ?', id])
|
||||
end
|
||||
end
|
||||
|
||||
def self.visible_condition(user, options={})
|
||||
allowed_to_condition(user, :view_course, options)
|
||||
end
|
||||
|
||||
def self.allowed_to_condition(user, permission, options={})
|
||||
perm = Redmine::AccessControl.permission(permission)
|
||||
base_statement = ("#{Contest.table_name}.is_delete <> 1")
|
||||
if perm && perm.contest_module
|
||||
base_statement << " AND #{Contest.table_name}.id IN (SELECT em.contest_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.contest_module}')"
|
||||
end
|
||||
|
||||
if options[:contest]
|
||||
contest_statement = "#{Contest.table_name}.id = #{options[:contest].id}"
|
||||
contest_statement << " OR (#{Contest.table_name}.lft > #{options[:contest].lft} AND #{Contest.table_name}.rgt < #{options[:contest].rgt})" if options[:with_subcontests]
|
||||
base_statement = "(#{contest_statement}) AND (#{base_statement})"
|
||||
end
|
||||
|
||||
if user.admin?
|
||||
base_statement
|
||||
else
|
||||
statement_by_role = {}
|
||||
unless options[:contest_member]
|
||||
role = user.logged? ? Role.non_member : Role.anonymous
|
||||
if role.allowed_to?(permission)
|
||||
statement_by_role[role] = "#{Contest.table_name}.is_public = #{connection.quoted_true}"
|
||||
end
|
||||
end
|
||||
if user.logged?
|
||||
user.contests_by_role.each do |role, contests|
|
||||
if role.allowed_to?(permission) && contests.any?
|
||||
statement_by_role[role] = "#{Contest.table_name}.id IN (#{contests.collect(&:id).join(',')})"
|
||||
end
|
||||
end
|
||||
end
|
||||
if statement_by_role.empty?
|
||||
"1=0"
|
||||
else
|
||||
if block_given?
|
||||
statement_by_role.each do |role, statement|
|
||||
if s = yield(role, user)
|
||||
statement_by_role[role] = "(#{statement} AND (#{s}))"
|
||||
end
|
||||
end
|
||||
end
|
||||
"((#{base_statement}) AND (#{statement_by_role.values.join(' OR ')}))"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 竞赛动态公共表记录
|
||||
def act_as_contest_activity
|
||||
self.contest_acts << ContestActivity.new(:user_id => self.user_id,:contest_id => self.id)
|
||||
end
|
||||
|
||||
# 延迟生成邀请码
|
||||
def invite_code
|
||||
return generate_invite_code
|
||||
end
|
||||
|
||||
# 生成邀请码
|
||||
# 如果已有改邀请码,则重新生成
|
||||
CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z)
|
||||
def generate_invite_code
|
||||
code = read_attribute(:invite_code)
|
||||
if !code || code.size < 4
|
||||
code = CODES.sample(4).join
|
||||
return generate_invite_code if Project.where(invite_code: code).present?
|
||||
update_attribute(:invite_code, code)
|
||||
end
|
||||
code
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
class ContestActivity < ActiveRecord::Base
|
||||
attr_accessible :contest_act_id, :contest_act_type, :user_id, :contest_id
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :contest
|
||||
belongs_to :contest_act ,:polymorphic => true
|
||||
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
|
||||
after_create :add_user_activity
|
||||
before_destroy :destroy_user_activity
|
||||
|
||||
#在个人动态里面增加当前动态
|
||||
def add_user_activity
|
||||
user_activity = UserActivity.where("act_type = '#{self.contest_act_type.to_s}' and act_id = '#{self.contest_act_id}'").first
|
||||
if user_activity
|
||||
user_activity.save
|
||||
else
|
||||
if self.contest_act_type == 'Message' && !self.contest_act.parent_id.nil?
|
||||
user_activity = UserActivity.where("act_type = 'Message' and act_id = #{self.contest_act.parent.id}").first
|
||||
user_activity.created_at = self.created_at
|
||||
user_activity.save
|
||||
else
|
||||
user_activity = UserActivity.new
|
||||
user_activity.act_id = self.contest_act_id
|
||||
user_activity.act_type = self.contest_act_type
|
||||
user_activity.container_type = "Contest"
|
||||
user_activity.container_id = self.contest_id
|
||||
user_activity.user_id = self.user_id
|
||||
user_activity.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_user_activity
|
||||
user_activity = UserActivity.where("act_type = '#{self.contest_act_type.to_s}' and act_id = '#{self.contest_act_id}'")
|
||||
user_activity.destroy_all
|
||||
end
|
||||
end
|
|
@ -0,0 +1,59 @@
|
|||
class ContestMember < ActiveRecord::Base
|
||||
attr_accessible :is_collect, :user_id, :contest_id
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :contest
|
||||
|
||||
belongs_to :principal, :foreign_key => 'user_id'
|
||||
has_many :contest_member_roles, :dependent => :destroy
|
||||
has_many :roles, :through => :contest_member_roles
|
||||
|
||||
validates_presence_of :principal
|
||||
validates_uniqueness_of :user_id, :scope => [:contest_id]
|
||||
#validate :validate_role
|
||||
|
||||
def deletable?
|
||||
user != contest.user
|
||||
end
|
||||
|
||||
def role
|
||||
end
|
||||
|
||||
def role=
|
||||
end
|
||||
|
||||
def name
|
||||
self.user.name
|
||||
end
|
||||
|
||||
# alias :base_role_ids= :role_ids=
|
||||
# def role_ids=(arg)
|
||||
# ids = (arg || []).collect(&:to_i) - [0]
|
||||
#
|
||||
# new_role_ids = ids - role_ids
|
||||
# if (new_role_ids.include?(14) || new_role_ids.include?(13)) && role_ids.include?(15)
|
||||
# contest_member_roles.where("role_id = 15").first.update_column('is_current', 0)
|
||||
# end
|
||||
# # Add new roles
|
||||
# if new_role_ids.include?(14) && new_role_ids.include?(13)
|
||||
# contest_member_roles << ContestMemberRole.new(:role_id => 14)
|
||||
# contest_member_roles << ContestMemberRole.new(:role_id => 15, :is_current => 0)
|
||||
# elsif new_role_ids.include?(13) && new_role_ids.include?(15)
|
||||
# contest_member_roles << ContestMemberRole.new(:role_id => 13)
|
||||
# contest_member_roles << ContestMemberRole.new(:role_id => 15, :is_current => 0)
|
||||
# else
|
||||
# new_role_ids.each {|id| contest_member_roles << ContestMemberRole.new(:role_id => id) }
|
||||
# end
|
||||
# # Remove roles (Rails' #role_ids= will not trigger MemberRole#on_destroy)
|
||||
# member_roles_to_destroy = contest_member_roles.select {|mr| !ids.include?(mr.role_id)}
|
||||
# if member_roles_to_destroy.any?
|
||||
# member_roles_to_destroy.each(&:destroy)
|
||||
# end
|
||||
# end
|
||||
|
||||
protected
|
||||
|
||||
def validate_role
|
||||
errors.add_on_empty :role if contest_member_roles.empty? && roles.empty?
|
||||
end
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
class ContestMemberRole < ActiveRecord::Base
|
||||
attr_accessible :role_id, :contest_member_id, :is_current
|
||||
|
||||
belongs_to :contest_member
|
||||
belongs_to :role
|
||||
|
||||
#after_destroy :remove_member_if_empty
|
||||
|
||||
validates_presence_of :role
|
||||
#validate :validate_role_member
|
||||
|
||||
def validate_role_member
|
||||
errors.add :role_id, :invalid if role && !role.member?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_member_if_empty
|
||||
if contest_member.roles.empty?
|
||||
contest_member.destroy
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,20 @@
|
|||
class ContestMessage < ActiveRecord::Base
|
||||
attr_accessible :content, :contest_message_id, :contest_message_type, :status, :viewed, :user_id, :contest_id
|
||||
|
||||
belongs_to :contest_message ,:polymorphic => true
|
||||
belongs_to :user
|
||||
belongs_to :contest
|
||||
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
|
||||
|
||||
validates :user_id, presence: true
|
||||
validates :contest_id, presence: true
|
||||
validates :contest_message_id, presence: true
|
||||
validates :contest_message_type, presence: true
|
||||
after_create :add_user_message
|
||||
|
||||
def add_user_message
|
||||
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? && self.status != 9
|
||||
self.message_alls << MessageAll.new(:user_id => self.user_id)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +0,0 @@
|
|||
class ContestNotification < ActiveRecord::Base
|
||||
attr_accessible :content, :title
|
||||
validates :title, length: {maximum: 30}
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class ContestantForContest < ActiveRecord::Base
|
||||
belongs_to :contest
|
||||
attr_accessible :student_id, :contest_id
|
||||
|
||||
belongs_to :contestants, :class_name => 'User', :foreign_key => :student_id
|
||||
validates_presence_of :contest_id, :student_id
|
||||
validates_uniqueness_of :student_id, :scope => :contest_id
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
class ContestantWork < ActiveRecord::Base
|
||||
belongs_to :work
|
||||
belongs_to :user
|
||||
belongs_to :project
|
||||
attr_accessible :commit_time, :description, :is_delete, :name, :work_score, :work_status, :work_id, :user_id, :project_id
|
||||
|
||||
has_many :contestant_work_projects, :dependent => :destroy
|
||||
has_many :contestant_work_scores, :dependent => :destroy
|
||||
has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy
|
||||
has_many :attachments, :dependent => :destroy
|
||||
|
||||
scope :has_committed, lambda{where("work_status != 0 and work_status != 3")}
|
||||
scope :no_copy, lambda{where("work_status != 3")}
|
||||
|
||||
after_create :act_as_message
|
||||
acts_as_attachable
|
||||
|
||||
def act_as_message
|
||||
if self.work_status != 0 && self.created_at > self.work.end_time + 1
|
||||
self.contest_messages << ContestMessage.new(:user_id => self.user_id, :contest_id => self.work.contest_id, :viewed => false, :status => false)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class ContestantWorkProject < ActiveRecord::Base
|
||||
belongs_to :contest
|
||||
belongs_to :work
|
||||
belongs_to :contestant_work
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
attr_accessible :is_leader, :contest_id, :work_id, :contestant_work_id, :project_id, :user_id
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class ContestantWorkScore < ActiveRecord::Base
|
||||
belongs_to :contestant_work
|
||||
belongs_to :user
|
||||
attr_accessible :comment, :reviewer_role, :score, :contestant_work_id, :user_id
|
||||
end
|
|
@ -1,53 +0,0 @@
|
|||
class ContestingProject < ActiveRecord::Base
|
||||
attr_accessible :contest_id, :description, :project_id, :user_id, :reward
|
||||
|
||||
belongs_to :contest
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
|
||||
DESCRIPTION_LENGTH_LIMIT = 500
|
||||
validates :description, length: {maximum:DESCRIPTION_LENGTH_LIMIT }
|
||||
validates :user_id, presence: true
|
||||
validates :contest_id, presence: true, uniqueness: {scope: :project_id}
|
||||
validates :project_id, presence: true
|
||||
|
||||
validate :validate_user
|
||||
validate :validate_contest
|
||||
validate :validate_project
|
||||
|
||||
def self.create_contesting(contest_id, project_id, description = nil)
|
||||
self.create(:user_id => User.current.id, :contest_id => contest_id,
|
||||
:project_id => project_id, :description => description)
|
||||
end
|
||||
|
||||
|
||||
def update_reward(which)
|
||||
self.update_attribute(:reward,which)
|
||||
end
|
||||
|
||||
def get_reward
|
||||
self.reward
|
||||
end
|
||||
|
||||
def cancel_contesting
|
||||
unless self.nil?
|
||||
if User.current.id == self.user_id
|
||||
self.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_user
|
||||
errors.add :user_id, :invalid if user.nil? || !user.active?
|
||||
end
|
||||
|
||||
def validate_contest
|
||||
errors.add :contest_id, :invalid if contest.nil?
|
||||
end
|
||||
|
||||
def validate_project
|
||||
errors.add :project_id, :invalid if project.nil?
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
class ContestingSoftapplication < ActiveRecord::Base
|
||||
attr_accessible :contest_id, :description, :softapplication_id, :user_id
|
||||
|
||||
belongs_to :contest
|
||||
belongs_to :softapplication, :dependent => :destroy
|
||||
belongs_to :user
|
||||
|
||||
|
||||
def self.create_softapplication_contesting(contest_id, softapplication_id, description = nil)
|
||||
self.create(:user_id => User.current.id, :contest_id => contest_id,
|
||||
:softapplication_id => softapplication_id, :description => description)
|
||||
end
|
||||
|
||||
def self.create_work_contesting(contest_id, softapplication_id)
|
||||
self.create(:user_id => User.current.id, :contest_id => contest_id,
|
||||
:softapplication_id => softapplication_id)
|
||||
end
|
||||
|
||||
def update_reward(which)
|
||||
self.update_attribute(:reward,which)
|
||||
end
|
||||
|
||||
def get_reward
|
||||
self.reward
|
||||
end
|
||||
|
||||
end
|
|
@ -1,59 +0,0 @@
|
|||
class Contestnotification < ActiveRecord::Base
|
||||
#attr_accessible :author_id, :notificationcomments_count, :contest_id, :description, :summary, :title
|
||||
|
||||
include Redmine::SafeAttributes
|
||||
#Contestnotification::Notificationcomment
|
||||
belongs_to :contest
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
has_many :notificationcomments, as: :notificationcommented, :dependent => :delete_all, :order => "created_at"
|
||||
# fq
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
validates :title, length: {maximum: 60}, presence: true
|
||||
validates :description, presence: true
|
||||
validates :summary, length: {maximum: 255}
|
||||
|
||||
acts_as_attachable :delete_permission => :manage_contestnotifications
|
||||
acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :contest
|
||||
acts_as_event :url => Proc.new {|o| {:controller => 'contestnotifications', :action => 'show', :id => o.id}}
|
||||
acts_as_activity_provider :find_options => {:include => [:contest, :author]},
|
||||
:author_key => :author_id
|
||||
acts_as_watchable
|
||||
after_create :add_author_as_watcher
|
||||
after_create :act_as_activity
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
nil
|
||||
#includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_contestnotifications, *args))
|
||||
}
|
||||
|
||||
safe_attributes 'title', 'summary', 'description'
|
||||
|
||||
def visible?(user=User.current)
|
||||
!user.nil? && user.allowed_to?(:view_contestnotifications, contest)
|
||||
end
|
||||
|
||||
# Returns true if the news can be commented by user
|
||||
def notificationcommentable?(user=User.current)
|
||||
user.allowed_to?(:notificationcomment_contestnotifications, contest)
|
||||
end
|
||||
|
||||
def recipients
|
||||
#contest.users.select {|user| user.notify_about?(self)}.map(&:mail)
|
||||
end
|
||||
|
||||
# returns latest news for contests visible by user
|
||||
def self.latest(user = User.current, count = 5)
|
||||
visible(user).includes([:author, :contest]).order("#{Contestnotification.table_name}.created_at DESC").limit(count).all
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_author_as_watcher
|
||||
#Watcher.create(:watchable => self, :user => author)
|
||||
end
|
||||
## fq
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.author_id)
|
||||
end
|
||||
|
||||
end
|
|
@ -64,8 +64,11 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
has_many :principal_acts, :class_name => 'PrincipalActivity',:as =>:principal_act ,:dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# 竞赛动态
|
||||
has_many :contest_acts, :class_name => 'ContestActivity',:as =>:contest_act ,:dependent => :destroy
|
||||
# 消息关联
|
||||
has_many :course_messages, :class_name => 'CourseMessage',:as =>:course_message ,:dependent => :destroy
|
||||
has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy
|
||||
has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy
|
||||
|
||||
has_many :at_messages, as: :at_message, dependent: :destroy
|
||||
|
|
|
@ -40,11 +40,13 @@ class Message < ActiveRecord::Base
|
|||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
|
||||
# 竞赛动态
|
||||
has_many :contest_acts, :class_name => 'ContestActivity',:as =>:contest_act ,:dependent => :destroy
|
||||
# end
|
||||
# 课程/项目 消息
|
||||
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
|
||||
has_many :at_messages, as: :at_message, dependent: :destroy
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
|
|
|
@ -25,6 +25,7 @@ class News < ActiveRecord::Base
|
|||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
#added by nwb
|
||||
belongs_to :course,:touch => true
|
||||
belongs_to :contest,:touch => true
|
||||
belongs_to :org_subfield, :touch => true
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
has_many :comments, :as => :commented, :dependent => :destroy, :order => "created_on"
|
||||
|
@ -34,10 +35,13 @@ class News < ActiveRecord::Base
|
|||
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
|
||||
# 课程动态
|
||||
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
|
||||
# 竞赛动态
|
||||
has_many :contest_acts, :class_name => 'ContestActivity',:as =>:contest_act ,:dependent => :destroy
|
||||
# end
|
||||
# 课程/项目消息关联
|
||||
# 课程/项目/竞赛消息关联
|
||||
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
|
||||
|
@ -76,6 +80,10 @@ class News < ActiveRecord::Base
|
|||
scope :course_visible, lambda {|*args|
|
||||
includes(:course).where(Course.allowed_to_condition(args.shift || User.current, :view_course_news, *args))
|
||||
}
|
||||
|
||||
scope :contest_visible, lambda {|*args|
|
||||
includes(:contest).where(Contest.allowed_to_condition(args.shift || User.current, :view_contest_news, *args))
|
||||
}
|
||||
safe_attributes 'title', 'summary', 'description', 'sticky'
|
||||
|
||||
#动态的更新
|
||||
|
@ -157,6 +165,8 @@ class News < ActiveRecord::Base
|
|||
def act_as_course_activity
|
||||
if self.course
|
||||
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.course_id)
|
||||
elsif self.contest
|
||||
self.contest_acts << ContestActivity.new(:user_id => self.author_id,:contest_id => self.contest_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -226,6 +236,23 @@ class News < ActiveRecord::Base
|
|||
self.delay.contain_news_message(vs)
|
||||
end
|
||||
|
||||
elsif self.contest_id
|
||||
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,
|
||||
:contest_id => self.contest_id, :viewed => false}
|
||||
|
||||
if vs.size >= 30
|
||||
self.delay.contain_contst_news_message(vs)
|
||||
vs.clear
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless vs.empty?
|
||||
self.delay.contain_contst_news_message(vs)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -233,6 +260,10 @@ class News < ActiveRecord::Base
|
|||
CourseMessage.create(vs)
|
||||
end
|
||||
|
||||
def contain_contst_news_message(vs)
|
||||
ContestMessage.create(vs)
|
||||
end
|
||||
|
||||
# Time 2015-03-31 13:50:54
|
||||
# Author lizanle
|
||||
# Description 删除news后删除对应的资源
|
||||
|
|
|
@ -34,6 +34,10 @@ class Principal < ActiveRecord::Base
|
|||
has_many :course_groups, :through => :members
|
||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||
|
||||
has_many :contest_members, :foreign_key => 'user_id', :dependent => :destroy
|
||||
has_many :contestmemberships, :class_name => 'ContestMember', :foreign_key => 'user_id', :include => [:contest, :roles], :order => "#{Contest.table_name}.name"
|
||||
has_many :contests, :through => :contestmemberships
|
||||
|
||||
# Groups and active users
|
||||
scope :active, lambda { where(:status => STATUS_ACTIVE) }
|
||||
|
||||
|
@ -87,6 +91,16 @@ class Principal < ActiveRecord::Base
|
|||
end
|
||||
}
|
||||
|
||||
scope :not_member_of_contest, lambda {|contests|
|
||||
contests = [contests] unless contests.is_a?(Array)
|
||||
if contests.empty?
|
||||
where("1=0")
|
||||
else
|
||||
ids = contests.map(&:id)
|
||||
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{ContestMember.table_name} WHERE contest_id IN (?))", ids)
|
||||
end
|
||||
}
|
||||
|
||||
scope :not_member_of_org, lambda {|org|
|
||||
orgs = [org] unless org.is_a?(Array)
|
||||
if orgs.empty?
|
||||
|
@ -157,6 +171,14 @@ class Principal < ActiveRecord::Base
|
|||
return projects
|
||||
end
|
||||
|
||||
#收藏的竞赛
|
||||
def favorite_contests
|
||||
members = ContestMember.where(:user_id => self.id, :is_collect => true)
|
||||
contest_ids = members.empty? ? "(-1)" : "(" + members.map{|member| member.contest_id}.join(",") + ")"
|
||||
contests = Contest.where("id in #{contest_ids}")
|
||||
return contests
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Make sure we don't try to insert NULL values (see #4632)
|
||||
|
|
|
@ -57,6 +57,8 @@ class Role < ActiveRecord::Base
|
|||
has_many :members, :through => :member_roles
|
||||
has_many :org_member_roles, :dependent => :destroy
|
||||
has_many :org_members,:through => :org_member_roles
|
||||
has_many :contest_member_roles, :dependent => :destroy
|
||||
has_many :contest_members, :through => :contest_member_roles
|
||||
acts_as_list
|
||||
|
||||
serialize :permissions, ::Role::PermissionsAttributeCoder
|
||||
|
|
|
@ -130,7 +130,6 @@ class User < Principal
|
|||
belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang
|
||||
## added by xianbo for delete
|
||||
# has_many :biding_projects, :dependent => :destroy
|
||||
has_many :contesting_projects, :dependent => :destroy
|
||||
belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy
|
||||
##ended by xianbo
|
||||
|
||||
|
@ -138,12 +137,12 @@ class User < Principal
|
|||
has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy
|
||||
has_many :journals_messages, :class_name => 'JournalsForMessage', :foreign_key => "user_id", :dependent => :destroy
|
||||
# has_many :bids, :foreign_key => 'author_id', :dependent => :destroy
|
||||
has_many :contests, :foreign_key => 'author_id', :dependent => :destroy
|
||||
has_many :softapplications, :foreign_key => 'user_id', :dependent => :destroy
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :journal_replies, :dependent => :destroy
|
||||
has_many :activities, :dependent => :destroy
|
||||
has_many :students_for_courses
|
||||
has_many :contestant_for_contests
|
||||
#has_many :courses, :through => :students_for_courses, :source => :project
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
has_many :principal_acts, :class_name => 'PrincipalActivity',:as =>:principal_act ,:dependent => :destroy
|
||||
|
@ -151,11 +150,8 @@ class User < Principal
|
|||
has_many :course_attachments , :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Course'"
|
||||
####
|
||||
# added by bai
|
||||
has_many :join_in_contests, :dependent => :destroy
|
||||
has_many :news, :foreign_key => 'author_id'
|
||||
has_many :contestnotification, :foreign_key => 'author_id'
|
||||
has_many :comments, :foreign_key => 'author_id'
|
||||
has_many :notificationcomments, :foreign_key => 'author_id'
|
||||
has_many :wiki_contents, :foreign_key => 'author_id'
|
||||
has_many :journals
|
||||
has_many :messages, :foreign_key => 'author_id'
|
||||
|
@ -501,6 +497,7 @@ class User < Principal
|
|||
@name = nil
|
||||
@projects_by_role = nil
|
||||
@courses_by_role = nil
|
||||
@contests_by_role = nil
|
||||
@membership_by_project_id = nil
|
||||
base_reload(*args)
|
||||
end
|
||||
|
@ -884,6 +881,11 @@ class User < Principal
|
|||
courses.to_a.include?(course)
|
||||
end
|
||||
|
||||
def member_of_contest?(contest)
|
||||
contest.contest_members.where(:user_id => self.id).count > 0
|
||||
#contests.to_a.include?(contest)
|
||||
end
|
||||
|
||||
def member_of_org?(org)
|
||||
if !self.logged?
|
||||
return false
|
||||
|
@ -912,6 +914,46 @@ class User < Principal
|
|||
false
|
||||
end
|
||||
end
|
||||
|
||||
# 判断是否是竞赛的主办人
|
||||
def admin_of_contest?(contest)
|
||||
if ContestMember.where("user_id =? and contest_id =?", self.id, contest.id).count == 0
|
||||
return false
|
||||
end
|
||||
member_role = ContestMember.where("user_id =? and contest_id =?", self.id, contest.id)[0].contest_member_roles.where(:is_current => true)[0]
|
||||
unless member_role.nil?
|
||||
member_role.role.name == 'ContestManager' ? true : false
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
# 判断是否是竞赛的评委
|
||||
def judge_of_contest?(contest)
|
||||
if ContestMember.where("user_id =? and contest_id =?", self.id, contest.id).count == 0
|
||||
return false
|
||||
end
|
||||
member_role = ContestMember.where("user_id =? and contest_id =?", self.id, contest.id)[0].contest_member_roles.where(:is_current => true)[0]
|
||||
unless member_role.nil?
|
||||
member_role.role.name == 'Judge' ? true : false
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
# 判断是否是竞赛的参赛者
|
||||
def contestant_of_contest?(contest)
|
||||
if ContestMember.where("user_id =? and contest_id =?", self.id, contest.id).count == 0
|
||||
return false
|
||||
end
|
||||
member_role = ContestMember.where("user_id =? and contest_id =?", self.id, contest.id)[0].contest_member_roles.where(:is_current => true)[0]
|
||||
unless member_role.nil?
|
||||
member_role.role.name == 'Contestant' ? true : false
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def member_of_course_group?(course_group)
|
||||
course_groups.to_a.include?(course_group)
|
||||
end
|
||||
|
@ -954,6 +996,26 @@ class User < Principal
|
|||
|
||||
@courses_by_role
|
||||
end
|
||||
|
||||
# 竞赛的角色权限
|
||||
def contests_by_role
|
||||
return @contests_by_role if @contests_by_role
|
||||
|
||||
@contests_by_role = Hash.new([])
|
||||
contestmemberships.each do |membership|
|
||||
if membership.contest
|
||||
membership.roles.each do |role|
|
||||
@contests_by_role[role] = [] unless @contests_by_role.key?(role)
|
||||
@contests_by_role[role] << membership.contest
|
||||
end
|
||||
end
|
||||
end
|
||||
@contests_by_role.each do |role, contests|
|
||||
contests.uniq!
|
||||
end
|
||||
|
||||
@contests_by_role
|
||||
end
|
||||
# Returns true if user is arg or belongs to arg
|
||||
def is_or_belongs_to?(arg)
|
||||
if arg.is_a?(User)
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
class Work < ActiveRecord::Base
|
||||
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_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
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
has_one :praise_tread_cache, as: :object, dependent: :destroy
|
||||
# 竞赛动态
|
||||
has_many :contest_acts, :class_name => 'ContestActivity',:as =>:contest_act ,:dependent => :destroy
|
||||
# 竞赛消息
|
||||
has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy
|
||||
acts_as_attachable
|
||||
|
||||
after_create :act_as_contest_message
|
||||
after_update :update_activity
|
||||
after_save :act_as_contest_activity
|
||||
#after_destroy :delete_kindeditor_assets
|
||||
|
||||
def is_group_work?
|
||||
self.work_type == 3 && self.work_detail_group
|
||||
end
|
||||
|
||||
###添加回复
|
||||
def self.add_work_jour(user, notes, id, root_id, options = {})
|
||||
homework = Work.find(id)
|
||||
if options.count == 0
|
||||
jfm = homework.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0, :root_id => root_id)
|
||||
else
|
||||
jfm = homework.journals_for_messages.build(options)
|
||||
end
|
||||
jfm.save
|
||||
jfm
|
||||
end
|
||||
|
||||
def act_as_contest_activity
|
||||
if self.contest
|
||||
if self.work_status == 0
|
||||
self.contest_acts.destroy_all
|
||||
else
|
||||
if self.contest_acts.size == 0
|
||||
self.contest_acts << ContestActivity.new(:user_id => self.user_id,:contest_id => self.contest_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#动态的更新
|
||||
def update_activity
|
||||
update_contest_activity(self.class, self.id)
|
||||
update_user_activity(self.class, self.id)
|
||||
end
|
||||
|
||||
def act_as_contest_message
|
||||
if self.contest
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class WorkDetailGroup < ActiveRecord::Base
|
||||
belongs_to :work
|
||||
attr_accessible :base_on_project, :max_num, :min_num, :work_id
|
||||
end
|
|
@ -0,0 +1,45 @@
|
|||
#coding=utf-8
|
||||
class ContestsService
|
||||
include ApplicationHelper
|
||||
include ContestsHelper
|
||||
include ApiHelper
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
#多个角色加入竞赛
|
||||
def join_contest_roles params,current_user
|
||||
contest = Contest.find_by_invite_code(params[:invite_code]) if params[:invite_code]
|
||||
go_contestgroup_flag = 0
|
||||
contest_id = 0
|
||||
|
||||
@state = 10
|
||||
if contest
|
||||
if contest[:is_delete] == 1
|
||||
@state = 11
|
||||
elsif contest[:invite_code_halt] == 1
|
||||
@state = 14
|
||||
else
|
||||
if current_user.member_of_contest?(contest) #如果已经是成员
|
||||
@state = 3
|
||||
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
|
||||
@state = 7
|
||||
else
|
||||
AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_str, :status => 0)
|
||||
@state = 6
|
||||
end
|
||||
else
|
||||
@state = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@state = 4
|
||||
end
|
||||
{:state => @state, :contest => contest, :go_contestgroup_flag => go_contestgroup_flag, :contest_id => contest_id}
|
||||
end
|
||||
end
|
|
@ -2,6 +2,8 @@
|
|||
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% elsif @project %>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% elsif @contest %>
|
||||
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id => @user_activity_id}) %>");
|
||||
<% else %>
|
||||
$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% end %>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
$("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% elsif @news.course_id %>
|
||||
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% elsif @news.contest_id %>
|
||||
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id => @user_activity_id}) %>");
|
||||
<% elsif @news.org_subfield_id %>
|
||||
$("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_subfield_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% end %>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
$("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% elsif @news.course_id %>
|
||||
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% elsif @news.contest_id %>
|
||||
$("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id => @user_activity_id}) %>");
|
||||
<% elsif @news.org_subfield_id %>
|
||||
$("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_subfield_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<% if @contest %>
|
||||
var checked = $("#principals_for_new_member input:checked").size();
|
||||
if(checked > 0)
|
||||
{
|
||||
alert('翻页或搜索后将丢失当前选择的用户数据!');
|
||||
}
|
||||
$('#principals_for_new_member').html('<%= escape_javascript(find_user_not_in_current_contest_by_name(@contest)) %>');
|
||||
|
||||
<% end %>
|
||||
var collection = $("#principals_for_new_member").children("#principals").children("label");
|
||||
collection.css("text-overflow", "ellipsis");
|
||||
collection.css("white-space", "nowrap");
|
||||
collection.css("width", "200px");
|
||||
collection.css("overflow", "hidden");
|
||||
for(i = 0; i < collection.length; i++) { //增加悬浮显示
|
||||
var label = collection[i];
|
||||
var text = $(label).text();
|
||||
$(label).attr("title", text);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<%if @contest%>
|
||||
<% if @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("添加成功");
|
||||
<% end%>
|
||||
hideOnLoad();
|
||||
<%end%>
|
|
@ -0,0 +1,6 @@
|
|||
$('#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 %>");
|
||||
|
||||
hideOnLoad();
|
|
@ -0,0 +1,6 @@
|
|||
$('#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 %>");
|
||||
|
||||
hideOnLoad();
|
|
@ -0,0 +1,125 @@
|
|||
<% if @contestwork.work_detail_group %>
|
||||
<div id="popbox02">
|
||||
<div>
|
||||
<div class="relateText fl">请从<%= @contestwork.work_detail_group.base_on_project ? '项目成员':'竞赛成员' %>中添加小组成员</div>
|
||||
</div>
|
||||
<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="clickCanel();"></a></div>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<form class="resourcesSearchBox">
|
||||
<input type="text" name="serach" placeholder="输入关键字搜索" class="searchResourcePopup" />
|
||||
</form>
|
||||
</div>
|
||||
<ul class="addMemberC fl" id="all_students_list"></ul>
|
||||
<div class="rightArrow"><img src="/images/course/right-arrow.png" width="16" height="30" /></div>
|
||||
<ul class="addMemberC fr" id="choose_students_list">
|
||||
<li id="choose_student_<%=User.current.id %>"><%=User.current.show_name %>
|
||||
<% unless User.current.user_extensions.student_id == "" %>
|
||||
(<%=User.current.user_extensions.student_id %>)
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="cl"></div>
|
||||
<div class="courseSendCancel mr15" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickCanel();">取消</a></div>
|
||||
<div class="courseSendSubmit" style="float:right;"><a href="javascript:void(0);" class="sendSourceText" onclick="clickOK()">确定</a></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var lastSearchCondition = '';
|
||||
var count = 0;
|
||||
function search_stus(e){
|
||||
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastSearchCondition = $(e.target).val().trim();
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'contestant_works', :action => 'search_contest_students') %>'+'?name='+ e.target.value+'&work='+<%=@contestwork.id %>,
|
||||
type:'get'
|
||||
});
|
||||
}
|
||||
|
||||
function throttle(method,context,e){
|
||||
clearTimeout(method.tId);
|
||||
method.tId=setTimeout(function(){
|
||||
method.call(context,e);
|
||||
},500);
|
||||
}
|
||||
|
||||
//查询
|
||||
$("input[name='serach']").on('input', function (e) {
|
||||
throttle(search_stus,window,e);
|
||||
});
|
||||
|
||||
function clickOK() {
|
||||
var str="";
|
||||
var show = "合作成员:";
|
||||
var lists = $("#choose_students_list li");
|
||||
if(lists.length > 0) {
|
||||
for(var i=0; i<lists.length; i++) {
|
||||
var id = $(lists[i]).attr("id").replace(/[^0-9]/ig,"");
|
||||
str += id;
|
||||
var show_name = $(lists[i]).html();
|
||||
var index = show_name.indexOf("(");
|
||||
if (index != -1) {
|
||||
var name = show_name.substring(0,show_name.indexOf("("));
|
||||
} else {
|
||||
var name = show_name;
|
||||
}
|
||||
show += name;
|
||||
if (i == 0) {
|
||||
show += "(组长)";
|
||||
}
|
||||
if (i != lists.length -1) {
|
||||
str += ",";
|
||||
show += "、";
|
||||
}
|
||||
}
|
||||
$("#group_member_ids").val(str);
|
||||
}
|
||||
hideModal("#popbox02");
|
||||
$("#group_members_show").show().html(show);
|
||||
}
|
||||
|
||||
function delete_student(id) {
|
||||
$("#choose_student_"+id).remove();
|
||||
$("#student_"+id).one("click",function choose_student() {
|
||||
$("#choose_students_list").append("<li id='choose_student_"+id+"' onclick='delete_student("+id+");'>"+$("#student_"+id).html()+"</li>");
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'contestant_works', :action => 'search_contest_students') %>'+'?work='+<%=@contestwork.id %>,
|
||||
type:'get'
|
||||
});
|
||||
var ids = $("#group_member_ids").val().split(',');
|
||||
if (ids.length > 1){
|
||||
for(var i=1; i<ids.length; i++) {
|
||||
if($("#choose_student_"+ids[i]).length == 0) {
|
||||
$.get(
|
||||
'/student_work/get_user_infor',
|
||||
{
|
||||
user_id: ids[i]
|
||||
},
|
||||
function (data) {
|
||||
if (data.valid) {
|
||||
var link = "<li id='choose_student_"+data.id+"' onclick='delete_student("+data.id+");'>"+data.name;
|
||||
if (data.student_id != "" ) {
|
||||
link += "("+data.student_id+")";
|
||||
}
|
||||
link += "</li>";
|
||||
$("#choose_students_list").append(link);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
|
@ -0,0 +1,9 @@
|
|||
<div class="syllabus_courses_box">
|
||||
<% @stundet_works.each_with_index do |student_work, i| %>
|
||||
<div class="syllabus_courses_list" id="student_work_<%= student_work.id%>" onclick="show_student_work('<%= contestant_work_path(student_work)%>');" style="cursor: default; background-color:#f6f6f6;">
|
||||
<%= render :partial => 'contest_evaluation_un_group_work', :locals => {:student_work => student_work} %>
|
||||
</div>
|
||||
<div id="about_hwork_<%= student_work.id %>" class="about_hwork"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
|
@ -0,0 +1,65 @@
|
|||
<div class="sy_courses_open f14 fontGrey3">
|
||||
<div>
|
||||
<span class="fl" style="width:280px;">
|
||||
<span class="hidden fl" style="max-width:220px;"><%= student_work.name %></span>
|
||||
<span class="fontGrey2 ml5 fl">
|
||||
<% if student_work.work_status %>
|
||||
<%= get_status student_work.work_status %>
|
||||
<% end %>
|
||||
</span>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<% if @contestwork.work_detail_group.base_on_project %>
|
||||
<div class="pr">
|
||||
<span class="fl fontGrey2">关联项目:</span>
|
||||
<div class="fl projectName">
|
||||
<% if student_work.project.status != 9 && (student_work.project.is_public || User.current.member_of?(student_work.project) || User.current.admin? || User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest)) %>
|
||||
<%= link_to student_work.project.name, project_path(student_work.project.id), :class => 'link-blue fl hidden', :style => "max-width:550px;", :title => "项目名称", :target => "_blank" %>
|
||||
<% elsif student_work.project.status != 9 %>
|
||||
<span class="fontBlue fr hidden" style="max-width:550px;" title="该项目是私有的"><%= student_work.project.name %></span>
|
||||
<% else %>
|
||||
<span class="fontGrey2 fr hidden" style="max-width:550px;" title="该项目已删除"><%= student_work.project.name %>(已删除)</span><% end %>
|
||||
<% project = student_work.project %>
|
||||
<div class="score-tip none tl f12" style="width:300px; top:-48px; right:-372px;">
|
||||
<em style="bottom:45px;"></em>
|
||||
<font style="bottom:45px;"></font>
|
||||
|
||||
<p class="fb break_word mw280"><%= project.name %><%= project.status == 9 ? "(已删除)" : ""%></p>
|
||||
|
||||
<p class="mb10">
|
||||
<span class="mr15">创建者:<%= project.creater %></span><span>成员数量:<%= project.members.count %></span></p>
|
||||
<% project_score = project.project_score %>
|
||||
<p>项目综合得分:<%= project.status == 9 ? 0 : static_project_score(project_score).to_i %></p>
|
||||
|
||||
<% if project.status != 9 %>
|
||||
<p>= 代码提交得分 + issue得分 + 资源得分 + 帖子得分</p>
|
||||
|
||||
<p>= <%= (project_score.changeset_num||0) * 4 %>
|
||||
+ <%= project_score.issue_num * 4 + project_score.issue_journal_num %> + <%= project_score.attach_num * 5 %>
|
||||
+ <%= project_score.board_num * 2 + project_score.board_message_num + project_score.news_num %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="fl sy_p_grey" style="margin-left: 0px;">
|
||||
<span class="fl" style="width:180px;">提交时间:<%= format_date(student_work.commit_time) %></span>
|
||||
<span class="fl" style="width:105px; text-align: center">人数:<%=student_work.contestant_work_projects.count %>人</span>
|
||||
|
||||
<div class="flex-container fl" style="width:400px;">
|
||||
<div class="flex-cell">评委评分:--</div>
|
||||
<div class="flex-cell">最终成绩:--</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<script>
|
||||
$(".projectName").mouseenter(function () {
|
||||
$(this).children().next().show();
|
||||
}).mouseleave(function () {
|
||||
$(this).children().next().hide();
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,42 @@
|
|||
<table class="hwork-table-wrap" id="homework_table">
|
||||
<%# if @homework.homework_type == 1 %>
|
||||
<%#= render :partial => 'evaluation_un_common_title' %>
|
||||
<%# elsif @homework.homework_type == 2 %>
|
||||
<%#= render :partial => 'evaluation_un_pro_title' %>
|
||||
<%# elsif @homework.homework_type == 3 %>
|
||||
<%#= render :partial => 'evaluation_un_group_title' %>
|
||||
<%# else %>
|
||||
<tr class="b_grey hworkH30">
|
||||
<th class="hworkList40 hworkH30 pl5 pr5">序号</th>
|
||||
<th class="hworkList50"> </th>
|
||||
<th class="hworkList190 pl5 pr5 hide-text">
|
||||
姓名
|
||||
</th>
|
||||
|
||||
<th class="hworkList80 pl5 pr5 hide-text">
|
||||
</th>
|
||||
|
||||
<th class="hworkList130">
|
||||
状态
|
||||
</th>
|
||||
<th class="hworkList100">
|
||||
评委评分
|
||||
</th>
|
||||
|
||||
<th class="hworkList100">
|
||||
最终成绩
|
||||
</th>
|
||||
</tr>
|
||||
<%# end %>
|
||||
<% @stundet_works.each_with_index do |student_work, i| %>
|
||||
<% score_open = true %>
|
||||
<a name="<%= student_work.id%>"></a>
|
||||
<%= render :partial => "contest_evaluation_un_work", :locals => {:student_work => student_work, :index => i, :score_open => score_open} %>
|
||||
<tr>
|
||||
<td colspan="12">
|
||||
<div id="about_hwork_<%= student_work.id %>" class="about_hwork">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
|
@ -0,0 +1,37 @@
|
|||
<tr class="hworkListRow" id="student_work_<%= student_work.id%>">
|
||||
<td class="hworkList40 pl5 pr5" id="work_num_<%=student_work.id %>"><%=index + 1 %></td>
|
||||
<td class="hworkPortrait pr10 float-none">
|
||||
<%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40",:style => "display:block;"),user_path(student_work.user), :target => '_blank') %>
|
||||
</td>
|
||||
<td class="hworkStName190 pr10 float-none hidden" title="<%= student_work.user.show_name%>" style="cursor:pointer;">
|
||||
<%= link_to student_work.user.show_name ,user_path(student_work.user), :target => '_blank' %>
|
||||
</td>
|
||||
|
||||
<td class="hworkList80 student_work_<%= student_work.id%>" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">
|
||||
</td>
|
||||
|
||||
<td class="hworkList130 c_grey student_work_<%= student_work.id%>" onclick="show_student_work('<%= contestant_work_path(student_work)%>');" style="cursor: pointer;">
|
||||
<% if student_work.work_status%>
|
||||
<%=get_status student_work.work_status %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="hworkList100 <%= score_color nil %>">
|
||||
--
|
||||
</td>
|
||||
|
||||
<td class="hworkList100 <%= score_color nil %> student_final_scor_info pr">
|
||||
--
|
||||
</td>
|
||||
<td><div style="position:relative;"><div class="hworkTip" style="display: none" id="work_click_<%= student_work.id%>"><em></em><span></span><font class="fontGrey2">点击查看详情</font></div></div></td>
|
||||
</tr>
|
||||
<%# end %>
|
||||
<script type="text/javascript">
|
||||
$(".student_work_<%= student_work.id%>").mouseenter(function(){
|
||||
if($("#about_hwork_<%= student_work.id%>").html().trim() == "") {
|
||||
$("#work_click_<%= student_work.id%>").show();
|
||||
}
|
||||
}).mouseleave(function(){
|
||||
$("#work_click_<%= student_work.id%>").hide();
|
||||
}).mouse;
|
||||
</script>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<% attachments.each_with_index do |attachment,i| %>
|
||||
<div id="attachment_<%= attachment.id%>">
|
||||
<span class="fl">
|
||||
<span title="点击可下载">
|
||||
<%= link_to_short_attachment attachment,:length=> 58, :class => 'hidden link_file_a fl newsBlue mw360', :download => true -%>
|
||||
</span>
|
||||
</span>
|
||||
<% if attachment.id && User.current == attachment.author && (attachment.attachtype == 7 || @contestwork.end_time >= Date.today) %>
|
||||
<%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) %>
|
||||
<% end %>
|
||||
<span class="postAttSize">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||
<span class="author">
|
||||
<%= format_time(attachment.created_on) %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end -%>
|
|
@ -0,0 +1,56 @@
|
|||
<div class="mt10">
|
||||
<span id="attachments_fields" class="attachments_fields">
|
||||
<% if defined?(container) && container && container.saved_attachments %>
|
||||
<% container.attachments.each_with_index do |attachment, i| %>
|
||||
<span id="attachments_p<%= i %>">
|
||||
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%>
|
||||
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
|
||||
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
|
||||
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
|
||||
<%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
|
||||
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
<% container.saved_attachments.each_with_index do |attachment, i| %>
|
||||
<span id="attachments_p<%= i %>">
|
||||
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
|
||||
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
|
||||
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
|
||||
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
|
||||
<%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
|
||||
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
<%= file_field_tag 'attachments[dummy][file]',
|
||||
:id => '_file',
|
||||
:class => ie8? ? '' : 'file_selector',
|
||||
:multiple => true,
|
||||
:onchange => 'addInputFiles(this);',
|
||||
:style => ie8? ? '' : 'display:none',
|
||||
:data => {
|
||||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||
:upload_path => uploads_path(:format => 'js',:project =>nil),
|
||||
:description_placeholder => l(:label_optional_description),
|
||||
:field_is_public => l(:field_is_public),
|
||||
:are_you_sure => l(:text_are_you_sure),
|
||||
:file_count => l(:label_file_count),
|
||||
:lebel_file_uploding => l(:lebel_file_uploding),
|
||||
:delete_all_files => l(:text_are_you_sure_all)
|
||||
} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="mt5 fl">
|
||||
<!-- , user_import_resource_user_path(User.current.id,:homework_id=>container.id) -->
|
||||
<a href="javascript:void(0);" id="upload_file_local" class="AnnexBtn fl mt3 mr15" onclick="$('#_file').click();" title="请选择文件上传">上传附件</a>
|
||||
</div>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag 'attachments' %>
|
||||
<% end %>
|
|
@ -0,0 +1,55 @@
|
|||
<div class="fl pr" style="padding-bottom:10px; width:720px;">
|
||||
<span class="c_dark f14 fb fl mr10">
|
||||
作品
|
||||
<font class="f12 c_red">
|
||||
<% if @contestwork.work_type == 3 %>
|
||||
<% member_count = @contestwork.contestant_works.where("work_status != 0").count %>
|
||||
(<%= @student_work_count%>组<%=member_count %>人已交)
|
||||
<% else %>
|
||||
(<%= @student_work_count%>人已交)
|
||||
<% end %>
|
||||
</font>
|
||||
<%# my_work = @homework.student_works.where("user_id = #{User.current.id}").first %>
|
||||
<% 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 %>
|
||||
<%=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?%>
|
||||
<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?%>
|
||||
<% if @contestwork.work_type == 3 %>
|
||||
<span class="f12 c_red">组长已提交,组长还可修改</span>
|
||||
<% else %>
|
||||
<span class="f12 c_red">您已提交,您还可以修改</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
|
||||
<%# if !@is_teacher && !@is_judge && @contestwork.work_type == 3 && my_work && my_work.user == User.current && Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") %>
|
||||
<!--<div class="mt5 fr">-->
|
||||
<!--<a href="javascript:void(0);" class="memberBtn fl mt3" title="添加小组成员" onclick="add_or_delete_group_member();">合作成员</a>-->
|
||||
<!--</div>-->
|
||||
<%# end %>
|
||||
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="fl">
|
||||
<% if @contestwork.work_type != 3%>
|
||||
<%= render :partial => "contest_evaluation_un_title"%>
|
||||
<% else %>
|
||||
<%= render :partial => "contest_evaluation_un_group"%>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
// function add_or_delete_group_member() {
|
||||
// var html_value = "<%#= escape_javascript(render :partial => 'student_work/add_or_delete_member',:locals => {:homework=>@homework,:edit_mode => true}) %>";
|
||||
// pop_up_box(html_value, 530);
|
||||
// }
|
||||
</script>
|
|
@ -0,0 +1,24 @@
|
|||
<div id="popbox02">
|
||||
<div class="ni_con">
|
||||
<div><p align='center' style='margin-top: 35px'>您已提交过作品,请不要重复提交,如果想修改作品请点击编辑。</p></div>
|
||||
<div class="cl"></div>
|
||||
<div class="ni_btn mt10">
|
||||
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
|
||||
编 辑
|
||||
</a>
|
||||
<a href="javascript:" class="tijiao" onclick="clickCanel();" style="margin-bottom: 15px;margin-top:15px;" >
|
||||
取 消
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function clickOK() {
|
||||
window.location.href = '<%= edit_contestant_work_path(@work.id)%>';
|
||||
}
|
||||
function clickCanel() {
|
||||
hideModal('#popbox02');
|
||||
window.location.href = '<%= contestant_works_path(:work => @contestwork.id)%>';
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,63 @@
|
|||
<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>
|
||||
<div class="muban_popup_con clear ml30 mr30 mt10">
|
||||
<%= form_for('new_form',:url =>{:controller => 'contestant_works',:action => 'student_work_project',:work => @contestwork.id,:user_activity_id=>@user_activity_id,:hw_status =>@hw_status},:method => "post", :remote => true) do |f|%>
|
||||
<input type="text" name="project" placeholder="输入项目名称进行搜索" class="searchResourcePopup mb10" />
|
||||
<div class="cl"></div>
|
||||
<p id="no_search_result" class="c_red f14" style="width:320px;display: none">您当前尚未创建任何项目,请先创建项目再关联。</p>
|
||||
<ul id="search_project_list" class="maxHeight200"></ul>
|
||||
<p id="notes" class="c_red"></p>
|
||||
<a href="javascript:void(0);" class="sy_btn_blue fr" onclick="clickOK();">确定</a>
|
||||
<a href="javascript:void(0);" class="sy_btn_grey fr mr5" onclick="clickCanel();">取消</a>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var lastSearchCondition = '';
|
||||
var count = 0;
|
||||
function search_pros(e){
|
||||
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastSearchCondition = $(e.target).val().trim();
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'student_work', :action => 'search_user_projects') %>'+'?name='+ e.target.value,
|
||||
type:'get'
|
||||
});
|
||||
}
|
||||
|
||||
function throttle(method,context,e){
|
||||
clearTimeout(method.tId);
|
||||
method.tId=setTimeout(function(){
|
||||
method.call(context,e);
|
||||
},500);
|
||||
}
|
||||
|
||||
//查询项目
|
||||
$("input[name='project']").on('input', function (e) {
|
||||
throttle(search_pros,window,e);
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'student_work', :action => 'search_user_projects') %>'+'?first=1',
|
||||
type:'get'
|
||||
});
|
||||
});
|
||||
|
||||
function clickOK() {
|
||||
var radio = $("input[name='projectName']:checked");
|
||||
if(radio.length < 1) {
|
||||
$("#notes").html("请先选择一个项目");
|
||||
return false;
|
||||
} else {
|
||||
$("#muban_popup_box").find('form').submit();
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,49 @@
|
|||
<div class="syllabus_courses_box">
|
||||
<% projects.each do |project|%>
|
||||
<% allow_visit = project.status != 9 && (project.is_public || User.current.member_of?(project) || User.current.admin? || User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest)) %>
|
||||
<div class="syllabus_courses_list" style="cursor: default">
|
||||
<div class="sy_courses_open">
|
||||
<% projectUser = User.where("id=?",project.user_id).first %>
|
||||
<% is_change = project.status == 9 && projectUser == User.current && @contestwork.contestant_works.has_committed.where("user_id = #{User.current.id}").count == 1 %>
|
||||
<h3>
|
||||
<% if allow_visit %>
|
||||
<%= link_to "#{project.name}", project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%>
|
||||
<% elsif project.status != 9 %>
|
||||
<a href="javascript:void(0)" class="new_project_title fl" title="私有项目不可访问"><%=project.name %></a>
|
||||
<% else %>
|
||||
<a href="javascript:void(0)" onclick="alert_notice_box();" class="new_project_title fl" title="项目已删除"><%=project.name %></a>
|
||||
<% end %>
|
||||
</h3>
|
||||
<span class="<%= project.is_public? ? 'syllabus_class_open' : 'syllabus_class_private' %> fl ml10 mt3 syllabus_class_property"><%= project.is_public? ? '公开' : '私有' %></span>
|
||||
<%# if is_change %>
|
||||
<!--<a href="javascript:void(0)" onclick="alert_change_project();" class="btn_grey_mid mt-5 ml10 fr">更换项目</a>-->
|
||||
<%# end %>
|
||||
<%=link_to "<span class='fr grayTxt hidden mw150'>创建者:#{projectUser.show_name}</span>".html_safe, user_path(projectUser), :title => "#{projectUser.show_name}" %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="fl sy_p_grey" style="margin-left: 0">更新时间:<%= format_date(project.updated_on) %></p>
|
||||
<div class=" fr">
|
||||
<p class="list-info fr grayTxt">
|
||||
<%= link_to project.members.count, allow_visit ? member_project_path(project) : 'javascript:void(0)', :class => "c_blue" %><span class="mr5">成员 |</span>
|
||||
<%= link_to project.project_score.issue_num, allow_visit ? project_issues_path(project) : 'javascript:void(0)', :class => "c_blue" %><span class="mr5">问题 |</span>
|
||||
<%= link_to project.project_score.changeset_num, visible_repository?(project) ? ({:controller => 'repositories', :action => 'show', :id => project, :repository_id => gitlab_repository(project).try(:identifier)}) : 'javascript:void(0)', :class => "c_blue" %><span>提交</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div><!--syllabus_courses_box end-->
|
||||
<script>
|
||||
function alert_notice_box(){
|
||||
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">项目已删除,链接无效</p><div class="cl"></div>'+
|
||||
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10" style="margin-right: 119px;" onclick="hideModal();">确 定</a></div></div>';
|
||||
pop_box_new(htmlvalue, 300, 140);
|
||||
}
|
||||
// function alert_change_project(){
|
||||
// var htmlvalue = "<%#= escape_javascript(render :partial => 'student_work/change_project') %>";
|
||||
// pop_box_new(htmlvalue, 400, 285);
|
||||
// }
|
||||
</script>
|
|
@ -0,0 +1,149 @@
|
|||
<div class="show_hwork_arrow"></div>
|
||||
<div class="showHwork">
|
||||
<% is_teacher = User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest) || User.current.admin? %>
|
||||
<% if @contestwork.work_type != 3 %>
|
||||
<% is_my_work = work.user == User.current%>
|
||||
<% else %>
|
||||
<% pro = @contestwork.contestant_work_projects.where(:user_id => User.current.id).first %>
|
||||
<% is_my_work = pro && pro.contestant_work_id == work.id%>
|
||||
<% end %>
|
||||
<% is_member_work = @contestwork.work_type == 3 && work.contestant_work_projects.empty? %>
|
||||
<% if !is_member_work %>
|
||||
<ul>
|
||||
<li class="fl" >
|
||||
<span class="tit_fb">上交时间:</span>
|
||||
<%=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") %>
|
||||
<!-- 我的作业 && 匿评作业 && 未开启匿评,显示编辑和删除按钮 -->
|
||||
<li class="fr" >
|
||||
<%= link_to("", contestant_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del",:title=>"删除") %>
|
||||
</li>
|
||||
<li class="fr mr5" >
|
||||
<%= link_to "",edit_contestant_work_path(work),:class => "pic_edit",:title => "修改"%>
|
||||
</li>
|
||||
<% end%>
|
||||
|
||||
<div class="cl"></div>
|
||||
|
||||
<!--<li ><span class="tit_fb"> 参与人员:</span>程梦雯 王强</li>-->
|
||||
<% if @contestwork.work_type == 3 && work.contestant_work_projects %>
|
||||
<div class="cl"></div>
|
||||
<li>
|
||||
<span class="tit_fb"> 参与人员:</span>
|
||||
<%= link_to(work.user.show_name+"(组长)", user_path(work.user.id), :class => "linkBlue" )%>
|
||||
<% members = work.contestant_work_projects.where("is_leader = 0") %>
|
||||
<% members.each do |member| if !members.empty? %>
|
||||
、<%=link_to((User.find member.user_id).show_name, user_path(member.user.id), :class => "linkBlue" ) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% if @contestwork.work_detail_group.base_on_project %>
|
||||
<li>
|
||||
<span class="tit_fb"> 关联项目:</span>
|
||||
<% if work.project_id == 0 || work.project_id.nil? %>
|
||||
<span>暂无</span>
|
||||
<% elsif work.project.is_public || User.current.member_of?(work.project) || User.current.admin? %>
|
||||
<%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%>
|
||||
<span class="ml5">(综合评分:<font class="c_red"><%=static_project_score(work.project.project_score).to_i %></font>)</span>
|
||||
<% else %>
|
||||
<span title ="该项目是私有的"><%=work.project.name %></span>
|
||||
<span class="ml5">(综合评分:<font class="c_red"><%=static_project_score(work.project.project_score).to_i %></font>)</span>
|
||||
<% end %>
|
||||
<%#= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end%>
|
||||
|
||||
<li>
|
||||
<span class="tit_fb ">内容:</span>
|
||||
<div class="showHworkP break_word upload_img" id="student_work_img_<%=work.id %>">
|
||||
<%= work.description.html_safe if work.description%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<li>
|
||||
<span class="tit_fb"> 附件:</span>
|
||||
<% com_attachments = work.attachments.where("attachtype IS NULL OR attachtype <> 7") %>
|
||||
<% if com_attachments.empty?%>
|
||||
<span style="color: #999999">尚未提交附件</span>
|
||||
<% else%>
|
||||
<div class="fl" style="width: 90%;">
|
||||
<%= render :partial => 'contest_work_attachments_status', :locals => {:attachments => com_attachments, :status => 1} %>
|
||||
</div>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
</li>
|
||||
<!--<li >-->
|
||||
<!--<%# if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && !is_my_work)%>-->
|
||||
<!--<!– 老师 || 开启匿评状态 && 不是当前用户自己的作品 –>-->
|
||||
<!--<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>-->
|
||||
<!--<%# end%>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</li>-->
|
||||
</ul>
|
||||
|
||||
<!--<div id="revise_attachment">-->
|
||||
<!--<%#= render :partial => 'student_work/revise_attachment', :locals => {:work => work} %>-->
|
||||
<!--</div>-->
|
||||
<div class="cl"></div>
|
||||
<% else %>
|
||||
<!--<ul>-->
|
||||
<!--<li >-->
|
||||
<!--<%# if @is_teacher %>-->
|
||||
<!--<!– 老师 –>-->
|
||||
<!--<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>-->
|
||||
<!--<%# end%>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</li>-->
|
||||
<!--</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>-->
|
||||
<div class="cl"></div>
|
||||
<!---ping_box end--->
|
||||
<a href="javascript:void(0);" class="linkBlue mt5 mb5" style="margin-left:auto; margin-right: auto; display:block; width: 24px;" onclick="$('#about_hwork_<%= work.id%>').html('');">收起</a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
showNormalImage('student_work_img_<%=work.id %>');
|
||||
<% if defined?(is_focus) && is_focus.to_i == 1 %>
|
||||
$("#upload_revise_attachment").click();
|
||||
<% end %>
|
||||
});
|
||||
// function show_upload(){
|
||||
// var htmlvalue = "<%#= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>";
|
||||
// pop_box_new(htmlvalue, 500, 230);
|
||||
// }
|
||||
function regex_des() {
|
||||
if ($.trim($("#attachment_des").val()) == "") {
|
||||
$("#hint_message").text("附件描述不能为空");
|
||||
$("#hint_message").css('color','#ff0000');
|
||||
return false;
|
||||
} else {
|
||||
$("#hint_message").text("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
function submit_revise_files(){
|
||||
if (regex_des()) {
|
||||
$("#upload_form").submit();
|
||||
}
|
||||
}
|
||||
function closeModal(){
|
||||
hideModal($(".uploadBoxContainer"));
|
||||
}
|
||||
function disable_choose(){
|
||||
if ($("#attachments_fields .attachment").size() >= 1) {
|
||||
$("#choose_revise_attach").attr("onclick","return false;").addClass(disable_link);
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,43 @@
|
|||
<div id="popbox02">
|
||||
<div class="ni_con">
|
||||
<span class="f16 fontBlue fb">请您确认刚刚上传的作品信息</span>
|
||||
<p class="f14 mt5">
|
||||
<span class="fb">作品名称:</span><%=@student_work.name%>
|
||||
</p>
|
||||
<div class="f14 mt5 break_word" style="max-width: 425px; color:#808181; max-height:300px; overflow-x:hidden; overflow-y: auto;">
|
||||
<div class="fb fl dis">作品描述:</div>
|
||||
<div class="upload_img fl" style="max-width: 330px;"><%=@student_work.description.html_safe %></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<p class="mt5">
|
||||
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
|
||||
<% if @student_work.attachments.empty? %>
|
||||
<span class="fl c_red"><%= "无附件"%></span>
|
||||
<% else %>
|
||||
<div class="fl grey_c">
|
||||
<% @student_work.attachments.each_with_index do |attachment,i| %>
|
||||
<div id="attachment_<%= attachment.id%>">
|
||||
<%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%>
|
||||
<%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) %>
|
||||
<span class="ml5 fl">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end -%>
|
||||
<%#= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %>
|
||||
</div>
|
||||
<% end %>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<div class="ni_btn mt10">
|
||||
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px; margin-left: 55px;" >
|
||||
确 定
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function clickOK() {
|
||||
window.location.href= "<%= contestant_works_path(:work =>@contestwork.id, :tab => 2) %>"
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,44 @@
|
|||
<div id="popbox02">
|
||||
<div class="ni_con">
|
||||
<span class="f16 fontBlue fb">请您确认刚刚上传的作品信息</span>
|
||||
<p class="f14 mt5">
|
||||
<span class="fb">作品名称:</span><%=@student_work.name%>
|
||||
</p>
|
||||
<div class="f14 mt5 break_word" style="max-width: 425px; color:#808181; max-height:300px; overflow-x:hidden; overflow-y: auto;">
|
||||
<div class="fb fl dis">作品描述:</div>
|
||||
<div id="worksDescription" class="upload_img fl" style="max-width: 330px;"><%=@student_work.description.html_safe %></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<p class="mt5">
|
||||
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
|
||||
<% if @student_work.attachments.empty? %>
|
||||
<span class="fl c_red"><%= "无附件"%></span>
|
||||
<% else %>
|
||||
<div class="fl grey_c">
|
||||
<% @student_work.attachments.each_with_index do |attachment,i| %>
|
||||
<div id="attachment_<%= attachment.id%>">
|
||||
<%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%>
|
||||
<%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) %>
|
||||
<span class="ml5 fl">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end -%>
|
||||
<%#= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %>
|
||||
</div>
|
||||
<% end %>
|
||||
</p>
|
||||
<div class="cl"></div>
|
||||
<div class="ni_btn mt10">
|
||||
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
|
||||
确 定
|
||||
</a>
|
||||
<%= link_to("重 试", retry_work_contestant_work_path(@student_work.id),:class => "tijiao",:style =>"margin-bottom: 15px;margin-top:15px;",:remote => true)%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
function clickOK() {
|
||||
window.location.href= "<%= contestant_works_path(:work =>@contestwork.id, :tab => 2) %>"
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,66 @@
|
|||
<div class="homepagePostPortrait">
|
||||
<%=link_to image_tag(url_to_avatar(homework.user),width:"50px", height: "50px"), user_activities_path(homework.user_id)%>
|
||||
</div>
|
||||
<div class="homepagePostDes">
|
||||
<div class="homepagePostTo break_word mt-4">
|
||||
<%= link_to homework.user.show_name, user_activities_path(homework.user_id), :class => "newsBlue mr15"%>
|
||||
</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"%>
|
||||
</div>
|
||||
<%=get_cw_status(homework).html_safe %>
|
||||
<div class="cl"></div>
|
||||
<% if homework.work_type == 3 && homework.work_detail_group.base_on_project %>
|
||||
<span class="c_red">系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span>
|
||||
<% elsif homework.work_type == 3 && !homework.work_detail_group.base_on_project%>
|
||||
<span class="c_red">系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!</span>
|
||||
<% end %>
|
||||
|
||||
<% is_base_group = homework.work_type == 3 && (homework.work_detail_group.base_on_project || !(cur_user_works_for_work(homework).nil?)) && !is_teacher %>
|
||||
<div class="mt8 mb5">
|
||||
<%= render :partial => 'users/work_opr', :locals => {:activity => homework, :is_teacher => is_teacher, :hw_status => 5, :user_activity_id => homework.id} %>
|
||||
<% if is_base_group %>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
<% if !homework.publish_time.nil? %>
|
||||
<div class="homepagePostDeadline <%= is_base_group ? 'mt8' : '' %>">
|
||||
<%= l(:label_publish_time)%>:<%= homework.publish_time%> 00:00
|
||||
</div>
|
||||
<% end %>
|
||||
<% if !homework.end_time.nil? %>
|
||||
<div class="homepagePostDeadline ml15 <%= is_base_group ? 'mt8' : '' %>">提交截止时间:<%= homework.end_time.to_s %> 23:59</div>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="homeworkInfo" id="homeworkInformation">
|
||||
<div class="">
|
||||
<div class="homeworkDetail upload_img break_word list_style" id="homeworkDetail">
|
||||
<div id="homework_description">
|
||||
<%= homework.description.html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="mt5">
|
||||
<% if homework.work_status == 1%>
|
||||
<% end_time = homework.end_time.to_time.to_i + 24*60*60 - 1 %>
|
||||
<% if end_time >= Time.now.to_i %>
|
||||
<div class="fontGrey2 db fr">提交剩余时间: <span class="c_red"><%= (end_time - Time.now.to_i) / (24*60*60) %></span> 天
|
||||
<span class="c_red"><%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%></span> 小时
|
||||
<span class="c_red"><%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%></span> 分</div>
|
||||
<% else %>
|
||||
<div class="fontGrey2 db fr c_red">提交已截止</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="mt10" style="font-weight:normal;">
|
||||
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => homework} %>
|
||||
</div>
|
||||
|
||||
<%= render :partial => "users/contest_work_base_info", :locals =>{:activity => homework, :user_activity_id =>homework.id, :is_teacher => is_teacher, :hw_status => 5} %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
|
@ -0,0 +1,10 @@
|
|||
<% 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 %>
|
|
@ -0,0 +1,24 @@
|
|||
<% if @has_commit %>
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'has_commit_work') %>');
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
||||
<% elsif @submit_result%>
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'work_information') %>');
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='/student_work/"+ <%=@student_work.id%> +"/retry_work' class='upload_btn' data-remote='true'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
||||
<% else %>
|
||||
window.location.href = '<%= new_contestant_work_path(:work => @contestwork.id)%>';
|
||||
<% end %>
|
||||
|
||||
function clickCanel() {
|
||||
hideModal('#popbox02');
|
||||
window.location.href = '<%= contestant_works_path(:work => @contestwork.id)%>';
|
||||
}
|
|
@ -0,0 +1,250 @@
|
|||
<% content_for :header_tags do %>
|
||||
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
|
||||
<%= javascript_include_tag 'homework','baiduTemplate' %>
|
||||
<% end %>
|
||||
<div class="homepageRight mt0 ml10">
|
||||
<div class="homepageRightBanner mb10">
|
||||
<div class="NewsBannerName">编辑作品</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="HomeWork" id="users_setting">
|
||||
|
||||
<div class="HomeWorkBox">
|
||||
<div class="">
|
||||
<div class="homepagePostTitle fl m_w530 hidden">
|
||||
<%= @contestwork.name%>(作业名称)
|
||||
</div>
|
||||
<span class="fr c_grey">
|
||||
截止时间:<%= @contestwork.end_time%>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<a href="javascript:void(0);" class="c_blue">
|
||||
<%= link_to @contestwork.user.show_name, user_activities_path(@contestwork.user_id), :class => "c_blue"%>
|
||||
</a>
|
||||
<div class="cl"></div>
|
||||
<div class="HomeWorkP break_word">
|
||||
<%= @contestwork.description.html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
</div><!----HomeWorkBox end-->
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="HomeWorkCon mt15" nhname='student_work_form'>
|
||||
<%= labelled_form_for @work,:html => { :multipart => true },:remote=>true do |f|%>
|
||||
<div class="cl"></div>
|
||||
<% if @contestwork.work_type == 3 %>
|
||||
<span id="min_num_member" style="display: none"><%=@contestwork.work_detail_group.min_num %></span>
|
||||
<span id="max_num_member" style="display: none"><%=@contestwork.work_detail_group.max_num %></span>
|
||||
<% str = User.current.id.to_s%>
|
||||
<% @work.contestant_work_projects.where("is_leader = ?", 0).each do |pro| %>
|
||||
<% str += ','+pro.user_id.to_s %>
|
||||
<% end %>
|
||||
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>str %>
|
||||
<% end %>
|
||||
<div>
|
||||
<input type="text" name="student_work[name]" id="student_work_name" placeholder="请输入作品名称" class="InputBox W700" maxlength="200" onkeyup="regexStudentWorkName();" value="<%= @work.name%>">
|
||||
<div class="cl"></div>
|
||||
<p id="student_work_name_span" class="c_red mb10"></p>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<textarea placeholder="请输入作品描述" style="display: none" nhname='student_work_textarea' name="student_work[description]"><%= @work.description%></textarea>
|
||||
<!--<textarea name="student_work[description]" id="student_work_description" placeholder="请输入作品描述" class="InputBox W700 H150" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%#= @work.description%></textarea>-->
|
||||
<!--<script>
|
||||
var text = document.getElementById("student_work_description");
|
||||
autoTextarea(text);// 调用
|
||||
</script>-->
|
||||
<div class="cl"></div>
|
||||
<p id="student_work_description_textarea" class="c_red mb10"></p>
|
||||
<p id="e_tip" class="c_grey"></p>
|
||||
<p id="e_tips" class="c_grey"></p>
|
||||
</div>
|
||||
|
||||
<div class="mt10 mb10">
|
||||
<span class="fl fontGrey2 group_detail_info"></span>
|
||||
<div class="cl"></div>
|
||||
<span class="fl fontGrey2" id="group_members"></span>
|
||||
<div class="cl"></div>
|
||||
<% if @contestwork && @contestwork.work_type == 3 %>
|
||||
<sapn class="fl fontGrey2" id="group_members_show">
|
||||
合作成员:<%= User.current.show_name %>(组长)
|
||||
</sapn>
|
||||
<span id="student_work_group_textarea" class="ml10 c_red fl"></span>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<span class="fl fontGrey2" id="relate_project_show">
|
||||
<% if @contestwork && @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
|
||||
<% unless @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").empty? %>
|
||||
<% project = Project.find @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").first.project_id %>
|
||||
关联项目:<%= project.name %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div id="homework_attachments">
|
||||
<%= render :partial => 'contestant_work_attachment', :locals => {:container => @work} %>
|
||||
</div>
|
||||
|
||||
<% if @contestwork.work_type == 3 %>
|
||||
<div class="mt5 fl">
|
||||
<a href="javascript:void(0);" class="memberBtn fl mt3 mr15" title="请添加小组的其他成员" onclick="show_group_member();">合作成员</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="mt5">
|
||||
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
|
||||
<span class="fr mr10 mt3">或</span>
|
||||
<%= link_to "取消", contestant_work_path(:work => @contestwork.id), :class => "fr mr10 mt3"%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
</div><!----HomeWorkCon end-->
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
<% if @contestwork.work_detail_group %>
|
||||
$(function(){
|
||||
<%members = @work.contestant_work_projects.where("is_leader =?",0) %>
|
||||
var str = $('#group_members_show').html();
|
||||
<% members.each do |member| %>
|
||||
str += '、<%= (User.find member.user_id).show_name %>';
|
||||
<% end %>
|
||||
$('#group_members_show').html(str);
|
||||
$('span.group_detail_info').text('分组人数:<%=@contestwork.work_detail_group.min_num %>-<%=@contestwork.work_detail_group.max_num %> 人');
|
||||
});
|
||||
<% end %>
|
||||
// 添加组成员
|
||||
function show_group_member() {
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'choose_group_member',:locals => {:homework=>@contestwork,:edit_mode => true}) %>');
|
||||
showModal('ajax-modal', '528px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("addMemberCP");
|
||||
}
|
||||
|
||||
function popupRegex(){
|
||||
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
||||
}
|
||||
|
||||
function nh_check_field(params){
|
||||
var result=true;
|
||||
if(!regexStudentWorkName()) {
|
||||
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.html('作品描述不能为空');
|
||||
}else{
|
||||
params.contentmsg.html('');
|
||||
}
|
||||
}
|
||||
if(!result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if($("#group_member_ids").length > 0) {
|
||||
result=regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())));
|
||||
}
|
||||
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 = nh_check_field({
|
||||
issubmit:true,
|
||||
content:params.editor,
|
||||
contentmsg:params.contentmsg,
|
||||
textarea:params.textarea
|
||||
});
|
||||
|
||||
if(is_checked){
|
||||
if(flag){
|
||||
popupRegex();
|
||||
return true;
|
||||
}else{
|
||||
$(this)[0].submit();
|
||||
$("#ajax-indicator").hide();
|
||||
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(editor2,'student_work_<%=@work.id %>');
|
||||
}
|
||||
}).loadPlugin('paste');
|
||||
return editor;
|
||||
}
|
||||
KindEditor.ready(function(K){
|
||||
$("div[nhname='student_work_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='student_work_textarea']",params.div_form);
|
||||
params.contentmsg = $("#student_work_description_textarea");
|
||||
params.submit_btn = $("#new_message_submit_btn");
|
||||
if(params.textarea.data('init') == undefined) {
|
||||
params.editor = init_homework_editor(params);
|
||||
editor2 = params.editor;
|
||||
init_homework_form(params);
|
||||
params.submit_btn.click(function () {
|
||||
params.form.submit();
|
||||
$("#ajax-indicator").hide();
|
||||
});
|
||||
params.textarea.data('init', 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,190 @@
|
|||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag "/assets/codemirror/codemirror_python_ruby_c" %>
|
||||
<%= javascript_include_tag "resizeable_table" %>
|
||||
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
|
||||
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
|
||||
<% end %>
|
||||
<% is_group_project_homework = @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
$("#RSide").removeAttr("id");
|
||||
$("#homework_page_right").css("min-height",$("#courseLSide").height()-33);
|
||||
$("#Container").css("width","1000px");
|
||||
<% if @tab == 2%>
|
||||
$("#student_work_tab2").click();
|
||||
<% elsif @tab == 3 %>
|
||||
$("#student_work_tab3").click();
|
||||
<% end %>
|
||||
sd_create_editor_from_data(<%= @contestwork.id %>, null, "100%", "<%= @contestwork.class.to_s %>");
|
||||
});
|
||||
|
||||
function HoverLi(n){
|
||||
for(var i=1;i<=3;i++){
|
||||
$('#student_work_tab'+i).removeClass('selected');
|
||||
$('#student_work_con'+i).addClass('undis');
|
||||
}
|
||||
$('#student_work_tab'+n).addClass('selected');
|
||||
$('#student_work_con'+n).removeClass('undis');
|
||||
}
|
||||
|
||||
$("#moreProject_<%=@contestwork.id %>").click(function(){
|
||||
$("#relatePWrap_<%=@contestwork.id %>").toggleClass('relatePWrap');
|
||||
$("#relatePWrap_<%=@contestwork.id %>").css("height","auto");
|
||||
$(this).hide();
|
||||
});
|
||||
$("#hideProject_<%=@contestwork.id %>").click(function(){
|
||||
$("#relatePWrap_<%=@contestwork.id %>").toggleClass('relatePWrap');
|
||||
$("#moreProject_<%=@contestwork.id %>").show();
|
||||
});
|
||||
|
||||
// 匿评弹框提示
|
||||
<%# if @is_evaluation && !@stundet_works.empty?%>
|
||||
// $(function(){
|
||||
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/praise_alert') %>');
|
||||
// showModal('ajax-modal', '500px');
|
||||
// $('#ajax-modal').siblings().remove();
|
||||
// $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
// "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
// $('#ajax-modal').parent().css("top","").css("left","");
|
||||
// $('#ajax-modal').parent().addClass("anonymos");
|
||||
// });
|
||||
<%# end%>
|
||||
|
||||
// function set_score_rule_submit() {
|
||||
// if($("#late_penalty_num").val() == ""){
|
||||
// $("#late_penalty_num").val("0");
|
||||
// }
|
||||
// if($("#absence_penalty_num").val() == ""){
|
||||
// $("#absence_penalty_num").val("0");
|
||||
// }
|
||||
// $('#muban_popup_box').find('form').submit();
|
||||
// hideModal();
|
||||
// }
|
||||
|
||||
// //设置评分规则
|
||||
// function set_score_rule(){
|
||||
<!--<%# if @homework.homework_type == 2 %>-->
|
||||
<!--<%# if @homework.anonymous_comment == 0 %>-->
|
||||
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_pro',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
|
||||
// pop_box_new(htmlvalue, 570, 355);
|
||||
<!--<%# else %>-->
|
||||
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_pro_anon',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
|
||||
// pop_box_new(htmlvalue, 500, 285);
|
||||
<!--<%# end %>-->
|
||||
<!--<%# else %>-->
|
||||
<!--<%# if @homework.anonymous_comment == 0 %>-->
|
||||
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_non_pro',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
|
||||
// pop_box_new(htmlvalue, 500, 325);
|
||||
<!--<%# else %>-->
|
||||
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_none_pro_anon',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
|
||||
// pop_box_new(htmlvalue, 500, 225);
|
||||
<!--<%# end %>-->
|
||||
<!--<%# end %>-->
|
||||
// }
|
||||
</script>
|
||||
|
||||
<div class="homepageRight mt0 ml10">
|
||||
<div class="resources" id="homework_page_right">
|
||||
<div class="hworkListBanner">
|
||||
<div id="menu_r" class="fl">
|
||||
<ul class="menu_r">
|
||||
<li>
|
||||
<a href="javascript:void(0);" class="parent">
|
||||
<% if @is_teacher %>
|
||||
<% hcommons = @all_homework_commons %>
|
||||
<% else %>
|
||||
<% hcommons = @homework_commons %>
|
||||
<% end %>
|
||||
<% hcommons.each_with_index do |homework_common,index |%>
|
||||
<% if homework_common.id == @contestwork.id %>
|
||||
<%="作业 #{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 "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
|
||||
</li>
|
||||
<% end%>
|
||||
</ul>
|
||||
</li>
|
||||
<!---level1 end--->
|
||||
</ul>
|
||||
<!---menu_r end--->
|
||||
</div>
|
||||
<!--div class="hworkInfor"><a href="javascript:void(0);" class="linkBlue">作业信息</a></div-->
|
||||
<%# if @is_teacher%>
|
||||
<!--<div class="fr mt5">-->
|
||||
<!--<ul class="">-->
|
||||
<!--<li class="pr export_icon_li">-->
|
||||
<!--<a href="javascript:void(0);" class="export_icon linkBlue2">导出</a>-->
|
||||
<!--<ul class="hworkMenu" style="top: 30px; left: -100px;">-->
|
||||
<!--<!–<li>–>-->
|
||||
<!--<!–<%#= link_to "导出作业成绩", student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :group => @group, :format => 'xls'),:class=>'hworkExport postTypeGrey', :id => "export_student_work"%>–>-->
|
||||
<!--<!–</li>–>-->
|
||||
<!--<li>-->
|
||||
<!--<%# if @contestwork.contestant_works.empty?%>-->
|
||||
<!--<%#= link_to "导出作业附件", "javascript:void(0)", class: "hworkExport resourcesGrey", :onclick => "alert('没有学生提交作业,无法下载附件')" %>-->
|
||||
<!--<%# else%>-->
|
||||
<!--<%#= link_to "导出作业附件", zipdown_assort_path(obj_class: @contestwork.class, obj_id: @contestwork, format: :json),-->
|
||||
<!--remote: true, class: "hworkExport resourcesGrey", :id => "download_homework_attachments" %>-->
|
||||
<!--<%# end%>-->
|
||||
<!--</li>-->
|
||||
<!--</ul>-->
|
||||
<!--</li>-->
|
||||
<!--</ul>-->
|
||||
<!--</div>-->
|
||||
<%# end%>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
</li>
|
||||
<li onclick="HoverLi(2);" id="student_work_tab2">
|
||||
<a href="javascript:void(0);" class="fontGrey3">作品列表</a>
|
||||
</li>
|
||||
<% if is_group_project_homework %>
|
||||
<li onclick="HoverLi(3);" id="student_work_tab3">
|
||||
<a href="javascript:void(0);" class="fontGrey3">关联项目列表</a>
|
||||
</li>
|
||||
<li style="width:415px;"> </li>
|
||||
<% else %>
|
||||
<li style="width:515px;"> </li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<div id="student_work_con1">
|
||||
<div class="homepagePostBrief" id="homework_post_brief">
|
||||
<%= render :partial => 'work_post_brief', :locals => {:homework => @contestwork, :is_teacher => @is_teacher} %>
|
||||
</div>
|
||||
<%= render :partial => 'users/contest_work_post_reply', :locals => {:activity => @contestwork, :user_activity_id => @contestwork.id, :hw_status => 3, :is_teacher => @is_teacher} %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
||||
<div class="undis" id="student_work_con2">
|
||||
<div class="hworkListContainer">
|
||||
<div class="ctt2">
|
||||
<div class="dis" id="homework_student_work_list">
|
||||
<%= render :partial => "contestant_work_list"%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
|
||||
<div class="undis" id="student_work_con3">
|
||||
<% student_work_ids = @contestwork.contestant_works.has_committed.blank? ? "(-1)" : "(" + @contestwork.contestant_works.has_committed.map{|st| st.id}.join(",") + ")" %>
|
||||
<% student_work_projects = @contestwork.contestant_work_projects.where("contestant_work_id in #{student_work_ids} or contestant_work_id is null") %>
|
||||
<% project_ids = student_work_projects.blank? ? "(-1)" : "(" + student_work_projects.map{|pro| pro.project_id}.join(",") + ")" %>
|
||||
<% projects = Project.where("id in #{project_ids}").order("updated_on desc") %>
|
||||
<%= render :partial => "relate_projects", :locals => {:projects => projects}%>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
|
@ -0,0 +1,310 @@
|
|||
<!-- 此界面只用来新建匿评作业作品 -->
|
||||
<% content_for :header_tags do %>
|
||||
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
|
||||
<%= javascript_include_tag 'homework','baiduTemplate' %>
|
||||
<% end %>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
if(is_IE()){
|
||||
$("#_notice_box").show();
|
||||
$("#uploadReviseBox").addClass('disable_link');
|
||||
$("#upload_file_local").attr("title","IE无法上传");
|
||||
$("#upload_file_local").attr("onclick","return false;");
|
||||
$("#resource_repo_upload").attr("title","IE无法上传");
|
||||
$("#resource_repo_upload").attr("href","javascript:void(0)");
|
||||
}
|
||||
});
|
||||
<% if @contestwork.work_detail_group %>
|
||||
$(function(){
|
||||
$('span.group_detail_info').text('分组人数:<%=@contestwork.work_detail_group.min_num %>-<%=@contestwork.work_detail_group.max_num %> 人');
|
||||
});
|
||||
<% end %>
|
||||
|
||||
// //快速创建项目的弹框
|
||||
// function new_project(){
|
||||
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/new_project') %>');
|
||||
// showModal('ajax-modal', '800px');
|
||||
// $('#ajax-modal').siblings().remove();
|
||||
// $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
// "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
// $('#ajax-modal').parent().css("top","30%").css("left","20%").css("position","fixed").css("border","3px solid #269ac9");
|
||||
// }
|
||||
|
||||
// // 点击 checkbox选中引用的资源的时候,保存该资源的id到session里去
|
||||
// function store_seleted_resource(dom){
|
||||
// if(dom.attr('checked') == 'checked' ){
|
||||
// $.get(
|
||||
// '<%#= store_selected_resource_user_path(User.current) %>'+'?save=y&res_id='+dom.val()
|
||||
// )
|
||||
// }else {
|
||||
// $.get(
|
||||
// '<%#= store_selected_resource_user_path(User.current) %>'+'?save=n&res_id='+dom.val()
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// 添加组成员
|
||||
function show_group_member() {
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'choose_group_member',:locals => {:homework=>@contestwork}) %>');
|
||||
showModal('ajax-modal', '528px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("addMemberCP");
|
||||
}
|
||||
// 关联项目
|
||||
function show_project() {
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'relate_project',:locals => {:homework=>@contestwork}) %>');
|
||||
showModal('ajax-modal', '320px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').parent().css("top","").css("left","");
|
||||
$('#ajax-modal').parent().addClass("groupPopUp");
|
||||
}
|
||||
// 作品校验
|
||||
function popupRegex(){
|
||||
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
||||
}
|
||||
|
||||
function nh_check_field(params){
|
||||
var result=true;
|
||||
if(!regexStudentWorkName()) {
|
||||
result=false;
|
||||
return result;
|
||||
}
|
||||
if(params.content!=undefined){
|
||||
if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
|
||||
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() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
|
||||
params.contentmsg.html('作品描述不能为空');
|
||||
}else{
|
||||
params.contentmsg.html('');
|
||||
}
|
||||
}
|
||||
if(!result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if($("#group_member_ids").length > 0) {
|
||||
result=regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())));
|
||||
}
|
||||
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 = nh_check_field({
|
||||
issubmit:true,
|
||||
content:params.editor,
|
||||
contentmsg:params.contentmsg,
|
||||
textarea:params.textarea
|
||||
});
|
||||
|
||||
if(is_checked){
|
||||
if(flag){
|
||||
popupRegex();
|
||||
return true;
|
||||
}else{
|
||||
$(this)[0].submit();
|
||||
$("#ajax-indicator").hide();
|
||||
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));
|
||||
},
|
||||
afterBlur:function(){
|
||||
if(this.isEmpty()) {
|
||||
this.edit.html("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
|
||||
}
|
||||
},
|
||||
afterFocus: function(){
|
||||
var edit = this.edit;
|
||||
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(edit.html())){
|
||||
edit.html('');
|
||||
}
|
||||
},
|
||||
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("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
|
||||
//paramsHeight = params.kindutil.removeUnit(this.height);
|
||||
edit.iframe.height(150);
|
||||
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
|
||||
elocalStorage(editor2,'student_work_<%=@contestwork.id %>');
|
||||
}
|
||||
}).loadPlugin('paste');
|
||||
return editor;
|
||||
}
|
||||
KindEditor.ready(function(K){
|
||||
$("div[nhname='student_work_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='student_work_textarea']",params.div_form);
|
||||
params.contentmsg = $("#student_work_description_textarea");
|
||||
params.submit_btn = $("#new_message_submit_btn");
|
||||
if(params.textarea.data('init') == undefined) {
|
||||
params.editor = init_homework_editor(params);
|
||||
editor2 = params.editor;
|
||||
init_homework_form(params);
|
||||
params.submit_btn.click(function () {
|
||||
params.form.submit();
|
||||
$("#ajax-indicator").hide();
|
||||
});
|
||||
params.textarea.data('init', 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="homepageRight mt0 ml10">
|
||||
<div class="homepageRightBanner mb10 ml10">
|
||||
<div class="NewsBannerName">提交作品</div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="_notice_box text_c none mb10" style="height: 20px; padding: 4px 4px; line-height: 20px;" id="_notice_box">注意:暂不支持IE浏览器的上传,请更换浏览器</div>
|
||||
|
||||
<div class="HomeWork" id="users_setting">
|
||||
<div class="HomeWorkBox">
|
||||
<div class="">
|
||||
<div class="homepagePostTitle fl m_w530 hidden">
|
||||
<%= @contestwork.name%>(竞赛名称)
|
||||
</div>
|
||||
<span class="fr c_grey">
|
||||
截止时间:<%= @contestwork.end_time%>
|
||||
</span>
|
||||
<div class="cl"></div>
|
||||
<a href="javascript:void(0);" class="c_blue">
|
||||
<%= link_to @contestwork.user.show_name, user_activities_path(@contestwork.user_id), :class => "c_blue"%>
|
||||
</a>
|
||||
<div class="cl"></div>
|
||||
<div class="HomeWorkP break_word">
|
||||
<%= @contestwork.description.html_safe %>
|
||||
</div>
|
||||
<div>
|
||||
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => @contestwork.attachments} %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!----HomeWorkBox end-->
|
||||
<div class="cl"></div>
|
||||
|
||||
<div class="HomeWorkCon mt15" nhname='student_work_form'>
|
||||
<%= form_for(@student_work,
|
||||
:html => { :multipart => true },
|
||||
:url => {:controller => 'contestant_works',
|
||||
:action => 'create',
|
||||
:work => @contestwork.id
|
||||
},:remote=>true ) do |f| %>
|
||||
|
||||
<div class="cl"></div>
|
||||
<% if @contestwork.work_type == 3 %>
|
||||
<span id="min_num_member" style="display: none"><%=@contestwork.work_detail_group.min_num %></span>
|
||||
<span id="max_num_member" style="display: none"><%=@contestwork.work_detail_group.max_num %></span>
|
||||
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %>
|
||||
<% end %>
|
||||
<div>
|
||||
<input type="text" name="student_work[name]" id="student_work_name" class="InputBox fl W700" maxlength="200" onkeyup="regexStudentWorkName();" placeholder="请输入作品名称" value="<%=@contestwork.name %>的作品提交(可修改)">
|
||||
<div class="cl"></div>
|
||||
<p id="student_work_name_span" class="c_red mb10"></p>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<textarea placeholder="请输入作品描述" style="display: none" nhname='student_work_textarea' name="student_work[description]"></textarea>
|
||||
<%#= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%>
|
||||
<!--<script>
|
||||
var text = document.getElementById("student_work_description");
|
||||
autoTextarea(text);// 调用
|
||||
</script>-->
|
||||
<div class="cl"></div>
|
||||
<p id="student_work_description_textarea" class="c_red mb10"></p>
|
||||
<p id="e_tip" class="c_grey"></p>
|
||||
<p id="e_tips" class="c_grey"></p>
|
||||
</div>
|
||||
|
||||
<div class="mt10 mb10">
|
||||
<span class="fl fontGrey2 group_detail_info"></span>
|
||||
<div class="cl"></div>
|
||||
<span class="fl fontGrey2" id="group_members"></span>
|
||||
<div class="cl"></div>
|
||||
<% if @contestwork && @contestwork.work_type == 3 %>
|
||||
<sapn class="fl fontGrey2" id="group_members_show">
|
||||
合作成员:<%= User.current.show_name %>(组长)
|
||||
</sapn>
|
||||
<span id="student_work_group_textarea" class="ml10 c_red fl"></span>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<span class="fl fontGrey2" id="relate_project_show">
|
||||
<% if @contestwork && @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %>
|
||||
<% unless @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").empty? %>
|
||||
<% project = Project.find @contestwork.contestant_work_projects.where("user_id = #{User.current.id}").first.project_id %>
|
||||
关联项目:<%= project.name %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
||||
<div id="homework_attachments">
|
||||
<%= render :partial => 'contestant_work_attachment', :locals => {:container => @student_work} %>
|
||||
</div>
|
||||
<div id="group_member">
|
||||
</div>
|
||||
<div id="relate_project">
|
||||
</div>
|
||||
|
||||
<% if @contestwork.work_type == 3 %>
|
||||
<div class="fl mt5">
|
||||
<a href="javascript:void(0);" class="memberBtn fl mt3 mr15" title="请添加小组的其他成员" onclick="show_group_member();">合作成员</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="mt5">
|
||||
<a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">提交</a>
|
||||
<span class="fr mr10 mt3">或</span>
|
||||
<%= link_to "取消", delete_work_contestant_works_path(:work =>@contestwork.id),:id => 'new_message_cancel_btn', :class => "fr mr10 mt3"%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% end%>
|
||||
</div><!----HomeWorkCon end-->
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,2 @@
|
|||
var htmlvalue = "<%= escape_javascript(render :partial => 'relate_project') %>";
|
||||
pop_box_new(htmlvalue, 400, 285);
|
|
@ -0,0 +1,3 @@
|
|||
hideModal('#popbox02');
|
||||
$("#homework_attachments").html("<%= escape_javascript(render :partial => 'contestant_work_attachment', :locals => {:container => @work})%>");
|
||||
$("#group_member_ids").val("<%=User.current.id %>");
|
|
@ -0,0 +1,42 @@
|
|||
$("#all_students_list").empty();
|
||||
<% @users.each do |user|%>
|
||||
var link = "<li id='student_<%=user.id %>'><%=user.show_name %>";
|
||||
<% unless user.user_extensions.student_id == "" %>
|
||||
link += "(<%=user.user_extensions.student_id %>)";
|
||||
<% end %>
|
||||
link += "</li>";
|
||||
$("#all_students_list").append(link);
|
||||
|
||||
var str = $("#group_member_ids").val();
|
||||
var choose_str = "";
|
||||
var lists = $("#choose_students_list li");
|
||||
if(lists.length > 0) {
|
||||
for(var i=0; i<lists.length; i++) {
|
||||
var id = $(lists[i]).attr("id").replace(/[^0-9]/ig,"");
|
||||
choose_str += id;
|
||||
if (i != lists.length -1) {
|
||||
choose_str += ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
<% if user.id.to_i != User.current.id.to_i && (@commit_student_ids.find{|e| e.to_i == user.id.to_i}).nil? && user.contestant_of_contest?(@contest) %>
|
||||
if (str.indexOf(<%=user.id.to_s %>) < 0 && choose_str.indexOf(<%=user.id.to_s %>) < 0) {
|
||||
$("#student_<%=user.id %>").one("click",function choose_student() {
|
||||
var li = "<li id='choose_student_<%=user.id %>'";
|
||||
<% if user.id.to_i != User.current.id.to_i %>
|
||||
li += " onclick='delete_student(<%=user.id %>);'";
|
||||
<% end %>
|
||||
li += ">" + $("#student_<%=user.id %>").html()+"<input name='member_id[]' value='<%=user.id %>' type='hidden'/></li>";
|
||||
$("#choose_students_list").append(li);
|
||||
});
|
||||
}
|
||||
<% elsif !user.contestant_of_contest?(@contest) %>
|
||||
if (str.indexOf(<%=user.id.to_s %>) < 0) {
|
||||
$("#student_<%=user.id %>").attr("title","该项目成员不是本竞赛的参赛者");
|
||||
}
|
||||
<% else %>
|
||||
if (str.indexOf(<%=user.id.to_s %>) < 0) {
|
||||
$("#student_<%=user.id %>").attr("title","该成员已加入其它分组");
|
||||
}
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -0,0 +1,9 @@
|
|||
if($("#about_hwork_<%= @work.id%>").children().length > 0){
|
||||
$("#about_hwork_<%= @work.id%>").html("");
|
||||
}
|
||||
else{
|
||||
$(".about_hwork").html("");
|
||||
|
||||
$("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work =>@work}) %>");
|
||||
$('#score_<%= @work.id%>').peSlider({range: 'min'});
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
hideModal("#popbox02");
|
||||
<% 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 %>
|
|
@ -0,0 +1,16 @@
|
|||
<% if @submit_result%>
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'work_edit_information') %>');
|
||||
showModal('ajax-modal', '500px');
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
|
||||
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
|
||||
$('#ajax-modal').parent().addClass("anonymos");
|
||||
<% else %>
|
||||
window.location.href = '<%= edit_contestant_work_path(@work)%>';
|
||||
<% end %>
|
||||
|
||||
function clickCanel() {
|
||||
hideModal('#popbox02');
|
||||
window.location.href= "<%= contestant_works_path(:work =>@contestwork.id, :tab => 2) %>"
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
<%= error_messages_for @contestnotifications %>
|
||||
<script type="text/javascript">
|
||||
function regexTitle()
|
||||
{
|
||||
var title = $.trim($("#contestnotification_title").val());
|
||||
if(title.length ==0)
|
||||
{
|
||||
$("#title_span").text("<%= l(:label_no_contest_news_title) %>");
|
||||
$("#title_span").css('color','#ff0000');
|
||||
$("#title_span").focus();
|
||||
return false;
|
||||
}
|
||||
else if(title.length <= 254)
|
||||
{
|
||||
$("#title_span").text("<%= l(:label_field_correct) %>");
|
||||
$("#title_span").css('color','#008000');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#title_span").text("<%= l(:label_contest_news_title_condition) %>");
|
||||
$("#title_span").css('color','#ff0000');
|
||||
$("#title_span").focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//验证描述:不能为空,不能多余5000个字符
|
||||
function regexDescription()
|
||||
{
|
||||
var description = $.trim($("#contestnotification_description").val());
|
||||
if(description.length ==0)
|
||||
{
|
||||
$("#description_span").text("<%= l(:label_no_contest_news_description) %>");
|
||||
$("#description_span").css('color','#ff0000');
|
||||
$("#description_span").focus();
|
||||
return false;
|
||||
}
|
||||
else if(description.length <= 5000)
|
||||
{
|
||||
$("#description_span").text("<%= l(:label_field_correct) %>");
|
||||
$("#description_span").css('color','#008000');
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#description_span").text("<%= l(:label_contest_news_condition) %>");
|
||||
$("#description_span").css('color','#ff0000');
|
||||
$("#description_span").focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div class="box tabular">
|
||||
<p>
|
||||
<%= f.text_field :title,
|
||||
:required => true,
|
||||
:size => 60,
|
||||
:maxlength => 60,
|
||||
:style => "width:488px;",
|
||||
:onkeyup => "regexTitle();"
|
||||
%>
|
||||
</p>
|
||||
<span id="title_span" style="padding-left: 100px;"></span>
|
||||
<p>
|
||||
<%= f.text_area :description,
|
||||
:required => true,
|
||||
:cols => 60,
|
||||
:rows => 11,
|
||||
:class => 'wiki-edit',
|
||||
:style => "width:490px;",
|
||||
:onkeyup => "regexDescription();"
|
||||
%>
|
||||
</p>
|
||||
<span id="description_span" style="padding-left: 100px;"></span>
|
||||
</div>
|
||||
|
||||
<%= wikitoolbar_for 'news_description' %>
|
|
@ -1,51 +0,0 @@
|
|||
<!--<p><%#= link_to_project(news.project) + ': ' unless @project %>
|
||||
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%#= link_to h(news.title), news_path(news) %>
|
||||
<%#= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
|
||||
|
||||
<%# unless news.summary.blank? %></td><td><span class="fontligher"><%#=h news.summary %></span></td>
|
||||
<td><span class="author"><%#= authoring news.created_on, news.author %></span></td></tr></table></p>-->
|
||||
|
||||
<table width="660px" border="0" align="center">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" >
|
||||
<img src="/images/new/news.png" width="40" height="40"/>
|
||||
</td>
|
||||
<td><table width="580px" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top">
|
||||
<strong>
|
||||
<%=link_to contestnotifications.author,
|
||||
contest_contestnotification_path(contestnotifications)
|
||||
%>
|
||||
</strong>
|
||||
<a class="font_lighter">
|
||||
<%= l(:label_project_newshare) %>
|
||||
</a>
|
||||
<%= link_to h(contestnotifications.title),
|
||||
contest_contestnotification_path(contestnotifications)
|
||||
%>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px" >
|
||||
<p class="font_description">
|
||||
<%=h contestnotifications.description%>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
<a class="font_lighter">
|
||||
<%= contestnotifications.created_at %>
|
||||
</a>
|
||||
</td>
|
||||
<td width="200" align="right" class="a">
|
||||
<%= link_to l(:label_project_newother),
|
||||
contest_contestnotification_path(contestnotifications)
|
||||
%>
|
||||
<%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count > 0 %>
|
||||
</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
|
@ -1,18 +0,0 @@
|
|||
<h3><%=l(:label_edit_contest_notice)%></h3>
|
||||
|
||||
<%= labelled_form_for @contestnotification,
|
||||
:url => contest_contestnotification_path,
|
||||
:html => { :id => 'contestnotifications-form',
|
||||
:multipart => true,
|
||||
:method => :put } do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<%#= preview_link preview_contestnotifications_path(id: @contestnotification),
|
||||
'contestnotifications-form'
|
||||
%>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= stylesheet_link_tag 'scm' %>
|
||||
<% end %>
|
|
@ -1,14 +0,0 @@
|
|||
api.array :contestnotifications, api_meta(:total_count => @contestnotifications_count, :offset => @offset, :limit => @limit) do
|
||||
@contestnotificationss.each do |contestnotifications|
|
||||
api.contestnotifications do
|
||||
api.id contestnotifications.id
|
||||
api.contest(:id => contestnotifications.contest_id, :name => contestnotifications.contest.name) unless contestnotifications.contest.nil?
|
||||
api.author(:id => contestnotifications.author_id, :name => contestnotifications.author.name) unless contestnotifications.author.nil?
|
||||
|
||||
api.title contestnotifications.title
|
||||
api.summary contestnotifications.summary
|
||||
api.description contestnotifications.description
|
||||
api.created_at contestnotifications.created_at
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,151 +0,0 @@
|
|||
<script type="text/javascript">
|
||||
function submitContestNews()
|
||||
{
|
||||
if(regexTitle() && regexDescription())
|
||||
{
|
||||
$("#contestnotifications-form").submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
|
||||
<%= l(:label_notification) %>
|
||||
</span>
|
||||
<% if User.current.logged? && (User.current.admin? ||User.current == @contest.author) %>
|
||||
<%= link_to(l(:bale_news_notice),
|
||||
new_contest_contestnotification_path(@contest),
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %>
|
||||
<% end %>
|
||||
<% if @contest %>
|
||||
<div id="add-contestnotifications" class="add_frame" style="display:none;">
|
||||
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest),
|
||||
:html => {:id => 'contestnotifications-form', :multipart => true} do |f| %>
|
||||
<%= render :partial => 'contestnotifications/form', :locals => {:f => f} %>
|
||||
<input type="button" onclick="submitContestNews();" class="enterprise" value="<%= l(:button_create)%>"/>
|
||||
|
|
||||
<input type="button" onclick="$('#add-contestnotifications').hide(); return false;" class="enterprise" value="<%= l(:button_cancel)%>"/>
|
||||
<% end if @contest %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
<br/>
|
||||
<% end %>
|
||||
<div>
|
||||
|
||||
<div style="margin-left: 20px;">
|
||||
<span class="portrait">
|
||||
<%= image_tag(url_to_avatar(@contest.author), :class => "avatar")%>
|
||||
</span>
|
||||
<span class="body">
|
||||
<span id="praise_tread" style="float: right">
|
||||
<%= render :partial => "/praise_tread/praise_tread",
|
||||
:locals => {:obj => @contest,
|
||||
:show_flag => true,
|
||||
:user_id =>User.current.id,
|
||||
:horizontal => false}
|
||||
%>
|
||||
</span>
|
||||
<h3>
|
||||
<%= link_to(@contest.author.lastname+@contest.author.firstname,
|
||||
user_path(@contest.author))%>
|
||||
:<%= @contest.name %>
|
||||
</h3>
|
||||
<p>
|
||||
<strong>
|
||||
<%= l(:label_bids_reward_method) %>
|
||||
<span class="bonus">
|
||||
<%= @contest.budget%>
|
||||
</span>
|
||||
</strong>
|
||||
</p>
|
||||
<div class="bid_description" style="width: 100%;word-break:break-all;word-wrap: break-word;">
|
||||
<%= @contest.description %>
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div style="clear: both;"></div>
|
||||
|
||||
<br><br>
|
||||
<% @contestnotificationss.each do |contestnotifications| %>
|
||||
<table class="content-text-list">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50">
|
||||
<%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %>
|
||||
</td>
|
||||
<td>
|
||||
<table width="580px" border="0">
|
||||
|
||||
<tr>
|
||||
<td colspan="2" valign="top">
|
||||
<strong>
|
||||
<%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %>
|
||||
</strong>
|
||||
<span style="margin-left: 4px;" class="font_lighter">
|
||||
<%= l(:label_project_notice) %>
|
||||
</span>
|
||||
<span>
|
||||
<%= link_to h(contestnotifications.title), contest_contestnotification_path(@contest, contestnotifications) %>
|
||||
</span>
|
||||
<span style="float: right">
|
||||
<%= link_to l(:button_edit), edit_contest_contestnotification_path(@contest, contestnotifications) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
|
||||
<%= delete_link contest_contestnotification_path(@contest, contestnotifications) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px">
|
||||
<span class="font_description">
|
||||
<%= textilizable(contestnotifications, :description) %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><span class="font_lighter">
|
||||
<%= l :label_update_time %>
|
||||
|
||||
<%= format_time(contestnotifications.created_at) %>
|
||||
</span>
|
||||
</td>
|
||||
<td width="350" align="right" class="a">
|
||||
<%= link_to l(:label_check_comment), contest_contestnotification_path(@contest, contestnotifications) %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<!--end-->
|
||||
<div style="padding-right: 10px">
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<%= pagination_links_full @contestnotifications_pages %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
|
||||
<%= stylesheet_link_tag 'scm' %>
|
||||
<% end %>
|
||||
|
||||
<% html_title(l(:label_contest_notification)) -%>
|
||||
</div>
|
||||
|
||||
<script type='text/javascript'>
|
||||
$(document).ready(function ($) {
|
||||
$('.content-text-list').each(function () {
|
||||
$(this).find('.delete_icon').hide();
|
||||
$(this).mouseenter(function (event) {
|
||||
$(this).find('.delete_icon').show();
|
||||
});
|
||||
$(this).mouseleave(function (event) {
|
||||
$(this).find('.delete_icon').hide();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--end-->
|
|
@ -1,17 +0,0 @@
|
|||
<script type="text/javascript">
|
||||
function submitContestNews()
|
||||
{
|
||||
if(regexTitle() && regexDescription())
|
||||
{
|
||||
$("#contestnotifications-form").submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<%= labelled_form_for @contestnotification,
|
||||
:url => contest_contestnotifications_path(@contest),
|
||||
:html => { :id => 'contestnotifications-form', :multipart => true } do |f| %>
|
||||
<%= render :partial => 'contestnotifications/form', :locals => { :f => f } %>
|
||||
<input type="button" onclick="submitContestNews();" class="enterprise" value="<%= l(:button_create)%>"/>
|
||||
<%= link_to l(:button_cancel), contest_contestnotifications_path(@contest.id) %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
|
@ -1,144 +0,0 @@
|
|||
<script>
|
||||
function cancel() {
|
||||
$("#add_contestnotification").hide();
|
||||
}
|
||||
</script>
|
||||
<div class="contextual">
|
||||
<%= link_to(l(:button_edit),
|
||||
edit_contest_contestnotification_path(@contest, @contestnotification),
|
||||
:class => 'icon icon-edit',
|
||||
:accesskey => accesskey(:edit),
|
||||
:onclick => '$("#edit-contestnotifications").show(); return true;') if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)%>
|
||||
<%= delete_link contest_contestnotification_path(@contest, @contestnotification) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
|
||||
</div>
|
||||
|
||||
<h3><strong><%=h @contestnotification.title %></strong></h3>
|
||||
|
||||
<div id="edit-contestnotifications" style="display:none;">
|
||||
<%= labelled_form_for @contestnotification,
|
||||
:url => contest_contestnotification_path(@contest),
|
||||
:html => { :id => 'contestnotifications-form',
|
||||
:multipart => true,
|
||||
:method => :put } do |f| %>
|
||||
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<%= link_to l(:button_cancel),
|
||||
"#",
|
||||
:onclick => '$("#edit-contestnotifications").hide(); return false;' %>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
|
||||
<div id="notificationcomments" style="margin-bottom:16px;">
|
||||
|
||||
<div style="margin:15px" id ="add_contestnotification">
|
||||
<span class="font_description">
|
||||
<%= textilizable(@contestnotification, :description) %>
|
||||
</span>
|
||||
<br/>
|
||||
<%#= link_to_attachments @contestnotification %>
|
||||
<br/>
|
||||
<!--add comment-->
|
||||
|
||||
<% if User.current.logged? %>
|
||||
<p>
|
||||
<%= toggle_link l(:label_comment_add),
|
||||
"add_notificationcomment_form",
|
||||
:focus => "notificationcomment_notificationcomments"
|
||||
%>
|
||||
</p>
|
||||
<% else %>
|
||||
<%= l(:label_user_login_notificationcomment) %>
|
||||
<%= link_to l(:label_user_login_new), signin_path %>
|
||||
<% end %>
|
||||
|
||||
<%= form_tag( contest_contestnotification_notificationcomments_path(@contest, @contestnotification) ,
|
||||
:id => "add_notificationcomment_form",
|
||||
:style => "display:none;") do %>
|
||||
<div class="box">
|
||||
<%= text_area 'notificationcomment',
|
||||
'notificationcomments',
|
||||
:cols => 80,
|
||||
:rows => 15,
|
||||
:class => 'wiki-edit'
|
||||
%>
|
||||
<%= wikitoolbar_for 'notificationcomment_notificationcomments' %>
|
||||
</div>
|
||||
<p>
|
||||
<%= submit_tag l(:button_add) %>
|
||||
|
||||
<!--modified by longjun 点击取消时收回添加回复的部分-->
|
||||
|
||||
<%= submit_tag l(:button_cancel),
|
||||
:name => nil,
|
||||
:onclick => "cancel();",
|
||||
:type => 'button',
|
||||
:class => "enterprise",
|
||||
:onmouseout => "this.style.backgroundPosition = 'left top'",
|
||||
:onmouseover => "this.style.backgroundPosition = 'left -30px'"
|
||||
%>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% html_title @contestnotification.title -%>
|
||||
|
||||
<% content_for :header_tags do %>
|
||||
<%= stylesheet_link_tag 'scm' %>
|
||||
<% end %>
|
||||
|
||||
<!--dispaly comments-->
|
||||
<div class="line_heng"></div>
|
||||
</div>
|
||||
<h3 class="notificationcomments"><%= l(:label_comment_plural) %></h3>
|
||||
<% notificationcomments = @notificationcomments.reverse %>
|
||||
<% notificationcomments.each do |notificationcomment| %>
|
||||
<% next if notificationcomment.new_record? %>
|
||||
<table width="660px" border="0" align="center">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" >
|
||||
<%= image_tag(url_to_avatar(notificationcomment.author), :class => "avatar")%>
|
||||
</td>
|
||||
<td>
|
||||
<table width="580px" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top">
|
||||
<strong>
|
||||
<%= link_to_user(notificationcomment.author) if notificationcomment.respond_to?(:author) %>
|
||||
</strong>
|
||||
<span class="font_lighter">
|
||||
<%= l(:label_project_newadd) %>
|
||||
</span>
|
||||
<%= l(:label_comment_plural) %>
|
||||
</td>
|
||||
<!--modified by longjun 删除变成竖的,IE浏览器兼容,将宽度设置为40px-->
|
||||
<td width="40px">
|
||||
<% if notificationcomment.author==User.current|| User.current.admin? %>
|
||||
<%= link_to(l(:label_bid_respond_delete),
|
||||
contest_contestnotification_notificationcomment_path(@contest, @contestnotification,notificationcomment),
|
||||
:method => :delete,:confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px" >
|
||||
<p class="font_description">
|
||||
<%= textilizable(notificationcomment.notificationcomments) %>
|
||||
</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
<span class="font_lighter">
|
||||
<%= format_time(notificationcomment.created_at) %>
|
||||
</span>
|
||||
</td>
|
||||
<td width="200" align="right" class="a"><%#= link_to_if_authorized_contest image_tag('delete.png'), {:controller => 'notificationcomments', :action => 'destroy', :id => @contestnotifications, :notificationcomment_id => notificationcomment},
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end if @notificationcomments.any? %>
|
||||
</div>
|
||||
|
||||
<!--end-->
|
|
@ -0,0 +1,40 @@
|
|||
<div class="pro_new_setting_conbox " style="width:100%; border:none;">
|
||||
<div class=" sy_new_tchbox clear " style="margin-left:10px; margin-right:10px; " >
|
||||
<ul class="pro_newsetting_con mb15">
|
||||
<li class="mb10 clear">
|
||||
<label class=" fl">新增子栏目名称 : </label>
|
||||
<input type="text" class="w695 fl" placeholder=" 请输入子栏目名称">
|
||||
</li>
|
||||
</ul>
|
||||
<a href="javascript:void(0);" class="fr sy_btn_grey ">取消</a><a href="javascript:void(0);" class="fr sy_btn_blue mr5">保存</a>
|
||||
</div>
|
||||
<div class=" clear ml10 mr10" >
|
||||
<table class="sy_new_table clearfix mb15 " cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>名称</th>
|
||||
<th style="width:280px;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="game-text-left"><span class=" ml20"></span>竞赛讨论区</th>
|
||||
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_green mr5 ">添加子栏目</a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="game-text-left"><span class=" ml40"></span>技术讨论区</th>
|
||||
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">下移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</a><a href="javascript:void(0);" class=" sy_btn_grey mr5 ">删除</a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="game-text-left"><span class=" ml40"></span>学术论区</th>
|
||||
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">上移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">下移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</a><a href="javascript:void(0);" class=" sy_btn_grey mr5 ">删除</a></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="game-text-left"><span class=" ml40"></span>学术论区</th>
|
||||
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">上移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</a><a href="javascript:void(0);" class=" sy_btn_grey mr5 ">删除</a></th>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,63 @@
|
|||
<%= content_for(:header_tags) do %>
|
||||
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
|
||||
<% end %>
|
||||
<script>
|
||||
var onUserCard = false;
|
||||
var onImage = false;
|
||||
$(document).ready(function(){
|
||||
$("#relateProject,.relatePInfo").mouseover(function(){
|
||||
$(".relatePInfo").css("display","block");
|
||||
})
|
||||
$("#relateProject,.relatePInfo").mouseout(function(){
|
||||
$(".relatePInfo").css("display","none");
|
||||
})
|
||||
$(".coursesLineGrey").mouseover(function(){
|
||||
$(this).css("color","#ffffff");
|
||||
})
|
||||
$(".coursesLineGrey").mouseout(function(){
|
||||
$(this).css("color","#808080");
|
||||
})
|
||||
$(".homepagePostSetting,.coursesLineGrey").mouseover(function(){
|
||||
$(this).prev().css("color","#ffffff");
|
||||
$(this).css("z-index", "9999");
|
||||
})
|
||||
$(".homepagePostSetting").mouseout(function(){
|
||||
$(this).prev().css("color","#808080");
|
||||
$(this).css("z-index", "1");
|
||||
})
|
||||
})
|
||||
</script>
|
||||
<style type="text/css">
|
||||
</style>
|
||||
<% contest_activities.includes(:contest_act).each do |activity| if contest_activities %>
|
||||
<script>
|
||||
$(function () {
|
||||
sd_create_editor_from_data(<%= activity.id%>, null, "100%", "<%= activity.class.to_s %>");
|
||||
});
|
||||
</script>
|
||||
<% if activity && activity.contest_act %>
|
||||
<% act = activity.contest_act %>
|
||||
<% case activity.contest_act_type.to_s %>
|
||||
<% when 'Work' %>
|
||||
<%= render :partial => 'users/contest_work', :locals => {:activity => act, :user_activity_id => activity.id, :hw_status => 2} %>
|
||||
<% 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} %>
|
||||
<% when 'Poll' %>
|
||||
<%#= render :partial => 'users/contest_poll', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
|
||||
<% when 'JournalsForMessage' %>
|
||||
<%#= render :partial => 'users/contest_journalsformessage', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
|
||||
<% when 'Attachment' %>
|
||||
<%#= render :partial => 'users/contest_attachment', :locals => {:activity => act, :user_activity_id => activity.id} %>
|
||||
<% when 'Contest' %>
|
||||
<%= render :partial => 'users/contest_create', :locals => {:activity => act, :user_activity_id => activity.id, :is_contest => 1} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if contest_activities.count + page * 10 < @contest_activities_count %>
|
||||
<!--<div id="show_more_course_activities" class="loadMore mt10 f_grey">点击展开更多<%#= link_to "", course_activity_path(@course.id, :type => type, :page => page), :id => "more_course_activities_link", :remote => "true", :class => "none" %></div>-->
|
||||
<%= link_to "点击展开更多",contest_activities_contest_path(@contest.id, :type => type, :page => page),:id => "show_more_course_activities",:remote => "true",:class => "loadMore mt10 f_grey"%>
|
||||
<% end %>
|
|
@ -0,0 +1,38 @@
|
|||
<p class="sy_cgrey mb10">
|
||||
<%= link_to @contest.user.try(:show_name), user_path(@contest.user), :class => "sy_cgrey" %>
|
||||
<span class="sy_cgrey"> > </span>
|
||||
<%= link_to @contest.name, contest_path(@contest), :class => "sy_cgrey" %>
|
||||
</p>
|
||||
<% if User.current.admin_of_contest?(@contest) %>
|
||||
<%= render :partial => "contests/mamager_setting" %>
|
||||
<% end %>
|
||||
|
||||
<div class="cl"></div>
|
||||
<div class="banner-game"><img src="/images/game/banner-game.png" width="968" height="110"/></div>
|
||||
<div class="sy_class_info fl">
|
||||
<div class="sy_class_titbox">
|
||||
<h3 class="fl sy_class_title"><%= @contest.name %></h3>
|
||||
<% if @contest.is_public %>
|
||||
<span class="hw_icon_open fl ml5 mt3"></span>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<p class="sy_cgrey ">
|
||||
<span class=" mr15">管理员:<a class="sy_cblue" id="admin_num"><%= contest_managers(@contest).count %></a></span>
|
||||
<span class=" mr15">评委:<a class="sy_cblue" id="judge_num"><%= contest_judges(@contest).count %></a></span>
|
||||
<span class=" mr15">参赛者:<a class="sy_cblue" id="contestant_num"><%= contest_contestants(@contest).count %></a></span>
|
||||
</p>
|
||||
</div>
|
||||
<% if User.current.member_of_contest?(@contest) %>
|
||||
<% if @contest.contest_members.where(:user_id => User.current.id)[0].contest_member_roles.count == 2 %>
|
||||
<% if User.current.admin_of_contest?(@contest) %>
|
||||
<%= link_to '评委身份', switch_role_contest_path(@contest, :user_id => User.current.id, :curr_role => 13, :tar_role => 14), :class => "fr sy_btn_blue mt28 ml10", :title => "由管理员身份切换至评委身份" %>
|
||||
<% elsif User.current.judge_of_contest?(@contest) %>
|
||||
<%= link_to '管理员身份', switch_role_contest_path(@contest, :user_id => User.current.id, :curr_role => 14, :tar_role => 13), :class => "fr sy_btn_blue mt28 ml10", :title => "由评委身份切换至管理员身份" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% 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>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue