diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 8e57f9f2b..5b17271af 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -515,6 +515,7 @@ class BidsController < ApplicationController INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id}) AS table1 WHERE table1.m_score IS NULL") + @is_student_batch_homework = true end @homework_list = paginateHelper all_homework_list,10 diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 085b4d41f..917040170 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -8,7 +8,7 @@ class HomeworkAttachController < ApplicationController #判断当前角色权限时需先找到当前操作的project before_filter :find_course_by_bid_id, :only => [:new] before_filter :find_bid_and_course,:only => [:get_not_batch_homework,:get_batch_homeworks,:get_homeworks,:get_homework_jours, :get_student_batch_homework, :get_my_homework] - before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users] + before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users, :praise_homework] #判断当前角色是否有操作权限 #勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy] @@ -121,6 +121,25 @@ class HomeworkAttachController < ApplicationController end end + #为作业点赞 + def praise_homework + pt = PraiseTread.new + pt.user_id = User.current.id + pt.praise_tread_object_id = @homework.id + pt.praise_tread_object_type = "HomeworkAttach" + pt.praise_or_tread = 1 + @is_my_homework = params[:is_my_homework] + @is_student_batch_homework = params[:is_student_batch_homework] + @is_teacher = params[:is_teacher] + if pt.save + respond_to do |format| + format.js + end + else + render_404 + end + end + #获取作业的成员 def get_homework_member homework @hoemwork_users = users_for_homework(@homework) diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index 3510dc783..c3bd240a3 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -74,4 +74,14 @@ module HomeworkAttachHelper end type end + + #判断指定用户是不是已经赞过该作业 + def is_praise_homework user_id, obj_id + PraiseTread.where("user_id = #{user_id} AND praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'HomeworkAttach'").empty? + end + + #获取赞的总数 + def praise_homework_count obj_id + PraiseTread.where("praise_tread_object_id = #{obj_id} AND praise_tread_object_type = 'HomeworkAttach'").count + end end \ No newline at end of file diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index db61bf93d..5979e64d8 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -47,7 +47,7 @@
高校课程实践社区 | -<%= l(:label_user_location) %> : | - -
<%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index'%> | -<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> > - <%= link_to(@homework.bid.courses.first.name.to_s, homework_course_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)%>
高校课程实践社区 | -- - <%= l(:label_user_location) %> : - - | - -
- - <%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index'%> - - | -
- - <%=link_to "主页", home_path %> > - <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> > - - <%= link_to(@bid.courses.first.name.to_s, homework_course_path(@bid.courses.first)) if @bid.courses.first%> - > - <%=link_to(@bid.name, respond_path(@bid)) %> > - - <%= link_to "创建作业", new_homework_attach_path(@bid)%> - - - |
-
<%=h l(:label_new_homework)%>
diff --git a/app/views/homework_attach/praise_homework.js.erb b/app/views/homework_attach/praise_homework.js.erb new file mode 100644 index 000000000..77855cd3c --- /dev/null +++ b/app/views/homework_attach/praise_homework.js.erb @@ -0,0 +1,4 @@ +$('#homework_li_<%= @homework.id%>'). + html('<%= escape_javascript(render :partial => 'homework_attach/homework', + :locals => {:homework => @homework, :is_student_batch_homework => @is_student_batch_homework, + :is_my_homework => @is_my_homework, :is_teacher => @is_teacher})%>'); \ No newline at end of file diff --git a/app/views/praise_tread/_praise_tread.html.erb b/app/views/praise_tread/_praise_tread.html.erb index 5bb7addb2..d7ee09ce0 100644 --- a/app/views/praise_tread/_praise_tread.html.erb +++ b/app/views/praise_tread/_praise_tread.html.erb @@ -3,38 +3,57 @@ <% if horizontal %><%= image_tag "/images/praise_tread/praise_false.png" , weight:"22px", height:"22px",:title => l(:label_issue_praise_over) %> | -<%= get_praise_num(obj)%> | -<%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_appraise_over) %> | ++ <%= image_tag "/images/praise_tread/praise_false.png" , weight:"22px", height:"22px",:title => l(:label_issue_praise_over) %> + | ++ + <%= get_praise_num(obj)%> + + | ++ <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_appraise_over) %> + |
<%= image_tag "/images/praise_tread/praise_false.png",weight:"22px", height:"22px", :title => l(:label_issue_appraise_over) %> | -<%= get_praise_num(obj)%> | -<%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_tread_over) %> | ++ <%= image_tag "/images/praise_tread/praise_false.png",weight:"22px", height:"22px", :title => l(:label_issue_appraise_over) %> + | ++ + <%= get_praise_num(obj)%> + + | ++ <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_tread_over) %> + |
<%= image_tag "/images/praise_tread/praise_true.png" , weight:"22px", height:"22px",:title => l(:label_issue_not_praise_over) %> | -<%= get_praise_num(obj)%> | -<%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_not_treed_over) %> | ++ <%= image_tag "/images/praise_tread/praise_true.png" , weight:"22px", height:"22px",:title => l(:label_issue_not_praise_over) %> + | ++ + <%= get_praise_num(obj)%> + + | ++ <%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_not_treed_over) %> + |
<%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)), - :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %> | -<%= get_praise_num(obj)%> | -<%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issues_score_not_enough) %> | ++ <%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)), + :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %> + | ++ + <%= get_praise_num(obj)%> + + | ++ <%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issues_score_not_enough) %> + |
<%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)), - :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %> | -<%= get_praise_num(obj)%> | -<%= link_to image_tag("/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_tread)),:controller=>"praise_tread", - :action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %> | ++ <%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)), + :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %> + | ++ + <%= get_praise_num(obj)%> + + | ++ <%= link_to image_tag("/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_tread)),:controller=>"praise_tread", + :action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %> + |
<%= image_tag "/images/praise_tread/praise_false.png" , weight:"22px", height:"22px",:title => l(:label_issue_praise_over) %> | ++ <%= image_tag "/images/praise_tread/praise_false.png" , weight:"22px", height:"22px",:title => l(:label_issue_praise_over) %> + |
<%= get_praise_num(obj)%> | ++ + <%= get_praise_num(obj)%> + + |
<%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_appraise_over) %> | ++ <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_appraise_over) %> + |
<%= image_tag "/images/praise_tread/praise_false.png",weight:"22px", height:"22px", :title => l(:label_issue_appraise_over) %> | ++ <%= image_tag "/images/praise_tread/praise_false.png",weight:"22px", height:"22px", :title => l(:label_issue_appraise_over) %> + |
<%= get_praise_num(obj)%> | ++ + <%= get_praise_num(obj)%> + + |
<%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_tread_over) %> | ++ <%= image_tag "/images/praise_tread/tread_false.png",weight:"22px", height:"22px",:title => l(:label_issue_tread_over) %> + |
<%= image_tag "/images/praise_tread/praise_true.png",weight:"22px", height:"22px", :title => l(:label_issue_not_praise_over) %> | ++ <%= image_tag "/images/praise_tread/praise_true.png",weight:"22px", height:"22px", :title => l(:label_issue_not_praise_over) %> + |
<%= get_praise_num(obj)%> | ++ + <%= get_praise_num(obj)%> + + |
<%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_not_treed_over) %> | ++ <%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_not_treed_over) %> + |
<%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)), - :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class ,:horizontal => horizontal %> | ++ <%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)), + :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class ,:horizontal => horizontal %> + |
<%= get_praise_num(obj)%> | ++ + <%= get_praise_num(obj)%> + + |
<%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issues_score_not_enough) %> | ++ <%= image_tag "/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issues_score_not_enough) %> + |
<%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)), - :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class ,:horizontal => horizontal %> | ++ <%= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)), + :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class ,:horizontal => horizontal %> + |
<%= get_praise_num(obj)%> | ++ + <%= get_praise_num(obj)%> + + |
<%= link_to image_tag("/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_tread)),:controller=>"praise_tread", - :action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class ,:horizontal => horizontal %> | ++ <%= link_to image_tag("/images/praise_tread/tread_true.png",weight:"22px", height:"22px",:title => l(:label_issue_tread)),:controller=>"praise_tread", + :action=>"tread_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class ,:horizontal => horizontal %> + |