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/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/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..596775045 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] ? 0 : 1 + 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/helpers/application_helper.rb b/app/helpers/application_helper.rb index 678d3ed50..75a0eb3f1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -42,6 +42,11 @@ module ApplicationHelper number > 10000 ? (number.to_f / 1000).round.to_s + "k" : number end + # 判断某个课程是否包含仅对自己可见的作业 + def course_has_score_open_common_homework course + course.homework_commons.select{|hc| hc.score_open == 0}.count > 0 ? true : false + end + # 隐藏项目以外的信息 # return: true 显示,false 不显示 def hidden_unproject_infos @@ -2855,18 +2860,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 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/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/courses/_course_heroes.html.erb b/app/views/courses/_course_heroes.html.erb index bd285f9b0..b6bf0daa0 100644 --- a/app/views/courses/_course_heroes.html.erb +++ b/app/views/courses/_course_heroes.html.erb @@ -15,9 +15,15 @@ <% hero_homework_scores.each do |student_score| %> <% if student_score.score.to_i != 0 %> -
  • <%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %> -

    <%=link_to student_score.user.show_name, user_path(student_score.user), :title => student_score.user.show_name %>

    -

    <%= student_score.score<0 ? 0 : student_score.score.to_i %>

    +
  • <%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %> +

    <%=link_to student_score.user.show_name, user_path(student_score.user), :title => student_score.user.show_name %>

    +

    + <% if !(User.current.allowed_to?(:as_teacher, @course) || User.current.admin?) && User.current.id != student_score.user.id && course_has_score_open_common_homework(@course) %> + <%= "**" %> + <% else %> + <%= student_score.score<0 ? 0 : student_score.score.to_i %> + <% end %> +

  • <% end %> <% end %> diff --git a/app/views/courses/_new_member_list.html.erb b/app/views/courses/_new_member_list.html.erb index ac3c847a9..0e21eeb5d 100644 --- a/app/views/courses/_new_member_list.html.erb +++ b/app/views/courses/_new_member_list.html.erb @@ -86,22 +86,32 @@ <%= user.user_extensions.student_id %> - <%= link_to format("%0.2f", hw_score), { - :action => 'show_member_score', - :member_id => member.id, - :remote => true}, - :class => "" %> + <% if !is_teacher && User.current.id != member.user_id && course_has_score_open_common_homework(@course) %> + ** + <% else %> + <%= link_to format("%0.2f", hw_score), { + :action => 'show_member_score', + :member_id => member.id, + :remote => true}, + :class => "" %> + <% end %> <%= ex_score %> <%= link_to act_score, { - :action => 'show_member_act_score', - :member_id => member.id, - :remote => true}, - :class => '' %> + :action => 'show_member_act_score', + :member_id => member.id, + :remote => true}, + :class => '' %> - <%= format("%0.2f", sum) %> + + <% if !is_teacher && User.current.id != member.user_id && course_has_score_open_common_homework(@course) %> + ** + <% else %> + <%= format("%0.2f", sum) %> + <% end %> +

    diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index a1dd20627..daa732fbe 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -36,7 +36,7 @@ 测试时长:<%= exercise.time.nil? || exercise.time == -1 ? '不限' : exercise.time.to_s + "分钟" %> 截止时间:<%= exercise.end_time.nil? ? '未设置' : format_time(exercise.end_time) %> 发布时间:<%= exercise.publish_time.nil? ? '未设置' : format_time(exercise.publish_time) %> - <% if @is_teacher && exercise.exercise_status > 1 %> + <% if exercise.exercise_status > 1 %> 已提交:<%= exercise.exercise_users.where("commit_status = 1").count %> 未提交:<%= exercise.course.student.count - exercise.exercise_users.where("commit_status = 1").count %> <% end %> diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index 27e9673a7..bd2c427f7 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -94,6 +94,7 @@ <%= render :partial => "files/tag_yun_project", :locals => {:tag_list => @tag_list,:project => @project, :tag_name => @tag_name}%>

    + <% if @tip_all_attachments > 0 %>

    <%= render :partial => "files/tip_attachment_count" %> @@ -124,5 +125,8 @@

    <%= render :partial => 'project_list',:locals => {project: @project, all_attachments: @all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments} %>
    + <% else %> + <%= render :partial => "projects/no_data" %> + <% end %>
    <%# html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/homework_common/_alert_score_open_modal.html.erb b/app/views/homework_common/_alert_score_open_modal.html.erb new file mode 100644 index 000000000..b5a0e5409 --- /dev/null +++ b/app/views/homework_common/_alert_score_open_modal.html.erb @@ -0,0 +1,42 @@ +
    +
    +

    成绩公开范围

    + +
    +
    + <%= form_for('new_form',:url =>{:controller => 'homework_common',:action => 'set_score_open',:id => @homework.id,:user_activity_id => @user_activity_id, :hw_status => @hw_status}, + :method => "post", :remote => true) do |f|%> +
    +
    +
      +
    • +
        +
      • + +
      • +
      • + value="1" name="score_open"/> + +
      • +
      • + value="0" name="score_open"/> + +
      • +
      +
    • +
    +
      + +
    +
    + 确定 + 取消 +
    + +
    + <% end%> +
    \ No newline at end of file diff --git a/app/views/homework_common/_set_score_rule_non_pro.html.erb b/app/views/homework_common/_set_score_rule_non_pro.html.erb index afa768838..6afd5f1ee 100644 --- a/app/views/homework_common/_set_score_rule_non_pro.html.erb +++ b/app/views/homework_common/_set_score_rule_non_pro.html.erb @@ -17,6 +17,10 @@
  • + value="<%=homework.homework_detail_manual.no_anon_penalty%>"/> + +
  • +
  • @@ -38,7 +42,7 @@ -