sql="select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+
"and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})"
sql="select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'"+
" and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})"
@events_pages=ForgeActivity.where("project_id = ? and forge_act_type != ?",@project,"Document").order("created_at desc").page(params['page'||1]).per(20);
caseparams[:type]
whennil
@events_pages=ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo')",@project).order("updated_at desc").limit(10).offset(@page*10)
when'issue'
@events_pages=ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page*10)
when'news'
@events_pages=ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page*10)
when'message'
@events_pages=ForgeActivity.where("project_id = ? and forge_act_type = 'Message'",@project).order("updated_at desc").limit(10).offset(@page*10)
end
#events = @activity.events(@date_from, @date_to)
#events = @activity.events(@date_from, @date_to)
else
else
@events_pages=ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public
@events_pages=ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public
@ -128,7 +128,7 @@ class UsersController < ApplicationController
#课程相关消息
#课程相关消息
when'homework'
when'homework'
@message_alls=CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork') and user_id =?",@user).order("created_at desc")
@message_alls=CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =?",@user).order("created_at desc")
when'course_message'
when'course_message'
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","Message",@user).order("created_at desc")
@message_alls=CourseMessage.where("course_message_type =? and user_id =?","Message",@user).order("created_at desc")
when'course_news'
when'course_news'
@ -1367,7 +1367,7 @@ class UsersController < ApplicationController
@ -92,7 +104,35 @@ class Attachment < ActiveRecord::Base
" LEFT JOIN #{News.table_name} ON #{Attachment.table_name}.container_type='News' AND (#{News.table_name}.project_id in "+self.public_project_id+" OR #{News.table_name}.course_id in "+self.public_course_id+")"+
" LEFT JOIN #{News.table_name} ON #{Attachment.table_name}.container_type='News' AND (#{News.table_name}.project_id in "+self.public_project_id+" OR #{News.table_name}.course_id in "+self.public_course_id+")"+
" LEFT JOIN #{HomeworkAttach.table_name} ON #{Attachment.table_name}.container_type='HomeworkAttach' AND #{HomeworkAttach.table_name}.bid_id in "+self.public_bid_id)
" LEFT JOIN #{HomeworkAttach.table_name} ON #{Attachment.table_name}.container_type='HomeworkAttach' AND #{HomeworkAttach.table_name}.bid_id in "+self.public_bid_id)
}
}
scope:indexable,lambda{where('is_public = 1 and ((container_type in ("Principal")) '+
'or (container_type = "Course" and container_id in( SELECT `courses`.id FROM `courses` WHERE (courses.status <> 9 AND courses.is_public = 1)) )'+
'or (container_type = "Project" and container_id in(SELECT `projects`.id FROM `projects` WHERE (projects.status <> 9 AND projects.is_public = 1) ))'+')')}#用于elastic建索引的scope
defself.search(query)
__elasticsearch__.search(
{
query:{
multi_match:{
query:query,
type:"most_fields",
operator:"or",
fields:['filename']
}
},
sort:{
_score:{order:"desc"},
downloads:{order:"desc"}
},
highlight:{
pre_tags:['<span class="c_red">'],
post_tags:['</span>'],
fields:{
filename:{}
}
}
}
)
end
# add by nwb
# add by nwb
# 公开的项目id列表
# 公开的项目id列表
defself.public_project_id
defself.public_project_id
@ -560,4 +600,47 @@ class Attachment < ActiveRecord::Base
@ -18,7 +32,7 @@ class Course < ActiveRecord::Base
:conditions=>"#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
:conditions=>"#{Principal.table_name}.type='Group' OR (#{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:members,:include=>[:principal,:roles],:conditions=>"#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
@ -138,8 +151,9 @@ class Project < ActiveRecord::Base
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first%>
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+
'<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+