组织精品课程,热门项目

This commit is contained in:
huang 2016-06-02 09:52:06 +08:00
parent 27a9170318
commit e5eeba90f6
4 changed files with 34 additions and 34 deletions

View File

@ -238,23 +238,12 @@ class OrganizationsController < ApplicationController
if @type.nil? if @type.nil?
@containers = Course.find_by_sql("SELECT * FROM `courses` where is_delete = 0 and is_public = 1 and name like '%#{q}%' order by updated_at desc;") @containers = Course.find_by_sql("SELECT * FROM `courses` where is_delete = 0 and is_public = 1 and name like '%#{q}%' order by updated_at desc;")
elsif @type == "famous" elsif @type == "famous"
@containers = Course.find_by_sql("SELECT * FROM `courses` where is_delete = 0 and is_public = 1 and hot = 1 and name like '%#{q}%' order by updated_at desc;") @containers = Course.find_by_sql("SELECT * FROM `courses` where is_delete = 0 and is_public = 1 and is_excellent = 1 and name like '%#{q}%' order by updated_at desc;")
end end
atta_page_public @containers atta_page_public @containers
end end
def acts def acts
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
atta_page_public container @containers
end end
def searchmember_by_name members, name def searchmember_by_name members, name
@ -543,6 +532,18 @@ class OrganizationsController < ApplicationController
end end
end end
def update_field_by_admin
@type = params[:type]
@status = params[:status]
if @type == "project"
@container = Project.find(params[:container])
@status == "reset" ? @container.update_column(:hot, 0) : @container.update_column(:hot, 1)
else
@container = Course.find(params[:container])
@status == "reset" ? @container.update_column(:is_excellent, 0) : @container.update_column(:is_excellent, 1)
end
end
# 设置为名师 # 设置为名师
def set_excellent_teacher def set_excellent_teacher
@ex_teacher = User.find(params[:user]) @ex_teacher = User.find(params[:user])

View File

@ -16,24 +16,9 @@
<div class="block-title">资源</div> <div class="block-title">资源</div>
</div> </div>
</div> </div>
<a href="javascript:void(0);" class="fr teacher-select" onclick="admin_hide_org($(this),'<%= container.id %>');" id="hide_<%= container.id %>"> <a href="javascript:void(0);" class="fr teacher-select" onclick="admin_hide_org($(this),'<%= container.id %>');" id="hide_<%= container.id %>"><%= container.class == Course ? (container.is_excellent == 0 ? "设为精品" : "取消精品") : (container.hot ==0 ? "设为热门" : "取消热门") %></a>
<%= (container.class == Course ? container.is_excellent == 0 : container.hot ==0) ? "设为热门" : "取消设置" %></a>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<% end %> <% 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>

View File

@ -0,0 +1,5 @@
<% if @type == "course" %>
$("#hide_<%= @container.id %>").text("<%= (@status == 'reset' ? '设为精品' : '取消精品') %>");
<% elsif @type == "project" %>
$("#hide_<%= @container.id %>").text("<%= (@status == 'reset' ? '设为热门' : '取消热门') %>");
<% end %>

View File

@ -112,19 +112,28 @@ function chooseTeacherType(org_id){
//修改状态 //修改状态
function admin_hide_org(content, id){ function admin_hide_org(content, id){
if (content.text() == '设为热门') if (content.text() == '设为热门'){
$.ajax({ $.ajax({
url: "/organizations/update_field_by_admin?user=" + id + "&type=project", url: "/organizations/update_field_by_admin?container=" + id + "&type=project",
type: "post" type: "post"
}); });
else if (content.text() == '设为精品') }
else if (content.text() == '设为精品'){
$.ajax({ $.ajax({
url: "/organizations/update_field_by_admin?user=" + id + "&type=course", url: "/organizations/update_field_by_admin?container=" + id + "&type=course",
type: "post" type: "post"
}); });
else if (content.text() == '取消设置') }
else if (content.text() == '取消热门'){
$.ajax({ $.ajax({
url: "/organizations/reset_update_field_by_admin?user=" + id + "&type=student", url: "/organizations/update_field_by_admin?container=" + id + "&type=project" + "&status=reset",
type: "post" type: "post"
}); });
}
else if (content.text() == '取消精品'){
$.ajax({
url: "/organizations/update_field_by_admin?container=" + id + "&type=course" + "&status=reset",
type: "post"
});
}
} }