diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb
index 6d68d549a..08c7adf10 100644
--- a/app/api/mobile/apis/courses.rb
+++ b/app/api/mobile/apis/courses.rb
@@ -80,6 +80,10 @@ module Mobile
class_period: params[:class_period]
}
course = ::Course.find(params[:course_id])
+ # 如果没有传密码过来,那就把原来的密码给上,不然会不更新
+ if params[:password].nil? || params[:password].blank?
+ cs_params[:course][:password] = course[:password]
+ end
cs.edit_course_authorize(current_user,course)
course = cs.edit_course(cs_params, course,current_user)
present :data, course, with: Mobile::Entities::Course
diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb
index c60d1bd8f..93e0e9c4b 100644
--- a/app/controllers/settings_controller.rb
+++ b/app/controllers/settings_controller.rb
@@ -29,6 +29,9 @@ class SettingsController < ApplicationController
end
def edit
+ 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)
+
@notifiables = Redmine::Notifiable.all
if request.post? && params[:settings] && params[:settings].is_a?(Hash)
settings = (params[:settings] || {}).dup.symbolize_keys
@@ -70,4 +73,20 @@ class SettingsController < ApplicationController
rescue Redmine::PluginNotFound
render_404
end
+
+ #隐藏/显示非项目信息
+ def hidden_non_project
+ @notifiable = Setting.find_by_name("hidden_non_project")
+ if @notifiable
+ @notifiable.value == "1" ? @notifiable.value = 0 : @notifiable.value = 1
+ @notifiable.save
+ else
+ @notifiable = Setting.new()
+ @notifiable.name = "hidden_non_project"
+ @notifiable.value = 0
+ @notifiable.save
+ end
+
+ redirect_to settings_url
+ end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index f36e4b397..095d0ada5 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -132,9 +132,10 @@ module ApplicationHelper
def link_to_user_header user,canShowRealName=false,options={}
if user.is_a?(User)
if canShowRealName
- name = h(user.realname(options[:format]))
+ name = user.show_name
+ name = user.login if name == ""
else
- name = h(user.name(options[:format]))
+ name = user.login
end
link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => options[:class]
else
@@ -1947,6 +1948,8 @@ module ApplicationHelper
end
def bootstrap_render_dynamic_nav
+ hidden_non_project = Setting.find_by_name("hidden_non_project")
+ visiable = !(hidden_non_project && hidden_non_project.value == "0")
main_course_link = link_to l(:label_course_practice), {:controller => 'welcome', :action => 'index', :host => Setting.course_domain}
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain}
@@ -1964,21 +1967,21 @@ module ApplicationHelper
#@nav_dispaly_project_label
nav_list = Array.new
- nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1
+ nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1 && visiable
# nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1
- nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1
+ nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1 && visiable
nav_list.push(main_project_link) if @nav_dispaly_main_project_label
- nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1
- nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1
+ nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1 && visiable
+ nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1 && visiable
- nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1
+ nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1 && visiable
# nav_list.push(projects_link) if @nav_dispaly_project_label
#nav_list.push(users_link) if @nav_dispaly_user_label
# nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1
- nav_list.push(bids_link) if @nav_dispaly_bid_label
- nav_list.push(forum_link) if @nav_dispaly_forum_label
- nav_list.push(stores_link) if @nav_dispaly_store_all_label
+ nav_list.push(bids_link) if @nav_dispaly_bid_label && visiable
+ nav_list.push(forum_link) if @nav_dispaly_forum_label && visiable
+ nav_list.push(stores_link) if @nav_dispaly_store_all_label && visiable
content_li = ''
nav_list.collect do |nav_item|
diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb
index 29ba94924..c8e8bd87b 100644
--- a/app/helpers/members_helper.rb
+++ b/app/helpers/members_helper.rb
@@ -44,7 +44,11 @@ module MembersHelper
# add by nwb
# 课程可添加的成员列表
def render_principals_for_new_course_members(course)
- scope = Principal.active.sorted.not_member_of_course(course).like(params[:q])
+ if params[:q] && params[:q] != ""
+ scope = Principal.active.sorted.not_member_of_course(course).like(params[:q])
+ else
+ scope = []
+ end
principals = paginateHelper scope,10
s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals')
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index de72cab7c..a96bc0fbe 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -434,7 +434,7 @@ class CoursesService
many_times = course.homeworks.index(bid) + 1
name = bid.name
homework_count = bid.homeworks.count #已提交的作业数量
- student_questions_count = bid.commit.nil? ? 0 : bid.commit
+ student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count
description = bid.description
#if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2
state = bid.comment_status
@@ -454,7 +454,7 @@ class CoursesService
many_times = course.homeworks.index(bid) + 1
name = bid.name
homework_count = bid.homeworks.count #已提交的作业数量
- student_questions_count = bid.commit.nil? ? 0 : bid.commit
+ student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count
description = bid.description
#if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2
state = bid.comment_status
diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb
index b026fead2..18586e809 100644
--- a/app/views/attachments/_form.html.erb
+++ b/app/views/attachments/_form.html.erb
@@ -17,23 +17,7 @@
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
<% end %>
- <% container.saved_attachments.each_with_index do |attachment, i| %>
-
- <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
- <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
- <%= l(:field_is_public)%>:
- <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
- <%= if attachment.id.nil?
- #待补充代码
- else
- link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
- end
- %>
- <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
- <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
-
- <% end %>
<% end %>