课程动态添加问卷发布,为通过问卷动态访问课程问卷做权限判断
This commit is contained in:
parent
86ef3e680a
commit
6195f0a150
|
@ -705,7 +705,7 @@ class CoursesController < ApplicationController
|
|||
#"show_course_journals_for_messages" => true,
|
||||
"show_bids" => true,
|
||||
"show_homeworks" => true,
|
||||
#"show_polls" => true
|
||||
"show_polls" => true
|
||||
}
|
||||
@date_to ||= Date.today + 1
|
||||
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
|
||||
|
|
|
@ -29,7 +29,7 @@ class PollController < ApplicationController
|
|||
end
|
||||
#已提交问卷的用户不能再访问该界面
|
||||
if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?)
|
||||
render_403
|
||||
redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id)
|
||||
else
|
||||
@can_edit_poll = (!has_commit_poll?(@poll.id,User.current.id)) || User.current.admin?
|
||||
@percent = get_percent(@poll,User.current)
|
||||
|
|
|
@ -691,9 +691,11 @@ module CoursesHelper
|
|||
#end
|
||||
|
||||
#poll_count
|
||||
#Poll.where(polls_group_id: @course_ids, polls_type: Course, polls_status: 2||3).where("published_at>?",date_from).each do |poll|
|
||||
# activities[poll.polls_group_id]+=1
|
||||
#end
|
||||
# 动态目前只统计发布的问卷,关闭的问卷不在动态内显示
|
||||
# Poll.where(polls_group_id: @course_ids, polls_type: Course, polls_status: 2||3).where("published_at>?",date_from).each do |poll|
|
||||
Poll.where(polls_group_id: @course_ids, polls_type: Course, polls_status: 2||3).where("published_at>?",date_from).each do |poll|
|
||||
activities[poll.polls_group_id]+=1
|
||||
end
|
||||
#end
|
||||
|
||||
|
||||
|
|
|
@ -7,22 +7,24 @@ class Poll < ActiveRecord::Base
|
|||
has_many :poll_users, :dependent => :destroy
|
||||
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
|
||||
# 添加课程的poll动态
|
||||
# has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
# after_create :act_as_activity
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
after_create :act_as_activity
|
||||
|
||||
# acts_as_event :title => Proc.new {|o| "#{l(:label_my_message)} ##{o.id}: #{o.name}" },
|
||||
# :description => :description,
|
||||
# :author => :author,
|
||||
# :url => Proc.new {|o| {:controller => 'poll', :action => 'show', :id => o.id}}
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
|
||||
:description => :polls_description,
|
||||
:datetime => :published_at,
|
||||
:author => :user,
|
||||
:url => Proc.new {|o| {:controller => 'poll', :action => 'show', :id => o.id}}
|
||||
|
||||
# acts_as_activity_provider :type => 'polls',
|
||||
# :permission => :view_course_polls,
|
||||
#:find_options => {:include => [:course, :author]},
|
||||
#:timestamp => "#{self.table_name}.published_at",
|
||||
# :author_key => :author_id
|
||||
acts_as_activity_provider :type => 'polls',
|
||||
#:permission => :view_course_polls,
|
||||
:find_options => {:select => "#{Poll.table_name}.*",
|
||||
:joins => "LEFT JOIN #{Course.table_name} ON ( #{Poll.table_name}.polls_type='Course' AND #{Poll.table_name}.polls_status= 2 AND #{Poll.table_name}.polls_group_id = #{Course.table_name}.id )"},
|
||||
:timestamp => "#{self.table_name}.published_at",
|
||||
:author_key => :user_id
|
||||
|
||||
# def act_as_activity
|
||||
# self.acts << Activity.new(:user_id => self.user_id)
|
||||
# end
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.user_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -90,4 +90,6 @@ zh:
|
|||
|
||||
#setting
|
||||
label_user_name: "用户名称"
|
||||
#setting end
|
||||
#setting end
|
||||
|
||||
label_course_poll: 课程问卷
|
|
@ -118,7 +118,7 @@ Redmine::AccessControl.map do |map|
|
|||
map.permission :projects_attachments_download,{:attachments => :download},:belong_to_project => true
|
||||
map.permission :course_attachments_download,{:attachments => :download},:belong_to_course => true
|
||||
map.permission :contest_attachments_download,{:attachments => :download},:belong_to_contest => true
|
||||
|
||||
map.permission :view_polls, {}, :public => true, :read => true
|
||||
map.permission :view_homeworks, {}, :public => true, :read => true
|
||||
|
||||
map.course_module :files do |map|
|
||||
|
@ -487,7 +487,7 @@ Redmine::Activity.map do |activity|
|
|||
activity.register :course_messages, :default => false, :class_name => 'Message'
|
||||
|
||||
activity.register :homeworks, :class_name => 'Bid'
|
||||
# activity.register :polls, :class_name => 'Poll'
|
||||
activity.register :polls, :class_name => 'Poll'
|
||||
end
|
||||
|
||||
Redmine::Search.map do |search|
|
||||
|
|
Loading…
Reference in New Issue