<p>photo<ahref="http://10.0.47.15:3000/shares/new?access_token='2d3dda45dsd'&comment='verygood'&title=davide&share_type=1&url=http://www.baidu.com"> Share A </a></p>
<hr/>
<h2>这是一段视频</h2>
<p>Text<ahref="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=kaka&share_type=2&url=http://www.sina.com"> Share B </a></p>
<hr/>
<h2>这是一篇文章</h2>
<p>Text<ahref="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=pepe&share_type=3&url=http://www.sina.com"> Share C </a></p>
activities=UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})"+
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) "+
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc')
=end
shield_project_ids=ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
shield_project_ids=ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
shield_course_ids=ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
shield_course_ids=ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
watched_user_blog_ids=Blog.select("id").where("author_id in #{user_ids}").map {|blog|blog.id}.join(",")
watched_user_blog_ids=Blog.select("id").where("author_id in #{user_ids}").count ==0?"":Blog.select("id").where("author_id in #{user_ids}").map {|blog|blog.id}.join(",")
blog_ids="("+watched_user_blog_ids+")"
blog_ids="("+watched_user_blog_ids+")"
activities=UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})"+
activities=UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})"+
@ -67,12 +67,15 @@ class AdminController < ApplicationController
defexcellent_all_courses
defexcellent_all_courses
name=params[:name]
name=params[:name]
@order=""
@order=""
ifparams[:order]=='asc'
@sort=""
courses=Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) asc, c.id desc")
ifparams[:sort]&&(params[:order]=='act')
courses=Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) #{params[:sort]}, c.id desc")
@order=params[:order]
@order=params[:order]
elsifparams[:order]=='desc'
@sort=params[:sort]
courses=Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) DESC, c.id desc")
elsifparams[:sort]&&(params[:order]=='time')
courses=Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY time #{params[:sort]},id desc")
resource_num*5+journal_num*1+homework_journal_num*1)FROM`course_contributor_scores`ASccsWHEREccs.course_id=#{@course.id} AND ccs.user_id = members.user_id
resource_num*5+journal_num*1+homework_journal_num*1)FROM`course_contributor_scores`ASccsWHEREccs.course_id=#{@course.id} AND ccs.user_id = members.user_id
@org_activities=OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page]||1).per(10)
@org_activities=OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page]||1).per(10)
@org_logo_attchment=Attachment.find_by_sql("SELECT * from attachments WHERE container_id = #{@organization.id} and container_type = 'Organization' and attachtype = 0 and filename REGEXP '(.jpg|.png|.bmp|.gif|.jpeg)' ORDER BY created_on desc limit 1").first
@org_banner_attchment=Attachment.find_by_sql("SELECT * from attachments WHERE container_id = #{@organization.id} and container_type = 'Organization' and attachtype = 1 and filename REGEXP '(.jpg|.png|.bmp|.gif|.jpeg)' ORDER BY created_on desc limit 1").first
shield_project_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id)
shield_project_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id)
shield_course_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id)
shield_course_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id)
@field=params[:org_subfield_id].nil??OrgSubfield.where("organization_id =? and field_type =?",params[:id].to_i,"Comptec").first:OrgSubfield.find(params[:org_subfield_id])
@type=params[:type]
@type=params[:type]
if@type=="courses"||@type.nil?
if@type.blank?
@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
@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
@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
@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
@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
@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
@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.blank?
@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
@field=params[:org_subfield_id].nil??OrgSubfield.where("organization_id =? and field_type =?",params[:id].to_i,"Comppro").first:OrgSubfield.find(params[:org_subfield_id])
@type=params[:type]
if@type.blank?
@containers=Project.find_by_sql("select p.*, (select count(*) from forge_activities where forge_activities.project_id = p.id) as project_count
@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.blank?
@containers=Course.find_by_sql("select c.*, (select count(*) from course_activities where course_activities.course_id = c.id) as course_count
shield_project_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id)
shield_course_ids=ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id)
@polls=Poll.where("(user_id = #{User.current.id} or polls_group_id in #{course_ids}) and polls_type = 'course' and polls_group_id not in #{none_course_ids}")
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
elsif@order=='student_id'
elsif@order=='student_id'
@ -439,7 +456,7 @@ class StudentWorkController < ApplicationController
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name).count
@student_work_count=(search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order}#{@b_sort}"),@name).count
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
@stundet_works=search_homework_member@homework.student_works.select("student_works.*,student_works.work_score as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
elsif@order=='student_id'
elsif@order=='student_id'
@ -816,7 +833,7 @@ class StudentWorkController < ApplicationController
stu_score=StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
stu_score=StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a")
student_work_id=@homework.student_work_projects.where("user_id=? and student_work_id is not null",User.current.id).first.nil??-1:@homework.student_work_projects.where("user_id=?",User.current.id).first.student_work_id
@courses=User.current.courses.visible.where("is_delete =? and syllabus_id =?",0,@syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name}#{sort_type}")
messages=MessageAll.where("(user_id =? and message_type !=?) or message_type =?",@user.id,"SystemMessage","SystemMessage").includes(:message).order("created_at desc")
messages=MessageAll.where("(user_id =? and message_type !=?) or message_type =?",@user.id,"SystemMessage","SystemMessage").includes(:message).order("created_at desc")
@message_alls=CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =?",@user.id).order("created_at desc")
@message_alls=CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =? and course_id NOT IN #{course_ids}",@user.id).order("created_at desc")
when'course_message'
when'course_message'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","Message",@user.id).order("created_at desc")
@message_alls=CourseMessage.where("course_message_type =? and user_id =? and course_id NOT IN #{course_ids}","Message",@user.id).order("created_at desc")
when'course_news'
when'course_news'
# 课程通知包含发布的通知和回复的通知
# 课程通知包含发布的通知和回复的通知
@message_alls=CourseMessage.where("course_message_type in ('News', 'Comment') and user_id =?",@user.id).order("created_at desc")
@message_alls=CourseMessage.where("course_message_type in ('News', 'Comment') and user_id =? and course_id NOT IN #{course_ids}",@user.id).order("created_at desc")
when'poll'
when'poll'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","Poll",@user.id).order("created_at desc")
@message_alls=CourseMessage.where("course_message_type =? and user_id =? and course_id NOT IN #{course_ids}","Poll",@user.id).order("created_at desc")
#项目相关消息
#项目相关消息
when'issue'
when'issue'
@message_alls=ForgeMessage.where("forge_message_type in ('Issue', 'Journal') and user_id =?",@user.id).order("created_at desc")
@message_alls=ForgeMessage.where("forge_message_type in ('Issue', 'Journal') and user_id =?",@user.id).order("created_at desc")
@ -311,6 +354,28 @@ class UsersController < ApplicationController
@ -519,7 +613,7 @@ class UsersController < ApplicationController
end
end
if!params[:search].nil?
if!params[:search].nil?
search="%#{params[:search].to_s.strip.downcase}%"
search="%#{params[:search].to_s.strip.downcase}%"
@course=@user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i} or #{Course.table_name}.name like :p",:p=>search).select{|course|@user.allowed_to?(:as_teacher,course)}
@course=@user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and (#{Course.table_name}.id = #{params[:search].to_i} or #{Course.table_name}.name like :p)",:p=>search).select{|course|@user.allowed_to?(:as_teacher,course)}
else
else
@course=@user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select{|course|@user.allowed_to?(:as_teacher,course)}
@course=@user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select{|course|@user.allowed_to?(:as_teacher,course)}
end
end
@ -589,7 +683,7 @@ class UsersController < ApplicationController
@attachments=Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
end
" or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc")
@attachments=Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty??'0':user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc")
@attachments=Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
@attachments=Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
elsifparams[:type]=="6"#公共资源
@attachments=Attachment.where("(is_public =1 and is_publish = 1 and container_id is not null)"+"or (author_id = #{params[:id]} and is_publish = 0)").order("created_on desc")
end
end
@type=params[:type]
@type=params[:type]
@limit=7
@limit=7
@ -1158,6 +1257,12 @@ class UsersController < ApplicationController
render:layout=>'new_base_user'
render:layout=>'new_base_user'
end
end
#给某人留言
deffeedBackTo
end
defuser_comments
defuser_comments
end
end
@ -1277,7 +1382,15 @@ class UsersController < ApplicationController
#显示更多用户课程
#显示更多用户课程
defuser_courses4show
defuser_courses4show
@page=params[:page].to_i+1
@page=params[:page].to_i+1
@courses=@user.courses.visible.where("is_delete =?",0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page*5)
@type=params[:type]
if@type=='User'
@courses=@user.courses.visible.where("is_delete =?",0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page*5)
@courses=User.current.courses.visible.where("is_delete =? and syllabus_id =?",0,@syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page*5)
@all_count=User.current.courses.visible.where("is_delete =? and syllabus_id =?",0,@syllabus.id).count
end
end
end
#显示更多用户项目
#显示更多用户项目
@ -1373,7 +1486,7 @@ class UsersController < ApplicationController
attachments=Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil??'created_on':order}#{score}")
attachments=Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil??'created_on':order}#{score}")
attachments=Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
attachments=Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)",:p=>search).order("#{order.nil??'created_on':order}#{score}")
end
end
# 获取我的资源
# 获取我的资源
@ -2633,10 +2783,20 @@ class UsersController < ApplicationController
@ -2714,7 +2874,7 @@ class UsersController < ApplicationController
# 获取我的用户类型资源
# 获取我的用户类型资源
defget_principal_resources_publicorder,score
defget_principal_resources_publicorder,score
attchments=Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("#{order.nil??'created_on':order}#{score}")
attchments=Attachment.where("container_type = 'Principal' and is_public =1 and container_id is not null").order("#{order.nil??'created_on':order}#{score}")
end
end
# 获取我的用户类型资源
# 获取我的用户类型资源
@ -2734,7 +2894,7 @@ class UsersController < ApplicationController
@courses=@user.courses.visible.where("is_delete =?",0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name}#{sort_type}")
Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
end
end
# 获取两种类型的隐藏状态,数量大于0说明是可见
defdouble_field_showorg
OrgSubfield.find_by_sql("SELECT * FROM `org_subfields` where organization_id = #{org.id} and (field_type = 'Compstu' or field_type = 'Comptec') and hide = 0;").count
# Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;")
org_acts=OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{org_subfield.id})").order('updated_at desc')
org_acts=OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{org_subfield.id})").order('updated_at desc')
# acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'news', 'message', 'Issue') and (container_type = 'Course' or container_type = 'Project') order by created_at limit 10;")
# end
deforg_teacher_resource_countuser
deforg_teacher_resource_countuser
results=Attachment.find_by_sql("SELECT * FROM attachments where author_id = #{user.id};").count
results=Attachment.find_by_sql("SELECT * FROM attachments where author_id = #{user.id};").count
count=ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count
has_many:members,:include=>[:principal,:roles],:conditions=>"#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
has_many:members,:include=>[:principal,:roles],:conditions=>"#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
has_many:memberships,:class_name=>'Member'
has_many:memberships,:class_name=>'Member'
@ -64,7 +67,7 @@ class Course < ActiveRecord::Base
#count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
count=ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
@ -108,15 +108,15 @@ class HomeworkCommon < ActiveRecord::Base
end
end
#修改作业后发送微信模板消息
#修改作业后发送微信模板消息
defwechat_message
# def wechat_message
self.course.members.eachdo|member|
# self.course.members.each do |member|
count=ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
count=ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.parent.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count
count=ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count
count=ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count
count=ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count
count=ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count
count=ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count
ifCourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count!=0
ifCourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count!=0