修改孙涛提出的bug

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2014-12-05 16:03:41 +08:00
parent 020242a8c9
commit 9d0e39e708
5 changed files with 40 additions and 11 deletions

View File

@ -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
@membercount = @members.count
else
@subPage_title = ''
@members = @course.member_principals.includes(:roles, :principal).all.sort

View File

@ -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")

View File

@ -1,4 +1,28 @@
<script type=" text/javascript" charset="utf-8">
function validate_groupname(value1) {
if(value1.length > 20) {
alert('<%= l(:label_limit_groupname) %>');
}
}
function validate_groupname_null(value1) {
if(value1.length == 0) {
alert('<%= l(:label_limit_groupname_null) %>');
}
}
function validate_update(name) {
value1 = document.getElementsByName(name)[0].value;
validate_groupname(value1);
document.getElementsByName(name)[0].value = "";
}
function validate_add_group() {
value1 = document.getElementsByName("group_name")[0].value;
validate_groupname(value1);
validate_groupname_null(value1);
document.getElementsByName('group_name')[0].value = "";
}
</script>"
<ul>
@ -6,7 +30,7 @@
<li style=" color:#8b8b8b;">分班:</li>
<li class="classbox">
<% 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 @@
<li>
<%= form_tag(updategroupname_course_path(@course,:group_id => group.id), method: 'get', remote:true, update: 'group_name') do %>
<span id="add_tag_<%= group.id %>" style="display:none; vertical-align: middle;" class=" f_l">
<%= 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 %>
<!--<input type="button" class="submit f_l" onclick="addTag();" style="width: 43px"/>-->
<%= 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;" %>
</span>
<% end %>
</li>
@ -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 %>

View File

@ -1,5 +1,5 @@
<div >
<% 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 %>&nbsp;&nbsp;&nbsp;

View File

@ -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: 跟踪标签