diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5933a83a9..a12fa37e4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -305,10 +305,11 @@ class UsersController < ApplicationController #用户作业列表 def user_homeworks + @page = params[:page] ? params[:page].to_i + 1 : 0 user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" - homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc") - @homework_commons = paginateHelper homework_commons,10 + @homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10) respond_to do |format| + format.js format.html {render :layout => 'new_base_user'} end end @@ -551,12 +552,33 @@ class UsersController < ApplicationController end def show - @page = (params[:page] || -1).to_i + 1 - user_project_ids = "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" - user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" - @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids}) or (container_type = 'Course' and container_id in #{user_course_ids})").order('created_at desc').limit(10).offset(@page * 10) + @page = params[:page] ? params[:page].to_i + 1 : 0 + @type = params[:type] + user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" + user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" + if @type + case @type + when "course_homework" + @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('created_at desc').limit(10).offset(@page * 10) + when "course_news" + @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'News'").order('created_at desc').limit(10).offset(@page * 10) + when "course_message" + @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10) + when "project_issue" + @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('created_at desc').limit(10).offset(@page * 10) + when "project_message" + @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10) + end + else + course_types = "('Message','News','HomeworkCommon')" + project_types = "('Message','Issue')" + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) + end # @user_activities = paginateHelper @user_activities,500 - render :layout=>'new_base_user' + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end end def show_old diff --git a/app/views/users/_course_attachment.html.erb b/app/views/users/_course_attachment.html.erb new file mode 100644 index 000000000..d58ef5655 --- /dev/null +++ b/app/views/users/_course_attachment.html.erb @@ -0,0 +1,39 @@ +
+
+
+ + <%= link_to image_tag(url_to_avatar(activity.author), :width => "90", :height => "90"), user_path(activity.author_id), :alt => "用户头像" %> +
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.course.name.to_s+"(课程名称)", course_path(activity.container_id), :class => "newsBlue ml15", :style=>"word-break:break-all" %> + +
+ +
+
时间:<%= format_date(activity.created_on) %>
+
+
(附件描述)<%=activity.description.to_s%>
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/users/_course_create.html.erb b/app/views/users/_course_create.html.erb new file mode 100644 index 000000000..4d26b523a --- /dev/null +++ b/app/views/users/_course_create.html.erb @@ -0,0 +1,29 @@ +
+
+
+ 用户头像
+
+ + +
+ +
截止时间:2015-08-20
+
+
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb new file mode 100644 index 000000000..6b53d44eb --- /dev/null +++ b/app/views/users/_course_journalsformessage.html.erb @@ -0,0 +1,29 @@ +
+
+
+ 用户头像
+
+ + +
+ +
截止时间:2015-08-20
+
+
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/users/_course_poll.html.erb b/app/views/users/_course_poll.html.erb new file mode 100644 index 000000000..f76b6d0ae --- /dev/null +++ b/app/views/users/_course_poll.html.erb @@ -0,0 +1,39 @@ +
+
+
+ + <%= link_to image_tag(url_to_avatar(activity.user), :width => "90", :height => "90"), user_path(activity.user_id), :alt => "用户头像" %> +
+
+
+ <% if activity.try(:user).try(:realname) == ' ' %> + <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to Course.find(activity.polls_group_id).name.to_s+"(课程名称)", course_path(activity.polls_group_id), :class => "newsBlue ml15", :style=>"word-break:break-all" %> + +
+ +
+
时间:<%= format_date(activity.created_at) %>
+
+
(问卷描述)<%=activity.polls_description.to_s%>
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/users/_project_attachment.html.erb b/app/views/users/_project_attachment.html.erb new file mode 100644 index 000000000..742d9acd4 --- /dev/null +++ b/app/views/users/_project_attachment.html.erb @@ -0,0 +1,29 @@ +
+
+
+ 用户头像
+
+ + +
+ +
截止时间:2015-08-20
+
+
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/users/_project_create.html.erb b/app/views/users/_project_create.html.erb new file mode 100644 index 000000000..795c8f2a8 --- /dev/null +++ b/app/views/users/_project_create.html.erb @@ -0,0 +1,29 @@ +
+
+
+ 用户头像
+
+ + +
+ +
截止时间:2015-08-20
+
+
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/users/_project_document.html.erb b/app/views/users/_project_document.html.erb new file mode 100644 index 000000000..082963d36 --- /dev/null +++ b/app/views/users/_project_document.html.erb @@ -0,0 +1,29 @@ +
+
+
+ 用户头像
+
+ + +
+ +
截止时间:2015-08-20
+
+
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/users/_project_journal.html.erb b/app/views/users/_project_journal.html.erb new file mode 100644 index 000000000..f16b09c66 --- /dev/null +++ b/app/views/users/_project_journal.html.erb @@ -0,0 +1,29 @@ +
+
+
+ 用户头像
+
+ + +
+ +
截止时间:2015-08-20
+
+
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb new file mode 100644 index 000000000..8bc1b5422 --- /dev/null +++ b/app/views/users/_project_news.html.erb @@ -0,0 +1,29 @@ +
+
+
+ 用户头像
+
+ + +
+ +
截止时间:2015-08-20
+
+
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
+ +
+
+
+
\ No newline at end of file diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb new file mode 100644 index 000000000..60992c384 --- /dev/null +++ b/app/views/users/_user_activities.html.erb @@ -0,0 +1,44 @@ +<% user_activities.each do |user_activity| + unless user_activities.nil? %> + <% act= user_activity.act unless user_activity.act_type == "ProjectCreateInfo" %> + <% case user_activity.container_type.to_s %> + <% when 'Course' %> + <% if act %> + <% case user_activity.act_type.to_s %> + <% when 'HomeworkCommon' %> + <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity =>user_activity} %> + <% when 'News' %> + <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity =>user_activity} %> + <% when 'Message'%> + <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity =>user_activity} %> + <%# when 'Course'%> + <%#= render :partial => 'course_create', :locals => {:activity => act,:user_activity =>user_activity} %> + <%# when 'Attachment' %> + <%#= render :partial => 'course_attachment', :locals => {:activity => act, :user_activity => user_activity} %> + <%# when 'JournalsForMessage' %> + <%#= render :partial => 'course_journalsformessage', :locals => {:activity => act, :user_activity => user_activity} %> + <%# when 'Poll' %> + <%#= render :partial => 'course_poll', :locals => {:activity => act, :user_activity => user_activity} %> + <% end %> + <% end %> + <% when 'Project' %> + <% case user_activity.act_type.to_s %> + <% when 'Issue' %> + <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity =>user_activity} %> + <% when 'Message' %> + <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity =>user_activity} %> + <%# when 'Journal' %> + <%#= render :partial => 'project_journal', :locals => {:activity => act,:user_activity =>user_activity} %> + <%# when 'News' %> + <%#= render :partial => 'project_news', :locals => {:activity => act,:user_activity =>user_activity} %> + <%# when 'Document' %> + <%#= render :partial => 'project_document', :locals => {:activity => act,:user_activity =>user_activity} %> + <%# when 'Attachment' %> + <%#= render :partial => 'project_attachment', :locals => {:activity => act,:user_activity =>user_activity} %> + <%# when 'ProjectCreateInfo' %> + <%#= render :partial => 'project_create', :locals => {:activity => act,:user_activity =>user_activity} %> + <% end %> + <% end %> + <% end %> +<% end %> + \ No newline at end of file diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb new file mode 100644 index 000000000..6476f9e71 --- /dev/null +++ b/app/views/users/_user_homework_list.html.erb @@ -0,0 +1,55 @@ +<% homework_commons.each do |homework_common|%> + <% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %> +
+
+
+ <%=link_to image_tag(url_to_avatar(homework_common.user),width:"90px", height: "90px"), user_activities_path(homework_common.user.id)%> +
+
+
+ <%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%> + TO + <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%> +
+
+ <%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%> +
+ +
+
+ <%= user_for_homework_common homework_common,is_teacher %> +
+
+ <%= l(:label_end_time)%>:<%= homework_common.end_time%> +
+
+
+ <%= homework_common.description.html_safe %> +
+
+ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %> +
+
+ <% if is_teacher%> +
+
    +
  • +
      +
    • + <%= link_to l(:button_edit),edit_homework_common_path(homework_common), :class => "postOptionLink"%> +
    • +
    • + <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> +
    • +
    +
  • +
+
+ <% end%> +
+
+
+
+<% end%> + + \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index b30a51c4b..d0e8351ee 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,3 +1,20 @@ + + +
最新动态
@@ -7,17 +24,22 @@
    • 课程动态
    • -
    • 作业动态
    • -
    • 通知动态
    • -
    • 论坛动态
    • +
    • <%= link_to "作业动态", {:controller => "users", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%> +
    • +
    • <%= link_to "通知动态", {:controller => "users", :action => "show", :type => "course_news"}, :class => "homepagePostTypeAssignment postTypeGrey"%> + +
    • <%= link_to "论坛动态", {:controller => "users", :action => "show", :type => "course_message"}, :class => "homepagePostTypeAssignment postTypeGrey"%> +
    • 项目动态
    • -
    • 问题动态
    • -
    • 论坛动态
    • +
    • <%= link_to "问题动态", {:controller => "users", :action => "show", :type => "project_issue"}, :class => "homepagePostTypeAssignment postTypeGrey"%> +
    • <%= link_to "论坛动态", {:controller => "users", :action => "show", :type => "project_message"}, :class => "homepagePostTypeAssignment postTypeGrey"%> +
  • @@ -25,30 +47,5 @@
    -<% @user_activities.each do |user_activity| - unless @user_activities.nil? %> - <% act= user_activity.act %> - <% case user_activity.act_type.to_s %> - <% when 'CourseActivity' %> - <% if act %> - <% activity= act.course_act %> - <% case act.course_act_type.to_s %> - <% when 'HomeworkCommon' %> - <%= render :partial => 'course_homework', :locals => {:activity => activity,:user_activity =>user_activity} %> - <% when 'News' %> - <%= render :partial => 'course_news', :locals => {:activity => activity,:user_activity =>user_activity} %> - <% when 'Message'%> - <%= render :partial => 'course_message', :locals => {:activity => activity,:user_activity =>user_activity} %> - <% end %> - <% end %> - <% when 'ForgeActivity' %> - <% activity= act.forge_act unless act.forge_act_type == "ProjectCreateInfo" %> - <% case act.forge_act_type.to_s %> - <% when 'Issue' %> - <%= render :partial => 'project_issue', :locals => {:activity => activity,:user_activity =>user_activity} %> - <% when 'Message' %> - <%= render :partial => 'project_message', :locals => {:activity => activity,:user_activity =>user_activity} %> - <% end %> - <% end %> -<% end %> -<% end %> \ No newline at end of file + +<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => @page} %> \ No newline at end of file diff --git a/app/views/users/show.js.erb b/app/views/users/show.js.erb new file mode 100644 index 000000000..0ce84cf0e --- /dev/null +++ b/app/views/users/show.js.erb @@ -0,0 +1,4 @@ +$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page} )%>"); +<% if @user_activities.count < 10%> +$(window).off("scroll", scrollHandler); +<% end%> diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index a6032a60b..19ecf3588 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -1,3 +1,18 @@ + + <% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%>
    @@ -42,56 +57,4 @@
    <% end%> -<% @homework_commons.each do |homework_common|%> - <% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %> -
    -
    -
    - <%=link_to image_tag(url_to_avatar(homework_common.user),width:"90px", height: "90px"), user_activities_path(homework_common.user.id)%> -
    -
    -
    - <%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%> - TO - <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%> -
    -
    - <%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%> -
    - -
    -
    - <%= user_for_homework_common homework_common,is_teacher %> -
    -
    - <%= l(:label_end_time)%>:<%= homework_common.end_time%> -
    -
    -
    - <%= homework_common.description.html_safe %> -
    -
    - <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %> -
    -
    - <% if is_teacher%> -
    -
      -
    • -
        -
      • - <%= link_to l(:button_edit),edit_homework_common_path(homework_common), :class => "postOptionLink"%> -
      • -
      • - <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> -
      • -
      -
    • -
    -
    - <% end%> -
    -
    -
    -
    -<% end%> +<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0} %> diff --git a/app/views/users/user_homeworks.js.erb b/app/views/users/user_homeworks.js.erb new file mode 100644 index 000000000..a2e778a21 --- /dev/null +++ b/app/views/users/user_homeworks.js.erb @@ -0,0 +1,4 @@ +$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page} )%>"); +<% if @homework_commons.count < 10%> + $(window).off("scroll", scrollHandler); +<% end%> diff --git a/db/schema.rb b/db/schema.rb index 1c77ff04b..4639c07ec 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -474,13 +474,6 @@ ActiveRecord::Schema.define(:version => 20150820025358) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -903,6 +896,7 @@ ActiveRecord::Schema.define(:version => 20150820025358) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" + t.datetime "updated_on" end add_index "news", ["author_id"], :name => "index_news_on_author_id" diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index a526b0266..fb16d39c5 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -578,7 +578,7 @@ a.postOptionLink:hover {color:#ffffff; background-color:#15bccf;} .homepagePostReplyDes {float:left; width:595px; margin-left:15px;} .homepagePostReplyPublisher {font-size:12px; color:#484848; margin-bottom:12px;} .homepagePostReplyContent {font-size:12px; color:#484848; margin-bottom:12px;} -.homepagePostProjectState {width:42px; height:20px; line-height:20px; border-radius:1px; background-color:#28be6c; color:#ffffff; text-align:center; vertical-align:middle; font-size:12px; display:inline-block; margin-left:5px;} +.homepagePostProjectState {width:52px; height:20px; line-height:20px; border-radius:1px; background-color:#28be6c; color:#ffffff; text-align:center; vertical-align:middle; font-size:12px; display:inline-block; margin-left:5px;} .homepagePostAssignTo {float:left; font-size:14px; color:#15bccf; height:30px; line-height:30px; vertical-align:middle;} .homepagePostFileAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/homepage_icon.png) -85px -150px no-repeat; padding-left:35px; font-size:14px; margin-right:25px;} .homepagePostImageAtt {height:22px; line-height:22px; vertical-align:middle; background:url(../images/homepage_icon.png) -86px -195px no-repeat; padding-left:35px; font-size:14px; margin-right:25px;}