diff --git a/Gemfile b/Gemfile index 1305320cf..cbeade2a3 100644 --- a/Gemfile +++ b/Gemfile @@ -50,10 +50,10 @@ gem 'elasticsearch-model' gem 'elasticsearch-rails' #rails 3.2.22.2 bug - # gem "test-unit", "~>3.0" + gem "test-unit", "~>3.0" ### profile - # gem 'oneapm_rpm' + gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e0fa253b3..559f29235 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1691,9 +1691,12 @@ class UsersController < ApplicationController when "current_user" container_type = 'Principal' act_type = 'Principal' + when "all" + container_type = 'all' + act_type = 'all' end end - if container_type != '' && act_type != '' + if container_type != '' && container_type != 'all' if container_type == 'Course' sql = "container_type = '#{container_type}' and container_id in #{user_course_ids} and act_type = '#{act_type}'" elsif container_type == 'Project' @@ -1709,69 +1712,19 @@ class UsersController < ApplicationController else if User.current != @user blog_ids = "("+@user.blog.id.to_s+")" - sql = "user_id = #{@user.id} and((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}) "+ - "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + - "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids}))" else blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" - sql = "(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}) "+ - "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + - "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})" + end + sql = "(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}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})" + if container_type != 'all' && User.current != @user + sql = "user_id = #{@user.id} and(" + sql + ")" end end + @user_activities = UserActivity.where("#{sql}").order('updated_at desc').limit(10).offset(@page * 10) - # if params[:type].present? - # case params[:type] - # when "course_homework" - # @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('updated_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('updated_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('updated_at desc').limit(10).offset(@page * 10) - # when "course_poll" - # @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page * 10) - # when "course_journals" - # @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'JournalsForMessage'").order('updated_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('updated_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('updated_at desc').limit(10).offset(@page * 10) - # when "user_journals" - # @user_activities = UserActivity.where("container_type = 'Principal' and act_type= 'JournalsForMessage' and container_id = #{@user.id}").order('updated_at desc').limit(10).offset(@page * 10) - # when "current_user" - # @user_activities = UserActivity.where("user_id = #{@user.id} and ((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('updated_at desc').limit(10).offset(@page * 10) - # else - # if @user == User.current - # blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" - # else - # blog_ids = "("+@user.blog.id.to_s+")" - # end - # @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}) "+ - # "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + - # "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10) - # end - # else - # # @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})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10) - # # blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" - # # 减少数据库交互 - # if @user == User.current - # watched_user_ids = User.watched_by(@user.id).count == 0 ? " " : ("," + User.watched_by(@user.id).map{|u| u.id.to_s }.join(',')) - # user_ids = "(" + @user.id.to_s + watched_user_ids + ")" - # else - # user_ids = "(" + @user.id.to_s + ")" - # end - # watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}") - # blog_ids = watched_user_blog_ids.empty? ? "(-1)" : "(" + watched_user_blog_ids.map { |blog| blog.id}.join(",") + ")" - # - # @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}) "+ - # "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + - # "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10) - # end - # @user_activities = paginateHelper @user_activities,500 @type = params[:type] respond_to do |format| format.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3c125a185..c1d6950fa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3420,6 +3420,43 @@ def get_hw_index(hw,is_teacher) return index end +def get_hw_status homework_common + str = "" + if homework_common.homework_detail_manual + if homework_common.homework_detail_manual.comment_status == 0 && homework_common.publish_time.nil? + str += '挂起' + elsif homework_common.homework_detail_manual.comment_status == 0 + str += '未发布' + elsif homework_common.homework_detail_manual.comment_status == 1 + if homework_common.anonymous_comment == 0 + str += '未开启匿评' + else + str += '匿评已禁用' + end + if Time.parse(homework_common.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") + str += '作品提交中' + elsif Time.parse(homework_common.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") + str += '作品补交中' + end + elsif homework_common.homework_detail_manual.comment_status == 2 + if homework_common.anonymous_comment == 0 + str += '匿评中' + else + str += '匿评已禁用' + end + str += '教师评阅中' + elsif homework_common.homework_detail_manual.comment_status == 3 + if homework_common.anonymous_comment == 0 + str += '匿评已结束' + else + str += '匿评已禁用' + end + str += '教师评阅中' + end + end + str +end + def get_group_member_names work result = "" unless work.nil? diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 398fb8510..bc52b0002 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -162,17 +162,17 @@ module UsersHelper end def current_time_and_term_resource course - str = "" + str = course.syllabus.title + " · " term = cur_course_term_resource name = course.name if (course.time == course.end_time && course.term == course.end_term) || (course.end_term.nil? && course.end_time.nil?) || course.time > Time.now.year - str = name + "(" + course.time.to_s + course.term.to_s + ")" + str = str + name + "(" + course.time.to_s + course.term.to_s + ")" elsif course.time == Time.now.year && set_term_value(cur_course_term) <= set_term_value(course.term) - str = name + "(" + course.time.to_s + course.term.to_s + ")" + str = str + name + "(" + course.time.to_s + course.term.to_s + ")" elsif course.end_time < Time.now.year || (course.end_time == Time.now.year && set_term_value(cur_course_term) >= set_term_value(course.term)) - str = name + "(" + course.end_time.to_s + course.end_term.to_s + ")" + str = str + name + "(" + course.end_time.to_s + course.end_term.to_s + ")" else - str = name + "(" + Time.now.year.to_s + cur_course_term_resource.to_s + ")" + str = str + name + "(" + Time.now.year.to_s + cur_course_term_resource.to_s + ")" end str end diff --git a/app/views/admin/syllabuses.html.erb b/app/views/admin/syllabuses.html.erb index 5098131da..d24f7d39a 100644 --- a/app/views/admin/syllabuses.html.erb +++ b/app/views/admin/syllabuses.html.erb @@ -58,7 +58,7 @@ <%= format_date(syllabus.created_at) %> - <% courses = syllabus.courses %> + <% courses = syllabus.courses.not_deleted %> <% courses.each do |course| %> diff --git a/app/views/blogs/index.html.erb b/app/views/blogs/index.html.erb index f473ab534..8ad845c16 100644 --- a/app/views/blogs/index.html.erb +++ b/app/views/blogs/index.html.erb @@ -1,193 +1,192 @@ - - -<%= import_ke(enable_at: false, prettify: false) %> - - -<%= render :partial => 'blogs/article_list', :locals => {:blog=>@user.blog,:topics => @topics, :page => 0, :user => @user} %> - - - - + + +<%= import_ke(enable_at: false, prettify: false) %> + + +<%= render :partial => 'blogs/article_list', :locals => {:blog=>@user.blog,:topics => @topics, :page => 0, :user => @user} %> + + + + diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 6cc755b61..ac50c0ee9 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -1,7 +1,6 @@ - -<% end%> + + -- + +   + + <% if exercise.created_at%> + <%= Time.parse(format_time(exercise.created_at)).strftime("%m-%d %H:%M")%>  + <% if @exercise.end_time <= exercise.created_at %> + [未答] + <% end %> + <% end %> + + + <%= exercise.score.nil? ? "--" : format("%.1f",exercise.score)%> + +
+ + + + +<% end%> \ No newline at end of file diff --git a/app/views/layouts/_course_base_info.html.erb b/app/views/layouts/_course_base_info.html.erb index 65c065672..cc15b6101 100644 --- a/app/views/layouts/_course_base_info.html.erb +++ b/app/views/layouts/_course_base_info.html.erb @@ -18,7 +18,7 @@