This commit is contained in:
huang 2015-08-14 08:55:18 +08:00
commit 0917030395
31 changed files with 442 additions and 246 deletions

View File

@ -124,47 +124,47 @@ class CoursesController < ApplicationController
@course_pages = Paginator.new @course_count, per_page_option, params['page']
# 课程的动态数
@course_activity_count=Hash.new
@courses_all.each do |course|
@course_activity_count[course.id]=0
end
case params[:course_sort_type]
when '0'
@courses = @courses_all.order("created_at desc")
@s_type = 0
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
@course_activity_count=get_course_activity @courses,@course_activity_count
when '1'
@courses = @courses_all.order("course_ac_para desc")
@s_type = 1
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
@course_activity_count=get_course_activity @courses,@course_activity_count
when '2'
@courses = @courses_all.order("watchers_count desc")
@s_type = 2
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
@course_activity_count=get_course_activity @courses,@course_activity_count
when '3'
@course_activity_count=get_course_activity @courses_all,@course_activity_count_array
@courses=handle_course @courses_all,@course_activity_count
@s_type = 3
@courses = @courses[@course_pages.offset, @course_pages.per_page]
else
@s_type = 0
@courses = @courses_all.order("created_at desc")
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
@course_activity_count=get_course_activity @courses,@course_activity_count
end
# @course_activity_count=Hash.new
# @courses_all.each do |course|
# @course_activity_count[course.id]=0
# end
#
# case params[:course_sort_type]
# when '0'
# @courses = @courses_all.order("created_at desc")
# @s_type = 0
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
#
# @course_activity_count=get_course_activity @courses,@course_activity_count
#
# when '1'
# @courses = @courses_all.order("course_ac_para desc")
# @s_type = 1
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
#
# @course_activity_count=get_course_activity @courses,@course_activity_count
#
# when '2'
# @courses = @courses_all.order("watchers_count desc")
# @s_type = 2
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
#
# @course_activity_count=get_course_activity @courses,@course_activity_count
#
# when '3'
# @course_activity_count=get_course_activity @courses_all,@course_activity_count_array
# @courses=handle_course @courses_all,@course_activity_count
# @s_type = 3
# @courses = @courses[@course_pages.offset, @course_pages.per_page]
#
# else
# @s_type = 0
# @courses = @courses_all.order("created_at desc")
# @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
#
# @course_activity_count=get_course_activity @courses,@course_activity_count
#
# end
end
respond_to do |format|
@ -663,92 +663,9 @@ class CoursesController < ApplicationController
end
def show
if params[:jump] && redirect_to_course_menu_item(@course, params[:jump])
return
end
@users_by_role = @course.users_by_role
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
@key = User.current.rss_key
#新增内容
@days = Setting.activity_days_default.to_i
if params[:from]
begin; @date_to = params[:from].to_date + 1; rescue; end
end
has = {
"show_course_files" => true,
"show_course_news" => true,
"show_course_messages" => true,
#"show_course_journals_for_messages" => true,
# "show_bids" => true,
# "show_homeworks" => 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
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
if @author.nil?
# 显示老师和助教的活动
# @authors = searchTeacherAndAssistant(@course)
@authors = course_all_member(@course)
events = []
key = "course_events_#{@course.id}".to_sym
if Rails.env.production? && Setting.course_cahce_enabled?
events = Rails.cache.read(key) || []
end
if events.empty?
@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
Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled?
end
else
# @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?
events = @activity.events
else
events = @activity.events(:is_public => 1)
end
end
@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
course_activities = @course.course_activities.order("created_at desc")
@canShowRealName = User.current.member_of_course? @course
@course_activities = paginateHelper course_activities,10
respond_to do |format|
format.html{render :layout => 'base_courses'}
format.api

View File

@ -86,8 +86,14 @@ class ProjectsController < ApplicationController
@project_pages = Project.project_entities.visible.like(params[:name]).page(params[:page]).per(10)
else
@project_pages = Project.project_entities.visible.page(params[:page] ).per(10)
@project_pages = Project.project_entities.visible.page(params[:page] ).per(10)
end
@projects = @project_pages.order("created_on desc")
@limit = 10#per_page_option
@project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count
@project_pages = Paginator.new @project_count, @limit, params['page']
respond_to do |format|
format.html {
render :layout => 'base'

View File

@ -118,7 +118,7 @@ class UsersController < ApplicationController
return
end
end
projects = @user.projects.visible.order("updated_on desc")
projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc")
if(params[:status] == '1')
projects = projects.where("projects.user_id = ?",@user.id)
elsif(params[:status] == '2')
@ -248,7 +248,7 @@ class UsersController < ApplicationController
return
end
end
courses = @user.courses.visible.order("created_at desc")
courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc")
if(params[:status] == '1')
courses = courses.where("endup_time >= ? or endup_time is null or endup_time=''",Time.now)
elsif(params[:status] == '2')

View File

@ -1812,7 +1812,7 @@ module ApplicationHelper
#获取用户未过期的课程
def get_user_course user
courses_doing = []
user.courses.each do |course|
user.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course|
if !course_endTime_timeout?(course)
courses_doing.push course
end
@ -2379,17 +2379,18 @@ module ApplicationHelper
notice.html_safe
end
def stantard_code
"// 这是一个C语言的样例程序
//
//
#老师C语言的标准代码
def c_stantard_code_teacher
"// 老师您好这是一个C语言的样例程序
//
//
// 123
// 347
//
// ... ...
//
//
// argv传入
//
// argv传入
//
#include <stdio.h> //引用必须头文件
int main(int argc, char** argv) {
@ -2398,6 +2399,77 @@ int main(int argc, char** argv) {
printf(\"%d\",a+b); //输出a+b
return 0;
}".html_safe
end
#老师C++语言的标准代码
def c_stantard_code_teacher_
"// 老师您好这是一个C++语言的样例程序
//
//
// 123
// 347
// ... ...
//
// argv传入
//
#include <iostream> //引用必须头文件
#include <cstdlib>
using namespace std;
int main(int argc, char** argv){
int a = atoi(argv[1]); //
int b = atoi(argv[2]); //
cout<<a+b; //a+b
return 0;
}".html_safe
end
#学生C语言的标准代码
def c_stantard_code_student
"// 同学好这是一个C语言的样例程序
//
//
// 123
// 347
// ... ...
//
// argv传入
//
#include <stdio.h> //引用必须头文件
int main(int argc, char** argv) {
int a = atoi(argv[1]); //
int b = atoi(argv[2]); //
printf(\"%d\",a+b); //输出a+b
return 0;
}".html_safe
end
#学生C++语言的标准代码
def c_stantard_code_student_
"// 同学好这是一个C++语言的样例程序
//
//
// 123
// 347
// ... ...
//
// argv传入
//
#include <iostream> //引用必须头文件
#include <cstdlib>
using namespace std;
int main(int argc, char** argv){
int a = atoi(argv[1]); //
int b = atoi(argv[2]); //
cout<<a+b; //a+b
return 0;
}".html_safe
end
end

View File

@ -676,4 +676,61 @@ module CoursesHelper
end
result
end
#生成课程相关动态的链接
def course_activity_link activity
# activity = CourseActivity.first
title = ""
url = ""
if activity.course_act
case activity.course_act_type
when "Course"
title = activity.course_act.name
url = course_path activity.course
when "HomeworkCommon"
title = "作业&nbsp;" + activity.course_act.name
url = student_work_index_path(:homework => activity.course_act.id)
when "News"
title = "通知公告&nbsp;" + activity.course_act.title
url = course_news_index_path(activity.course)
when "Attachment"
title = "课件&nbsp;" + activity.course_act.filename
url = course_files_path(activity.course)
when "Message"
title = "课程讨论区&nbsp;" + activity.course_act.subject
url = course_boards_path(activity.course,:parent_id => activity.course_act.parent_id ? activity.course_act.parent_id : activity.course_act.id, :topic_id => activity.course_act.id)
when "JournalsForMessage"
title = "留言&nbsp;" + activity.course_act.notes
url = course_feedback_path(activity.course)
when "Poll"
title = "问卷&nbsp;" + activity.course_act.polls_name
url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id)
end
end
link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb"
end
#课程动态的描述
def course_activity_desc activity
desc = ""
if activity.course_act
case activity.course_act_type
when "Course"
desc = ""
when "HomeworkCommon"
desc = activity.course_act.description
when "News"
desc = activity.course_act.description
when "Attachment"
desc = ""
when "Message"
desc = activity.course_act.content
when "JournalsForMessage"
desc = ""
when "Poll"
desc = activity.course_act.polls_description
end
end
desc.html_safe
end
end

View File

@ -27,6 +27,8 @@ class Attachment < ActiveRecord::Base
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
include UserScoreHelper
@ -71,8 +73,8 @@ class Attachment < ActiveRecord::Base
cattr_accessor :thumbnails_storage_path
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location
after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score
before_save :files_to_final_location,:act_as_course_activity
after_create :office_conver, :be_user_score,:act_as_forge_activity
after_update :office_conver, :be_user_score
after_destroy :delete_from_disk,:down_user_score
@ -552,4 +554,10 @@ class Attachment < ActiveRecord::Base
end
end
#课程动态公共表记录
def act_as_course_activity
if self.container_type == "Course" && self.course_acts.empty?
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id)
end
end
end

View File

@ -33,6 +33,10 @@ class Course < ActiveRecord::Base
has_many :student_works, :through => :homework_commons, :dependent => :destroy
has_many :course_groups, :dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
has_many :course_activities
acts_as_taggable
acts_as_nested_set :order => 'name', :dependent => :destroy
@ -44,7 +48,7 @@ class Course < ActiveRecord::Base
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
validates_length_of :description, :maximum => 10000
before_save :self_validate
after_create :create_board_sync
after_create :create_board_sync, :act_as_course_activity
before_destroy :delete_all_members
safe_attributes 'extra',
@ -310,6 +314,11 @@ class Course < ActiveRecord::Base
end
end
#课程动态公共表记录
def act_as_course_activity
self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id)
end
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
#def name
# read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)

View File

@ -0,0 +1,7 @@
class CourseActivity < ActiveRecord::Base
attr_accessible :user_id, :course_act_id,:course_act_type,:course_id
# 虚拟关联
belongs_to :course_act ,:polymorphic => true
belongs_to :course
belongs_to :user
end

View File

@ -13,17 +13,27 @@ class HomeworkCommon < ActiveRecord::Base
has_many :student_works, :dependent => :destroy
has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
acts_as_attachable
acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" },
:description => :description,
:author => :author,
:url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}}
after_create :act_as_activity, :send_mail
after_create :act_as_activity, :send_mail, :act_as_course_activity
after_destroy :delete_kindeditor_assets
def act_as_activity
self.acts << Activity.new(:user_id => self.user_id)
end
#课程动态公共表记录
def act_as_course_activity
if self.course
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id)
end
end
#删除对应的图片
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON

View File

@ -56,9 +56,11 @@ class JournalsForMessage < ActiveRecord::Base
acts_as_attachable
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_activity #huang
after_create :act_as_activity, :act_as_course_activity
after_create :reset_counters!
after_destroy :reset_counters!
after_save :be_user_score
@ -177,4 +179,11 @@ class JournalsForMessage < ActiveRecord::Base
def delete_kindeditor_assets
delete_kindeditor_assets_from_disk self.id,7
end
#课程动态公共表记录
def act_as_course_activity
if self.jour_type == 'Course'
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id)
end
end
end

View File

@ -32,6 +32,8 @@ class Message < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
@ -68,7 +70,7 @@ class Message < ActiveRecord::Base
after_update :update_messages_board
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
after_create :act_as_activity,:be_user_score,:act_as_forge_activity, :send_mail
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :send_mail
#before_save :be_user_score
scope :visible, lambda {|*args|
@ -186,6 +188,13 @@ class Message < ActiveRecord::Base
end
end
#课程动态公共表记录
def act_as_course_activity
if self.course
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id)
end
end
#更新用户分数 -by zjc
def be_user_score
#新建message且无parent的为发帖

View File

@ -28,6 +28,8 @@ class News < ActiveRecord::Base
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
@ -49,7 +51,7 @@ class News < ActiveRecord::Base
:author_key => :author_id
acts_as_watchable
after_create :act_as_activity,:act_as_forge_activity,:add_author_as_watcher, :send_mail
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:add_author_as_watcher, :send_mail
after_destroy :delete_kindeditor_assets
@ -121,6 +123,13 @@ class News < ActiveRecord::Base
end
end
#课程动态公共表记录
def act_as_course_activity
if self.course
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.course_id)
end
end
# Time 2015-03-31 13:50:54
# Author lizanle
# Description 删除news后删除对应的资源

View File

@ -8,7 +8,9 @@ class Poll < ActiveRecord::Base
has_many :users, :through => :poll_users #该文件被哪些用户提交答案过
# 添加课程的poll动态
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
after_create :act_as_activity
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
after_create :act_as_activity, :act_as_course_activity
acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" },
:description => :polls_description,
@ -27,4 +29,10 @@ class Poll < ActiveRecord::Base
self.acts << Activity.new(:user_id => self.user_id)
end
#课程动态公共表记录
def act_as_course_activity
if self.polls_type == "Course"
self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id)
end
end
end

View File

@ -61,8 +61,8 @@
<!--gcm-->
<p class="stats">
<%= content_tag('span', link_to("#{course_activity_count @course}", course_path(@course)), :class => "info") %>
<%= content_tag('span', l(:label_x_activity, :count => @course_activity_count[@course.id])) %>
<%= content_tag('span', link_to("#{@course.course_activities.count}", course_path(@course)), :class => "info") %>
<%= content_tag('span', l(:label_x_activity, :count => @course.course_activities.count)) %>
</p>
<!--gcm-->

View File

@ -1,83 +1,37 @@
<div class="project_r_h">
<% if @controller_name=='ActivityNotifys' %>
<a class="fl about_me" style="width:80px;" href="<%=course_path(@course)%>"><%= l(:label_activity)%></a>
<h2 class="fl project_h2" style="width:100px;">与我相关
<span class="c_orange f12" style="display:none;">(<font id="new_notify_count"><%=get_new_notify_count(@course,'Course')%></font>)</span>
</h2>
<div class="fr mt10 mr5 c_grey02">
<a class="c_dblue">
<label class="mr5" style="cursor:pointer;" data-href="<%= course_activity_notifys_path(@course) %>/chang_read_flag" nhname='nh_act_link_all'>全部标为已读</label>
</a>
</div>
<% else %>
<h2 class="fl project_h2"><%= l(:label_activity)%></h2>
<% if User.current.logged? %>
<a class="fl about_me" href="<%=course_activity_notifys_path(@course)%>">与我相关
<span class="c_orange f12" style="display:none;">(<font id="new_notify_count"><%=get_new_notify_count(@course,'Course')%></font>)</span>
</a>
<% end %>
<% end %>
</div>
<% if @events_by_day != nil && @events_by_day.size >0 %>
<% @events_by_day.keys.sort.reverse.each do |day| %>
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
<%@course_activities.each do |activity|%>
<div class="problem_main" nhname="container">
<a class="problem_pic fl">
<%= image_tag(url_to_avatar(e.event_author), :width => "42", :height => "42") %>
<%= image_tag(url_to_avatar(activity.user), :width => "42", :height => "42") %>
</a>
<div class="problem_txt fl mt5 upload_img">
<%= 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) %>
<%= link_to_user_header(activity.user,false,:class => 'problem_name c_orange fl') %>
<span class="fl"> &nbsp;</span>
<span class="fl"> <%= l(:label_new_activity) %></span>
<%
link = (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) :
(e.event_type.eql?("bid") ? homework_course_path(@course) :
(e.event_type.eql?("message") || e.event_type.eql?("reply") ?
course_boards_path(@course,:topic_id => e.id,:parent_id=>(e.parent_id ? e.parent_id : e.id)) : e.event_url))
%>
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), link,
<span class="fl"> <%= activity.course_act_type == "Course" ? "创建了课程" : l(:label_new_activity) %></span>
<%#= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), link,
:class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type,
'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link",
'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%>
<%if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%>
<span nhname="nh_act_flag" class="ml10 fl"><img src="/images/new.png" width="35" height="15"/></span>
<%end%>
<br />
<p class="mt5 break_word"><%= e.event_description.html_safe %>
<%#if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%>
<!--span nhname="nh_act_flag" class="ml10 fl"><img src="/images/new.png" width="35" height="15"/></span-->
<%#end%>
<%= link_to course_activity_link activity%>
<div class="cl"></div>
<p class="mt5 break_word">
<%= course_activity_desc activity%>
<br />
<div class="cl"></div>
<%= l :label_activity_time %> <%= format_activity_day(day) %>&nbsp;<%= format_time(e.event_datetime, false) %>
</p>
<%= link_to_attachments_course(e) if e.class.to_s == "News" %>
</div>
<div class="cl"></div>
</div><!--课程动态 end-->
<% end%>
<% end%>
<% elsif @controller_name=='ActivityNotifys' %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end%>
<% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %>
<div class="problem_main">
<a class="problem_pic fl">
<%= image_tag(url_to_avatar(@user), :width => "42", :height => "42") %>
</a>
<div class="problem_txt fl mt5">
<%= link_to_user_header(@user,false,:class => 'problem_name c_orange fl') %>
<%= link_to_user_header("(#{@user})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName %>
<span class="fl"> <%= l(:label_user_create_project) %></span>
<%= link_to @course.name,course_path(@course),:class => "problem_tit c_dblue fl fb"%>
<br />
<p class="mt5">
<br />
<%= l :label_create_time %> <%= format_time(@course.created_at) %>
<%= l :label_activity_time %> <%= format_time(activity.created_at) %>
</p>
<%= link_to_attachments_course(activity.course_act) if activity.course_act_type.to_s == "News" %>
</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

@ -56,7 +56,7 @@
<ul>
<li >
<label class="label02">&nbsp;开发语言:&nbsp;</label>
<%= select_tag :language,options_for_select(programing_languages_options,homework.homework_detail_programing.language.to_i), {:class => "fl mb10 h26 w70"} %>
<%= select_tag :language,options_for_select(programing_languages_options,homework.homework_detail_programing.language.to_i), {:class => "fl mb10 h26 w70",:onchange => "homework_language_change($(this));"} %>
<div class="cl"></div>
</li>
@ -78,7 +78,7 @@
<li >
<label class="label02">&nbsp;标准代码:&nbsp;</label>
<textarea name="standard_code" class=" w547 h350 mb10 fl" oninput="init_programing_test();" onpropertychange="init_programing_test()"><%= homework.homework_detail_programing.standard_code || stantard_code%></textarea>
<textarea name="standard_code" class=" w547 h400 mb10 fl" oninput="init_programing_test();" onpropertychange="init_programing_test()"><%= homework.homework_detail_programing.standard_code || c_stantard_code_teacher%></textarea>
<div class="cl"></div>
</li>
@ -173,4 +173,20 @@
$(this).next("input").val("");
});
}
function homework_language_change(obj)
{
if(obj.val() == "1")
{
// alert(1);
$("textarea[name='standard_code']").val("<%= escape_javascript c_stantard_code_teacher%>");
}
else if(obj.val() == "2")
{
// alert(2);
$("textarea[name='standard_code']").val("<%= escape_javascript c_stantard_code_teacher_%>");
}
}
</script>

View File

@ -18,7 +18,7 @@
<ul class="sub_menu">
<% if @show_course == 1 && !visiable %>
<% hasCourse=false %>
<% User.current.courses.each do |course| %>
<% User.current.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course| %>
<% if !course_endTime_timeout?(course) %>
<% hasCourse=true %>
<% break %>

View File

@ -26,7 +26,7 @@
<li>
<a href="<%= url_for(:controller => 'users', :action => 'user_courses', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的课程</a>
<ul>
<% User.current.courses.each do |course| %>
<% User.current.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course| %>
<% if !course_endTime_timeout?(course) %>
<li title="<%=course.name%>"><a href="<%= url_for(:controller => 'courses', :action=>"show", :id=>course.id, :host=>Setting.host_course) %>"><%= course.name %></a>
<% end %>
@ -41,8 +41,12 @@
<li>
<a href="<%= url_for(:controller => 'users', :action => 'user_projects', :id=>User.current.id, :host=>Setting.host_user) %>" class="parent">我的项目</a>
<ul>
<% User.current.projects.each do |project| %>
<li title="<%=project.name%>"><a href="<%= url_for(:controller => 'projects', :action=>"show", :id=>project.id, :host=>Setting.host_name) %>"><%=project.name%></a></li>
<% User.current.projects.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").each do |project| %>
<li title="<%=project.name%>">
<a href="<%= url_for(:controller => 'projects', :action=>"show", :id=>project.id, :host=>Setting.host_name) %>">
<%=project.name%>
</a>
</li>
<% end %>
</ul>
</li>

View File

@ -26,7 +26,7 @@
<li id="my_courses_li">
<%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id},target:"_blank", :class => "parent" %>
<ul id="my_courses_ul">
<% user_course.reverse.each do |course| %>
<% user_course.each do |course| %>
<li title="<%=course.name%>">
<%= link_to course.name, {:controller => 'courses',:action => 'show',:id => course.id},target:"_blank" %>
</li>
@ -40,7 +40,7 @@
<li id="my_projects_li">
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name},target:"_blank", :class => "parent" %>
<ul id="my_projects_ul" >
<% User.current.projects.reverse.each do |project| %>
<% User.current.projects.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").each do |project| %>
<li title="<%=project.name%>">
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name }, target:"_blank" %>
</li>

View File

@ -4,7 +4,7 @@
<ul class="course_sub_menu">
<% course_index = 0 %>
<% User.current.courses.reverse.each do |course| %>
<% User.current.courses.each do |course| %>
<% if !course_endTime_timeout?(course) %>
<%= render :partial => 'layouts/user_homework_list', :locals => {:course => course,:course_index => course_index} %>
<% course_index += 1 %>

View File

@ -2,7 +2,7 @@
<li id="project_loggedas_li" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.host_name} %>
<ul class="project_sub_menu" style="top:<%= hasCourse ? 35 : 0 %>px;">
<% User.current.projects.reverse.each do |project| %>
<% User.current.projects.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").each do |project| %>
<li style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;" title="<%=project.name%>">
<%= link_to project.name, {:controller => 'projects', :action => 'show',id: project.id, host: Setting.host_name } %>
</li>

View File

@ -113,7 +113,7 @@
<div class="subNav">
<%= link_to l(:label_activity), course_path(@course), :class => "f14 c_blue02" %>
<!--暂时不显示课程动态数,优化后在显示-->
<%= link_to "(#{course_activity_count @course})", course_path(@course), :class => "subnav_num c_orange"%>
<%= link_to "(#{@course.course_activities.count})", course_path(@course), :class => "subnav_num c_orange"%>
</div>
<div class="subNav">
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>

View File

@ -104,9 +104,13 @@
</div>
<% end %>
<div class="pagination">
<ul>
<%= pagination_links_full @project_pages, @project_count %>
</ul>
</div>
<%= paginate @project_pages %>
<%#= paginate @project_pages %>

View File

@ -54,8 +54,8 @@
<%= @homework.homework_type == 2 ? "提交代码" : "作品描述"%>
&nbsp;&nbsp;&nbsp;
</label>
<% if @homework.homework_type == 2%>
<%= f.text_area "description", :class => "w620 hwork_txt h350", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => stantard_code%>
<% if @homework.homework_type == 2 && @homework.homework_detail_programing%>
<%= f.text_area "description", :class => "w620 hwork_txt h400", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => @homework.homework_detail_programing.language == "1" ? c_stantard_code_student : c_stantard_code_student_%>
<% else %>
<%= f.text_area "description", :class => "w620 hwork_txt", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%>
<% end%>

View File

@ -23,8 +23,19 @@
</tr>
<tr>
<td colspan="2">
<%= l(:label_x_has_fans,:count=>user.watcher_users.count)%>
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
<%= l(:label_x_has_fans,:count=>user.watcher_users.count, :remote => true)%>
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count, :remote => true) %>
<% if User.current.logged?%>
<% if User.current == user%>
<a href="<%= url_for(:controller => 'my', :action => 'account') %>" class="fr gz_btn mr10 ">编辑资料</a>
<%else%>
<%if(user.watched_by?(User.current))%>
<a id="user_watch_id" href="<%= watch_path(:object_type=> 'user',:object_id=>user.id,:target_id=>user.id) %>" class="fr qx_btn mr10" data-method="delete" data-remote="true" title="取消关注">取消关注</a>
<% else %>
<a id="user_watch_id" href="<%= watch_path(:object_type=>'user',:object_id=>user.id,:target_id=>user.id) %>" class="fr gz_btn mr10" data-method="post" data-remote="true" title="添加关注">添加关注</a>
<% end %>
<% end%>
<% end %>
</td>
</tr>
</table>

View File

@ -690,7 +690,7 @@ zh:
label_sort_lowest: 置底
label_roadmap_due_in: "截止日期到 %{value}"
label_roadmap_overdue: "%{value} 延期"
label_roadmap_no_issues: 该版本还没有对应的缺陷,可以在“发布问题”的“目标版本”中设置
label_roadmap_no_issues: 该版本还没有对应的缺陷,可以在“发布问题”的“目标版本”中指定版本
label_user_search_type: 搜索类型
label_search_by_login: 登录名
label_search_by_name: 名字

View File

@ -0,0 +1,15 @@
class AddCourseActivities < ActiveRecord::Migration
def up
create_table :course_activities do |t|
t.integer :user_id
t.integer :course_id
t.integer :course_act_id
t.string :course_act_type
t.timestamps
end
end
def down
drop_table :course_activities
end
end

View File

@ -0,0 +1,40 @@
#encoding=UTF-8
class CourseActivities < ActiveRecord::Migration
def up
Course.all.each do |course|
transaction do
course.course_acts << CourseActivity.new(:user_id => course.tea_id,:course_id => course.id)
#作业
course.homework_commons.each do |homework_common|
homework_common.course_acts << CourseActivity.new(:user_id => homework_common.user_id,:course_id => course.id)
end
#通知
course.news.each do |new|
new.course_acts << CourseActivity.new(:user_id => new.author_id,:course_id => course.id)
end
#资源
course.attachments.each do |attachment|
attachment.course_acts << CourseActivity.new(:user_id => attachment.author_id,:course_id => course.id)
end
#讨论区
if course.boards.first
course.boards.first.messages.each do |message|
message.course_acts << CourseActivity.new(:user_id => message.author_id,:course_id => course.id)
end
end
#留言
course.journals_for_messages.each do |jour|
jour.course_acts << CourseActivity.new(:user_id => jour.user_id,:course_id => course.id)
end
#问卷
Poll.where("polls_type = 'Course' and polls_group_id = #{course.id}").each do |poll|
poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => course.id)
end
end
end
end
def down
CourseActivity.destroy_all
end
end

View File

@ -0,0 +1,22 @@
class UpdateCourseActivityTime < ActiveRecord::Migration
def up
count = CourseActivity.all.count / 10 + 1
transaction do
for i in 1 ... count do i
CourseActivity.page(i).per(10).each do |activity|
if activity.course_act
if activity.course_act.respond_to?("created_at")
activity.created_at = activity.course_act.created_at
elsif activity.course_act.respond_to?("created_on")
activity.created_at = activity.course_act.created_on
end
activity.save
end
end
end
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150801034945) do
ActiveRecord::Schema.define(:version => 20150811083234) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -324,6 +324,15 @@ ActiveRecord::Schema.define(:version => 20150801034945) do
t.datetime "updated_on", :null => false
end
create_table "course_activities", :force => true do |t|
t.integer "user_id"
t.integer "course_id"
t.integer "course_act_id"
t.string "course_act_type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "course_attachments", :force => true do |t|
t.string "filename"
t.string "disk_filename"

View File

@ -55,7 +55,7 @@ a:hover.problem_pic{border:1px solid #64bdd9;}
.problem_txt{ width:610px; margin-left:10px; color:#777777;word-break: break-all;word-wrap: break-word;}
a.problem_name{ color:#ff5722;max-width:60px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
a:hover.problem_name{ color:#d33503;}
a.problem_tit{ color:#0781b4; max-width:410px; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;}
a.problem_tit{ color:#0781b4; max-width:410px; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;vertical-align: top;}
a.pro_mes_w{ height:20px; float:right;display:block; color:#999999;}
a:hover.problem_tit{ color:#09658c; }
.problem_main{ border-bottom:1px dashed #d4d4d4; padding-bottom:10px; margin-bottom:10px;}
@ -226,7 +226,7 @@ a:hover.ping_sub{ background:#14a8b9;}
.w430{ width:470px;}
.w557{ width:557px;}
.w350{ width:350px;}
.h350{height: 350px !important;}
.h400{height: 400px !important;}
.w620{ width:480px; height:160px; border:1px solid #CCC;}
.bo{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:470px; }
.bo02{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:480px; margin-left:2px; color: #999; }