diff --git a/Gemfile b/Gemfile
index 72bd03c7b..58ccbc011 100644
--- a/Gemfile
+++ b/Gemfile
@@ -50,10 +50,10 @@ gem 'elasticsearch-model'
gem 'elasticsearch-rails'
#rails 3.2.22.2 bug
- # gem "test-unit", "~>3.0"
+ gem "test-unit", "~>3.0"
### profile
- # gem 'oneapm_rpm'
+ gem 'oneapm_rpm'
group :development do
gem 'grape-swagger'
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 1f8cdd275..d8fc9ce28 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -175,8 +175,10 @@ class AdminController < ApplicationController
def courses
@name = params[:name].to_s.strip.downcase
if @name && @name != ""
- @courses = Course.select{ |course| course.teacher && ((course.teacher.show_name).include?(@name) || course.name.include?(@name))}
- @courses = @courses.sort{|x, y| y.created_at <=> x.created_at}
+ all_user_ids = Course.all.map{|course| course.tea_id}
+ user_str_ids = search_user_by_name all_user_ids, @name
+ user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
+ @courses = Course.where("tea_id in #{user_ids} or name like '%#{@name}%'").reorder("created_at desc")
else
@courses = Course.order('created_at desc')
end
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index b9a49dbcb..3234d15c0 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -6,7 +6,7 @@ class HomeworkCommonController < ApplicationController
include StudentWorkHelper
before_filter :find_course, :only => [:index,:new,:create]
- before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works]
+ before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,:set_score_open,:alert_score_open_modal]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works]
before_filter :member_of_course, :only => [:index]
@@ -198,6 +198,23 @@ class HomeworkCommonController < ApplicationController
end
end
+ # 成绩公开范围弹框
+ def alert_score_open_modal
+ if params[:user_activity_id]
+ @user_activity_id = params[:user_activity_id]
+ else
+ @user_activity_id = -1
+ end
+ @hw_status = params[:hw_status].to_i
+ end
+
+ def set_score_open
+ @homework.update_attribute('score_open', params[:score_open].to_i)
+ @user_activity_id = params[:user_activity_id].to_i
+ @hw_status = params[:hw_status].to_i
+ @is_teacher = User.current.admin? || User.current.allowed_to?(:as_teacher, @course)
+ end
+
#开启匿评
#statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
def start_anonymous_comment
@@ -257,26 +274,25 @@ class HomeworkCommonController < ApplicationController
def stop_anonymous_comment
@homework_detail_manual.update_column('comment_status', 3)
@homework_detail_manual.update_column('evaluation_end', Date.today)
- #计算缺评扣分
+ # 计算缺评扣分
work_ids = "(" + @homework.student_works.has_committed.map(&:id).join(",") + ")"
- if @homework.homework_type != 3
- @homework.student_works.has_committed.each do |student_work|
- absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count
- student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
- student_work.save
- end
- else
- @homework.student_works.has_committed.each do |student_work|
- absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count
- student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
- student_work.save
- pros = student_work.student_work_projects.where("is_leader = 0")
- user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")"
- student_works = @homework.student_works.where("user_id in #{user_ids}")
- student_works.each do |st_work|
- absence_penalty_count = st_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - st_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count
- st_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
- st_work.save
+
+ # 参与匿评的缺评计算
+ @homework.student_works.where("work_status != 0").each do |student_work|
+ absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count
+ student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
+ student_work.save
+ end
+
+ # 未参与匿评的缺评计算
+ if @homework_detail_manual.no_anon_penalty == 0
+ all_dis_eva = StudentWorksEvaluationDistribution.where("student_work_id IN #{work_ids}")
+ has_sw_count = all_dis_eva.select("distinct user_id").count
+ anon_count = all_dis_eva.count / has_sw_count
+ @homework.student_works.where("work_status != 0").each do |student_work|
+ if student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count == 0
+ student_work.absence_penalty = @homework_detail_manual.absence_penalty * anon_count
+ student_work.save
end
end
end
diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb
index a47ddf787..69a1b829c 100644
--- a/app/controllers/memos_controller.rb
+++ b/app/controllers/memos_controller.rb
@@ -14,17 +14,17 @@ class MemosController < ApplicationController
# layout 'base_memos'
def quote
- @subject = @memo.subject
- @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
-
- @content = "#{ll(Setting.default_language, :text_user_wrote, @memo.author)}
"
- @content << @memo.content.to_s.strip.gsub(%r{
((.|\s)*?)}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n") + "\n\n
" << @content - #@content = "> #{ll(Setting.default_language, :text_user_wrote, @memo.author)}\n> " - #@content << @memo.content.to_s.strip.gsub(%r{\n\n((.|\s)*?)}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" - #@content_html = textilizable(@content) - @temp = Memo.new - @temp.content = @content + # @subject = @memo.subject + # @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + # + # @content = "#{ll(Setting.default_language, :text_user_wrote, @memo.author)}
" + # @content << @memo.content.to_s.strip.gsub(%r{((.|\s)*?)}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n") + "
" << @content + # #@content = "> #{ll(Setting.default_language, :text_user_wrote, @memo.author)}\n> " + # #@content << @memo.content.to_s.strip.gsub(%r{((.|\s)*?)}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" + # #@content_html = textilizable(@content) + # @temp = Memo.new + # @temp.content = @content end def new @@ -47,6 +47,8 @@ class MemosController < ApplicationController @quote = params[:quote] end + + #unless params[:quote].nil? # @quote = params[:quote][:quote] #end @@ -55,6 +57,10 @@ class MemosController < ApplicationController @memo.forum_id = params[:forum_id] @memo.author_id = User.current.id + if params[:memo][:parent_id] + @memo.root_id = (Memo.find params[:memo][:parent_id]).root_id.nil? ? params[:memo][:parent_id].to_i : (Memo.find params[:memo][:parent_id]).root_id + end + @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) @memo.content = @quote + @memo.content respond_to do |format| @@ -111,32 +117,37 @@ class MemosController < ApplicationController @memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示 @memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1)) - page = params[:page] - if params[:r] && page.nil? - offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count - page = 1 + offset / pre_count - else - - end - @reply_count = @memo.children.count - @reply_pages = Paginator.new @reply_count, pre_count, page - @replies = @memo.children. - includes(:author, :attachments). - reorder("#{Memo.table_name}.created_at DESC"). - limit(@reply_pages.per_page). - offset(@reply_pages.offset). - all + # page = params[:page] + # if params[:r] && page.nil? + # offset = @memo.children.where("#{Memo.table_name}.id < ?", params[:r].to_i).count + # page = 1 + offset / pre_count + # else + # end + + # @reply_count = @memo.children.count + # @reply_pages = Paginator.new @reply_count, pre_count, page + # @replies = @memo.children. + # includes(:author, :attachments). + # reorder("#{Memo.table_name}.created_at DESC"). + # limit(@reply_pages.per_page). + # offset(@reply_pages.offset). + # all + + @replies = Memo.where("root_id = #{@memo.id}").reorder("created_at desc") + @reply_count = @replies.count + @replies = get_no_children_comments_all @replies + @limit_count = @replies.count + @page = params[:page] ? params[:page].to_i + 1 : 0 + @limit = 10 + @replies = @replies[@page * @limit..@page * @limit + 9] @memo_new = Memo.new @my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count @my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count - # @memo = Memo.find_by_id(params[:id]) - # @forum = Forum.find(params[:forum_id]) - # @replies = @memo.replies - # @mome_new = Memo.new respond_to do |format| + format.js format.html {render :layout=> 'base_forums'}#:layout=> 'base_forums', format.json { render json: @memo } format.xml { render xml: @memo } diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 08e221d5e..325517e4b 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -270,6 +270,7 @@ class PollController < ApplicationController #发布问卷 def publish_poll + @index = params[:index] @poll.polls_status = 2 @poll.published_at = Time.now @poll.show_result = params[:show_result].to_i if params[:show_result] @@ -508,6 +509,7 @@ class PollController < ApplicationController #重新发布问卷 def republish_poll + @index = params[:index] @poll.poll_questions.each do |poll_question| poll_question.poll_votes.destroy_all end @@ -530,6 +532,7 @@ class PollController < ApplicationController #关闭问卷 def close_poll + @index = params[:index] @poll.polls_status = 3 @poll.closed_at = Time.now if @poll.save diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b9d61e61e..dcd337df2 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -543,12 +543,12 @@ class ProjectsController < ApplicationController @users -= watched.watcher_users if @watched end @watchers = @project.watcher_users - @limit = 20 + @limit = 32 @is_remote = true @watchers_count = @watchers.count @watcher_pages = Paginator.new @watchers_count, @limit, params['page'] || 1 @offset ||= @watcher_pages.offset - @watchers = paginateHelper @watchers, 20 + @watchers = paginateHelper @watchers, @limit end end @@ -611,14 +611,14 @@ class ProjectsController < ApplicationController @applied_members = appied_project_members(@project, @members) end end - @members = paginateHelper @members + @members = paginateHelper @members, 32 end def member_forked @forked_projects = Project.where(:forked_from_project_id => @project.id) - @limit = 20 + @limit = 32 @is_remote = true @forked_count = @forked_projects.count @forked_pages = Paginator.new @forked_count, @limit, params['page'] || 1 diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 9dd6e6358..b6fdd1fee 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -38,12 +38,12 @@ class PullRequestsController < ApplicationController @requests_merged_count = merge_requests.select{|request| request.state == "merged"}.count @requests_closed_count = merge_requests.select{|request| request.state == "closed"}.count - @limit = 10 + @limit = 20 @is_remote = true @count = type_count(type, @requests_opened_count, @requests_merged_count, @requests_closed_count) @pages = Paginator.new @count, @limit, params['page'] || 1 @offset ||= @pages.offset - @requests = paginateHelper @requests, 10 + @requests = paginateHelper @requests, 20 respond_to do |format| format.html format.js @@ -101,16 +101,16 @@ class PullRequestsController < ApplicationController request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id) @fork_project_name = Project.find(params[:target_project_id]).try(:name) @fork_pr_message = true if @fork_project_name - # 发送消息 - #send_message(User.current.id, target_project_id, title) - # 创建Trustie数据 - #PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id) + # 向管理员发送消息 + send_message_to_manager(params[:target_project_id].to_i, request.id, 1) + PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id, :title => title) else + @project_member = Member.where(:project_id => @project.id) request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch) # 发送消息 - #send_message(User.current.id, @project.id, title) + send_message_to_manager(@project.id, request.id, 1) # 创建Trustie数据 - #PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id) + PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id, :title => title) respond_to do |format| format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)} end @@ -189,7 +189,9 @@ class PullRequestsController < ApplicationController def accept_pull_request begin status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid) - PullRequest.create(:pull_request_id => status.id, :user_id => User.current.id, :gpid => status.project_id) + # 接受后,给用户发消息 + send_message_to_author(@project.id, status.author.try(:username), params[:id], 2) + respond_to do |format| format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)} end @@ -214,7 +216,13 @@ class PullRequestsController < ApplicationController # @return [Gitlab::ObjectifiedHash] Information about updated merge request. def update_pull_request begin - @g.update_merge_request(@project.gpid, params[:id], User.current.gid, :state_event => params[:state]) + 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_author(@project.id, user.login, request.id, status) + end respond_to do |format| format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} end @@ -320,8 +328,31 @@ class PullRequestsController < ApplicationController end end - def send_message user_id, project_id, title - self.forge_acts << ForgeMessage.new(:user_id => user_id, :project_id => project_id, :title => title) + def send_message_to_manager project_id, pull_request_id, status + project = Project.find(project_id) + project.members.each do |member| + if is_project_manager?(member.user_id, project_id) && User.current.id != member.user_id + add_message(member.user_id, project_id, pull_request_id, status) + end + end + end + + def send_message_to_author(project_id, user_login, request_id, status) + user = get_user_by_login_and(user_login) + if user.id != User.current.id + add_message(user.id, project_id, request_id, status) + end + end + + def add_message(user_id, project_id, pull_request_id, status) + ForgeMessage.create(:user_id => user_id, + :project_id => project_id, + :forge_message_id => pull_request_id, + :forge_message_type => "PullRequest", + :viewed => true, + :status => status, + :operate_user_id => User.current.id, + ) end def authorize_logged diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index f932748af..fc7ec3b48 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -430,29 +430,21 @@ update end + # 注:由于考虑到性能所以commits api每次返回20条记录 def changes # 顶部导航 @project_menu_type = 5 - @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry g = Gitlab.client - limit = 20 - #每次页面的换回值从1开始,但是gitlab的页面查询是从0开始,所以先改变page的类型减一在改回来 + limit = 10 + # 每次页面的换回值从1开始,但是gitlab的页面查询是从0开始,所以先改变page的类型减一在改回来 @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:@rev) + @commits_count = params[:commit_count].nil? ? @g.user_static(@project.gpid, :rev => @rev).count : params[:commit_count].to_i + @commits_pages = Paginator.new @commits_count, limit, params[:page] + # @offset ||= @commits_pages.offset + # @commits = paginateHelper @commits, limit - #add by hx - #rep_count = commit_count(@project) - - #页面传递必须要str类型,但是Paginator的初始化必须要num类型,需要类型转化 - @commits_count = params[:commit_count].to_i - @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] - - @commit = g.commit(@project.gpid,@rev) - # @changesets = g.get ("/projects/#{@project.gpid}/repository/commits?#{@rev}") - #@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) - @properties = @repository.properties(@path, @rev) - @changeset = @repository.find_changeset_by_name(@rev) render :layout => 'base_projects' end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index fb99f6507..7119d7c9f 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -691,7 +691,11 @@ class StudentWorkController < ApplicationController def show @score = student_work_score @work,User.current @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? - @student_work_scores = student_work_score_record(@work) + if @homework.homework_detail_manual.comment_status == 2 && !@is_teacher && @work.user != User.current + @student_work_scores = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").order("updated_at desc") + else + @student_work_scores = student_work_score_record(@work) + end respond_to do |format| format.js end @@ -867,6 +871,7 @@ class StudentWorkController < ApplicationController @score = StudentWorksScore.find params[:score_id] @is_last = params[:is_last] == "true" @jour = @score.journals_for_messages.new(:user_id => User.current.id,:notes =>params[:message], :reply_id => 0) + @show_real_name = User.current.allowed_to?(:as_teacher, @score.student_work.homework_common.course) || User.current.admin? || @score.reviewer_role != 3 || @jour.user == User.current if @jour.save @status = 1 else @@ -982,33 +987,38 @@ class StudentWorkController < ApplicationController end end - if params[:absence_penalty] && homework_detail_manual.absence_penalty.to_s != params[:absence_penalty].to_s - homework_detail_manual.absence_penalty = params[:absence_penalty] + no_anon_penalty = params[:no_anon_penalty] ? 1 : 0 + if no_anon_penalty != homework_detail_manual.no_anon_penalty + homework_detail_manual.no_anon_penalty = no_anon_penalty if homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值 work_ids = "(" + @homework.student_works.has_committed.map(&:id).join(",") + ")" - if @homework.homework_type != 3 - @homework.student_works.has_committed.each do |student_work| - absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count - student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 - student_work.save - end - else - @homework.student_works.has_committed.each do |student_work| - absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count - student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 - student_work.save - pros = student_work.student_work_projects.where("is_leader = 0") - user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")" - student_works = @homework.student_works.where("user_id in #{user_ids}") - student_works.each do |st_work| - absence_penalty_count = st_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - st_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count - st_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 - st_work.save + all_dis_eva = StudentWorksEvaluationDistribution.where("student_work_id IN #{work_ids}") + has_sw_count = all_dis_eva.select("distinct user_id").count + anon_count = all_dis_eva.count / has_sw_count + @homework.student_works.where("work_status != 0").each do |student_work| + if student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count == 0 + if no_anon_penalty == 0 + student_work.absence_penalty = homework_detail_manual.absence_penalty * anon_count + else + student_work.absence_penalty = 0 end + student_work.save end end end + homework_detail_manual.save if homework_detail_manual + end + if (params[:absence_penalty] && homework_detail_manual.absence_penalty.to_s != params[:absence_penalty].to_s) + homework_detail_manual.absence_penalty = params[:absence_penalty] + if homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值 + work_ids = "(" + @homework.student_works.has_committed.map(&:id).join(",") + ")" + @homework.student_works.where("work_status != 0").each do |student_work| + absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count + student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 + student_work.save + end + end homework_detail_manual.save if homework_detail_manual end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 86c04e9e4..da7cfd849 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -164,6 +164,8 @@ class UsersController < ApplicationController @comment = Comment.find params[:comment].to_i when 'Journal','is_project_issue' @comment = Journal.find params[:comment].to_i + when 'Memo' + @comment = Memo.find params[:comment].to_i end @user_activity_id = params[:user_activity_id] @parent_id = params[:parent_id] if params[:parent_id] @@ -308,6 +310,15 @@ class UsersController < ApplicationController @root.update_column('updated_at', Time.now) @count = @root.journals_for_messages.count @comments = @root.journals_for_messages.reorder("created_on desc").limit(3) + when 'Memo' + @root = reply.root + comment = Memo.new + comment.author = User.current + comment.forum = reply.forum + comment.content = params[:reply_message] + comment.subject = "#{@root.subject}" + comment.root_id = reply.root_id + reply.children << comment end update_course_activity(@root.class.to_s,@root.id) update_user_activity(@root.class.to_s,@root.id) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e9bbcaafe..02bdde103 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2855,18 +2855,18 @@ module ApplicationHelper #获取匿评相关连接代码 def homework_anonymous_comment (homework, hw_status, user_activity_id = -1) if homework.homework_detail_manual.comment_status == 0 ||Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") - link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评" + link = link_to "启动匿评","javascript:void(0)", :class => "wpostOptionLink", :title => "作业截止日期之前不可以启动匿评" elsif homework.student_works.has_committed.count >= 2 && homework.homework_detail_manual#作业份数大于2 case homework.homework_detail_manual.comment_status when 1 - link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink' + link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'wpostOptionLink' when 2 - link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' + link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?hw_status=" + hw_status.to_s + "&user_activity_id=" + user_activity_id.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'wpostOptionLink' when 3 # link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束" end else - link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "学生提交作业数大于等于2时才可以启动匿评" + link = link_to "启动匿评","javascript:void(0)", :class => "wpostOptionLink", :title => "学生提交作业数大于等于2时才可以启动匿评" end link end @@ -3422,6 +3422,8 @@ def get_reply_by_type type, reply_id reply = Journal.find reply_id when 'Syllabus' reply = JournalsForMessage.find reply_id + when 'Memo' + reply = Memo.find reply_id end reply end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 4dd3399a3..98024954d 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -90,6 +90,20 @@ module UsersHelper end end + # 获取pullrequest消息状态 + def pull_request_message_status ma + case ma.status + when 1 + "创建了PullRequest:" + when 2 + "接受了PullRequest:" + when 3 + "重新打开了PullRequest:" + when 4 + "关闭了PullRequest:" + end + + end # 判断当前用户能否对消息进行操作 def allow_to_show applied_message (User.current.id == applied_message.user_id && applied_message.status == 1) ? true : false diff --git a/app/models/forge_message.rb b/app/models/forge_message.rb index bc514025e..e131eb600 100644 --- a/app/models/forge_message.rb +++ b/app/models/forge_message.rb @@ -1,7 +1,7 @@ class ForgeMessage < ActiveRecord::Base # status在不同的类中,作用不同 # Isseu: satus nil:发布了缺陷;:1:缺陷计划完成日志到了提醒 - attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed, :secret_key, :status + attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed, :secret_key, :status, :operate_user_id belongs_to :forge_message ,:polymorphic => true belongs_to :project diff --git a/app/models/homework_detail_manual.rb b/app/models/homework_detail_manual.rb index e0c4dcdcb..6faa84d40 100644 --- a/app/models/homework_detail_manual.rb +++ b/app/models/homework_detail_manual.rb @@ -1,7 +1,7 @@ #手动评分作业表 #comment_status: 1:未开启匿评,2:开启匿评,3:匿评结束 class HomeworkDetailManual < ActiveRecord::Base - attr_accessible :ta_proportion, :comment_status, :evaluation_start, :evaluation_end, :evaluation_num, :absence_penalty, :homework_common_id + attr_accessible :ta_proportion, :comment_status, :evaluation_start, :evaluation_end, :evaluation_num, :absence_penalty, :homework_common_id, :no_anon_penalty belongs_to :homework_common end diff --git a/app/models/memo.rb b/app/models/memo.rb index f08e9afb2..e6701849f 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -79,7 +79,8 @@ class Memo < ActiveRecord::Base "lock", "sticky", "parent_id", - "replies_count" + "replies_count", + "root_id" after_create :add_author_as_watcher, :reset_counters!, :send_message,:create_memo_ealasticsearch_index after_update :update_memo_ealasticsearch_index @@ -126,6 +127,18 @@ class Memo < ActiveRecord::Base Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') end + def creator_user + self.author + end + + def created_time + self.created_on + end + + def content_detail + self.content + end + # 公共贴吧消息记录 # 原则:贴吧创始人;发帖人,wanglingchun(特殊用户) def send_message diff --git a/app/models/professional_level.rb b/app/models/professional_level.rb new file mode 100644 index 000000000..b04741f91 --- /dev/null +++ b/app/models/professional_level.rb @@ -0,0 +1,3 @@ +class ProfessionalLevel < ActiveRecord::Base + attr_accessible :level +end diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index ec13ff16b..92f9b56a6 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -1,6 +1,6 @@ class PullRequest < ActiveRecord::Base # status 1:创建 2:接受 3:重新打开 4:关闭 - attr_accessible :gpid, :pull_request_id, :user_id, :status + attr_accessible :gpid, :pull_request_id, :user_id, :project_id, :title validates_uniqueness_of :pull_request_id has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy diff --git a/app/views/blog_comments/_blog_comment_show_replies.html.erb b/app/views/blog_comments/_blog_comment_show_replies.html.erb index 3a3e8ef81..23cabb67d 100644 --- a/app/views/blog_comments/_blog_comment_show_replies.html.erb +++ b/app/views/blog_comments/_blog_comment_show_replies.html.erb @@ -19,7 +19,7 @@