资源按时间倒序显示;新建课程设置公开私有属性;课程动态(动态统计主要在作业和作品上存在问题,动态显示在作品和留言中存在权限问题);课程动态格式调整

This commit is contained in:
whimlex 2015-04-03 11:30:48 +08:00
parent b344bf3ea6
commit aa64b47d74
16 changed files with 126 additions and 38 deletions

View File

@ -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

View File

@ -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

View File

@ -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<<homework.bid_id
# activities[homework.bid_id]+=Bid.where(id: @bid_ids).where("created_on>?",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

View File

@ -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

View File

@ -1,3 +1,16 @@
<script src="/jquery.min.js"></script>
<script type="text/javascript" src="/javascripts/iPass.packed.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// to enable iPass plugin
$("input[type=password]").iPass();
// for the demo
$("#psw_btn").click(function() {
alert("密码: "+$("#course_course_password").val());
})
});
</script>
<div class="project_r_h02">
<h2 class="project_h2"><%= l(:permission_new_course)%></h2>
</div>
@ -24,7 +37,8 @@
<div class="cl"></div>
<li class="ml45 mb10">
<label><span class="c_red">*</span>&nbsp;<%= l(:label_new_course_password)%>&nbsp;&nbsp;</label>
<input type="text" name="course[password]" id="course_course_password" class="hwork_input02" >
<input type="password" name="course[password]" id="course_course_password" class="hwork_input02" >
<a id="psw_btn" class="">显示明码</a>
<div class="cl"></div>
<span class=" ml80 c_orange">学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。</span>
</li>
@ -35,7 +49,7 @@
</li>
<li class=" mb5 ml80">
<label >公开&nbsp;&nbsp;</label>
<input checked="checked" id="course_is_public" name="course[is_public]" type="checkbox" value="1">
<input id="course_is_public" name="course[is_public]" type="checkbox" value="1">
<span class="c_grey">(打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。)</span>
<div class="cl"></div>
</li>

View File

@ -12,12 +12,13 @@
<div class="problem_txt fl mt5">
<%= 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) %>
<span class="fl"> &nbsp;</span>
<span class="fl"> <%= l(:label_new_activity) %></span>
<%= 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"%>
<br />
<p class="mt5 break_word"><%= e.event_description %>
<br />
<%= l :label_activity_time %> <%= format_activity_day(day) %><%= format_time(e.event_datetime, false) %>
<%= l :label_activity_time %> <%= format_activity_day(day) %>&nbsp;<%= format_time(e.event_datetime, false) %>
</p>
</div>
<div class="cl"></div>
@ -25,7 +26,7 @@
<% end%>
<% end%>
<% end%>
<% if @obj_pages.next_page.nil? %>
<div class="problem_main">
<a class="problem_pic fl">
<%= image_tag(url_to_avatar(@user), :width => "42", :height => "42") %>
@ -43,7 +44,7 @@
</div>
<div class="cl"></div>
</div><!--课程动态 end-->
<% end%>
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>

View File

@ -15,7 +15,8 @@
</div>
<div class="cl"></div>
<div class="for_img_thumbnails">
<% curse_attachments.each do |file| %>
<% curse_attachments.sort.reverse.each do |file| %>
<% if file.is_public? || User.current.member_of_course?(course) %>
<div class="re_con_box">
<div class="">
<%= 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 @@
</div>
<div class="cl"></div>
</div><!---re_con_box end-->
<% else %>
<div class="re_con_box"><span class='fr mr10 pr_join_span '><%= file.filename %>是私有资源</span></div>
<% end %>
<% end %>
</div>
<ul class="wlist">

View File

@ -48,7 +48,7 @@
</div>
<div class="search fl">
<%= form_tag({:controller => 'courses', :action => 'search'},:id => "course_search_form", :method => :get, :class => "search_form") do %>
<%= text_field_tag 'name', params[:name], :placeholder => "课程名称", :class => "search_text fl", :onkeyup => "regexName('#{l(:label_search_conditions_not_null)}');" %>
<%= text_field_tag 'name', params[:name], :placeholder => l(:label_course_name), :class => "search_text fl", :onkeyup => "regexName('#{l(:label_search_conditions_not_null)}');" %>
<a href="#" onclick="submitSerch('<%= l(:label_search_conditions_not_null) %>');" class="search_btn fl f14 c_white" >
<%= l(:label_search)%>
</a>

View File

@ -184,6 +184,11 @@ en:
label_anonymous: Anonymous #作业和留言 模块
text_are_you_sure: Are you sure? #js 提示
text_are_you_sure_out: 你确定要退出该课程吗?
text_are_you_sure_out_group: 你确定要退出该分班吗?
label_no_data: No data to display
# 项目、课程、用户公用

View File

@ -187,7 +187,8 @@ zh:
text_are_you_sure: 您确定要删除吗? #js 提示
text_are_you_sure_out: 你确定要退出该课程吗?
text_are_you_sure_out_group: 你确定要退出该分班吗?
label_no_data: 没有任何数据可供显示

View File

@ -4,7 +4,7 @@ en:
# 托管平台主页 > 底部承办单位
label_hosted_by: Organizer
label_hosted_organization: Organizer
label_hosted_by: National Key Laboratory for Parallel and Distributed Processing, NUDT
label_sponsor: Department of Computer Science and Technology, NUDT
label_co_organizer_NUDT: College of Computer, NUDT

View File

@ -6,10 +6,13 @@ en:
#
# 课程公共标签
#
label_course_join_student: 加入课程
label_course_new: 新建课程
label_homework: 课程作业
label_course_join_student: Join a course
label_course_exit_student: Exit a course
label_course_new: New course
label_course_name: Course name
label_homework: Task
label_course_news: 课程通知
label_main_teacher: 主讲教师
label_course_term: 开课学期

View File

@ -13,6 +13,7 @@ zh:
label_course_join_student: 加入课程
label_course_exit_student: 退出课程
label_course_new: 新建课程
label_course_name: 课程名称
label_homework: 课程作业
label_course_news: 课程通知

View File

@ -331,7 +331,7 @@ en:
# edit by meng
lable_hot_course: Hot Courses
label_course_join_student: Join a course
label_contest_modify_settings: Configuration
bale_news_notice: Add a notification
label_field_correct: correct input
@ -1259,11 +1259,11 @@ en:
#end
label_course: Course
label_course_new: New course
label_public_info: "If you don't choose public, only the project's members can see the project."
label_course_public_info: "If you don't choose public, only the course's members can see the course."
label_course_student: Student
label_homework: Task
label_course_new_homework: New homework
label_course_homework_list: Homework List
label_course_homework_new: new homework

View File

@ -15,7 +15,7 @@ en:
# top_menu 个人相关
label_my_course: My Course
label_my_message: Msgs
label_my_projects: My projects
label_my_projects: My projectsed
#

View File

@ -932,9 +932,7 @@ zh:
text_project_destroy_confirmation: 您确信要删除这个项目以及所有相关的数据吗?
text_subprojects_destroy_warning: "以下子项目也将被同时删除:%{value}"
text_workflow_edit: 选择角色和跟踪标签来编辑工作流程
text_are_you_sure: 您确定要删除吗?
text_are_you_sure_out: 你确定要退出该课程吗?
text_are_you_sure_out_group: 你确定要退出该分班吗?
text_journal_changed: "%{label} 从 %{old} 变更为 %{new}"
text_journal_set_to: "%{label} 被设置为 %{value}"
text_journal_deleted: "%{label} 已删除 (%{old})"