竞赛框架搭建

This commit is contained in:
cxt 2016-12-22 10:01:37 +08:00
parent 426ee0a26c
commit 5242e12373
161 changed files with 2018 additions and 4088 deletions

View File

@ -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/

View File

@ -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/

View File

@ -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.

View File

@ -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/

View File

@ -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/

View File

@ -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/

View File

@ -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/

View File

@ -1,4 +0,0 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/

View File

@ -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/

View File

@ -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/

View File

@ -0,0 +1,2 @@
class ContestMembersController < ApplicationController
end

View File

@ -1,6 +0,0 @@
class ContestNotificationController < ApplicationController
layout 'contest_base'
def show
@notification = ContestNotification.find(params[:id])
end
end

View File

@ -0,0 +1,119 @@
#encoding: utf-8
class ContestantWorksController < ApplicationController
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,
:search_course_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
end
def index
end
def show
end
def create
end
def edit
end
def update
end
def destroy
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 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

View File

@ -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

View File

@ -1,736 +1,51 @@
# fq
# class BidsController < ApplicationController
class ContestsController < ApplicationController
layout "contest_base"
menu_item :respond
menu_item :project, :only => :show_project
menu_item :application, :only => :show_softapplication
menu_item :attendingcontests, :only => :show_attendingcontest
menu_item :contestnotifications, :only => :index
before_filter :can_show_contest, :except => [] # modified by alan
# modified by longjun
before_filter :find_contest, :only => [
:show_contest, :show_project, :show_softapplication,
:show_attendingcontest, :index, :set_reward_project,
:set_reward_softapplication, :create, :destroy, :more,
:back, :add, :add_softapplication, :new,:show_results,
:set_reward, :show_contest_project, :show_contest_user, :watcherlist,
:join_in_contest, :unjoin_in_contest, :new_join, :settings
]
# end longjun
# added by fq
before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest]
# end
before_filter :require_login,:only => [:set_reward, :destroy, :add, :new ]
helper :watchers
helper :attachments
helper :projects
helper :words
include AttachmentsHelper
include ApplicationHelper
def index
render_404 unless params[:name]
# @contests = Contest.visible
# @contests ||= []
@offset, @limit = api_offset_and_limit(:limit => 10)
#@contests = Contest.visible
#@contests = @contests.like(params[:name]) if params[:name].present?
@is_search = params[:name] ? true:false
@contests = Contest.visible.where("name like '%#{params[:name]}%'")
if params[:contests_search]
(redirect_to contests_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
end
@contest_count = @contests.count
@contest_pages = Paginator.new @contest_count, @limit, params['page']
@offset ||= @contest_pages.reverse_offset
if params[:contest_sort_type].present?
case params[:contest_sort_type]
when '0'
# modified by longjun
# never use unless and else, 将下面重复操作模块化放在private下
# unless @offset == 0
# if @offset != 0
# @contests = @contests.reorder('contests.commit').offset(@offset).limit(@limit).all.reverse
# else
# limit = @contest_count % @limit
# limit = @limit if limit == 0
# @contests = @contests.reorder('contests.commit').offset(@offset).limit(limit).all.reverse
@contests = index_page_sort(@offset, @limit, @contest_count, @contests, 'contests.commit')
# end
@s_state = 0
when '1'
@contests = index_page_sort(@offset, @limit, @contest_count, @contests, 'contests.created_on')
@s_state = 1
# modified by longjun
# 目前只有 0 1 两个sort_type
# when '2'
else
# end longjun
@contests = index_page_sort(@offset, @limit, @contest_count, @contests, '')
@s_state = 0
end
else
# modified by longjun
# never use unless and else
# unless @offset == 0
if @offset != 0
@contests = @contests.reorder('contests.created_on').offset(@offset).limit(@limit).all.reverse
else
limit = @contest_count % @limit
limit = @limit if limit == 0
@contests = @contests.reorder('contests.created_on').offset(@offset).limit(limit).all.reverse
end
@s_state = 1
end
end
def search
redirect_to action: 'index',name:params[:name]
end
def homework
@offset, @limit = api_offset_and_limit({:limit => 10})
@bids = @course.homeworks.order('deadline DESC')
@bids = @bids.like(params[:name]) if params[:name].present?
@bid_count = @bids.count
@bid_pages = Paginator.new @bid_count, @limit, params['page']
@offset ||= @bid_pages.reverse_offset
# modified by longjun
# never use unless and else
# unless @offset == 0
if @offset != 0
@bids = @bids.offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count % @limit
@bids = @bids.offset(@offset).limit(limit).all.reverse
end
render :layout => 'base_courses'
end
def show_contest
@user = @contest.author
@jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
#@limit = 10
#@feedback_count = @jours.count
#@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
#@offset ||= @feedback_pages.offset
#@jour = @jours[@offset, @limit]
@jour = paginateHelper @jours,10
@state = false
respond_to do |format|
format.html {
render :layout => 'base_newcontest'
}
format.api
end
end
def join_in_contest
if params[:contest_password] == @contest.password
JoinInCompetition.create(:user_id => User.current.id, :competition_id => @contest.id)
@state = 0
else
@state = 1
end
respond_to do |format|
format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
end
end
def unjoin_in_contest
joined = JoinInCompetition.where('competition_id = ? and user_id = ?', @contest.id, User.current.id)
joined.each do |join|
join.delete
end
respond_to do |format|
format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
end
end
def show_participator
render :layout => 'base_newcontest'
end
def settings
if @contest.author.id == User.current.id
@contest = Contest.find(params[:id])
render :layout => 'base_newcontest'
else
render_403 :message => :notice_not_contest_setting_authorized
end
end
# Added by Longjun
def destroy_contest
@contest = Contest.find(params[:id])
if @contest.author_id == User.current.id || User.current.admin?
@contest.destroy
redirect_to welcome_contest_url
else
render_403 :message => :notice_not_contest_delete_authorized
end
end
# end
def show_contest_project
contests = Contest.where('parent_id = ?', @contest.id)
@projects = []
# Modified by longjun
# 用 arr.each 替换 for [ according to the style guide ]
# for contest in contests
# @projects += contest.contesting_projects
# end
contests.each do |contest|
@projects += contest.contesting_projects
end
# end
respond_to do |format|
format.html {
render :layout => 'base_newcontest'
}
format.api
end
end
def show_contest_softapplication
contests = Contest.where('parent_id = ?', @contest.id)
@softapplications = []
# Modified by Longjun
# for contest in contests
# @softapplications += contest.contesting_softapplications
contests.each do |contest|
@softapplications += contest.contesting_softapplications
end
# end
respond_to do |format|
format.html {
render :layout => 'base_newcontest'
}
format.api
end
end
def show_contest_user
contests = Contest.find(:all)
@users = []
# Modified by Longjun
# for contest in contests
# for project in contest.projects
# @users += project.users
# end
contests.each do |contest|
contest.projects.each do |project|
@users += project.users
end
end
# end
respond_to do |format|
format.html {
render :layout => 'base_newcontest'
}
format.api
end
end
#显示参赛的项目
def show_project
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@option = []
# @contesting_project_count = @contesting_project_all.count
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
@membership.each do |membership|
# Modified by Longjun
# 将两个判断语句合并
# unless membership.project.project_type==1
# if User.current.allowed_to?(:quote_project, membership.project)
# @option << membership.project
# end
# end
if membership.project.project_type != 1 && User.current.allowed_to?(:quote_project, membership.project)
@option << membership.project
end
# end
end
@user = @contest.author
@contesting_project = @contest.contesting_projects.all
if params[:student_id].present?
@temp = []
@contesting_project.each do |pro|
if pro.project && pro.project.project_status
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
@temp << pro
end
end
@temp
end
@contesting_project = @temp
else
@temp = []
@contesting_project.each do |pro|
# modified by longjun
# if pro.project && pro.project.project_status
# @temp << pro
# end
@temp << pro if pro.project && pro.project.project_status
# end longjun
@temp
end
if @temp.size > 0
@contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
end
end
@contesting_project = paginateHelper(@contesting_project)
respond_to do |format|
format.html {
render :layout => 'base_newcontest'
}
format.api
end
end
############
##显示参赛的应用
def show_softapplication
# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
# @option = []
# @user = @contest.user
@softapplication = Softapplication.all
@contesting_softapplication = @contest.contesting_softapplications
@contesting_softapplication = paginateHelper(@contesting_softapplication, 10)
# @temp = []
# @softapplicationt.each do |pro|
# if pro.project && pro.project.project_status
# @temp << pro
# end
# @temp
# if @temp.size > 0
# @contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
# end
# end
# respond_to do |format|
# format.html {
# render :layout => 'base_newcontest'
# }
# format.api
# end
##########################
@contest = Contest.find_by_id(params[:id])
respond_to do |format|
format.html {
render :layout => 'base_newcontest'
}
format.api
end
end
###我要参赛
def show_attendingcontest
##取出参赛项目--项目列表
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
@option = []
# @contesting_project_count = @contesting_project_all.count
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
@membership.each do |membership|
unless membership.project.project_type==1
#拥有编辑项目权限的可将该项目参赛
if User.current.allowed_to?(:quote_project, membership.project)
@option << membership.project
end
end
end
@user = @contest.author
@contesting_project = @contest.contesting_projects.all
if params[:student_id].present?
@temp = []
@contesting_project.each do |pro|
if pro.project && pro.project.project_status
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
@temp << pro
end
end
@temp
end
@contesting_project = @temp
else
@temp = []
@contesting_project.each do |pro|
# modified by longjun
# if pro.project && pro.project.project_status
# @temp << pro
# end
@temp << pro if pro.project && pro.project.project_status
# end longjun
@temp
end
if @temp.size > 0
@contesting_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
end
end
# 取出参赛应用 --应用列表
@softapplication = Softapplication.all
@contesting_softapplication = @contest.contesting_softapplications.
joins("LEFT JOIN softapplications ON contesting_softapplications.softapplication_id=softapplications.id").
joins("LEFT JOIN (
SELECT * FROM seems_rateable_cached_ratings
WHERE cacheable_type='Softapplication' AND DIMENSION = 'quality') AS cached
ON cached.cacheable_id=softapplications.id").
order("cached.avg").reverse_order
@contesting_softapplication = paginateHelper @contesting_softapplication, 10
#引用base_newcontest整体样式
@contest = Contest.find_by_id(params[:id])
respond_to do |format|
format.html {
render :layout => 'base_newcontest'
}
format.api
end
end
###end
def show_notification
@contest = Contest.find_by_id(params[:id])
respond_to do |format|
format.html {
render :layout => 'base_newcontest'
}
format.api
end
end
def set_reward_project
@c_p = nil
@contesting_project_id = nil
if params[:set_reward_project][:reward]&&((User.current.id==@contest.author_id)||User.current.admin)
# @bid_id = params[:id]
@contesting_project_id = params[:set_reward_project][:c_id]
@c_p = ContestingProject.find_by_id(@contesting_project_id)
# 把字段存进表中
@c_p.update_reward(params[:set_reward_project][:reward].to_s)
end
respond_to do |format|
format.js
end
end
def set_reward_softapplication
@c_sa = nil
@contesting_softapplication_id = nil
if params[:set_reward_softapplication][:reward]&&((User.current.id==@contest.author_id)||User.current.admin)
# @bid_id = params[:id]
@contesting_softapplication_id = params[:set_reward_softapplication][:c_id]
@c_sa = ContestingSoftapplication.find_by_id(@contesting_softapplication_id)
# 把字段存进表中
@c_sa.update_reward(params[:set_reward_softapplication][:reward].to_s)
end
respond_to do |format|
format.js
end
end
###添加已创建的参赛项目
def add
project = Project.find(params[:contest])
contest_message = params[:contest_for_save][:contest_message]
if ContestingProject.where("project_id = ? and contest_id = ?", project.id, @contest.id).size == 0
# modified by longjun, create 写错了
# if ContestingProject.cerate_contesting(@contest.id, project.id, contest_message)
if ContestingProject.create_contesting(@contest.id, project.id, contest_message)
# end longjun
flash.now[:notice] = l(:label_bidding_contest_succeed)
end
else
flash.now[:error] = l(:label_bidding_fail)
end
@contesting_project = paginateHelper @contest.contesting_projects
respond_to do |format|
format.html { redirect_to :back }
format.js
end
end
###添加已发布的参赛应用
def add_softapplication
softapplication = Softapplication.find(params[:contest])
contest_message = params[:contest_for_save][:contest_message]
if ContestingSoftapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0
if ContestingSoftapplication.create_softapplication_contesting(@contest.id, softapplication.id, contest_message)
flash.now[:notice] = l(:label_release_add_contest_succeed)
end
else
flash.now[:error] = l(:label_add_contest_succeed_fail)
end
@contesting_softapplication = paginateHelper @contest.contesting_softapplications
respond_to do |format|
format.html { redirect_to :back }
format.js
end
end
## 新建留言
def create
if params[:contest_message][:message].size>0
if params[:reference_content]
message = params[:contest_message][:message] + "\n" + params[:reference_content]
else
message = params[:contest_message][:message]
end
refer_user_id = params[:contest_message][:reference_user_id].to_i
@contest.add_jour(User.current, message, refer_user_id)
end
@user = @contest.author
@jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
@limit = 10
@feedback_count = @jours.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@contest.set_commit(@feedback_count)
respond_to do |format|
format.js
end
end
##删除留言
def destroy
@user = @contest.author
if User.current.admin? || User.current.id == @user.id
JournalsForMessage.delete_message(params[:object_id])
end
@jours = @contest.journals_for_messages.reverse
@limit = 10
@feedback_count = @jours.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@jour = @jours[@offset, @limit]
@contest.set_commit(@feedback_count)
respond_to do |format|
format.js
end
end
##引用留言
def new
@jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
if @jour
user = @jour.user
text = @jour.notes
else
user = @contest.author
text = @contest.description
end
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
@content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> "
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
@id = user.id
rescue ActiveRecord::RecordNotFound
render_404
end
##新建竞赛
def new_contest
@contest = Contest.new
@contest.safe_attributes = params[:contest]
end
##提交创建的竞赛
def create_contest
@contest = Contest.new
@contest.name = params[:contest][:name]
@contest.description = params[:contest][:description]
@contest.budget = params[:contest][:budget]
@contest.deadline = params[:contest][:deadline]
@contest.password = params[:contest][:password]
@contest.author_id = User.current.id
@contest.commit = 0
if @contest.save
unless @contest.watched_by?(User.current)
if @contest.add_watcher(User.current)
flash[:notice] = l(:label_contesting_created_succeed)
end
end
redirect_to show_contest_contest_url(@contest)
else
@contest.safe_attributes = params[:contest]
render :action => 'new_contest'
end
end
##更新竞赛配置信息
def update_contest
@contest = Contest.find(params[:id])
@contest.name = params[:contest][:name]
@contest.description = params[:contest][:description]
@contest.budget = params[:contest][:budget]
@contest.deadline = params[:contest][:deadline]
@contest.password = params[:contest][:password]
@contest.author_id = User.current.id
@contest.commit = 0
if @contest.save
unless @contest.watched_by?(User.current)
if @contest.add_watcher(User.current)
flash[:notice] = l(:label_contesting_updated_succeed)
end
end
redirect_to show_contest_contest_url(@contest)
else
@contest.safe_attributes = params[:contest]
render :action => 'new_contest'
end
end
def more
@jour = @contest.journals_for_messages
@jour.each_with_index {|j,i| j.indice = i+1}
@state = true
respond_to do |format|
format.html { redirect_to :back }
format.js
#format.api { render_api_ok }
end
end
def back
@jour = @contest.journals_for_messages
@jour.each_with_index {|j,i| j.indice = i+1}
@state = false
respond_to do |format|
format.html { redirect_to :back }
format.js
#format.api { render_api_ok }
end
end
def set_reward
@b_p = nil
@contesting_project_id = nil
if params[:set_reward][:reward]&&((User.current.id==@contest.author_id)||User.current.admin)
# @contest_id = params[:id]
@contesting_project_id = params[:set_reward][:b_id] #[:b_id]???
@b_p = ContestingProject.find_by_id(@contesting_project_id)
# 把字段存进表中
@b_p.update_reward(params[:set_reward][:reward].to_s)
end
respond_to do |format|
format.js
end
end
def watcherlist
render :layout => 'base_newcontest'
end
private
def find_contest
if params[:id]
@contest = Contest.find(params[:id])
@user = @contest.author
end
rescue
render_404
end
#验证是否显示竞赛
def can_show_contest
@first_page = FirstPage.find_by_page_type('project')
if @first_page.show_contest == 2
render_404
end
end
# added by longjun
# 将index页面中分页排序的方法抽离出来
def index_page_sort(offset, limit, contest_count, contests, contest_sort_by)
# modified by longjun
# never use unless and else
# unless @offset == 0
if offset != 0
contests = contests.reorder(contest_sort_by).offset(offset).limit(limit).all.reverse
else
limit = contest_count % limit
limit = limit if limit == 0
contests = contests.reorder(contest_sort_by).offset(offset).limit(limit).all.reverse
end
contests
end
end
class ContestsController < ApplicationController
before_filter :find_contest, :only => [:show]
before_filter :is_logged, :only => [:index, :new, :create]
def show
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?
r = Role.givable.where(:name => 'ContestManager').first
m = ContestMember.new(:user => current_user, :roles => [r])
@contest.contest_members << m
end
respond_to do |format|
format.html {redirect_to contest_url(@contest)}
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

View File

@ -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

View File

@ -40,9 +40,9 @@ class UsersController < ApplicationController
: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,
: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
@ -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?
@ -2224,6 +2231,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 = 'HomeworkCommon'
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
@ -3987,6 +4049,9 @@ 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)
@ -3995,6 +4060,8 @@ class UsersController < ApplicationController
@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

View File

@ -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?

View File

@ -0,0 +1,6 @@
class WorksController < ApplicationController
def index
end
end

View File

@ -2826,9 +2826,16 @@ module ApplicationHelper
end
technical_title
end
# 用户竞赛总数
def user_contest_count
count = @user.contests.where(:is_delete => false).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
@ -3024,6 +3031,40 @@ module ApplicationHelper
end
end
#根据传入作业确定显示为编辑作品还是新建作品,或者显示作品数量
def user_for_contest_work homework,is_teacher,work
count = homework.contestant_works.count
if User.current.member_of_contest?(homework.contest)
if is_teacher #老师显示作品数量
link_to "作品(#{count})", contestant_work_index_url_in_org(homework.id, 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_works_index_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_works_index_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_works_path(work.id),:class => 'c_blue'
else
link_to "查看作品(#{count})", contestant_work_index_url_in_org(homework.id, 2), :class => 'c_blue', :title => "作业截止后不可修改作品"
end
end
end
else
link_to "作品(#{count})",contestant_work_index_url_in_org(homework.id, 2),:class => "c_blue"
end
end
#根据传入作业确定显示为提交作品、补交作品、查看作品等
def student_for_homework_common homework
if User.current.allowed_to?(:as_teacher, homework.course)
@ -3108,6 +3149,24 @@ module ApplicationHelper
homework.student_work_projects.where("user_id = ?",User.current).first
end
#获取当前用户在指定题目下提交的作业的集合
def cur_user_works_for_work work
work = work.contestant_works.where("user_id = ? && work_status != 0",User.current).first
if work.work_type == 3
pro = work.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 = ""
@ -3294,6 +3353,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
@ -3392,6 +3459,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
@ -3750,6 +3828,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")

View File

@ -0,0 +1,2 @@
module ContestMembersHelper
end

View File

@ -0,0 +1,2 @@
module ContestantWorksHelper
end

View File

@ -1,2 +0,0 @@
module ContestnotificationsHelper
end

View File

@ -1,206 +1,2 @@
#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
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)
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')
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)))
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'}))
end
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
#end
# def course_options_for_select(courses)
# # <option value = '0'>#{l(:label_choose_reward)}</option>
# html = ''
# courses.each do |course|
# html << "<option value = #{course.id}>"
# html << course.name
# html << "</option>"
# end
# html.html_safe
# end
# used to get the reward and handle the value which can be used to display in views
# added by william
def get_prize(c_project)
c_project.get_reward
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
end
@projects.count
end
def count_contest_softapplication
contests = Contest.find(:id)
@softapplications = []
# Modified by alan
# for contest in contests
contests.each do |contest|
# end alan
@softapplications += contest.contesting_softapplications
end
@projects.count
end
def count_contest_user
contests = Contest.find(:id)
@users = []
# Modified by alan
# for contest in contests
contests.each do |contest|
contest.projects.each do |project|
@users += project.users
end
end
# end alan
@users.count
end
def count_contest_softapplication_user
contests = Contest.find(:id)
@users = []
# Modified by alan
# for contest in contests
contests.each do |contest|
contest.projects.each do |softapplications|
# for project in contest.softapplications
@users += softapplication.users
end
end
@users.count
end
def im_watching_student_id? contest
people = []
people << contest.author
# case bid.reward_type # 天煞的bid分了三用途里面各种hasmany还不定能用
# when 1
# when 2
# bid.join_in_contests.each do |jic|
# people << jic.user
# end
# when 3
# people += bid.courses.first.users.to_a
# else
# raise 'bids_helper: unknow bid type' # 出了错看这里!不知道的抛异常,省的找不到出错的地方!
# end
contest.join_in_contests.each do |jic|
people << jic.user
end
people.include?(User.current)
end
# def select_option_helper option
# tmp = Hash.new
# tmp={"" => ""}
# option.each do |project|
# tmp[project.name] = project.identifier
# end
# tmp
# end
def select_option_app_helper options
tmp = Hash.new
options.each do |option|
tmp[option.name] = option.id
end
tmp
end
#作品分类下拉框
def work_type_opttion
type = []
#work_types = WorksCategory.all
WorksCategory.all.each do |work_type|
option = []
option << work_type.category
option << work_type.category
type << option
end
type
end
end
end

View File

@ -0,0 +1,2 @@
module WorksHelper
end

View File

@ -1,136 +1,87 @@
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
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 :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
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]*$/
before_destroy :delete_all_members
after_create :act_as_course_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
end

View File

@ -0,0 +1,37 @@
class ContestActivity < ActiveRecord::Base
attr_accessible :contest_act_id, :contest_act_type
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

View File

@ -0,0 +1,19 @@
class ContestMember < ActiveRecord::Base
belongs_to :user
belongs_to :contest
attr_accessible :is_collect, :is_current
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
protected
def validate_role
errors.add_on_empty :role if contest_member_roles.empty? && roles.empty?
end
end

View File

@ -0,0 +1,22 @@
class ContestMemberRole < ActiveRecord::Base
belongs_to :contest_member
belongs_to :role
# attr_accessible :title, :body
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

View File

@ -0,0 +1,20 @@
class ContestMessage < ActiveRecord::Base
attr_accessible :content, :contest_message_id, :course_message_type, :status, :viewed
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

View File

@ -1,6 +0,0 @@
class ContestNotification < ActiveRecord::Base
attr_accessible :content, :title
validates :title, length: {maximum: 30}
end

View File

@ -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 => :course_id
end

View File

@ -0,0 +1,20 @@
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
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
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

View File

@ -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
end

View File

@ -0,0 +1,5 @@
class ContestantWorkScore < ActiveRecord::Base
belongs_to :contestant_work
belongs_to :user
attr_accessible :comment, :reviewer_role, :score
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -34,10 +34,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

View File

@ -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], :conditions => "#{Contest.table_name}.is_delete != 0", :order => "#{Contest.table_name}.name"
has_many :contests, :through => :contestmemberships
# Groups and active users
scope :active, lambda { where(:status => STATUS_ACTIVE) }
@ -157,6 +161,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)

View File

@ -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

View File

@ -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,10 @@ class User < Principal
courses.to_a.include?(course)
end
def member_of_contest?(contest)
contests.to_a.include?(contest)
end
def member_of_org?(org)
if !self.logged?
return false
@ -912,6 +913,49 @@ class User < Principal
false
end
end
# 判断是否是竞赛的主办人
def admin_of_contest?(contest)
if self.admin?
return true
end
if ContestMember.where("user_id =? and contest_id =?", self.id, contest.id).count == 0
return false
end
role = ContestMember.where("user_id =? and contest_id =?", self.id, contest.id)[0].roles[0]
unless role.nil?
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
role = ContestMember.where("user_id =? and contest_id =?", self.id, contest.id)[0].roles[0]
unless role.nil?
role.name == 'Judge' ? 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
role = ContestMember.where("user_id =? and contest_id =?", self.id, contest.id)[0].roles[0]
unless role.nil?
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 +998,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)

66
app/models/work.rb Normal file
View File

@ -0,0 +1,66 @@
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
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 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

View File

@ -0,0 +1,4 @@
class WorkDetailGroup < ActiveRecord::Base
belongs_to :work
attr_accessible :base_on_project, :max_num, :min_num
end

View File

@ -0,0 +1,63 @@
<div id="muban_popup_box" style="width:400px;">
<div class="muban_popup_top">
<h3 class="fl">关联项目</h3>
<a href="javascript:void(0);" class="muban_icons_close fr"></a>
<div class="cl"></div>
</div>
<div class="muban_popup_con clear ml30 mr30 mt10">
<%= form_for('new_form',:url =>{:controller => 'contestant_work',:action => 'student_work_project',:work => @contestantwork.id,:user_activity_id=>@user_activity_id,:hw_status =>@hw_status},:method => "post", :remote => true) do |f|%>
<input type="text" name="project" placeholder="输入项目名称进行搜索" class="searchResourcePopup mb10" />
<div class="cl"></div>
<p id="no_search_result" class="c_red f14" style="width:320px;display: none">您当前尚未创建任何项目,请先创建项目再关联。</p>
<ul id="search_project_list" class="maxHeight200"></ul>
<p id="notes" class="c_red"></p>
<a href="javascript:void(0);" class="sy_btn_blue fr" onclick="clickOK();">确定</a>
<a href="javascript:void(0);" class="sy_btn_grey fr mr5" onclick="clickCanel();">取消</a>
<div class="cl"></div>
<% end %>
</div>
</div>
<script type="text/javascript">
var lastSearchCondition = '';
var count = 0;
function search_pros(e){
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
{
return;
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
url: '<%= url_for(:controller => 'student_work', :action => 'search_user_projects') %>'+'?name='+ e.target.value,
type:'get'
});
}
function throttle(method,context,e){
clearTimeout(method.tId);
method.tId=setTimeout(function(){
method.call(context,e);
},500);
}
//查询项目
$("input[name='project']").on('input', function (e) {
throttle(search_pros,window,e);
});
$(document).ready(function(){
$.ajax({
url: '<%= url_for(:controller => 'student_work', :action => 'search_user_projects') %>'+'?first=1',
type:'get'
});
});
function clickOK() {
var radio = $("input[name='projectName']:checked");
if(radio.length < 1) {
$("#notes").html("请先选择一个项目");
return false;
} else {
$("#muban_popup_box").find('form').submit();
}
}
</script>

View File

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

View File

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

View File

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

View File

@ -1,77 +0,0 @@
<%= error_messages_for @contestnotifications %>
<script type="text/javascript">
function regexTitle()
{
var title = $.trim($("#contestnotification_title").val());
if(title.length ==0)
{
$("#title_span").text("<%= l(:label_no_contest_news_title) %>");
$("#title_span").css('color','#ff0000');
$("#title_span").focus();
return false;
}
else if(title.length <= 254)
{
$("#title_span").text("<%= l(:label_field_correct) %>");
$("#title_span").css('color','#008000');
return true;
}
else
{
$("#title_span").text("<%= l(:label_contest_news_title_condition) %>");
$("#title_span").css('color','#ff0000');
$("#title_span").focus();
return false;
}
}
//验证描述不能为空不能多余5000个字符
function regexDescription()
{
var description = $.trim($("#contestnotification_description").val());
if(description.length ==0)
{
$("#description_span").text("<%= l(:label_no_contest_news_description) %>");
$("#description_span").css('color','#ff0000');
$("#description_span").focus();
return false;
}
else if(description.length <= 5000)
{
$("#description_span").text("<%= l(:label_field_correct) %>");
$("#description_span").css('color','#008000');
return true;
}
else
{
$("#description_span").text("<%= l(:label_contest_news_condition) %>");
$("#description_span").css('color','#ff0000');
$("#description_span").focus();
return false;
}
}
</script>
<div class="box tabular">
<p>
<%= f.text_field :title,
:required => true,
:size => 60,
:maxlength => 60,
:style => "width:488px;",
:onkeyup => "regexTitle();"
%>
</p>
<span id="title_span" style="padding-left: 100px;"></span>
<p>
<%= f.text_area :description,
:required => true,
:cols => 60,
:rows => 11,
:class => 'wiki-edit',
:style => "width:490px;",
:onkeyup => "regexDescription();"
%>
</p>
<span id="description_span" style="padding-left: 100px;"></span>
</div>
<%= wikitoolbar_for 'news_description' %>

View File

@ -1,51 +0,0 @@
<!--<p><%#= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%#= link_to h(news.title), news_path(news) %>
<%#= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<%# unless news.summary.blank? %></td><td><span class="fontligher"><%#=h news.summary %></span></td>
<td><span class="author"><%#= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<table width="660px" border="0" align="center">
<tr>
<td colspan="2" valign="top" width="50" >
<img src="/images/new/news.png" width="40" height="40"/>
</td>
<td><table width="580px" border="0">
<tr>
<td colspan="2" valign="top">
<strong>
<%=link_to contestnotifications.author,
contest_contestnotification_path(contestnotifications)
%>
</strong>
<a class="font_lighter">
<%= l(:label_project_newshare) %>
</a>
<%= link_to h(contestnotifications.title),
contest_contestnotification_path(contestnotifications)
%>
</td>
</tr>
<tr>
<td colspan="2" width="580px" >
<p class="font_description">
<%=h contestnotifications.description%>
</p>
</td>
</tr>
<tr>
<td align="left">
<a class="font_lighter">
<%= contestnotifications.created_at %>
</a>
</td>
<td width="200" align="right" class="a">
<%= link_to l(:label_project_newother),
contest_contestnotification_path(contestnotifications)
%>
<%= "(#{l(:label_x_comments, :count => contestnotifications.notificationcomments_count)})" if contestnotifications.notificationcomments_count > 0 %>
</td>
</tr>
</table></td>
</tr>
</table>

View File

@ -1,18 +0,0 @@
<h3><%=l(:label_edit_contest_notice)%></h3>
<%= labelled_form_for @contestnotification,
:url => contest_contestnotification_path,
:html => { :id => 'contestnotifications-form',
:multipart => true,
:method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%#= preview_link preview_contestnotifications_path(id: @contestnotification),
'contestnotifications-form'
%>
<% end %>
<div id="preview" class="wiki"></div>
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'scm' %>
<% end %>

View File

@ -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

View File

@ -1,151 +0,0 @@
<script type="text/javascript">
function submitContestNews()
{
if(regexTitle() && regexDescription())
{
$("#contestnotifications-form").submit();
}
}
</script>
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
<%= l(:label_notification) %>
</span>
<% if User.current.logged? && (User.current.admin? ||User.current == @contest.author) %>
<%= link_to(l(:bale_news_notice),
new_contest_contestnotification_path(@contest),
:class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-contestnotifications", "contestnotifications_title"); return false;') %>
<% end %>
<% if @contest %>
<div id="add-contestnotifications" class="add_frame" style="display:none;">
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest),
:html => {:id => 'contestnotifications-form', :multipart => true} do |f| %>
<%= render :partial => 'contestnotifications/form', :locals => {:f => f} %>
<input type="button" onclick="submitContestNews();" class="enterprise" value="<%= l(:button_create)%>"/>
|
<input type="button" onclick="$('#add-contestnotifications').hide(); return false;" class="enterprise" value="<%= l(:button_cancel)%>"/>
<% end if @contest %>
<div id="preview" class="wiki"></div>
</div>
<br/>
<% end %>
<div>
<div style="margin-left: 20px;">
<span class="portrait">
<%= image_tag(url_to_avatar(@contest.author), :class => "avatar")%>
</span>
<span class="body">
<span id="praise_tread" style="float: right">
<%= render :partial => "/praise_tread/praise_tread",
:locals => {:obj => @contest,
:show_flag => true,
:user_id =>User.current.id,
:horizontal => false}
%>
</span>
<h3>
<%= link_to(@contest.author.lastname+@contest.author.firstname,
user_path(@contest.author))%>
<%= @contest.name %>
</h3>
<p>
<strong>
<%= l(:label_bids_reward_method) %>
<span class="bonus">
<%= @contest.budget%>
</span>
</strong>
</p>
<div class="bid_description" style="width: 100%;word-break:break-all;word-wrap: break-word;">
<%= @contest.description %>
</div>
</span>
</div>
<div style="clear: both;"></div>
<br><br>
<% @contestnotificationss.each do |contestnotifications| %>
<table class="content-text-list">
<tr>
<td colspan="2" valign="top" width="50">
<%= link_to image_tag(url_to_avatar(contestnotifications.author), :class => "avatar"), user_path(contestnotifications.author) %>
</td>
<td>
<table width="580px" border="0">
<tr>
<td colspan="2" valign="top">
<strong>
<%= link_to_user(contestnotifications.author) if contestnotifications.respond_to?(:author) %>
</strong>
<span style="margin-left: 4px;" class="font_lighter">
<%= l(:label_project_notice) %>
</span>
<span>
<%= link_to h(contestnotifications.title), contest_contestnotification_path(@contest, contestnotifications) %>
</span>
<span style="float: right">
<%= link_to l(:button_edit), edit_contest_contestnotification_path(@contest, contestnotifications) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
<%= delete_link contest_contestnotification_path(@contest, contestnotifications) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
</span>
</td>
</tr>
<tr>
<td colspan="2" width="580px">
<span class="font_description">
<%= textilizable(contestnotifications, :description) %>
</span>
</td>
</tr>
<tr>
<td align="left"><span class="font_lighter">
<%= l :label_update_time %>
&nbsp;
<%= format_time(contestnotifications.created_at) %>
</span>
</td>
<td width="350" align="right" class="a">
<%= link_to l(:label_check_comment), contest_contestnotification_path(@contest, contestnotifications) %>
</td>
</tr>
</table>
</td>
</tr>
</table>
<% end %>
</div>
<!--end-->
<div style="padding-right: 10px">
<div class="pagination">
<ul>
<%= pagination_links_full @contestnotifications_pages %>
</ul>
</div>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
<%= stylesheet_link_tag 'scm' %>
<% end %>
<% html_title(l(:label_contest_notification)) -%>
</div>
<script type='text/javascript'>
$(document).ready(function ($) {
$('.content-text-list').each(function () {
$(this).find('.delete_icon').hide();
$(this).mouseenter(function (event) {
$(this).find('.delete_icon').show();
});
$(this).mouseleave(function (event) {
$(this).find('.delete_icon').hide();
});
});
});
</script>
<!--end-->

View File

@ -1,17 +0,0 @@
<script type="text/javascript">
function submitContestNews()
{
if(regexTitle() && regexDescription())
{
$("#contestnotifications-form").submit();
}
}
</script>
<%= labelled_form_for @contestnotification,
:url => contest_contestnotifications_path(@contest),
:html => { :id => 'contestnotifications-form', :multipart => true } do |f| %>
<%= render :partial => 'contestnotifications/form', :locals => { :f => f } %>
<input type="button" onclick="submitContestNews();" class="enterprise" value="<%= l(:button_create)%>"/>
<%= link_to l(:button_cancel), contest_contestnotifications_path(@contest.id) %>
<% end %>
<div id="preview" class="wiki"></div>

View File

@ -1,144 +0,0 @@
<script>
function cancel() {
$("#add_contestnotification").hide();
}
</script>
<div class="contextual">
<%= link_to(l(:button_edit),
edit_contest_contestnotification_path(@contest, @contestnotification),
:class => 'icon icon-edit',
:accesskey => accesskey(:edit),
:onclick => '$("#edit-contestnotifications").show(); return true;') if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?)%>
<%= delete_link contest_contestnotification_path(@contest, @contestnotification) if (User.current.admin? && User.current.logged? )||(User.current == @contest.author && User.current.logged?) %>
</div>
<h3><strong><%=h @contestnotification.title %></strong></h3>
<div id="edit-contestnotifications" style="display:none;">
<%= labelled_form_for @contestnotification,
:url => contest_contestnotification_path(@contest),
:html => { :id => 'contestnotifications-form',
:multipart => true,
:method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= link_to l(:button_cancel),
"#",
:onclick => '$("#edit-contestnotifications").hide(); return false;' %>
<% end %>
<div id="preview" class="wiki"></div>
</div>
<div id="notificationcomments" style="margin-bottom:16px;">
<div style="margin:15px" id ="add_contestnotification">
<span class="font_description">
<%= textilizable(@contestnotification, :description) %>
</span>
<br/>
<%#= link_to_attachments @contestnotification %>
<br/>
<!--add comment-->
<% if User.current.logged? %>
<p>
<%= toggle_link l(:label_comment_add),
"add_notificationcomment_form",
:focus => "notificationcomment_notificationcomments"
%>
</p>
<% else %>
<%= l(:label_user_login_notificationcomment) %>
<%= link_to l(:label_user_login_new), signin_path %>
<% end %>
<%= form_tag( contest_contestnotification_notificationcomments_path(@contest, @contestnotification) ,
:id => "add_notificationcomment_form",
:style => "display:none;") do %>
<div class="box">
<%= text_area 'notificationcomment',
'notificationcomments',
:cols => 80,
:rows => 15,
:class => 'wiki-edit'
%>
<%= wikitoolbar_for 'notificationcomment_notificationcomments' %>
</div>
<p>
<%= submit_tag l(:button_add) %>
<!--modified by longjun 点击取消时收回添加回复的部分-->
<%= submit_tag l(:button_cancel),
:name => nil,
:onclick => "cancel();",
:type => 'button',
:class => "enterprise",
:onmouseout => "this.style.backgroundPosition = 'left top'",
:onmouseover => "this.style.backgroundPosition = 'left -30px'"
%>
</p>
<% end %>
<% html_title @contestnotification.title -%>
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'scm' %>
<% end %>
<!--dispaly comments-->
<div class="line_heng"></div>
</div>
<h3 class="notificationcomments"><%= l(:label_comment_plural) %></h3>
<% notificationcomments = @notificationcomments.reverse %>
<% notificationcomments.each do |notificationcomment| %>
<% next if notificationcomment.new_record? %>
<table width="660px" border="0" align="center">
<tr>
<td colspan="2" valign="top" width="50" >
<%= image_tag(url_to_avatar(notificationcomment.author), :class => "avatar")%>
</td>
<td>
<table width="580px" border="0">
<tr>
<td colspan="2" valign="top">
<strong>
<%= link_to_user(notificationcomment.author) if notificationcomment.respond_to?(:author) %>
</strong>
<span class="font_lighter">
<%= l(:label_project_newadd) %>
</span>
<%= l(:label_comment_plural) %>
</td>
<!--modified by longjun 删除变成竖的IE浏览器兼容将宽度设置为40px-->
<td width="40px">
<% if notificationcomment.author==User.current|| User.current.admin? %>
<%= link_to(l(:label_bid_respond_delete),
contest_contestnotification_notificationcomment_path(@contest, @contestnotification,notificationcomment),
:method => :delete,:confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
<% end %>
</td>
</tr>
<tr>
<td colspan="2" width="580px" >
<p class="font_description">
<%= textilizable(notificationcomment.notificationcomments) %>
</p></td>
</tr>
<tr>
<td align="left">
<span class="font_lighter">
<%= format_time(notificationcomment.created_at) %>
</span>
</td>
<td width="200" align="right" class="a"><%#= link_to_if_authorized_contest image_tag('delete.png'), {:controller => 'notificationcomments', :action => 'destroy', :id => @contestnotifications, :notificationcomment_id => notificationcomment},
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
</tr>
</table></td>
</tr>
</table>
<% end if @notificationcomments.any? %>
</div>
<!--end-->

View File

@ -1,14 +0,0 @@
<div class="dis">
<div class="msg_box" id='leave-message'>
<h4>留言内容</h4>
<%= render :partial => 'new', :locals => {:contest => @contest, :sta => @state} %>
<!-- <textarea id="ta_msg_content" name="content" placeholder="最多250个字"></textarea> -->
<!-- <a href="#">取&nbsp;&nbsp;消</a><a href="#">留&nbsp;&nbsp;言</a> -->
</div>
<div id="history">
<%= render :partial => 'history',:locals => { :contest => @contest, :journals => @jour, :state => false} %>
</div>
<ul class="wlist"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%></ul>
</div>

View File

@ -1,118 +0,0 @@
<!-- fq -->
<% contests.each do |contest|%>
<table width="95%" border="0" style="padding-left: 10px; padding-top: 10px;">
<tr>
<td colspan="2" valign="top" width="50" >
<% unless contest.author.nil? %>
<%= link_to(image_tag(url_to_avatar(contest.author), :class => 'avatar'),
user_path(contest.author),
:class => "avatar")
%>
<% end %>
</td>
<td>
<table width="100%" border="0">
<tr>
<td colspan="2" valign="top"><strong>
<% unless contest.author.nil? %>
<%= link_to(contest.author,
user_path(contest.author),
:class => 'bid_user')
%>:
<% end %>
&nbsp;<%= link_to(contest.name,
contest_contestnotifications_path(contest),
:class => 'bid_path',
:target => "_blank") %></strong></td>
</tr>
<tr>
<td width="500">
<table border="0">
<tr>
<td>
<strong><%= l(:label_contests_reward_method) %>:&nbsp;&nbsp;
<span style="word-break: break-all; color: #15bccf; font-family: 14px; font-family: '微软雅黑'">
<%= contest.budget%>
</span>
</strong>
</td>
</tr>
<tr>
<td class="font_lighter">
<!-- <span class="font_lighter">
<%#= l(:label_contest_project,
:count => contest.contesting_projects.count)
%>
(<strong><span style="font-size: 17px">
<%#= link_to(contest.contesting_projects.count,
show_project_contest_path(contest),
:target => "_blank")
%></span></strong>)</span>
<span class="font_lighter">
<%#= l(:label_contest_softapplication,
:count => contest.contesting_softapplications.count)
%>
(<strong><span style="font-size: 17px">
<%#= link_to(contest.contesting_softapplications.count,
show_softapplication_contest_path(contest),
:target => "_blank")
%>
</span></strong>)</span> -->
<!-- modified by longjun
将 or 改成 || -->
<% if contest.id == 2 || contest.id == 3 || contest.id == 6 %>
<%= l(:label_contest_work,
:count => contest.contesting_projects.count)
%>
(<strong>
<span style="font-size: 17px">
<%= link_to(contest.projects.where('is_public=1').count,
show_attendingcontest_contest_path(contest),
:target => "_blank")
%>
</span>
</strong>)
<% else %>
<%= l(:label_contest_work,
:count => contest.contesting_softapplications.count)
%>
(<strong>
<span style="font-size: 17px">
<%= link_to(contest.contesting_softapplications.count,
show_attendingcontest_contest_path(contest),
:target => "_blank") %>
</span>
</strong>)
<% end %>
</td>
</tr>
</table></td>
<td width="200" align="right" class="a">
<span class="font_lighter">
<%= l :label_create_time %>: <%= format_time contest.created_on %>
</span>
</td>
</tr>
<tr>
<td>
<div class="bid-description" style="border-left: 1px solid #d9d8d8; border-bottom: 1px solid #d9d8d8; padding-left: 20px; padding-bottom: 10px; margin-bottom: 20px;">
<table width="100%">
<tr>
<!-- <td> <%#= contest.description%> </td> -->
</tr>
</table>
</div>
</td>
</tr>
</table></td>
</tr>
</table>
<% end %>
<div class="pagination">
<ul>
</ul>
</div>

View File

@ -1,76 +0,0 @@
<!-- huang -->
<script type="text/javascript" language="javascript">
function show(id, id_t, label_reward, label_money, label_credit, label_content) {
var text = $('#' + id);
var text_t = $('#' + id_t);
if (text.val() == 0) {
text_t.attr("placeholder", label_reward);
}
if (text.val() == 1) {
text_t.attr("placeholder", label_money);
}
if (text.val() == 3) {
text_t.attr("placeholder", label_credit);
}
if (text.val() == 2) {
text_t.attr("placeholder", label_content);
}
return content;
}
</script>
<%= error_messages_for 'contest' %>
<!--[form:project]-->
<p style="width:500px;">
<%= l(:label_bids_form_contest_new_description) %>
</p>
<p>
<%= f.text_field :name,
:required => true,
:size => 60,
:style => "width:490px;",
:maxlength => Contest::NAME_LENGTH_LIMIT,
:placeholder => "#{l(:label_contest_name)}"
%>
</p>
<p>
<%= f.text_area :description,
:size => 60,
:rows => 4,
:style => "width:490px;",
:maxlength => Contest::DESCRIPTION_LENGTH_LIMIT,
:placeholder => "#{l(:label_contest_description)}"
%>
</p>
<p>
<%= f.text_field :password,
:size => 60,
:rows => 4,
:style => "width:490px;"
%>
</p>
<p>
<%= f.text_area :budget,
:required => true,
:size => 60,
:rows => 4,
:maxlength => Contest::DESCRIPTION_LENGTH_LIMIT,
:style => "width:490px;",
:placeholder => l(:label_bids_reward_what)
%>
<!-- 设置奖项设置的打开 关闭开关-->
</p>
<!-- <em class="info" style="margin-left:95px;"><%#= l(:text_contest_reward) %></em> -->
<p>
<%= f.text_field :deadline,
:required => true,
:size => 60,
:style => "width:150px;float:left;",
:readonly => true,
:placeholder => "#{l(:label_deadline)}"
%>
<%= calendar_for('contest_deadline')%>
</p>

View File

@ -1,63 +0,0 @@
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
<div class="ping_ctt">
<div id="tbc_01" class="ping_dis">
<% if journals.size > 0 %>
<% for journal in journals %>
<div class="ping_C" id='word_li_<%= journal.id.to_s %>'>
<div class="ping_dispic"><a target="_blank" href="#"><%= image_tag(url_to_avatar(journal.user)) %></a></div>
<div class="ping_discon" style="width: 85%;">
<div class="ping_distop">
<!-- <a style=" font-weight:bold; color:#15bccf; margin-right:30px; background:none;" target="_blank" href="#">gugu01</a> -->
<span><%= link_to journal.user, user_path(journal.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%></span><span style="color:#a6a6a6; margin-right:40px; margin-left:30px;"><%= format_time(journal.created_on) %></span>
<div class="cl"></div>
<p><%= textilizable journal.notes%></p>
</div>
<div class="ping_disfoot">
<% ids = 'project_respond_form_'+ journal.id.to_s%>
<span style="float: right">
<% if journal.user == User.current|| User.current.admin? %>
<%= link_to(l(:label_bid_respond_delete),
{:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => @user},
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete',
:class => "delete", :title => l(:button_delete)) %>
<% end %>
<% if reply_allow %>
<%= link_to l(:label_bid_respond_quote),'',
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea')); $('##{ids} textarea') ;return false;"} %>
<%= link_to(l(:button_quote), contests_path(:id => contest,
:journal_id => journal),
:remote => true,
:method => 'post',
:title => l(:button_quote))%>
<% end %>
</span>
<span class="font_lighter" style="float: right">
<%= l(:label_bids_published) %>&nbsp;
<%= time_tag(journal.created_on).html_safe %>&nbsp;
<%= l(:label_bids_published_ago) %>
</span>
</div>
<div style="clear: both;"></div>
<% ids = 'project_respond_form_'+ journal.id.to_s%>
<% if reply_allow %>
<div id='<%= ids %>' class="respond-form">
<%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal,:show_name => true} %>
</div>
<% end %>
<div style="clear: both;"></div>
<div>
<%= render :partial => "words/journal_reply", :locals => {:journal => journal, :show_name => true} %>
</div>
</div>
<div class="cl"></div>
</div>
<% end %>
<% end %>
</div>
</div>

View File

@ -1,109 +0,0 @@
<% contesting_project.each do |c_project|%>
<% if c_project.project %>
<table width="90%" border="0" align='center'>
<tr>
<td>
<table width="660px" border="0" align='center'>
<tr>
<td width="50px" valign="top" colspan="2" align="middle">
<div style="width: 50px; height: 50px;">
<%= image_tag(url_to_avatar(c_project.project), :class => 'avatar3') %>
</div></td>
<td width="65%" valign="top">
<table width="100%" valign="top">
<tr>
<td colspan="2" valign="top" width="50%">
<strong>
<%= link_to(c_project.project.name, project_path(c_project.project)) %>
</strong>
<span class="font_lighter"><%= l(:label_joined_contest)%></span>
</td>
<!-- 如果需求到期 并且是该需求的管理员 -->
<td style="color: #ec6300;" align="right" valign="0.1em" width="16%">
<strong>
<span id="reward_result_<%=c_project.id%>"> <!-- 调用js进行刷新 -->
<%= 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 %>
</span>
</strong>
</td>
<!-- 评价显隐控制按钮-->
</tr>
<tr>
<td valign="top" width="50%" style=" word-wrap: break-word; word-break: break-all"><%= c_project.project.description %></td>
</tr>
<tr>
<td valign="top"><span class="font_lighter">
<%= format_time c_project.created_at%>
</span></td>
</tr>
</table>
</td>
<td width="30%">
<div class="bid-user-message" style="border-left: 1px solid rgb(225, 225, 225); margin-left: 20px; padding-left: 20px;">
<table width="100%">
<tr>
<td>
<strong>
<%= l(:label_contest_user) %>
<% unless c_project.user.nil? %>
<!-- modified by zjc 添加超链接 -->
<%= link_to c_project.user.lastname + c_project.user.firstname,
user_path(c_project.user)
%>
<% end %>
</strong>
</td>
</tr>
<tr>
<td style=" word-wrap: break-word; word-break: break-all">
<%= l(:label_contest_reason) %>
<%= c_project.description %>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<% end %>
<% end %>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>

View File

@ -1,40 +0,0 @@
<% contesting_softapplication.each do |c_softapplication|%>
<% if c_softapplication.softapplication %>
<div style="padding-left: 18px">
<div style="font-size: 15px">
<tr>
<td><strong><%=l(:label_softapplication)%>:</strong></td>
<td>
<%= link_to(c_softapplication.softapplication.name,
softapplication_path(c_softapplication.softapplication),
:target => '_blank')
%>
</td>
</tr></br>
</div>
<div style="padding-left: 68px">
<tr>
<td><%=l(:label_profile)%>:</td>
<td>
<%= c_softapplication.softapplication.description.truncate(90, omission: '...') %>
</td>
</tr></br>
</div>
<div style="padding-left: 68px; padding-bottom: 8px">
<tr>
<td><%=l(:label_activity_time)%></td>
<td>
<%=format_time c_softapplication.created_at %>
</td>
</tr>
</div>
</div>
<% end %>
<div class="underline-contests_three"></div>
<% end %>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>

View File

@ -1,36 +0,0 @@
<!-- fq -->
<div style="width: 80%; margin-left:10%;">
<%= form_for('contest_message',
:remote => true, :method => :post,
:url => {:controller => 'contests',
:action => 'create',
:id => contest,
:sta => sta}
) do |f|%>
<div id = 'pre_show'> <!--what function?-->
<%= render :partial => 'pre_show', :locals => {:content => @content} %>
</div>
<% 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 %>
<div style="font-size: 14px;margin:10px;padding-left: 13px">
<%= l(:label_user_login_tips) %>
<%= link_to l(:label_user_login_new), signin_path %>
</div>
<% end %>
<% end %>
<div class="cl"></div>
</div>

View File

@ -1,66 +0,0 @@
<!-- added by fq -->
<style>
input[type="submit"].contest_btn {
vertical-align: middle;
width: 60px;/*modified by ming*/
height: 25px;
line-height: 19px;
font-size: 14px;
color: rgb(0, 0, 0);
background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
/*margin-top: -10px;*/
/*margin-right: -4px;*/
}
input[type="button"].contest_btn {
width: 60px;/*modified by ming*/
height: 25px;
line-height: 19px;
font-size: 14px;
color: rgb(0, 0, 0);
background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
/*margin-top: -10px;*/
margin-right: -2px;
}
textarea:focus {
border: #d5dee9 1px solid;
}
</style>
<h3 class="title"><%=l(:label_please_input_password)%></h3>
<%= form_tag( join_in_contest_contests_path(id: contest.id),
:remote => true,
:method => :post,
:id => 'new-watcher-form') do %>
<table border="0">
<tr>
<td align="cneter">
</td>
<%= text_field_tag 'contest_password', nil, :size => 45 %>
<p class="buttons" style="padding-top: 10px; padding-bottom: 1px; margin-bottom: 1px">
<%= 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'
%>
</p>
</td>
</tr></table>
<% end %>

View File

@ -1,228 +0,0 @@
<%#= error_messages_for 'softapplication' %>
<script type="text/javascript" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
//验证作品名称
function regexName()
{
var name = $.trim($("#softapplication_name").val());
if(name.length == 0)
{
$("#spane_name_notice").text("<%= l(:label_no_softapplication_name) %>");
$("#spane_name_notice").css('color','#ff0000');
$("#spane_name_notice").focus();
return false;
}
else if(name.length <= 25)
{
$("#spane_name_notice").text("<%= l(:label_field_correct) %>");
$("#spane_name_notice").css('color','#008000');
return true;
}
else
{
$("#spane_name_notice").text("<%= l(:label_work_name_condition) %>");
$("#spane_name_notice").css('color','#ff0000');
$("#spane_name_notice").focus();
return false;
}
}
// added by longjun
//验证作品简介
function regexDescription()
{
var name = $.trim($("#softapplication_description").val());
if(name.length ==0)
{
$("#span_sofapplication_description").text("<%= l(:label_no_softapplication_description) %>");
$("#span_sofapplication_description").css('color','#ff0000');
$("#span_sofapplication_description").focus();
return false;
}
else if(name.length <= 500)
{
$("#span_sofapplication_description").text("<%= l(:label_field_correct) %>");
$("#span_sofapplication_description").css('color','#008000');
return true;
}
else
{
$("#span_sofapplication_description").text("<%= l(:label_work_description_condition) %>");
$("#span_sofapplication_description").css('color','#ff0000');
$("#span_sofapplication_description").focus();
return false;
}
}
//验证运行平台
function regexWorkdescription()
{
var workDescription = $.trim($("#softapplication_android_min_version_available").val());
if(workDescription.length ==0)
{
$("#spane_workdescription_notice").text("<%= l(:label_no_softapplication_platform) %>");
$("#spane_workdescription_notice").css('color','#ff0000');
return false;
}
if(workDescription.length <= 125)
{
$("#spane_workdescription_notice").text("<%= l(:label_field_correct) %>");
$("#spane_workdescription_notice").css('color','#008000');
return true;
}
else
{
$("#spane_workdescription_notice").text("<%= l(:label_work_platform_condition) %>");
$("#spane_workdescription_notice").css('color','#ff0000');
return false;
}
}
//验证开发人员
function regexDevelopers()
{
var workDescription = $.trim($("#softapplication_application_developers").val());
if(workDescription.length ==0)
{
$("#span_softapplication_application_developers").text("<%= l(:label_no_softapplication_developers) %>");
$("#span_softapplication_application_developers").css('color','#ff0000');
return false;
}
if(workDescription.length <= 125)
{
$("#span_softapplication_application_developers").text("<%= l(:label_field_correct) %>");
$("#span_softapplication_application_developers").css('color','#008000');
return true;
}
else
{
$("#span_softapplication_application_developers").text("<%= l(:label_softapplication_developers_condition) %>");
$("#span_softapplication_application_developers").css('color','#ff0000');
return false;
}
}
//提交验证
function submit_new_softapplication()
{
if(regexName() && regexDescription() && regexDevelopers())
{
$("#new_softapplication").submit();
}
}
</script>
<%= form_for Softapplication.new, :url => softapplications_path do |f| %>
<fieldset class="contes-new-box" style="padding-left: 36px; line-height: 8px; margin-left: 1px" >
<%= hidden_field_tag 'contest_id', @contest.id %>
<tr style="width:700px; margin-left: -10px;">
<span><%= l(:label_work_name) %></span>
<span class="contest-star"> * </span>:
<%= f.text_field :name,
:required => true,
:size => 60,
:style => "width:320px;",
:onkeyup => "regexName();"
%>
<span style="font-size: 10px;" id="spane_name_notice">(<%= l(:label_workname_lengthlimit) %>)</span>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px; padding-bottom: 30px;">
<span style="margin-top: 5px; float: left; display: block;"><%= l(:label_work_description) %>&nbsp;</span>
<span style="margin-top: 5px;float: left; display: block;" class="contest-star"> * </span>
<span style="margin-top: 5px; float: left; display: block;"> &nbsp;:&nbsp;</span>
<!-- modified by longjun 将单行输入框改成多行-->
<%= f.text_area :description,
:required => true,
:size => 60,
:rows => 3,
:onkeyup => 'regexDescription();',
:style => "width:320px; "
%>
<span style="font-size: 10px;" id="span_sofapplication_description">(<%= l(:label_work_description_lengthlimit) %>)</span>
<!--span style="font-size: 10px">(<%#= l(:label_workdescription_lengthlimit) %>)</span-->
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_softapplication_developers) %></span>
<span class="contest-star"> * </span>:
<%= f.text_field :application_developers,
:required => true,
:size => 60,
:style => "width:320px;",
:onkeyup => 'regexDevelopers();'
%>
<span style="font-size: 10px; " id="span_softapplication_application_developers">
(<%= l(:label_workdescription_lengthlimit) %>)
</span>
</tr>
<br/>
<br/>
<br/>
<tr style="width:800px;">
<span><%= l(:label_work_deposit_project) %></span>
<span style="padding-left: 4px">
<%= select_tag 'project',
options_for_select(select_option_helper(@option)),
:name => 'project',
:class => 'grayline2',
:style => "width:328px;"
%>
</span>
<span>
<!-- modified by longjun -->
<%= link_to l(:label_create_new_projects),
new_project_path(:course => 0, :project_type => 0, :host => Setting.host_name),
:target => '_blank'
%>
<!-- end longjun -->
</span><!-- new_project_path(course: 0, project_type: 0) -->
</tr>
<br/>
<br/>
<br/>
<fieldset style="width: 500px; padding-top: 10px">
<legend>
<%= l(:label_upload_softworkpacket_photo) %>
</legend>
<%#= render_flash_messages %>
<p id="put-bid-form-partial">
<%= render :partial => 'attachments/form' %>
</p>
<p style="font-size: 11px;line-height:normal;">
1、<%= l(:label_upload_softapplication_packets_mustpacketed) %> <br/>
<br>
2、<%= l(:label_upload_softapplication_photo_condition) %>
</p>
</fieldset>
</fieldset></br>
<div class="align-center" style="padding-top: -3px; padding-bottom: 8px">
<input type="button" class="enterprise" value="<%=l(:button_create) %>" onclick="submit_new_softapplication();" >
<%#= 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'" %>
</div>
<% end %>

View File

@ -1,18 +0,0 @@
<!-- fq -->
<% unless content.nil?%>
<table width="60%" style="margin-left: 60px;">
<tr>
<td> <%= textilizable content %></td>
</tr>
<tr>
<td>
<%= hidden_field_tag 'reference_content',
params[:reference_content],
:value => content
%>
</td>
</tr>
</table>
<% end %>

View File

@ -1,19 +0,0 @@
<!-- fq -->
<%= render_flash_messages %>
<table width="100%" border="0" style="padding-left: 15px">
<td width="15%" class="font_lighter" style="font-size: 15px;">
<%= l(:label_bidding_project) %>(<%= contesting_project.count%>)
</td> <!--标注参与项目及数量-->
<% if User.current.logged? %>
<td width="85%">
<div class='icon icon-add'> <!--标注我要参加及添加图标-->
<%= toggle_link l(:button_contesting_as_project), 'put-bid-form' %>
</div>
</td>
<% end %>
</table>
<%= render :partial=> "list_projects",
:locals => {:contesting_project => contesting_project,:contest => @contest }
%>

View File

@ -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 %>

View File

@ -1,24 +0,0 @@
<!-- fq -->
<%= render_flash_messages %>
<table width="100%" border="0" style="padding-left: 15px">
<td width="15%" class="font_lighter" style="font-size: 15px;">
<%= l(:label_contest_softapplication) %>
(<%= @contest.contesting_softapplications.count%>)
</td> <!--标注参赛应用及数量-->
<% if User.current.logged? %>
<td width="85%">
<div class='icon icon-add'> <!--标注我要参加及添加图标-->
<%= link_to l(:button_contesting_as_application),
"javascript:void(0);",
onclick: "$('#put-bid-form').toggle();"
%>
</div>
</td>
<% end %>
</table>
<%= render :partial=> "list_softapplications",
:locals => {:contesting_softapplication => contesting_softapplication,
:contest => @contest }
%>

View File

@ -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();

View File

@ -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();

View File

@ -1,2 +0,0 @@
$('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:contest => @contest, :journals => @jour, :state => @state})) %>');
$('#contest_message_reference_user_id').val("");

View File

@ -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("");

View File

@ -1,2 +0,0 @@
$('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:contest => @contest, :journals => @jour, :state => false})) %>');
$('#contest_message_reference_user_id').val("");

View File

@ -1,79 +0,0 @@
<div class="top-content">
<%= form_tag({:controller => 'contests', :action => 'index'}, :method => :get, :id => 'contests_serch') do %>
<table width="940px">
<tr>
<td class="info_font" style="width: 220px; color: #15bccf" rowspan="2">
<a href="http://<%= Setting.host_contest%>" style="color: #15bccf;">
<%=l(:label_contest_innovate_community)%>
</a>
</td>
<td class="location-list">
<strong><%= l(:label_user_location) %> :</strong>
</td>
<td rowspan="2" valign="bottom">
<% 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 longjun -->
<% end %>
<% end %>
</td>
<td rowspan="2" >
<div class="project-search" style="float: right">
<script type="text/javascript">
function regexName1()
{
var name = $.trim($("#name").val());
if(name.length == 0)
{
$("#contest_name_span_head").text("<%= l(:label_search_conditions_not_null) %>");
$("#contest_name_span_head").css('color','#ff0000');
$("#contest_name_span_head").focus();
return false;
}
else
{
$("#contest_name_span_head").text("");
return true;
}
}
function submitSerch()
{
if(regexName1()){$("#contests_serch").submit();}
}
</script>
<%= 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" %>
<br />
<span id="contest_name_span_head"></span>
</div>
</td>
</tr>
<tr>
<td >
<%=link_to l(:field_homepage), home_path %> >
<a><%= l(:label_contest_innovate) %></a>
<!-- end longjun -->
</td>
</tr>
</table>
<% end %>
</div>
<% if @contests.size > 0%>
<%#= sort_contest(@s_state)%>
<div id="bid-show" class="projects-index">
<%= render :partial => 'contest_list', :locals => {:contests => @contests, :contest_pages => @contest_pages} %>
</div>
<% elsif @is_search%>
<%= render :partial => "layouts/no_content"%>
<% else %>
<%#= sort_contest(@s_state)%>
<div id="bid-show" class="projects-index">
<%= render :partial => 'contest_list', :locals => {:contests => @contests, :contest_pages => @contest_pages} %>
</div>
<% end %>
<% html_title l(:label_contest_list)%>

View File

@ -1,2 +0,0 @@
$('#history').html('<%= escape_javascript(render(:partial => 'history', :locals => {:contest => @contest, :journals => @jour, :state => @state})) %>');
$('#contest_message_reference_user_id').val("");

View File

@ -0,0 +1,31 @@
<div class="project_r_h02" style="width: 980px;">
<h2 class="project_h2"><%= l(:permission_new_contest)%></h2>
</div>
<div class="hwork_new pr">
<ul>
<%= labelled_form_for @contest do |f| %>
<li class="mt10 ml45">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_tags_contest_name)%>&nbsp;&nbsp;</label>
<input type="text" name="contest[name]" id="new_course_name" class="courses_input" maxlength="100" placeholder="例如:顶尖移动应用开发大赛" onkeyup="regex_contest_name('new');">
<div class="cl"></div>
<span class="c_red ml80" id="new_course_name_notice" style="display: none;">竞赛名称不能为空且至少有两个字符</span>
</li>
<div class="cl"></div>
<li class="mt10 mb5 ml78">
<label >公开&nbsp;&nbsp;</label>
<input id="course_is_public" name="contest[is_public]" type="checkbox" value="1">
<span class="c_grey">(选中后对所有用户可见,否则仅对成员可见)</span>
<div class="cl"></div>
</li>
<li class="mt10 ml45">
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="submit_new_contest();">提交</a>
<%= link_to "取消",user_activities_path(User.current.id),:class => "grey_btn fl c_white ml10"%>
<div class="cl"></div>
</li>
<% end%>
</ul>
</div><!--talknew end-->
<div class="cl"></div>
<script>
</script>

View File

@ -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");

View File

@ -1,13 +0,0 @@
<!-- huang -->
<h3><%=l(:label_newtype_contest)%></h3>
<%= labelled_form_for @contest,
:url => {:controller => 'contests', :action => 'create_contest'},
method: :post do |f| %>
<div class="box tabular">
<%= 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 %>
</div>
<% html_title(l(:label_newtype_contest)) -%>

View File

@ -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');

View File

@ -1,31 +0,0 @@
<!-- modified by longjun 将or 改成 || -->
$('#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()

View File

@ -1,32 +0,0 @@
<!-- modified by longjun 将or 改成 || -->
$('#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()

View File

@ -1,35 +0,0 @@
<!-- added by bai -->
<p>
<td><%=l(:label_contest_settings)%></td>
&nbsp;&nbsp;&nbsp;
</p>
<script type="text/javascript" language="javascript">
function show(id, id_t, label_reward, label_money, label_credit, label_content) {
var text = $('#' + id);
var text_t = $('#' + id_t);
if (text.val() == 0) {
text_t.attr("placeholder", label_reward);
}
if (text.val() == 1) {
text_t.attr("placeholder", label_money);
}
if (text.val() == 3) {
text_t.attr("placeholder", label_credit);
}
if (text.val() == 2) {
text_t.attr("placeholder", label_content);
}
return content;
}
</script>
<%= error_messages_for 'contest' %>
<%= labelled_form_for @contest, :url => update_contest_contest_path(@contest) do |f| %>
<div class="box tabular">
<%= render :partial => 'form_contest', :locals => { :f => f } %>
</div>
<%= submit_tag l(:button_create) %>
<%= javascript_tag "$('#bid_name').focus();" %>
<% end %>

View File

@ -1,318 +0,0 @@
<style>
input[type="submit"].contest_btn {
vertical-align: middle;
width: 60px;
height: 30px;
line-height: 18px;
font-size: 14px;
color: rgb(0, 0, 0);
background: url("/images/button/bg103.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
/*margin-right: -4px;*/
}
input[type="button"].contest_btn {
width: 60px;
height: 30px;
line-height: 18px;
font-size: 14px;
color: rgb(0, 0, 0);
background: url("/images/button/bg103.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
margin-right: -2px;
}
textarea:focus {
border: #d5dee9 1px solid;
}
</style>
<script type="text/javascript" language="javascript">
function clearInfo(id, content) {
var text = $('#' + id);
if (text.val() == content) {
$('#' + id).val('');
}
}
function showInfo(id, content) {
var text = $('#' + id);
if (text.val() == '') {
$('#' + id).val(content);
}
}
function cancel() {
$("#put-bid-form").hide();
}
function cancel() {
$("#put-project-form").hide();
}
function selectChange(obj)
{
if(obj.value=="其他")
{
//document.getElementById("a").style.display = ""
$("#other_span").show();
}
else
{
$("#other_span").hide();
$("#other_input").val("");
//document.getElementById("a").style.display = "none"
}
}
</script>
<%= render_flash_messages %>
<!--参赛步骤-->
<div style="padding-left: 23px; padding-bottom: 10px; color: grey; font-size: 12px">
<div>
<%= l(:label_wellmeaning_intimation_contentone) %>
</div>
<div style="margin-left: 59px; padding-top: 2px">
1) <%= l(:label_wellmeaning_intimation_contenttwo) %>
</div>
<div style="margin-left: 59px; padding-top: 2px">
2) <%= l(:label_wellmeaning_intimation_contentthree) %>
</div>
</div>
<% if User.current.logged? %>
<div style="padding-bottom: 10px; line-height: 15px">
<div style="padding-left: 82px; font-size: 14px">
<span><strong><%= l(:label_attending_contest) %></strong></span>
<span>
<%= link_to l(:label_new_attendingcontest_work),
"javascript:void(0);",
onclick: "$('#put-project-form').slideToggle();"
%>
</span>
</div>
</div>
<div id="put-project-form" style=" padding-left: 83px; width: 88%">
<%= render "new_softapplication" %>
</div>
<% else %>
<div style="font-size: 14px;margin:10px;padding-left: 73px">
<%= l(:label_user_login_attending_contest) %>
<%= link_to l(:label_user_login_new), signin_path %>
</div>
<% end %>
<div class="underline-contests_three"></div>
<!--参赛作品列表,通过判断竞赛的id为2,3,6的显示参赛作品为提交的项目否则显示参赛的应用-->
<% if @contest.id == 2 or @contest.id == 3 or @contest.id == 6 %>
<% @contesting_project.sort.reverse.each do |c_project| %>
<% if c_project.project %>
<div style="padding-left: 18px">
<div style="font-size: 15px">
<div>
<div><strong><%= l(:label_contest_work) %>
: <%= link_to(c_project.project.name, project_path(c_project.project), :target => '_blank') %> </strong>
<div style="float: right">
<td style="color: #ec6300;" align="right" valign="0.1em" width="16%">
<strong>
<span id="reward_result_<%= c_project.id %>"> <!-- 调用js进行刷新 -->
<% if get_prize(c_project).nil? or get_prize(c_project) == "" %>
<% if @contest.deadline < Date.today %>
<span style="color: red"><%= l(:label_noawards) %></span>
<% else %>
<span style="color: red"><%= l(:label_noawards_current) %></span>
<% 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 %>
</span>
</strong>
</td>
<!-- 评价显隐控制按钮-->
<% if ((User.current.id == @contest.author_id) && (@contest.deadline >= Date.today))||User.current.admin %>
<td valign="top" align="right" width="10%">
<span> <%= toggle_link l(:label_reward), c_project.id.to_s %></span>
<!-- 评价应标项目的表单 -->
<span style="display: none; vertical-align: top " id='<%= c_project.id %>'>
<%= 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, "<option value = '-1'>#{l(:label_special_reward)}</option>
<option value = '0'>#{l(:label_first_reward)}</option>
<option value = '1'>#{l(:label_second_reward)}</option>
<option value = '2'>#{l(:label_third_reward)}</option>
<option value = '3'>#{l(:label_fourth_reward)}</option>
<option value = '4'>#{l(:label_fifth_reward)}</option>
<option value = '5'>#{l(:label_comfort_reward)}</option>".html_safe %>
<%= f.submit :value => l(:button_submit), :class => "submit" %>
<% end %>
</span>
</td>
<% end %>
</div>
</div>
</div>
</br>
</div>
<div style="padding-left: 68px">
<tr>
<td><%= l(:label_profile) %>:</td>
<td>
<%#= c_project.project.description.truncate(90, omission: '...') %>
<%= c_project.project.description %>
</td>
</tr>
</br>
</div>
<div style="padding-left: 68px; padding-bottom: 8px">
<span><strong><%= l(:label_attendingcontest_time) %>
</strong><%= format_time c_project.created_at %></span>
<span style="padding-left: 240px"><strong><%= l(:label_attendingcontest_spoksman) %>
<!-- modified by zjc 添加超链接 -->
<% unless c_project.nil? || c_project.user.nil? %>
</strong><%= link_to c_project.user.name,user_path(c_project.user) %></span>
<% end %>
</div>
<div style="padding-left: 68px">
</div>
</div>
<% end %>
<div class="underline-contests_three"></div>
<% end %>
<% else %>
<% @contesting_softapplication.each do |c_softapplication| %>
<% if c_softapplication.softapplication %>
<div style="padding-left: 18px">
<div style="font-size: 15px">
<tr>
<td><strong><%= l(:label_contest_work) %>: </strong></td>
<td> <%= link_to(c_softapplication.softapplication.name, softapplication_path(c_softapplication.softapplication), :target => '_blank') %> </td>
</tr>
</br>
</div>
<div style="padding-left: 68px; padding-top: 5px;word-break:break-all;word-wrap: break-word;">
<tr>
<td><strong><%= l(:label_profile) %>:</strong></td>
<td>
<%#= c_softapplication.softapplication.description.truncate(90, omission: '...') %>
<%= c_softapplication.softapplication.description %>
</td>
</tr>
</br>
</div>
<div style="padding-left: 68px; pading-bottom: 8px">
<span><strong><%= l(:label_attendingcontest_time) %>
</strong><%= format_time c_softapplication.created_at %></span>
<span style="padding-left: 240px"><strong><%= l(:label_attendingcontest_spoksman) %>
<!-- modified by zjc 添加超链接 -->
<% unless c_softapplication.nil? || c_softapplication.softapplication.nil? || c_softapplication.softapplication.user.nil? %>
</strong><%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %></span>
<% end %>
</div>
<!--获奖及教师评奖-->
<div style="padding-left: 18px; padding-bottom: 5px">
<% score = c_softapplication.softapplication.average(:quality).try(:avg).try(:round, 2).to_f %>
<span style="padding-left: 50px"><strong><%= l(:label_final_scores) %>
</strong></span><span style="color: red"><%= format("%.2f" , score) %>
分</span>
<span style="padding-left: 334px">
<td>
<strong>
<span id="reward_result_<%= c_softapplication.id %>"> <!-- 调用js进行刷新 -->
<% if get_prize(c_softapplication).nil? or get_prize(c_softapplication) == "" %>
<% if @contest.deadline < Date.today %>
<span style="color: red"><%= l(:label_noawards) %></span>
<% else %>
<span style="color: red"><%= l(:label_noawards_current) %></span>
<% 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 %>
</span>
</strong>
</td>
<!-- 评价显隐控制按钮-->
<% if ((User.current.id == @contest.author_id) && (@contest.deadline >= Date.today))||User.current.admin %>
<div style="text-align: right;width: 100%;">
<span style="padding-right: 5px; padding-top: 1px"> <%= toggle_link '评奖', c_softapplication.id.to_s %></span>
<!-- 评价应标项目的表单 -->
<span style="display: none; vertical-align: top " id='<%= c_softapplication.id %>'>
<%= 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, "<option value = '-1'>#{l(:label_special_reward)}</option>
<option value = '0'>#{l(:label_first_reward)}</option>
<option value = '1'>#{l(:label_second_reward)}</option>
<option value = '2'>#{l(:label_third_reward)}</option>
<option value = '3'>#{l(:label_fourth_reward)}</option>
<option value = '4'>#{l(:label_fifth_reward)}</option>
<option value = '5'>#{l(:label_comfort_reward)}</option>".html_safe %>
<%= f.submit :value => l(:button_submit), :class => "submit" %>
<% end %>
</span>
</div>
<% end %>
</span>
</div>
</div>
<% end %>
<div class="underline-contests_three"></div>
<% end %>
<% end %>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_contest_joincontest)) -%>

View File

@ -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}
%>
<script>
var W3CDOM = document.createElement && document.getElementsByTagName;
window.onload = setMaxLength;
function setMaxLength() {
if (!W3CDOM) return;
var textareas = document.getElementsByTagName('textarea');
for (var i=0;i<textareas.length;i++) {
var textarea = textareas[i];
setMaxLengthItem(textareas[i]);
}
}
function setMaxLengthItem(textarea){
if (textarea.getAttribute('maxlength')) {
var counter = document.createElement('div');
counter.className = 'counter';
var counterClone = counter.cloneNode(true);
counterClone.innerHTML = '<span>0</span>/'+textarea.getAttribute('maxlength');
textarea.parentNode.insertBefore(counterClone,textarea.nextSibling);
textarea.relatedElement = counterClone.getElementsByTagName('span')[0];
textarea.onkeyup = textarea.onchange = checkMaxLength;
textarea.onkeyup();
}
}
function checkMaxLength() {
var maxLength = this.getAttribute('maxlength');
var currentLength = this.value.length;
if (currentLength > maxLength)
this.relatedElement.className = 'toomuch';
else
this.relatedElement.className = '';
this.relatedElement.firstChild.nodeValue = currentLength;
}
</script>
<% html_title(l(:label_user_response)) -%>

View File

@ -1,37 +0,0 @@
<div class="inf_user_image">
<% for user in @contest.watcher_users %>
<ul class="list_watch"><li>
<table width="660px" border="0" align="center">
<tr>
<td colspan="2" valign="top" width="50" >
<%= image_tag(url_to_avatar(user), :class => "avatar") %>
</td>
<td><table width="580px" border="0">
<tr>
<td colspan="2" valign="top">
<strong>
<%= content_tag "div", link_to_user(user), :class => "project_avatar_name" %>
</strong>
</td>
</tr>
<tr>
<td colspan="2" width="580px" ><p class="font_description">
<% 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 %>
</p></td>
</tr>
<tr>
<td width="200" align="right" class="font_lighter">
<%= l(:label_user_joinin) %><%= format_date(user.created_on) %>
</td>
</tr>
</table></td>
</tr>
</table></li></ul>
<% end %>
</div>

View File

@ -1,135 +0,0 @@
<style>
input[type="submit"].contest_btn {
vertical-align: middle;
width: 60px;
height: 30px;
line-height: 18px;
font-size: 14px;
color: rgb(0, 0, 0);
background: url("/images/button/bg103.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
/*margin-right: -4px;*/
}
input[type="button"].contest_btn {
width: 60px;
height: 30px;
line-height: 18px;
font-size: 14px;
color: rgb(0, 0, 0);
background: url("/images/button/bg103.jpg") no-repeat scroll left top transparent;
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
margin-top: -10px;
margin-right: -2px;
}
textarea:focus {
border: #d5dee9 1px solid;
}
</style>
<script type="text/javascript" language="javascript">
function clearInfo(id,content) {
var text = $('#' + id);
if (text.val() == content) {
$('#' + id).val('');
}
}
function showInfo(id,content) {
var text = $('#' + id);
if (text.val() == '') {
$('#' + id).val(content);
}
}
function cancel() {
$("#put-bid-form").hide();
}
</script>
<% if User.current.logged? %>
<!--我要以发布应用的形式参加竞赛-弹出框-->
<div id = 'flash' style="float:left; width: 100%; display: nonea" ></div>
<div id="put-bid-form" style="display: none">
<%= form_for "contest_for_save",
:remote=>true,
:url => {:controller => 'contests', :action => 'add_softapplication'},
:update => "contesting_softapplication_list",
:complete => '$("#put-bid-form").hide();' do |f|
%>
<!--该table为点击我要参加后弹出的-->
<table id="contesting_table" border="0" width="100%" style="margin-left: 40px;">
<tr>
<td>
<%= select_tag 'contest',
options_for_select(select_option_app_helper(@softapplication)),
:name => 'contest',
:class => 'grayline'
%>
</td>
<div id="prompt_create_pro">
<td>
<p>
<div class="font_lighter" style="font-size: 13px;">
<%= link_to l(:label_release_softapplication),
new_softapplication_path(:target=>'_blank'),
:target=>'_blank'
%>
</div>
</p>
</td>
</div>
</tr>
<tr>
<td>
<%= f.text_area :contest_message,
:id => "contest_message",
:required => true,
:rows => 4,
:cols => 40,
:placeholder => l(:label_bid_reason),
:style => "resize: none;",
:class => 'noline'
%>
</td>
</tr>
<tr>
<td align="right">
<%= submit_tag l(:button_add),
:name => nil ,
:class => "enterprise",
:onmouseout => "this.style.backgroundPosition = 'left top'",
:onmouseover => "this.style.backgroundPosition = 'left -30px'"
%>
<%= 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'"
%>
</td>
</tr>
</table>
<% end %>
</div>
<% end %>
<div id='contesting_softapplication_list'>
<%= render :partial => 'softapplication_list', :locals => {:contesting_softapplication => @contesting_softapplication,:contest => @contest} %>
</div>

View File

@ -1,34 +0,0 @@
<!--add by huang-->
<h3><%= l(:label_user_watcher)%></h3>
<div class="inf_user_image">
<% @contest.watcher_users.each do |user| %> <!-- @contest.watcher_users.count -->
<ul class="list_watch">
<li>
<table width="660px" border="0" align="center">
<tr>
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(user), :class => "avatar") %></td>
<td><table width="580px" border="0">
<tr>
<td colspan="2" width="580px" ><p><%= content_tag "div", link_to_user(user), :class =>"project_avatar_name" %></p>
</td>
</tr>
<tr>
<td colspan="2" width="580px" ><p class="font_description">
<% 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 %>
</p></td>
</tr>
<tr>
<td width="200" align="right" class="font_lighter"><%= l(:label_user_joinin) %><%= format_date(user.created_on) %>
</td>
</tr>
</table></td>
</tr>
</table></li></ul>
<% end %>
</div>
<% html_title(l(:label_followers)) -%>

View File

@ -0,0 +1,17 @@
<% all_count = @user.contests.visible.where("is_delete =?", 0).count%>
<div id="homepageLeftMenuContests">
<ul class="user_sub_menu" id="user_contests_li">
<%= render :partial => 'layouts/user_contests', :locals => {:courses => contests,:user => @user,:all_count => all_count,:page => 0} %>
</ul>
</div>
<% if !contests.empty? %>
<a class="user_navmorebox" href="javascript:void(0);" id="user_hide_course" onclick="leftContestslistChange();">
<span id="hide_show_courseicon" class="user_icons_closeclass"></span>
</a>
<% end %>
<script>
$(function() {
$('#user_hide_contest').hide();
})
</script>

View File

@ -0,0 +1,72 @@
<% contests.each do |contest|%>
<li class="pr">
<span class="user_icons_class"></span>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.admin_of_contest?(contest)) %>
<p href="javascript:void(0);" id="show_contest_<%= contest.id %>" class="course_list_menu" >
<%= link_to contest.name, contest_path(contest.id), :target => '_blank', :class => 'hidden', :style => 'display:block;'%>
</p>
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Contest' and shield_id=#{contest.id}").count %>
<div class="user_navmore_box">
<ul class="<%#= count > 0 ? 'shild shildP':'subNavArrow'%>">
<li class="user_navmore_icons">
<ul class="user_navmore_txt">
<% if is_teacher %>
<li class="clear">
<%= link_to "作品",works_index_path(:contest => contest.id), :class => 'user_navmore_li fl', :target => '_blank' %>
<%= link_to '+',works_index_path(:contest => contest.id,:is_new => 1), :class => 'user_navmore_add fl', :title => '发布作品',:target => '_blank' %>
</li>
<li class="clear">
<%= link_to "通知", contest_news_index_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
<%= link_to "+", new_contest_news_path(contest,:is_new=>1), :class => 'user_navmore_add fl', :title => '发布通知',:target => '_blank' %>
</li>
<% else %>
<li>
<%= link_to "作业",works_index_path(:contest => contest.id), :class => 'user_navmore_li', :target => '_blank' %>
<div class="cl"></div>
</li>
<li>
<%= link_to "通知", contest_news_index_path(contest), :class => 'user_navmore_li',:target => '_blank' %>
<div class="cl"></div>
</li>
<% end %>
<li class="clear">
<%= link_to "论坛",contest_boards_path(contest), :class => 'user_navmore_li fl',:target => '_blank' %>
<%= link_to "+",contest_boards_path(contest, :flag => true, :is_new => 1), :class => 'user_navmore_add fl', :title => '发布帖子',:target => '_blank' %>
</li>
<% if User.current == user %>
<li>
<%= link_to "取消收藏", cancel_or_collect_user_path(user, :contest => contest.id), :class => 'user_navmore_li',:target => '_blank', :remote => true %>
<div class="cl"></div>
</li>
<li>
<% 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 %>
</li>
<% end %>
</ul>
</li>
</ul>
</div>
</li>
<% end %>
<% if all_count > (page.to_i+1) * 10%>
<a class="user_navmorebox" href="javascript:void(0);" id="user_show_more_course" onclick="show_more_course('<%= user_contests4show_user_path(user.id,:page => page)%>');">
<span class="user_icons_moreclass"></span>
</a>
<% end%>
<script type="text/javascript">
var coursecount = <%= all_count %>;
var courseshowcount = document.getElementsByClassName("course_list_menu").length;
if((coursecount <= courseshowcount)&&(coursecount > 10) ){
$("#user_show_more_course").hide();
$('#user_hide_course').show();
}
</script>

View File

@ -1,289 +0,0 @@
<%
@nav_dispaly_contest_label = 1
@nav_dispaly_store_all_label = 1
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><%= h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= 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 %>
<!-- page specific tags -->
<%= yield :header_tags -%>
</head>
<body class="<%= h body_css_classes %>">
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">
<%=render :partial => 'layouts/base_header'%>
<div id="main" class="">
<!-- added by bai -->
<div class="top-content">
<table>
<tr>
<td class="info_font" style="width: 240px;" rowspan="2">
<a href="http://<%= Setting.host_contest%>" style="color: #15bccf;">
<%=l(:label_contest_innovate_community)%>
</a>
</td>
<td style="width: 430px; color: #15bccf">
<strong>
<%= l(:label_user_location) %> :
</strong>
</td>
<td rowspan="2" width="250px">
<div class="project-search">
<%= 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] %>
<a href="#" onclick="$('#contest_search_form').submit();" class="ButtonColor m3p10" style="float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" >
<%= l(:label_search)%>
</a>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<% end %>
</div>
</td>
</tr>
<tr>
<td >
<%=link_to l(:field_homepage), home_path %> >
<%= l(:label_contest_innovate)%> >
<span>
<%= link_to @bid.name, bid_path %>
</span>
</td>
</tr>
</table>
</div>
<!-- end -->
<div id="sidebar">
<div class="main_context">
<div class="spaceleft">
<div class="inf_user_image">
<table>
<tr>
<td align="left" width="100px">
<%= image_tag(url_to_avatar(@user), :class => "avatar2") %>
</td>
<td>
<table>
<tr>
<td class="info_font" style=" word-wrap: break-word; word-break: break-all">
<%= h @bid.name %>
</td>
</tr>
<% if User.current.login? %> <!--added by linchun-->
<tr colspan='3'>
<td valign="middle">
<span style="display:block; margin-left:20px;">
<%= join_in_contest(@bid, User.current)%>
</span>
<span style="display:block; margin-left:20px;">
<span class="icon-fav icon"></span>
<%= watcher_link(@bid, User.current) %>
</span>
</td>
</tr>
<% end %>
</table>
<!-- added by bai 增加了竞赛的配置 -->
<% if User.current.logged? %>
<% if @bid.author.id == User.current.id %>
<%= link_to l(:label_contest_modify_settings), {:controller => 'bids', :action => 'settings', :id => @bid} %>
<% end %>
<% end %>
</td>
</table>
</div>
<!-- added by bai 增加参与人和参与项目的数量显示 -->
<div class="user_fans">
<table width="240" border="0">
<tr align="center" width="80px">
<td class="font_index">
<%=link_to "#{@bid.join_in_contests.count}",:controller => "bids",
:action => "show_participator" %>
</td>
<td class="font_index">
<%=link_to "#{@bid.projects.where('is_public=1').count}", :controller => 'bids',
:action => 'show_project' %>
</td>
<tr class="font_aram">
<td align="center" width="70px">
<%= l(:label_participator) %>
</td>
<td align="center" width="70px">
<%= l(:label_bidding_project) %>
</td>
</tr>
</table>
<div class="user_underline"></div>
</div>
<!-- end -->
<div class="inf_user_image">
<table>
<tr>
<td>
<%= l(:lable_contest_user) %>
<%= link_to(@user.name, user_path(@user))%>
</td>
</tr>
<tr>
<td>
<%= l(:label_bids_reward_method) %>
<%= @bid.budget%>
</td>
</tr>
<tr>
<td>
<%= l(:label_limit_time) %> :
<%= @bid.deadline%>
</td>
</tr>
</table>
</div>
<div class="user_underline"></div>
<!--description-->
<div class="inf_user_context">
<div class="font_title_left">
<%= l(:label_overview) %>
</div>
<div style="padding-bottom: 8px">
<% if @bid.description.size>0 %>
<div class="font_lighter_sidebar">
<%= textilizable @bid.description %>
</div>
<% else %>
<div class="font_lighter_sidebar">
<%= l(:label_course_description_no) %>
</div>
<% end %>
<div class="created_on_project">
<strong style="color: #068d9c">
<%= l(:label_create_time) %>
</strong>
<%= format_time(@bid.created_on) %>
</div>
</div>
<div class="user_underline"></div>
</div>
<!--tags-->
<div class="user_fans">
<div class="user_underline"></div>
<table style="font-family:'微软雅黑'">
<tr>
<td><!-- added by william -for tag -->
<%= render :partial => 'tags/tag', :locals => {:obj => @bid, :object_flag => "4"}%>
</td>
</tr>
</table>
</div>
<div class="user_fans">
<div class="user_underline"></div>
<div class="font_title_left">
<strong>
<%= l(:label_x_followers, :count => @bid.watcher_users.count) %>
</strong>
<% if show_more_fans?(@bid) %>
<span style="display:inline-block; font-size: 12px; float:right; margin-bottom: -4px;">
<%= link_to l(:button_more), :controller => 'bids', :action => 'show_bid_user'%>
</span>
<% end %>
</div>
<div class="left_wf">
<table>
<tr>
<td style="padding-top: 5px">
<%= show_bid_fans_picture(@bid)%>
</td>
</tr>
</table>
</div>
</div>
<!-- participate -->
<div class="user_fans">
<div class="user_underline"></div>
<div class="font_title_left">
<strong>
<%= l(:label_bidding_project) %>
</strong>
<% if show_more_bid_project?(@bid) %>
<span style="display:inline-block; font-size: 12px; float:right; margin-bottom: -4px;">
<%= link_to l(:button_more), :controller => 'bids', :action => 'show_project'%>
</span>
<% end %>
</div>
<div class="left_wf">
<table>
<tr>
<td style="padding-top: 5px">
<%= show_bid_project(@bid) %>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<!-- end -->
<div class="user_underline"></div>
<!--fans fq-->
<div class="user_fans">
<div class="font_title_left">
<strong>
<%= l(:label_x_join_in_contest, :count => @bid.join_in_contests.count) %>
</strong>
<% if show_more_participate?(@bid) %>
<span style="font-size: 12px; display: inline; float: right;" >
<%= link_to l(:button_more), :controller => "bids", :action => "show_participator"%>
</span>
<% end %>
</div>
<div class="left_wf">
<table>
<tr>
<td style="padding-top: 5px">
<%= show_participate_picture(@bid) %>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="content">
<% if display_main_menu?(@bid) %>
<div class="tabs_new">
<%= render_menu :bid_menu %>
</div>
<% end %>
<%= yield %>
<%= call_hook :view_layouts_base_content %>
<div style="clear:both;"></div>
</div>
<%=render :partial => 'layouts/base_footer'%>
</div>
</div>
</div>
<div id="ajax-indicator" style="display:none;">
<span>
<%= l(:label_loading) %>
</span>
</div>
<div id="ajax-modal" style="display:none;"></div>
</div>
<%= call_hook :view_layouts_base_body_bottom %>
</body>
</html>

View File

@ -0,0 +1,103 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title><%= h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= 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 -%>
<!-- MathJax的配置 -->
<script type="text/javascript"
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- 配置 在生成的公式图片上去掉Math定义的右键菜单$$ $$ \( \) \[ \] 中的公式给予显示-->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
showMathMenu: false,
showMathMenuMSIE: false,
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
</head>
<body onload="prettyPrint();">
<div class="navContainer">
<% 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%>
</div>
<div class="cl"></div>
<div class="homepageContentContainer">
<!--div class="homepageRightBannerImg"></div-->
<div class="cl"></div>
<div class="homepageContent">
<div class="homepageLeft mt10" id="LSide">
<div class="user_leftnav ">
<% if hidden_unproject_infos %>
<ul class="users_accordion mb10">
<li id="user_01" class="user_icons_course">
<%= link_to '竞赛',{:controller => "users", :action => "user_contestlist", :id => @user}, :id => "user_contest_list" %>
<font class="show-all-sub"><%= link_to '全部',{:controller => "users", :action => "user_contestlist", :id => @user}, :style => "color:#aaa;" %></font>
<% contests = @user.favorite_contests.visible.where("is_delete =?", 0).select("contests.*,(SELECT MAX(updated_at) FROM `contest_activities` WHERE contest_activities.contest_id = contests.id) AS a").order("a desc").limit(10) %>
<% unless contests.empty? %>
<div class="" id="homepage_left_contest_list">
<%= render :partial => 'layouts/homepage_left_contest_list', :locals => {:contests => contests} %>
</div>
<% end %>
</li>
<% if is_current_user %>
<li id="user_03" class="user_icons_new">
<%= link_to "新建竞赛", new_contest_path(), :target => "_blank", :style => "font-size:14px;" %>
</li>
<li id="user_04" class="user_icons_addclass">
<%= link_to "加入竞赛",join_contest_contests_path(),:remote => true, :method => "post", :style => "font-size:14px;" %>
</li>
<% end %>
</ul>
<% end %>
</div>
<%# 更新访问数,刷新的时候更新访问次数 %>
<%# update_visiti_count @user %>
<!--<div class="fontGrey5 mt10 ml20">访问计数 <%#= @user.visits.to_i %> 自2016年5月</div>-->
</div>
<div class="homepageRight">
<%= yield %>
</div>
</div>
</div>
<div class="cl"></div>
<%= render :partial => 'layouts/footer' %>
<div class="cl"></div>
<div id="ajax-modal" style="display:none;"></div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
<div id="nh_tx_dialog_html" class="white_content" style="display:none;">
<%=render :partial => 'layouts/upload_avatar', :locals => {:source => @user} %>
</div>
<script>
function leftContestslistChange(){
var target = $('#user_contests_li>li');
for(var i = 10; i < target.length; i++){
target.eq(i).slideToggle();
}
$('#hide_show_courseicon').toggleClass("user_icons_closeclass");
$('#hide_show_courseicon').toggleClass("user_icons_moreclass");
}
</script>
</body>
</html>

View File

View File

@ -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' %>
<!-- page specific tags -->
<%= yield :header_tags -%>
<!-- MathJax的配置 -->

View File

@ -238,6 +238,19 @@
</li>
</ul>
</div>
<div class="home-user-leftnav">
<h3 >
<%= link_to "竞赛社区", user_contest_community_path(User.current), :class => "fl" , :target => "_blank"%>
</h3>
<ul>
<li class="home-user-leftnav-li icons-class clear">
<%= link_to user_contest_count > 0 ? "竞赛<span class='issues_nav_tag mr10 fr' style='line-height:18px;margin-top: 9px;'>#{user_contest_count}</span>".html_safe : "竞赛",
user_contest_community_path(User.current), :id => "user_contest_list", :target => "_blank" %>
</li>
</ul>
<%# end %>
</div>
<% else %>
<div class="home-user-leftnav">
<h3 >Ta在确实
@ -252,6 +265,10 @@
<%= link_to user_project_count > 0 ? "项目<span class='issues_nav_tag ml140'>#{user_project_count}</span>".html_safe : "项目",
user_project_community_path(@user), :id => 'user_project_list', :class => "fl", :target => "_blank" %>
</li>
<li class="home-user-leftnav-li icons-project clear">
<%= link_to user_contest_count > 0 ? "竞赛<span class='issues_nav_tag ml140'>#{user_contest_count}</span>".html_safe : "竞赛",
user_contest_community_path(@user), :id => 'user_contest_list', :class => "fl", :target => "_blank" %>
</li>
</ul>
</div>
<% end %>

View File

@ -0,0 +1,23 @@
<div class="resources mt10">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= 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} %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word">
<%= 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" %>
</div>
<div class="homepagePostTitle break_word" >
<%= link_to activity.name, contest_path(activity.id), :class => "postGrey" %>
</div>
<div class="homepagePostDate">
创建时间:<%= format_time(activity.created_at) %>
</div>
</div>
<div class="cl"></div>
</div>
</div>

View File

@ -0,0 +1,61 @@
<% is_teacher = User.current.admin_of_contest?(:as_teacher,activity.course) %>
<div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= 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} %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word">
<%= link_to activity.user.show_name, user_path(activity.user,:host=>Setting.host_user), :class => "newsBlue mr15" %>
TO
<% if hw_status == 3 || hw_status == 2 %>
<%= link_to "竞赛作品", works_index_path(:contest => activity.contest.id), :class => "newsBlue ml15"%>
<% else %>
<%= link_to activity.contest.name.to_s+" | 竞赛作品", works_index_path(:contest => activity.contest.id), :class => "newsBlue ml15"%>
<% end %>
</div>
<div class="homepagePostTitle hidden fl m_w505"> <!--+"(作业名称)"-->
<% if hw_status == 3 || hw_status == 5 %>
<% index = get_work_index(activity, is_teacher) %>
<%= link_to "<span class='fontBlue2'>作品#{index+1}</span>".html_safe+activity.name,contestant_work_index_path(:work => activity.id),:class => "postGrey"%>
<% else %>
<%= link_to activity.name.to_s, contestant_work_index_path(:work => activity.id), :class => "postGrey"%>
<% end %>
</div>
<%#=get_hw_status(activity).html_safe %>
<div class="cl"></div>
<% if activity.work_type == 3 && activity.work_detail_group.base_on_project %>
<span class="c_red">系统提示:该题目要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span>
<% elsif activity.work_type == 3 && !activity.work_detail_group.base_on_project%>
<span class="c_red">系统提示:该题目要求各组长提交作品,提交作品时请添加组成员。谢谢配合!</span>
<% end %>
<div class="homepagePostSubmitContainer">
<%= 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? %>
<div class="homepagePostDeadline">提交截止时间:<%= activity.end_time.to_s %>&nbsp;23:59</div>
<% end %>
<% if activity.homework_detail_manual.comment_status == 0 && !activity.publish_time.nil? %>
<div class="homepagePostDeadline ml15">
<%= l(:label_publish_time)%><%= activity.publish_time%>&nbsp;00:00
</div>
<% end %>
</div>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
<div class="cl"></div>
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
<div class="cl"></div>
<div class="mt10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
</div>
<%= render :partial => "users/contest_work_base_info", :locals =>{:activity => activity, :user_activity_id =>user_activity_id, :is_teacher => is_teacher, :hw_status => hw_status} %>
</div>
<div class="cl"></div>
</div>
<%= render :partial => 'users/homework_post_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id, :is_teacher => is_teacher} %>
</div>

View File

@ -0,0 +1,58 @@
<!--<div class="mt10">-->
<!--<div class="homepagePostDeadline">-->
<!--迟交扣分:<%#= activity.late_penalty%>分-->
<!--</div>-->
<!--</div>-->
<!--<div class="cl"></div>-->
<% if activity.contestant_works.count != 0 %>
<% sw = activity.contestant_works.reorder("commit_time desc").first %>
<div class="mt10 homepagePostDeadline">
#&nbsp;<%=time_from_now sw.commit_time %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
</div>
<div class="cl"></div>
<% 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 %>
<div class="mt10">
<p class="fontGrey2">#&nbsp;<%=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"%>评阅了作品
</p>
</div>
<% end %>
<% end %>
<div class="cl"></div>
<% 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 %>
<div class="mt10 relatePWrap" id="relatePWrap_<%=user_activity_id %>">
<div class="mr5 fontGrey2">
<% 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 %>
#&nbsp;<%=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"%>更新了项目
</div>
<div class="cl"></div>
</div>
<% end %>
<% end %>
<div class="cl"></div>
<% if is_teacher%>
<div class="homepagePostSetting">
<ul>
<li class="homepagePostSettingIcon">
<ul class="whomepagePostSettiongText">
<li>
<%= link_to l(:button_edit),edit_work_path(activity, :hw_status => hw_status), :class => "wpostOptionLink"%>
</li>
<li>
<%= link_to(l(:label_bid_respond_delete), works_path(activity, :hw_status => hw_status),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "wpostOptionLink") %>
</li>
</ul>
</li>
</ul>
</div>
<% end%>

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