Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
7303253c07
|
@ -80,6 +80,10 @@ module Mobile
|
||||||
class_period: params[:class_period]
|
class_period: params[:class_period]
|
||||||
}
|
}
|
||||||
course = ::Course.find(params[:course_id])
|
course = ::Course.find(params[:course_id])
|
||||||
|
# 如果没有传密码过来,那就把原来的密码给上,不然会不更新
|
||||||
|
if params[:password].nil? || params[:password].blank?
|
||||||
|
cs_params[:course][:password] = course[:password]
|
||||||
|
end
|
||||||
cs.edit_course_authorize(current_user,course)
|
cs.edit_course_authorize(current_user,course)
|
||||||
course = cs.edit_course(cs_params, course,current_user)
|
course = cs.edit_course(cs_params, course,current_user)
|
||||||
present :data, course, with: Mobile::Entities::Course
|
present :data, course, with: Mobile::Entities::Course
|
||||||
|
|
|
@ -681,9 +681,10 @@ class CoursesController < ApplicationController
|
||||||
"show_course_files" => true,
|
"show_course_files" => true,
|
||||||
"show_course_news" => true,
|
"show_course_news" => true,
|
||||||
"show_course_messages" => true,
|
"show_course_messages" => true,
|
||||||
"show_course_journals_for_messages" => true,
|
#"show_course_journals_for_messages" => true,
|
||||||
"show_bids" => true,
|
"show_bids" => true,
|
||||||
"show_homeworks" => true
|
"show_homeworks" => true,
|
||||||
|
#"show_polls" => true
|
||||||
}
|
}
|
||||||
@date_to ||= Date.today + 1
|
@date_to ||= Date.today + 1
|
||||||
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
|
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
|
||||||
|
|
|
@ -52,7 +52,7 @@ module CoursesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def course_poll_count
|
def course_poll_count
|
||||||
Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}").count
|
Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status in (2,3)").count
|
||||||
end
|
end
|
||||||
|
|
||||||
def course_feedback_count
|
def course_feedback_count
|
||||||
|
@ -632,48 +632,73 @@ module CoursesHelper
|
||||||
#获取课程动态
|
#获取课程动态
|
||||||
def get_course_activity courses, activities
|
def get_course_activity courses, activities
|
||||||
@course_ids=activities.keys()
|
@course_ids=activities.keys()
|
||||||
@bid_ids = []
|
|
||||||
days = Setting.activity_days_default.to_i
|
days = Setting.activity_days_default.to_i
|
||||||
date_to ||= Date.today + 1
|
#原来课程动态计算当期时间前(一年+一月)的动态
|
||||||
date_from = date_to - days-1.years
|
# date_to ||= Date.today + 1
|
||||||
|
# #date_from = date_to - days-1.years
|
||||||
|
|
||||||
|
date_from = @course.created_at.to_date-days
|
||||||
#file_count
|
#file_count
|
||||||
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
|
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
|
||||||
|
if attachment.is_public? || User.current.member_of_course?(@course) || User.current.admin?
|
||||||
activities[attachment.container_id]+=1
|
activities[attachment.container_id]+=1
|
||||||
|
else
|
||||||
|
activities[attachment.container_id]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#message_count
|
||||||
|
#Board.where(course_id: @course_ids).each do |board|
|
||||||
|
# activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count
|
||||||
|
#end
|
||||||
|
|
||||||
#message_count
|
#message_count
|
||||||
Board.where(course_id: @course_ids).each do |board|
|
Board.where(course_id: @course_ids).each do |board|
|
||||||
# activities[board.course_id]+=1
|
countmessage = 0
|
||||||
activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count
|
# 课程人员退出课程后,之前在讨论区回帖不计入课程动态统计
|
||||||
|
board.messages.where("updated_on>?", date_from).each do |message|
|
||||||
|
if message.author.member_of_course?(@course)
|
||||||
|
countmessage+=1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
activities[board.course_id]+=countmessage
|
||||||
end
|
end
|
||||||
|
|
||||||
#news
|
#news
|
||||||
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
|
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
|
||||||
|
if news.author.member_of_course?(@course)
|
||||||
activities[news.course_id]+=1
|
activities[news.course_id]+=1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#feedbackc_count
|
#feedback_count 留言目前有问题留待下一步处理
|
||||||
JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess|
|
#JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess|
|
||||||
activities[jourformess.jour_id]+=1
|
# activities[jourformess.jour_id]+=1
|
||||||
end
|
#end
|
||||||
|
|
||||||
#homework_count
|
#homework_count
|
||||||
#HomeworkForCourse.where(course_id: @course_ids).each do |homework|
|
HomeworkForCourse.where(course_id: @course_ids).each do |homework|
|
||||||
# @bid_ids<<homework.bid_id
|
countbid=0
|
||||||
# activities[homework.bid_id]+=Bid.where(id: @bid_ids).where("created_on>?",date_from).count
|
# @bid_ids<<homework.bid_id
|
||||||
|
Bid.where(id: homework.bid_id).where("created_on>?",date_from).each do |bid|
|
||||||
#end
|
countbid+=1
|
||||||
|
end
|
||||||
|
activities[homework.course_id]+=countbid
|
||||||
|
end
|
||||||
|
|
||||||
#@bid_ids.each do |bid_id|
|
#@bid_ids.each do |bid_id|
|
||||||
# activities[] +=Bid.where(id: bid_id ).where("created_on>?",date_from).count
|
# activities[] +=Bid.where(id: bid_id ).where("created_on>?",date_from).count
|
||||||
|
#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
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 动态数 + 1 ( 某某创建了该课程 )
|
# 动态数 + 1 ( 某某创建了该课程 )
|
||||||
# activities.each_pair { |key, value| activities[key] = value + 1 }
|
activities.each_pair { |key, value| activities[key] = value + 1 }
|
||||||
return activities
|
return activities
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -759,7 +784,7 @@ module CoursesHelper
|
||||||
def visable_attachemnts_incourse course
|
def visable_attachemnts_incourse course
|
||||||
result = []
|
result = []
|
||||||
course.attachments.each do |attachment|
|
course.attachments.each do |attachment|
|
||||||
if attachment.is_public? || User.current.member_of_course?(course)
|
if attachment.is_public? || User.current.member_of_course?(course) || User.current.admin?
|
||||||
result << attachment
|
result << attachment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,6 +49,7 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
|
|
||||||
acts_as_activity_provider :type => 'course_journals_for_messages',
|
acts_as_activity_provider :type => 'course_journals_for_messages',
|
||||||
:author_key => :user_id,
|
:author_key => :user_id,
|
||||||
|
:permission => :view_course_journals_for_messages,
|
||||||
:timestamp => "#{self.table_name}.updated_on",
|
:timestamp => "#{self.table_name}.updated_on",
|
||||||
:find_options => {:include => :course }
|
:find_options => {:include => :course }
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,23 @@ class Poll < ActiveRecord::Base
|
||||||
has_many :poll_questions, :dependent => :destroy,:order => "#{PollQuestion.table_name}.question_number"
|
has_many :poll_questions, :dependent => :destroy,:order => "#{PollQuestion.table_name}.question_number"
|
||||||
has_many :poll_users, :dependent => :destroy
|
has_many :poll_users, :dependent => :destroy
|
||||||
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
|
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
|
||||||
|
# 添加课程的poll动态
|
||||||
|
# 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_activity_provider :type => 'polls',
|
||||||
|
# :permission => :view_course_polls,
|
||||||
|
#:find_options => {:include => [:course, :author]},
|
||||||
|
#:timestamp => "#{self.table_name}.published_at",
|
||||||
|
# :author_key => :author_id
|
||||||
|
|
||||||
|
# def act_as_activity
|
||||||
|
# self.acts << Activity.new(:user_id => self.user_id)
|
||||||
|
# end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="for_img_thumbnails">
|
<div class="for_img_thumbnails">
|
||||||
<% curse_attachments.sort.reverse.each do |file| %>
|
<% curse_attachments.each do |file| %>
|
||||||
<% if file.is_public? || User.current.member_of_course?(course) %>
|
<% if file.is_public? || User.current.member_of_course?(course) %>
|
||||||
<div class="re_con_box">
|
<div class="re_con_box">
|
||||||
<div class="">
|
<div class="">
|
||||||
|
|
|
@ -2014,6 +2014,8 @@ zh:
|
||||||
label_recently_updated_courseware: 最近更新了课件
|
label_recently_updated_courseware: 最近更新了课件
|
||||||
label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧!
|
label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧!
|
||||||
label_commit_failed: 提交失败
|
label_commit_failed: 提交失败
|
||||||
|
label_recently: 最近被
|
||||||
|
label_creat: 创建
|
||||||
#api end
|
#api end
|
||||||
|
|
||||||
label_end_time: 截止时间
|
label_end_time: 截止时间
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
class CreateDiscussDemos < ActiveRecord::Migration
|
|
||||||
def change
|
|
||||||
create_table :discuss_demos do |t|
|
|
||||||
t.string :title
|
|
||||||
t.text :body
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -137,6 +137,9 @@ Redmine::AccessControl.map do |map|
|
||||||
map.permission :paret_in_homework,{},:require => :member ,:belong_to_course => true
|
map.permission :paret_in_homework,{},:require => :member ,:belong_to_course => true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# map.course_module :polls do |map|
|
||||||
|
# map.permission :view_course_polls, {:polls => [:index,:show]},:require => :member, :belong_to_course => true
|
||||||
|
# end
|
||||||
|
|
||||||
map.course_module :boards do |map|
|
map.course_module :boards do |map|
|
||||||
# map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member
|
# map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member
|
||||||
|
@ -484,6 +487,7 @@ Redmine::Activity.map do |activity|
|
||||||
activity.register :course_messages, :default => false, :class_name => 'Message'
|
activity.register :course_messages, :default => false, :class_name => 'Message'
|
||||||
|
|
||||||
activity.register :homeworks, :class_name => 'Bid'
|
activity.register :homeworks, :class_name => 'Bid'
|
||||||
|
# activity.register :polls, :class_name => 'Poll'
|
||||||
end
|
end
|
||||||
|
|
||||||
Redmine::Search.map do |search|
|
Redmine::Search.map do |search|
|
||||||
|
|
Loading…
Reference in New Issue