班级分班进行删除时,根据是否有成员,做不同的提示

This commit is contained in:
cxt 2016-10-28 17:49:09 +08:00
parent cfea5e9da4
commit 21655565ea
4 changed files with 37 additions and 6 deletions

View File

@ -227,7 +227,15 @@ class CoursesController < ApplicationController
end end
def deletegroup def deletegroup
group = CourseGroup.find params[:group_id]
if group
if group.members.count == 0
CourseGroup.delete(params[:group_id]) 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 @subPage_title = l :label_student_list
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
@is_remote = true @is_remote = true
@ -395,6 +403,7 @@ class CoursesController < ApplicationController
page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1) page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1)
@results = student_homework_score(0,page_from, 10,"desc") @results = student_homework_score(0,page_from, 10,"desc")
end end
@no_group_count = @course.student.count - @course.members.where("course_group_id != 0").count
@course_groups = @course.course_groups @course_groups = @course.course_groups
@limit = 50 @limit = 50
@page = params[:page].nil? ? 1 : params['page'].to_i @page = params[:page].nil? ? 1 : params['page'].to_i

View File

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

View File

@ -10,20 +10,27 @@
<% unless course_groups.nil? %> <% unless course_groups.nil? %>
<% course_groups.each do |group| %> <% 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 %> <%# 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"> <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}')"%> <%= 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> <span class="fl sy_cgrey mr5">(<%=group.members.count.to_s %>人)</span>
<% if @canShowCode%> <% 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> <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?%> <%# if group.members.empty?%>
<%= link_to '', deletegroup_course_path(:group_id => group.id), :method => 'delete', :remote => true, <%#= link_to '', deletegroup_course_path(:group_id => group.id), :method => 'delete', :remote => true,
:data => {confirm: l(:label_delete_group)}, :data => {confirm: l(:label_delete_group)},
:class => 'sy_icons_del fl' :class => 'sy_icons_del fl'
%> %>
<% else%> <!--<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>-->
<a href="javascript:void(0)" onClick="alert('温馨提示:已有学生加入该班级,不能删除该班级,仅可编辑班级名称。');" class="sy_icons_del fl"></a> <%# else%>
<% end%> <a href="javascript:void(0)" onClick="delete_group_<%= group.id%>();" class="sy_icons_del fl"></a>
<%#end%>
<% end %> <% end %>
</li> </li>
<% end %> <% end %>

View File

@ -1,2 +1,3 @@
hideModal();
$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>"); $("#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})%>"); $("#member_content").html("<%= escape_javascript( render :partial => 'new_member_list', :locals => {:members => @members})%>");