This commit is contained in:
guange 2017-01-18 00:18:58 +08:00
commit 3146342586
196 changed files with 72652 additions and 2413 deletions

View File

@ -54,6 +54,7 @@ gem 'elasticsearch-rails'
### profile
# gem 'oneapm_rpm'
# gem 'therubyracer'
group :development do
gem 'grape-swagger'

View File

@ -124,6 +124,16 @@ class AdminController < ApplicationController
render :action => "projects", :layout => false if request.xhr?
end
def contests
@name = params[:name]
@contests = Contest.where("id >= 780 and name like '%#{@name}%'").order('created_at desc')
@contests = paginateHelper @contests,30
@page = (params['page'] || 1).to_i - 1
respond_to do |format|
format.html
end
end
def syllabuses
@name = params[:name]
@syllabuses = Syllabus.like(@name).order('created_at desc')

View File

@ -500,10 +500,6 @@ class ApplicationController < ActionController::Base
#<23><>ȡ<EFBFBD>γ<EFBFBD>
def find_course
@course= Course.find(params[:id])
if @course.is_delete == 1 and !User.current.admin?
render_404
return
end
rescue ActiveRecord::RecordNotFound
render_404
end
@ -581,19 +577,19 @@ class ApplicationController < ActionController::Base
end
def redirect_back_or_default(default, options={})
back_url = '' #params[:back_url].to_s
back_url = params[:back_url].to_s
if back_url.present?
begin
uri = URI.parse(back_url)
# do not redirect user to another host or to the login or register page
if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) if default.is_a?(:User)
back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) if default.is_a?(User)
redirect_to(back_url)
return
end
rescue URI::InvalidURIError
logger.warn("Could not redirect to invalid URL #{back_url}")
# redirect to default
redirect to default
end
elsif options[:referer]
redirect_to_referer_or default

View File

@ -40,7 +40,7 @@ class AvatarController < ApplicationController
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
# 用户头像上传时进行特别处理
if @is_direct == '1' && (@source_type == 'User' || @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization')
if @is_direct == '1' && (@source_type == 'User' || @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization'|| @source_type == 'Contest')
diskfile += "temp"
@urlfile += "temp"
end

View File

@ -173,12 +173,19 @@ class BlogCommentsController < ApplicationController
render_attachment_warning_if_needed(@blogComment)
#@article.save
# redirect_to user_blogs_path(:user_id=>params[:user_id])
# 给回复的人发消息
reply_user_id = params[:reply_id].nil? ? @blogComment.blog.author_id: params[:reply_id].to_i
# 回复的作业与评论的作者不是同一人则发送消息
if ( params[:reply_id].nil? && @blogComment.author.id != @blogComment.blog.author_id )|| (!params[:reply_id].nil? && @blogComment.author.id != params[:reply_id].to_i)
BlogMessage.create(:user_id => reply_user_id, :blog_id => params[:blog_id].to_i, :content => params[:blog_comment][:content],
:blog_commont_id => @blogComment.id, :blog_message_type => "BlogComment", :user_operator_id => @blogComment.author.id)
end
respond_to do |format|
format.html {
if params[:course_id] #如果呆了course_id过来了那么这是要跳到课程大纲去的
redirect_to syllabus_course_path(:id=>params[:course_id])
else
redirect_to user_blog_blog_comment_path(:user_id=>@article.author_id,:blog_id=>@article.blog_id,:id=>@article)
redirect_to user_blog_blog_comment_path( @article.author, :blog_id => @article.blog_id, :id => @article)
end
}

View File

@ -261,6 +261,18 @@ class BoardsController < ApplicationController
respond_to do |format|
format.js
end
elsif @contest
parent = Board.find params[:board_id].to_i
board = @contest.boards.build
board.name = params[:name]
board.description = board.name
board.project_id = -1
board.course_id = -1
board.position = parent.children.count + 1
parent.children << board
respond_to do |format|
format.js
end
end
end
@ -284,7 +296,7 @@ class BoardsController < ApplicationController
after_boards = @board.parent.children.where("position > #{@board.position}")
after_boards.update_all("position = position - 1")
@board.destroy
if @course
if @course || @contest
respond_to do |format|
format.js
end
@ -294,7 +306,7 @@ class BoardsController < ApplicationController
end
def update_position
if @course
if @course || @contest
boards = @board.parent.children
if params[:opr] == 'up' && @board.position > 1
before_board = boards.where("position = #{@board.position - 1}").first
@ -314,7 +326,7 @@ class BoardsController < ApplicationController
end
def update_name
if @course
if @course || @contest
@board.update_attribute("name", params[:name])
@board.update_attribute("description", params[:name])
respond_to do |format|

View File

@ -48,10 +48,13 @@ class ContestantWorksController < ApplicationController
@all_homework_commons = @contest.works.order("created_at desc")
@is_teacher = User.current.admin_of_contest?(@contest) || User.current.admin?
@is_judge = User.current.judge_of_contest?(@contest)
@is_evaluation = @is_judge && @contestwork.work_status == 3 && @contestwork.online_evaluation
@show_all = false
if @is_teacher || @is_judge
is_judge_open = @is_judge && (!@contestwork.online_evaluation || (@contestwork.online_evaluation && @contestwork.work_status == 4))
is_contestant_open = User.current.contestant_of_contest?(@contest) && ((!@contestwork.online_evaluation && @contestwork.work_status == 2 && @contestwork.score_open) || (@contestwork.online_evaluation && @contestwork.work_status == 4 && @contestwork.score_open))
if @is_teacher || is_judge_open || is_contestant_open
# if @order == 'lastname'
# @stundet_works = search_homework_member @homework.student_works.no_copy.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
# elsif @order == 'student_id'
@ -60,7 +63,15 @@ class ContestantWorksController < ApplicationController
@stundet_works = @contestwork.contestant_works.no_copy.select("contestant_works.*,contestant_works.work_score as score").includes(:user => {:user_extensions => []}, :project => {}, :contestant_work_scores => {}).order("#{@order} #{@b_sort}")
#end
@show_all = true
elsif User.current.member_of_contest?(@contest)
elsif @is_evaluation
if @contestwork.work_detail_manual.evaluation_num == -1
@stundet_works = @contestwork.contestant_works.no_copy.select("contestant_works.*,contestant_works.work_score as score").includes(:user => {:user_extensions => []}, :project => {}, :contestant_work_scores => {}).order("#{@order} #{@b_sort}")
else
@stundet_works = User.current.contestant_work_evaluation_distributions.map(&:contestant_work).select { |cwork| cwork.work_id == @contestwork.id}
end
elsif User.current.judge_of_contest?(@contest)
@stundet_works = []
elsif User.current.contestant_of_contest?(@contest)
if @contestwork.work_type == 3
pro = @contestwork.contestant_work_projects.where(:user_id => User.current.id).first
if pro.nil?
@ -86,18 +97,19 @@ class ContestantWorksController < ApplicationController
respond_to do |format|
format.js
format.html
# format.xls {
# filename = "#{@contest.user.lastname.to_s + @contest.user.firstname}_#{@contest.name}_#{@contestwork.name}#{l(:excel_homework_list)}.xls"
# send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
# :filename => filename_for_content_disposition(filename))
# }
format.xls {
filename = "#{@contest.user.show_name.to_s}_#{@contest.name}_#{@contestwork.name}_#{l(:excel_homework_list)}_#{DateTime.parse(Time.now.to_s).strftime('%Y%m%d%H%M%S').to_s}.xls"
send_data(work_score_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
:filename => filename_for_content_disposition(filename))
}
end
end
def show
#@score = student_work_score @work,User.current
@score = ContestantWorkScore.where(:user_id => User.current.id,:contestant_work_id => @work.id,:reviewer_role => 2).last
@is_evaluation = User.current.judge_of_contest?(@contest) && @contestwork.work_status == 3 && @contestwork.online_evaluation
@is_teacher = User.current.admin_of_contest?(@contest) || User.current.judge_of_contest?(@contest) || User.current.admin?
if @contestwork.work_status == 3 && User.current.judge_of_contest?(@contest) && @contestwork.online_evaluation
if @is_evaluation
@student_work_scores = @work.contestant_work_scores.where("user_id = #{User.current.id} and reviewer_role = 2").order("updated_at desc")
else
@student_work_scores = contestant_work_score_record(@work)
@ -368,9 +380,10 @@ class ContestantWorksController < ApplicationController
def add_score
@is_last = params[:is_last] == "true"
@is_teacher = User.current.admin_of_contest?(@contest) || User.current.judge_of_contest?(@contest) || User.current.admin?
@is_evaluation = User.current.judge_of_contest?(@contest) && @contestwork.work_status == 3 && @contestwork.online_evaluation
#@is_teacher = User.current.admin_of_contest?(@contest) || User.current.judge_of_contest?(@contest) || User.current.admin?
#老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
render_403 and return unless User.current.judge_of_contest?(@contest) && @contestwork.work_status == 3
render_403 and return unless @is_evaluation
@is_last_a = @work.contestant_work_scores.empty?
@new_score = ContestantWorkScore.new
@new_score.score = params[:score].to_i
@ -403,6 +416,8 @@ class ContestantWorksController < ApplicationController
@contestwork.update_column('updated_at', Time.now)
update_contest_activity(@contestwork.class,@contestwork.id)
update_user_activity(@contestwork.class,@contestwork.id)
judge_score = ContestantWorkScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{@work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@work.judge_score = judge_score.first.score.nil? ? nil : judge_score.first.score.try(:round, 2).to_f
if @work.save
@work = @contestwork.contestant_works.select("contestant_works.*,contestant_works.work_score as score").where(:id => @work.id).first
@count = @contestwork.contestant_works.has_committed.count
@ -457,4 +472,140 @@ class ContestantWorksController < ApplicationController
def is_logged
redirect_to signin_path unless User.current.logged?
end
#提交成绩导出
def work_score_to_xls items
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "work"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
if @contestwork.work_type == 1 #普通作业
#开启在线评审
if @contestwork.online_evaluation
sheet1.row(0).concat([l(:excel_contestant_id),l(:excel_user_name),l(:excel_nickname),l(:excel_mail),l(:excel_school),l(:excel_homework_name),l(:excel_homework_des)])
if @contestwork.work_detail_manual.evaluation_num != -1
num = @contestwork.work_detail_manual.evaluation_num
n = num < (contest_judges @contest).size ? num : (contest_judges @contest).size
else
n = (contest_judges @contest).size
end
for i in 1 .. n do i
sheet1.row(0).concat([l(:label_judge_score, :num => i),l(:label_judge_comment, :num => i)])
end
sheet1.row(0).concat([l(:label_highest_score),l(:label_lowest_score),l(:excel_f_score),l(:excel_commit_time)])
count_row = 1
items.each do |contestant_work|
sheet1[count_row,0] = contestant_work.user.id
sheet1[count_row,1] = contestant_work.user.show_name
sheet1[count_row,2] = contestant_work.user.login
sheet1[count_row,3] = contestant_work.user.mail
sheet1[count_row,4] = contestant_work.user.user_extensions.school.nil? ? "" : contestant_work.user.user_extensions.school.name
sheet1[count_row,5] = contestant_work.name
sheet1[count_row,6] = strip_html contestant_work.description if !contestant_work.description.nil?
work_scores = contestant_work_score_record contestant_work
for i in 1 .. n do i
sheet1[count_row,6 + i*2 -1] = (work_scores.nil? || work_scores[i - 1].nil?) ? l(:label_without_score) : work_scores[i - 1].score
sheet1[count_row,6 + i*2] = (work_scores.nil? || work_scores[i - 1].nil?) ? "" : work_scores[i - 1].comment
end
sheet1[count_row,7+2*n] = (work_scores.nil? || work_scores.reorder("score desc").first.nil?) ? l(:label_without_score) : work_scores.reorder("score desc").first.score
sheet1[count_row,8+2*n] = (work_scores.nil? || work_scores.reorder("score desc").last.nil?) ? l(:label_without_score) : work_scores.reorder("score desc").last.score
sheet1[count_row,9+2*n] = contestant_work.work_score.nil? ? l(:label_without_score) : contestant_work.work_score.round(2)
sheet1[count_row,10+2*n] = format_time contestant_work.commit_time
count_row += 1
end
#未开启在线评审
else
sheet1.row(0).concat([l(:excel_contestant_id),l(:excel_user_name),l(:excel_nickname),l(:excel_mail),l(:excel_school),l(:excel_homework_name),l(:excel_homework_des),l(:excel_commit_time)])
count_row = 1
items.each do |contestant_work|
sheet1[count_row,0] = contestant_work.user.id
sheet1[count_row,1] = contestant_work.user.show_name
sheet1[count_row,2] = contestant_work.user.login
sheet1[count_row,3] = contestant_work.user.mail
sheet1[count_row,4] = contestant_work.user.user_extensions.school.nil? ? "" : contestant_work.user.user_extensions.school.name
sheet1[count_row,5] = contestant_work.name
sheet1[count_row,6] = strip_html contestant_work.description if !contestant_work.description.nil?
sheet1[count_row,7] = format_time contestant_work.commit_time
count_row += 1
end
end
elsif @contestwork.work_type == 3 #分组作业
if @contestwork.online_evaluation
sheet1.row(0).concat([l(:excel_group_member),l(:excel_group_leader),l(:excel_group_leader_login),l(:excel_group_leader_mail),l(:excel_school)])
if @contestwork.work_detail_group.base_on_project
sheet1.row(0).concat([l(:excel_homework_project),l(:excel_homework_name),l(:excel_homework_des)])
else
sheet1.row(0).concat([l(:excel_homework_name),l(:excel_homework_des)])
end
if @contestwork.work_detail_manual.evaluation_num != -1
num = @contestwork.work_detail_manual.evaluation_num
n = num < (contest_judges @contest).size ? num : (contest_judges @contest).size
else
n = (contest_judges @contest).size
end
for i in 1 .. n do i
sheet1.row(0).concat([l(:label_judge_score, :num => i),l(:label_judge_comment, :num => i)])
end
sheet1.row(0).concat([l(:label_highest_score),l(:label_lowest_score),l(:excel_f_score),l(:excel_commit_time)])
count_row = 1
items.each do |contestant_work|
sheet1[count_row,0] = get_contest_group_member_names contestant_work
sheet1[count_row,1] = contestant_work.user.show_name
sheet1[count_row,2] = contestant_work.user.login
sheet1[count_row,3] = contestant_work.user.mail
sheet1[count_row,4] = contestant_work.user.user_extensions.school.nil? ? "" : contestant_work.user.user_extensions.school.name
if @contestwork.work_detail_group.base_on_project
sheet1[count_row,5] = (contestant_work.project_id == 0 || contestant_work.project_id.nil?) ? l(:excel_no_project) : contestant_work.project.name
current_column = 6
else
current_column = 5
end
sheet1[count_row,current_column] = contestant_work.name
sheet1[count_row,current_column + 1] = strip_html contestant_work.description if !contestant_work.description.nil?
work_scores = contestant_work_score_record contestant_work
for i in 1 .. n do i
sheet1[count_row,current_column + 1 + i*2 -1] = (work_scores.nil? || work_scores[i - 1].nil?) ? l(:label_without_score) : work_scores[i - 1].score
sheet1[count_row,current_column + 1 + i*2] = (work_scores.nil? || work_scores[i - 1].nil?) ? "" : work_scores[i - 1].comment
end
sheet1[count_row,current_column + 2 +2*n] = (work_scores.nil? || work_scores.reorder("score desc").first.nil?) ? l(:label_without_score) : work_scores.reorder("score desc").first.score
sheet1[count_row,current_column + 3 +2*n] = (work_scores.nil? || work_scores.reorder("score desc").last.nil?) ? l(:label_without_score) : work_scores.reorder("score desc").last.score
sheet1[count_row,current_column + 4 +2*n] = contestant_work.work_score.nil? ? l(:label_without_score) : contestant_work.work_score.round(2)
sheet1[count_row,current_column + 5 +2*n] = format_time contestant_work.commit_time
count_row += 1
end
else
if @contestwork.work_detail_group.base_on_project
sheet1.row(0).concat([l(:excel_group_member),l(:excel_group_leader),l(:excel_group_leader_login),l(:excel_group_leader_mail),l(:excel_school),l(:excel_homework_project),l(:excel_homework_name),l(:excel_homework_des),l(:excel_commit_time)])
else
sheet1.row(0).concat([l(:excel_group_member),l(:excel_group_leader),l(:excel_group_leader_login),l(:excel_group_leader_mail),l(:excel_school),l(:excel_homework_name),l(:excel_homework_des),l(:excel_commit_time)])
end
count_row = 1
items.each do |contestant_work|
sheet1[count_row,0] = get_contest_group_member_names contestant_work
sheet1[count_row,1] = contestant_work.user.show_name
sheet1[count_row,2] = contestant_work.user.login
sheet1[count_row,3] = contestant_work.user.mail
sheet1[count_row,4] = contestant_work.user.user_extensions.school.nil? ? "" : contestant_work.user.user_extensions.school.name
if @contestwork.work_detail_group.base_on_project
sheet1[count_row,5] = (contestant_work.project_id == 0 || contestant_work.project_id.nil?) ? l(:excel_no_project) : contestant_work.project.name
current_column = 6
else
current_column = 5
end
sheet1[count_row,current_column] = contestant_work.name
sheet1[count_row,current_column + 1] = strip_html contestant_work.description if !contestant_work.description.nil?
sheet1[count_row,current_column + 2] = format_time contestant_work.commit_time
count_row += 1
end
end
end
book.write xls_report
xls_report.string
end
end

View File

@ -4,8 +4,12 @@ class ContestsController < ApplicationController
include ContestsHelper
helper :contest_members
helper :users
helper :attachments
helper :files
include AvatarHelper
before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :search_member, :private_or_public, :switch_role, :set_invite_code_halt, :renew]
before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :search_member, :private_or_public, :switch_role, :set_invite_code_halt, :renew,
:member, :export_all_members, :feedback]
before_filter :is_logged, :only => [:index, :new, :create]
before_filter :is_admin?, :only => [:settings, :set_invite_code_halt, :destroy]
before_filter :is_member?, :only => [:show, :contest_activities]
@ -111,6 +115,30 @@ class ContestsController < ApplicationController
@contest.update_attributes(:is_delete => true)
end
def feedback
if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest)))
ContestMessage.where(:user_id => User.current.id, :contest_id => @contest.id, :contest_message_type => 'JournalsForMessage', :contest_message_id => @contest.journals_for_messages.map{|jour|jour.id}).update_all(:viewed => true)
page = params[:page]
# Find the page of the requested reply
@jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
@jour_count = @jours.count
@limit = 10
if params[:r] && page.nil?
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
page = 1 + offset / @limit
end
@jour = paginateHelper @jours,10
@state = false
@left_nav_type = 6
respond_to do |format|
format.html{render :layout => 'base_contests'}
format.api
end
else
render_403
end
end
def private_or_public
@contest.update_attributes(:is_public => !@contest.is_public)
@ -131,11 +159,8 @@ class ContestsController < ApplicationController
end
def settings
if params[:tab] && params[:tab] == 'boards'
@tab = 2
else
@tab = 0
end
@select_tab = params[:tab]
@member ||= @contest.contest_members.new
@roles = Role.where("id in (13, 14, 15)")
@members = @contest.member_principals.includes(:roles, :principal).all.sort
@ -253,8 +278,82 @@ class ContestsController < ApplicationController
end
end
# 成员列表
def member
if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest)))
@role = params[:role].nil? ? '3' : params[:role]
case @role
when '1'
@members = contest_managers @contest
when '2'
@members = contest_judges @contest
when '3'
@members = contest_contestants @contest
end
if params[:name]
q = "#{params[:name].strip}"
@members = search_member_by_name_login_school @members, q
end
@limit = 50
@page = params[:page].nil? ? 1 : params['page'].to_i
@members_count = @members.count
@mem_pages = Paginator.new @members_count, @limit, @page
@members = paginateHelper @members, @limit
respond_to do |format|
format.html {render :layout => 'base_contests'}
format.js
end
else
render_403
end
end
def export_all_members
sql = "SELECT DISTINCT(cmr.id) AS cmr_id, cmr.role_id, users.`login`, users.id AS user_id, users.`mail`, cmr.created_at FROM users, contest_members cm, contest_member_roles cmr, user_extensions ue, schools " +
"WHERE users.id = cm.`user_id` AND users.id=ue.`user_id` AND cmr.`contest_member_id` = cm.`id` AND cm.`contest_id` = #{@contest.id} AND (ue.`school_id` IS NULL OR ue.`school_id` = schools.`id`) " +
"ORDER BY role_id ASC, CONVERT(schools.`name` USING gbk) COLLATE gbk_chinese_ci DESC, CONVERT(users.`lastname` USING gbk) COLLATE gbk_chinese_ci DESC"
@members = ContestMemberRole.find_by_sql sql
respond_to do |format|
format.xls {
filename = "#{@contest.name.to_s}-成员列表-#{DateTime.parse(Time.now.to_s).strftime('%Y%m%d%H%M%S').to_s}.xls"
send_data(member_to_xls(@members), :type => "text/excel;charset=utf-8; header=present",
:filename => filename_for_content_disposition("#{filename}.xls"))
}
end
end
private
def member_to_xls members
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "成员列表"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
#sheet1.row(0).default_format = blue
#sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)])
sheet1[0,0] = "id"
sheet1[0,1] = "姓名"
sheet1[0,2] = "登录名"
sheet1[0,3] = "电子邮箱"
sheet1[0,4] = "单位"
sheet1[0,5] = "角色"
sheet1[0,6] = "加入时间"
count_row = 1
members.each_with_index do |member, i|
user = User.find(member.user_id)
sheet1[count_row,0]= user.id
sheet1[count_row,1] = user.show_name
sheet1[count_row,2] = user.login
sheet1[count_row,3] = user.mail
sheet1[count_row,4] = user.user_extensions.school_id.blank? ? "" : (user.user_extensions.school.blank? ? "" : user.user_extensions.school.name)
sheet1[count_row,5] = member.role_id == 13 ? "管理员" : (member.role_id == 14 ? "评委" : "参赛者")
sheet1[count_row,6] = format_time member.created_at
count_row += 1
end
book.write xls_report
xls_report.string
end
def find_contest
if params[:id].to_i < 780
render_403

View File

@ -187,6 +187,7 @@ class CoursesController < ApplicationController
# @is_remote = true
@sort_type = 'score'
@score_sort_by = "desc"
@search_name = "#{params[:name].strip}"
q = "#{params[:name].strip}"
if params[:incourse]
results = searchmember_by_name(student_homework_score(0,0,0,"desc"), q)
@ -350,19 +351,17 @@ class CoursesController < ApplicationController
@search = params[:search]
q = params[:search] ? "#{params[:search].strip}" : ""
@members = []
@members = @course.members.where("course_group_id = 0").joins("join user_extensions on members.user_id = user_extensions.user_id").order("student_id asc").select{|m| m.roles.to_s.include?("Student")}
if q.nil? || q == ""
@course.members.includes(:user =>[:user_extensions =>[]]).where("course_group_id = 0").each do |m|
if m && m.user && m.user.join_in?(@course)
@members << m
end
end
else
@course.members.includes(:user =>[:user_extensions =>[]]).where("course_group_id = 0").each do |m|
members = []
@members.each do |m|
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
if m && m.user && m.user.join_in?(@course) && (m.user[:login].to_s.downcase.include?(q) || m.user.user_extensions[:student_id].to_s.downcase.include?(q) || username.include?(q))
@members << m
if m && m.user && (m.user[:login].to_s.downcase.include?(q) || m.user.user_extensions[:student_id].to_s.downcase.include?(q) || username.include?(q))
members << m
end
end
@members = members
end
@is_search = params[:is_search] ? 1 : 0
respond_to do |format|
@ -402,6 +401,7 @@ class CoursesController < ApplicationController
@is_remote = true
@sort_type = 'score'
@score_sort_by = "desc"
@search_name = ""
if params[:group_id] && params[:group_id] != "0" && params[:group_id] != "-1"
@group = CourseGroup.find(params[:group_id])
@results = student_homework_score(@group.id,0, 0,"desc")
@ -455,6 +455,7 @@ class CoursesController < ApplicationController
@is_remote = true
@course_groups = @course.course_groups if @course.course_groups
@show_serch = params[:role] == '2'
@search_name = ""
case @role
when '1'
@subPage_title = l :label_teacher_list
@ -490,14 +491,18 @@ class CoursesController < ApplicationController
end
def export_course_member_excel
if params[:group_id]
q = "#{params[:name].strip}"
if params[:group_id] && params[:group_id] != "0" && params[:group_id] != "-1"
group = CourseGroup.find params[:group_id]
unless group.nil?
@all_members = student_homework_score(group.id,0,0,"desc")
@all_members = searchmember_by_name(student_homework_score(group.id,0,0,"desc"), q)
end
elsif params[:group_id] && params[:group_id] == "-1"
@all_members = searchmember_by_name(student_homework_score(-1, 0, 10,"desc"), q)
else
@all_members = student_homework_score(0,0,0,"desc")
@all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q)
end
@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc")
filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}";
@ -654,6 +659,7 @@ class CoursesController < ApplicationController
course_status.destroy if course_status
course_status = CourseStatus.create(:course_id => @course.id, :grade => 0)
end
@syllabus = @course.syllabus
respond_to do |format|
format.js
end

View File

@ -89,7 +89,7 @@ class HomeworkCommonController < ApplicationController
end
homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
param_end_time = Time.parse(params[:homework_common][:end_time]).strftime("%Y-%m-%d")
homework_end_time = Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d")
homework_end_time = @homework.end_time ? Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") : ''
if homework_end_time != param_end_time
if homework_end_time > param_end_time
@homework.student_works.where("work_status = 1").each do |st|
@ -172,7 +172,7 @@ class HomeworkCommonController < ApplicationController
end
#分组作业
if @homework.homework_type == 3
if @homework.homework_type == 3 && @homework.student_works.has_committed.count == 0
@homework.homework_detail_group ||= HomeworkDetailGroup.new
@homework_detail_group = @homework.homework_detail_group
@homework_detail_group.min_num = params[:min_num].to_i if params[:min_num]
@ -180,6 +180,12 @@ class HomeworkCommonController < ApplicationController
@homework_detail_group.base_on_project = params[:base_on_project] ? 1 : 0
end
if anonymous != @homework.anonymous_comment
@homework.student_works.where("work_status != 0").each do |student_work|
student_work.save
end
end
@homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 1
if @homework.save
homework_detail_manual.save if homework_detail_manual
@ -192,11 +198,11 @@ class HomeworkCommonController < ApplicationController
@hw_status = params[:hw_status].to_i
if params[:is_manage] == "1"
redirect_to manage_or_receive_homeworks_user_path(User.current.id)
redirect_to user_manage_homeworks_user_path(User.current.id)
elsif params[:is_manage] == "2"
redirect_to my_homeworks_user_path(User.current.id)
redirect_to user_receive_homeworks_user_path(User.current.id)
elsif @hw_status == 1
redirect_to user_path(User.current.id)
redirect_to user_course_community_path(User.current.id)
elsif @hw_status == 2
redirect_to course_path(@course.id)
elsif @hw_status == 5

View File

@ -345,7 +345,7 @@ class MessagesController < ApplicationController
elsif @message.parent
redirect_to board_message_url(@board, @message.parent, :r => r)
else
redirect_to course_boards_path(@course)
redirect_to course_boards_path(@course, :board_id => @board.id)
end
elsif @contest
if params[:is_course] && params[:is_course].to_i == 0
@ -357,7 +357,7 @@ class MessagesController < ApplicationController
elsif @message.parent
redirect_to board_message_url(@board, @message.parent, :r => r)
else
redirect_to contest_boards_path(@contest)
redirect_to contest_boards_path(@contest, :board_id => @board.id)
end
elsif @org_subfield
if params[:is_board]

View File

@ -93,6 +93,9 @@ class MyController < ApplicationController
if params[:course]
@course = Course.find params[:course]
diskfile = disk_filename('Course', @course.id)
elsif params[:contest]
@contest = Contest.find params[:contest]
diskfile = disk_filename('Contest', @contest.id)
elsif params[:project]
@project = Project.find params[:project]
diskfile = disk_filename('Project', @project.id)
@ -116,6 +119,9 @@ class MyController < ApplicationController
when 'Course'
@course = Course.find params[:source_id]
diskfile = disk_filename('Course', @course.id)
when 'Contest'
@contest = Contest.find params[:source_id]
diskfile = disk_filename('Contest', @contest.id)
when 'Project'
@project = Project.find params[:source_id]
diskfile = disk_filename('Project', @project.id)

View File

@ -51,7 +51,12 @@ class OrgSubfieldsController < ApplicationController
@organization = Organization.find(params[:id])
else
domain = Secdomain.where("subname=?", request.subdomain).first
@organization = Organization.find(domain.pid)
begin
@organization = Organization.find(domain.pid)
rescue
render_404
return
end
end
if @organization.is_public? or User.current.admin? or User.current.member_of_org?(@organization)
@org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+

View File

@ -28,7 +28,8 @@ class ProjectsController < ApplicationController
menu_item :feedback, :only => :feedback
menu_item :share, :only => :share
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project]
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,
:view_homework_attaches,:join_project, :project_home]
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
before_filter :require_admin, :only => [ :copy, :unarchive, :destroy, :calendar]
@ -72,6 +73,22 @@ class ProjectsController < ApplicationController
### added by william
include ActsAsTaggableOn::TagsHelper
# 仅仅为了转换Gitlab地址
def project_home
rep = params[:rep]
login = params[:username]
begin
user = User.find_by_login(login)
project = Project.find_by_sql("SELECT projects.* FROM `repositories`,`projects` where repositories.project_id = projects.id and projects.user_id =#{user.try(:id)} and repositories.identifier='#{rep}'").first
respond_to do |format|
format.html{redirect_to(:controller => 'repositories', :action => 'show', :id => project.id, :repository_id => rep)}
end
rescue
render_404
return
end
end
#查找组织
def search_public_orgs_not_in_project
condition = '%%'

View File

@ -157,6 +157,9 @@ class PullRequestsController < ApplicationController
def show
# compare_pull_request source_project, source_branch, target_project, target_branch
# compare_pull_request
# 如何从个人主页点击进入,则将该消息设为“已读”
ForgeMessage.where(:forge_message_id => params[:id], :forge_message_type => "PullRequest", :user_id => User.current.id, :viewed => false).update_all(:viewed => true)
@project_menu_type = 6
@type = params[:type]
@request = @g.merge_request(@project.gpid, params[:id])
@ -189,9 +192,13 @@ class PullRequestsController < ApplicationController
def accept_pull_request
begin
@status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
user = User.find_by_login(@status.author.try(:username))
# 更新管理员的pullrequest消息
update_pullrequest_message(params[:id].to_i, @project.id, "PullRequest", 2)
# 接受后,给用户发消息
send_message_to_author(@project.id, @status.author.try(:username), params[:id], 2)
if ForgeMessage.where(:forge_message_id => params[:id].to_i, :project_id => @project.id, :forge_message_type => "PullRequest", :user_id => user.id).count == 0
send_message_to_author(@project.id, @status.author.try(:username), params[:id], 2)
end
respond_to do |format|
format.js{redirect_to project_pull_request_path(@status.id, :project_id => @project.id)}
end
@ -225,8 +232,10 @@ class PullRequestsController < ApplicationController
request = @g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state])
user = User.find_by_login(request.author.try(:username))
status = params[:state] == "close" ? 4 : 3
send_message_to_manager(@project.id, params[:id], status)
if is_project_manager?(User.current.id, @project.id)
#send_message_to_manager(@project.id, params[:id], status)
update_pullrequest_message(request.id, @project.id, "PullRequest", status)
# 给作者发送消息,如何已经发送了消息,则不发
if is_project_manager?(User.current.id, @project.id) && ForgeMessage.where(:forge_message_id => request.id, :project_id => @project.id, :forge_message_type => "PullRequest", :user_id => user.id).count == 0
send_message_to_author(@project.id, user.login, request.id, status)
end
respond_to do |format|
@ -360,12 +369,21 @@ class PullRequestsController < ApplicationController
:project_id => project_id,
:forge_message_id => pull_request_id,
:forge_message_type => "PullRequest",
:viewed => true,
:viewed => false,
:status => status,
:operate_user_id => User.current.id,
)
end
def update_pullrequest_message forge_message_id, project_id, forge_message_type, status
# 更新这条pullrequest消息所有相关的信息
ForgeMessage.where(:forge_message_id => forge_message_id, :project_id => project_id, :forge_message_type => forge_message_type).update_all(:status => status, :operate_user_id => User.current.id, :updated_at => Time.now)
# 更新自己的消息为已读
ForgeMessage.where(:forge_message_id => forge_message_id, :project_id => project_id, :forge_message_type => forge_message_type, :user_id => User.current.id).update_all(:viewed => true)
# 更新pullrequest的status字段
PullRequest.where(:pull_request_id => forge_message_id).update_all(:status => status)
end
def authorize_logged
if !User.current.logged?
redirect_to signin_path

View File

@ -6,7 +6,7 @@ class QualityAnalysisController < ApplicationController
layout "base_projects"
include ApplicationHelper
include QualityAnalysisHelper
require 'jenkins_api_client'
# require 'jenkins_api_client'
require 'nokogiri'
require 'json'
require 'open-uri'
@ -230,7 +230,7 @@ class QualityAnalysisController < ApplicationController
# resource_id: login + @repository.id
def index
# 顶部导
# 顶部导
@project_menu_type = 5
begin

View File

@ -407,7 +407,8 @@ update
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
else
unless @entries.blank?
@changesets_latest_coimmit = @g.commit(@project.gpid, @entries.first.try(:lastrev))
@changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
# @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
# 总的提交数
@changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count
# 获取默认分支
@ -497,7 +498,8 @@ update
entry_and_raw(false)
@content = @repository.cat(@path, @rev)
@changesets_latest_coimmit = @g.commit(@project.gpid, @entry.try(:lastrev))
# @changesets_latest_coimmit = @g.commit(@project.gpid, @entry.try(:lastrev))
@changesets_latest_coimmit = @g.rep_last_changes(@project.gpid, :rev => @rev, :path => @path)
# 总的提交数
@changesets_all_count = @g.user_static(@project.gpid, :rev => @rev).count
if is_entry_text_data?(@content, @path)

View File

@ -8,7 +8,7 @@ class StudentWorkController < ApplicationController
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,
:set_score_rule,:forbidden_anonymous_comment,:delete_work,: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 :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work, :retry_work, :revise_attachment, :hide_score_detail]
before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment]
@ -778,7 +778,7 @@ class StudentWorkController < ApplicationController
end
end
end
redirect_to student_homeworks_user_path(User.current.id)
redirect_to student_work_index_path(:homework => @homework.id)
end
def retry_work
@ -868,8 +868,12 @@ class StudentWorkController < ApplicationController
end
when 2 #教辅评分 教辅评分显示平均分
#@work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f
if @homework.homework_detail_manual.ta_mode == 1
ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f
else
@work.teaching_asistant_score = @new_score.score
end
if @is_group_leader && params[:same_score]
add_score_to_member @work, @homework, @new_score
end
@ -946,6 +950,19 @@ class StudentWorkController < ApplicationController
end
end
def hide_score_detail
student_work_score = StudentWorksScore.where(:id => params[:score_id]).first
if student_work_score
student_work_score.update_attributes(:is_hidden => 1)
end
@is_member_work = @homework.homework_type == 3 && @work.student_work_projects.empty?
@student_work_scores = student_work_score_record(@work)
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
respond_to do |format|
format.js
end
end
#缺评列表显示
def student_work_absence_penalty
order = params[:order] || "desc"
@ -1072,6 +1089,24 @@ class StudentWorkController < ApplicationController
homework_detail_manual.save if homework_detail_manual
end
if params[:ta_mode] && homework_detail_manual.ta_mode.to_i != params[:ta_mode].to_i
homework_detail_manual.ta_mode = params[:ta_mode].to_i
homework_detail_manual.save
if homework_detail_manual.ta_mode == 1
@homework.student_works.where("work_status != 0").each do |student_work|
ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{student_work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
student_work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f
student_work.save
end
else
@homework.student_works.where("work_status != 0").each do |student_work|
ts_score = StudentWorksScore.where("student_work_id = #{student_work.id} AND reviewer_role = 2 AND score IS NOT NULL").order("created_at DESC")
student_work.teaching_asistant_score = ts_score.first.nil? ? nil : ts_score.first.score
student_work.save
end
end
end
teacher_priority = params[:teacher_priority].to_i
if homework_detail_manual.ta_proportion.to_s != params[:ta_proportion].to_s || @homework.teacher_priority.to_s != teacher_priority.to_s || (homework_detail_programing && homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s)
homework_detail_manual.ta_proportion = params[:ta_proportion]

View File

@ -36,7 +36,7 @@ class UsersController < ApplicationController
#
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :unsolved_issues_list, :unfinished_homework_list, :user_manage_homeworks,
:unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :update_message_viewed,
:anonymous_evaluation_list,:unfinished_test_list, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :user_receive_homeworks,
: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_contestlist, :user_manage_issues, :user_receive_issues,
@ -44,6 +44,7 @@ class UsersController < ApplicationController
: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, :contest_community]
before_filter :auth_user_extension, only: :show
before_filter :show_system_message, :only => [:show]
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx
@ -151,96 +152,98 @@ class UsersController < ApplicationController
end
# 我发布的issue
def user_manage_issues
@manage_issues = "我发布的Issue"
# 排序(默认以更新时间降序)
order = "updated_on desc"
if params[:reorder_release_time]
order = "created_on #{params[:reorder_release_time]}"
elsif params[:reorder_turnover_time]
order = "updated_on #{params[:reorder_turnover_time]}"
end
def user_manage_issues
@manage_issues = "我发布的Issue"
# 排序(默认以更新时间降序)
order = "updated_on desc"
if params[:reorder_release_time]
order = "created_on #{params[:reorder_release_time]}"
elsif params[:reorder_turnover_time]
order = "updated_on #{params[:reorder_turnover_time]}"
end
@subject = params[:subject]
params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i
params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i
params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id]
if @project_id.nil?
@issues = Issue.where("author_id =? and subject like ?",
@user.id, "%#{@subject}%").order(order)
else
@issues = Issue.where("author_id =? and project_id=? and subject like ?",
@user.id, @project_id, "%#{@subject}%").order(order)
end
@issues_filter = Issue.where("author_id =?", @user.id).order('updated_on desc')
@issue_open_count = Issue.where(:author_id => @user.id, :status_id => [1, 2, 3, 4, 6]).count
@issue_close_count = Issue.where(:author_id => @user.id, :status_id => 5).count
@subject = params[:subject]
params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i
params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i
params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id]
if @project_id.nil?
@issues = Issue.where("author_id =? and subject like ?",
@user.id, "%#{@subject}%").order(order)
else
@issues = Issue.where("author_id =? and project_id=? and subject like ?",
@user.id, @project_id, "%#{@subject}%").order(order)
end
@issues_filter = Issue.where("author_id =?", @user.id)
@issue_open_count = @issues_filter.where(:status_id => [1, 2, 3, 4, 6]).count
@issue_close_count = @issues_filter.where(:status_id => 5).count
# @issue_open_count = Issue.where(:author_id => @user.id, :status_id => [1, 2, 3, 4, 6]).count
# @issue_close_count = Issue.where(:author_id => @user.id, :status_id => 5).count
# 导出excel的issues
@excel_issues = @issues
@issue_count = @issues.count
@limit = 10
@is_remote = true
@issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1
@offset ||= @issue_pages.offset
@issues = paginateHelper @issues, @limit
# @issues.limit(@issue_pages.per_page).offset(@issue_pages.offset).reorder(order).all
respond_to do |format|
format.html{render :layout => 'static_base'}
format.xls{
filename = "我发布的_#{l(:label_issue_list_xls)}.xls"
send_data(issue_list_xls(@excel_issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
format.api
format.js
# 导出excel的issues
@excel_issues = @issues
@issue_count = @issues.count
@limit = 10
@is_remote = true
@issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1
@offset ||= @issue_pages.offset
@issues = paginateHelper @issues, @limit
# @issues.limit(@issue_pages.per_page).offset(@issue_pages.offset).reorder(order).all
respond_to do |format|
format.html{render :layout => 'static_base'}
format.xls{
filename = "我发布的_#{l(:label_issue_list_xls)}.xls"
send_data(issue_list_xls(@excel_issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
format.api
format.js
end
end
end
# 我收到的issue
def user_receive_issues
@receive_issues = "我收到的Issue"
# 排序(默认以更新时间降序)
order = "updated_on desc"
if params[:reorder_release_time]
order = "created_on #{params[:reorder_release_time]}"
elsif params[:reorder_turnover_time]
order = "updated_on #{params[:reorder_turnover_time]}"
end
def user_receive_issues
@receive_issues = "我收到的Issue"
# 排序(默认以更新时间降序)
order = "updated_on desc"
if params[:reorder_release_time]
order = "created_on #{params[:reorder_release_time]}"
elsif params[:reorder_turnover_time]
order = "updated_on #{params[:reorder_turnover_time]}"
end
@subject = params[:subject]
params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i
params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i
params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id]
if @project_id.nil?
@issues = Issue.where("assigned_to_id =? and subject like ?",
@user.id, "%#{@subject}%").order(order)
else
@issues = Issue.where("assigned_to_id =? and project_id=? and subject like ?",
@user.id, @project_id, "%#{@subject}%").order(order)
end
@issues_filter = Issue.where("assigned_to_id =?", @user.id).order('updated_on desc')
@issue_open_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 3, 4, 6]).count
@issue_close_count = Issue.where(:assigned_to_id => @user.id, :status_id => 5).count
@subject = params[:subject]
params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i
params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i
params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id]
if @project_id.nil?
@issues = Issue.where("assigned_to_id =? and subject like ?",
@user.id, "%#{@subject}%").order(order)
else
@issues = Issue.where("assigned_to_id =? and project_id=? and subject like ?",
@user.id, @project_id, "%#{@subject}%").order(order)
end
@issues_filter = Issue.where("assigned_to_id =?", @user.id)
@issue_open_count = @issues_filter.where(:status_id => [1, 2, 3, 4, 6]).count
@issue_close_count = @issues_filter.where(:status_id => 5).count
# 导出excel的issues
@excel_issues = @issues
@issue_count = @issues.count
@limit = 10
@is_remote = true
@issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1
@offset ||= @issue_pages.offset
@issues = paginateHelper @issues, @limit
# @issues.limit(@issue_pages.per_page).offset(@issue_pages.offset).reorder(order).all
respond_to do |format|
format.html{render :layout => 'static_base'}
format.xls{
filename = "我发布的_#{l(:label_issue_list_xls)}.xls"
send_data(issue_list_xls(@excel_issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
format.api
format.js
# 导出excel的issues
@excel_issues = @issues
@issue_count = @issues.count
@limit = 10
@is_remote = true
@issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1
@offset ||= @issue_pages.offset
@issues = paginateHelper @issues, @limit
# @issues.limit(@issue_pages.per_page).offset(@issue_pages.offset).reorder(order).all
respond_to do |format|
format.html{render :layout => 'static_base'}
format.xls{
filename = "我发布的_#{l(:label_issue_list_xls)}.xls"
send_data(issue_list_xls(@excel_issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
format.api
format.js
end
end
end
#展开所有回复
def show_all_replies
@ -388,6 +391,16 @@ end
comment.reply_id = params[:reply_id]
comment.root_id = reply.root_id
reply.children << comment
# 评论后,给回复人发消息(如果是本人就不发)
if comment.author.id != BlogComment.find(comment.reply_id).author_id
BlogMessage.create(:user_id => BlogComment.find(comment.reply_id).author_id,
:blog_commont_id => comment.id,
:blog_id => comment.blog_id,
:blog_message_type => "BlogComment",
:content => comment.content,
:user_operator_id => comment.author.id
)
end
when 'OrgDocumentComment'
@root = reply.root
comment = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:reply_id])
@ -476,9 +489,9 @@ end
# 初始化/更新 点击按钮时间, 24小时内显示系统消息
update_onclick_time
# 全部设为已读
if params[:viewed] == "all"
update_message_viewed(@user)
end
# if params[:viewed] == "all"
# update_message_viewed(@user)
# end
# @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count
courses = @user.courses.where("is_delete = 1")
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
@ -486,7 +499,7 @@ end
when nil
# 系统消息为管理员发送,我的消息中包含有系统消息
@message_alls = []
messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc")
messages = MessageAll.where(:user_id => @user.id).includes(:message).order("created_at desc")
messages.each do |message_all|
mess = message_all.message
unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1)
@ -558,21 +571,28 @@ end
end
# 消息设置为已读
def update_message_viewed(user)
def update_message_viewed
if User.current.id == @user.id
course_querys = CourseMessage.where("user_id =? and viewed =?", user, 0)
forge_querys = ForgeMessage.where("user_id =? and viewed =?", user, 0)
user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0)
forum_querys = MemoMessage.where("user_id =? and viewed =?", user, 0)
org_querys = OrgMessage.where("user_id=? and viewed=0", user)
at_querys = AtMessage.where("user_id=? and viewed=0", user)
course_querys.update_all(:viewed => true) unless course_querys.nil?
forge_querys.update_all(:viewed => true) unless forge_querys.nil?
user_querys.update_all(:viewed => true) unless user_querys.nil?
forum_querys.update_all(:viewed => true) unless forum_querys.nil?
org_querys.update_all(:viewed => true) unless org_querys.nil?
at_querys.update_all(:viewed => true) unless at_querys.nil?
course_querys = CourseMessage.where("user_id =? and viewed =?", @user.id, 0)
forge_querys = ForgeMessage.where("user_id =? and viewed =?", @user.id, 0)
user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", @user.id, 0)
forum_querys = MemoMessage.where("user_id =? and viewed =?", @user.id, 0)
org_querys = OrgMessage.where("user_id=? and viewed=0", @user.id)
at_querys = AtMessage.where("user_id=? and viewed=0", @user.id)
contest_querys = ContestMessage.where(:user_id => @user.id, :viewed => 0)
blog_querys = BlogMessage.where(:user_id => @user.id, :viewed => 0)
applied_querys = AppliedMessage.where("user_id=? and viewed =?", @user.id, 0)
course_querys.update_all(:viewed => true) unless course_querys.nil?
forge_querys.update_all(:viewed => true) unless forge_querys.nil?
user_querys.update_all(:viewed => true) unless user_querys.nil?
forum_querys.update_all(:viewed => true) unless forum_querys.nil?
org_querys.update_all(:viewed => true) unless org_querys.nil?
at_querys.update_all(:viewed => true) unless at_querys.nil?
contest_querys.update_all(:viewed => true) unless contest_querys.nil?
blog_querys.update_all(:viewed => true) unless blog_querys.nil?
applied_querys.update_all(:viewed => true) unless applied_querys.nil?
end
redirect_to user_path(@user)
end
# 系统消息
@ -1913,11 +1933,11 @@ end
if params[:property]
all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")"
if params[:property] == "1"
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1")
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1 order by created_at desc")
elsif params[:property] == "2"
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2")
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2 order by created_at desc")
elsif params[:property] == "3"
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3")
@homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3 order by created_at desc")
end
end
@limit = 10
@ -1990,26 +2010,22 @@ end
end
def show
if is_current_user
if User.current == @user
# 全部设为已读
# 自己的主页显示消息
# 系统消息为管理员发送,我的消息中包含有系统消息
@message_alls = []
messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" , @user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc")
messages.each do |message_all|
mess = message_all.message
unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1)
if (message_all.message_type =="SystemMessage" && !many_days_ago(mess.created_at, 30))
next
else
@message_alls << mess
end
end
end
@message_count = @message_alls.count
@message_alls = paginateHelper @message_alls, 20
messages_all = MessageAll.where(:user_id => @user.id)
@message_count = messages_all.count
# REDO:已删除的内容应该在页面中显示不点击
@message_all_pages = Paginator.new @message_count, per_page_option, params['page']
@message_alls = messages_all.includes(:message).
limit(@message_all_pages.per_page).
offset(@message_all_pages.offset).
reorder("#{MessageAll.table_name}.created_at desc")
@unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).count
# 用户待完成的作业
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).
where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'")
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0")
@ -2037,7 +2053,9 @@ end
# 待审批的申请
@applied_message_alls = []
applied_messages_all = MessageAll.where(:user_id => @user.id, :message_type => ["OrgMessage", "AppliedMessage", "CourseMessage"]).includes(:message)
OrgMessage
applied_messages_all = MessageAll.where(:user_id => @user.id, :message_type => ["OrgMessage", "AppliedMessage", "CourseMessage", "ForgeMessage"]).includes(:message)
applied_messages_all.each do |message_all|
mess = message_all.message
if !mess.nil?
@ -2053,6 +2071,13 @@ end
if mess.course_message_type == "JoinCourseRequest" && mess.status == 0
@applied_message_alls << mess
end
elsif message_all.message_type == "ForgeMessage"
if mess.forge_message_type == "PullRequest" && PullRequest.where(:pull_request_id => mess.forge_message_id, :status => [1, 3]).count > 0 && PullRequest.where(:pull_request_id => mess.forge_message_id).first.user_id != User.current.id
user_id = PullRequest.where(:pull_request_id => mess.forge_message_id, :status => [1, 3]).first.id
if ForgeMessage.where("status in (1,3) and user_id != #{user_id} and pull_request_id = #{mess.forge_message_id}")
@applied_message_alls << mess
end
end
end
end
end
@ -2248,7 +2273,7 @@ end
def unapproval_applied_list
@message_alls = []
# messages_all = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc")
messages_all = MessageAll.where(:user_id => @user.id, :message_type => ["OrgMessage", "AppliedMessage", "CourseMessage"]).includes(:message).order("created_at desc")
messages_all = MessageAll.where(:user_id => @user.id, :message_type => ["OrgMessage", "AppliedMessage", "CourseMessage", "ForgeMessage"]).includes(:message).order("created_at desc")
messages_all.each do |message_all|
mess = message_all.message
if !mess.nil?
@ -2262,14 +2287,15 @@ end
end
elsif message_all.message_type == "CourseMessage"
if mess.course_message_type == "JoinCourseRequest" && mess.status == 0
@message_alls << mess
end
=begin
elsif message_all.message_type == "ForgeMessage"
if mess.forge_message_type == "PullRequest" && PullRequest.where(:forge_message_id => mess.forge_message_id, :status =>0 )
@message_alls << mess
end
=end
elsif message_all.message_type == "ForgeMessage"
if mess.forge_message_type == "PullRequest" && PullRequest.where(:pull_request_id => mess.forge_message_id, :status => [1, 3]).count > 0 && PullRequest.where(:pull_request_id => mess.forge_message_id).first.user_id != User.current.id
user_id = PullRequest.where(:pull_request_id => mess.forge_message_id, :status => [1, 3]).first.id
if ForgeMessage.where("status in (1,3) and user_id != #{user_id} and pull_request_id = #{mess.forge_message_id}")
@message_alls << mess
end
end
end
end
end
@ -2280,7 +2306,7 @@ end
end
end
# 课程社区
# 课程社区
def course_community
@course_community = "课程"
if params[:course_id] != nil
@ -2349,7 +2375,7 @@ end
end
end
# 项目社区
# 项目社区
def project_community
# 看别人的主页显示动态
#更新用户申请成为课程老师或教辅消息的状态
@ -2402,7 +2428,7 @@ end
end
end
# 竞赛社区
# 竞赛社区
def contest_community
@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)
@ -2604,7 +2630,7 @@ end
end
#Modified by nie
#Modified by nie
unless User.current.admin?
if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?)
# redirect_to home_path
@ -2619,9 +2645,9 @@ end
end
end
##end fq
##end fq
#### added by fq
#### added by fq
def info
message = []
@ -2650,7 +2676,7 @@ end
format.api
end
end
#### end
#### end
def new
@ -2764,7 +2790,7 @@ end
end
end
# 上传用户资源
# 上传用户资源
def user_resource_create
user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id}
user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id }
@ -2819,7 +2845,7 @@ end
end
end
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
def user_resource_delete
if params[:resource_id].present?
Attachment.where("author_id =? and id =?", User.current.id, params[:resource_id]).first.destroy
@ -2877,7 +2903,7 @@ end
end
end
#根据id或者名称搜索教师或者助教为当前用户的课程
#根据id或者名称搜索教师或者助教为当前用户的课程
def search_user_course
@user = User.current
if !params[:search].nil?
@ -2897,7 +2923,7 @@ end
end
end
# 根据id或者名称搜索当前用户所在的项目
# 根据id或者名称搜索当前用户所在的项目
def search_user_project
@user = User.current
if !params[:search].nil?
@ -2917,7 +2943,7 @@ end
end
end
# 将资源发送到对应的课程,分为发送单个,或者批量发送
# 将资源发送到对应的课程,分为发送单个,或者批量发送
def add_exist_file_to_course
@flag = true
if params[:send_id].present?
@ -3028,7 +3054,7 @@ end
end
end
# 添加资源到对应的项目
# 添加资源到对应的项目
def add_exist_file_to_project
@flag = true
# 发送单个资源
@ -3448,7 +3474,7 @@ end
end
# 资源预览
# 资源预览
def resource_preview
preview_id = params[:resource_id]
@file = Attachment.find(preview_id)
@ -3461,7 +3487,7 @@ end
end
end
# 重命名资源
# 重命名资源
def rename_resource
@attachment = Attachment.find(params[:res_id]) if params[:res_id].present?
if @attachment != nil
@ -3506,7 +3532,7 @@ end
end
end
################# added by william
################# added by william
def tag_save
@tags = params[:tag_for_save][:name]
@obj_id = params[:tag_for_save][:object_id]
@ -3592,7 +3618,7 @@ end
format.html
end
end
###add by huang
###add by huang
def user_watchlist
limit = 10;
query = User.watched_by(@user.id);
@ -3602,7 +3628,7 @@ end
@action = 'watch'
render :template=>'users/user_fanslist',:layout=>'new_base_user'
end
###add by huang
###add by huang
def user_fanslist
limit = 10;
query = @user.watcher_users;
@ -3624,7 +3650,7 @@ end
render :template=>'users/user_fanslist',:layout=>'base_users_new'
end
#william
#william
def update_extensions(user_extensions)
user_extensions = params[:user_extensions]
unless user_extensions.nil?
@ -3638,7 +3664,7 @@ end
@user = User.find(params[:id])
end
#修改个人简介
#修改个人简介
def edit_brief_introduction
if @user && @user.extensions
@user.extensions.update_column("brief_introduction",params[:brief_introduction])
@ -3648,133 +3674,133 @@ end
end
end
# 获取公共资源
# 获取公共资源
def get_public_resources user_course_ids, user_project_ids, order, score
attachments = Attachment.where("(is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源搜索
# 获取公共资源搜索
def get_public_resources_search user_course_ids, user_project_ids, order, score, search
attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的资源
# 获取我的资源
def get_my_resources author_id, user_course_ids, user_project_ids, order, score
attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('OrgSubfield','Principal','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的资源查询结果
# 获取我的资源查询结果
def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search)
@attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的课程资源
# 获取我的课程资源
def get_course_resources author_id, user_course_ids, order, score
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and container_type = 'Course')"+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# # 获取我的私有资源分享结果
# def get_my_private_resources apply_ids, resource_type, order, score
# attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type})").order("#{order.nil? ? 'created_on' : order} #{score}")
# end
#
# # 获取我的私有资源分享搜索结果
# def get_my_private_resources_search apply_ids, resource_type, order, score, search
# attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type}) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
# end
# # 获取我的私有资源分享结果
# def get_my_private_resources apply_ids, resource_type, order, score
# attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type})").order("#{order.nil? ? 'created_on' : order} #{score}")
# end
#
# # 获取我的私有资源分享搜索结果
# def get_my_private_resources_search apply_ids, resource_type, order, score, search
# attachments = Attachment.where("id in (#{apply_ids.empty? ? '0': apply_ids.join(',')}) and container_type in(#{resource_type}) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
# end
# 获取我的课程资源中搜索结果
# 获取我的课程资源中搜索结果
def get_course_resources_search author_id, user_course_ids, order, score, search
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源中课程资源
# 获取公共资源中课程资源
def get_course_resources_public user_course_ids, order, score
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源中课程资源搜索结果
# 获取公共资源中课程资源搜索结果
def get_course_resources_public_search user_course_ids, order, score, search
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的项目资源
# 获取我的项目资源
def get_project_resources author_id, user_project_ids, order, score
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的项目资源搜索
# 获取我的项目资源搜索
def get_project_resources_search author_id, user_project_ids, order, score, search
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源的项目资源
# 获取公共资源的项目资源
def get_project_resources_public user_project_ids, order, score
attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源的项目资源搜索
# 获取公共资源的项目资源搜索
def get_project_resources_public_search user_project_ids, order, score, search
attchments = Attachment.where("(container_type = 'Project' and container_id is not null and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我上传的附件
# 获取我上传的附件
def get_attch_resources author_id, order, score
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我上传的附件搜索结果
# 获取我上传的附件搜索结果
def get_attch_resources_search author_id, order, score, search
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源中我上传的附件
# 获取公共资源中我上传的附件
def get_attch_resources_public order, score
attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源中我上传的附件
# 获取公共资源中我上传的附件
def get_attch_resources_public_search order, score, search
attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的用户类型资源
# 获取我的用户类型资源
def get_principal_resources author_id, order, score
attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的用户类型资源搜索
# 获取我的用户类型资源搜索
def get_principal_resources_search author_id, order, score, search
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的用户类型资源
# 获取我的用户类型资源
def get_principal_resources_public order, score
attchments = Attachment.where("container_type = 'Principal' and is_public =1 and container_id is not null").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的用户类型资源
# 获取我的用户类型资源
def get_principal_resources_public_search order, score, search
attchments = Attachment.where("(container_type = 'Principal'and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 资源库 分为全部 课程资源 项目资源 附件
# 资源库 分为全部 课程资源 项目资源 附件
def user_resource
# 别人的资源库是没有权限去看的
if User.current.id.to_i != @user.id.to_i
@ -3841,7 +3867,7 @@ end
end
end
# 导入资源
# 导入资源
def import_resources
@resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id]
@resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"
@ -3904,7 +3930,7 @@ end
end
end
# 内容导入到对象中
# 内容导入到对象中
def import_into_container
send_ids = params[:checkbox1]
# mul_id为当前课程id、项目id、组织id的多种形态
@ -3961,7 +3987,7 @@ end
end
end
# 根据资源关键字进行搜索
# 根据资源关键字进行搜索
def resource_search
@order, @b_sort = params[:order] || "created_on", params[:sort] || "desc"
@score = @b_sort == "desc" ? "asc" : "desc"
@ -4109,7 +4135,7 @@ end
end
end
#课程列表的排序
#课程列表的排序
def sort_syllabus_list
@order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1
@ -4155,7 +4181,7 @@ end
end
end
#归档班级列表
# 归档班级列表
def user_archive_courses
if User.current.logged?
@order, @c_sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
@ -4193,12 +4219,12 @@ end
end
respond_to do |format|
format.js
format.html {render :layout => 'new_base_user'}
format.html {render :layout => 'base_course_community'}
end
end
end
#展开课程下的班级
# 展开课程下的班级
def expand_courses
@syllabus = Syllabus.where("id = #{params[:syllabus_id]}").first
unless @syllabus.nil?
@ -4213,7 +4239,7 @@ end
end
end
#收藏班级/项目/竞赛
# 收藏班级/项目/竞赛
def cancel_or_collect
if params[:project]
@project = Project.find params[:project]
@ -4382,6 +4408,10 @@ end
end
private
def show_system_message
# 系统消息总显示在最前面,显示周期30天
@system_messages = SystemMessage.where("created_at > ?", Time.now - 86400 * 30)
end
def find_user
if params[:id] == 'current'

View File

@ -109,6 +109,19 @@ class WordsController < ApplicationController
end
return
end
elsif @journal_destroyed.jour_type == "Contest"
@contest = Contest.find(@journal_destroyed.jour_id)
@jours_count = @contest.journals_for_messages.where('m_parent_id IS NULL').count
@user_activity_id = params[:user_activity_id] if params[:user_activity_id]
@activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id]
unless @activity
if params[:user_activity_id] == params[:activity_id]
redirect_to feedback_contest_path(@contest)
else
redirect_to contest_activities_contest_path(@contest)
end
return
end
elsif @journal_destroyed.jour_type == 'HomeworkCommon'
@homework = HomeworkCommon.find @journal_destroyed.jour_id
if params[:user_activity_id]
@ -305,6 +318,18 @@ class WordsController < ApplicationController
end
end
def leave_contest_message
if User.current.logged?
@contest = Contest.find params[:id]
if params[:new_form][:content].size>0 && User.current.logged?
@contest.journals_for_messages << JournalsForMessage.new(:user_id => User.current.id, :notes => params[:new_form][:content], :reply_id => 0, :status => true, :is_readed => false)
end
redirect_to feedback_contest_path(@contest)
else
render_403
end
end
#作业的回复
def leave_homework_message
if User.current.logged?

View File

@ -242,7 +242,8 @@ class WorksController < ApplicationController
def set_score_rule
# 未启动在线评审时才能更改评审参数
if @contestwork.work_status < 3
@contestwork.online_evaluation = params[:online_evaluation] ? 1 : 0
@contestwork.online_evaluation = params[:online_evaluation].to_i ? 1 : 0
@contestwork.save
# 如果开启在线评审
if params[:online_evaluation]
@ -257,11 +258,11 @@ class WorksController < ApplicationController
score_valid = params[:score_valid].to_i == 1 ? true : false
if score_valid != @contestwork.score_valid
@contestwork.score_valid = score_valid
@contestwork.save
@contestwork.contestant_works.has_committed.each do |c_work|
c_work.save
end
end
@contestwork.save
if params[:student_path] && params[:student_path] == "true"
redirect_to contestant_works_path(:work => @contestwork.id)
else

View File

@ -43,10 +43,10 @@ class ZipdownController < ApplicationController
zip_homework_common homework
}
elsif params[:obj_class] == "Work"
homework = Work.find params[:obj_id]
render_403 if User.current.admin_of_contest?(homework.contest)
zipfile = checkfileSize(homework.contestant_works) {
zip_homework_common homework
contest_work = Work.find params[:obj_id]
render_403 if User.current.admin_of_contest?(contest_work.contest)
zipfile = checkfileSize(contest_work.contestant_works) {
zip_contest_work contest_work
}
else
logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!"

View File

@ -1341,6 +1341,8 @@ module ApplicationHelper
title << @contest.name
elsif @organization
title << @organization.name
elsif @forum || params[:controller] == "forums"
title << "问吧"
elsif @user
if !@project_community.blank?
title << @project_community
@ -2904,8 +2906,7 @@ module ApplicationHelper
# 用户竞赛总数
def user_contest_count
count = @user.favorite_contests.visible.where("is_delete =?", 0).count
return count
@user.favorite_contests.visible.where("is_delete =?", 0).count
end
# 用户项目总数
@ -2944,14 +2945,12 @@ module ApplicationHelper
# 用户发布的issue数
def issues_author_is_self_count
@issues = Issue.where( :author_id => @user.id )
@issues_author_is_self_count = @issues.count
Issue.where(:author_id => @user.id).count
end
# 用户收到的issue数
def issues_assigned_is_self_count
@issues = Issue.where( :assigned_to_id => @user.id )
@issues_assigned_is_self_count = @issues.count
Issue.where( :assigned_to_id => @user.id ).count
end
def get_user_roll user
@ -3986,6 +3985,10 @@ def get_cw_status contest_work
end
elsif contest_work.work_status == 2
str += '<span class="red_homework_btn_cir ml5">提交已截止</span>'
elsif contest_work.work_status == 3
str += '<span class="green_homework_btn_cir ml5">在线评审中</span>'
elsif contest_work.work_status == 4
str += '<span class="red_homework_btn_cir ml5">评审已截止</span>'
end
str
end
@ -4008,6 +4011,23 @@ def get_group_member_names work
result
end
def get_contest_group_member_names work
result = ""
unless work.nil?
work.contestant_work_projects.each do |member|
user = User.where(:id => member.user_id).first
unless user.nil?
if result != ""
result += "#{user.show_name}"
else
result += user.show_name
end
end
end
end
result
end
def course_syllabus_option user = User.current
syllabus_members = SyllabusMember.where("user_id = #{user.id}")
syllabus_ids = syllabus_members.empty? ? "(-1)" : "(" + syllabus_members.map{|mem| mem.syllabus_id}.join(',') + ")"
@ -4123,6 +4143,10 @@ def searchstudent_by_name users, name
mems
end
def contest_feedback_count
@contest.journals_for_messages.where('m_parent_id IS NULL').count
end
def add_reply_adapter obj, options
#modify by nwb
#添加对课程留言的支持
@ -4134,6 +4158,8 @@ def add_reply_adapter obj, options
Project.add_new_jour(nil, nil, obj.jour_id, options)
when 'Course'
Course.add_new_jour(nil, nil, obj.jour_id, options)
when 'Contest'
Contest.add_new_jour(nil, nil, obj.jour_id, options)
#when 'Bid'
# obj.jour.add_jour(nil, nil, nil, options)
#when 'Contest'

View File

@ -18,15 +18,14 @@ module ContestantWorksHelper
def set_final_score contestwork, contestant_work
if contestwork.online_evaluation
if contestwork.score_valid
if ContestantWorkScore.find_by_sql("SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id").count < 2
judge_score = ContestantWorkScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
contestant_work.work_score = contestant_work.judge_score
else
if ContestantWorkScore.find_by_sql("SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id").count <= 2
contestant_work.work_score = contestant_work.judge_score
else
judge_score = ContestantWorkScore.find_by_sql("SELECT (SUM(score)-MIN(score)-MAX(score))/(COUNT(score)-2) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
contestant_work.work_score = judge_score.first.score.try(:round, 2).to_f
end
@work.work_score = judge_score.first.score.try(:round, 2).to_f
else
judge_score = ContestantWorkScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
@work.work_score = judge_score.first.score.try(:round, 2).to_f
end
else
contestant_work.work_score = nil
@ -37,8 +36,7 @@ module ContestantWorksHelper
def contestant_work_score_record work
sql = "SELECT MAX(id) id FROM contestant_work_scores WHERE reviewer_role = 2 AND score IS NOT NULL AND contestant_work_id = #{work.id} GROUP BY user_id"
tea_ts_ids = ContestantWorkScore.find_by_sql sql
tea_ts_ids = tea_ts_ids.empty? ? "(-1)" : "(" + tea_ts_ids.map{|tea| tea.id}.join(",") + ")"
scores = work.contestant_work_scores.where("score IS NULL or reviewer_role = 3 or id in #{tea_ts_ids}").order("updated_at desc")
scores = work.contestant_work_scores.where(:id => tea_ts_ids.map{|tea| tea.id}).order("updated_at desc")
return scores
end

View File

@ -76,4 +76,21 @@ module ContestsHelper
end
result
end
def search_member_by_name_login_school members, name
mems = []
if name != ""
name = name.to_s.downcase
school_ids = School.where("name like '%#{name}%'").map{|school| school.id}
members.each do |m|
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
if(m.user[:login].to_s.downcase.include?(name) || school_ids.include?(m.user.user_extensions[:school_id]) || username.include?(name))
mems << m
end
end
else
mems = members
end
mems
end
end

View File

@ -69,12 +69,13 @@ module StudentWorkHelper
str
end
#获取学生作品的评分记录:同一个教师或教辅只显示最后一次评分
#获取学生作品的评分记录:同一个教师或教辅只显示未隐藏的评分
def student_work_score_record work
sql = "SELECT MAX(id) id FROM student_works_scores WHERE (reviewer_role = 2 OR reviewer_role = 1) AND score IS NOT NULL AND student_work_id = #{work.id} GROUP BY user_id"
tea_ts_ids = StudentWorksScore.find_by_sql sql
tea_ts_ids = tea_ts_ids.empty? ? "(-1)" : "(" + tea_ts_ids.map{|tea| tea.id}.join(",") + ")"
scores = work.student_works_scores.where("score IS NULL or reviewer_role = 3 or id in #{tea_ts_ids}").order("updated_at desc")
# sql = "SELECT MAX(id) id FROM student_works_scores WHERE (reviewer_role = 2 OR reviewer_role = 1) AND score IS NOT NULL AND is_hidden = 0 AND student_work_id = #{work.id} GROUP BY user_id"
# tea_ts_ids = StudentWorksScore.find_by_sql sql
# tea_ts_ids = tea_ts_ids.empty? ? "(-1)" : "(" + tea_ts_ids.map{|tea| tea.id}.join(",") + ")"
# scores = work.student_works_scores.where("score IS NULL or reviewer_role = 3 or id in #{tea_ts_ids}").order("updated_at desc")
scores = work.student_works_scores.where(:is_hidden => false).order("created_at desc")
return scores
end

View File

@ -307,7 +307,10 @@ module UsersHelper
user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count
user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count
at_count = user.at_messages.where(viewed: false).count
messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + org_count
contest_count = ContestMessage.where(:user_id => user, :viewed => 0).count
applied_count = AppliedMessage.where("user_id=? and viewed =?", user, 0).count
blog_count = BlogMessage.where(:user_id => user, :viewed => 0).count
messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + org_count + contest_count + blog_count + applied_count
end
def user_mail_notification_options(user)

View File

@ -355,7 +355,7 @@ module WatchersHelper
text = collected == 1 ? l(:label_project_collect_cancel) : l(:label_project_collect)
url = store_mine_project_path(project_id)
method = 'post'
link = link_to(text, url, :remote => true, :method => method, :id => "#{project_id}", :class => "pro_new_topbtn_left fl", :title => "#{collected == 1 ? '点击将其从个人主页的项目列表中移除' : '点击将其添加至人主页的项目列表中'}")
link = link_to(text, url, :remote => true, :method => method, :id => "#{project_id}", :class => "pro_new_topbtn_left fl", :title => "#{collected == 1 ? '点击将其从左侧导航的项目列表中移除' : '点击将其添加至左侧导航的项目列表中'}")
# link.html_safe
end

View File

@ -6,6 +6,7 @@ class BlogComment < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :blog
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :blog_messages, :class_name => 'BlogMessage', :as => :blog_message, :dependent => :destroy
acts_as_tree :counter_cache => :comments_count, :order => "#{BlogComment.table_name}.sticky desc ,#{BlogComment.table_name}.created_on ASC"
acts_as_attachable

View File

@ -0,0 +1,20 @@
class BlogMessage < ActiveRecord::Base
# attr_accessible :title, :body
attr_accessible :content, :blog_commont_id, :blog_message_type, :viewed, :user_id, :blog_id, :user_operator_id
belongs_to :blog_comment ,:polymorphic => true
belongs_to :user
has_many :message_alls, :class_name => 'MessageAll', :as => :message, :dependent => :destroy
validates :user_id, presence: true
validates :blog_id, presence: true
validates :blog_commont_id, presence: true
validates :blog_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.message_alls << MessageAll.new(:user_id => self.user_id)
end
end
end

View File

@ -15,7 +15,8 @@ class Contest < ActiveRecord::Base
has_many :works
has_many :contestant_work_projects, :dependent => :destroy
has_many :boards, :dependent => :destroy, :order => "position ASC"
has_many :files
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
has_many :news, :dependent => :destroy, :include => :author
@ -31,6 +32,10 @@ class Contest < ActiveRecord::Base
scope :visible, lambda {|*args| where(Contest.where("is_delete =?", 0).visible_condition(args.shift || User.current, *args)) }
def contest_judges
self.contest_members.select{|cm| cm.roles.to_s.include?("Judge")}
end
# 删除竞赛所有成员
def delete_all_members
if self.contest_members && self.contest_members.count > 0
@ -126,4 +131,16 @@ class Contest < ActiveRecord::Base
logger.error "[Contest Model] ===> Auto create board when contest saved, because #{@board.full_messages}"
end
end
# 新增竞赛留言
def self.add_new_jour(user, notes, id, options={})
contest = Contest.find(id)
if options.count == 0
pjfm = contest.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0)
else
pjfm = contest.journals_for_messages.build(options)
end
pjfm.save
pjfm
end
end

View File

@ -1,4 +1,7 @@
class ContestMessage < ActiveRecord::Base
# Workstatus
# nil发布了作业 1截止时间到了提醒2:开启在线评审; 3关闭在线评审 4匿评开始失败 5在线评审时间快到了
attr_accessible :content, :contest_message_id, :contest_message_type, :status, :viewed, :user_id, :contest_id
belongs_to :contest_message ,:polymorphic => true

View File

@ -26,6 +26,8 @@ class ContestantWork < ActiveRecord::Base
end
def set_work_score
set_final_score self.work,self
if self.id
set_final_score self.work,self
end
end
end

View File

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

View File

@ -76,7 +76,7 @@ class JournalsForMessage < ActiveRecord::Base
has_one :praise_tread_cache, as: :object, dependent: :destroy
validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_course_activity, :act_as_course_message,
after_create :act_as_course_activity, :act_as_course_message, :act_as_contest_activity,
act_as_at_message(:notes, :user_id), :act_as_user_feedback_message,
:act_as_principal_activity
# after_create :reset_counters!
@ -222,6 +222,13 @@ class JournalsForMessage < ActiveRecord::Base
end
end
#竞赛动态公共表记录
def act_as_contest_activity
if self.jour_type == 'Contest' && self.m_parent_id.nil?
self.contest_acts << ContestActivity.new(:user_id => self.user_id,:contest_id => self.jour_id)
end
end
# 课程/作品回复 留言消息通知
def act_as_course_message
if self.jour_type == 'StudentWorksScore'

View File

@ -1,5 +1,6 @@
class MessageAll < ActiveRecord::Base
attr_accessible :message_id, :message_type, :user_id
belongs_to :user
# 虚拟关联---项目消息表/课程消息表/用户留言消息表/贴吧消息表
belongs_to :message ,:polymorphic => true
end

View File

@ -1,6 +1,6 @@
class PullRequest < ActiveRecord::Base
# status 1创建 2接受 3重新打开 4关闭
attr_accessible :gpid, :pull_request_id, :user_id, :project_id, :title
attr_accessible :gpid, :pull_request_id, :user_id, :project_id, :title, :status
validates_uniqueness_of :pull_request_id
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy

View File

@ -2,7 +2,7 @@
class StudentWorksScore < ActiveRecord::Base
#reviewer_role: 1:教师评分;2:教辅评分;3:学生匿评
#appeal_status: 0正常1申诉中2撤销申诉3申诉成功4申诉被拒绝
attr_accessible :student_work_id, :user_id, :score, :comment, :reviewer_role
attr_accessible :student_work_id, :user_id, :score, :comment, :reviewer_role, :is_hidden
belongs_to :user
belongs_to :student_work

View File

@ -1,3 +1,4 @@
#encoding: utf-8
class StudentsForCourse < ActiveRecord::Base
attr_accessible :course_id, :student_id
@ -9,7 +10,7 @@ class StudentsForCourse < ActiveRecord::Base
validates_uniqueness_of :student_id, :scope => :course_id
after_destroy :delete_student_works
after_create :recovery_student_works
after_create :recovery_student_works, :create_student_works
#退出班级或删除学生时隐藏学生的作品
def delete_student_works
@ -26,4 +27,14 @@ class StudentsForCourse < ActiveRecord::Base
student_works = StudentWork.where("user_id = #{self.student_id} && homework_common_id in #{homework_ids}")
student_works.update_all(:is_delete => 0)
end
#加入班级时创建已发布作业的作品
def create_student_works
course = self.course
course.homework_commons.each do |hw|
if hw.homework_type != 3 && hw.student_works.where("user_id = #{self.student_id}").count == 0
hw.student_works << StudentWork.new(:user_id => self.student_id, :name => hw.name.to_s+"的作品提交", :work_status => 0)
end
end
end
end

View File

@ -114,6 +114,13 @@ class User < Principal
has_many :apply_homeworks, :dependent => :destroy
has_many :apply_resources, :dependent => :destroy
#end
#竞赛
has_many :contests, :dependent => :destroy
has_many :works, :dependent => :destroy
has_many :contestant_works, :dependent => :destroy
has_many :contestant_work_evaluation_distributions, :dependent => :destroy
has_many :contestant_work_scores
has_many :contestant_work_projects
has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)},
:after_remove => Proc.new {|user, group| group.user_removed(user)}
@ -392,6 +399,7 @@ class User < Principal
user = User.current
onclick_time = user.onclick_time.onclick_time
course_count = CourseMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
contest_count = ContestMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
@ -399,7 +407,8 @@ class User < Principal
at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", user.id,0, onclick_time).count
applied_count = AppliedMessage.where("user_id=? and viewed =? and created_at >?", user.id, 0, onclick_time).count
messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count
blog_message_count = BlogMessage.where("user_id=? and viewed=? and created_at >?", user.id, 0, onclick_time).count
messages_count = course_count + contest_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count + blog_message_count
end
# 查询指派给我的缺陷记录

View File

@ -72,7 +72,7 @@ module ZipService
digests = []
homework_common.contestant_works.each do |work|
unless work.attachments.empty?
out_file = zip_student_work_by_user(work)
out_file = zip_contestant_work_by_user(work)
bid_homework_path << out_file.file_path
digests << out_file.file_digest
@ -151,7 +151,7 @@ module ZipService
end
def zip_student_work_by_user(work)
def zip_contestant_work_by_user(work)
homeworks_attach_path = []
not_exist_file = []
# 需要将所有homework.attachments遍历加入zip
@ -169,13 +169,13 @@ module ZipService
#单个文件的话,不需要压缩,只改名
out_file = nil
if homeworks_attach_path.size == 1
out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){
out_file = find_or_pack(work.work_id, work.user_id, digests.sort){
des_path = "#{OUTPUT_FOLDER}/#{make_zip_name(work)}_#{File.basename(homeworks_attach_path.first)}"
FileUtils.cp homeworks_attach_path.first, des_path
des_path
}
else
out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){
out_file = find_or_pack(work.work_id, work.user_id, digests.sort){
zipping("#{make_zip_name(work)}.zip",
homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file)
}

View File

@ -0,0 +1,88 @@
<h3>
<%=l(:label_contest_plural)%>
</h3>
<%= form_tag({}, :method => :get) do %>
<fieldset>
<label for='name'>
竞赛:
</label>
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '竞赛名称' %>
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'contests'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 40px;">
序号
</th>
<th style="width: 180px;">
竞赛
</th>
<th style="width: 40px;">
公开
</th>
<th style="width: 80px;">
创建者
</th>
<th style="width: 40px;">
成员数
</th>
<th style="width: 40px;">
提交数
</th>
<th style="width: 80px;">
创建于
</th>
<th style="width: 130px;">
最新动态时间
</th>
</tr>
</thead>
<tbody>
<% @contests.each do |contest| %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= contest.id %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=contest.name%>'>
<span>
<%= link_to contest.name, contest_path(contest), :target => '_blank' %>
</span>
</td>
<td align="center">
<%= checked_image contest.is_public %>
</td>
<td style="text-align: center; white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=contest.user.show_name%>'>
<span>
<%= link_to contest.user.show_name, user_path(contest.user), :target => '_blank' %>
</span>
</td>
<td align="center">
<%=contest.contest_members.count %>
</td>
<td align="center">
<%=contest.works.count %>
</td>
<td align="center">
<%= format_date(contest.created_at) %>
</td>
<td align="center">
<%= contest.contest_acts.order("updated_at asc").last.updated_at.strftime('%Y-%m-%d %H:%M:%S') %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_project_plural)) -%>

View File

@ -0,0 +1,31 @@
<% if source.id == 786 %>
<img src="/images/game/appbanner.jpg" width="968" height="110" id="avatar_image"/>
<% else %>
<%= image_tag(url_to_avatar(source), :width => "968", :height => "110", :id => "avatar_image", :alt => "竞赛图片")%>
<% end %>
<% if is_admin %>
<a class="banner-inner" href="javascript:void(0)" onclick="$('#upload_contest_logo').click();"></a>
<a class="banner-notice" href="javascript:void(0)" onclick="$('#upload_contest_logo').click();">点击替换图片(968*110)</a>
<%= file_field_tag 'avatar[image]',
:id => 'upload_contest_logo',
:class => 'undis upload_file',
:size => "1",
:multiple => true,
:data => {
:max_file_size => Setting.upload_avatar_max_size,
:max_file_size_message => l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:file_type => Redmine::Configuration['pic_types'].to_s,
:type_support_message => l(:error_pic_type),
:upload_path => upload_avatar_path(:format => 'js'),
:description_placeholder => nil ,# l(:label_optional_description)
:source_type => source.class.to_s,
:source_id => source.id.to_s,
:is_direct => 0
} %>
<!--</span>-->
<%#= content_for(:header_tags) do %>
<%#= javascript_include_tag '/javascripts/jq-upload/jquery.ui.widget', '/javascripts/jq-upload/jquery.iframe-transport', '/javascripts/jq-upload/jquery.fileupload', '/javascripts/jq-upload/upload' %>
<%# end %>
<% end %>
<div class="cl"></div>

View File

@ -1,4 +1,4 @@
<% if @is_direct == '1' && (@source_type=='User'|| @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization') %>
<% if @is_direct == '1' && (@source_type=='User'|| @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization'|| @source_type == 'Contest') %>
var imgSpan = $("img[nhname='avatar_image']");
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
<% else %>

View File

@ -26,9 +26,9 @@
</div>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.admin_of_contest?(@board.contest)) %>
<%# if is_teacher %>
<%#= link_to "添加子栏目", settings_course_path(@board.course.id,'boards'), :class => "link-blue fr mt5" %>
<%# end %>
<% if is_teacher %>
<%= link_to "添加子栏目", settings_contest_path(@board.contest.id, :tab => 'boards'), :class => "link-blue fr mt5" %>
<% end %>
</div>
<div nhname="topic_form">
<% if User.current.logged? %>

View File

@ -2,4 +2,8 @@
$("#tbc_04").html("<%=escape_javascript(render :partial => 'courses/settings/boards_setting') %>");
<% course_board = @course.boards.where("parent_id is NULL").first %>
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/board_children_list', :locals => {:course_board => course_board})%>");
<% elsif @contest %>
$("#game-setting-content-3").html("<%=escape_javascript(render :partial => 'contests/boards') %>");
<% contest_board = @contest.boards.where("parent_id is NULL").first %>
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/contest_board_children_list', :locals => {:contest_board => contest_board})%>");
<% end %>

View File

@ -2,4 +2,9 @@
$("#tbc_04").html("<%=escape_javascript(render :partial => 'courses/settings/boards_setting') %>");
<% course_board = @course.boards.where("parent_id is NULL").first %>
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/board_children_list', :locals => {:course_board => course_board})%>");
<% elsif @contest %>
hideModal();
$("#game-setting-content-3").html("<%=escape_javascript(render :partial => 'contests/boards') %>");
<% contest_board = @contest.boards.where("parent_id is NULL").first %>
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/contest_board_children_list', :locals => {:contest_board => contest_board})%>");
<% end %>

View File

@ -2,4 +2,9 @@
$("#tbc_04").html("<%=escape_javascript(render :partial => 'courses/settings/boards_setting') %>");
<% course_board = @course.boards.where("parent_id is NULL").first %>
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/board_children_list', :locals => {:course_board => course_board})%>");
<% elsif @contest %>
hideModal();
$("#game-setting-content-3").html("<%=escape_javascript(render :partial => 'contests/boards') %>");
<% contest_board = @contest.boards.where("parent_id is NULL").first %>
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/contest_board_children_list', :locals => {:contest_board => contest_board})%>");
<% end %>

View File

@ -2,4 +2,8 @@
$("#tbc_04").html("<%=escape_javascript(render :partial => 'courses/settings/boards_setting') %>");
<% course_board = @course.boards.where("parent_id is NULL").first %>
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/board_children_list', :locals => {:course_board => course_board})%>");
<% elsif @contest %>
$("#game-setting-content-3").html("<%=escape_javascript(render :partial => 'contests/boards') %>");
<% contest_board = @contest.boards.where("parent_id is NULL").first %>
$("#board_children_list").html("<%= escape_javascript(render :partial => 'layouts/contest_board_children_list', :locals => {:contest_board => contest_board})%>");
<% end %>

View File

@ -1,4 +1,4 @@
<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_contestant_works_path(work.id),:id=>'add_score_'+work.id.to_s) do |f|%>
<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_contestant_work_path(work.id),:id=>'add_score_'+work.id.to_s) do |f|%>
<li >
<span class="tit_fb"> 评价:</span>
<%= f.text_area 'user_message', :class => 'hwork_ping_text', :id => 'score_comment_'+work.id.to_s, :placeholder => l(:text_caracters_maximum,:count=>500),:maxlength => 500 %>
@ -40,11 +40,4 @@
$('#about_hwork_'+id).html('');
}
}
function submit_teacher_score(id){
if (first_click_score) {
first_click_score = false;
$("#work_submit_"+id).parent().parent().submit();
hideModal();
}
}
</script>

View File

@ -0,0 +1,9 @@
<div class="syllabus_courses_box">
<% @stundet_works.each_with_index do |student_work, i| %>
<div class="syllabus_courses_list" id="student_work_<%= student_work.id%>" style="cursor: default; background-color:#f6f6f6;">
<%= render :partial => 'contest_evaluation_group_work', :locals => {:student_work => student_work} %>
</div>
<div id="about_hwork_<%= student_work.id %>" class="about_hwork"></div>
<% end %>
</div>
<div class="cl"></div>

View File

@ -0,0 +1,68 @@
<div class="sy_courses_open f14 fontGrey3">
<div>
<span class="fl" style="width:280px;" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">
<span class="hidden fl" style="max-width:220px;"><%= student_work.name %></span>
<span class="fontGrey2 ml5 fl">
<% if student_work.work_status %>
<%= get_status student_work.work_status %>
<% end %>
</span>
</span>
<a href="javascript:void(0)" class="linkBlue2 fr" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">评分</a>
<div class="cl"></div>
<% if @contestwork.work_detail_group.base_on_project %>
<div class="pr">
<span class="fl fontGrey2">关联项目:</span>
<div class="fl projectName">
<% if student_work.project.status != 9 && (student_work.project.is_public || User.current.member_of?(student_work.project) || User.current.admin? || User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest)) %>
<%= link_to student_work.project.name, project_path(student_work.project.id), :class => 'link-blue fl hidden', :style => "max-width:550px;", :title => "项目名称", :target => "_blank" %>
<% elsif student_work.project.status != 9 %>
<span class="fontBlue fr hidden" style="max-width:550px;" title="该项目是私有的"><%= student_work.project.name %></span>
<% else %>
<span class="fontGrey2 fr hidden" style="max-width:550px;" title="该项目已删除"><%= student_work.project.name %>(已删除)</span><% end %>
<% project = student_work.project %>
<div class="score-tip none tl f12" style="width:300px; top:-48px; right:-372px;">
<em style="bottom:45px;"></em>
<font style="bottom:45px;"></font>
<p class="fb break_word mw280"><%= project.name %><%= project.status == 9 ? "(已删除)" : ""%></p>
<p class="mb10">
<span class="mr15">创建者:<%= project.creater %></span><span>成员数量:<%= project.members.count %></span></p>
<% project_score = project.project_score %>
<p>项目综合得分:<%= project.status == 9 ? 0 : static_project_score(project_score).to_i %></p>
<% if project.status != 9 %>
<p>= 代码提交得分 + issue得分 + 资源得分 + 帖子得分</p>
<p>= <%= (project_score.changeset_num||0) * 4 %>
+ <%= project_score.issue_num * 4 + project_score.issue_journal_num %> + <%= project_score.attach_num * 5 %>
+ <%= project_score.board_num * 2 + project_score.board_message_num + project_score.news_num %></p>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<div class="cl"></div>
</div>
<div class="fl sy_p_grey" style="margin-left: 0px;" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">
<span class="fl" style="width:180px;">提交时间:<%= format_date(student_work.commit_time) %></span>
<span class="fl" style="width:105px; text-align: center">人数:<%=student_work.contestant_work_projects.count %>人</span>
<div class="flex-container fl" style="width:400px;">
<div class="flex-cell">我的评分:
<% my_score = ContestantWorkScore.where(:user_id => User.current.id,:contestant_work_id => student_work.id,:reviewer_role => 2).last %>
<span class="<%= my_score.nil? ? 'c_grey' : score_color(my_score.score) %>"><%= my_score.nil? ? "--" : format("%.1f",my_score.score)%></span>
</div>
</div>
</div>
<div class="cl"></div>
<script>
$(".projectName").mouseenter(function () {
$(this).children().next().show();
}).mouseleave(function () {
$(this).children().next().hide();
});
</script>

View File

@ -0,0 +1,29 @@
<table class="hwork-table-wrap" id="homework_table">
<tr class="b_grey hworkH30">
<th class="hworkList40 hworkH30 pl5 pr5">序号</th>
<th class="hworkList50">&nbsp;</th>
<th class="hworkList230 pl5 pr5 hide-text">
姓名
</th>
<th class="hworkList190">
提交时间
</th>
<th class="hworkList140">
我的评分
</th>
<th class="hworkList40 pl5 pr5 hide-text">
</th>
</tr>
<%# end %>
<% @stundet_works.each_with_index do |student_work, i| %>
<% score_open = true %>
<a name="<%= student_work.id%>"></a>
<%= render :partial => "contest_evaluation_work", :locals => {:student_work => student_work, :index => i, :score_open => score_open} %>
<tr>
<td colspan="12">
<div id="about_hwork_<%= student_work.id %>" class="about_hwork">
</div>
</td>
</tr>
<% end %>
</table>

View File

@ -1,9 +1,16 @@
<div class="syllabus_courses_box">
<% @stundet_works.each_with_index do |student_work, i| %>
<div class="syllabus_courses_list" id="student_work_<%= student_work.id%>" onclick="show_student_work('<%= contestant_work_path(student_work)%>');" style="cursor: default; background-color:#f6f6f6;">
<%= render :partial => 'contest_evaluation_un_group_work', :locals => {:student_work => student_work} %>
</div>
<div id="about_hwork_<%= student_work.id %>" class="about_hwork"></div>
<% end %>
</div>
<div class="cl"></div>
<% if @is_judge && @contestwork.online_evaluation && @contestwork.work_status < 3 %>
<div class="pro_new_info mt50" style="width:720px;height:405px;">
<div class="icons_tishi"><img src="/images/new_project/icons_smile.png" width="110" height="110" alt=""></div>
<p class="sy_tab_con_p ">在线评审启动之前,无法查看具体作品</p>
</div>
<% else %>
<div class="syllabus_courses_box">
<% @stundet_works.each_with_index do |student_work, i| %>
<div class="syllabus_courses_list" id="student_work_<%= student_work.id%>" style="cursor: default; background-color:#f6f6f6;">
<%= render :partial => 'contest_evaluation_un_group_work', :locals => {:student_work => student_work} %>
</div>
<div id="about_hwork_<%= student_work.id %>" class="about_hwork"></div>
<% end %>
</div>
<div class="cl"></div>
<% end %>

View File

@ -1,13 +1,14 @@
<div class="sy_courses_open f14 fontGrey3">
<div>
<span class="fl" style="width:280px;">
<span class="hidden fl" style="max-width:220px;"><%= student_work.name %></span>
<span class="fontGrey2 ml5 fl">
<% if student_work.work_status %>
<%= get_status student_work.work_status %>
<% end %>
<span class="fl" style="width:280px;" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">
<span class="hidden fl" style="max-width:220px;"><%= student_work.name %></span>
<span class="fontGrey2 ml5 fl">
<% if student_work.work_status %>
<%= get_status student_work.work_status %>
<% end %>
</span>
</span>
</span>
<a href="javascript:void(0)" class="linkBlue2 fr" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">查看</a>
<div class="cl"></div>
<% if @contestwork.work_detail_group.base_on_project %>
<div class="pr">
@ -45,13 +46,37 @@
</div>
<div class="cl"></div>
</div>
<div class="fl sy_p_grey" style="margin-left: 0px;">
<div class="fl sy_p_grey" style="margin-left: 0px;" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">
<span class="fl" style="width:180px;">提交时间:<%= format_date(student_work.commit_time) %></span>
<span class="fl" style="width:105px; text-align: center">人数:<%=student_work.contestant_work_projects.count %>人</span>
<div class="flex-container fl" style="width:400px;">
<div class="flex-cell">评委评分:--</div>
<div class="flex-cell">最终成绩:--</div>
<div class="flex-cell">评委评分:
<span class="<%= score_color student_work.judge_score %>"><%=student_work.judge_score.nil? ? "--" : format("%.1f",student_work.judge_score) %></span>
<% unless student_work.judge_score.nil? %>
<span class="<%= score_color student_work.judge_score %>">(<%= student_work.contestant_work_scores.where(:reviewer_role => 2).group_by(&:user_id).count%>)</span>
<% end %>
</div>
<div class="flex-cell student_final_scor_info pr">最终成绩:
<span class="<%= score_color student_work.work_score %>"><%=student_work.work_score.nil? ? "--" : format("%.1f",student_work.work_score) %></span>
<% unless student_work.work_score.nil? %>
<div class="contest-group-score-tip none tl" style="line-height: 18px;">
<em></em>
<font></font>
评委平均分
<span class="c_red">&nbsp;<%= format("%.1f",student_work.judge_score < 0 ? 0 : student_work.judge_score)%>&nbsp;</span>分<br/>
<% if !@contestwork.score_valid && student_work.contestant_work_scores.where(:reviewer_role => 2).group_by(&:user_id).count > 2 %>
<% work_scores = student_work.contestant_work_scores.where(:reviewer_role => 2).order("score desc") %>
去除最高分
<span class="c_red">&nbsp;<%= format("%.1f",work_scores.first.score < 0 ? 0 : work_scores.first.score) %>&nbsp;</span>分<br/>
去除最低分
<span class="c_red">&nbsp;<%= format("%.1f",work_scores.last.score < 0 ? 0 : work_scores.last.score) %>&nbsp;</span>分<br/>
<% end %>
作品最终成绩为
<span class="c_red">&nbsp;<%= format("%.1f",student_work.work_score < 0 ? 0 : student_work.work_score)%>&nbsp;</span>分<br/>
</div>
<% end %>
</div>
</div>
</div>
<div class="cl"></div>

View File

@ -1,34 +1,30 @@
<table class="hwork-table-wrap" id="homework_table">
<%# if @homework.homework_type == 1 %>
<%#= render :partial => 'evaluation_un_common_title' %>
<%# elsif @homework.homework_type == 2 %>
<%#= render :partial => 'evaluation_un_pro_title' %>
<%# elsif @homework.homework_type == 3 %>
<%#= render :partial => 'evaluation_un_group_title' %>
<%# else %>
<tr class="b_grey hworkH30">
<th class="hworkList40 hworkH30 pl5 pr5">序号</th>
<th class="hworkList50">&nbsp;</th>
<th class="hworkList190 pl5 pr5 hide-text">
姓名
</th>
<th class="hworkList80 pl5 pr5 hide-text">
</th>
<th class="hworkList130">
状态
</th>
<th class="hworkList100">
评委评分
</th>
<th class="hworkList100">
最终成绩
</th>
</tr>
<%# end %>
<% @stundet_works.each_with_index do |student_work, i| %>
<%# end %>
<% if @is_judge && @contestwork.online_evaluation && @contestwork.work_status < 3 %>
<div class="pro_new_info mt50" style="width:720px;height:405px;">
<div class="icons_tishi"><img src="/images/new_project/icons_smile.png" width="110" height="110" alt=""></div>
<p class="sy_tab_con_p ">在线评审启动之前,无法查看具体作品</p>
</div>
<% else %>
<table class="hwork-table-wrap" id="homework_table">
<tr class="b_grey hworkH30">
<th class="hworkList40 hworkH30 pl5 pr5">序号</th>
<th class="hworkList50">&nbsp;</th>
<th class="hworkList230 pl5 pr5 hide-text">
姓名
</th>
<th class="hworkList130">
提交时间
</th>
<th class="hworkList100">
评委评分
</th>
<th class="hworkList100">
最终成绩
</th>
<th class="hworkList40 pl5 pr5 hide-text">
</th>
</tr>
<% @stundet_works.each_with_index do |student_work, i| %>
<% score_open = true %>
<a name="<%= student_work.id%>"></a>
<%= render :partial => "contest_evaluation_un_work", :locals => {:student_work => student_work, :index => i, :score_open => score_open} %>
@ -38,5 +34,6 @@
</div>
</td>
</tr>
<% end %>
</table>
<% end %>
</table>
<% end %>

View File

@ -3,24 +3,42 @@
<td class="hworkPortrait pr10 float-none">
<%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40",:style => "display:block;"),user_path(student_work.user), :target => '_blank') %>
</td>
<td class="hworkStName190 pr10 float-none hidden" title="<%= student_work.user.show_name%>" style="cursor:pointer; text-align: center;">
<td class="hworkList230 pl5 pr5 float-none hidden" title="<%= student_work.user.show_name%>" style="cursor:pointer; text-align: center;">
<%= link_to student_work.user.show_name ,user_path(student_work.user), :target => '_blank' %>
</td>
<td class="hworkList80 student_work_<%= student_work.id%>" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">
</td>
<td class="hworkList130 c_grey student_work_<%= student_work.id%>" onclick="show_student_work('<%= contestant_work_path(student_work)%>');" style="cursor: pointer;">
<% if student_work.work_status%>
<%=get_status student_work.work_status %>
<%=format_time student_work.commit_time %>
</td>
<td class="hworkList100 <%= score_color student_work.judge_score %>">
<%=student_work.judge_score.nil? ? "--" : format("%.1f",student_work.judge_score) %>
<% unless student_work.judge_score.nil? %>
<span>(<%= student_work.contestant_work_scores.where(:reviewer_role => 2).group_by(&:user_id).count%>)</span>
<% end %>
</td>
<td class="hworkList100 <%= score_color nil %>">
--
</td>
<td class="hworkList100 <%= score_color nil %> student_final_scor_info pr">
--
<td class="hworkList100 <%= score_color student_work.work_score %> student_final_scor_info pr">
<%=student_work.work_score.nil? ? "--" : format("%.1f",student_work.work_score) %>
<% unless student_work.work_score.nil? %>
<div class="contest-score-tip none tl" style="line-height: 18px;">
<em></em>
<font></font>
评委平均分
<span class="c_red">&nbsp;<%= format("%.1f",student_work.judge_score < 0 ? 0 : student_work.judge_score)%>&nbsp;</span>分<br/>
<% if !@contestwork.score_valid && student_work.contestant_work_scores.where(:reviewer_role => 2).group_by(&:user_id).count > 2 %>
<% work_scores = student_work.contestant_work_scores.where(:reviewer_role => 2).order("score desc") %>
去除最高分
<span class="c_red">&nbsp;<%= format("%.1f",work_scores.first.score < 0 ? 0 : work_scores.first.score) %>&nbsp;</span>分<br/>
去除最低分
<span class="c_red">&nbsp;<%= format("%.1f",work_scores.last.score < 0 ? 0 : work_scores.last.score) %>&nbsp;</span>分<br/>
<% end %>
作品最终成绩为
<span class="c_red">&nbsp;<%= format("%.1f",student_work.work_score < 0 ? 0 : student_work.work_score)%>&nbsp;</span>分<br/>
</div>
<% end %>
</td>
<td class="hworkList40 student_work_<%= student_work.id%>">
<a href="javascript:void(0)" class="linkBlue2" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">查看</a>
</td>
<td><div style="position:relative;"><div class="hworkTip" style="display: none" id="work_click_<%= student_work.id%>"><em></em><span></span><font class="fontGrey2">点击查看详情</font></div></div></td>
</tr>

View File

@ -0,0 +1,33 @@
<tr class="hworkListRow" id="student_work_<%= student_work.id%>">
<td class="hworkList40 pl5 pr5" id="work_num_<%=student_work.id %>"><%=index + 1 %></td>
<td class="hworkPortrait pr10 float-none">
<%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40",:style => "display:block;"),user_path(student_work.user), :target => '_blank') %>
</td>
<td class="hworkList230 pl5 pr5 float-none hidden" title="<%= student_work.user.show_name%>" style="cursor:pointer; text-align: center;">
<%= link_to student_work.user.show_name ,user_path(student_work.user), :target => '_blank' %>
</td>
<td class="hworkList190 c_grey student_work_<%= student_work.id%>" onclick="show_student_work('<%= contestant_work_path(student_work)%>');" style="cursor: pointer;">
<%=format_time student_work.commit_time %>
</td>
<% my_score = ContestantWorkScore.where(:user_id => User.current.id,:contestant_work_id => student_work.id,:reviewer_role => 2).last %>
<td class="hworkList140 <%= my_score.nil? ? 'c_grey' : score_color(my_score.score) %> student_final_scor_info pr">
<%= my_score.nil? ? "--" : format("%.1f",my_score.score)%>
</td>
<td class="hworkList40 student_work_<%= student_work.id%>">
<a href="javascript:void(0)" class="linkBlue2" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">评分</a>
</td>
<td><div style="position:relative;"><div class="hworkTip" style="display: none" id="work_click_<%= student_work.id%>"><em></em><span></span><font class="fontGrey2">点击进行评分</font></div></div></td>
</tr>
<%# end %>
<script type="text/javascript">
$(".student_work_<%= student_work.id%>").mouseenter(function(){
if($("#about_hwork_<%= student_work.id%>").html().trim() == "") {
$("#work_click_<%= student_work.id%>").show();
}
}).mouseleave(function(){
$("#work_click_<%= student_work.id%>").hide();
}).mouse;
</script>

View File

@ -38,9 +38,17 @@
<div class="fl">
<% if @contestwork.work_type != 3%>
<%= render :partial => "contest_evaluation_un_title"%>
<% if @is_evaluation && !@stundet_works.empty? %>
<%= render :partial => "contest_evaluation_title"%>
<% else%>
<%= render :partial => "contest_evaluation_un_title"%>
<% end%>
<% else %>
<%= render :partial => "contest_evaluation_un_group"%>
<% if @is_evaluation && !@stundet_works.empty? %>
<%= render :partial => "contest_evaluation_group"%>
<% else %>
<%= render :partial => "contest_evaluation_un_group"%>
<% end%>
<% end %>
</div>
<div class="cl"></div>

View File

@ -1,16 +1,14 @@
<ul class="ping_box_ul <%= is_last ? '' : 'ping_line'%> fl">
<% show_real_name = @is_teacher || score.user == User.current || score.reviewer_role != 3 %>
<%= link_to image_tag(url_to_avatar(show_real_name ? score.user : ""), :width => "34", :height => "34"), show_real_name ? user_path(score.user) : "javascript:void(0)",:class => "ping_pic fl" %>
<% show_real_score = @contestwork.score_open || @is_teacher || score.contestant_work.user == User.current || score.user == User.current %>
<%= link_to image_tag(url_to_avatar(score.user), :width => "34", :height => "34"), user_path(score.user), :class => "ping_pic fl" %>
<div class="pingBoxTit">
<%= link_to show_real_name ? score.user.show_name : "匿名", show_real_name ? user_path(score.user) : "javascript:void(0)", :title => show_real_name ? score.user.show_name : "匿评用户", :class => "linkBlue fl" %>
<%= link_to score.user.show_name, user_path(score.user), :title => score.user.show_name, :class => "linkBlue fl" %>
<span class="ml5 fl">
<%= student_work_score_role score%>
评委
</span>
<% unless score.score.nil? %>
<span class="ml20 fl">评分:</span>
<a href="javascript:void(0);" class="c_orange fl" >
<%= show_real_score ? score.score : "**" %>分
<%= score.score %>分
</a>
<% end %>
<!--<a href="javascript:void(0);" class="fr linkBlue mr5" onclick="$('#add_score_reply_<%#= score.id%>').slideToggle();">回复</a>-->

View File

@ -1,12 +1,17 @@
<div id="popbox02">
<div class="ni_con">
<div><p align='center' style='margin-top: 35px'>您已提交过作品,请不要重复提交,如果想修改作品请点击编辑。</p></div>
<div id="muban_popup_box" style="width:500px;">
<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">
<div><p align='center' style='margin-top: 30px'>您已提交过作品,请不要重复提交,如果想修改作品请点击编辑。</p></div>
<div class="cl"></div>
<div class="ni_btn mt10">
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
<a href="javascript:" class="fr sy_btn_blue mr30" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
编&nbsp;&nbsp;辑
</a>
<a href="javascript:" class="tijiao" onclick="clickCanel();" style="margin-bottom: 15px;margin-top:15px;" >
<a href="javascript:" class="fr sy_btn_grey mr5" onclick="clickCanel();" style="margin-bottom: 15px;margin-top:15px;" >
取&nbsp;&nbsp;消
</a>
</div>

View File

@ -75,15 +75,15 @@
<% end%>
<div class="cl"></div>
</li>
<!--<li >-->
<!--<%# if @contestwork.online_evaluation && User.current.judge_of_contest?(@contestwork.contest) && @contestwork.work_status == 3 %>-->
<!--&lt;!&ndash; 老师 || 开启匿评状态 && 不是当前用户自己的作品 &ndash;&gt;-->
<!--<div id="add_student_score_<%#= work.id%>" class="mt10 evaluation">-->
<!--<%#= render :partial => 'add_score',:locals => {:work => work,:score => score,:is_member_work => is_member_work}%>-->
<!--</div>-->
<!--<%# end%>-->
<!--<div class="cl"></div>-->
<!--</li>-->
<li >
<% if @is_evaluation %>
<!-- 评委&&评审中 -->
<div id="add_student_score_<%= work.id%>" class="mt10 evaluation">
<%= render :partial => 'add_score',:locals => {:work => work,:score => score,:is_member_work => is_member_work}%>
</div>
<% end%>
<div class="cl"></div>
</li>
</ul>
<!--<div id="revise_attachment">-->
@ -104,9 +104,9 @@
<!--</ul>-->
<% end %>
<!--<div class="ping_box fl" id="score_list_<%#= work.id%>" style="<%#= student_work_scores.empty? ? 'padding:0px;' : ''%>">-->
<!--<%#= render :partial => 'contestant_work_score_records', :locals => {:student_work_scores => student_work_scores, :is_member_work => is_member_work} %>-->
<!--</div>-->
<div class="ping_box fl" id="score_list_<%= work.id%>" style="<%= student_work_scores.empty? ? 'padding:0px;' : ''%>">
<%= render :partial => 'contestant_work_score_records', :locals => {:student_work_scores => student_work_scores, :is_member_work => is_member_work} %>
</div>
<div class="cl"></div>
<!---ping_box end--->
<a href="javascript:void(0);" class="linkBlue mt5 mb5" style="margin-left:auto; margin-right: auto; display:block; width: 24px;" onclick="$('#about_hwork_<%= work.id%>').html('');">收起</a>

View File

@ -1,39 +1,49 @@
<div id="popbox02">
<div class="ni_con">
<span class="f16 fontBlue fb">请您确认刚刚上传的作品信息</span>
<p class="f14 mt5 break_word">
<span class="fb">作品名称:</span><%=@student_work.name%>
</p>
<div class="f14 mt5 break_word" style="max-width: 425px; color:#808181; max-height:300px; overflow-x:hidden; overflow-y: auto;">
<div class="fb fl dis">作品描述:</div>
<div class="upload_img fl" style="max-width: 330px;"><%=@student_work.description.html_safe %></div>
<div class="cl"></div>
</div>
<p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.empty? %>
<span class="fl c_red"><%= "无附件"%></span>
<% else %>
<div class="fl grey_c">
<% @student_work.attachments.each_with_index do |attachment,i| %>
<div id="attachment_<%= attachment.id%>">
<%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) %>
<span class="ml5 fl">(<%= number_to_human_size attachment.filesize %>)</span>
<div class="cl"></div>
</div>
<% end -%>
<%#= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %>
</div>
<% end %>
<div id="muban_popup_box" style="width:500px;">
<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">
<div class="clear mt15 ml20" style="color:#808181;">
<span class="f16 fontBlue fb">请您确认刚刚上传的作品信息</span>
<p class="f14 mt5 break_word">
<span class="fb">作品名称:</span><%= @student_work.name %>
</p>
<div class="f14 mt5 break_word" style="max-width: 425px; max-height:300px; overflow-x:hidden; overflow-y: auto;">
<div class="fb fl dis">作品描述:</div>
<div class="upload_img fl" style="max-width: 330px;"><%= @student_work.description.html_safe %></div>
<div class="cl"></div>
</div>
<p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.empty? %>
<span class="fl c_red">无附件</span>
<% else %>
<div class="fl grey_c">
<% @student_work.attachments.each_with_index do |attachment, i| %>
<div id="attachment_<%= attachment.id %>">
<%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) %>
<span class="ml5 fl">(<%= number_to_human_size attachment.filesize %>)</span>
<div class="cl"></div>
</div>
<% end -%>
<%#= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %>
</div>
<% end %>
</p>
<div class="cl"></div>
<div class="ni_btn mt10">
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px; margin-left: 55px;" >
<a href="javascript:" class="sy_btn_blue" onclick="clickOK();" style="margin-left: 55px;">
确&nbsp;&nbsp;定
</a>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">

View File

@ -1,40 +1,50 @@
<div id="popbox02">
<div class="ni_con">
<span class="f16 fontBlue fb">请您确认刚刚上传的作品信息</span>
<p class="f14 mt5 break_word">
<span class="fb">作品名称:</span><%=@student_work.name%>
</p>
<div class="f14 mt5 break_word" style="max-width: 425px; color:#808181; max-height:300px; overflow-x:hidden; overflow-y: auto;">
<div class="fb fl dis">作品描述:</div>
<div id="worksDescription" class="upload_img fl" style="max-width: 330px;"><%=@student_work.description.html_safe %></div>
<div class="cl"></div>
</div>
<p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.empty? %>
<span class="fl c_red"><%= "无附件"%></span>
<% else %>
<div class="fl grey_c">
<% @student_work.attachments.each_with_index do |attachment,i| %>
<div id="attachment_<%= attachment.id%>">
<%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) %>
<span class="ml5 fl">(<%= number_to_human_size attachment.filesize %>)</span>
<div class="cl"></div>
</div>
<% end -%>
<%#= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %>
</div>
<% end %>
<div id="muban_popup_box" style="width:500px;">
<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">
<div class="clear mt15 ml20" style="color:#808181;">
<span class="f16 fontBlue fb">请您确认刚刚上传的作品信息</span>
<p class="f14 mt5 break_word">
<span class="fb">作品名称:</span><%= @student_work.name %>
</p>
<div class="f14 mt5 break_word" style="max-width: 425px; color:#808181; max-height:300px; overflow-x:hidden; overflow-y: auto;">
<div class="fb fl dis">作品描述:</div>
<div id="worksDescription" class="upload_img fl" style="max-width: 330px;"><%= @student_work.description.html_safe %></div>
<div class="cl"></div>
</div>
<p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.empty? %>
<span class="fl c_red"><%= "无附件" %></span>
<% else %>
<div class="fl grey_c">
<% @student_work.attachments.each_with_index do |attachment, i| %>
<div id="attachment_<%= attachment.id %>">
<%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) %>
<span class="ml5 fl">(<%= number_to_human_size attachment.filesize %>)</span>
<div class="cl"></div>
</div>
<% end -%>
<%#= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %>
</div>
<% end %>
</p>
<div class="cl"></div>
<div class="ni_btn mt10">
<a href="javascript:" class="tijiao" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;" >
<a href="javascript:" class="fr sy_btn_blue mr45" onclick="clickOK();" style="margin-bottom: 15px;margin-top:15px;">
确&nbsp;定
</a>
<%= link_to("重 试", retry_work_contestant_work_path(@student_work.id),:class => "tijiao",:style =>"margin-bottom: 15px;margin-top:15px;",:remote => true)%>
</div>
<%= link_to("重 试", retry_work_contestant_work_path(@student_work.id), :class => "fr sy_btn_blue mr5", :style => "margin-bottom: 15px;margin-top:15px;", :remote => true) %>
</div>
</div>
</div>
</div>
<script type="text/javascript">

View File

@ -9,9 +9,9 @@ var num = $("#work_num_<%= @work.id%>").html();
$("#score_list_<%= @work.id%>").removeAttr("style");
<% if @contestwork.work_type == 3 %>
$("#student_work_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'contest_evaluation_un_group_work', :locals => {:student_work => @work}) %>");
$("#student_work_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'contest_evaluation_group_work', :locals => {:student_work => @work}) %>");
<% else %>
$("tr[id='student_work_<%= @work.id%>']").replaceWith("<%= escape_javascript(render :partial => 'contest_evaluation_un_work',:locals => {:student_work => @work, :index => 1, :score_open => score_open}) %>");
$("tr[id='student_work_<%= @work.id%>']").replaceWith("<%= escape_javascript(render :partial => 'contest_evaluation_work',:locals => {:student_work => @work, :index => 1, :score_open => score_open}) %>");
$("#work_num_<%= @work.id%>").html(num);
<% end %>

View File

@ -1,21 +1,12 @@
hideModal();
<% if @has_commit %>
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'has_commit_work') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
var htmlvalue = '<%= escape_javascript(render :partial => 'contestant_works/has_commit_work') %>';
pop_box_new(htmlvalue, 500, 163);
<% elsif @submit_result%>
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'work_information') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='/student_work/"+ <%=@student_work.id%> +"/retry_work' class='upload_btn' data-remote='true'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
var htmlvalue = '<%= escape_javascript(render :partial => 'contestant_works/work_information') %>';
pop_box_new(htmlvalue, 500, 400);
<% else %>
window.location.href = '<%= new_contestant_work_path(:work => @contestwork.id)%>';
window.location.href = '<%= new_contestant_work_path(:work => @contestwork.id)%>';
<% end %>
function clickCanel() {

View File

@ -37,51 +37,6 @@
$("#relatePWrap_<%=@contestwork.id %>").toggleClass('relatePWrap');
$("#moreProject_<%=@contestwork.id %>").show();
});
// 匿评弹框提示
<%# if @is_evaluation && !@stundet_works.empty?%>
// $(function(){
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/praise_alert') %>');
// showModal('ajax-modal', '500px');
// $('#ajax-modal').siblings().remove();
// $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
// "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
// $('#ajax-modal').parent().css("top","").css("left","");
// $('#ajax-modal').parent().addClass("anonymos");
// });
<%# end%>
// function set_score_rule_submit() {
// if($("#late_penalty_num").val() == ""){
// $("#late_penalty_num").val("0");
// }
// if($("#absence_penalty_num").val() == ""){
// $("#absence_penalty_num").val("0");
// }
// $('#muban_popup_box').find('form').submit();
// hideModal();
// }
// //设置评分规则
// function set_score_rule(){
<!--<%# if @homework.homework_type == 2 %>-->
<!--<%# if @homework.anonymous_comment == 0 %>-->
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_pro',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
// pop_box_new(htmlvalue, 570, 355);
<!--<%# else %>-->
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_pro_anon',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
// pop_box_new(htmlvalue, 500, 285);
<!--<%# end %>-->
<!--<%# else %>-->
<!--<%# if @homework.anonymous_comment == 0 %>-->
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_non_pro',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
// pop_box_new(htmlvalue, 500, 325);
<!--<%# else %>-->
// var htmlvalue = "<%#= escape_javascript(render :partial => 'homework_common/set_score_rule_none_pro_anon',:locals => {:homework => @homework, :student_path => true, :user_activity_id => -1,:hw_status => 5}) %>";
// pop_box_new(htmlvalue, 500, 225);
<!--<%# end %>-->
<!--<%# end %>-->
// }
</script>
<div class="homepageRight mt0 ml10">
@ -116,28 +71,29 @@
<!---menu_r end--->
</div>
<!--div class="hworkInfor"><a href="javascript:void(0);" class="linkBlue">作业信息</a></div-->
<%# if @is_teacher%>
<!--<div class="fr mt5">-->
<!--<ul class="">-->
<!--<li class="pr export_icon_li">-->
<!--<a href="javascript:void(0);" class="export_icon linkBlue2">导出</a>-->
<!--<ul class="hworkMenu" style="top: 30px; left: -100px;">-->
<!--&lt;!&ndash;<li>&ndash;&gt;-->
<!--&lt;!&ndash;<%#= link_to "导出作业成绩", student_work_index_path(:homework => @homework.id,:order => @order, :sort => @b_sort, :name => @name, :group => @group, :format => 'xls'),:class=>'hworkExport postTypeGrey', :id => "export_student_work"%>&ndash;&gt;-->
<!--&lt;!&ndash;</li>&ndash;&gt;-->
<!--<li>-->
<!--<%# if @contestwork.contestant_works.empty?%>-->
<!--<%#= link_to "导出作业附件", "javascript:void(0)", class: "hworkExport resourcesGrey", :onclick => "alert('没有学生提交作业,无法下载附件')" %>-->
<!--<%# else%>-->
<!--<%#= link_to "导出作业附件", zipdown_assort_path(obj_class: @contestwork.class, obj_id: @contestwork, format: :json),-->
<!--remote: true, class: "hworkExport resourcesGrey", :id => "download_homework_attachments" %>-->
<!--<%# end%>-->
<!--</li>-->
<!--</ul>-->
<!--</li>-->
<!--</ul>-->
<!--</div>-->
<%# end%>
<% if @is_teacher%>
<div class="fr mt5">
<ul class="">
<li class="pr export_icon_li">
<a href="javascript:void(0);" class="export_icon linkBlue2">导出</a>
<ul class="hworkMenu" style="top: 30px; left: -100px;">
<li>
<%= link_to "导出提交成绩", contestant_works_path(:work => @contestwork.id,:order => @order, :sort => @b_sort, :name => @name, :group => @group, :format => 'xls'),:class=>'hworkExport postTypeGrey', :id => "export_student_work"%>
</li>
<li>
<% if @contestwork.contestant_works.has_committed.empty?%>
<a href="javascript:void(0)" class="hworkExport resourcesGrey" onclick="notice_box('没有学生提交作业,无法下载附件')">导出作业附件</a>
<%#= link_to "导出作业附件", "javascript:void(0)", class: "hworkExport resourcesGrey", :onclick => "alert('没有学生提交作业,无法下载附件')" %>
<% else%>
<%= link_to "导出作业附件", zipdown_assort_path(obj_class: @contestwork.class, obj_id: @contestwork, format: :json),
remote: true, class: "hworkExport resourcesGrey", :id => "download_homework_attachments" %>
<% end%>
</li>
</ul>
</li>
</ul>
</div>
<% end%>
<div class="cl"></div>
</div>

View File

@ -21,28 +21,6 @@
});
<% end %>
// //快速创建项目的弹框
// function new_project(){
// $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'student_work/new_project') %>');
// showModal('ajax-modal', '800px');
// $('#ajax-modal').siblings().remove();
// $('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
// "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
// $('#ajax-modal').parent().css("top","30%").css("left","20%").css("position","fixed").css("border","3px solid #269ac9");
// }
// // 点击 checkbox选中引用的资源的时候保存该资源的id到session里去
// function store_seleted_resource(dom){
// if(dom.attr('checked') == 'checked' ){
// $.get(
// '<%#= store_selected_resource_user_path(User.current) %>'+'?save=y&res_id='+dom.val()
// )
// }else {
// $.get(
// '<%#= store_selected_resource_user_path(User.current) %>'+'?save=n&res_id='+dom.val()
// )
// }
// }
// 添加组成员
function show_group_member() {
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'choose_group_member',:locals => {:homework=>@contestwork}) %>');

View File

@ -4,6 +4,6 @@ if($("#about_hwork_<%= @work.id%>").children().length > 0){
else{
$(".about_hwork").html("");
$("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work =>@work}) %>");
$("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work =>@work, :score => @score, :student_work_scores => @student_work_scores}) %>");
$('#score_<%= @work.id%>').peSlider({range: 'min'});
}

View File

@ -1,11 +1,7 @@
hideModal();
<% if @submit_result%>
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'work_edit_information') %>');
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
var htmlvalue = '<%= escape_javascript(render :partial => 'contestant_works/work_edit_information') %>';
pop_box_new(htmlvalue, 500, 400);
<% else %>
window.location.href = '<%= edit_contestant_work_path(@work)%>';
<% end %>

View File

@ -1,15 +1,22 @@
<div class="pro_new_setting_conbox " style="width:100%; border:none;">
<div class=" sy_new_tchbox clear " style="margin-left:10px; margin-right:10px; " >
<ul class="pro_newsetting_con mb15">
<li class="mb10 clear">
<label class=" fl">新增子栏目名称&nbsp;&nbsp;:&nbsp;</label>
<input type="text" class="w695 fl" placeholder=" 请输入子栏目名称">
</li>
</ul>
<a href="javascript:void(0);" class="fr sy_btn_grey ">取消</a><a href="javascript:void(0);" class="fr sy_btn_blue mr5">保存</a>
<% board = @contest.boards.where("parent_id is NULL").first %>
<div class="pro_new_setting_conbox" style="width:100%; border:none;">
<div class="sy_new_tchbox clear undis" style="margin-left:10px; margin-right:10px;" id="add_sub_board">
<%= form_tag url_for(:controller => 'boards', :action => 'create', :contest_id => @contest.id, :board_id => board.id), :id=> 'add_board_form_subboard',:remote => true do %>
<ul class="pro_newsetting_con mb15">
<li>
<label class="fl">新增子栏目名称&nbsp;&nbsp;:&nbsp;</label>
<input id="subfield_name" name="name" placeholder="请输入子栏目名称" maxlength="30" class="fl h28" style="width: 420px" type="text">
<a href="javascript:void(0);" class="fr sy_btn_grey" onclick="$('#add_sub_board').toggle();">取消</a>
<a href="javascript:void(0);" class="fr sy_btn_blue mr5" id="subMenuSubmit">保存</a>
</li>
<div class="cl"></div>
<span id="new_notice" class="undis fl c_red">名称不能为空</span>
</ul>
<% end %>
</div>
<div class=" clear ml10 mr10" >
<table class="sy_new_table clearfix mb15 " cellpadding="0" cellspacing="0">
<div class="clear ml10 mr10">
<table class="sy_new_table clearfix mb15" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>名称</th>
@ -18,23 +25,86 @@
</thead>
<tbody>
<tr>
<th class="game-text-left"><span class=" ml20"></span>竞赛讨论区</th>
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_green mr5 ">添加子栏目</a></th>
<td class="game-text-left"><span class="ml20"></span>竞赛讨论区</td>
<td class="game-text-right"><a href="javascript:void(0);" class="sy_btn_green mr5" onclick="$('#add_sub_board').toggle();">添加子栏目</a></td>
</tr>
<tr>
<th class="game-text-left"><span class=" ml40"></span>技术讨论区</th>
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">下移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</a><a href="javascript:void(0);" class=" sy_btn_grey mr5 ">删除</a></th>
</tr>
<tr>
<th class="game-text-left"><span class=" ml40"></span>学术论区</th>
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">上移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">下移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</a><a href="javascript:void(0);" class=" sy_btn_grey mr5 ">删除</a></th>
</tr>
<tr>
<th class="game-text-left"><span class=" ml40"></span>学术论区</th>
<th class="game-text-right"><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">上移</a><a href="javascript:void(0);" class=" sy_btn_blue mr5 ">编辑</a><a href="javascript:void(0);" class=" sy_btn_grey mr5 ">删除</a></th>
</tr>
<% count = board.children.count %>
<% board.children.reorder("position asc").each_with_index do |board, i|%>
<tr>
<td class="game-text-left">
<div id="board_sub_show_<%= board.id %>" class="ml40 w350 hidden" title="<%=board.name %>"><%=board.name %></div>
<div id="board_sub_edit_<%= board.id %>" style="display:none;" class="ml40">
<input type="text" name="name" class="h28 w300" id="board_sub_name_<%=board.id %>" maxlength="30"
onblur="update_sub_board_name('#board_sub_show_<%= board.id %>','#board_sub_edit_<%= board.id %>','<%= board.id %>','<%= @contest.id %>',$(this).val());" value="<%= board.name %>"/>
</div>
</td>
<td class="game-text-right">
<% unless i == 0 %>
<%= link_to('上移', {:controller => 'boards', :action => 'update_position', :id => board.id, :contest_id => @contest.id, :opr => 'up'},:remote => true, :method => 'post', :class => "sy_btn_blue mr5", :title => '上移') %>
<% end %>
<% if i < count - 1 %>
<%= link_to('下移', {:controller => 'boards', :action => 'update_position', :id => board.id, :contest_id => @contest.id, :opr => 'down'},:remote => true, :method => 'post', :class => "sy_btn_blue mr5", :title => '下移') %>
<% end %>
<a href="javascript:void(0);" class="sy_btn_blue mr5" onclick="edit('#board_sub_show_<%= board.id %>','#board_sub_edit_<%= board.id %>');">编辑</a>
<a href="javascript:void(0);" class="sy_btn_blue mr5" onclick="delete_confirm_box_2('<%=contest_board_path(board, :contest_id => @contest.id) %>', '确定要删除<%=board.name %>吗?')">删除</a>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<script>
$(function(){
$("#subMenuSubmit").one('click', function(){
sub_board_submit();
});
});
function sub_board_submit(){
if ($("#subfield_name").val().trim() != ""){
$("#new_notice").hide();
$("#add_board_form_subboard").submit();
} else {
$("#new_notice").show();
$("#subMenuSubmit").one('click', function(){
sub_board_submit();
});
}
}
function update_sub_board_name(show_id, edit_id, field_id, domain_id, input_value) {
if (input_value.trim() != "" && $(show_id).html().trim() != input_value.trim()) {
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f16 fontGrey7">确定修改为' + input_value + '</p><div class="cl"></div><a href="javascript:void(0)" class="fr sy_btn_blue mt10"' +
' style="margin-right: 92px;" onclick="update_confirm(1,' + field_id + ',' + domain_id + ');">确定</a>'+
'<a href="javascript:void(0);" class="fr sy_btn_grey mt10 mr10" onclick="update_confirm(2,' + field_id + ',' + domain_id + ');">取消</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
}
$(show_id).show();
$(edit_id).hide();
}
function update_confirm(type, field_id, domain_id){
if(type == 1){
$.ajax({
url: "/boards/" + field_id + "/update_name?contest_id=" + domain_id + "&name=" + $("#board_sub_name_"+field_id).val(),
type: 'put'
});
} else {
hideModal();
$("#board_sub_edit_"+field_id).children("input").val($("#board_sub_show_"+field_id).html().trim());
}
}
function edit(show_id, edit_id) {
$(show_id).toggle();
$(edit_id).toggle();
$(edit_id).find('input').focus();
$(edit_id).find('input').on('keypress', function (e) {
if (e.keyCode == 13) {
this.blur();
}
})
}
</script>

View File

@ -47,7 +47,7 @@
<% when 'Poll' %>
<%#= render :partial => 'users/contest_poll', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<% when 'JournalsForMessage' %>
<%#= render :partial => 'users/contest_journalsformessage', :locals => {:activity => act, :user_activity_id => activity.id, :is_course => 1} %>
<%= render :partial => 'users/contest_journalsformessage', :locals => {:activity => act, :user_activity_id => activity.id, :is_contest => 1} %>
<% when 'Attachment' %>
<%#= render :partial => 'users/contest_attachment', :locals => {:activity => act, :user_activity_id => activity.id} %>
<% when 'Contest' %>

View File

@ -0,0 +1,37 @@
<% if @members.count > 0 %>
<table class="sy_new_table clearfix" cellpadding="0" cellspacing="0">
<thead>
<tr class="clearfix">
<th style="width:50px;">序号</th>
<th style="width:150px">姓名</th>
<th style="width:150px;">登录名</th>
<th style="width:368px; ">单位</th>
</tr>
</thead>
<tbody>
<% @members.each_with_index do |member, index| %>
<% user = member.user %>
<tr class="clearfix">
<td><%= index + 1%></td>
<td>
<%= link_to image_tag(url_to_avatar(user), :width => "30", :height => "30", :style => "display: block;"), user_path(user), :class => 'sy_class_users_st fl mt5 mr5' ,:alt => "用户头像", :target => '_blank' %>
<%= link_to user.show_name, user_path(user), :class => 'fl sy_class_users_st_name ml5', :style => "width: 105px; text-align: left;", :title => "#{user.show_name}", :target => '_blank' %>
<div class="cl"></div>
</td>
<td><span class="sy_new_name ml15" ><%= user.login%></span></td>
<td><%=user.user_extensions.school ? user.user_extensions.school.name : '--' %></td>
</tr>
<% end %>
</tbody>
</table>
<div style="text-align:center;">
<div class="pages" style="width:auto; display:inline-block;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @mem_pages, @members_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
<div class="cl"></div>
</div>
</div>
<% else %>
<%= render :partial => 'users/no_data'%>
<% end %>

View File

@ -9,11 +9,12 @@
<div class="cl"></div>
<div class="banner-game">
<% if @contest.id == 786 %>
<img src="/images/game/appbanner.jpg" width="968" height="110"/>
<% else %>
<img src="/images/game/banner-game.png" width="968" height="110"/>
<%= image_tag(url_to_avatar(@contest), :width => "968", :height => "110", :alt => "竞赛图片", :id=>'nh_source_tx')%>
<% if User.current.admin_of_contest?(@contest) || User.current.admin? %>
<a class="banner-inner" href="<%=my_clear_user_avatar_temp_path(:contest => @contest.id) %>" data-remote="true"></a>
<a class="banner-notice" href="<%=my_clear_user_avatar_temp_path(:contest => @contest.id) %>" data-remote="true">点击替换图片(968*110)</a>
<% end %>
<%#=render :partial => 'avatar/new_contest_avatar_form', :locals => {source: @contest, is_admin: User.current.admin_of_contest?(@contest) || User.current.admin?} %>
</div>
<div class="sy_class_info fl">
<div class="sy_class_titbox">
@ -22,9 +23,9 @@
<div class="cl"></div>
</div>
<p class="sy_cgrey ">
<span class=" mr15">管理员:<a class="sy_cblue" id="admin_num"><%= contest_managers(@contest).count %></a></span>
<span class=" mr15">评委:<a class="sy_cblue" id="judge_num"><%= contest_judges(@contest).count %></a></span>
<span class=" mr15">参赛者:<a class="sy_cblue" id="contestant_num"><%= contest_contestants(@contest).count %></a></span>
<span class=" mr15">管理员:<a class="sy_cblue" href="<%= member_contest_path(@contest, :role => 1)%>" id="admin_num"><%= contest_managers(@contest).count %></a></span>
<span class=" mr15">评委:<a class="sy_cblue" href="<%= member_contest_path(@contest, :role => 2)%>" id="judge_num"><%= contest_judges(@contest).count %></a></span>
<span class=" mr15">参赛者:<a class="sy_cblue" href="<%= member_contest_path(@contest, :role => 3)%>" id="contestant_num"><%= contest_contestants(@contest).count %></a></span>
</p>
</div>
<% if User.current.member_of_contest?(@contest) %>

View File

@ -0,0 +1,19 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<%#= javascript_include_tag "init_KindEditor","user" %>
<% end %>
<%if jours %>
<% jours.each do |jour|%>
<script type="text/javascript">
$(function(){
sd_create_editor_from_data(<%= jour.id%>, null, "100%", "<%=jour.class.to_s%>");
});
</script>
<%= render :partial => 'users/contest_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id, :is_contest => 1} %>
<%#= render :partial => 'user_jours_new', :locals => {:jour => jour} %>
<%end%>
<% end%>
<% if (jours.count + page * 10) < count %>
<%= link_to "点击展开更多",feedback_contest_path(@contest.id, :page => page),:id => "show_more_jours",:remote => "true",:class => "loadMore mt10 f_grey"%>
<% end %>

View File

@ -1,8 +1,9 @@
<table class="sy_new_table clearfix mb15" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>序号</th>
<th style="width:320px;">用户</th>
<th style="width: 35px;">序号</th>
<th style="width:180px;">姓名</th>
<th style="width:140px;">单位</th>
<th>角色</th>
<th class="sy_new_namebox">操作</th>
</tr>
@ -12,7 +13,10 @@
<tr>
<td><%= index + 1 %></td>
<td>
<%= link_to member.user.show_name, user_path(member.user), :class => "pro_new_idname ml10", :title => "#{member.user.show_name}" %>
<%= link_to member.user.show_name, user_path(member.user), :class => "pro_new_idname ml10 mr10", :title => "#{member.user.show_name}" %>
</td>
<td>
<span class="pro_new_school_name ml5 mr5"><%=member.user.user_extensions.school ? member.user.user_extensions.school.name : '--' %></span>
</td>
<td style="width: 200px">
<span id="member_role_<%=member.id %>"><%= zh_contest_role(h member.roles.sort.collect(&:to_s).join(', ')) %></span>

View File

@ -2,7 +2,7 @@
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li><%= link_to !@contest.is_public ? "设为公开" : "设为私有", {:controller => 'contests', :action => 'private_or_public', :id => @contest},:remote=>true,:confirm=>"您确定要设置为"+(!@contest.is_public ? "公开" : "私有")+"吗", :class => "postOptionLink" %></li>
<li><a href="javascript:void(0);" class="postOptionLink" onclick="delete_confirm_box('<%=private_or_public_contest_path(@contest) %>', '您确定要设置为<%= !@contest.is_public ? '公开' : '私有'%>吗')"><%= !@contest.is_public ? '设为公开' : '设为私有'%></a></li>
<% if @contest.invite_code_halt == 0 %>
<li><a href="javascript:void(0);" class="postOptionLink" onclick="alert_halt_code();">暂停加入</a></li>
<% elsif @contest.invite_code_halt == 1 %>

View File

@ -1,5 +1,6 @@
<div class="pro_new_setting_conbox fl " style="width:100%; border:none;">
<a href="javascript:void(0);" class="fl sy_btn_green mb10 ml15" onclick="add_contest_member();">添加成员</a>
<a href="javascript:void(0);" class="fl sy_btn_green mb10 ml15" onclick="add_contest_member();">添加成员</a>
<%= link_to "Excel导出", export_all_members_contest_path(@contest, :format => 'xls'), :class => 'fl sy_btn_green mb10 ml15' %>
<div class="cl"></div>
<div class=" sy_new_tchbox clear undis" style="margin-left:10px; margin-right:10px" id="add_contest_member">
<%= form_tag url_for(:controller => 'contest_members', :action => 'create', :contest => @contest.id),:id => 'contest_member_add_form', :remote => true do |f|%>

View File

@ -0,0 +1,51 @@
<div id="sy_popup_box" style="width:1000px;">
<div class="sy_popup_top">
<h3 class="fl">上传图片</h3>
<a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a>
<div class="cl"></div>
</div>
<div class="">
<div style="margin: 10px 20px;">
<a class="BlueCirBtn" onclick="$('#upload_avatar').click();" style="cursor: pointer;">上传图片</a>
<%= file_field_tag 'avatar[image]',
:id => "upload_avatar",
:style => 'display:none;',#added by young
:size => "1",
:multiple => false,
:onchange => 'addInputAvatar(this);',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
:file_type => Redmine::Configuration['pic_types'].to_s,
:type_support_message => l(:error_pic_type),
:upload_path => upload_avatar_path(:format => 'js'),
:description_placeholder => nil ,# l(:label_optional_description)
:source_type => source.class.to_s,
:source_id => source.id.to_s,
:is_direct => 1
} %>
<!--<br/>-->
<!--<span>只支持jpg,png,gif,大小不超过5M</span>-->
</div>
<div class="cl"></div>
<div>
<p style="text-align: center; font-size: 16px;">预览(968px*110px)</p>
<%= image_tag(url_to_avatar(source), :style=>"width:968px;height:110px;",:class=>"mb5 mt10 ml16",:nhname=>'avatar_image') %>
<br/>
</div>
<div class="cl mb10"></div>
<a href="<%= url_for(:controller => 'my', :action => 'save_user_avatar', :source_id => source.id, :source_type => source.class.to_s) %>" data-remote="true" class="sy_btn_blue fr mr16 f14">确&nbsp;&nbsp;定</a>
<a href="javascript:hideModal();" class="fr sy_btn_grey mr5 f14"> 取&nbsp;&nbsp;消</a>
<div class="cl"></div>
</div>
</div>
<script>
function submit_join_course(){
}
function disable_contestant_choose(){
}
</script>

View File

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

View File

@ -0,0 +1,28 @@
<div class="homepageRight mt0 ml10">
<div class="homepageRightBanner mb10">
<div class="NewsBannerName pr"><span id="mesLabel">竞赛留言</span></div>
</div>
<div class="cl"></div>
<div id="messageContent">
<div class="resources"><%= link_to image_tag(url_to_avatar(User.current),:class=>"fl mr10", :width => "50", :height => "50"), :alt => "用户头像" %>
<div class="fl" style="width:658px;">
<%= form_for('new_form',:url => leave_contest_message_path(@contest.id), :html =>{:id => "contest_feedback_new"}, :method => "post") do |f|%>
<%= render :partial => "users/jour_form", :locals => {:f => f, :object => @contest} %>
<input id="private_flag" name="private" type="hidden" value="0"/>
<a href="javascript:void(0);" class="blue_n_btn fr mt5" id="submit_feedback_user" >留言</a>
<a href="javascript:void(0);" onclick="cancel_jour_submit()" class="greyBtn2 postReplySubmit mt5 mr15">取消</a>
<% end %>
</div>
</div>
<%=render :partial => "contest_jours_list", :locals => {:jours =>@jours, :page => 0, :count => @jour_count} %>
<div class="cl"></div>
</div><!--message_box end-->
</div>
<script type="text/javascript">
$(function(){
$("#submit_feedback_user").one('click',function() {
contest_jour_submit();
});
});
</script>

View File

@ -0,0 +1 @@
$("#show_more_jours").replaceWith("<%= escape_javascript( render :partial => 'contests/contest_jours_list',:locals => {:jours => @jours, :page => @page, :count => @jour_count} )%>");

View File

@ -0,0 +1,23 @@
<div class="sy_class_r fr ml10">
<h3 class="game-setting-h3 clear">
<span class="ml15"></span>
<%= @role == '1' ? '管理员' : @role == '2' ? '评委' : '参赛者' %>列表
<% if User.current.admin_of_contest?(@contest) %>
<%=link_to "成员管理", {:controller => 'contests', :action => 'settings', :id => @contest.id, :tab=>'member'}, :class => 'fr mr15 sy_cblue'%>
<% end %>
</h3>
<div class="hw_search_box fr mt15 mr15 mb10">
<%= form_tag(member_contest_path(@contest), method: 'get',:class => "f_l",:remote=>true,:id => "search_member") do %>
<input class="hw_search-input" name="name" id="search_member_input" placeholder="输入<%= @role == '1' ? '管理员' : @role == '2' ? '评委' : '参赛者' %>登录名/姓名/单位名称进行搜索" type="text">
<input type="hidden" name="role" value="<%=@role %>"/>
<% end %>
<a href="javascript:void(0)" class="hw_btn_search" onclick="$('#search_member').submit();"></a>
<div class="cl"></div>
</div>
<div class="ml15 mr15 mb15" id="contest_all_member">
<%=render :partial => 'contest_all_member' %>
</div>
</div><!--sy_class_r end-->

View File

@ -0,0 +1 @@
$("#contest_all_member").html("<%=escape_javascript(render :partial => 'contest_all_member') %>");

View File

@ -6,7 +6,7 @@
<%= 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');">
<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>

View File

@ -1,3 +1,4 @@
hideModal();
$("#contest_base_info").html('<%=escape_javascript(render :partial=>'contests/contest_base_info') %>');
if(document.getElementById("contest_is_public")) {
<% if !@contest.is_public %>

View File

@ -3,13 +3,13 @@
<div class="game-setting-tab">
<ul id="game-setting-tab-nav">
<li id="game-setting-tab-nav-1" class="game-setting-nav-hover" onclick="HoverLi(1);">
<a href="javascript:void(0);" >基本信息</a>
<a href="javascript:void(0);">基本信息</a>
</li>
<li id="game-setting-tab-nav-2" onclick="HoverLi(2);">
<a href="javascript:void(0);" >成员</a>
<a href="javascript:void(0);">成员</a>
</li>
<li id="game-setting-tab-nav-3" >
<!--<a href="javascript:void(0);" >讨论区设置</a>-->
<li id="game-setting-tab-nav-3" onclick="HoverLi(3);">
<a href="javascript:void(0);">讨论区设置</a>
</li>
<div class="cl"></div>
</ul>
@ -30,6 +30,13 @@
<script type="text/javascript">
$(function(){
<% if @select_tab == 'member'%>
$("#game-setting-tab-nav-2").click();
<% elsif @select_tab == 'boards'%>
$("#game-setting-tab-nav-3").click();
<% end %>
});
function g(o){
return document.getElementById(o);
}
@ -39,7 +46,7 @@
g('game-setting-tab-nav-'+i).className='game-setting-nav-nomall';
g('game-setting-content-'+i).className='undis';
}
g('game-setting-content-'+n).className='dis';
g('game-setting-content-'+n).className='game-dis';
g('game-setting-tab-nav-'+n).className='game-setting-nav-hover';
}

View File

@ -1,21 +1,31 @@
<div class="f14 fb fontGrey3 mb10">选择成员加入分班</div>
<div class="fl mr10">
<input type="text" name="search" value="<%=@search %>" placeholder="输入学生登录名/姓名/学号进行搜索" class="subjectSearch" />
<div class="cl"></div>
<%= form_tag(add_members_course_path(@course, :group_id => @group.id), method: 'post',:class => "f_l",:id => "add_group_members") do %>
<div id="search_member_list">
<%=render :partial => 'search_member_list', :locals => {:members => members} %>
</div>
<% end %>
<div class="cl"></div>
<span class="c_red none" id="add_members_notice"></span>
<div class="cl"></div>
<div class="courseSendSubmit mr15"><a href="javascript:void(0);" class="sendSourceText" onclick="submit_add_members_form();">确定</a></div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText" onclick="hideModal();">取消</a></div>
<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="cl"></div>
<div class="muban_popup_con clear">
<div class="f14 fb fontGrey3 mb10 mt15 ml20">选择成员加入分班</div>
<div class="fl mr10 ml20 w350">
<input type="text" name="search" value="<%=@search %>" placeholder="输入学生登录名/姓名/学号进行搜索" class="subjectSearch" />
<div class="cl"></div>
<%= form_tag(add_members_course_path(@course, :group_id => @group.id), method: 'post',:class => "",:id => "add_group_members") do %>
<div id="search_member_list">
<%=render :partial => 'search_member_list', :locals => {:members => members} %>
</div>
<% end %>
<div class="cl"></div>
<span class="c_red none" id="add_members_notice"></span>
<div class="cl"></div>
<div class="mt10">
<a href="javascript:void(0);" class="fl sy_btn_blue mr10" onclick="submit_add_members_form();">确定</a>
<a href="javascript:void(0);" class="fl sy_btn_grey" onclick="hideModal();">取消</a>
<div class="cl"></div>
</div>
</div>
<div class="cl"></div>
</div>
</div>
<script>
var lastSearchCondition = '';
var count = 0;

View File

@ -0,0 +1,6 @@
<h3 class="fl"><%= @subPage_title %></h3>
<% if User.current.allowed_to?(:as_teacher,@course) %>
<%=link_to "成员管理", {:controller => 'courses', :action => 'settings', :id => @course.id, :tab => 'member'}, :class => 'link-blue ml10 fr mt5' %>
<% end %>
<%= link_to "导出成绩", export_course_member_excel_course_path(@course,:group_id => (@group ? (@group == -1 ? -1 : @group.id) : 0), :name => @search_name,:format => 'xls'), :class => 'link-blue fr mt5'%>
<div class="cl"></div>

View File

@ -5,7 +5,7 @@
<li>
<span class="sy_sq_orange fl mr5 mt5"><%= i+1 %></span>
<div class="fl" style="width:185px;">
<%=link_to e_course.name, course_path(e_course.id), :class => "sy_class_ltitle mb10" %>
<%=link_to e_course.name, course_path(e_course.id), :class => "sy_class_ltitle mb10", :target => '_blank' %>
</div>
<div class="cl"></div>
<p class="sy_cgrey ml20">

View File

@ -74,7 +74,7 @@ var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muba
pop_box_new(htmlvalue, 300, 140);
<% elsif @state == 14 %>
var htmlvalue = '<div id="muban_popup_box" style="width:300px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+
'<div class="clear mt15"><p class="text_c f14">此二维码已停用,请与老师联系</p><div class="cl"></div>'+
'<div class="clear mt15"><p class="text_c f14">此邀请码已停用,请与老师联系</p><div class="cl"></div>'+
'<a href="javascript:void(0);" class="fr sy_btn_blue mt10" style="margin-right: 119px;" onclick="hideModal();">确&nbsp;&nbsp;定</a></div></div>';
pop_box_new(htmlvalue, 300, 140);
<% else %>

View File

@ -11,13 +11,8 @@
</div>
<% else %>
<div class="sy_class_r sy_class_nobg fr ml10">
<div class="sy_class_r_head mb10">
<h3 class="fl"><%= @subPage_title %></h3>
<% if User.current.allowed_to?(:as_teacher,@course) %>
<%=link_to "成员管理", {:controller => 'courses', :action => 'settings', :id => @course.id, :tab => 'member'}, :class => 'link-blue ml10 fr mt5' %>
<% end %>
<%= link_to "导出成绩", export_course_member_excel_course_path(@course,:format => 'xls'), :class => 'link-blue fr mt5'%>
<div class="cl"></div>
<div class="sy_class_r_head mb10" id="course_member_opr">
<%= render :partial => 'course_member_opr' %>
</div>
<%= render :partial => 'course_student', :locals => {:members => @members} %>
</div>

View File

@ -11,11 +11,15 @@
window.location.href = "<%=course_files_path(@course) %>";
}
<% else %>
<% if @course.is_public? %>
if($("#syllabus_course_ul_<%=@syllabus.id %>").length > 0){
window.location.href = "<%= user_courselist_user_path(User.current)%>";
} else{
<% if @course.is_public? %>
$("#show_course_<%= @course.id %>").attr("title","公开班级:<%= @course.name %><%= @course.time.to_s+ @course.term %>");
<% else %>
<% else %>
$("#show_course_<%= @course.id %>").attr("title","私有班级:<%= @course.name %><%= @course.time.to_s+ @course.term %>");
<% end %>
$("#set_course_public_<%= @course.id %>").replaceWith('<%= escape_javascript(link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => "courses", :action => "private_or_public", :id => @course,:user_page => true},
<% end %>
$("#set_course_public_<%= @course.id %>").replaceWith('<%= escape_javascript(link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => "courses", :action => "private_or_public", :id => @course,:user_page => true},
:id => "set_course_public_#{@course.id.to_s}",:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗") %>');
}
<% end %>

View File

@ -1,6 +1,6 @@
<% if @is_search == 0 %>
var htmlvalue = "<%= escape_javascript( render :partial => 'courses/add_members', :locals => {:members => @members} )%>";
pop_up_box(htmlvalue,400,30,50);
pop_box_new(htmlvalue,400,510);
<% else %>
$("#search_member_list").html("<%= escape_javascript(render :partial => 'search_member_list', :locals => {:members => @members}) %>");
<% end %>

View File

@ -3,4 +3,5 @@
*/
$("#search_members").html("<%= escape_javascript( render :partial => 'searchmembers')%>");
$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>");
$("#member_content").html("<%= escape_javascript( render :partial => @render_file, :locals => {:members => @results})%>");
$("#member_content").html("<%= escape_javascript( render :partial => @render_file, :locals => {:members => @results})%>");
$("#course_member_opr").html("<%= escape_javascript( render :partial => 'course_member_opr')%>");

View File

@ -3,4 +3,5 @@
*/
$('#new_group_name').hide();
$('#edit_group_form').hide();
$("#course_member_opr").html("<%= escape_javascript( render :partial => 'course_member_opr')%>");
$("#member_content").html("<%= escape_javascript( render :partial => 'new_member_list', :locals => {:members => @results})%>");

View File

@ -2,14 +2,19 @@
<div class="fl mr10"><%= link_to image_tag(url_to_avatar(User.current), :width => 50, :height => 50,:alt=>'贴吧图像' ), user_path( User.current) %></div>
<div class="fl">
<div class="f16 fontGrey2 ml38">我在问吧</div>
<div class="homepageImageBlock" style="width: 68px !important;">
<div><a href="javascript:void(0);" class="homepageImageNumber" style="cursor: default"><%= @my_memos_count %></a></div>
<div class="homepageImageText">回答</div>
<div class="homepageImageBlock" style="width: 75px !important;">
<!--<div><a href="javascript:void(0);" class="homepageImageNumber" style="cursor: default"><%#= @my_memos_count %></a></div>-->
<div class="mt10">
<div class="homepageImageText fl ml10">回答</div>
<div><a href="javascript:void(0);" class="homepageImageNumber fl ml10" style="cursor: default;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="<%= @my_memos_count %>"><%= @my_memos_count %></a></div>
</div>
</div>
<div class="homepageVerDiv"></div>
<div class="homepageImageBlock" style="width: 68px !important;">
<div><a href="javascript:void(0);" class="homepageImageNumber" style="cursor: default"><%= @my_forums_count %></a></div>
<div class="homepageImageText">发帖</div>
<!-- <div class="homepageVerDiv"></div>-->
<div class="homepageImageBlock" style="width: 70px !important;">
<div class="mt10">
<div class="homepageImageText fl ml10">发帖</div>
<div><a href="javascript:void(0);" class="homepageImageNumber fl ml10" style="width:26px;cursor:default; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="<%= @my_forums_count %>"><%= @my_forums_count %></a></div>
</div>
</div>
</div>
<div class="cl"></div>

View File

@ -1,14 +1,9 @@
<% @forums.each_with_index do |forum, i| %>
<div class="wenba-rightbar-li clearfix <%= i > 9 ? 'none' : ''%> " id="forum_list_<%= forum.id %>">
<h4 class="fl wenba-rightbar-title mt5 ml10" style="border-bottom: 0px"><%= link_to forum.name, forum_path(forum), :class => "", :target => "_blank" %></h4>
<ul class=" fl right-line wenba-rightbar-ul" >
<li><%= link_to forum.memo_count, forum_path(forum), :class => "linkGrey5" %></li>
<li>回答</li>
</ul>
<ul class=" fl wenba-rightbar-ul" >
<li><%= link_to forum.topic_count, forum_path(forum), :class => "linkGrey5" %></li>
<li>帖子</li>
</ul>
<% @forums.each_with_index do |forum, i| %>
<div class="wenba-rightbar-li clearfix <%= i > 9 ? 'none' : ''%> " id="forum_list_<%= forum.id %>">
<h4 class="fl wenba-rightbar-title mt5 ml10" style="border-bottom: 0px;font-weight: normal;"><%= link_to forum.name, forum_path(forum), :style => "color:#666;", :target => "_blank" %></h4>
<div style="width: 40px; overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" class="mt5 mr10 fr" title="回答数+帖子数">
<%= link_to forum.topic_count + forum.memo_count, forum_path(forum), :class => "fontGrey4", :style => "font-size: 10px;" %>
</div>
<% end %>
</div>
<% end %>

View File

@ -33,9 +33,10 @@
<a href="<%= forum_memo_path(topic.forum, topic)%>" class="postReplyIcon mr5" target="_blank"></a>
<% replies_count = Memo.where("root_id = #{topic.id}").count %>
<%= link_to (replies_count), forum_memo_path(topic.forum, topic),:target =>'_blank',:class=>'linkGrey2' %>
<a href="javascript:void(0);" class="linkGrey2 disablePostLikeIcon ml10" style="cursor: default" title="点赞人数" > <%= get_praise_num(topic)%></a>
<% if get_praise_num(topic) > 0 %>
<a href="javascript:void(0);" class="linkGrey2 disablePostLikeIcon ml10" style="cursor: default" title="点赞人数" > <%= get_praise_num(topic)%></a>
<% end %>
</div>
<div class="postDetailDes maxh300" id = "postDetailDes_<%= topic.id %>">
<div id="intro_content_<%= topic.id %>">
<%= topic.content.html_safe%>

View File

@ -9,7 +9,7 @@
<div class="postSort" id="popu"><a href="javascript:void(0);" class="linkGrey2 fl">人气</a><a href="javascript:void(0);" id="reorder_popu" class=""></a></div>
<div class="postSort" id="complex"><a href="javascript:void(0);" class="linkGrey2 fl">综合</a><a href="javascript:void(0);" id="reorder_complex" class=""></a><!--<a href="javascript:void(0);" class="sortArrowActiveD"></a>--></div>
<div class="creatPost" id="create_memo_btn">
<%= link_to "发布新帖",new_forum_memo_path(:forum_id => Forum.first.id), :class => "c_white db creatPostIcon bBlue" %>
<%= link_to "发布新帖",new_forum_memo_path(:forum_id => Forum.first.id), :class => "c_white db creatPostIcon bGreen" %>
</div>
<div class="cl"></div>
</div>
@ -23,7 +23,7 @@
<div class="wenba-rightbar fr">
<div class="wenba-rightbar-top clearfix">
<h3 class="fl ml10">问吧</h3>
<%= link_to "新建贴吧", new_forum_path, :class => "btn-blue btn fr mt5 mr5", :remote => true %>
<%= link_to "新建贴吧", new_forum_path, :class => "btn-blue forum_btn fr mt7 mr5", :remote => true %>
</div>
<div id="forums_right_list">
<%= render :partial => "forums/right_bar" %>

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