diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 93e0e9c4b..c22f9e4ab 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -32,6 +32,10 @@ class SettingsController < ApplicationController hidden_non_project = Setting.find_by_name("hidden_non_project") @text = (hidden_non_project && hidden_non_project.value == "0") ? l(:label_show_non_project) : l(:label_hidden_non_project) + #1隐藏了课程信息 0显示了课程信息 + hidden_courses = Setting.find_by_name("hidden_courses") + @text_1 = (hidden_courses && hidden_courses.value == "1") ? l(:label_show_courses) : l(:label_hidden_courses) + @notifiables = Redmine::Notifiable.all if request.post? && params[:settings] && params[:settings].is_a?(Hash) settings = (params[:settings] || {}).dup.symbolize_keys @@ -89,4 +93,22 @@ class SettingsController < ApplicationController redirect_to settings_url end + + #隐藏/显示课程信息 + def hidden_courses + @notifiable = Setting.find_by_name("hidden_courses") + if @notifiable + @notifiable.value == "1" ? @notifiable.value = 0 : @notifiable.value = 1 + @notifiable.save + else + @notifiable = Setting.new() + @notifiable.name = "hidden_courses" + @notifiable.value = 1 + @notifiable.save + end + + redirect_to settings_url + end end + + diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 5077ecab3..0d40bb946 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -185,49 +185,53 @@
<%= link_to "动态",user_activities_path(@user.id),:class => "homepageMenuText"%>
-
- <%= link_to '课程',{:controller => "users", :action => "user_courselist", :id => @user.id}, :class => "homepageMenuText" %> - - <% if is_current_user%> - <% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> -
-
- <% else%> - <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:style => "margin-right:10px;", :remote => true, :title => "加入课程"%> +
+ <% else%> + <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:style => "margin-right:10px;", :remote => true, :title => "加入课程"%> + <% end%> <% end%> - <% end%> - - <% if @user.courses.visible.count > 0 - course_order_ids = "(" + - CourseActivity.find_by_sql("SELECT c.course_id, updated_at FROM - (SELECT ca.course_id, MAX(ca.updated_at) AS updated_at FROM course_activities ca WHERE ca.course_id IN (" + @user.courses.visible.select('courses.id').map{|c| c.id}.join(',') + ") - GROUP BY ca.course_id) AS c - ORDER BY c.updated_at DESC limit 5").map {|c| c.course_id}.join(",") + ")" - courses = Course.where("id in #{course_order_ids}") - else - courses = [] + + <% if @user.courses.visible.count > 0 + course_order_ids = "(" + + CourseActivity.find_by_sql("SELECT c.course_id, updated_at FROM + (SELECT ca.course_id, MAX(ca.updated_at) AS updated_at FROM course_activities ca WHERE ca.course_id IN (" + @user.courses.visible.select('courses.id').map{|c| c.id}.join(',') + ") + GROUP BY ca.course_id) AS c + ORDER BY c.updated_at DESC limit 5").map {|c| c.course_id}.join(",") + ")" + courses = Course.where("id in #{course_order_ids}") + else + courses = [] + + end + %> + <%# courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %> +
+ +
+ <% end %> - end - %> - <%# courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %> -
- -
项目 diff --git a/app/views/settings/edit.html.erb b/app/views/settings/edit.html.erb index 798db291b..32e95db57 100644 --- a/app/views/settings/edit.html.erb +++ b/app/views/settings/edit.html.erb @@ -1,5 +1,6 @@

<%=l(:label_settings)%>

<%= link_to @text,settings_hidden_non_project_path,:id => "hidden_non_project",:style => "float: right;margin-right: 60px;margin-top: 9px;"%> +<%= link_to @text_1,settings_hidden_courses_path,:id => "hidden_courses",:style => "float: right;margin-right: 60px;margin-top: 9px;"%>
<%= render_tabs administration_settings_tabs %> diff --git a/app/views/settings/hidden_courses.js.erb b/app/views/settings/hidden_courses.js.erb new file mode 100644 index 000000000..b4d344a6c --- /dev/null +++ b/app/views/settings/hidden_courses.js.erb @@ -0,0 +1,5 @@ +<% if @notifiable.value == "0"%> +$("#hidden_courses").replaceWith("<%= escape_javascript(link_to '隐藏课程信息',settings_hidden_courses_path,:id => 'hidden_courses',:style => 'float: right;margin-right: 60px;margin-top: 9px;', :remote => true)%>"); +<% else%> +$("#hidden_courses").replaceWith("<%= escape_javascript(link_to '显示课程信息',settings_hidden_courses_path,:id => 'hidden_courses',:style => 'float: right;margin-right: 60px;margin-top: 9px;', :remote => true)%>"); +<% end%> \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 3cdcc2053..743090a4d 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -81,9 +81,11 @@
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>
-
- <%= link_to "代码查重", work_canrepeat_student_work_index_path(homework: activity.id, course_id: activity.course.id), class: 'c_blue test-program-btn',:remote => true %> -
+ <% if activity.homework_detail_manual.comment_status != 0 %> +
+ <%= link_to "代码查重", work_canrepeat_student_work_index_path(homework: activity.id, course_id: activity.course.id), class: 'c_blue test-program-btn',:remote => true %> +
+ <% end %> <% end %> <% if activity.homework_type == 2%>
diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 69d209df9..b7df824a4 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -65,7 +65,11 @@ <% case user_activity.act_type.to_s %> <% when 'HomeworkCommon' %> <%# cache (act) do %> - <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id,:course_activity => 0} %> + <% hidden_courses = Setting.find_by_name("hidden_courses") %> + <% unvisiable = hidden_courses && hidden_courses.value == "1"%> + <% if !unvisiable %> + <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id,:course_activity => 0} %> + <% end %> <%# end %> <% when 'News' %> <%# cache [act, act.comments.count] do %> diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 5d443af48..4bab8d98f 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -80,9 +80,11 @@
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>
-
- <%= link_to "代码查重", work_canrepeat_student_work_index_path(homework: homework_common.id, course_id: homework_common.course_id), class: 'c_blue test-program-btn',:remote => true %> -
+ <% if homework_common.homework_detail_manual.comment_status != 0 %> +
+ <%= link_to "代码查重", work_canrepeat_student_work_index_path(homework: homework_common.id, course_id: homework_common.course_id), class: 'c_blue test-program-btn',:remote => true %> +
+ <% end %> <% end %> <% if homework_common.homework_type == 2%>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 2fe9ab079..5470d2bf3 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -5,20 +5,24 @@
    • -
    • -
        -
      • 课程动态
      • -
      • <%= link_to "作业动态", {:controller => "users", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%> -
      • -
      • <%= link_to "通知动态", {:controller => "users", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%> - -
      • <%= link_to "论坛动态", {:controller => "users", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%> -
      • <%= link_to "问卷动态", {:controller => "users", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%> -
      • <%= link_to "课程留言", {:controller => "users", :action => "show", :type => "course_journals"}, :class =>"homepagePostTypeMessage postTypeGrey"%> - - -
      -
    • +
    • +
        + <% hidden_courses = Setting.find_by_name("hidden_courses") %> + <% unvisiable = hidden_courses && hidden_courses.value == "1"%> + <% if !unvisiable %> +
      • 课程动态
      • +
      • <%= link_to "作业动态", {:controller => "users", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%> +
      • +
      • <%= link_to "通知动态", {:controller => "users", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%> + +
      • <%= link_to "论坛动态", {:controller => "users", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%> +
      • <%= link_to "问卷动态", {:controller => "users", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%> +
      • <%= link_to "课程留言", {:controller => "users", :action => "show", :type => "course_journals"}, :class =>"homepagePostTypeMessage postTypeGrey"%> + + + <% end %> +
      +
      • 项目动态
      • diff --git a/config/locales/zh.yml b/config/locales/zh.yml index a9522a03b..d6f292d79 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -371,8 +371,8 @@ zh: permission_contest_attachments_download: 竞赛附件下载 permission_upload_attachments: 资源上传 - - + label_show_courses: 显示课程信息 + label_hidden_courses: 隐藏课程信息 label_user: 用户 label_user_plural: 用户列表 @@ -2126,4 +2126,4 @@ zh: label_resource_belongs_project: 所属项目 #edit yk - label_code_work_tests: 代码测试列表 + label_code_work_tests: 代码测试列表 diff --git a/config/routes.rb b/config/routes.rb index fcb3f5272..17857d3b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1089,6 +1089,7 @@ RedmineApp::Application.routes.draw do match 'settings/edit', :via => [:get, :post] match 'settings/plugin/:id', :to => 'settings#plugin', :via => [:get, :post], :as => 'plugin_settings' match 'settings/hidden_non_project', :via => [:get, :post] + match 'settings/hidden_courses', :via => [:get, :post] match 'sys/projects', :via => :get match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post diff --git a/config/settings.yml b/config/settings.yml index 611ba8138..bebf9ac94 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -267,6 +267,8 @@ please_chose: default: 请选择 hidden_non_project: default: 1 +hidden_courses: + default: 0 plugin_redmine_ckeditor: serialized: true default: --- !ruby/hash:ActiveSupport::HashWithIndifferentAccess