班级分班进行删除时,根据是否有成员,做不同的提示
This commit is contained in:
parent
cfea5e9da4
commit
21655565ea
|
@ -227,7 +227,15 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
|
||||
def deletegroup
|
||||
group = CourseGroup.find params[:group_id]
|
||||
if group
|
||||
if group.members.count == 0
|
||||
CourseGroup.delete(params[:group_id])
|
||||
else
|
||||
group.members.update_all(:course_group_id => 0)
|
||||
CourseGroup.delete(params[:group_id])
|
||||
end
|
||||
end
|
||||
@subPage_title = l :label_student_list
|
||||
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||
@is_remote = true
|
||||
|
@ -395,6 +403,7 @@ class CoursesController < ApplicationController
|
|||
page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1)
|
||||
@results = student_homework_score(0,page_from, 10,"desc")
|
||||
end
|
||||
@no_group_count = @course.student.count - @course.members.where("course_group_id != 0").count
|
||||
@course_groups = @course.course_groups
|
||||
@limit = 50
|
||||
@page = params[:page].nil? ? 1 : params['page'].to_i
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<br>
|
||||
<div style='width:360px;text-align:center;font-family: "微软雅黑","宋体"' class="f14">
|
||||
<% if count == 0 %>
|
||||
确定删除分班吗?
|
||||
<% else %>
|
||||
已有学生加入本分班,删除之后,这些学生将处于未分班状态
|
||||
您是否确定删除该分班
|
||||
<% end %>
|
||||
</div>
|
||||
</br>
|
||||
<div style='width:164px; margin:0 auto; text-align:center; font-family: "微软雅黑","宋体"'>
|
||||
<%=link_to '确定', deletegroup_course_path(:group_id => group_id), :method => 'delete', :remote => true, :class => 'Blue-btn fl', :method => 'delete'%>
|
||||
<a href='javascript:void(0);' class='Blue-btn fl' onclick='hideModal()'>取消</a>
|
||||
</div>
|
|
@ -10,20 +10,27 @@
|
|||
|
||||
<% unless course_groups.nil? %>
|
||||
<% course_groups.each do |group| %>
|
||||
<script>
|
||||
function delete_group_<%= group.id%>(){
|
||||
var htmlvalue = '<%=escape_javascript(render :partial => 'delete_member_group', :locals => {:group_id => group.id, :count => group.members.count}) %>';
|
||||
pop_up_box(htmlvalue, 400);
|
||||
}
|
||||
</script>
|
||||
<%# group_name = " #{ group.name}( <span class='c_red'>#{group.members.count.to_s}人</span>)".html_safe %>
|
||||
<li class="fl sy_fenban_list clear mr10 mb10">
|
||||
<%= link_to group.name, searchgroupmembers_course_path(@course,:group_id => group.id), class: 'fl mr5', method: 'get', remote: true,:onclick => "checkclass('group_name_#{group.id}')"%>
|
||||
<span class="fl sy_cgrey mr5">(<%=group.members.count.to_s %>人)</span>
|
||||
<% if @canShowCode%>
|
||||
<a href="javascript:void(0)" class="sy_icons_edit fl" onclick="$('#edit_group_name').val('<%= group.name%>');$('#edit_group_id').val('<%= group.id%>');$('#edit_group_form').slideToggle();"></a>
|
||||
<% if group.members.empty?%>
|
||||
<%= link_to '', deletegroup_course_path(:group_id => group.id), :method => 'delete', :remote => true,
|
||||
<%# if group.members.empty?%>
|
||||
<%#= link_to '', deletegroup_course_path(:group_id => group.id), :method => 'delete', :remote => true,
|
||||
:data => {confirm: l(:label_delete_group)},
|
||||
:class => 'sy_icons_del fl'
|
||||
%>
|
||||
<% else%>
|
||||
<a href="javascript:void(0)" onClick="alert('温馨提示:已有学生加入该班级,不能删除该班级,仅可编辑班级名称。');" class="sy_icons_del fl"></a>
|
||||
<% end%>
|
||||
<!--<a href="javascript:void(0)" onClick="pop_up_box('<%#=escape_javascript(render :partial => 'delete_no_member_group', :locals => {:group_id => group.id}) %>');" class="sy_icons_del fl"></a>-->
|
||||
<%# else%>
|
||||
<a href="javascript:void(0)" onClick="delete_group_<%= group.id%>();" class="sy_icons_del fl"></a>
|
||||
<%#end%>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
hideModal();
|
||||
$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>");
|
||||
$("#member_content").html("<%= escape_javascript( render :partial => 'new_member_list', :locals => {:members => @members})%>");
|
Loading…
Reference in New Issue