diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 581005bf7..a243018ba 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1,6 +1,7 @@ class CoursesController < ApplicationController layout 'base_courses' include CoursesHelper + include ActivitiesHelper helper :activities helper :members helper :words @@ -680,26 +681,49 @@ class CoursesController < ApplicationController "show_course_files" => true, "show_course_news" => true, "show_course_messages" => true, - "show_bids" => true, "show_course_journals_for_messages" => true, + "show_bids" => true, "show_homeworks" => true } @date_to ||= Date.today + 1 @date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) - @author ||= @course.teacher - # 决定显示所用用户或单个用户活动 - @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, - :with_subprojects => false, - :author => @author) - @activity.scope_select {|t| has["show_#{t}"]} - # modify by nwb - # 添加私密性判断 - if User.current.member_of_course?(@course)|| User.current.admin? - events = @activity.events(@days, @course.created_at) + if @author.nil? + # 显示老师和助教的活动 + # @authors = searchTeacherAndAssistant(@course) + @authors = course_all_member(@course) + events = [] + @authors.each do |author| + @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, + :with_subprojects => false, + :author => author.user) + + @activity.scope_select {|t| has["show_#{t}"]} + # modify by nwb + # 添加私密性判断 + if User.current.member_of_course?(@course)|| User.current.admin? + events += @activity.events(@days, @course.created_at) + else + events += @activity.events(@days, @course.created_at, :is_public => 1) + end + + end else - events = @activity.events(@days, @course.created_at, :is_public => 1) + # @author = @course.teacher + @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, + :with_subprojects => false, + :author => @author) + + @activity.scope_select {|t| has["show_#{t}"]} + # modify by nwb + # 添加私密性判断 + if User.current.member_of_course?(@course)|| User.current.admin? + events = @activity.events(@days, @course.created_at) + else + events = @activity.events(@days, @course.created_at, :is_public => 1) + end end + # 无新动态时,显示老动态 if events.count == 0 if User.current.member_of_course?(@course)|| User.current.admin? @@ -708,13 +732,17 @@ class CoursesController < ApplicationController events = @activity.events(:is_public => 1) end end - events = paginateHelper events,10 - @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} - # documents @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id))) @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id) end + + sorted_events = sort_activity_events_course(events); + events = paginateHelper sorted_events,10 + @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} + # documents + + respond_to do |format| format.html{render :layout => 'base_courses'} format.api diff --git a/app/helpers/activities_helper.rb b/app/helpers/activities_helper.rb index c15d89e0c..2f48ba87f 100644 --- a/app/helpers/activities_helper.rb +++ b/app/helpers/activities_helper.rb @@ -30,4 +30,16 @@ module ActivitiesHelper end sorted_events end + def sort_activity_events_course(events) + events_by_group = events.group_by(&:event_group) + sorted_events = [] + events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each do |event| + if group_events = events_by_group.delete(event.event_group) + group_events.sort {|x, y| y.event_datetime <=> x.event_datetime}.each_with_index do |e, i| + sorted_events << e unless e.event_description.nil? + end + end + end + sorted_events + end end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index f4ba5040e..3adcdb09e 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -632,7 +632,7 @@ module CoursesHelper #获取课程动态 def get_course_activity courses, activities @course_ids=activities.keys() - + @bid_ids = [] days = Setting.activity_days_default.to_i date_to ||= Date.today + 1 date_from = date_to - days-1.years @@ -653,8 +653,27 @@ module CoursesHelper activities[news.course_id]+=1 end + #feedbackc_count + JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess| + activities[jourformess.jour_id]+=1 + end + + #homework_count + #HomeworkForCourse.where(course_id: @course_ids).each do |homework| + # @bid_ids<?",date_from).count + + #end + + #@bid_ids.each do |bid_id| + # activities[] +=Bid.where(id: bid_id ).where("created_on>?",date_from).count + + #end + + + # 动态数 + 1 ( 某某创建了该课程 ) - activities.each_pair { |key, value| activities[key] = value + 1 } + # activities.each_pair { |key, value| activities[key] = value + 1 } return activities end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 7c816ec19..7c1f14104 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -194,6 +194,8 @@ class CoursesService @course.setup_time = params[:setup_time] @course.endup_time = params[:endup_time] @course.class_period = params[:class_period] + params[:course][:is_public] ? @course.is_public = 1 : @course.is_public = 0 + params[:course][:open_student] ? @course.open_student = 1 : @course.open_student = 0 end @issue_custom_fields = IssueCustomField.sorted.all diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index 3057285a7..68a326fb2 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -1,3 +1,16 @@ + + +

<%= l(:permission_new_course)%>

@@ -24,7 +37,8 @@
  • - + + 显示明码
    学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。
  • @@ -35,7 +49,7 @@
  • - + (打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。)
  • diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index c0b2f1eb6..698bf3cea 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -12,12 +12,13 @@
    <%= link_to_user_header(e.event_author,false,:class => 'problem_name c_orange fl') if e.respond_to?(:event_author) %> <%= link_to_user_header("(#{e.event_author})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName && e.respond_to?(:event_author) %> +   <%= l(:label_new_activity) %>: - <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url,:class => "problem_tit c_dblue fl fb"%> + <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url,:class => "problem_tit c_dblue fl fb"%>

    <%= e.event_description %>
    - <%= l :label_activity_time %> : <%= format_activity_day(day) %><%= format_time(e.event_datetime, false) %> + <%= l :label_activity_time %> : <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %>

    @@ -25,7 +26,7 @@ <% end%> <% end%> <% end%> - +<% if @obj_pages.next_page.nil? %>
    <%= image_tag(url_to_avatar(@user), :width => "42", :height => "42") %> @@ -43,7 +44,7 @@
    - +<% end%> diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index de2a5a82c..7fc079bcb 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -15,7 +15,8 @@
    -<% curse_attachments.each do |file| %> +<% curse_attachments.sort.reverse.each do |file| %> + <% if file.is_public? || User.current.member_of_course?(course) %>
    <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> @@ -50,6 +51,9 @@
    + <% else %> +
    <%= file.filename %>是私有资源
    + <% end %> <% end %>