教师团队中上移、下移功能的完善
This commit is contained in:
parent
9e2c381b4a
commit
7f3bb0be63
|
@ -45,12 +45,12 @@ class SyllabusMemberController < ApplicationController
|
|||
member = SyllabusMember.find(params[:id])
|
||||
@syllabus = member.syllabus
|
||||
members = @syllabus.syllabus_members
|
||||
if params[:opr] == 'up' && member.rank > 2
|
||||
if params[:opr] == 'up' && member.rank > 1
|
||||
before_mem = members.where("rank = #{member.rank - 1}").first
|
||||
if before_mem && member.update_attribute('rank', member.rank - 1)
|
||||
before_mem.update_attribute('rank', before_mem.rank + 1)
|
||||
end
|
||||
elsif params[:opr] == 'down' && member.rank > 1 && member.rank < members.count
|
||||
elsif params[:opr] == 'down' && member.rank < members.count
|
||||
after_mem = members.where("rank = #{member.rank + 1}").first
|
||||
if after_mem && member.update_attribute('rank', member.rank + 1)
|
||||
after_mem.update_attribute('rank', after_mem.rank - 1)
|
||||
|
|
|
@ -853,6 +853,13 @@ class User < Principal
|
|||
OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0
|
||||
end
|
||||
|
||||
def member_of_syl?(syllabus)
|
||||
if !self.logged?
|
||||
return false
|
||||
end
|
||||
SyllabusMember.where("user_id =? and syllabus_id =?", self.id, syllabus.id).count > 0
|
||||
end
|
||||
|
||||
def admin_of_org?(org)
|
||||
if self.admin?
|
||||
return true
|
||||
|
|
|
@ -76,8 +76,8 @@
|
|||
</div>
|
||||
<% else %>
|
||||
<div class="icons_tishi"><img src="/images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
|
||||
<% if User.current == @syllabus.user %>
|
||||
<p class="sy_tab_con_p">您建立的课程还未创建班级,请
|
||||
<% if User.current.member_of_syl?(@syllabus) %>
|
||||
<p class="sy_tab_con_p">该课程还未创建班级,请
|
||||
<%= link_to "新建班级", new_course_path(:host=> Setting.host_course, :syllabus_id => @syllabus.id), :class => "sy_corange", :target => '_blank'%>
|
||||
,谢谢啦!</p>
|
||||
<% else %>
|
||||
|
|
|
@ -13,13 +13,14 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% count = @members.count %>
|
||||
<% @members.each_with_index do |member, i| %>
|
||||
<% user = member.user %>
|
||||
<% allow_delete = @syllabus.courses.where(:tea_id => member.user_id).empty? && i != 0 %>
|
||||
<% allow_delete = is_admin && @syllabus.courses.where(:tea_id => member.user_id).empty? %>
|
||||
<tr>
|
||||
<td><%= member.rank %></td>
|
||||
<td>
|
||||
<% if member.rank == 1 %>
|
||||
<% if user == @syllabus.user %>
|
||||
<div style="display: inline-block"><span class="sy_new_name fl"><%= user.show_name %></span><span class="sy_new_orange ml5 fl mt12">创建者</span></div>
|
||||
<% else %>
|
||||
<span class="sy_new_long_name"><%= user.show_name %></span>
|
||||
|
@ -35,23 +36,20 @@
|
|||
<td><%= courses.where("tea_id != #{user.id}").count %></td>
|
||||
<% if is_admin %>
|
||||
<td>
|
||||
<% if i == 0 %>
|
||||
|
||||
<% if user == @syllabus.user %>
|
||||
<% elsif allow_delete %>
|
||||
<%= link_to('删除', {:controller => 'syllabus_member', :action => 'destroy', :id => member.id, :syllabus => @syllabus.id},:remote => true, :method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr sy_btn_grey mr5", :title => l(:button_delete)) %>
|
||||
<% else %>
|
||||
<% if allow_delete %>
|
||||
<%= link_to('删除', {:controller => 'syllabus_member', :action => 'destroy', :id => member.id, :syllabus => @syllabus.id},:remote => true, :method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr sy_btn_grey mr5", :title => l(:button_delete)) %>
|
||||
<% else %>
|
||||
<a href="javascript:void(0)" class="fr sy_btn_grey mr5" title="该老师已在本课程下创建了班级,不能删除">删除</a>
|
||||
<% end %>
|
||||
<% if i == 1 %>
|
||||
<%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %>
|
||||
<% elsif i == @members.count - 1 %>
|
||||
<%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %>
|
||||
<% else %>
|
||||
<%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %>
|
||||
<%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %>
|
||||
<% end %>
|
||||
<a href="javascript:void(0)" class="fr sy_btn_grey mr5" title="该老师已在本课程下创建了班级,不能删除">删除</a>
|
||||
<% end %>
|
||||
<% if i != 0 && i < count - 1 %>
|
||||
<%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %>
|
||||
<%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %>
|
||||
<% elsif i < count - 1 %>
|
||||
<%= link_to('下移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'down'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '下移') %>
|
||||
<% elsif i == count - 1 %>
|
||||
<%= link_to('上移', {:controller => 'syllabus_member', :action => 'update_rank', :id => member.id, :syllabus => @syllabus.id, :opr => 'up'},:remote => true, :method => 'post', :class => "fr sy_btn_blue mr5", :title => '上移') %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue