diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 09d357ebf..d10f09ffa 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -18,6 +18,13 @@ class HomeworkAttachController < ApplicationController @project = @homework.bid.courses[0] end + #获取作业的成员 + def get_homework_member homework + @hoemwork_users = users_for_homework(@homework) + @members = members_for_homework(@homework,@hoemwork_users,params[:q]) + @members = paginateHelper @members,10 + end + def index @homeworks = HomeworkAttach.all respond_to do |format| @@ -28,7 +35,7 @@ class HomeworkAttachController < ApplicationController #作业添加成员(参与人员) def add_homework_users - if User.current.admin? || User.current == @homework.user + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) #@homework = HomeworkAttach.find(params[:id]) if params[:membership] if params[:membership][:user_ids] @@ -40,9 +47,7 @@ class HomeworkAttachController < ApplicationController end end @homework.save - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - @members = paginateHelper @members,10 + get_homework_member @homework respond_to do |format| format.js end @@ -54,12 +59,10 @@ class HomeworkAttachController < ApplicationController #作业删除成员(参与人员) def destory_homework_users #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current == @homework.user + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first homework_user.destroy - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - @members = paginateHelper @members,10 + get_homework_member @homework respond_to do |format| format.js end @@ -136,11 +139,7 @@ class HomeworkAttachController < ApplicationController @homework = HomeworkAttach.find(params[:bid_id]) course = @homework.bid.courses.first if User.current.admin? || User.current.member_of?(course) - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - #该课程的学生的集合 - #@members = course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]}) - @members = paginateHelper @members,10 + get_homework_member @homework else raise "error" end @@ -157,6 +156,7 @@ class HomeworkAttachController < ApplicationController #获取可选成员列表 #homework:作业 #users:该作业所有成员 + #q:模糊匹配的用户的昵称 def members_for_homework homework,users,q homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'") end @@ -165,9 +165,7 @@ class HomeworkAttachController < ApplicationController #@homework = HomeworkAttach.find(params[:id]) if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) #@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]}) - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - @members = paginateHelper @members,10 + get_homework_member @homework else render_403 :message => :notice_not_authorized end @@ -198,7 +196,7 @@ class HomeworkAttachController < ApplicationController def destroy #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + if User.current.admin? || User.current == @homework if @homework.destroy respond_to do |format| format.html { redirect_to project_for_bid_path @homework.bid } diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index eef630996..0602e52d2 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -177,4 +177,9 @@ module CoursesHelper seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count seem_count > 0 end + + #获取指定作业的所有成员 + def users_for_homework homework + homework.nil? ? [] : (homework.users + [homework.user]) + end end diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index c801885b1..e60d4230b 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -14,8 +14,8 @@ class HomeworkAttach < ActiveRecord::Base "user_id" acts_as_attachable - def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0 - jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation) + def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0,reply_id = 0 + jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation,:reply_id => reply_id) jfm.save jfm end diff --git a/app/models/user_score.rb b/app/models/user_score.rb index 3e052f110..bf6f97988 100644 --- a/app/models/user_score.rb +++ b/app/models/user_score.rb @@ -122,8 +122,8 @@ class UserScore < ActiveRecord::Base Rails.logger.error "[UserScore#influence] ===> #{operate} is not define." return false end - #rescue => e - #Rails.logger.error "[UserScore#influence] ===> Exception: #{e}." + rescue => e + Rails.logger.error "[UserScore#influence] ===> Exception: #{e}." end # 前略·技术得分 diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 0f605d6fa..18778f5e9 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -90,10 +90,12 @@ <% end %> - <% if (User.current == homework.user) || is_teacher %> + <% if (users_for_homework(homework).include?(User.current) || is_teacher) %> <%= link_to l(:button_edit), edit_homework_attach_path(homework) %> - <%= link_to(l(:label_bid_respond_delete), homework, - method: :delete, :confirm => l(:text_are_you_sure)) %> + <% if homework.user == User.current || is_teacher %> + <%= link_to(l(:label_bid_respond_delete), homework, + method: :delete, :confirm => l(:text_are_you_sure)) %> + <% end %> <% end %> @@ -102,4 +104,4 @@
-<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index a36c1a8bf..f7104840b 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -8,6 +8,22 @@ } +
+ + + + + + + + + + +
高校课程实践社区<%= l(:label_user_location) %> :
<%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%>

<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > + <%= link_to(@homework.bid.courses.first.name.to_s, homework_project_path(@homework.bid.courses.first)) if @homework.bid.courses.first%> > + <%=link_to(@homework.bid.name, respond_path(@homework.bid)) %> > <%= link_to "修改作业",edit_homework_attach_path(@homework)%>

+
+

<%=raw l(:label_edit_homework)%>

<%= @stars_status_map["star#{(star/20).to_s}".to_sym] %> -
+
<% end %> @@ -142,32 +141,37 @@
-
-
作业评论:
- <% if is_student %> - <% if @is_evaluation %> - <% if @has_evaluation %> -
- <%= l(:lable_has_evaluation)%> -
+ + +<% if !users_for_homework(@homework).include?(User.current) %> +
+
作业评论:
+ <% if is_student %> + <% if @is_evaluation %> + <% if @has_evaluation %> +
+ <%= l(:lable_has_evaluation)%> +
+ <% else %> + <%= render :partial => 'evaluation', :locals => {:homework => @homework} %> + <% end %> <% else %> - <%= render :partial => 'evaluation', :locals => {:homework => @homework} %> +
+ <%= l(:lable_close_evaluation)%> +
<% end %> - <% else %> -
- <%= l(:lable_close_evaluation)%> -
<% end %> - <% end %> -
+
+<% end %> <% if !is_teacher %> - -
- <%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => nil} %> -
+ +
+ <%= render :partial => 'addjour', :locals => {:homework_attach => @homework, :sta => 0, :is_comprehensive_evaluation => nil} %> +
<% end %> +
<%= render :partial => 'showjour', :locals => {:jour => @jour,:homework => @homework} %> diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb index baf438cb2..3d55869a4 100644 --- a/app/views/layouts/_base_footer.html.erb +++ b/app/views/layouts/_base_footer.html.erb @@ -1,4 +1,5 @@ +<% cache "footer" do %>