组织管理员提供学霸功能
This commit is contained in:
parent
c57c575c84
commit
c333a0c55d
|
@ -15,11 +15,9 @@ class OrgSubfieldsController < ApplicationController
|
|||
end
|
||||
end
|
||||
@subfield.update_attributes(:field_type => params[:field_type])
|
||||
# 如果栏目是教师,不参入类型的配置,定义为右三模式
|
||||
# 新增模块命名规则,左边1开头,右边2开头,以前的不变
|
||||
# eg:23 右三
|
||||
if params[:field_type] == "Comptec"
|
||||
@subfield.update_attributes(:status => 23)
|
||||
# 如果栏目是教师或学生,不参入类型的配置,默认定义为右三模式
|
||||
if params[:field_type] == "Comptec" || params[:field_type] == "Compstu"
|
||||
@subfield.update_attribute(:status, 6)
|
||||
end
|
||||
else
|
||||
@res = false
|
||||
|
|
|
@ -28,7 +28,7 @@ class OrganizationsController < ApplicationController
|
|||
helper :project_score
|
||||
helper :issues
|
||||
include UsersHelper
|
||||
before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers]
|
||||
before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers, :students]
|
||||
layout 'base_org'
|
||||
def index
|
||||
|
||||
|
@ -159,7 +159,7 @@ class OrganizationsController < ApplicationController
|
|||
end
|
||||
|
||||
def teachers
|
||||
unless @organization.allow_set_teachers
|
||||
unless User.current.admin?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
|
@ -169,12 +169,6 @@ class OrganizationsController < ApplicationController
|
|||
if @type == "courses" || @type.nil?
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif @type == "students"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif @type == "resources"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif @type == "famous"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
|
@ -192,6 +186,34 @@ class OrganizationsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def students
|
||||
unless User.current.admin?
|
||||
render_403
|
||||
return
|
||||
end
|
||||
q = params[:search].nil? ? "" : "#{params[:search].strip}"
|
||||
@field = params[:org_subfield_id].nil? ? OrgSubfield.where("organization_id =? and field_type =?", params[:id].to_i, "Compstu").first : OrgSubfield.find(params[:org_subfield_id])
|
||||
@type = params[:type]
|
||||
if @type == "courses" || @type.nil?
|
||||
@org_students = User.find_by_sql("select u.*, ue.student_id, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity= 1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif @type == "famous"
|
||||
@org_students = User.find_by_sql("select u.*, ue.student_id, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity= 1 and u.excellent_student =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
end
|
||||
limit = 10
|
||||
# @is_remote = true
|
||||
@students_count = @org_students.count
|
||||
@atta_pages = Paginator.new @students_count, limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||
@org_students = paginateHelper @org_students, limit
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def searchmember_by_name members, name
|
||||
#searchPeopleByRoles(project, StudentRoles)
|
||||
mems = []
|
||||
|
@ -474,13 +496,13 @@ class OrganizationsController < ApplicationController
|
|||
# 设置为名师
|
||||
def set_excellent_teacher
|
||||
@ex_teacher = User.find(params[:user])
|
||||
@ex_teacher.update_column(:excellent_teacher, 1)
|
||||
params[:type] == "student" ? @ex_teacher.update_column(:excellent_student, 1) : @ex_teacher.update_column(:excellent_teacher, 1)
|
||||
end
|
||||
|
||||
# 取消名师
|
||||
def reset_excellent_teacher
|
||||
@ex_teacher = User.find(params[:user])
|
||||
@ex_teacher.update_column(:excellent_teacher, 0)
|
||||
params[:type] == "student" ? @ex_teacher.update_column(:excellent_student, 0) : @ex_teacher.update_column(:excellent_teacher, 0)
|
||||
end
|
||||
|
||||
def hide_org_subfield
|
||||
|
|
|
@ -140,10 +140,13 @@ module OrganizationsHelper
|
|||
org_acts
|
||||
end
|
||||
|
||||
def allow_to_create?(org, type)
|
||||
!org_subfield_had_created?(org, type) && User.current.admin?
|
||||
end
|
||||
|
||||
def org_subfield_had_created?(org, type)
|
||||
sub_field = org.org_subfields.select{|subfield| subfield.field_type == type}
|
||||
result = sub_field.length > 0 ? true : false
|
||||
result
|
||||
end
|
||||
|
||||
def org_subfield_type(field)
|
||||
|
|
|
@ -11,6 +11,8 @@ class OrgSubfield < ActiveRecord::Base
|
|||
acts_as_attachable
|
||||
after_create :create_board_sync
|
||||
after_destroy :update_priority
|
||||
# status 为栏目定制决定参数,1 左一 2 左二 3 左三 4 右一 5 右二 6 右三
|
||||
|
||||
# 创建资源栏目讨论区
|
||||
def create_board_sync
|
||||
@board = self.boards.build
|
||||
|
|
|
@ -24,11 +24,11 @@ class Organization < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def switch_type
|
||||
self.show_mode.to_i == 1 ? true : false
|
||||
self.show_mode.to_i == 1
|
||||
end
|
||||
|
||||
def allow_set_teachers
|
||||
self.allow_teacher.to_i == 1 ? true : false
|
||||
self.allow_teacher.to_i == 1
|
||||
end
|
||||
|
||||
def secdomain_name
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
:locals => {:subfields => @organization.org_subfields.order("priority") }) %>");
|
||||
$("#sub_field_left_lists").html("");
|
||||
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
|
||||
$("#org_excellent_teachers").html("<%= escape_javascript(render :partial => 'organizations/setting_excellent_teachers') %>");
|
||||
$("#org_custom_admin").html("<%= escape_javascript(render :partial => 'organizations/org_custom_admin') %>");
|
||||
<% end %>
|
||||
$("#subfield_name").val("");
|
||||
$("#sub_dir").val("");
|
|
@ -3,4 +3,4 @@ $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organiza
|
|||
:locals => {:subfields => @organization.org_subfields.order("priority") }) %>");
|
||||
$("#sub_field_left_lists").html("");
|
||||
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
|
||||
$("#org_excellent_teachers").html("<%= escape_javascript(render :partial => 'organizations/setting_excellent_teachers') %>");
|
||||
$("#org_custom_admin").html("<%= escape_javascript(render :partial => 'organizations/org_custom_admin') %>");
|
|
@ -0,0 +1,12 @@
|
|||
<% if allow_to_create?(@organization, "Comptec") %>
|
||||
<li class="fl mr15">
|
||||
<input type="radio" id="orgTec" value="Comptec" name="field_type" />
|
||||
<label for="Comptec">教师</label>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if allow_to_create?(@organization, "Compstu") %>
|
||||
<li class="fl mr15">
|
||||
<input type="radio" id="orgStu" value="Compstu" name="field_type" />
|
||||
<label for="Comptec">学生</label>
|
||||
</li>
|
||||
<% end %>
|
|
@ -67,7 +67,7 @@
|
|||
<% end %>
|
||||
</ul>
|
||||
<% if User.current.admin_of_org?(@organization) %>
|
||||
<a href="<%= setting_organization_path(@organization) %>" class="link-black fr por_edit_index">配置</a>
|
||||
<a href="<%= setting_organization_path(@organization) %>" class="link-black fr por_edit_index" target="_blank">配置</a>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div><!--por_nav end-->
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<% org_students.each do |org_student| %>
|
||||
<% school = School.where("id =?", org_student.school_id).first %>
|
||||
<div class="teacher-list-row">
|
||||
<div>
|
||||
<div class="teacher-avatar">
|
||||
<%= link_to image_tag(url_to_avatar(org_student), :width => "90", :height => "90"), user_url_in_org(org_student), :alt => "用户头像" %>
|
||||
</div>
|
||||
<div class="fl">
|
||||
<div class="ml25 mb20"><span class="teacher-name"><%=link_to org_student.try(:realname).nil? ? org_student.try(:login) : org_student.try(:realname), user_url_in_org(org_student) %></span>
|
||||
<% unless school.nil? %>
|
||||
<span class="f12 fontGrey2 mr15"><%= school.name %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="teacher-social-block">
|
||||
<div class="block-num"><%= org_student.courses.count %></div>
|
||||
<div class="block-title">课程数</div>
|
||||
</div>
|
||||
<div class="block-slice"></div>
|
||||
<div class="teacher-social-block">
|
||||
<div class="block-num"><%= org_teacher_resource_count(org_student) %></div>
|
||||
<div class="block-title">资源数</div>
|
||||
</div>
|
||||
</div>
|
||||
<% if User.current.admin_of_org?(@organization) %>
|
||||
<a href="javascript:void(0);" class="fr teacher-select" onclick="hide($(this),'<%= org_student.id %>');" id="hide_<%= org_student.id %>"><%= org_student.excellent_student ==0 ? "设为学霸" : "取消设置" %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
function hide(content, id){
|
||||
if (content.text() == '设为学霸')
|
||||
$.ajax({
|
||||
url: "/organizations/set_excellent_teacher?user=" + id + "&type=student",
|
||||
type: "post"
|
||||
});
|
||||
else
|
||||
$.ajax({
|
||||
url: "/organizations/reset_excellent_teacher?user=" + id + "&type=student",
|
||||
type: "post"
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,12 @@
|
|||
<% if @organization.allow_set_teachers && !org_subfield_had_created?(@organization, "Comptec") %>
|
||||
<li class="fl mr15">
|
||||
<input type="radio" id="orgTec" value="Comptec" name="field_type" />
|
||||
<label for="Comptec">教师</label>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if User.current.admin? && !org_subfield_had_created?(@organization, "Compstu") %>
|
||||
<li class="fl mr15">
|
||||
<input type="radio" id="orgStu" value="Compstu" name="field_type" />
|
||||
<label for="Comptec">学生</label>
|
||||
</li>
|
||||
<% end %>
|
|
@ -92,7 +92,7 @@
|
|||
<%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkGrey fr ml5 mr5" %>
|
||||
<span class="fr">|</span>
|
||||
<a href="javascript:void(0);" class="linkGrey fr ml5 mr5" onclick="edit('#subfield_show_<%= field.id %>','#subfield_edit_<%= field.id %>');">编辑</a>
|
||||
<% unless field.field_type == "Resource" || field.field_type == "Comptec" %>
|
||||
<% unless field.field_type == "Resource" || field.field_type == "Comptec" || field.field_type == "Compstu" %>
|
||||
<span class="fr">|</span>
|
||||
<!--escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (Setting.cross_project_issue_relations? ? 'all' : nil)-->
|
||||
<!--<a href="javascript:void(0);" class="linkGrey fr mr5" onclick="org_submain_new('<%#= escape_javascript new_org_subfield_sub_domain_path(:org_subfield_id => field.id, :field => field) %>');">添加二级目录</a>-->
|
||||
|
|
|
@ -1 +1 @@
|
|||
$("#hide_<%= @ex_teacher.id %>").text("设为名师");
|
||||
$("#hide_<%= @ex_teacher.id %>").text(<%= params[:type]== "student" ? "设为学霸" : "设为名师"%>);
|
|
@ -87,11 +87,11 @@
|
|||
<span>允许游客下载</span>
|
||||
<span class="c_green f12" id="allow_down_hint"><%= @organization.is_public? ? "" : "(私有组织不允许游客下载资源)" %></span>
|
||||
</div>
|
||||
<% if User.current.admin? %>
|
||||
<div class="orgRow mb10 mt5"><span style="margin-left:10px;">允许设置名师榜 : </span>
|
||||
<input id="allow_set_excellent_teachers" type="checkbox" style="margin-top:5px;" name="organization[allow_teacher]" <%= @organization.allow_teacher==1 ? 'checked': ''%> class="ml3" />
|
||||
</div>
|
||||
<% end %>
|
||||
<!--<%# if User.current.admin? %>-->
|
||||
<!--<div class="orgRow mb10 mt5"><span style="margin-left:10px;">允许设置名师榜 : </span>-->
|
||||
<!--<input id="allow_set_excellent_teachers" type="checkbox" style="margin-top:5px;" name="organization[allow_teacher]" <%#= @organization.allow_teacher==1 ? 'checked': ''%> class="ml3" />-->
|
||||
<!--</div>-->
|
||||
<!--<%# end %>-->
|
||||
<a href="javascript:void(0);" class="saveBtn ml80 db fl" onclick="update_org('<%=@organization.id %>','<%= @organization.name %>', $('#organization_name'));">保存</a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -162,8 +162,8 @@
|
|||
<input type="radio" id="orgMeb" value="Resource" name="field_type" />
|
||||
<label for="orgMeb">资源</label>
|
||||
</li>
|
||||
<div id="org_excellent_teachers">
|
||||
<%= render :partial => 'organizations/setting_excellent_teachers' %>
|
||||
<div id="org_custom_admin">
|
||||
<%= render :partial => 'organizations/org_custom_admin' %>
|
||||
</div>
|
||||
<li class="fr"><a href="javascript:void(0);" class="saveBtn db" onclick="add_org_subfield();">新增</a></li>
|
||||
<li class="cl"></li>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<div class="homepageRightBanner">
|
||||
<div class="f16 fontGrey3">
|
||||
<% if @type == "famous" %>
|
||||
学霸列表
|
||||
<% else %>
|
||||
<%= @field.name %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="resources mt10">
|
||||
<div class="function-row" id="org_student_search">
|
||||
<%= form_tag(url_for(:controller => 'organizations', :action => 'students', :type => @type), :remote => true , :method => 'get', :id => 'resource_search_form') do %>
|
||||
<input type="text" name="search" placeholder="输入学生名进行搜索" class="teacher-list-search fl" />
|
||||
<%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :class => "teacher-search-icon fl" %>
|
||||
<!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>-->
|
||||
<% end %>
|
||||
<div class="sn-font-grey fr">
|
||||
<%= link_to "学霸列表", students_organization_path(@organization, :type => "famous", :org_subfield_id => @field.id), :class => "fontGrey2" %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div id="org_students_list">
|
||||
<%=render 'organizations/org_students_list', :org_students => @org_students %>
|
||||
</div>
|
||||
<div>
|
||||
<ul class="wlist" id="pages" style="margin-top: 15px;">
|
||||
<%= pagination_links_full @atta_pages, @students_count, :per_page_links => false, :flag => true %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,3 @@
|
|||
$("#org_students_list").html('<%= escape_javascript( render :partial => 'organizations/org_students_list', :locals => {:org_students => @org_students})%>');
|
||||
$("#pages").html('<%= pagination_links_full @atta_pages, @students_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||
$("#org_student_search").attr('href','<%= students_organization_path(@organization, :type => @type) %>');
|
|
@ -77,6 +77,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'more_org_courses'
|
||||
get 'search_courses'
|
||||
get 'teachers'
|
||||
get 'students'
|
||||
post 'join_course_menu'
|
||||
post 'join_courses'
|
||||
get 'search_projects'
|
||||
|
@ -94,7 +95,9 @@ RedmineApp::Application.routes.draw do
|
|||
post 'hide_org_subfield'
|
||||
post 'show_org_subfield'
|
||||
post 'set_excellent_teacher'
|
||||
post 'set_excellent_student'
|
||||
post 'reset_excellent_teacher'
|
||||
post 'reset_excellent_student'
|
||||
post 'agree_apply_subdomain'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddExcellentStudentToUser < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :excellent_student, :integer, :default => false
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160523085440) do
|
||||
ActiveRecord::Schema.define(:version => 20160531021244) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -2426,6 +2426,7 @@ ActiveRecord::Schema.define(:version => 20160523085440) do
|
|||
t.integer "gid"
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "excellent_teacher", :default => 0
|
||||
t.integer "excellent_student", :default => 0
|
||||
end
|
||||
|
||||
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"
|
||||
|
|
Loading…
Reference in New Issue