diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index d266f5990..b89c407a3 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -217,6 +217,10 @@ class CoursesController < ApplicationController
group.course_id = @course.id
group.save
end
+ @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
+ @is_remote = true
+ @members = searchStudent(@course)
+ @membercount = @members.count
@course_groups = @course.course_groups
end
@@ -229,6 +233,8 @@ class CoursesController < ApplicationController
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@is_remote = true
@course_groups = @course.course_groups
+ @members = searchStudent(@course)
+ @membercount = @members.count
end
def join_group
group = CourseGroup.find(params[:object_id])
@@ -283,11 +289,8 @@ class CoursesController < ApplicationController
@members = searchTeacherAndAssistant(@course)
when '2'
@subPage_title = l :label_student_list
- if @course_group_id
- @members = search_student_in_group(@course, @course_group_id)
- else
- @members = searchStudent(@course)
- end
+ @members = searchStudent(@course)
+ @membercount = @members.count
else
@subPage_title = ''
@members = @course.member_principals.includes(:roles, :principal).all.sort
diff --git a/app/models/course_group.rb b/app/models/course_group.rb
index 6126352f6..c5c2f5c85 100644
--- a/app/models/course_group.rb
+++ b/app/models/course_group.rb
@@ -12,7 +12,7 @@ class CourseGroup < ActiveRecord::Base
before_destroy :set_member_nil
attr_accessible :name
-
+ validates :name, :presence => true, :length => {:maximum => 20}, :uniqueness => true
def set_member_nil
if self.members && self.members.count > 0
self.members.update_all("course_group_id = 0")
diff --git a/app/views/courses/_groups_name.html.erb b/app/views/courses/_groups_name.html.erb
index 151eb9c7e..479bf27a5 100644
--- a/app/views/courses/_groups_name.html.erb
+++ b/app/views/courses/_groups_name.html.erb
@@ -1,4 +1,28 @@
+"
@@ -6,7 +30,7 @@
- 分班:
-
- <% course_member_count = l(:label_all) + "(" + @course.members.count.to_s + "人)" %>
+ <% course_member_count = l(:label_all) + "(" + @membercount.to_s + "人)" %>
<%= form_tag( searchgroupmembers_course_path(@course, :group_id => 0), method: 'get',:remote=>true) do %>
@@ -30,9 +54,9 @@
-
<%= form_tag(updategroupname_course_path(@course,:group_id => group.id), method: 'get', remote:true, update: 'group_name') do %>
- <%= text_field_tag "group_name", params[:group_name], :size=>10, :class=>"isTxt w90 f_l", :style=>"padding: 0px", :max => 100 %>
+ <%= text_field_tag "group_name", params[:group_name],:name => "group_name#{group.id}", :size=>10, :class=>"isTxt w90 f_l", :style=>"padding: 0px", :max => 20 %>
- <%= submit_tag '', class: "submit f_l", style: "width: 43px;height: 21px;background: url(/images/btn.png) no-repeat 0 0;" %>
+ <%= submit_tag '', class: "submit f_l", :onclick => "validate_update('group_name#{group.id}')", style: "width: 43px;height: 21px;background: url(/images/btn.png) no-repeat 0 0;" %>
<% end %>
@@ -47,7 +71,7 @@
<%= form_tag( addgroups_course_path(@course), method: 'get',:remote=>true) do %>
<%= text_field_tag "group_name", params[:group_name], size: "20", class: "isTxt w90 f_l", style: "padding: 0px", maxlength: "100" %>
- <%= submit_tag '', class: "submit f_l", style: "width: 43px;height: 21px;background: url(/images/btn.png) no-repeat 0 0;" %>
+ <%= submit_tag '', class: "submit f_l",:onclick => "validate_add_group()", style: "width: 43px;height: 21px;background: url(/images/btn.png) no-repeat 0 0;" %>
<%= link_to_function '', "$('#add_tag04').slideToggle();", class: "submit_2", style: "width: 43px"%>
<% end %>
diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb
index 436a339dd..2363d0fe5 100644
--- a/app/views/courses/_member_list.html.erb
+++ b/app/views/courses/_member_list.html.erb
@@ -1,5 +1,5 @@
-<% if @group %>
+<% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
<% if !@canShowCode %>
<%= join_in_course_group(@course.course_groups,@group, User.current) %>
<% end %>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index cecc9b465..ce3181864 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -572,6 +572,8 @@ zh:
label_member:
label_search_member_count: 共搜索到
label_member_people: 人
+ label_limit_groupname: 组别名不能超出20字符
+ label_limit_groupname_null: 组别名不能为空
label_member_new: 添加成员
label_member_plural: 成员
label_tracker: 跟踪标签