diff --git a/Gemfile b/Gemfile
index 7326febc3..854267ee8 100644
--- a/Gemfile
+++ b/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
diff --git a/app/assets/javascripts/contest_members.js.coffee b/app/assets/javascripts/contest_members.js.coffee
new file mode 100644
index 000000000..761567942
--- /dev/null
+++ b/app/assets/javascripts/contest_members.js.coffee
@@ -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/
diff --git a/app/assets/javascripts/contestant_works.js.coffee b/app/assets/javascripts/contestant_works.js.coffee
new file mode 100644
index 000000000..761567942
--- /dev/null
+++ b/app/assets/javascripts/contestant_works.js.coffee
@@ -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/
diff --git a/app/assets/javascripts/contestnotifications.js b/app/assets/javascripts/contestnotifications.js
deleted file mode 100644
index dee720fac..000000000
--- a/app/assets/javascripts/contestnotifications.js
+++ /dev/null
@@ -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.
diff --git a/app/assets/javascripts/contests.js.coffee b/app/assets/javascripts/contests.js.coffee
new file mode 100644
index 000000000..761567942
--- /dev/null
+++ b/app/assets/javascripts/contests.js.coffee
@@ -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/
diff --git a/app/assets/javascripts/works.js.coffee b/app/assets/javascripts/works.js.coffee
new file mode 100644
index 000000000..761567942
--- /dev/null
+++ b/app/assets/javascripts/works.js.coffee
@@ -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/
diff --git a/app/assets/stylesheets/contest_members.css.scss b/app/assets/stylesheets/contest_members.css.scss
new file mode 100644
index 000000000..ca038cd20
--- /dev/null
+++ b/app/assets/stylesheets/contest_members.css.scss
@@ -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/
diff --git a/app/assets/stylesheets/contestant_works.css.scss b/app/assets/stylesheets/contestant_works.css.scss
new file mode 100644
index 000000000..3c6e458c8
--- /dev/null
+++ b/app/assets/stylesheets/contestant_works.css.scss
@@ -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/
diff --git a/app/assets/stylesheets/contestnotifications.css b/app/assets/stylesheets/contestnotifications.css
deleted file mode 100644
index afad32db0..000000000
--- a/app/assets/stylesheets/contestnotifications.css
+++ /dev/null
@@ -1,4 +0,0 @@
-/*
- Place all the styles related to the matching controller here.
- They will automatically be included in application.css.
-*/
diff --git a/app/assets/stylesheets/contests.css.scss b/app/assets/stylesheets/contests.css.scss
new file mode 100644
index 000000000..f799aa9d3
--- /dev/null
+++ b/app/assets/stylesheets/contests.css.scss
@@ -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/
diff --git a/app/assets/stylesheets/works.css.scss b/app/assets/stylesheets/works.css.scss
new file mode 100644
index 000000000..8c84be8c4
--- /dev/null
+++ b/app/assets/stylesheets/works.css.scss
@@ -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/
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 4948d82df..21653b3e4 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -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
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 9226b904c..193dbd407 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -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]
diff --git a/app/controllers/contest_members_controller.rb b/app/controllers/contest_members_controller.rb
new file mode 100644
index 000000000..99c63bfe2
--- /dev/null
+++ b/app/controllers/contest_members_controller.rb
@@ -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
diff --git a/app/controllers/contest_notification_controller.rb b/app/controllers/contest_notification_controller.rb
deleted file mode 100644
index 2ae841ed0..000000000
--- a/app/controllers/contest_notification_controller.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class ContestNotificationController < ApplicationController
- layout 'contest_base'
- def show
- @notification = ContestNotification.find(params[:id])
- end
-end
diff --git a/app/controllers/contestant_works_controller.rb b/app/controllers/contestant_works_controller.rb
new file mode 100644
index 000000000..1c95d71e3
--- /dev/null
+++ b/app/controllers/contestant_works_controller.rb
@@ -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
diff --git a/app/controllers/contestnotifications_controller.rb b/app/controllers/contestnotifications_controller.rb
deleted file mode 100644
index 54ba33262..000000000
--- a/app/controllers/contestnotifications_controller.rb
+++ /dev/null
@@ -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
diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb
index d3edde756..c37cd9443 100644
--- a/app/controllers/contests_controller.rb
+++ b/app/controllers/contests_controller.rb
@@ -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{
((.|\s)*?) }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
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 540f4bdd3..8ff035cb1 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -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
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index aa037b8d5..87b021678 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -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
diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb
index 9f0fe41c8..3e3c338b4 100644
--- a/app/controllers/praise_tread_controller.rb
+++ b/app/controllers/praise_tread_controller.rb
@@ -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
diff --git a/app/controllers/shield_activities_controller.rb b/app/controllers/shield_activities_controller.rb
index b2d5191b3..633fe4e93 100644
--- a/app/controllers/shield_activities_controller.rb
+++ b/app/controllers/shield_activities_controller.rb
@@ -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
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 806a2e13b..92858d45b 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -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
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index d00aba4fa..490a21884 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index 2ce505e15..953848d84 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -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?
diff --git a/app/controllers/works_controller.rb b/app/controllers/works_controller.rb
new file mode 100644
index 000000000..01457bc00
--- /dev/null
+++ b/app/controllers/works_controller.rb
@@ -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
diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb
index d9a9e1def..15eccba1e 100644
--- a/app/controllers/zipdown_controller.rb
+++ b/app/controllers/zipdown_controller.rb
@@ -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?
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 0996150bc..0964f4041 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -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 += '挂起 '
+ elsif contest_work.work_status == 0
+ str += '未发布 '
+ 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 += '作品提交中 '
+ else
+ str += '作品补交中 '
+ 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
#添加对课程留言的支持
diff --git a/app/helpers/contest_members_helper.rb b/app/helpers/contest_members_helper.rb
new file mode 100644
index 000000000..2f3399d6f
--- /dev/null
+++ b/app/helpers/contest_members_helper.rb
@@ -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
diff --git a/app/helpers/contestant_works_helper.rb b/app/helpers/contestant_works_helper.rb
new file mode 100644
index 000000000..29f31455f
--- /dev/null
+++ b/app/helpers/contestant_works_helper.rb
@@ -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
diff --git a/app/helpers/contestnotifications_helper.rb b/app/helpers/contestnotifications_helper.rb
deleted file mode 100644
index ab17149d7..000000000
--- a/app/helpers/contestnotifications_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module ContestnotificationsHelper
-end
diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb
index 0bc3e5e73..948c5de80 100644
--- a/app/helpers/contests_helper.rb
+++ b/app/helpers/contests_helper.rb
@@ -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)
- # # #{l(:label_choose_reward)}
- # html = ''
- # courses.each do |course|
- # html << ""
- # html << course.name
- # html << " "
- # 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
\ No newline at end of file
+end
diff --git a/app/helpers/owner_type_helper.rb b/app/helpers/owner_type_helper.rb
index ead87f55a..6595c5656 100644
--- a/app/helpers/owner_type_helper.rb
+++ b/app/helpers/owner_type_helper.rb
@@ -11,4 +11,5 @@ module OwnerTypeHelper
SYLLABUS = 10
ArticleHomepage = 11
PROJECT = 12
+ CONTEST = 13
end
\ No newline at end of file
diff --git a/app/helpers/works_helper.rb b/app/helpers/works_helper.rb
new file mode 100644
index 000000000..ccb78c2b7
--- /dev/null
+++ b/app/helpers/works_helper.rb
@@ -0,0 +1,2 @@
+module WorksHelper
+end
diff --git a/app/models/applied_contest.rb b/app/models/applied_contest.rb
new file mode 100644
index 000000000..1e26211c9
--- /dev/null
+++ b/app/models/applied_contest.rb
@@ -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
diff --git a/app/models/contest.rb b/app/models/contest.rb
index 4fbd5441e..b4f36330d 100644
--- a/app/models/contest.rb
+++ b/app/models/contest.rb
@@ -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
diff --git a/app/models/contest_activity.rb b/app/models/contest_activity.rb
new file mode 100644
index 000000000..9bcfe223d
--- /dev/null
+++ b/app/models/contest_activity.rb
@@ -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
diff --git a/app/models/contest_member.rb b/app/models/contest_member.rb
new file mode 100644
index 000000000..49d6bd1b3
--- /dev/null
+++ b/app/models/contest_member.rb
@@ -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
diff --git a/app/models/contest_member_role.rb b/app/models/contest_member_role.rb
new file mode 100644
index 000000000..f7bab8b84
--- /dev/null
+++ b/app/models/contest_member_role.rb
@@ -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
diff --git a/app/models/contest_message.rb b/app/models/contest_message.rb
new file mode 100644
index 000000000..1f1ce43b5
--- /dev/null
+++ b/app/models/contest_message.rb
@@ -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
diff --git a/app/models/contest_notification.rb b/app/models/contest_notification.rb
deleted file mode 100644
index 71c448f65..000000000
--- a/app/models/contest_notification.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-class ContestNotification < ActiveRecord::Base
- attr_accessible :content, :title
- validates :title, length: {maximum: 30}
-
-
-end
diff --git a/app/models/contestant_for_contest.rb b/app/models/contestant_for_contest.rb
new file mode 100644
index 000000000..e751e47c4
--- /dev/null
+++ b/app/models/contestant_for_contest.rb
@@ -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
diff --git a/app/models/contestant_work.rb b/app/models/contestant_work.rb
new file mode 100644
index 000000000..3db9dd160
--- /dev/null
+++ b/app/models/contestant_work.rb
@@ -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
diff --git a/app/models/contestant_work_project.rb b/app/models/contestant_work_project.rb
new file mode 100644
index 000000000..71d53c532
--- /dev/null
+++ b/app/models/contestant_work_project.rb
@@ -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
diff --git a/app/models/contestant_work_score.rb b/app/models/contestant_work_score.rb
new file mode 100644
index 000000000..b051647a6
--- /dev/null
+++ b/app/models/contestant_work_score.rb
@@ -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
diff --git a/app/models/contesting_project.rb b/app/models/contesting_project.rb
deleted file mode 100644
index ced787cbd..000000000
--- a/app/models/contesting_project.rb
+++ /dev/null
@@ -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
diff --git a/app/models/contesting_softapplication.rb b/app/models/contesting_softapplication.rb
deleted file mode 100644
index f91c16f69..000000000
--- a/app/models/contesting_softapplication.rb
+++ /dev/null
@@ -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
diff --git a/app/models/contestnotification.rb b/app/models/contestnotification.rb
deleted file mode 100644
index fff861ab4..000000000
--- a/app/models/contestnotification.rb
+++ /dev/null
@@ -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
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index 58c597061..a80d9b425 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -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
diff --git a/app/models/message.rb b/app/models/message.rb
index a71cca6ec..312893415 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -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
diff --git a/app/models/news.rb b/app/models/news.rb
index b5a4c85e0..e06166494 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -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后删除对应的资源
diff --git a/app/models/principal.rb b/app/models/principal.rb
index 7c2b24587..81a39ec46 100644
--- a/app/models/principal.rb
+++ b/app/models/principal.rb
@@ -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)
diff --git a/app/models/role.rb b/app/models/role.rb
index f6a24a27f..233a54531 100644
--- a/app/models/role.rb
+++ b/app/models/role.rb
@@ -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
diff --git a/app/models/user.rb b/app/models/user.rb
index 6cf58be14..a564916e9 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -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)
diff --git a/app/models/work.rb b/app/models/work.rb
new file mode 100644
index 000000000..02c7b5a08
--- /dev/null
+++ b/app/models/work.rb
@@ -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
diff --git a/app/models/work_detail_group.rb b/app/models/work_detail_group.rb
new file mode 100644
index 000000000..df0563641
--- /dev/null
+++ b/app/models/work_detail_group.rb
@@ -0,0 +1,4 @@
+class WorkDetailGroup < ActiveRecord::Base
+ belongs_to :work
+ attr_accessible :base_on_project, :max_num, :min_num, :work_id
+end
diff --git a/app/services/contests_service.rb b/app/services/contests_service.rb
new file mode 100644
index 000000000..10f1bb7e1
--- /dev/null
+++ b/app/services/contests_service.rb
@@ -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
\ No newline at end of file
diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb
index 970fded22..a58c1a7e4 100644
--- a/app/views/comments/create.js.erb
+++ b/app/views/comments/create.js.erb
@@ -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 %>
diff --git a/app/views/comments/destroy.js.erb b/app/views/comments/destroy.js.erb
index 1df37cd43..acb93457c 100644
--- a/app/views/comments/destroy.js.erb
+++ b/app/views/comments/destroy.js.erb
@@ -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 %>
diff --git a/app/views/comments/reply.js.erb b/app/views/comments/reply.js.erb
index 1df37cd43..acb93457c 100644
--- a/app/views/comments/reply.js.erb
+++ b/app/views/comments/reply.js.erb
@@ -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 %>
diff --git a/app/views/contest_members/contest_member_autocomplete.js.erb b/app/views/contest_members/contest_member_autocomplete.js.erb
new file mode 100644
index 000000000..5d5fc54a1
--- /dev/null
+++ b/app/views/contest_members/contest_member_autocomplete.js.erb
@@ -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);
+}
\ No newline at end of file
diff --git a/app/views/contest_members/create.js.erb b/app/views/contest_members/create.js.erb
new file mode 100644
index 000000000..124339124
--- /dev/null
+++ b/app/views/contest_members/create.js.erb
@@ -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%>
diff --git a/app/views/contest_members/destroy.js.erb b/app/views/contest_members/destroy.js.erb
new file mode 100644
index 000000000..8df2dd685
--- /dev/null
+++ b/app/views/contest_members/destroy.js.erb
@@ -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();
\ No newline at end of file
diff --git a/app/views/contest_members/update.js.erb b/app/views/contest_members/update.js.erb
new file mode 100644
index 000000000..8df2dd685
--- /dev/null
+++ b/app/views/contest_members/update.js.erb
@@ -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();
\ No newline at end of file
diff --git a/app/views/contestant_works/_choose_group_member.html.erb b/app/views/contestant_works/_choose_group_member.html.erb
new file mode 100644
index 000000000..51ca02d7d
--- /dev/null
+++ b/app/views/contestant_works/_choose_group_member.html.erb
@@ -0,0 +1,125 @@
+<% if @contestwork.work_detail_group %>
+
+
+
请从<%= @contestwork.work_detail_group.base_on_project ? '项目成员':'竞赛成员' %>中添加小组成员
+
+
+
+
+
+
+
+
+
+ <%=User.current.show_name %>
+ <% unless User.current.user_extensions.student_id == "" %>
+ (<%=User.current.user_extensions.student_id %>)
+ <% end %>
+
+
+
+
+
+
+
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/contestant_works/_contest_evaluation_un_group.html.erb b/app/views/contestant_works/_contest_evaluation_un_group.html.erb
new file mode 100644
index 000000000..9e75e4132
--- /dev/null
+++ b/app/views/contestant_works/_contest_evaluation_un_group.html.erb
@@ -0,0 +1,9 @@
+
+ <% @stundet_works.each_with_index do |student_work, i| %>
+
+ <%= render :partial => 'contest_evaluation_un_group_work', :locals => {:student_work => student_work} %>
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_contest_evaluation_un_group_work.html.erb b/app/views/contestant_works/_contest_evaluation_un_group_work.html.erb
new file mode 100644
index 000000000..603d0e788
--- /dev/null
+++ b/app/views/contestant_works/_contest_evaluation_un_group_work.html.erb
@@ -0,0 +1,65 @@
+
+
+
+ <%= student_work.name %>
+
+ <% if student_work.work_status %>
+ <%= get_status student_work.work_status %>
+ <% end %>
+
+
+
+ <% if @contestwork.work_detail_group.base_on_project %>
+
+
关联项目:
+
+ <% 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 %>
+
<%= student_work.project.name %>
+ <% else %>
+
<%= student_work.project.name %>(已删除) <% end %>
+ <% project = student_work.project %>
+
+
+
+
+
<%= project.name %><%= project.status == 9 ? "(已删除)" : ""%>
+
+
+ 创建者:<%= project.creater %> 成员数量:<%= project.members.count %>
+ <% project_score = project.project_score %>
+
项目综合得分:<%= project.status == 9 ? 0 : static_project_score(project_score).to_i %>
+
+ <% if project.status != 9 %>
+
= 代码提交得分 + issue得分 + 资源得分 + 帖子得分
+
+
= <%= (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 %>
+ <% end %>
+
+
+
+ <% end %>
+
+
+
+
+
提交时间:<%= format_date(student_work.commit_time) %>
+
人数:<%=student_work.contestant_work_projects.count %>人
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_contest_evaluation_un_title.html.erb b/app/views/contestant_works/_contest_evaluation_un_title.html.erb
new file mode 100644
index 000000000..fe31d49f6
--- /dev/null
+++ b/app/views/contestant_works/_contest_evaluation_un_title.html.erb
@@ -0,0 +1,42 @@
+
+ <%# 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 %>
+
+ 序号
+
+
+ 姓名
+
+
+
+
+
+
+ 状态
+
+
+ 评委评分
+
+
+
+ 最终成绩
+
+
+ <%# end %>
+ <% @stundet_works.each_with_index do |student_work, i| %>
+ <% score_open = true %>
+
+ <%= render :partial => "contest_evaluation_un_work", :locals => {:student_work => student_work, :index => i, :score_open => score_open} %>
+
+
+
+
+
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_contest_evaluation_un_work.html.erb b/app/views/contestant_works/_contest_evaluation_un_work.html.erb
new file mode 100644
index 000000000..19896fa2c
--- /dev/null
+++ b/app/views/contestant_works/_contest_evaluation_un_work.html.erb
@@ -0,0 +1,37 @@
+
+ <%=index + 1 %>
+
+ <%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40",:style => "display:block;"),user_path(student_work.user), :target => '_blank') %>
+
+
+ <%= link_to student_work.user.show_name ,user_path(student_work.user), :target => '_blank' %>
+
+
+
+
+
+
+ <% if student_work.work_status%>
+ <%=get_status student_work.work_status %>
+ <% end %>
+
+
+ --
+
+
+
+ --
+
+
+
+<%# end %>
+
+
diff --git a/app/views/contestant_works/_contest_work_attachments_status.html.erb b/app/views/contestant_works/_contest_work_attachments_status.html.erb
new file mode 100644
index 000000000..7ea488ff7
--- /dev/null
+++ b/app/views/contestant_works/_contest_work_attachments_status.html.erb
@@ -0,0 +1,17 @@
+<% attachments.each_with_index do |attachment,i| %>
+
+
+
+ <%= link_to_short_attachment attachment,:length=> 58, :class => 'hidden link_file_a fl newsBlue mw360', :download => true -%>
+
+
+ <% 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 %>
+
(<%= number_to_human_size attachment.filesize %>)
+
+ <%= format_time(attachment.created_on) %>
+
+
+
+<% end -%>
\ No newline at end of file
diff --git a/app/views/contestant_works/_contestant_work_attachment.html.erb b/app/views/contestant_works/_contestant_work_attachment.html.erb
new file mode 100644
index 000000000..ae88d4565
--- /dev/null
+++ b/app/views/contestant_works/_contestant_work_attachment.html.erb
@@ -0,0 +1,56 @@
+
+
+ <% if defined?(container) && container && container.saved_attachments %>
+ <% container.attachments.each_with_index do |attachment, 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;") %>
+ <%= l(:field_is_public)%>:
+ <%= 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}" %>
+
+
+ <% end %>
+ <% container.saved_attachments.each_with_index do |attachment, 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;") %>
+ <%= l(:field_is_public)%>:
+ <%= 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}" %>
+
+
+ <% end %>
+ <% end %>
+
+ <%= 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)
+ } %>
+
+
+
+
+
+<% content_for :header_tags do %>
+ <%= javascript_include_tag 'attachments' %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/contestant_works/_contestant_work_list.html.erb b/app/views/contestant_works/_contestant_work_list.html.erb
new file mode 100644
index 000000000..af20fb1a7
--- /dev/null
+++ b/app/views/contestant_works/_contestant_work_list.html.erb
@@ -0,0 +1,55 @@
+
+
+ 作品
+
+ <% 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 %>
+
+ <%# 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) %>
+ 您尚未提交作品
+ <% 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?%>
+ 截止日期已过,已提交且不可修改
+ <% 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 %>
+ 组长已提交,组长还可修改
+ <% else %>
+ 您已提交,您还可以修改
+ <% end %>
+ <% end %>
+
+
+ <%# 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") %>
+
+
+
+ <%# end %>
+
+
+
+
+
+ <% if @contestwork.work_type != 3%>
+ <%= render :partial => "contest_evaluation_un_title"%>
+ <% else %>
+ <%= render :partial => "contest_evaluation_un_group"%>
+ <% end %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_has_commit_work.html.erb b/app/views/contestant_works/_has_commit_work.html.erb
new file mode 100644
index 000000000..bbfc6e042
--- /dev/null
+++ b/app/views/contestant_works/_has_commit_work.html.erb
@@ -0,0 +1,24 @@
+
+
+
您已提交过作品,请不要重复提交,如果想修改作品请点击编辑。
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_relate_project.html.erb b/app/views/contestant_works/_relate_project.html.erb
new file mode 100644
index 000000000..e28404f61
--- /dev/null
+++ b/app/views/contestant_works/_relate_project.html.erb
@@ -0,0 +1,63 @@
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_relate_projects.html.erb b/app/views/contestant_works/_relate_projects.html.erb
new file mode 100644
index 000000000..7cfc7ac0a
--- /dev/null
+++ b/app/views/contestant_works/_relate_projects.html.erb
@@ -0,0 +1,49 @@
+
+ <% 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)) %>
+
+
+ <% 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 %>
+
+ <% 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 %>
+ <%=project.name %>
+ <% else %>
+ <%=project.name %>
+ <% end %>
+
+
<%= project.is_public? ? '公开' : '私有' %>
+ <%# if is_change %>
+
+ <%# end %>
+ <%=link_to "
创建者:#{projectUser.show_name} ".html_safe, user_path(projectUser), :title => "#{projectUser.show_name}" %>
+
+
+
+
更新时间:<%= format_date(project.updated_on) %>
+
+
+ <%= link_to project.members.count, allow_visit ? member_project_path(project) : 'javascript:void(0)', :class => "c_blue" %>成员 |
+ <%= link_to project.project_score.issue_num, allow_visit ? project_issues_path(project) : 'javascript:void(0)', :class => "c_blue" %>问题 |
+ <%= 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" %>提交
+
+
+
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_show.html.erb b/app/views/contestant_works/_show.html.erb
new file mode 100644
index 000000000..910e4c95c
--- /dev/null
+++ b/app/views/contestant_works/_show.html.erb
@@ -0,0 +1,149 @@
+
+
+ <% 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 %>
+
+
+ 上交时间:
+ <%=format_time work.commit_time %>
+
+
+ <% if work.user == User.current && Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") %>
+
+
+ <%= link_to("", contestant_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del",:title=>"删除") %>
+
+
+ <%= link_to "",edit_contestant_work_path(work),:class => "pic_edit",:title => "修改"%>
+
+ <% end%>
+
+
+
+
+ <% if @contestwork.work_type == 3 && work.contestant_work_projects %>
+
+
+ 参与人员:
+ <%= 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 %>
+
+ <% if @contestwork.work_detail_group.base_on_project %>
+
+ 关联项目:
+ <% if work.project_id == 0 || work.project_id.nil? %>
+ 暂无
+ <% 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" )%>
+ (综合评分:<%=static_project_score(work.project.project_score).to_i %> )
+ <% else %>
+ <%=work.project.name %>
+ (综合评分:<%=static_project_score(work.project.project_score).to_i %> )
+ <% end %>
+ <%#= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%>
+
+ <% end %>
+ <% end%>
+
+
+ 内容:
+
+ <%= work.description.html_safe if work.description%>
+
+
+
+
+ 附件:
+ <% com_attachments = work.attachments.where("attachtype IS NULL OR attachtype <> 7") %>
+ <% if com_attachments.empty?%>
+ 尚未提交附件
+ <% else%>
+
+ <%= render :partial => 'contest_work_attachments_status', :locals => {:attachments => com_attachments, :status => 1} %>
+
+ <% end%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <% else %>
+
+
+
+
+
+
+
+
+
+
+
+ <% end %>
+
+
+
+
+
+
+
收起
+
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_work_edit_information.html.erb b/app/views/contestant_works/_work_edit_information.html.erb
new file mode 100644
index 000000000..3be9f2dae
--- /dev/null
+++ b/app/views/contestant_works/_work_edit_information.html.erb
@@ -0,0 +1,43 @@
+
+
+
请您确认刚刚上传的作品信息
+
+ 作品名称: <%=@student_work.name%>
+
+
+
作品描述:
+
<%=@student_work.description.html_safe %>
+
+
+
+ 附 件:
+ <% if @student_work.attachments.empty? %>
+ <%= "无附件"%>
+ <% else %>
+
+ <% @student_work.attachments.each_with_index do |attachment,i| %>
+
+ <%= 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)) %>
+
(<%= number_to_human_size attachment.filesize %>)
+
+
+ <% end -%>
+ <%#= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %>
+
+ <% end %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_work_information.html.erb b/app/views/contestant_works/_work_information.html.erb
new file mode 100644
index 000000000..a11bbbc9a
--- /dev/null
+++ b/app/views/contestant_works/_work_information.html.erb
@@ -0,0 +1,44 @@
+
+
+
请您确认刚刚上传的作品信息
+
+ 作品名称: <%=@student_work.name%>
+
+
+
作品描述:
+
<%=@student_work.description.html_safe %>
+
+
+
+ 附 件:
+ <% if @student_work.attachments.empty? %>
+ <%= "无附件"%>
+ <% else %>
+
+ <% @student_work.attachments.each_with_index do |attachment,i| %>
+
+ <%= 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)) %>
+
(<%= number_to_human_size attachment.filesize %>)
+
+
+ <% end -%>
+ <%#= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %>
+
+ <% end %>
+
+
+
+
+ 确 定
+
+ <%= link_to("重 试", retry_work_contestant_work_path(@student_work.id),:class => "tijiao",:style =>"margin-bottom: 15px;margin-top:15px;",:remote => true)%>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/_work_post_brief.html.erb b/app/views/contestant_works/_work_post_brief.html.erb
new file mode 100644
index 000000000..6beb5de6a
--- /dev/null
+++ b/app/views/contestant_works/_work_post_brief.html.erb
@@ -0,0 +1,66 @@
+
+ <%=link_to image_tag(url_to_avatar(homework.user),width:"50px", height: "50px"), user_activities_path(homework.user_id)%>
+
+
+
+ <%= link_to homework.user.show_name, user_activities_path(homework.user_id), :class => "newsBlue mr15"%>
+
+
+ <% index = get_work_index(homework, is_teacher) %>
+ <%= link_to "题目#{index + 1}: ".html_safe + homework.name,contestant_works_path(:work => homework.id),:class => "postGrey"%>
+
+ <%=get_cw_status(homework).html_safe %>
+
+ <% if homework.work_type == 3 && homework.work_detail_group.base_on_project %>
+
系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
+ <% elsif homework.work_type == 3 && !homework.work_detail_group.base_on_project%>
+
系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!
+ <% end %>
+
+ <% is_base_group = homework.work_type == 3 && (homework.work_detail_group.base_on_project || !(cur_user_works_for_work(homework).nil?)) && !is_teacher %>
+
+ <%= render :partial => 'users/work_opr', :locals => {:activity => homework, :is_teacher => is_teacher, :hw_status => 5, :user_activity_id => homework.id} %>
+ <% if is_base_group %>
+
+ <% end %>
+ <% if !homework.publish_time.nil? %>
+
+ <%= l(:label_publish_time)%>:<%= homework.publish_time%> 00:00
+
+ <% end %>
+ <% if !homework.end_time.nil? %>
+
提交截止时间:<%= homework.end_time.to_s %> 23:59
+ <% end %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => homework} %>
+
+
+ <%= render :partial => "users/contest_work_base_info", :locals =>{:activity => homework, :user_activity_id =>homework.id, :is_teacher => is_teacher, :hw_status => 5} %>
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/cancel_relate_project.js.erb b/app/views/contestant_works/cancel_relate_project.js.erb
new file mode 100644
index 000000000..fa235426c
--- /dev/null
+++ b/app/views/contestant_works/cancel_relate_project.js.erb
@@ -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 %>
\ No newline at end of file
diff --git a/app/views/contestant_works/create.js.erb b/app/views/contestant_works/create.js.erb
new file mode 100644
index 000000000..d636e788e
--- /dev/null
+++ b/app/views/contestant_works/create.js.erb
@@ -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("" +
+ " ");
+$('#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("" +
+ " ");
+$('#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)%>';
+}
\ No newline at end of file
diff --git a/app/views/contestant_works/edit.html.erb b/app/views/contestant_works/edit.html.erb
new file mode 100644
index 000000000..cc6c3e8b0
--- /dev/null
+++ b/app/views/contestant_works/edit.html.erb
@@ -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 %>
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/index.html.erb b/app/views/contestant_works/index.html.erb
new file mode 100644
index 000000000..d39a11503
--- /dev/null
+++ b/app/views/contestant_works/index.html.erb
@@ -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 %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contestant_works/new.html.erb b/app/views/contestant_works/new.html.erb
new file mode 100644
index 000000000..a807d64f7
--- /dev/null
+++ b/app/views/contestant_works/new.html.erb
@@ -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 %>
+
+
+
+
diff --git a/app/views/contestant_works/new_student_work_project.js.erb b/app/views/contestant_works/new_student_work_project.js.erb
new file mode 100644
index 000000000..8a6aecacd
--- /dev/null
+++ b/app/views/contestant_works/new_student_work_project.js.erb
@@ -0,0 +1,2 @@
+var htmlvalue = "<%= escape_javascript(render :partial => 'relate_project') %>";
+pop_box_new(htmlvalue, 400, 285);
\ No newline at end of file
diff --git a/app/views/contestant_works/retry_work.js.erb b/app/views/contestant_works/retry_work.js.erb
new file mode 100644
index 000000000..7d1f2936f
--- /dev/null
+++ b/app/views/contestant_works/retry_work.js.erb
@@ -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 %>");
\ No newline at end of file
diff --git a/app/views/contestant_works/search_contest_students.js.erb b/app/views/contestant_works/search_contest_students.js.erb
new file mode 100644
index 000000000..a99f5887d
--- /dev/null
+++ b/app/views/contestant_works/search_contest_students.js.erb
@@ -0,0 +1,42 @@
+$("#all_students_list").empty();
+<% @users.each do |user|%>
+var link = "<%=user.show_name %>";
+<% unless user.user_extensions.student_id == "" %>
+link += "(<%=user.user_extensions.student_id %>)";
+<% end %>
+link += " ";
+$("#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
+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 += " onclick='delete_student(<%=user.id %>);'";
+ <% end %>
+ li += ">" + $("#student_<%=user.id %>").html()+" ";
+ $("#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 %>
\ No newline at end of file
diff --git a/app/views/contestant_works/show.js.erb b/app/views/contestant_works/show.js.erb
new file mode 100644
index 000000000..840573201
--- /dev/null
+++ b/app/views/contestant_works/show.js.erb
@@ -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'});
+}
\ No newline at end of file
diff --git a/app/views/contestant_works/student_work_project.js.erb b/app/views/contestant_works/student_work_project.js.erb
new file mode 100644
index 000000000..d107a764a
--- /dev/null
+++ b/app/views/contestant_works/student_work_project.js.erb
@@ -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 %>
\ No newline at end of file
diff --git a/app/views/contestant_works/update.js.erb b/app/views/contestant_works/update.js.erb
new file mode 100644
index 000000000..228b8bb65
--- /dev/null
+++ b/app/views/contestant_works/update.js.erb
@@ -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("" +
+ " ");
+$('#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) %>"
+}
\ No newline at end of file
diff --git a/app/views/contestnotifications/_form.html.erb b/app/views/contestnotifications/_form.html.erb
deleted file mode 100644
index 680ab93d1..000000000
--- a/app/views/contestnotifications/_form.html.erb
+++ /dev/null
@@ -1,77 +0,0 @@
-<%= error_messages_for @contestnotifications %>
-
-
-
- <%= f.text_field :title,
- :required => true,
- :size => 60,
- :maxlength => 60,
- :style => "width:488px;",
- :onkeyup => "regexTitle();"
- %>
-
-
-
- <%= f.text_area :description,
- :required => true,
- :cols => 60,
- :rows => 11,
- :class => 'wiki-edit',
- :style => "width:490px;",
- :onkeyup => "regexDescription();"
- %>
-
-
-
-
-<%= wikitoolbar_for 'news_description' %>
diff --git a/app/views/contestnotifications/_news.html.erb b/app/views/contestnotifications/_news.html.erb
deleted file mode 100644
index c8af85cf4..000000000
--- a/app/views/contestnotifications/_news.html.erb
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- <%=link_to contestnotifications.author,
- contest_contestnotification_path(contestnotifications)
- %>
-
-
- <%= l(:label_project_newshare) %>
-
- <%= link_to h(contestnotifications.title),
- contest_contestnotification_path(contestnotifications)
- %>
-
-
-
-
-
- <%=h contestnotifications.description%>
-
-
-
-
-
-
- <%= contestnotifications.created_at %>
-
-
-
- <%= link_to l(:label_project_newother),
- contest_contestnotification_path(contestnotifications)
- %>
- <%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count > 0 %>
-
-
-
-
-
diff --git a/app/views/contestnotifications/edit.html.erb b/app/views/contestnotifications/edit.html.erb
deleted file mode 100644
index 53536aaaf..000000000
--- a/app/views/contestnotifications/edit.html.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-<%=l(:label_edit_contest_notice)%>
-
-<%= 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 %>
-
-
-<% content_for :header_tags do %>
- <%= stylesheet_link_tag 'scm' %>
-<% end %>
\ No newline at end of file
diff --git a/app/views/contestnotifications/index.api.rsb b/app/views/contestnotifications/index.api.rsb
deleted file mode 100644
index 6509d2915..000000000
--- a/app/views/contestnotifications/index.api.rsb
+++ /dev/null
@@ -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
diff --git a/app/views/contestnotifications/index.html.erb b/app/views/contestnotifications/index.html.erb
deleted file mode 100644
index cf7ebe508..000000000
--- a/app/views/contestnotifications/index.html.erb
+++ /dev/null
@@ -1,151 +0,0 @@
-
-
-
- <%= l(:label_notification) %>
-
-<% 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 %>
-
-
-<% end %>
-
-
-
-
- <%= image_tag(url_to_avatar(@contest.author), :class => "avatar")%>
-
-
-
- <%= render :partial => "/praise_tread/praise_tread",
- :locals => {:obj => @contest,
- :show_flag => true,
- :user_id =>User.current.id,
- :horizontal => false}
- %>
-
-
- <%= link_to(@contest.author.lastname+@contest.author.firstname,
- user_path(@contest.author))%>
- :<%= @contest.name %>
-
-
-
- <%= l(:label_bids_reward_method) %>
-
- <%= @contest.budget%>
-
-
-
-
- <%= @contest.description %>
-
-
-
-
-
-
-
- <% @contestnotificationss.each do |contestnotifications| %>
-
-
-
- <%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %>
-
-
-
-
-
-
-
- <%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %>
-
-
- <%= l(:label_project_notice) %>
-
-
- <%= link_to h(contestnotifications.title), contest_contestnotification_path(@contest, contestnotifications) %>
-
-
- <%= 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?) %>
-
-
-
-
-
-
- <%= textilizable(contestnotifications, :description) %>
-
-
-
-
-
- <%= l :label_update_time %>
-
- <%= format_time(contestnotifications.created_at) %>
-
-
-
- <%= link_to l(:label_check_comment), contest_contestnotification_path(@contest, contestnotifications) %>
-
-
-
-
-
-
- <% end %>
-
-
-
-
-
-
- <% 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)) -%>
-
-
-
-
-
\ No newline at end of file
diff --git a/app/views/contestnotifications/new.html.erb b/app/views/contestnotifications/new.html.erb
deleted file mode 100644
index 310a68d77..000000000
--- a/app/views/contestnotifications/new.html.erb
+++ /dev/null
@@ -1,17 +0,0 @@
-
-<%= labelled_form_for @contestnotification,
- :url => contest_contestnotifications_path(@contest),
- :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %>
- <%= render :partial => 'contestnotifications/form', :locals => { :f => f } %>
-
- <%= link_to l(:button_cancel), contest_contestnotifications_path(@contest.id) %>
-<% end %>
-
diff --git a/app/views/contestnotifications/show.html.erb b/app/views/contestnotifications/show.html.erb
deleted file mode 100644
index 47cdd3a86..000000000
--- a/app/views/contestnotifications/show.html.erb
+++ /dev/null
@@ -1,144 +0,0 @@
-
-
- <%= 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?) %>
-
-
-<%=h @contestnotification.title %>
-
-
- <%= 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 %>
-
-
-
-
-
-
diff --git a/app/views/contests/_boards.html.erb b/app/views/contests/_boards.html.erb
new file mode 100644
index 000000000..e8155e5ff
--- /dev/null
+++ b/app/views/contests/_boards.html.erb
@@ -0,0 +1,40 @@
+
\ No newline at end of file
diff --git a/app/views/contests/_contest_activity.html.erb b/app/views/contests/_contest_activity.html.erb
new file mode 100644
index 000000000..9e496bcd0
--- /dev/null
+++ b/app/views/contests/_contest_activity.html.erb
@@ -0,0 +1,63 @@
+<%= content_for(:header_tags) do %>
+ <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
+<% end %>
+
+
+<% contest_activities.includes(:contest_act).each do |activity| if contest_activities %>
+
+ <% 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 %>
+
+ <%= 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 %>
diff --git a/app/views/contests/_contest_base_info.html.erb b/app/views/contests/_contest_base_info.html.erb
new file mode 100644
index 000000000..226f1406f
--- /dev/null
+++ b/app/views/contests/_contest_base_info.html.erb
@@ -0,0 +1,38 @@
+
+ <%= link_to @contest.user.try(:show_name), user_path(@contest.user), :class => "sy_cgrey" %>
+ >
+ <%= link_to @contest.name, contest_path(@contest), :class => "sy_cgrey" %>
+
+<% if User.current.admin_of_contest?(@contest) %>
+ <%= render :partial => "contests/mamager_setting" %>
+<% end %>
+
+
+
+
+<% 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 %>
+ 邀请码:<%= @contest.invite_code %>
+
\ No newline at end of file
diff --git a/app/views/contests/_contest_jours.html.erb b/app/views/contests/_contest_jours.html.erb
deleted file mode 100644
index 54a7f14a7..000000000
--- a/app/views/contests/_contest_jours.html.erb
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
留言内容
- <%= render :partial => 'new', :locals => {:contest => @contest, :sta => @state} %>
-
-
-
-
-
- <%= render :partial => 'history',:locals => { :contest => @contest, :journals => @jour, :state => false} %>
-
-
-
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
-
\ No newline at end of file
diff --git a/app/views/contests/_contest_list.html.erb b/app/views/contests/_contest_list.html.erb
deleted file mode 100644
index 26035aa29..000000000
--- a/app/views/contests/_contest_list.html.erb
+++ /dev/null
@@ -1,118 +0,0 @@
-
-<% contests.each do |contest|%>
-
-
-
- <% unless contest.author.nil? %>
- <%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'),
- user_path(contest.author),
- :class => "avatar")
- %>
- <% end %>
-
-
-
-
-
- <% unless contest.author.nil? %>
- <%= link_to(contest.author,
- user_path(contest.author),
- :class => 'bid_user')
- %>:
- <% end %>
- <%= link_to(contest.name,
- contest_contestnotifications_path(contest),
- :class => 'bid_path',
- :target => "_blank") %>
-
-
-
-
-
-
- <%= l(:label_contests_reward_method) %>:
-
- <%= contest.budget%>
-
-
-
-
-
-
-
-
-
- <% if contest.id == 2 || contest.id == 3 || contest.id == 6 %>
- <%= l(:label_contest_work,
- :count => contest.contesting_projects.count)
- %>
- (
-
- <%= link_to(contest.projects.where('is_public=1').count,
- show_attendingcontest_contest_path(contest),
- :target => "_blank")
- %>
-
- )
- <% else %>
- <%= l(:label_contest_work,
- :count => contest.contesting_softapplications.count)
- %>
- (
-
- <%= link_to(contest.contesting_softapplications.count,
- show_attendingcontest_contest_path(contest),
- :target => "_blank") %>
-
- )
- <% end %>
-
-
-
-
-
-
- <%= l :label_create_time %>: <%= format_time contest.created_on %>
-
-
-
-
-
-
-
-
-
-
-
-<% end %>
-
-
diff --git a/app/views/contests/_contest_member.html.erb b/app/views/contests/_contest_member.html.erb
new file mode 100644
index 000000000..e1ec48b48
--- /dev/null
+++ b/app/views/contests/_contest_member.html.erb
@@ -0,0 +1,107 @@
+
+
+
+ 序号
+ 用户
+ 角色
+ 操作
+
+
+
+ <% @members.each_with_index do |member, index| %>
+
+ <%= index + 1 %>
+
+ <%= link_to member.user.show_name, user_path(member.user), :class => "pro_new_idname", :title => "#{member.user.show_name}" %>
+
+
+ <%= zh_contest_role(h member.roles.sort.collect(&:to_s).join(', ')) %>
+ <%= form_for(member, {:as => :membership, :remote => true, :url => contest_member_path(member),
+ :method => :put,
+ :html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
+ ) do |f| %>
+
+ <% end %>
+
+
+ <% if User.current.admin_of_contest?(@contest) %>
+ 编辑
+ 保存
+ 取消
+ <% unless member.user == @contest.user %>
+ <%= delete_link contest_member_path(member),
+ :remote => true,
+ :class => "sy_btn_grey mr5",
+ :id => "delete_member_#{member.id}",
+ :data => ({confirm: l(:label_delete_confirm)}) %>
+ <% end %>
+ <% end%>
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/contests/_edit.html.erb b/app/views/contests/_edit.html.erb
new file mode 100644
index 000000000..ad6f2dcc0
--- /dev/null
+++ b/app/views/contests/_edit.html.erb
@@ -0,0 +1,70 @@
+<%= content_for(:header_tags) do %>
+ <%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
+<% end %>
+
+
+ <%= labelled_form_for @contest do |f| %>
+
+
+ * 竞赛名称 :
+
+ 竞赛名称不能为空!
+
+
+ 竞赛介绍 :
+ <%= f.kindeditor :description, :editor_id => 'contest_setting_editor',
+ :owner_id => @contest.nil? ? 0: @contest.id,
+ :owner_type => OwnerTypeHelper::CONTEST,
+ :width => '84%',
+ :height => 300,
+ :minHeight=> 300,
+ :class => 'fl ml5 w690',
+ :input_html => { :id => 'contest_description',
+ :class => 'courses_text fl',
+ :maxlength => 5000 }
+ %>
+
+
+
+ <%= render :partial => 'attachments/form_course', :locals => {:container => @contest, :isReply => false} %>
+
+
+
+
+
+ 公开 :
+ >
+ (选中后对所有用户可见,否则仅对成员可见。)
+
+
+
+
+ 保存
+ 取消
+
+
+ <% end %>
+
+
+
diff --git a/app/views/contests/_form_contest.html.erb b/app/views/contests/_form_contest.html.erb
deleted file mode 100644
index 0b9f1469d..000000000
--- a/app/views/contests/_form_contest.html.erb
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-<%= error_messages_for 'contest' %>
-
-
- <%= l(:label_bids_form_contest_new_description) %>
-
-
- <%= f.text_field :name,
- :required => true,
- :size => 60,
- :style => "width:490px;",
- :maxlength => Contest::NAME_LENGTH_LIMIT,
- :placeholder => "#{l(:label_contest_name)}"
- %>
-
-
-
- <%= f.text_area :description,
- :size => 60,
- :rows => 4,
- :style => "width:490px;",
- :maxlength => Contest::DESCRIPTION_LENGTH_LIMIT,
- :placeholder => "#{l(:label_contest_description)}"
- %>
-
-
-
- <%= f.text_field :password,
- :size => 60,
- :rows => 4,
- :style => "width:490px;"
- %>
-
-
-
- <%= f.text_area :budget,
- :required => true,
- :size => 60,
- :rows => 4,
- :maxlength => Contest::DESCRIPTION_LENGTH_LIMIT,
- :style => "width:490px;",
- :placeholder => l(:label_bids_reward_what)
- %>
-
-
-
-
-
- <%= f.text_field :deadline,
- :required => true,
- :size => 60,
- :style => "width:150px;float:left;",
- :readonly => true,
- :placeholder => "#{l(:label_deadline)}"
- %>
- <%= calendar_for('contest_deadline')%>
-
diff --git a/app/views/contests/_history.html.erb b/app/views/contests/_history.html.erb
deleted file mode 100644
index 1115b81b0..000000000
--- a/app/views/contests/_history.html.erb
+++ /dev/null
@@ -1,63 +0,0 @@
-<% reply_allow = JournalsForMessage.create_by_user? User.current %>
-
-
-
- <% if journals.size > 0 %>
- <% for journal in journals %>
-
-
-
-
-
-
<%= link_to journal.user, user_path(journal.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%> <%= format_time(journal.created_on) %>
-
-
<%= textilizable journal.notes%>
-
-
-
- <% ids = 'project_respond_form_'+ journal.id.to_s%>
- <% if reply_allow %>
-
- <%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal,:show_name => true} %>
-
- <% end %>
-
-
- <%= render :partial => "words/journal_reply", :locals => {:journal => journal, :show_name => true} %>
-
-
-
-
- <% end %>
- <% end %>
-
-
-
-
-
-
-
diff --git a/app/views/contests/_join_contest_box.html.erb b/app/views/contests/_join_contest_box.html.erb
new file mode 100644
index 000000000..40161d03d
--- /dev/null
+++ b/app/views/contests/_join_contest_box.html.erb
@@ -0,0 +1,77 @@
+
+
\ No newline at end of file
diff --git a/app/views/contests/_list_projects.html.erb b/app/views/contests/_list_projects.html.erb
deleted file mode 100644
index 2ffecff12..000000000
--- a/app/views/contests/_list_projects.html.erb
+++ /dev/null
@@ -1,109 +0,0 @@
-
-<% contesting_project.each do |c_project|%>
- <% if c_project.project %>
-
-
-
-
-
-
-
- <%= image_tag(url_to_avatar(c_project.project), :class => 'avatar3') %>
-
-
-
-
-
-
-
- <%= link_to(c_project.project.name, project_path(c_project.project)) %>
-
- <%= l(:label_joined_contest)%>
-
-
-
-
-
-
-
- <%= l(:label_system_grade) %>:
- <%= (c_project.project.project_status.nil? ? 0.0 : c_project.project.project_status.grade) unless (c_project.project.project_status.nil? && c_project.project.nil?) %>
- <% if get_prize(c_project).nil? || get_prize(c_project) == "" %>
- <% if @contest.deadline < Date.today %>
- <%= l(:label_noawards)%>
- <% end %>
- <% else %>
-
- <% case get_prize(c_project) %>
- <% when '-1' %>
- <%= image_tag("/images/bid/special_reward.png")%>
- <% when '0' %>
- <%= image_tag("/images/bid/first_reward.png")%>
- <% when '1' %>
- <%= image_tag("/images/bid/second_reward.png")%>
- <% when '2' %>
- <%= image_tag("/images/bid/third_reward.png")%>
- <% when '3' %>
- <%= image_tag("/images/bid/forth_reward.png")%>
- <% when '4' %>
- <%= image_tag("/images/bid/fifth_reward.png")%>
- <% when '5' %>
- <%= image_tag("/images/bid/qualified.png")%>
- <% end %>
- <% end %>
-
-
-
-
-
-
-
- <%= c_project.project.description %>
-
-
-
-
- <%= format_time c_project.created_at%>
-
-
-
-
-
-
-
-
-
-
-
- <%= l(:label_contest_user) %>
- <% unless c_project.user.nil? %>
-
- <%= link_to c_project.user.lastname + c_project.user.firstname,
- user_path(c_project.user)
- %>
- <% end %>
-
-
-
-
-
-
-
- <%= l(:label_contest_reason) %>
- <%= c_project.description %>
-
-
-
-
-
-
-
-
-
-
- <% end %>
-<% end %>
-
-
diff --git a/app/views/contests/_list_softapplications.html.erb b/app/views/contests/_list_softapplications.html.erb
deleted file mode 100644
index 40a6f1cb2..000000000
--- a/app/views/contests/_list_softapplications.html.erb
+++ /dev/null
@@ -1,40 +0,0 @@
-
-<% contesting_softapplication.each do |c_softapplication|%>
- <% if c_softapplication.softapplication %>
-
-
-
- <%=l(:label_softapplication)%>:
-
- <%= link_to(c_softapplication.softapplication.name,
- softapplication_path(c_softapplication.softapplication),
- :target => '_blank')
- %>
-
-
-
-
-
- <%=l(:label_profile)%>:
-
- <%= c_softapplication.softapplication.description.truncate(90, omission: '...') %>
-
-
-
-
-
- <%=l(:label_activity_time)%>:
-
- <%=format_time c_softapplication.created_at %>
-
-
-
-
-
- <% end %>
-
-<% end %>
-
-
diff --git a/app/views/contests/_mamager_setting.html.erb b/app/views/contests/_mamager_setting.html.erb
new file mode 100644
index 000000000..c16696f75
--- /dev/null
+++ b/app/views/contests/_mamager_setting.html.erb
@@ -0,0 +1,12 @@
+
+
+
+
+ <%= link_to !@contest.is_public ? "设为公开" : "设为私有", {:controller => 'contests', :action => 'private_or_public', :id => @contest},:remote=>true,:confirm=>"您确定要设置为"+(!@contest.is_public ? "公开" : "私有")+"吗", :class => "postOptionLink" %>
+
+ <%= link_to "配置", {:controller => 'contests', :action => 'settings', :id => @contest}, :class => "postOptionLink" %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contests/_members.html.erb b/app/views/contests/_members.html.erb
new file mode 100644
index 000000000..aeefcfc79
--- /dev/null
+++ b/app/views/contests/_members.html.erb
@@ -0,0 +1,75 @@
+
+
添加成员
+
+
+ <%= form_tag url_for(:controller => 'contest_members', :action => 'create', :contest => @contest.id),:id => 'contest_member_add_form', :remote => true do |f|%>
+
+
+ <%= javascript_tag "observeSearchfield('principal_search', null, '#{escape_javascript "/contest_members/contest_member_autocomplete?" + {:contest => @contest.id}.to_query }')" %>
+
+
+ <%= find_user_not_in_current_contest_by_name(@contest) %>
+
+
+
+
取消
+
保存
+ <% end %>
+
+
+
+ <%= render :partial => 'contests/contest_member' %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contests/_new.html.erb b/app/views/contests/_new.html.erb
deleted file mode 100644
index 2a88a7f46..000000000
--- a/app/views/contests/_new.html.erb
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
- <%= form_for('contest_message',
- :remote => true, :method => :post,
- :url => {:controller => 'contests',
- :action => 'create',
- :id => contest,
- :sta => sta}
- ) do |f|%>
-
-
- <%= render :partial => 'pre_show', :locals => {:content => @content} %>
-
-
- <% if User.current.logged? %>
-
- <%= f.text_area 'message',
- :rows => 3,
- :cols => 65,
- :placeholder => l(:label_my_respond),
- :style => "resize: none; width: 98%",
- :class => 'noline',
- :maxlength => 250
- %>
-
- <%= f.text_field :reference_user_id, :style=>"display:none"%>
- <%= submit_tag l(:button_leave_meassge), :name => nil , :class => "enterprise" , :style => "display: block; float: right; margin-right: 1%; margin-top: 1px;"%>
- <% else %>
-
- <%= l(:label_user_login_tips) %>
- <%= link_to l(:label_user_login_new), signin_path %>
-
- <% end %>
- <% end %>
-
-
\ No newline at end of file
diff --git a/app/views/contests/_new_join.html.erb b/app/views/contests/_new_join.html.erb
deleted file mode 100644
index fc638d218..000000000
--- a/app/views/contests/_new_join.html.erb
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-<%=l(:label_please_input_password)%>
-
-<%= form_tag( join_in_contest_contests_path(id: contest.id),
- :remote => true,
- :method => :post,
- :id => 'new-watcher-form') do %>
-
-
-
-
-
- <%= text_field_tag 'contest_password', nil, :size => 45 %>
-
-
- <%= submit_tag l(:label_new_join),
- :name => nil, :class => "contest_btn",
- :onclick => "hideModal(this);"
- %>
- <%= submit_tag l(:button_cancel),
- :name => nil,
- :class => "contest_btn",
- :onclick => "hideModal(this);",
- :type => 'button'
- %>
-
-
-
-<% end %>
diff --git a/app/views/contests/_new_softapplication.html.erb b/app/views/contests/_new_softapplication.html.erb
deleted file mode 100644
index 3bba3db41..000000000
--- a/app/views/contests/_new_softapplication.html.erb
+++ /dev/null
@@ -1,228 +0,0 @@
-<%#= error_messages_for 'softapplication' %>
-
-
-
-<%= form_for Softapplication.new, :url => softapplications_path do |f| %>
-
- <%= hidden_field_tag 'contest_id', @contest.id %>
-
- <%= l(:label_work_name) %>
- * :
-
- <%= f.text_field :name,
- :required => true,
- :size => 60,
- :style => "width:320px;",
- :onkeyup => "regexName();"
- %>
-
- (<%= l(:label_workname_lengthlimit) %>)
-
-
-
-
-
-
-
-
-
- <%= l(:label_work_description) %>
- *
- :
-
-
- <%= f.text_area :description,
- :required => true,
- :size => 60,
- :rows => 3,
- :onkeyup => 'regexDescription();',
- :style => "width:320px; "
- %>
- (<%= l(:label_work_description_lengthlimit) %>)
-
-
-
-
-
-
-
-
- <%= l(:label_softapplication_developers) %>
- * :
-
- <%= f.text_field :application_developers,
- :required => true,
- :size => 60,
- :style => "width:320px;",
- :onkeyup => 'regexDevelopers();'
- %>
-
-
- (<%= l(:label_workdescription_lengthlimit) %>)
-
-
-
-
-
-
-
- <%= l(:label_work_deposit_project) %>:
-
- <%= select_tag 'project',
- options_for_select(select_option_helper(@option)),
- :name => 'project',
- :class => 'grayline2',
- :style => "width:328px;"
- %>
-
-
-
-
- <%= link_to l(:label_create_new_projects),
- new_project_path(:course => 0, :project_type => 0, :host => Setting.host_name),
- :target => '_blank'
- %>
-
-
-
-
-
-
-
-
-
- <%= l(:label_upload_softworkpacket_photo) %>
-
- <%#= render_flash_messages %>
-
- <%= render :partial => 'attachments/form' %>
-
-
-
- 1、<%= l(:label_upload_softapplication_packets_mustpacketed) %>
-
- 2、<%= l(:label_upload_softapplication_photo_condition) %>
-
-
-
-
-
-
- <%#= submit_tag l(:button_create) %>
- <%= 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'" %>
-
-<% end %>
\ No newline at end of file
diff --git a/app/views/contests/_pre_show.html.erb b/app/views/contests/_pre_show.html.erb
deleted file mode 100644
index 67ceeb356..000000000
--- a/app/views/contests/_pre_show.html.erb
+++ /dev/null
@@ -1,18 +0,0 @@
-
-<% unless content.nil?%>
-
-
- <%= textilizable content %>
-
-
-
- <%= hidden_field_tag 'reference_content',
- params[:reference_content],
- :value => content
- %>
-
-
-
-<% end %>
-
-
diff --git a/app/views/contests/_project_list.html.erb b/app/views/contests/_project_list.html.erb
deleted file mode 100644
index 33e884020..000000000
--- a/app/views/contests/_project_list.html.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-
-<%= render_flash_messages %>
-
-
-
- <%= l(:label_bidding_project) %>(<%= contesting_project.count%>)
-
- <% if User.current.logged? %>
-
-
- <%= toggle_link l(:button_contesting_as_project), 'put-bid-form' %>
-
-
- <% end %>
-
-
-<%= render :partial=> "list_projects",
- :locals => {:contesting_project => contesting_project,:contest => @contest }
-%>
diff --git a/app/views/contests/_set_join.js.erb b/app/views/contests/_set_join.js.erb
deleted file mode 100644
index d06f773d1..000000000
--- a/app/views/contests/_set_join.js.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-$("#<%=object_id%>").replaceWith('<%= escape_javascript join_in_competition(@contest, user) %>');
-<% if @state %>
-// modified by longjun 去掉中文,引用zh.yml中的标签
- <% if @state == 0 %>
- alert(<%= l(:notice_successful_join) %>)
- <% else %>
- alert(<%= l(:notice_account_wrong_password) %>)
- <% end %>
-<% end %>
\ No newline at end of file
diff --git a/app/views/contests/_softapplication_list.html.erb b/app/views/contests/_softapplication_list.html.erb
deleted file mode 100644
index d93923d72..000000000
--- a/app/views/contests/_softapplication_list.html.erb
+++ /dev/null
@@ -1,24 +0,0 @@
-
-<%= render_flash_messages %>
-
-
-
- <%= l(:label_contest_softapplication) %>
- (<%= @contest.contesting_softapplications.count%>)
-
- <% if User.current.logged? %>
-
-
-
- <%= link_to l(:button_contesting_as_application),
- "javascript:void(0);",
- onclick: "$('#put-bid-form').toggle();"
- %>
-
-
- <% end %>
-
-<%= render :partial=> "list_softapplications",
- :locals => {:contesting_softapplication => contesting_softapplication,
- :contest => @contest }
-%>
diff --git a/app/views/contests/add.js.erb b/app/views/contests/add.js.erb
deleted file mode 100644
index 0706d0c56..000000000
--- a/app/views/contests/add.js.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-$('#contesting_project_list').html('<%= escape_javascript(render(:partial => 'project_list', :locals => {:contesting_project => @contesting_project})) %>');
-$("#project_id").val("<%= l(:label_please_select_project) %>");
-$("#contest_message").val( "<%= l(:label_bid_reason) %>" );
-$("#put-bid-form").hide();
\ No newline at end of file
diff --git a/app/views/contests/add_softapplication.js.erb b/app/views/contests/add_softapplication.js.erb
deleted file mode 100644
index dfe774100..000000000
--- a/app/views/contests/add_softapplication.js.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-$('#contesting_softapplication_list').html('<%= escape_javascript(render(:partial => 'softapplication_list', :locals => {:contesting_softapplication => @contesting_softapplication})) %>');
-$("#softapplication_id").val("<%= l(:label_please_select_contestingsoftapplication) %>");
-$("#contest_message").val( "<%= l(:label_bid_reason) %>" );
-$("#put-bid-form").hide();
\ No newline at end of file
diff --git a/app/views/contests/back.js.erb b/app/views/contests/back.js.erb
deleted file mode 100644
index d806c1481..000000000
--- a/app/views/contests/back.js.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-$('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:contest => @contest, :journals => @jour, :state => @state})) %>');
-$('#contest_message_reference_user_id').val("");
\ No newline at end of file
diff --git a/app/views/contests/contest_activities.html.erb b/app/views/contests/contest_activities.html.erb
new file mode 100644
index 000000000..564e54dfb
--- /dev/null
+++ b/app/views/contests/contest_activities.html.erb
@@ -0,0 +1,24 @@
+
\ No newline at end of file
diff --git a/app/views/contests/contest_activities.js.erb b/app/views/contests/contest_activities.js.erb
new file mode 100644
index 000000000..3b479d518
--- /dev/null
+++ b/app/views/contests/contest_activities.js.erb
@@ -0,0 +1 @@
+$("#show_more_course_activities").replaceWith("<%= escape_javascript( render :partial => 'contests/contest_activity',:locals => {:contest_activities => @contest_activities, :page => @page,:type => @type} )%>");
diff --git a/app/views/contests/create.js.erb b/app/views/contests/create.js.erb
deleted file mode 100644
index 9246d939c..000000000
--- a/app/views/contests/create.js.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-$('#history').html('<%= escape_javascript(render(:partial => 'contests/history', :locals => {:contest => @contest, :journals => @jour, :state => true})) %>');
-$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>');
-$('#contest_message_message').val("");
-$('#contest_message_reference_user_id').val("");
diff --git a/app/views/contests/dealwith_apply_request.js.erb b/app/views/contests/dealwith_apply_request.js.erb
new file mode 100644
index 000000000..9320f7e8b
--- /dev/null
+++ b/app/views/contests/dealwith_apply_request.js.erb
@@ -0,0 +1 @@
+$("#contest_message_join_<%=@msg.id %>").html('<%= escape_javascript(render :partial => 'users/join_contest_applied_message', :locals => {:ma => @msg}) %>');
\ No newline at end of file
diff --git a/app/views/contests/destroy.js.erb b/app/views/contests/destroy.js.erb
deleted file mode 100644
index a2f0fb2da..000000000
--- a/app/views/contests/destroy.js.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-$('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:contest => @contest, :journals => @jour, :state => false})) %>');
-$('#contest_message_reference_user_id').val("");
\ No newline at end of file
diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb
deleted file mode 100644
index 26e9e2114..000000000
--- a/app/views/contests/index.html.erb
+++ /dev/null
@@ -1,79 +0,0 @@
-
- <%= form_tag({:controller => 'contests', :action => 'index'}, :method => :get, :id => 'contests_serch') do %>
-
-
-
-
- <%=l(:label_contest_innovate_community)%>
-
-
-
- <%= l(:label_user_location) %> :
-
-
- <% if User.current.logged? %>
- <% unless User.current.user_extensions.identity == 1 %>
- <%= link_to(l(:label_newtype_contest), new_contest_contests_path, :class => 'icon icon-add', :target => "_blank") %>
-
- <% end %>
- <% end %>
-
-
-
-
- <%= text_field_tag 'name', params[:name], :size => 30, :onkeyup => 'regexName1();', :width => "125px" %>
- <%= hidden_field_tag 'project_type', params[:project_type] %>
- <%#= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
- <%= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
-
-
-
-
-
-
-
- <%=link_to l(:field_homepage), home_path %> >
- <%= l(:label_contest_innovate) %>
-
-
-
-
- <% end %>
-
-<% if @contests.size > 0%>
- <%#= sort_contest(@s_state)%>
-
- <%= render :partial => 'contest_list', :locals => {:contests => @contests, :contest_pages => @contest_pages} %>
-
-<% elsif @is_search%>
- <%= render :partial => "layouts/no_content"%>
-<% else %>
- <%#= sort_contest(@s_state)%>
-
- <%= render :partial => 'contest_list', :locals => {:contests => @contests, :contest_pages => @contest_pages} %>
-
-<% end %>
-
-<% html_title l(:label_contest_list)%>
diff --git a/app/views/contests/join_contest.js.erb b/app/views/contests/join_contest.js.erb
new file mode 100644
index 000000000..fe124ea36
--- /dev/null
+++ b/app/views/contests/join_contest.js.erb
@@ -0,0 +1,2 @@
+var htmlvalue = "<%= escape_javascript(render :partial => 'join_contest_box') %>";
+pop_box_new(htmlvalue,460,220);
diff --git a/app/views/contests/join_contest_multi_role.js.erb b/app/views/contests/join_contest_multi_role.js.erb
new file mode 100644
index 000000000..8c9f5063d
--- /dev/null
+++ b/app/views/contests/join_contest_multi_role.js.erb
@@ -0,0 +1,85 @@
+
+<% if @state %>
+<% if @state == 0 %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 1 %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 3 %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 4 %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 5 %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 6 %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 7%>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 8%>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 9%>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 10%>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 11%>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 12 %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 13 %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% elsif @state == 14 %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% else %>
+var htmlvalue = '';
+pop_box_new(htmlvalue, 300, 140);
+<% end %>
+<% end %>
+function refresh_current_contest(){
+ hideModal();
+ <% if @contest %>
+ window.location.href= "<%=contest_path(@contest.id) %>";
+ <% end %>
+}
diff --git a/app/views/contests/more.js.erb b/app/views/contests/more.js.erb
deleted file mode 100644
index d806c1481..000000000
--- a/app/views/contests/more.js.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-$('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:contest => @contest, :journals => @jour, :state => @state})) %>');
-$('#contest_message_reference_user_id').val("");
\ No newline at end of file
diff --git a/app/views/contests/new.html.erb b/app/views/contests/new.html.erb
new file mode 100644
index 000000000..7950ad990
--- /dev/null
+++ b/app/views/contests/new.html.erb
@@ -0,0 +1,31 @@
+
+
<%= l(:permission_new_contest)%>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contests/new.js.erb b/app/views/contests/new.js.erb
deleted file mode 100644
index a251b3d69..000000000
--- a/app/views/contests/new.js.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-$('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => @content})) %>');
-$('#contest_message_reference_user_id').val("<%= @id%>");
-showAndScrollTo("pre_show", "contest_message_reference_user_id");
-
-
diff --git a/app/views/contests/new_contest.html.erb b/app/views/contests/new_contest.html.erb
deleted file mode 100644
index 0e1b83602..000000000
--- a/app/views/contests/new_contest.html.erb
+++ /dev/null
@@ -1,13 +0,0 @@
-
-<%=l(:label_newtype_contest)%>
-
-<%= labelled_form_for @contest,
- :url => {:controller => 'contests', :action => 'create_contest'},
- method: :post do |f| %>
-
- <%= render :partial => 'form_contest', :locals => { :f => f } %>
- <%= submit_tag l(:button_create), :style=> "margin-left: 100px;margin-top: 10px;" %>
- <%= javascript_tag "$('#bid_name').focus();" %>
- <% end %>
-
-<% html_title(l(:label_newtype_contest)) -%>
\ No newline at end of file
diff --git a/app/views/contests/new_join.js.erb b/app/views/contests/new_join.js.erb
deleted file mode 100644
index 5ec9356d7..000000000
--- a/app/views/contests/new_join.js.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-$('#ajax-modal').html('<%= escape_javascript(render :partial => 'contests/new_join', :locals => {:contest => @contest}) %>');
-showModal('ajax-modal', '400px');
-$('#ajax-modal').addClass('new-watcher');
diff --git a/app/views/contests/private_or_public.js.erb b/app/views/contests/private_or_public.js.erb
new file mode 100644
index 000000000..dff4ba2b1
--- /dev/null
+++ b/app/views/contests/private_or_public.js.erb
@@ -0,0 +1,8 @@
+$("#contest_base_info").html('<%=escape_javascript(render :partial=>'contests/contest_base_info') %>');
+if(document.getElementById("contest_is_public")) {
+ <% if !@contest.is_public %>
+ $("#contest_is_public").attr("checked",false);
+ <% elsif @contest.is_public %>
+ $("#contest_is_public").attr("checked",true);
+ <% end %>
+}
\ No newline at end of file
diff --git a/app/views/contests/search_member.js.erb b/app/views/contests/search_member.js.erb
new file mode 100644
index 000000000..c34a08aaf
--- /dev/null
+++ b/app/views/contests/search_member.js.erb
@@ -0,0 +1 @@
+$('#course_members_setting').html('<%= escape_javascript(render :partial => 'courses/course_members') %>');
\ No newline at end of file
diff --git a/app/views/contests/set_contest_attribute.js.erb b/app/views/contests/set_contest_attribute.js.erb
new file mode 100644
index 000000000..8932016b6
--- /dev/null
+++ b/app/views/contests/set_contest_attribute.js.erb
@@ -0,0 +1,2 @@
+/*
+$("#contest_list_<%#= @contest.id %>").html("<%#= escape_javascript( render :partial => 'users/contest_list_contents', :locals => {:contest => @contest, :list_type => 1}) %>");*/
diff --git a/app/views/contests/set_reward_project.js.erb b/app/views/contests/set_reward_project.js.erb
deleted file mode 100644
index 2ea06abb1..000000000
--- a/app/views/contests/set_reward_project.js.erb
+++ /dev/null
@@ -1,31 +0,0 @@
-
-$('#reward_result_<%= @contesting_project_id %>').html('<%= j(
-
-if get_prize(@c_p).nil? || get_prize(@c_p) == ""
- if @contest.deadline < Date.today
- puts '未评奖'
- end
-else
-
- case get_prize(@c_p)
- when '-1'
- image_tag("/images/bid/special_reward.png")
- when '0'
- image_tag("/images/bid/first_reward.png")
- when '1'
- image_tag("/images/bid/second_reward.png")
- when '2'
- image_tag("/images/bid/third_reward.png")
- when '3'
- image_tag("/images/bid/forth_reward.png")
- when '4'
- image_tag("/images/bid/fifth_reward.png")
- when '5'
- image_tag("/images/bid/qualified.png")
- end
-
-end
-)
-%>')
-
-$('#<%= @contesting_project_id %>').hide()
diff --git a/app/views/contests/set_reward_softapplication.js.erb b/app/views/contests/set_reward_softapplication.js.erb
deleted file mode 100644
index 2906d95d3..000000000
--- a/app/views/contests/set_reward_softapplication.js.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-
-$('#reward_result_<%= @contesting_softapplication_id %>').html('<%= j(
-
-
-if get_prize(@c_sa).nil? || get_prize(@c_sa) == ""
- if @contest.deadline < Date.today
- puts '未评奖'
- end
-else
-
- case get_prize(@c_sa)
- when '-1'
- image_tag("/images/bid/special_reward.png")
- when '0'
- image_tag("/images/bid/first_reward.png")
- when '1'
- image_tag("/images/bid/second_reward.png")
- when '2'
- image_tag("/images/bid/third_reward.png")
- when '3'
- image_tag("/images/bid/forth_reward.png")
- when '4'
- image_tag("/images/bid/fifth_reward.png")
- when '5'
- image_tag("/images/bid/qualified.png")
- end
-
-end
-)
-%>')
-
-$('#<%= @contesting_softapplication_id %>').hide()
diff --git a/app/views/contests/settings.html.erb b/app/views/contests/settings.html.erb
index 4f8b8b0f2..4717ecc22 100644
--- a/app/views/contests/settings.html.erb
+++ b/app/views/contests/settings.html.erb
@@ -1,35 +1,64 @@
-
-
-
<%=l(:label_contest_settings)%>
-
+
+
竞赛配置
+
+
+
+ <%= render :partial => "contests/edit" %>
+
-
+
+ <%= render :partial => "contests/members" %>
+
+
+ <%= render :partial => "contests/boards" %>
+
+
-
-<%= error_messages_for 'contest' %>
-<%= labelled_form_for @contest, :url => update_contest_contest_path(@contest) do |f| %>
-
- <%= render :partial => 'form_contest', :locals => { :f => f } %>
-
- <%= submit_tag l(:button_create) %>
- <%= javascript_tag "$('#bid_name').focus();" %>
-<% end %>
\ No newline at end of file
+
+
+
+
\ No newline at end of file
diff --git a/app/views/contests/show.html.erb b/app/views/contests/show.html.erb
new file mode 100644
index 000000000..b584828da
--- /dev/null
+++ b/app/views/contests/show.html.erb
@@ -0,0 +1,30 @@
+
\ No newline at end of file
diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb
deleted file mode 100644
index 3f8ef4264..000000000
--- a/app/views/contests/show_attendingcontest.html.erb
+++ /dev/null
@@ -1,318 +0,0 @@
-
-
-
-<%= render_flash_messages %>
-
-
-
- <%= l(:label_wellmeaning_intimation_contentone) %>
-
-
- 1) <%= l(:label_wellmeaning_intimation_contenttwo) %>
-
-
- 2) <%= l(:label_wellmeaning_intimation_contentthree) %>
-
-
-
-<% if User.current.logged? %>
-
-
- <%= l(:label_attending_contest) %>:
-
- <%= link_to l(:label_new_attendingcontest_work),
- "javascript:void(0);",
- onclick: "$('#put-project-form').slideToggle();"
- %>
-
-
-
-
- <%= render "new_softapplication" %>
-
-
-<% else %>
-
- <%= l(:label_user_login_attending_contest) %>
- <%= link_to l(:label_user_login_new), signin_path %>
-
-<% end %>
-
-
-
-
-<% if @contest.id == 2 or @contest.id == 3 or @contest.id == 6 %>
-
- <% @contesting_project.sort.reverse.each do |c_project| %>
- <% if c_project.project %>
-
-
-
-
<%= l(:label_contest_work) %>
- : <%= link_to(c_project.project.name, project_path(c_project.project), :target => '_blank') %>
-
-
-
-
-
- <% if get_prize(c_project).nil? or get_prize(c_project) == "" %>
- <% if @contest.deadline < Date.today %>
- <%= l(:label_noawards) %>
- <% else %>
- <%= l(:label_noawards_current) %>
- <% end %>
- <% else %>
- <% case get_prize(c_project) %>
- <% when '-1' %>
- <%= image_tag("/images/bid/special_reward.png") %>
- <% when '0' %>
- <%= image_tag("/images/bid/first_reward.png") %>
- <% when '1' %>
- <%= image_tag("/images/bid/second_reward.png") %>
- <% when '2' %>
- <%= image_tag("/images/bid/third_reward.png") %>
- <% when '3' %>
- <%= image_tag("/images/bid/forth_reward.png") %>
- <% when '4' %>
- <%= image_tag("/images/bid/fifth_reward.png") %>
- <% when '5' %>
- <%= image_tag("/images/bid/qualified.png") %>
- <% end %>
- <% end %>
-
-
-
-
-
- <% if ((User.current.id == @contest.author_id) && (@contest.deadline >= Date.today))||User.current.admin %>
-
-
- <%= toggle_link l(:label_reward), c_project.id.to_s %>
-
-
- <%= form_for "set_reward_project", :remote => true, :url => set_reward_project_contest_path do |f| %>
- <%= f.text_field :c_id, :style => "display:none", :value => c_project.id, :size => "0" %>
- <%= f.select :reward, "#{l(:label_special_reward)}
- #{l(:label_first_reward)}
- #{l(:label_second_reward)}
- #{l(:label_third_reward)}
- #{l(:label_fourth_reward)}
- #{l(:label_fifth_reward)}
- #{l(:label_comfort_reward)} ".html_safe %>
- <%= f.submit :value => l(:button_submit), :class => "submit" %>
- <% end %>
-
-
-
- <% end %>
-
-
-
-
-
-
-
- <%= l(:label_profile) %>:
-
- <%#= c_project.project.description.truncate(90, omission: '...') %>
- <%= c_project.project.description %>
-
-
-
-
-
- <%= l(:label_attendingcontest_time) %>
- : <%= format_time c_project.created_at %>
- <%= l(:label_attendingcontest_spoksman) %>
-
- <% unless c_project.nil? || c_project.user.nil? %>
- : <%= link_to c_project.user.name,user_path(c_project.user) %>
- <% end %>
-
-
-
-
-
-
- <% end %>
-
- <% end %>
-<% else %>
- <% @contesting_softapplication.each do |c_softapplication| %>
- <% if c_softapplication.softapplication %>
-
-
-
- <%= l(:label_contest_work) %>:
- <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication), :target => '_blank') %>
-
-
-
-
-
-
- <%= l(:label_profile) %>:
-
- <%#= c_softapplication.softapplication.description.truncate(90, omission: '...') %>
- <%= c_softapplication.softapplication.description %>
-
-
-
-
-
-
- <%= l(:label_attendingcontest_time) %>
- : <%= format_time c_softapplication.created_at %>
- <%= l(:label_attendingcontest_spoksman) %>
-
- <% unless c_softapplication.nil? || c_softapplication.softapplication.nil? || c_softapplication.softapplication.user.nil? %>
- : <%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %>
- <% end %>
-
-
-
-
- <% score = c_softapplication.softapplication.average(:quality).try(:avg).try(:round, 2).to_f %>
-
<%= l(:label_final_scores) %>
- : <%= format("%.2f" , score) %>
- 分
-
-
-
-
- <% if get_prize(c_softapplication).nil? or get_prize(c_softapplication) == "" %>
- <% if @contest.deadline < Date.today %>
- <%= l(:label_noawards) %>
- <% else %>
- <%= l(:label_noawards_current) %>
- <% end %>
- <% else %>
- <% case get_prize(c_softapplication) %>
- <% when '-1' %>
- <%= image_tag("/images/bid/special_reward.png") %>
- <% when '0' %>
- <%= image_tag("/images/bid/first_reward.png") %>
- <% when '1' %>
- <%= image_tag("/images/bid/second_reward.png") %>
- <% when '2' %>
- <%= image_tag("/images/bid/third_reward.png") %>
- <% when '3' %>
- <%= image_tag("/images/bid/forth_reward.png") %>
- <% when '4' %>
- <%= image_tag("/images/bid/fifth_reward.png") %>
- <% when '5' %>
- <%= image_tag("/images/bid/qualified.png") %>
- <% end %>
- <% end %>
-
-
-
-
-
- <% if ((User.current.id == @contest.author_id) && (@contest.deadline >= Date.today))||User.current.admin %>
-
- <%= toggle_link '评奖', c_softapplication.id.to_s %>
-
-
- <%= form_for "set_reward_softapplication", :remote => true, :url => set_reward_softapplication_contest_path do |f| %>
- <%= f.text_field :c_id, :style => "display:none", :value => c_softapplication.id, :size => "0" %>
- <%= f.select :reward, "#{l(:label_special_reward)}
- #{l(:label_first_reward)}
- #{l(:label_second_reward)}
- #{l(:label_third_reward)}
- #{l(:label_fourth_reward)}
- #{l(:label_fifth_reward)}
- #{l(:label_comfort_reward)} ".html_safe %>
- <%= f.submit :value => l(:button_submit), :class => "submit" %>
- <% end %>
-
-
- <% end %>
-
-
-
- <% end %>
-
- <% end %>
-<% end %>
-
-
-<% html_title(l(:label_contest_joincontest)) -%>
-
diff --git a/app/views/contests/show_contest.html.erb b/app/views/contests/show_contest.html.erb
deleted file mode 100644
index bbda34b88..000000000
--- a/app/views/contests/show_contest.html.erb
+++ /dev/null
@@ -1,44 +0,0 @@
-<% reply_allow = JournalsForMessage.create_by_user? User.current %>
-<%= stylesheet_link_tag 'css', :media => 'all' %>
-
- <%= render :partial => 'contest_jours',
- :locals => { :contest => @contest, :journals => @jour, :state => false}
- %>
-
-<% html_title(l(:label_user_response)) -%>
diff --git a/app/views/contests/show_contest_user.html.erb b/app/views/contests/show_contest_user.html.erb
deleted file mode 100644
index 1b8a27c1a..000000000
--- a/app/views/contests/show_contest_user.html.erb
+++ /dev/null
@@ -1,37 +0,0 @@
-
- <% for user in @contest.watcher_users %>
-
-
-
-
- <%= image_tag(url_to_avatar(user), :class => "avatar") %>
-
-
-
-
-
- <%= content_tag "div", link_to_user(user), :class => "project_avatar_name" %>
-
-
-
-
-
- <% unless user.memberships.empty? %>
- <%= l(:label_x_contribute_to, :count => user.memberships.count) %>
- <% for member in user.memberships %>
- <%= link_to_project(member.project) %>
- <%= (user.memberships.last == member) ? '' : ',' %>
- <% end %>
- <% end %>
-
-
-
-
- <%= l(:label_user_joinin) %><%= format_date(user.created_on) %>
-
-
-
-
-
-<% end %>
-
\ No newline at end of file
diff --git a/app/views/contests/show_softapplication.html.erb b/app/views/contests/show_softapplication.html.erb
deleted file mode 100644
index 86b20c09a..000000000
--- a/app/views/contests/show_softapplication.html.erb
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-
-
-
- <% if User.current.logged? %>
-
-
-
- <% end %>
-
-
-
-
- <%= render :partial => 'softapplication_list', :locals => {:contesting_softapplication => @contesting_softapplication,:contest => @contest} %>
-
-
diff --git a/app/views/contests/watcherlist.html.erb b/app/views/contests/watcherlist.html.erb
deleted file mode 100644
index 5628e5e95..000000000
--- a/app/views/contests/watcherlist.html.erb
+++ /dev/null
@@ -1,34 +0,0 @@
-
-<%= l(:label_user_watcher)%>
-
- <% @contest.watcher_users.each do |user| %>
-
-
-
-
- <%= image_tag(url_to_avatar(user), :class => "avatar") %>
-
-
- <%= content_tag "div", link_to_user(user), :class =>"project_avatar_name" %>
-
-
-
-
- <% unless user.memberships.empty? %>
- <%= l(:label_contribute_to, :count => "#{user.memberships.count}") %>
- <% for member in user.memberships %>
- <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %>
- <% end %>
- <% end %>
-
-
-
- <%= l(:label_user_joinin) %><%= format_date(user.created_on) %>
-
-
-
-
-
- <% end %>
-
-<% html_title(l(:label_followers)) -%>
\ No newline at end of file
diff --git a/app/views/layouts/_homepage_left_contest_list.html.erb b/app/views/layouts/_homepage_left_contest_list.html.erb
new file mode 100644
index 000000000..d8635c288
--- /dev/null
+++ b/app/views/layouts/_homepage_left_contest_list.html.erb
@@ -0,0 +1,17 @@
+<% all_count = @user.favorite_contests.visible.where("is_delete =?", 0).count%>
+
+<% if !contests.empty? %>
+
+
+
+<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/layouts/_user_contests.html.erb b/app/views/layouts/_user_contests.html.erb
new file mode 100644
index 000000000..553cc3e1c
--- /dev/null
+++ b/app/views/layouts/_user_contests.html.erb
@@ -0,0 +1,72 @@
+<% contests.each do |contest|%>
+
+
+ <% is_teacher = User.current.logged? && (User.current.admin? || User.current.admin_of_contest?(contest)) %>
+
+
+ <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Contest' and shield_id=#{contest.id}").count %>
+
+
+
+
+
+ <% if is_teacher %>
+
+ <%= link_to "作品",works_path(:contest => contest.id), :class => 'user_navmore_li fl', :target => '_blank' %>
+ <%= link_to '+',works_path(:contest => contest.id,:is_new => 1), :class => 'user_navmore_add fl', :title => '发布作品',:target => '_blank' %>
+
+
+ <%= link_to "通知", contest_news_index_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
+ <%= link_to "+", new_contest_news_path(contest,:is_new=>1), :class => 'user_navmore_add fl', :title => '发布通知',:target => '_blank' %>
+
+ <% else %>
+
+ <%= link_to "作业",works_path(:contest => contest.id), :class => 'user_navmore_li', :target => '_blank' %>
+
+
+
+ <%= link_to "通知", contest_news_index_path(contest), :class => 'user_navmore_li',:target => '_blank' %>
+
+
+ <% end %>
+
+ <%= link_to "论坛",contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
+ <%= link_to "+",contest_boards_path(contest, :flag => true, :is_new => 1), :class => 'user_navmore_add fl', :title => '发布帖子',:target => '_blank' %>
+
+ <% if User.current == user %>
+
+ <%= link_to "取消收藏", cancel_or_collect_user_path(user, :contest => contest.id), :class => 'user_navmore_li',:target => '_blank', :remote => true %>
+
+
+
+ <% if count == 0 %>
+ <%= link_to "屏蔽动态", shield_activities_path(:user_id => user.id, :contest_id => contest.id), :method => 'post', :class => 'user_navmore_li',:remote => true %>
+ <% else %>
+ <%= link_to "显示动态", show_acts_shield_activities_path(:user_id => user.id, :contest_id => contest.id),:remote => true,:method => 'delete', :class => 'user_navmore_li' %>
+ <% end %>
+
+ <% end %>
+
+
+
+
+
+<% end %>
+
+<% if all_count > (page.to_i+1) * 10%>
+
+
+
+<% end%>
+
+
diff --git a/app/views/layouts/base_contest.html.erb b/app/views/layouts/base_contest.html.erb
deleted file mode 100644
index 42a7eccd1..000000000
--- a/app/views/layouts/base_contest.html.erb
+++ /dev/null
@@ -1,289 +0,0 @@
-<%
- @nav_dispaly_contest_label = 1
- @nav_dispaly_store_all_label = 1
-%>
-
-
-
-
- <%= h html_title %>
-
-
- <%= csrf_meta_tag %>
- <%= favicon %>
- <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %>
- <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
- <%= javascript_heads %>
- <%= heads_for_theme %>
- <%= call_hook :view_layouts_base_html_head %>
-
- <%= yield :header_tags -%>
-
-
-
-
-
- <%=render :partial => 'layouts/base_header'%>
-
-
-
-
-
-
-
- <%=l(:label_contest_innovate_community)%>
-
-
-
-
- <%= l(:label_user_location) %> :
-
-
-
-
- <%= form_tag({:controller => 'bids', :action => 'contest'}, :id => "contest_search_form",:method => :get) do %>
- <%= text_field_tag 'name', params[:name], :size => 20 %>
- <%= hidden_field_tag 'reward_type', @bid.reward_type %>
- <%= hidden_field_tag 'project_type', params[:project_type] %>
-
- <%= l(:label_search)%>
-
- <%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
- <% end %>
-
-
-
-
-
- <%=link_to l(:field_homepage), home_path %> >
- <%= l(:label_contest_innovate)%> >
-
- <%= link_to @bid.name, bid_path %>
-
-
-
-
-
-
-
-
-
- <% if display_main_menu?(@bid) %>
-
- <%= render_menu :bid_menu %>
-
- <% end %>
-
- <%= yield %>
- <%= call_hook :view_layouts_base_content %>
-
-
- <%=render :partial => 'layouts/base_footer'%>
-
-
-
-
-
-
- <%= l(:label_loading) %>
-
-
-
-
-
- <%= call_hook :view_layouts_base_body_bottom %>
-
-
diff --git a/app/views/layouts/base_contest_community.html.erb b/app/views/layouts/base_contest_community.html.erb
new file mode 100644
index 000000000..8aef9e4d1
--- /dev/null
+++ b/app/views/layouts/base_contest_community.html.erb
@@ -0,0 +1,103 @@
+
+
+
+
+ <%= h html_title %>
+
+
+ <%= csrf_meta_tag %>
+ <%= favicon %>
+ <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','syllabus','css/moduel', 'css/user', :media => 'all' %>
+ <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
+ <%= javascript_heads %>
+ <%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%>
+ <%= heads_for_theme %>
+ <%= call_hook :view_layouts_base_html_head %>
+ <%= yield :header_tags -%>
+
+
+
+
+
+
+
+
+ <% is_current_user = User.current.logged? && User.current == @user%>
+ <% if User.current.logged? %>
+ <%= render :partial => 'layouts/logined_header' %>
+ <% else%>
+ <%= render :partial => 'layouts/unlogin_header' %>
+ <% end%>
+
+
+
+
+
+
+
+
+ <% if hidden_unproject_infos %>
+
+ <% end %>
+
+ <%# 更新访问数,刷新的时候更新访问次数 %>
+ <%# update_visiti_count @user %>
+
+
+
+
+
+
+<%= render :partial => 'layouts/footer' %>
+
+
+
+
+ <%= l(:label_loading) %>
+
+
+ <%=render :partial => 'layouts/upload_avatar', :locals => {:source => @user} %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/layouts/base_contests.html.erb b/app/views/layouts/base_contests.html.erb
new file mode 100644
index 000000000..63281ce55
--- /dev/null
+++ b/app/views/layouts/base_contests.html.erb
@@ -0,0 +1,115 @@
+<% work_num = visable_contest_work @contest %>
+<% is_admin = User.current.admin? || User.current.admin_of_contest?(@contest) %>
+
+
+
+
+ <%= h html_title %>
+
+
+ <%= csrf_meta_tag %>
+ <%= favicon %>
+ <%= javascript_heads %>
+ <%= heads_for_theme %>
+ <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus', 'css/moduel','css/contest'%>
+ <%= javascript_include_tag "course","avatars","header","attachments",'prettify' %>
+ <%= call_hook :view_layouts_base_html_head %>
+
+ <%= yield :header_tags -%>
+
+
+
+
+ <%= render :partial => User.current.logged? ? 'layouts/logined_header' : 'layouts/unlogin_header' %>
+
+
+
+
+
+ <%= render :partial => 'contests/contest_base_info' %>
+
+
+
+
+
+
+ <%= link_to '竞赛首页', contest_path(@contest) %>
+
+
+ <%= link_to '动态', contest_activities_contest_path(@contest) %>
+
+
+
+ 作品<%= work_num%>
+ <% if is_admin %>
+
+ <% end %>
+
+
+ <%= link_to "通知#{@contest.news.count} ".html_safe, contest_news_index_path(@contest), :class => "sy_icons_feedback" %>
+ <% if is_admin %>
+ <%= link_to "", contest_news_index_path(@contest,:is_new => 1), :class => "sy_class_add" %>
+ <% end %>
+
+
+
+
+
+
+ <%= render_flash_messages %>
+
+ <%= yield %>
+
+
+ <%= call_hook :view_layouts_base_content %>
+
+
+
+
+
+
+
+<%= render :partial => 'layouts/footer' %>
+
+<% if hidden_unproject_infos %>
+ <%= render :partial => 'layouts/new_feedback' %>
+<% end %>
+
+ <%= l(:label_loading) %>
+
+
+
+ <%=render :partial => 'layouts/upload_avatar', :locals => {:source => @contest} %>
+
+<%= call_hook :view_layouts_base_body_bottom %>
+
+
+
+
+
+<%= javascript_include_tag 'cookie','project',"avatars", 'header','prettify','select_list_move','attachments' %>
+
+
+
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index 069b2cc55..985cdacf4 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -29,8 +29,6 @@
<%= yield %>
<%= call_hook :view_layouts_base_content %>
-
-
diff --git a/app/views/layouts/new_base.html.erb b/app/views/layouts/new_base.html.erb
index d28171f5f..cc6da3581 100644
--- a/app/views/layouts/new_base.html.erb
+++ b/app/views/layouts/new_base.html.erb
@@ -14,7 +14,7 @@
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'css/common','css/structure', 'css/public', 'css/courses','prettify', 'css/org', 'syllabus'%>
- <%= javascript_include_tag "course","header",'prettify' %>
+ <%= javascript_include_tag "course","header",'prettify','contest' %>
<%= yield :header_tags -%>
diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb
index dd8650f9a..fdbf2f3db 100644
--- a/app/views/layouts/new_base_user.html.erb
+++ b/app/views/layouts/new_base_user.html.erb
@@ -238,6 +238,19 @@
+
+
+
+ <%= link_to "竞赛社区", user_contest_community_path(User.current), :class => "fl" , :target => "_blank"%>
+
+
+
+ <%= link_to user_contest_count > 0 ? "竞赛#{user_contest_count} ".html_safe : "竞赛",
+ user_contest_community_path(User.current), :id => "user_contest_list", :target => "_blank" %>
+
+
+ <%# end %>
+
<% else %>
Ta在确实
@@ -252,6 +265,10 @@
<%= link_to user_project_count > 0 ? "项目#{user_project_count} ".html_safe : "项目",
user_project_community_path(@user), :id => 'user_project_list', :class => "fl", :target => "_blank" %>
+
+ <%= link_to user_contest_count > 0 ? "竞赛#{user_contest_count} ".html_safe : "竞赛",
+ user_contest_community_path(@user), :id => 'user_contest_list', :class => "fl", :target => "_blank" %>
+
<% end %>
diff --git a/app/views/news/_contest_news.html.erb b/app/views/news/_contest_news.html.erb
new file mode 100644
index 000000000..cd0be8305
--- /dev/null
+++ b/app/views/news/_contest_news.html.erb
@@ -0,0 +1,34 @@
+
+
\ No newline at end of file
diff --git a/app/views/news/_contest_news_detail.html.erb b/app/views/news/_contest_news_detail.html.erb
new file mode 100644
index 000000000..e20177536
--- /dev/null
+++ b/app/views/news/_contest_news_detail.html.erb
@@ -0,0 +1,9 @@
+<%= content_for(:header_tags) do %>
+ <%= import_ke(enable_at: false, prettify: false) %>
+ <%= javascript_include_tag "create_kindeditor" %>
+<% end %>
+
+<% if newss%>
+ <%= render :partial => 'users/course_newslist', :locals => {:topics => newss} %>
+<% end%>
+
diff --git a/app/views/news/_contest_news_new.html.erb b/app/views/news/_contest_news_new.html.erb
new file mode 100644
index 000000000..6ebdf4365
--- /dev/null
+++ b/app/views/news/_contest_news_new.html.erb
@@ -0,0 +1,114 @@
+<%= content_for(:header_tags) do %>
+ <%= import_ke(enable_at: true, prettify: false) %>
+<% end %>
+
+
+
+
+
+
+
+ <%= f.check_box :sticky, :value => edit_mode ? news.sticky : 0 %>
+ <%= label_tag 'news_sticky', l(:label_board_sticky) %>
+
+
+
+
+ <%= text_area :quote,:quote,:style => 'display:none' %>
+ <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
+
+ <%= f.kindeditor :description, :editor_id => 'news_description_editor',
+ :owner_id => news.nil? ? 0: news.id,
+ :owner_type => OwnerTypeHelper::NEWS,
+ :width => '100%',
+ :height => 300,
+ :minHeight=>300,
+ :class => 'talk_text fl',
+ :input_html => { :id => 'news_content',
+ :class => 'talk_text fl',
+ :maxlength => 5000 },
+ at_id: news.id, at_type: news.class.to_s
+ %>
+
+
+
+
+
+
+ <%= render :partial => 'attachments/form_course', :locals => {:container => news, :isReply => false} %>
+
+
+
+
+ <%if !edit_mode %>
+
确定
+
或
+
取消
+ <% else %>
+
确定
+
或
+ <%= link_to "取消",news_path(news), :class => "fr mr10 mt3"%>
+ <% end %>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/news/_contest_show.html.erb b/app/views/news/_contest_show.html.erb
new file mode 100644
index 000000000..6c0b8feb1
--- /dev/null
+++ b/app/views/news/_contest_show.html.erb
@@ -0,0 +1,103 @@
+<%= content_for(:header_tags) do %>
+ <%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
+<% end %>
+
+
+
+
+
+
+
+ <%= link_to image_tag(url_to_avatar(@news.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@news.author) %>
+
+
+ <% if User.current.allowed_to?(:manage_news, @contest)%>
+
+
+
+
+ <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{@news.id}','#{User.current.id}','news')") %>
+
+ <%= link_to(
+ l(:button_edit),
+ {:action => 'edit', :id => @news},
+ :class => 'postOptionLink'
+ ) if User.current.allowed_to?(:manage_news, @contest) %>
+
+
+ <%= delete_link(
+ news_path(@news),
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if User.current.allowed_to?(:manage_news, @contest) %>
+
+
+
+
+
+ <% elsif User.current.logged? %>
+
+
+
+
+ <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{@news.id}','#{User.current.id}','news')") %>
+
+
+
+
+ <%end%>
+
+
+
+
+ <% if @news.try(:author).try(:realname) == ' ' %>
+ <%= link_to @news.try(:author), user_path(@news.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
+ <% else %>
+ <%= link_to @news.try(:author).try(:realname), user_path(@news.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
+ <% end %>
+
+
<%= format_time( @news.created_on)%>
+
+
+ <%= @news.description.html_safe%>
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @news} %>
+
+
+
+
+
+
+ <%= render :partial => 'news/news_all_replies', :locals => {:object => @contest} %>
+
+
+
diff --git a/app/views/news/edit.html.erb b/app/views/news/edit.html.erb
index c47e7bd6d..5a176e8aa 100644
--- a/app/views/news/edit.html.erb
+++ b/app/views/news/edit.html.erb
@@ -20,8 +20,10 @@
<%= render :partial => 'edit_for_org_subfield', :locals => {:f => f, :news => @news} %>
<% elsif @course %>
<%= render :partial => 'course_news_new', :locals => {:f => f, :news => @news, :edit_mode => true, :course => @course} %>
+ <% elsif @contest %>
+ <%= render :partial => 'contest_news_new', :locals => {:f => f, :news => @news, :edit_mode => true, :contest => @contest} %>
<% elsif @project %>
- <%= render :partial => 'project_news_new', :locals => {:f => f, :news => @news, :edit_mode => true} %>
+ <%= render :partial => 'project_news_new', :locals => {:f => f, :news => @news, :edit_mode => true} %>
<% end %>
<% end %>
diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb
index c4dd11ea0..aea794372 100644
--- a/app/views/news/index.html.erb
+++ b/app/views/news/index.html.erb
@@ -2,6 +2,8 @@
<%= render :partial => 'project_news', locals: {project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_news', locals: {course: @course} %>
+<% elsif @contest %>
+ <%= render :partial => 'contest_news', locals: {contest: @contest} %>
<% end %>
diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb
index 4f6ca056e..eeddffcfe 100644
--- a/app/views/news/show.html.erb
+++ b/app/views/news/show.html.erb
@@ -2,6 +2,8 @@
<%= render :partial => 'project_show', locals: {project: @project} %>
<% elsif @course %>
<%= render :partial => 'course_show', locals: {course: @course} %>
+<% elsif @contest %>
+ <%= render :partial => 'contest_show', :locals => {:contest => @contest} %>
<% elsif @organization %>
<%= render :partial => 'organization_show', :locals => {:org_subfield => @org_subfield} %>
<% end %>
diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb
index 152bd290f..64576726e 100644
--- a/app/views/student_work/_student_work_list.html.erb
+++ b/app/views/student_work/_student_work_list.html.erb
@@ -14,7 +14,7 @@
<% if !@is_teacher && my_work.nil? && User.current.member_of_course?(@course) %>
您尚未提交作品
<% unless @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
- <%=link_to "提交作品", new_student_work_url_without_domain(@homework.id),:class => 'blueCir ml5 f12' %>
+ <%=link_to "提交作品", new_contestant_work_path(:work => @homework.id),:class => 'blueCir ml5 f12' %>
<% end %>
<% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
截止日期已过,已提交且不可修改
diff --git a/app/views/users/_collect_contest.html.erb b/app/views/users/_collect_contest.html.erb
new file mode 100644
index 000000000..a76701ea0
--- /dev/null
+++ b/app/views/users/_collect_contest.html.erb
@@ -0,0 +1,10 @@
+<% member = ContestMember.where("user_id = #{@user.id} and contest_id = #{contest.id}").first %>
+<% if User.current == @user %>
+ <% if member %>
+ <%= link_to "", cancel_or_collect_user_path(@user, :contest => contest.id), :class => "#{member.is_collect == true ? 'icons_project_favorite mt3' : 'icons_project_star mt3'}", :target => '_blank', :remote => true, :title => "#{member.is_collect == true ? '点击将其从个人主页的项目列表中移除' : '点击将其添加至个人主页的项目列表中'}" %>
+ <% end %>
+<% else %>
+ <% if member %>
+
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/_contest_create.html.erb b/app/views/users/_contest_create.html.erb
new file mode 100644
index 000000000..017c57d58
--- /dev/null
+++ b/app/views/users/_contest_create.html.erb
@@ -0,0 +1,23 @@
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user), :alt => "用户头像" %>
+ <%#= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
+
+
+
+ <%= link_to activity.user.show_name, user_path(activity.user), :class => "newsBlue mr15" %>
+ TO
+ <% str = defined?(is_contest) && is_contest == 1 ? "竞赛" : "#{activity.name.to_s} | 竞赛" %>
+ <%= link_to str, contest_path(activity.id), :class => "newsBlue ml15" %>
+
+
+ <%= link_to activity.name, contest_path(activity.id), :class => "postGrey" %>
+
+
+ 创建时间:<%= format_time(activity.created_at) %>
+
+
+
+
+
diff --git a/app/views/users/_contest_list.html.erb b/app/views/users/_contest_list.html.erb
new file mode 100644
index 000000000..299699678
--- /dev/null
+++ b/app/views/users/_contest_list.html.erb
@@ -0,0 +1,30 @@
+
+
<%= @user == User.current ? "我" : "他" %><%= list_type == 1 ? "创建" : "参与" %>的竞赛
+
+
+
+ <% if contests.empty? %>
+
+ <% if list_type == 1 %>
+
<%=@user == User.current ? "您" : "他" %>还没有创建竞赛~~
+ <%= link_to "创建竞赛", new_contest_path(), :target => "_blank", :class => "sy_btn_green ml5 mt5" if @user == User.current %>
+
+ <% else %>
+
<%= @user == User.current ? "您" : "他" %>还没有加入竞赛~~
+ <%= link_to "加入竞赛", join_contest_contests_path(), :remote => true, :method => "get", :class => "sy_btn_green ml5 mt5" if @user == User.current %>
+
+ <% end %>
+ <% else %>
+ <% contests.each_with_index do |contest, i| %>
+
+ <%= render :partial => 'users/contest_list_contents', :locals => {:contest => contest, :list_type => list_type} %>
+
+ <% end %>
+ <% if count > 5 %>
+
+ <% end %>
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/_contest_list_contents.html.erb b/app/views/users/_contest_list_contents.html.erb
new file mode 100644
index 000000000..3d02dd46c
--- /dev/null
+++ b/app/views/users/_contest_list_contents.html.erb
@@ -0,0 +1,35 @@
+<% allow_visit = User.current.member_of_contest?(contest) || User.current.admin? || contest.is_public? %>
+
+
+ <%= render :partial => 'collect_contest', :locals => {:contest => contest} %>
+
+
<%= link_to contest.name, allow_visit ? contest_path(contest.id, :host => Setting.host_name) : 'javascript:void(0)', :target => '_blank',
+ :class => "new_project_title fl",:id => "show_project_#{contest.id}", :title => (allow_visit ? "#{contest.name}" : "私有竞赛不可访问") %>
+
<%= contest.is_public? ? '公开' : '私有' %>
+
+
+
+
+ 更新时间:<%= format_date(contest.updated_at) %>
+ <% contestUser = User.where("id=?", contest.user_id).first %>
+ 单位:<%= contestUser.user_extensions.school_id.blank? ? "无" : contestUser.user_extensions.school.name %>
+
+
+
+<%# if list_type == 1%>
+
+
+
+
+
+ <%#= link_to contest.is_public? ? '设为私有' : '设为公开', set_contest_attribute_contests_path(:contest => contest, :user_id => @user.id), :class => 'postOptionLink',:target =>'_blank', :remote => 'true' %>
+
+
+
+<%# end %>
\ No newline at end of file
diff --git a/app/views/users/_contest_news.html.erb b/app/views/users/_contest_news.html.erb
new file mode 100644
index 000000000..990430941
--- /dev/null
+++ b/app/views/users/_contest_news.html.erb
@@ -0,0 +1,77 @@
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <%= link_to activity.author.show_name, user_path(activity.author), :class => "newsBlue mr15" %>
+ TO
+ <% str = defined?(is_contest) && is_contest == 1 ? "竞赛通知" : "#{activity.contest.name.to_s} | 竞赛通知" %>
+ <%= link_to str, contest_news_index_path(activity.contest), :class => "newsBlue ml15" %>
+
+
+ <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
+
+ <% if activity.sticky == 1 %>
+
置顶
+ <% end%>
+
+
+ 发布时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(ContestActivity.where("contest_act_type='#{activity.class}' and contest_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+ <% if User.current.logged? %>
+
+
+
+ <% if User.current.logged? %>
+
+ <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
+
+ <%= link_to(
+ l(:button_edit),
+ {controller:'news', :action => 'edit', :id => activity.id},
+ :class => 'postOptionLink'
+ ) if User.current.allowed_to?(:manage_news, activity.course) %>
+
+
+ <%= delete_link(
+ news_path(activity),
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if User.current.allowed_to?(:manage_news, activity.course) %>
+
+
+ <% end %>
+
+
+
+ <% end %>
+
+
+
+
+
+
+ <%=render :partial => 'users/course_news_post_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %>
+
+
+
+
diff --git a/app/views/users/_contest_newslist.html.erb b/app/views/users/_contest_newslist.html.erb
new file mode 100644
index 000000000..4c9d7377c
--- /dev/null
+++ b/app/views/users/_contest_newslist.html.erb
@@ -0,0 +1,67 @@
+
+
+
+
通知列表
+
+
排序:
+ <%= link_to "时间", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %>
+ <% if @type.to_i == 1 %>
+ <%= link_to "", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <% end %>
+ <%= link_to "人气", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %>
+ <% if @type.to_i == 2 %>
+ <%= link_to "", {:controller => 'news', :action => 'index', :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
+ <% end %>
+
+
+
+ <% if topics.any? %>
+ <% topics.each do |activity| %>
+
+
+ <%= link_to activity.title.to_s, User.current.logged? ? news_path(activity) : signin_url_without_domain, :class => "list-title-normal fl" %>
+ <% if activity.sticky == 1 %>
+
顶
+ <% end%>
+ <% u = User.where("id=?",activity.author_id).first%>
+
+
+
+
+
+
+
+ 发布者:<%= link_to activity.author.show_name, user_path(activity.author), :class => "link-blue" %>
+
+
更新:<%= format_time(activity.course_acts.first.try(:updated_at)) %>
+ <% count=0 %>
+ <% count=activity.comments.count %>
+
<%= count>0 ? "#{count}" : "0" %> 回复 | <%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %> 赞
+
+
+
+ <% end %>
+
+
+ <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
+
+
+
+ <% else %>
+
<%= l(:label_no_data) %>
+ <% end %>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_contest_work.html.erb b/app/views/users/_contest_work.html.erb
new file mode 100644
index 000000000..7d1744303
--- /dev/null
+++ b/app/views/users/_contest_work.html.erb
@@ -0,0 +1,61 @@
+<% is_teacher = User.current.admin_of_contest?(activity.contest) %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user), :alt => "用户头像" %>
+ <%#= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
+
+
+
+ <%= link_to activity.user.show_name, user_path(activity.user,:host=>Setting.host_user), :class => "newsBlue mr15" %>
+ TO
+ <% if hw_status == 3 || hw_status == 2 %>
+ <%= link_to "作品", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%>
+ <% else %>
+ <%= link_to activity.contest.name.to_s+" | 竞赛作品", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%>
+ <% end %>
+
+
+ <% if hw_status == 3 || hw_status == 5 %>
+ <% index = get_work_index(activity, is_teacher) %>
+ <%= link_to "作品#{index+1}: ".html_safe+activity.name,contestant_works_path(:work => activity.id),:class => "postGrey"%>
+ <% else %>
+ <%= link_to activity.name.to_s, contestant_works_path(:work => activity.id), :class => "postGrey"%>
+ <% end %>
+
+ <%=get_cw_status(activity).html_safe %>
+
+
+ <% if activity.work_type == 3 && activity.work_detail_group.base_on_project %>
+
系统提示:该题目要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
+ <% elsif activity.work_type == 3 && !activity.work_detail_group.base_on_project%>
+
系统提示:该题目要求各组长提交作品,提交作品时请添加组成员。谢谢配合!
+ <% end %>
+
+ <%= render :partial => 'users/work_opr', :locals => {:activity => activity, :is_teacher => is_teacher, :hw_status => hw_status, :user_activity_id => user_activity_id} %>
+ <% if !activity.end_time.nil? %>
+
提交截止时间:<%= activity.end_time.to_s %> 23:59
+ <% end %>
+ <% if activity.work_status == 0 && !activity.publish_time.nil? %>
+
+ <%= l(:label_publish_time)%>:<%= activity.publish_time%> 00:00
+
+ <% end %>
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
+
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+ <%= render :partial => "users/contest_work_base_info", :locals =>{:activity => activity, :user_activity_id =>user_activity_id, :is_teacher => is_teacher, :hw_status => hw_status} %>
+
+
+
+
+ <%= render :partial => 'users/contest_work_post_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id, :is_teacher => is_teacher} %>
+
diff --git a/app/views/users/_contest_work_base_info.html.erb b/app/views/users/_contest_work_base_info.html.erb
new file mode 100644
index 000000000..8f9f2e5c7
--- /dev/null
+++ b/app/views/users/_contest_work_base_info.html.erb
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+<% if activity.contestant_works.count != 0 %>
+ <% sw = activity.contestant_works.reorder("commit_time desc").first %>
+
+ # <%=time_from_now sw.commit_time %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
+
+
+ <% sw_id = "("+activity.contestant_works.map{|sw| sw.id}.join(",")+")" %>
+ <% student_work_scores = ContestantWorkScore.where("contestant_work_id in #{sw_id} and score is not null").reorder("created_at desc") %>
+ <% unless student_work_scores.empty? %>
+ <% last_score = student_work_scores.first %>
+
+
# <%=time_from_now last_score.created_at %>
+ <%= link_to last_score.reviewer_role == 3 && !is_teacher ? '学生匿名' : last_score.user.show_name, last_score.reviewer_role == 3 && !is_teacher ? "javascript:void(0)" : user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品
+
+
+ <% end %>
+<% end %>
+
+<% if activity.work_type == 3 && activity.work_detail_group.base_on_project %>
+ <% projects = activity.contestant_work_projects.where(:is_leader => true) %>
+ <% unless projects.empty? %>
+ <% sort_projects = project_sort_update projects %>
+
+
+ <% first_pro_act = sort_projects.first %>
+ <% first_pro = Project.find first_pro_act.project_id %>
+ <% commit_time = first_pro.project_score.commit_time %>
+ <%# one_forge_time=ForgeActivity.where("project_id=?",first_pro.id).last.updated_at if ForgeActivity.where("project_id=?",first_pro.id).last %>
+ # <%=time_from_now !commit_time.nil? && format_time(commit_time) > format_time(first_pro_act.updated_at) ? commit_time : first_pro_act.updated_at %><%= link_to User.find(first_pro.user_id).show_name, user_activities_path(first_pro.user_id), :class => "newsBlue ml5 mr5"%>更新了项目
+
+
+
+ <% end %>
+<% end %>
+
+
+<% if is_teacher%>
+
+
+
+
+
+ <%= link_to "编 辑",edit_work_path(activity, :hw_status => hw_status), :class => "wpostOptionLink"%>
+
+
+ <%= link_to "删 除",work_path(activity, :hw_status => hw_status),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "wpostOptionLink" %>
+
+
+
+
+
+<% end%>
\ No newline at end of file
diff --git a/app/views/users/_contest_work_post_reply.html.erb b/app/views/users/_contest_work_post_reply.html.erb
new file mode 100644
index 000000000..fb966ea46
--- /dev/null
+++ b/app/views/users/_contest_work_post_reply.html.erb
@@ -0,0 +1,34 @@
+<% count=activity.journals_for_messages.count %>
+<% comments = activity.journals_for_messages.reorder("created_on desc") %>
+<% no_children_comments = get_no_children_comments comments %>
+
+ <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :expand_more =>no_children_comments[:three_more]} %>
+
+ <% if count > 0 %>
+
+ <%=render :partial => 'users/news_replies', :locals => {:comments => no_children_comments[:no_children_comments], :type => 'Work', :is_teacher => is_teacher, :user_activity_id => user_activity_id, :activity_id => activity.id} %>
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
+
+ <% if User.current.logged? %>
+
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_contest_work_message', :id => activity.id},:method => "post", :remote => true) do |f|%>
+ <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
+
+
+
发送
+
+
+ <% end%>
+
+ <% else %>
+ <%= render :partial => "users/show_unlogged" %>
+ <% end %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_course_newslist.html.erb b/app/views/users/_course_newslist.html.erb
index 65f9572d6..bc06023fa 100644
--- a/app/views/users/_course_newslist.html.erb
+++ b/app/views/users/_course_newslist.html.erb
@@ -33,7 +33,7 @@
发布者:<%= link_to activity.author.show_name, user_path(activity.author), :class => "link-blue" %>
- 更新:<%= format_time(activity.course_acts.first.try(:updated_at)) %>
+ 更新:<%= format_time(@course ? activity.course_acts.first.try(:updated_at) : activity.contest_acts.first.try(:updated_at)) %>
<% count=0 %>
<% count=activity.comments.count %>
<%= count>0 ? "#{count}" : "0" %> 回复 | <%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %> 赞
diff --git a/app/views/users/_join_contest_applied_message.html.erb b/app/views/users/_join_contest_applied_message.html.erb
new file mode 100644
index 000000000..3a6b5f3d3
--- /dev/null
+++ b/app/views/users/_join_contest_applied_message.html.erb
@@ -0,0 +1,51 @@
+
+ <% applied_contest = ma.applied %>
+ <% contest = Contest.find applied_contest.contest_id %>
+ <% message_user = User.find(applied_contest.user_id) %>
+
+
+ <%= link_to image_tag(url_to_avatar(message_user), :width => "30", :height => "30"), user_path(message_user), :target => '_blank' %>
+
+
+
+
+ <%=link_to message_user.show_name, user_path(applied_contest.user_id),
+ :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
+
+
+ <% if applied_contest.role
+ role_str = ""
+ if applied_contest.role.include?('13') && applied_contest.role.include?('14')
+ role_str = "管理员、评委"
+ elsif applied_contest.role.include?('13')
+ role_str = "管理员"
+ elsif applied_contest.role.include?('14')
+ role_str = "评委"
+ elsif applied_contest.role.include?('15')
+ role_str = "参赛者"
+ end
+ end %>
+ 申请以<%= role_str %>的身份加入竞赛:
+
+
+
+ <% content = message_user.show_name + "申请成为班级\"" + "#{contest.name}" + "\"的" + role_str %>
+ <%= link_to contest.name, contest_path(contest.id),
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank', :title => "#{content}" %>
+
+
+
+
+ <% if ma.status == 0 %>
+ <%= link_to '同意',dealwith_apply_request_contest_path(contest,:agree=>'Y',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%>
+ |
+ <%= link_to '拒绝',dealwith_apply_request_contest_path(contest,:agree=>'N',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%>
+ <% elsif ma.status == 1%>
+ 已同意申请
+ <% elsif ma.status == 2%>
+ 已拒绝申请
+ <%end %>
+
+
+<%= time_tag(ma.created_at).html_safe %>
+
diff --git a/app/views/users/_my_contests.html.erb b/app/views/users/_my_contests.html.erb
new file mode 100644
index 000000000..e94e48bd2
--- /dev/null
+++ b/app/views/users/_my_contests.html.erb
@@ -0,0 +1,3 @@
+
+ <%= render :partial => 'users/contest_list', :locals => {:contests => @my_contests, :list_type => 1, :count => @my_contests_count}%>
+
\ No newline at end of file
diff --git a/app/views/users/_my_joined_contests.html.erb b/app/views/users/_my_joined_contests.html.erb
new file mode 100644
index 000000000..4c7973e96
--- /dev/null
+++ b/app/views/users/_my_joined_contests.html.erb
@@ -0,0 +1,3 @@
+
+ <%= render :partial => 'users/contest_list', :locals => {:contests => @my_joined_contests, :list_type => 2, :count => @my_joined_contests_count}%>
+
\ No newline at end of file
diff --git a/app/views/users/_new_user_message.html.erb b/app/views/users/_new_user_message.html.erb
index 9fe27bcaa..a5c94df12 100644
--- a/app/views/users/_new_user_message.html.erb
+++ b/app/views/users/_new_user_message.html.erb
@@ -10,6 +10,9 @@
<%= render :partial => 'users/user_message_forge', :locals => {:ma => ma} %>
+ <%# 竞赛消息 %>
+ <%= render :partial => 'users/user_message_contest', :locals => {:ma => ma} %>
+
<%= render :partial => 'users/user_message_forum', :locals => {:ma => ma} %>
diff --git a/app/views/users/_news_replies.html.erb b/app/views/users/_news_replies.html.erb
index f14a7557f..aef4fb794 100644
--- a/app/views/users/_news_replies.html.erb
+++ b/app/views/users/_news_replies.html.erb
@@ -32,11 +32,11 @@
- <% if type == 'HomeworkCommon' %>
+ <% if type == 'HomeworkCommon' || type == 'Work' %>
<%= link_to(
l(:button_reply),
- {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :user_activity_id => user_activity_id},
+ {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id},
:remote => true,
:method => 'get',
:title => l(:button_reply)) %>
diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb
index d25d0aa01..7cce93ade 100644
--- a/app/views/users/_reply_to.html.erb
+++ b/app/views/users/_reply_to.html.erb
@@ -13,6 +13,16 @@
<% end%>
+ <% elsif @type == 'Work' %>
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_contest_work', :id => reply.id},:method => "post", :remote => true) do |f| %>
+ >
+
+
+
+ 发送
+
+
+ <% end%>
<% elsif @type == 'JournalsForMessage' %>
<%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => reply.id}, :method => "post", :remote => true) do |f|%>
<%= hidden_field_tag 'reference_id', params[:reference_id], :value => reply.id %>
diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb
index f0fa4d33e..03c54df77 100644
--- a/app/views/users/_user_activities.html.erb
+++ b/app/views/users/_user_activities.html.erb
@@ -2,25 +2,25 @@
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<% end %>
<% if user_activity.act_type == "Project" %>
<%= render :partial => 'project_create', :locals => {:activity => user_activity, :user_activity_id => user_activity.id} %>
<% else %>
- <% act = user_activity.act %>
+ <% act= user_activity.act %>
<% if act %>
<% case user_activity.container_type.to_s %>
<% when 'Course' %>
@@ -48,70 +48,82 @@
<% when 'HomeworkCommon' %>
<%# cache (act) do %>
<% hidden_courses = Setting.find_by_name("hidden_courses") %>
- <% unvisiable = hidden_courses && hidden_courses.value == "1"%>
+ <% unvisiable = hidden_courses && hidden_courses.value == "1" %>
<% if !unvisiable %>
- <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id => user_activity.id,:hw_status => 1} %>
+ <%= render :partial => 'course_homework', :locals => {:activity => act, :user_activity_id => user_activity.id, :hw_status => 1} %>
<% end %>
<%# end %>
<% when 'News' %>
<%# cache [act, act.comments.count] do %>
- <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
+ <%= render :partial => 'course_news', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<%# end %>
- <% when 'Attachment'%>
- <%= render :partial => 'users/course_attachment', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
- <% when 'Message'%>
- <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %>
+ <% when 'Message' %>
+ <%= render :partial => 'course_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_course => 0, :is_board => 0} %>
<% when 'Poll' %>
<%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
- <% when 'Course'%>
+ <% when 'Course' %>
<%# cache (act) do %>
<%= render :partial => 'users/course_create', :locals => {:activity => act, :user_activity_id => act.id} %>
<%# end%>
- <% when 'JournalsForMessage'%>
+ <% when 'JournalsForMessage' %>
<%= render :partial => 'users/course_journalsformessage', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<% end %>
<% when 'Project' %>
<% case user_activity.act_type.to_s %>
<% when 'Issue' %>
<%# cache [act, act.journals.count, act.attachments.count] do%>
- <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id, :user_id => user_id} %>
+ <%= render :partial => 'project_issue', :locals => {:activity => act, :user_activity_id => user_activity.id, :user_id => user_id} %>
<%# end %>
<% when 'Message' %>
- <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id => user_activity.id, :is_course => 0,:is_board=>0} %>
- <% when 'Project'%>
+ <%= render :partial => 'project_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_course => 0, :is_board => 0} %>
+ <% when 'Project' %>
<%# cache (act) do %>
- <%= render :partial => 'project_create', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
+ <%= render :partial => 'project_create', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<%# end %>
<% end %>
+ <% when 'Contest' %>
+ <% case user_activity.act_type.to_s %>
+ <% when 'Work' %>
+ <%= render :partial => 'contest_work', :locals => {:activity => act, :user_activity_id => user_activity.id, :hw_status => 1} %>
+ <% when 'News' %>
+ <%= render :partial => 'contest_news', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
+ <% when 'Message' %>
+ <%#= render :partial => 'contest_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_contest => 0, :is_board => 0} %>
+ <% when 'Contest' %>
+ <%= render :partial => 'users/contest_create', :locals => {:activity => act, :user_activity_id => act.id} %>
+ <% when 'JournalsForMessage' %>
+ <%#= render :partial => 'users/contest_journalsformessage', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
+ <% end %>
<% when 'Principal' %>
<% case user_activity.act_type.to_s %>
<% when 'JournalsForMessage' %>
<% unless act.private == 1 && (!User.current || (User.current && act.jour_id != User.current.id && act.user_id != User.current.id)) %>
- <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
+ <%= render :partial => 'user_journalsformessage', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<% end %>
<% end %>
- <% when 'Blog'%>
+ <% when 'Blog' %>
<%# cache (act) do %>
<% case user_activity.act_type.to_s %>
- <% when 'BlogComment' %>
+ <% when 'BlogComment' %>
<%# if !(act.blog.homepage_id and act.id == act.blog.homepage_id) %>
- <%= render :partial => 'user_blog', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
+ <%= render :partial => 'user_blog', :locals => {:activity => act, :user_activity_id => user_activity.id} %>
<%# end %>
- <% end %>
+ <% end %>
<%# end %>
- <% end %>
+ <% end %>
+
<% end %>
<% end %>
- <% end %>
+ <% end %>
<% end %>
-<% if user_activities.count == 10%>
+<% if user_activities.count == 10 %>
- <%= link_to "点击展开更多", action == "project_community" ? user_project_community_path(@user.id, :type => type, :page => page) : (action == "course_community" ? user_course_community_path(@user.id, :type => type,:page => page) : user_activities_path(@user.id,:type => type,:page => page)),
+ <%= link_to "点击展开更多", action == "project_community" ? user_project_community_path(@user.id, :type => type, :page => page) : (action == "course_community" ? user_course_community_path(@user.id, :type => type, :page => page) : (action == "contest_community" ? user_contest_community_path(@user.id, :type => type, :page => page) : user_activities_path(@user.id, :type => type, :page => page))),
:id => "show_more_activities", :remote => "true", :class => "loadMore mt10 f_grey" %>
-<% end%>
+<% end %>
+
+
+<%# end %>
+<%# if activity.homework_type == 2 && is_teacher%>
+
+
+
+
+
+
+
+ <%# end %>
+<%# end %>
+<% if activity.work_type == 3 && activity.work_detail_group%>
+ <% if activity.work_detail_group.base_on_project %>
+
+ <%=link_to "项目(#{activity.contestant_work_projects.where(:is_leader => true).count})",contestant_works_path(:work =>activity.id, :tab => 3),:class => "c_blue" %>
+
+ <% end %>
+
+ 分组人数:<%=activity.work_detail_group.min_num %>-<%=activity.work_detail_group.max_num %> 人
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/cancel_or_collect.js.erb b/app/views/users/cancel_or_collect.js.erb
index 833fa3260..7db92e4e7 100644
--- a/app/views/users/cancel_or_collect.js.erb
+++ b/app/views/users/cancel_or_collect.js.erb
@@ -8,4 +8,9 @@
if($("#collect_project_icon_<%=@project.id %>").length > 0){
$("#collect_project_icon_<%=@project.id %>").html("<%= escape_javascript(render :partial => 'users/collect_project', :locals => {:project => @project}) %>");
}
+<% elsif @contest %>
+ $("#homepage_left_contest_list").html("<%= escape_javascript(render :partial => 'layouts/homepage_left_contest_list', :locals => {:contests => @contests}) %>");
+ if($("#collect_project_icon_<%= @contest.id %>").length > 0){
+ $("#collect_project_icon_<%= @contest.id %>").html("<%= escape_javascript(render :partial => 'users/collect_contest', :locals => {:contest => @contest}) %>");
+ }
<% end %>
\ No newline at end of file
diff --git a/app/views/users/contest_community.html.erb b/app/views/users/contest_community.html.erb
new file mode 100644
index 000000000..0b4b971eb
--- /dev/null
+++ b/app/views/users/contest_community.html.erb
@@ -0,0 +1,32 @@
+
+
+
+
+<% if @user_activities_count > 0 %>
+ <%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities, :page => 0, :type => @type,
+ :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id), :action => "contest_community" } %>
+<% else %>
+
+ <%= render :partial => 'users/no_data' %>
+
+<% end %>
diff --git a/app/views/users/user_contestlist.html.erb b/app/views/users/user_contestlist.html.erb
new file mode 100644
index 000000000..6acade05e
--- /dev/null
+++ b/app/views/users/user_contestlist.html.erb
@@ -0,0 +1,39 @@
+
+
竞赛列表
+ <%= render :partial => 'users/my_contests'%>
+
+ <%= render :partial => 'users/my_joined_contests'%>
+
+
+
+
diff --git a/app/views/contests/show_notification.html.erb b/app/views/users/user_contests4show.html.erb
similarity index 100%
rename from app/views/contests/show_notification.html.erb
rename to app/views/users/user_contests4show.html.erb
diff --git a/app/views/words/leave_contest_work_message.js.erb b/app/views/words/leave_contest_work_message.js.erb
new file mode 100644
index 000000000..fc322e140
--- /dev/null
+++ b/app/views/words/leave_contest_work_message.js.erb
@@ -0,0 +1,6 @@
+$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work_post_reply', :locals => {:activity => @contestwork, :user_activity_id => @user_activity_id, :is_teacher => @is_teacher}) %>");
+<% 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 %>
\ No newline at end of file
diff --git a/app/views/words/reply_to_contest_work.js.erb b/app/views/words/reply_to_contest_work.js.erb
new file mode 100644
index 000000000..fc322e140
--- /dev/null
+++ b/app/views/words/reply_to_contest_work.js.erb
@@ -0,0 +1,6 @@
+$("#homework_post_reply_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/contest_work_post_reply', :locals => {:activity => @contestwork, :user_activity_id => @user_activity_id, :is_teacher => @is_teacher}) %>");
+<% 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 %>
\ No newline at end of file
diff --git a/app/views/works/_contest_work_form.html.erb b/app/views/works/_contest_work_form.html.erb
new file mode 100644
index 000000000..0fcd97e26
--- /dev/null
+++ b/app/views/works/_contest_work_form.html.erb
@@ -0,0 +1,261 @@
+<% not_allow_select = edit_mode && homework.contestant_works.count != 0 %>
+<% content_for :header_tags do %>
+ <%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
+
+ <%= javascript_include_tag 'homework','baiduTemplate' %>
+
+<% end %>
+
+
+
+
+ <%= hidden_field_tag :contest, params[:contest], :value =>@contest.id %>
+
+ <% group_pro = homework.work_type == 3 && homework.contestant_work_projects.count != 0 %>
+ id="homework_type_option">
+ <%= options_for_select(work_type_option,edit_mode ? homework.work_type : 0) %>
+
+ <% if not_allow_select || group_pro %>
+
+ <% end %>
+ 发布题目,请先选择竞赛类型
+
+
+
+
+
+
+
+
截止日期:
+
+
+ <%= calendar_for('homework_end_time')%>
+
+
发布日期(可选):
+
+ <% allow_edit = homework.contestant_works.count == 0 && homework.contestant_work_projects.count ==0 %>
+
+ <% if allow_edit %>
+ <%= calendar_for('homework_publish_time')%>
+ <% end %>
+
+
+
+
+
+
+ <% if edit_mode %>
+
+ <%#= f.kindeditor :description, :editor_id => 'work_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %>
+ <% else %>
+ <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %>
+
+ <%#= f.kindeditor :description, :editor_id => 'work_description_editor', :height => "150px",at_id: homework.id, at_type: homework.class.to_s %>
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+
+ <%= render :partial => 'attachments/form_course', :locals => {:container => homework, :isReply => false} %>
+
+
+
+ <% if edit_mode %>
+
确定
+
或
+ <%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%>
+
取消
+ <% else %>
+
发送
+
或
+
取消
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<% unless edit_mode %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/works/_work_group_attr.html.erb b/app/views/works/_work_group_attr.html.erb
new file mode 100644
index 000000000..4d9774bdc
--- /dev/null
+++ b/app/views/works/_work_group_attr.html.erb
@@ -0,0 +1,49 @@
+
+
分组设置:
+
每组最小人数:
+ />人
+
+
每组最大人数:
+ />人
+
+
+
+
+
+ />
+ 基于项目实施
+
+
提醒:勾选后各小组必须在Trustie平台创建项目,主办人和评委可随时观察平台对各小组最新进展的实时统计
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/works/_work_index_list.html.erb b/app/views/works/_work_index_list.html.erb
new file mode 100644
index 000000000..eb2736689
--- /dev/null
+++ b/app/views/works/_work_index_list.html.erb
@@ -0,0 +1,40 @@
+<%= content_for(:header_tags) do %>
+ <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
+<% end %>
+
+
+ <% homework_commons.each do |homework_common|%>
+
+ <%= render :partial => 'users/contest_work', :locals => {:activity => homework_common, :user_activity_id =>homework_common.id, :hw_status => 3} %>
+ <% end%>
+
+
+
+
+
+ <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true, :is_new => true%>
+
+
+
+
\ No newline at end of file
diff --git a/app/views/works/_work_search_form.html.erb b/app/views/works/_work_search_form.html.erb
new file mode 100644
index 000000000..52d2f6d2a
--- /dev/null
+++ b/app/views/works/_work_search_form.html.erb
@@ -0,0 +1,6 @@
+<%= form_tag(works_path(:contest => contest.id),
+ :remote=>true ,:method => 'get',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %>
+
+ <%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/works/edit.html.erb b/app/views/works/edit.html.erb
new file mode 100644
index 000000000..f9161e12b
--- /dev/null
+++ b/app/views/works/edit.html.erb
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+ <% committed_work_count = @homework.contestant_works.count %>
+ <% stu_pro_count = @homework.contestant_work_projects.count %>
+ <% if committed_work_count != 0 %>
+ <% if @homework.work_type == 1 %>
+
已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型。
+ <% elsif @homework.work_type == 3 %>
+
已有<%=committed_work_count %>个学生提交作品,不允许再修改作业类型和分组设置(可扩大分组范围)。
+ <% end %>
+ <% elsif stu_pro_count != 0 && @homework.work_type == 3 %>
+
已有<%=stu_pro_count %>个学生关联项目,不允许再修改作业类型。
+ <% end %>
+
+ <%= form_for @homework do |f| %>
+
+
+ <%= render :partial => 'contest_work_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
+
+ <% end%>
+
\ No newline at end of file
diff --git a/app/views/works/index.html.erb b/app/views/works/index.html.erb
new file mode 100644
index 000000000..e83e6d97b
--- /dev/null
+++ b/app/views/works/index.html.erb
@@ -0,0 +1,84 @@
+
+
+
+
+
+
diff --git a/app/views/works/index.js.erb b/app/views/works/index.js.erb
new file mode 100644
index 000000000..81467756c
--- /dev/null
+++ b/app/views/works/index.js.erb
@@ -0,0 +1 @@
+$("#homework_index_list").html("<%=escape_javascript(render :partial => 'work_index_list', :locals => {:homework_commons => @homeworks,:contest_id => @contest.id}) %>");
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index ac18cda3e..e5fd7b93b 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -377,7 +377,8 @@ zh:
label_user: 用户
label_user_plural: 用户列表
-
+ permission_new_contest: 新建竞赛
+ label_tags_contest_name: 竞赛名称
label_user_new: 新建用户
label_user_anonymous: 匿名用户
@@ -1601,6 +1602,9 @@ zh:
label_participator: 参与者
label_contest_modify_settings: 配置竞赛
label_no_current_participate: 该竞赛暂无参与者
+ label_CM: 管理员
+ label_judge: 评委
+ label_contestant: 参赛者
#end
diff --git a/config/routes.rb b/config/routes.rb
index 14942ed28..91a627424 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -359,8 +359,6 @@ RedmineApp::Application.routes.draw do
end
end
- resources :contest_notification
-
resources :open_source_projects do
collection do
match 'search', :via => [:get, :post]
@@ -403,47 +401,46 @@ RedmineApp::Application.routes.draw do
end
end
- ## new added by linchun #新竞赛相关
- resources :contests, only: [:index] do
- resources :contestnotifications do
- # get 'preview', on: :collection
- resources :notificationcomments
- end
-
- collection do
- match 'new_contest' , :via => :get
- match 'join_in_contest' , :via => :post
- match 'unjoin_in_contest' , :via => :delete
- match 'create_contest' , :via => :post
- match 'new_join' , :via => :post
- match 'new' , :via => :post
- end
- member do
- delete 'destroy_contest'
- match 'add_softapplication'
- match 'update_contest' , :via => [:put]
- match 'show_contest' , :via => [:get, :post]
- match 'show_project' , :via => :get
- match 'show_softapplication' , :via => :get
- match 'show_attendingcontest' , :via => :get
- #match 'show_notification' , :via => :get
- match 'show_participator' , :via => :get
- match 'set_reward_project' , :via => [:get, :post]
- match 'set_reward_softapplication' , :via => [:get, :post]
- match 'add' , :via => [:get, :post]
- match 'add_softapplication' , :via => [:get, :post]
- match 'create' , :via => :post
- match 'settings' , :via => [:get, :post]
- match 'show_contest_user'
- get 'watcherlist', :action=> 'watcherlist'
- end
- end
+ # ## new added by linchun #新竞赛相关
+ # resources :contests, only: [:index] do
+ # resources :contestnotifications do
+ # # get 'preview', on: :collection
+ # resources :notificationcomments
+ # end
+ #
+ # collection do
+ # match 'new_contest' , :via => :get
+ # match 'join_in_contest' , :via => :post
+ # match 'unjoin_in_contest' , :via => :delete
+ # match 'create_contest' , :via => :post
+ # match 'new_join' , :via => :post
+ # match 'new' , :via => :post
+ # end
+ # member do
+ # delete 'destroy_contest'
+ # match 'add_softapplication'
+ # match 'update_contest' , :via => [:put]
+ # match 'show_contest' , :via => [:get, :post]
+ # match 'show_project' , :via => :get
+ # match 'show_softapplication' , :via => :get
+ # match 'show_attendingcontest' , :via => :get
+ # #match 'show_notification' , :via => :get
+ # match 'show_participator' , :via => :get
+ # match 'set_reward_project' , :via => [:get, :post]
+ # match 'set_reward_softapplication' , :via => [:get, :post]
+ # match 'add' , :via => [:get, :post]
+ # match 'add_softapplication' , :via => [:get, :post]
+ # match 'create' , :via => :post
+ # match 'settings' , :via => [:get, :post]
+ # match 'show_contest_user'
+ # get 'watcherlist', :action=> 'watcherlist'
+ # end
+ # end
match '/news/preview', :to => 'previews#news', :as => 'preview_news', :via => [:get, :post, :put]
match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put]
match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put]
match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put]
- match '/contestnotifications/preview', :to => 'previews#contestnotification', :as => 'preview_contestnotifications', :via => [:get, :post, :put]
resources :stores do
collection do
@@ -570,11 +567,84 @@ RedmineApp::Application.routes.draw do
match 'users/:id/courses', :to => 'users#course_community', :as => "user_course_community"
match 'users/:id/projects', :to => 'users#project_community', :as => "user_project_community"
+ match 'users/:id/contests', :to => 'users#contest_community', :as => "user_contest_community"
scope ":username" do
resources :posts
end
+# added by cxt
+ resources :contest_members do
+ collection do
+ get 'contest_member_autocomplete'
+ end
+
+ member do
+
+ end
+ end
+
+ # added by cxt
+ resources :contestant_works do
+ collection do
+ post 'student_work_project'
+ get 'new_student_work_project'
+ get 'cancel_relate_project'
+ get 'delete_work'
+ get 'search_contest_students'
+ end
+
+ member do
+ get 'retry_work'
+ end
+ end
+
+ # added by cxt
+ resources :works do
+ collection do
+
+ end
+
+ member do
+
+ end
+ end
+
+ # added by cxt
+ resources :contests do
+ collection do
+ get 'join_contest'
+ get 'set_contest_attribute'
+ post 'join_contest_multi_role'
+ end
+
+ member do
+ match 'settings' , :via => [:get, :post]
+ get 'dealwith_apply_request'
+ get 'contest_activities'
+ get 'private_or_public'
+ get "switch_role"
+ end
+
+ resources :boards
+ resources :files, :only => [:index, :new, :create] do
+ collection do
+ match "getattachtype", :via => [:get, :post]
+ match "search",:via => [:post,:get]
+ match "searchone4reload",:via => [:post,:get]
+ match "search_tag_attachment", :via => [:post,:get]
+ end
+ member do
+ match "quote_resource_show", :via => [:get]
+ get "file_hidden"
+ post "republish_file"
+ get "update_file_description"
+ post "edit_file_description"
+ end
+ end
+ resources :news, :except => [:show, :edit, :update, :destroy]
+ end
+
#added by young
resources :users do
collection do
@@ -604,6 +674,7 @@ RedmineApp::Application.routes.draw do
match 'user_courses', :to => 'users#user_courses', :via => :get
match 'user_courses4show', :to => 'users#user_courses4show', :via => :get
match 'user_projects4show', :to => 'users#user_projects4show', :via => :get
+ match 'user_contests4show', :to => 'users#user_contests4show', :via => :get
match 'user_course_activities', :to => 'users#user_course_activities', :via => :get
match 'user_project_activities', :to => 'users#user_project_activities', :via => :get
match 'user_feedback4show', :to => 'users#user_feedback4show', :via => :get
@@ -647,6 +718,7 @@ RedmineApp::Application.routes.draw do
#addby yk
match 'user_courselist', :to => 'users#user_courselist', :via => :get, :as => "user_courselist"
match 'user_projectlist', :to => 'users#user_projectlist', :via => :get, :as => "user_projectlist"
+ match 'user_contestlist', :to => 'users#user_contestlist', :via => :get, :as => "user_contestlist"
match 'sort_syllabus_list', :to => 'users#sort_syllabus_list', :via => :get, :as => "sort_syllabus_list"
match 'sort_project_list', :to => 'users#sort_project_list', :via => :get, :as => "sort_project_list"
@@ -1357,6 +1429,8 @@ RedmineApp::Application.routes.draw do
post 'words/:id/leave_syllabus_message', :to => 'words#leave_syllabus_message', :as => "leave_syllabus_message"
post 'words/:id/leave_homework_message', :to => 'words#leave_homework_message', :as => "leave_homework_message"
post 'words/:id/reply_to_homework', :to => 'words#reply_to_homework', :as => "reply_to_homework"
+ post 'words/:id/leave_contest_work_message', :to => 'words#leave_contest_work_message', :as => "leave_contest_work_message"
+ post 'words/:id/reply_to_contest_work', :to => 'words#reply_to_contest_work', :as => "reply_to_contest_work"
post 'words/:id/reply_to_syllabus', :to => 'words#reply_to_syllabus', :as => "reply_to_syllabus"
post 'join_in/join', :to => 'courses#join', :as => 'join'
diff --git a/db/migrate/20140327071420_create_contests.rb b/db/migrate/20140327071420_create_contests.rb
deleted file mode 100644
index 0ec04a6c5..000000000
--- a/db/migrate/20140327071420_create_contests.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-class CreateContests < ActiveRecord::Migration
- def change
- create_table :contests do |t|
- t.string :name
- t.integer :budget
- t.integer :author_id
- t.date :deadline
- t.string :description
- t.integer :commit
- t.string :password
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20140327073052_create_contesting_projects.rb b/db/migrate/20140327073052_create_contesting_projects.rb
deleted file mode 100644
index b9dc336b2..000000000
--- a/db/migrate/20140327073052_create_contesting_projects.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class CreateContestingProjects < ActiveRecord::Migration
- def change
- create_table :contesting_projects do |t|
- t.integer :project_id
- t.string :contest_id
- t.integer :user_id
- t.string :description
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20140411003234_create_contesting_softapplications.rb b/db/migrate/20140411003234_create_contesting_softapplications.rb
deleted file mode 100644
index 118b518f5..000000000
--- a/db/migrate/20140411003234_create_contesting_softapplications.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class CreateContestingSoftapplications < ActiveRecord::Migration
- def change
- create_table :contesting_softapplications do |t|
- t.integer :softapplication_id
- t.integer :contest_id
- t.integer :user_id
- t.string :description
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20140530010015_create_contestnotifications.rb b/db/migrate/20140530010015_create_contestnotifications.rb
deleted file mode 100644
index 5aa1e2f9f..000000000
--- a/db/migrate/20140530010015_create_contestnotifications.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-class CreateContestnotifications < ActiveRecord::Migration
- def change
- create_table :contestnotifications do |t|
- t.integer :contest_id
- t.string :title
- t.string :summary
- t.string :description
- t.integer :author_id
- t.integer :notificationcomments_count
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20140722080529_create_contest_notifications.rb b/db/migrate/20140722080529_create_contest_notifications.rb
deleted file mode 100644
index 0aff8d268..000000000
--- a/db/migrate/20140722080529_create_contest_notifications.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class CreateContestNotifications < ActiveRecord::Migration
- def change
- create_table :contest_notifications do |t|
- t.text :title
- t.text :content
-
- t.timestamps
- end
- end
-end
diff --git a/db/migrate/20161220062249_create_contests.rb b/db/migrate/20161220062249_create_contests.rb
new file mode 100644
index 000000000..13121efa0
--- /dev/null
+++ b/db/migrate/20161220062249_create_contests.rb
@@ -0,0 +1,26 @@
+class CreateContests < ActiveRecord::Migration
+ def change
+ drop_table :contests
+ drop_table :contest_notifications
+ drop_table :contesting_projects
+ drop_table :contesting_softapplications
+ drop_table :contestnotifications
+
+ create_table :contests do |t|
+ t.integer :user_id
+ t.string :name
+ t.text :description
+ t.boolean :is_public
+ t.boolean :is_delete, :default => false
+ t.integer :visits, :default => 0
+ t.string :invite_code
+ t.integer :invite_code_halt, :default => 0
+
+ t.timestamps
+ end
+
+ for i in 1 .. 779
+ Contest.create(:user_id => 2, :name => 'test', :is_public => false, :is_delete => true)
+ end
+ end
+end
diff --git a/db/migrate/20161220090638_create_contest_members.rb b/db/migrate/20161220090638_create_contest_members.rb
new file mode 100644
index 000000000..d2b492045
--- /dev/null
+++ b/db/migrate/20161220090638_create_contest_members.rb
@@ -0,0 +1,13 @@
+class CreateContestMembers < ActiveRecord::Migration
+ def change
+ create_table :contest_members do |t|
+ t.references :user
+ t.references :contest
+ t.boolean :is_collect, :default => true
+
+ t.timestamps
+ end
+ add_index :contest_members, :user_id
+ add_index :contest_members, :contest_id
+ end
+end
diff --git a/db/migrate/20161220090826_create_contest_member_roles.rb b/db/migrate/20161220090826_create_contest_member_roles.rb
new file mode 100644
index 000000000..83c9b481d
--- /dev/null
+++ b/db/migrate/20161220090826_create_contest_member_roles.rb
@@ -0,0 +1,13 @@
+class CreateContestMemberRoles < ActiveRecord::Migration
+ def change
+ create_table :contest_member_roles do |t|
+ t.references :contest_member
+ t.references :role
+ t.boolean :is_current, :default => true
+
+ t.timestamps
+ end
+ add_index :contest_member_roles, :contest_member_id
+ add_index :contest_member_roles, :role_id
+ end
+end
diff --git a/db/migrate/20161220093609_create_contestant_for_contests.rb b/db/migrate/20161220093609_create_contestant_for_contests.rb
new file mode 100644
index 000000000..8c5764e5a
--- /dev/null
+++ b/db/migrate/20161220093609_create_contestant_for_contests.rb
@@ -0,0 +1,12 @@
+class CreateContestantForContests < ActiveRecord::Migration
+ def change
+ create_table :contestant_for_contests do |t|
+ t.integer :student_id
+ t.references :contest
+
+ t.timestamps
+ end
+ add_index :contestant_for_contests, :contest_id
+ add_index :contestant_for_contests, :student_id
+ end
+end
diff --git a/db/migrate/20161221055334_create_works.rb b/db/migrate/20161221055334_create_works.rb
new file mode 100644
index 000000000..d3c22de6b
--- /dev/null
+++ b/db/migrate/20161221055334_create_works.rb
@@ -0,0 +1,21 @@
+class CreateWorks < ActiveRecord::Migration
+ def change
+ create_table :works do |t|
+ t.string :name
+ t.references :user
+ t.text :description
+ t.date :publish_time
+ t.date :end_time
+ t.integer :work_type
+ t.references :contest
+ t.boolean :is_delete, :default => false
+ t.boolean :score_open, :default => true
+ t.boolean :is_open, :default => false
+ t.integer :work_status
+
+ t.timestamps
+ end
+ add_index :works, :user_id
+ add_index :works, :contest_id
+ end
+end
diff --git a/db/migrate/20161221060341_create_contest_activities.rb b/db/migrate/20161221060341_create_contest_activities.rb
new file mode 100644
index 000000000..cbc601a91
--- /dev/null
+++ b/db/migrate/20161221060341_create_contest_activities.rb
@@ -0,0 +1,14 @@
+class CreateContestActivities < ActiveRecord::Migration
+ def change
+ create_table :contest_activities do |t|
+ t.references :user
+ t.references :contest
+ t.integer :contest_act_id
+ t.string :contest_act_type
+
+ t.timestamps
+ end
+ add_index :contest_activities, :user_id
+ add_index :contest_activities, :contest_id
+ end
+end
diff --git a/db/migrate/20161221060853_create_contest_messages.rb b/db/migrate/20161221060853_create_contest_messages.rb
new file mode 100644
index 000000000..7c1a10113
--- /dev/null
+++ b/db/migrate/20161221060853_create_contest_messages.rb
@@ -0,0 +1,17 @@
+class CreateContestMessages < ActiveRecord::Migration
+ def change
+ create_table :contest_messages do |t|
+ t.references :user
+ t.references :contest
+ t.integer :contest_message_id
+ t.string :contest_message_type
+ t.boolean :viewed, :default => false
+ t.text :content
+ t.integer :status
+
+ t.timestamps
+ end
+ add_index :contest_messages, :user_id
+ add_index :contest_messages, :contest_id
+ end
+end
diff --git a/db/migrate/20161221065228_create_work_detail_groups.rb b/db/migrate/20161221065228_create_work_detail_groups.rb
new file mode 100644
index 000000000..0479cfe06
--- /dev/null
+++ b/db/migrate/20161221065228_create_work_detail_groups.rb
@@ -0,0 +1,13 @@
+class CreateWorkDetailGroups < ActiveRecord::Migration
+ def change
+ create_table :work_detail_groups do |t|
+ t.references :work
+ t.integer :min_num
+ t.integer :max_num
+ t.boolean :base_on_project
+
+ t.timestamps
+ end
+ add_index :work_detail_groups, :work_id
+ end
+end
diff --git a/db/migrate/20161221065841_create_contestant_works.rb b/db/migrate/20161221065841_create_contestant_works.rb
new file mode 100644
index 000000000..f65bc15da
--- /dev/null
+++ b/db/migrate/20161221065841_create_contestant_works.rb
@@ -0,0 +1,20 @@
+class CreateContestantWorks < ActiveRecord::Migration
+ def change
+ create_table :contestant_works do |t|
+ t.string :name
+ t.text :description
+ t.references :work
+ t.references :user
+ t.float :work_score
+ t.references :project
+ t.integer :work_status
+ t.timestamp :commit_time
+ t.boolean :is_delete, :default => false
+
+ t.timestamps
+ end
+ add_index :contestant_works, :work_id
+ add_index :contestant_works, :user_id
+ add_index :contestant_works, :project_id
+ end
+end
diff --git a/db/migrate/20161221070253_create_contestant_work_projects.rb b/db/migrate/20161221070253_create_contestant_work_projects.rb
new file mode 100644
index 000000000..aba5ab6ff
--- /dev/null
+++ b/db/migrate/20161221070253_create_contestant_work_projects.rb
@@ -0,0 +1,18 @@
+class CreateContestantWorkProjects < ActiveRecord::Migration
+ def change
+ create_table :contestant_work_projects do |t|
+ t.references :contest
+ t.references :work
+ t.references :contestant_work
+ t.references :project
+ t.references :user
+ t.boolean :is_leader
+
+ t.timestamps
+ end
+ add_index :contestant_work_projects, :contest_id
+ add_index :contestant_work_projects, :work_id
+ add_index :contestant_work_projects, :contestant_work_id
+ add_index :contestant_work_projects, :user_id
+ end
+end
diff --git a/db/migrate/20161221070623_create_contestant_work_scores.rb b/db/migrate/20161221070623_create_contestant_work_scores.rb
new file mode 100644
index 000000000..770cd9dcf
--- /dev/null
+++ b/db/migrate/20161221070623_create_contestant_work_scores.rb
@@ -0,0 +1,15 @@
+class CreateContestantWorkScores < ActiveRecord::Migration
+ def change
+ create_table :contestant_work_scores do |t|
+ t.references :contestant_work
+ t.references :user
+ t.integer :score
+ t.text :comment
+ t.integer :reviewer_role
+
+ t.timestamps
+ end
+ add_index :contestant_work_scores, :contestant_work_id
+ add_index :contestant_work_scores, :user_id
+ end
+end
diff --git a/db/migrate/20161222033007_update_mail_notification.rb b/db/migrate/20161222033007_update_mail_notification.rb
new file mode 100644
index 000000000..4469bd8f0
--- /dev/null
+++ b/db/migrate/20161222033007_update_mail_notification.rb
@@ -0,0 +1,7 @@
+class UpdateMailNotification < ActiveRecord::Migration
+ def up
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/20161222063638_create_applied_contests.rb b/db/migrate/20161222063638_create_applied_contests.rb
new file mode 100644
index 000000000..b110c6e95
--- /dev/null
+++ b/db/migrate/20161222063638_create_applied_contests.rb
@@ -0,0 +1,14 @@
+class CreateAppliedContests < ActiveRecord::Migration
+ def change
+ create_table :applied_contests do |t|
+ t.references :contest
+ t.references :user
+ t.string :role
+ t.integer :status
+
+ t.timestamps
+ end
+ add_index :applied_contests, :contest_id
+ add_index :applied_contests, :user_id
+ end
+end
diff --git a/db/migrate/20161223083022_add_contest_id_to_news.rb b/db/migrate/20161223083022_add_contest_id_to_news.rb
new file mode 100644
index 000000000..04afbe1e3
--- /dev/null
+++ b/db/migrate/20161223083022_add_contest_id_to_news.rb
@@ -0,0 +1,5 @@
+class AddContestIdToNews < ActiveRecord::Migration
+ def change
+ add_column :news, :contest_id, :integer
+ end
+end
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 885c61969..0f7134490 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -132,6 +132,12 @@ Redmine::AccessControl.map do |map|
map.permission :comment_news, {:comments => :create}
end
+ map.contest_module :news do |map|
+ map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member
+ map.permission :view_contest_news, {:news => [:index, :show]}, :public => true, :read => true
+ map.permission :comment_news, {:comments => :create}
+ end
+
map.course_module :bids do |map|
map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true,:belong_to_course => true
map.permission :paret_in_homework,{},:require => :member ,:belong_to_course => true
diff --git a/public/images/game/banner-game.jpg b/public/images/game/banner-game.jpg
new file mode 100644
index 000000000..cd1f3bbc2
Binary files /dev/null and b/public/images/game/banner-game.jpg differ
diff --git a/public/images/game/banner-game.png b/public/images/game/banner-game.png
new file mode 100644
index 000000000..c5265ba1e
Binary files /dev/null and b/public/images/game/banner-game.png differ
diff --git a/public/javascripts/contest.js b/public/javascripts/contest.js
new file mode 100644
index 000000000..8633c9dbb
--- /dev/null
+++ b/public/javascripts/contest.js
@@ -0,0 +1,28 @@
+/**
+ * Created by cxt on 2016/12/21.
+ */
+
+//提交新建竞赛
+function submit_new_contest()
+{
+ if(regex_contest_name('new'))
+ {
+ $("#new_contest").submit();
+ }
+}
+
+//验证课程名称
+function regex_contest_name(str)
+{
+ var name = $.trim($("#"+str+"_course_name").val());
+ if(name.length < 2)
+ {
+ $("#"+str+"_course_name_notice").show();
+ return false;
+ }
+ else
+ {
+ $("#"+str+"_course_name_notice").hide();
+ return true;
+ }
+}
diff --git a/public/stylesheets/css/common.css b/public/stylesheets/css/common.css
index 449dc2fa5..cdbc543e5 100644
--- a/public/stylesheets/css/common.css
+++ b/public/stylesheets/css/common.css
@@ -151,6 +151,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.ml358{ margin-left:358px;}
.mr-5 {margin-right:-5px;}
.mr2{ margin-right:2px;}
+.mr3{ margin-right:3px;}
.mr5{ margin-right:5px;}
.mr8{ margin-right:8px;}
.mr10{ margin-right:10px;}
@@ -871,4 +872,4 @@ input.btn{display: inline-block;border:none; padding:0 10px;color: #333;backgrou
input.btn-blue{background: #3b94d6; color: #fff; cursor:pointer;}
input:hover.btn-blue{background: #2788d0; color: #fff;}
input.btn-grey{background: #d9d9d9; color: #656565; cursor:default;}
-input.btn-grey:hover{background: #717171; color: #fff; cursor:default;}
\ No newline at end of file
+input.btn-grey:hover{background: #717171; color: #fff; cursor:default;}
diff --git a/public/stylesheets/css/contest.css b/public/stylesheets/css/contest.css
new file mode 100644
index 000000000..4f8e35110
--- /dev/null
+++ b/public/stylesheets/css/contest.css
@@ -0,0 +1,42 @@
+/* 新版项目配置*/
+.pro_new_setting_leftnav{ width: 162px; border:1px solid #ddd; background-color:#fff; padding:3px; padding-bottom: 0;}
+.pro_new_setting_leftnav ul li a{ display: block; height: 40px; line-height: 40px; border-bottom:3px solid #fff; text-align: center; width:162px;}
+.pro_new_setting_leftnav ul li a:hover,.pro_new_setting_leftnav .active{ color: #3b94d6; background: #f3faff; }
+.pro_new_setting_conbox{ background: #fff; width: 818px; border:1px solid #ddd; padding-top: 15px;}
+.pro_new_setting_conbox input,.pro_new_setting_conbox select{ border:1px solid #c8c8c8; color: #888;}
+.pro_new_setting_conbox label{width: 100px; text-align: right; display: inline-block;}
+.w690{width: 690px; }
+.pro_new_upimg{ width: 60px; height: 58px; border:1px solid #ddd; padding:1px;}
+.pro_newsetting_title{ font-size: 14px; color: #3b94d6;}
+
+.mt12{ margin-top:12px;}
+.pro_new_idbox{ width: 40%; padding-left: 30px;}
+.pro_new_idlist{ width: 50%; border-right: 1px solid #e5e5e5; padding-right: 30px; min-height: 100px;}
+.pro_new_idname{display:block;width:300px; overflow:hidden;white-space: nowrap; text-overflow:ellipsis;}
+.sy_new_tchbox p{ line-height: 30px;}
+.pro_newsetting_con p,.pro_newsetting_con { line-height: 30px;}
+.w650{ width: 650px;}
+.pro_new_prompt{ border:1px solid #f6d0b1; padding:10px; background: #fff9e9; color: #ee4a20; text-align: center;}
+p.pro_new_grey{ line-height: 1.9; }
+
+/* 竞赛设置tab*/
+.game-setting-tab{border:1px solid #fff; }
+#game-setting-tab-nav {border-bottom:1px solid #d0d0d0;}
+#game-setting-tab-nav li {float:left; padding:10px 15px; text-align:center; }
+#game-setting-tab-nav li a{font-size:14px; color:#444;}
+.game-setting-nav-hover{border-bottom:3px solid #3498db; font-weight:bold; }
+.game-setting-nav-nomall {border-bottom:none; }
+.undis {display:none;}
+.dis {display:block;}
+/* 竞赛*/
+.banner-game { width: 968px; height: 110px;}
+.game-text-right{ text-align: right;}
+.game-text-left{ text-align: left;}
+.game-setting-h3{ width: 100%; height: 40px; line-height: 40px; font-size: 14px; color: #666; font-weight: normal; background: #fff; border-bottom: 10px solid #eaebec;}
+.w695{width: 695px; }
+.w625{width: 625px; }
+.w621{width: 623px; }
+.description_div{width: 720px; padding: 15px;}
+.contestRightBanner {width:718px; margin:0px auto; float:right; background-color: #ffffff; padding:10px 15px;}
+
+.sy_new_table tbody tr th{ height:40px; line-height:40px; border-bottom:1px solid #e5e5e5; color:#888;}
diff --git a/public/stylesheets/css/project.css b/public/stylesheets/css/project.css
index 8607850c3..2adcd0b4b 100644
--- a/public/stylesheets/css/project.css
+++ b/public/stylesheets/css/project.css
@@ -886,6 +886,7 @@ a:hover.btn_newpro_grey,a:active.btn_newpro_grey{ background: #eaeaea;}
.sy_new_table thead tr td{ border-bottom:1px solid #e5e5e5; font-weight: bold; background-image: linear-gradient(#fcfcfc, #eee);}
.sy_new_table tbody tr:hover{ background:#f5f5f5;}
.sy_new_table tbody tr td{ height:40px; line-height:40px; border-bottom:1px solid #e5e5e5; color:#888;}
+.sy_new_table tbody tr th{ height:40px; line-height:40px; border-bottom:1px solid #e5e5e5; color:#888;}
.table-td-w180{display:inline-block;with:180px; overflow:hidden; text-overflow:ellipsis; -o-text-overflow:ellipsis; white-space:nowrap;}
.table-td-w380{display:inline-block;with:380px; overflow:hidden; text-overflow:ellipsis; -o-text-overflow:ellipsis; white-space:nowrap;}
/*项目简介*/
diff --git a/spec/controllers/contest_members_controller_spec.rb b/spec/controllers/contest_members_controller_spec.rb
new file mode 100644
index 000000000..abcbf4779
--- /dev/null
+++ b/spec/controllers/contest_members_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestMembersController, :type => :controller do
+
+end
diff --git a/spec/controllers/contestant_works_controller_spec.rb b/spec/controllers/contestant_works_controller_spec.rb
new file mode 100644
index 000000000..f266cc1c8
--- /dev/null
+++ b/spec/controllers/contestant_works_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestantWorksController, :type => :controller do
+
+end
diff --git a/spec/controllers/contests_controller_spec.rb b/spec/controllers/contests_controller_spec.rb
new file mode 100644
index 000000000..6e875cd5c
--- /dev/null
+++ b/spec/controllers/contests_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestsController, :type => :controller do
+
+end
diff --git a/spec/controllers/works_controller_spec.rb b/spec/controllers/works_controller_spec.rb
new file mode 100644
index 000000000..fddca1ab1
--- /dev/null
+++ b/spec/controllers/works_controller_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe WorksController, :type => :controller do
+
+end
diff --git a/spec/factories/applied_contests.rb b/spec/factories/applied_contests.rb
new file mode 100644
index 000000000..c52f31497
--- /dev/null
+++ b/spec/factories/applied_contests.rb
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+ factory :applied_contest do
+ contest nil
+user nil
+role ""
+ end
+
+end
diff --git a/spec/factories/contest_activities.rb b/spec/factories/contest_activities.rb
new file mode 100644
index 000000000..450ddd5bb
--- /dev/null
+++ b/spec/factories/contest_activities.rb
@@ -0,0 +1,9 @@
+FactoryGirl.define do
+ factory :contest_activity do
+ user nil
+contest nil
+contest_act_id 1
+contest_act_type "MyString"
+ end
+
+end
diff --git a/spec/factories/contest_member_roles.rb b/spec/factories/contest_member_roles.rb
new file mode 100644
index 000000000..7c18d35ab
--- /dev/null
+++ b/spec/factories/contest_member_roles.rb
@@ -0,0 +1,7 @@
+FactoryGirl.define do
+ factory :contest_member_role do
+ contest_member nil
+role nil
+ end
+
+end
diff --git a/spec/factories/contest_members.rb b/spec/factories/contest_members.rb
new file mode 100644
index 000000000..4222c915c
--- /dev/null
+++ b/spec/factories/contest_members.rb
@@ -0,0 +1,7 @@
+FactoryGirl.define do
+ factory :contest_member do
+ user nil
+contest nil
+ end
+
+end
diff --git a/spec/factories/contest_messages.rb b/spec/factories/contest_messages.rb
new file mode 100644
index 000000000..156304087
--- /dev/null
+++ b/spec/factories/contest_messages.rb
@@ -0,0 +1,12 @@
+FactoryGirl.define do
+ factory :contest_message do
+ user nil
+contest nil
+contest_message_id 1
+course_message_type "MyString"
+viewed false
+content "MyText"
+status 1
+ end
+
+end
diff --git a/spec/factories/contestant_for_contests.rb b/spec/factories/contestant_for_contests.rb
new file mode 100644
index 000000000..61a889aab
--- /dev/null
+++ b/spec/factories/contestant_for_contests.rb
@@ -0,0 +1,7 @@
+FactoryGirl.define do
+ factory :contestant_for_contest do
+ student_id 1
+contest nil
+ end
+
+end
diff --git a/spec/factories/contestant_work_projects.rb b/spec/factories/contestant_work_projects.rb
new file mode 100644
index 000000000..4429d4ec5
--- /dev/null
+++ b/spec/factories/contestant_work_projects.rb
@@ -0,0 +1,11 @@
+FactoryGirl.define do
+ factory :contestant_work_project do
+ contest nil
+work nil
+contestant_work nil
+project nil
+user nil
+is_leader false
+ end
+
+end
diff --git a/spec/factories/contestant_work_scores.rb b/spec/factories/contestant_work_scores.rb
new file mode 100644
index 000000000..d23fa8f3c
--- /dev/null
+++ b/spec/factories/contestant_work_scores.rb
@@ -0,0 +1,10 @@
+FactoryGirl.define do
+ factory :contestant_work_score do
+ contestant_work nil
+user nil
+score 1
+comment "MyText"
+reviewer_role 1
+ end
+
+end
diff --git a/spec/factories/contestant_works.rb b/spec/factories/contestant_works.rb
new file mode 100644
index 000000000..6795be2c0
--- /dev/null
+++ b/spec/factories/contestant_works.rb
@@ -0,0 +1,14 @@
+FactoryGirl.define do
+ factory :contestant_work do
+ name "MyString"
+description "MyText"
+work nil
+user nil
+work_score 1.5
+project nil
+work_status 1
+commit_time "2016-12-21 14:58:41"
+is_delete false
+ end
+
+end
diff --git a/spec/factories/contests.rb b/spec/factories/contests.rb
new file mode 100644
index 000000000..b3a1c2e4e
--- /dev/null
+++ b/spec/factories/contests.rb
@@ -0,0 +1,13 @@
+FactoryGirl.define do
+ factory :contest do
+ user_id 1
+name "MyString"
+description "MyText"
+is_public 1
+is_delete 1
+visits 1
+invite_code "MyString"
+invite_code_halt 1
+ end
+
+end
diff --git a/spec/factories/work_detail_groups.rb b/spec/factories/work_detail_groups.rb
new file mode 100644
index 000000000..7960c1f2b
--- /dev/null
+++ b/spec/factories/work_detail_groups.rb
@@ -0,0 +1,9 @@
+FactoryGirl.define do
+ factory :work_detail_group do
+ work nil
+min_num 1
+max_num 1
+base_on_project false
+ end
+
+end
diff --git a/spec/factories/works.rb b/spec/factories/works.rb
new file mode 100644
index 000000000..a2bccdd47
--- /dev/null
+++ b/spec/factories/works.rb
@@ -0,0 +1,16 @@
+FactoryGirl.define do
+ factory :work do
+ name "MyString"
+user nil
+description "MyText"
+publish_time "2016-12-21"
+end_time "2016-12-21"
+work_type 1
+contest nil
+is_delete false
+score_open false
+is_open false
+work_status 1
+ end
+
+end
diff --git a/spec/models/applied_contest_spec.rb b/spec/models/applied_contest_spec.rb
new file mode 100644
index 000000000..aa150bacc
--- /dev/null
+++ b/spec/models/applied_contest_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe AppliedContest, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/contest_activity_spec.rb b/spec/models/contest_activity_spec.rb
new file mode 100644
index 000000000..223d5ae49
--- /dev/null
+++ b/spec/models/contest_activity_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestActivity, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/contest_member_role_spec.rb b/spec/models/contest_member_role_spec.rb
new file mode 100644
index 000000000..d306f8a1c
--- /dev/null
+++ b/spec/models/contest_member_role_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestMemberRole, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/contest_member_spec.rb b/spec/models/contest_member_spec.rb
new file mode 100644
index 000000000..b6867c64b
--- /dev/null
+++ b/spec/models/contest_member_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestMember, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/contest_message_spec.rb b/spec/models/contest_message_spec.rb
new file mode 100644
index 000000000..3ea36df32
--- /dev/null
+++ b/spec/models/contest_message_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestMessage, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/contest_spec.rb b/spec/models/contest_spec.rb
new file mode 100644
index 000000000..16558959e
--- /dev/null
+++ b/spec/models/contest_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Contest, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/contestant_for_contest_spec.rb b/spec/models/contestant_for_contest_spec.rb
new file mode 100644
index 000000000..8f428f8ba
--- /dev/null
+++ b/spec/models/contestant_for_contest_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestantForContest, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/contestant_work_project_spec.rb b/spec/models/contestant_work_project_spec.rb
new file mode 100644
index 000000000..0a6522d65
--- /dev/null
+++ b/spec/models/contestant_work_project_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestantWorkProject, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/contestant_work_score_spec.rb b/spec/models/contestant_work_score_spec.rb
new file mode 100644
index 000000000..8c2d24166
--- /dev/null
+++ b/spec/models/contestant_work_score_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestantWorkScore, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/contestant_work_spec.rb b/spec/models/contestant_work_spec.rb
new file mode 100644
index 000000000..96ac28487
--- /dev/null
+++ b/spec/models/contestant_work_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe ContestantWork, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/work_detail_group_spec.rb b/spec/models/work_detail_group_spec.rb
new file mode 100644
index 000000000..5d1fb345a
--- /dev/null
+++ b/spec/models/work_detail_group_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe WorkDetailGroup, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/spec/models/work_spec.rb b/spec/models/work_spec.rb
new file mode 100644
index 000000000..dcd60a5e7
--- /dev/null
+++ b/spec/models/work_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Work, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
diff --git a/test/fixtures/contest_notifications.yml b/test/fixtures/contest_notifications.yml
deleted file mode 100644
index 71f88b98c..000000000
--- a/test/fixtures/contest_notifications.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-
-one:
- title: MyString
- content: MyString
-
-two:
- title: MyString
- content: MyString
diff --git a/test/fixtures/contesting_softapplications.yml b/test/fixtures/contesting_softapplications.yml
deleted file mode 100644
index 8cdde9d08..000000000
--- a/test/fixtures/contesting_softapplications.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-
-one:
- softapplication_id: 1
- contest_id: 1
- user_id: 1
- description: MyString
-
-two:
- softapplication_id: 1
- contest_id: 1
- user_id: 1
- description: MyString
diff --git a/test/fixtures/contestnotifications.yml b/test/fixtures/contestnotifications.yml
deleted file mode 100644
index 1bffa73a2..000000000
--- a/test/fixtures/contestnotifications.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-
-one:
- contest_id: 1
- title: MyString
- summary: MyString
- description: MyString
- author_id: 1
- comments_count: 1
-
-two:
- contest_id: 1
- title: MyString
- summary: MyString
- description: MyString
- author_id: 1
- comments_count: 1
diff --git a/test/functional/contestnotifications_controller_test.rb b/test/functional/contestnotifications_controller_test.rb
deleted file mode 100644
index 2873cceeb..000000000
--- a/test/functional/contestnotifications_controller_test.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'test_helper'
-
-class ContestnotificationsControllerTest < ActionController::TestCase
- setup do
- @contestnotification = contestnotifications(:one)
- end
-
- test "should get index" do
- get :index
- assert_response :success
- assert_not_nil assigns(:contestnotifications)
- end
-
- test "should get new" do
- get :new
- assert_response :success
- end
-
- test "should create contestnotification" do
- assert_difference('Contestnotification.count') do
- post :create, contestnotification: { author_id: @contestnotification.author_id, comments_count: @contestnotification.comments_count, contest_id: @contestnotification.contest_id, description: @contestnotification.description, summary: @contestnotification.summary, title: @contestnotification.title }
- end
-
- assert_redirected_to contestnotification_path(assigns(:contestnotification))
- end
-
- test "should show contestnotification" do
- get :show, id: @contestnotification
- assert_response :success
- end
-
- test "should get edit" do
- get :edit, id: @contestnotification
- assert_response :success
- end
-
- test "should update contestnotification" do
- put :update, id: @contestnotification, contestnotification: { author_id: @contestnotification.author_id, comments_count: @contestnotification.comments_count, contest_id: @contestnotification.contest_id, description: @contestnotification.description, summary: @contestnotification.summary, title: @contestnotification.title }
- assert_redirected_to contestnotification_path(assigns(:contestnotification))
- end
-
- test "should destroy contestnotification" do
- assert_difference('Contestnotification.count', -1) do
- delete :destroy, id: @contestnotification
- end
-
- assert_redirected_to contestnotifications_path
- end
-end
diff --git a/test/unit/contest_notification_test.rb b/test/unit/contest_notification_test.rb
deleted file mode 100644
index cf4ebf363..000000000
--- a/test/unit/contest_notification_test.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require 'test_helper'
-
-<<<<<<< HEAD:test/unit/applied_project_test.rb
-class AppliedProjectTest < ActiveSupport::TestCase
-=======
-class ContestNotificationTest < ActiveSupport::TestCase
->>>>>>> a09a3dc378c45f43f5c4b090479fa292a846f4f0:test/unit/contest_notification_test.rb
- # test "the truth" do
- # assert true
- # end
-end
diff --git a/test/unit/contesting_softapplication_test.rb b/test/unit/contesting_softapplication_test.rb
deleted file mode 100644
index a805392f0..000000000
--- a/test/unit/contesting_softapplication_test.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class ContestingSoftapplicationTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
-end
diff --git a/test/unit/contestnotification_test.rb b/test/unit/contestnotification_test.rb
deleted file mode 100644
index efff724e9..000000000
--- a/test/unit/contestnotification_test.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-require 'test_helper'
-
-class ContestnotificationTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
-end
diff --git a/test/unit/helpers/contestnotifications_helper_test.rb b/test/unit/helpers/contestnotifications_helper_test.rb
deleted file mode 100644
index e4dc64783..000000000
--- a/test/unit/helpers/contestnotifications_helper_test.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class ContestnotificationsHelperTest < ActionView::TestCase
-end