@ -189,16 +189,17 @@ class OrganizationsController < ApplicationController
if!params[:name].nil?
condition="%#{params[:name].strip}%".gsub("","")
end
#sql = "select courses.* from courses inner join members on courses.id = members.course_id inner join org_courses on courses.id = org_courses.course_id where org_courses.organization_id != #{@organization.id} and members.user_id = #{User.current.id} and courses.name like '#{condition}'"
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}'"
user_courses=Course.find_by_sql(sql)
@added_course_ids=@organization.courses.map(&:id)
@courses=[]
user_courses.eachdo|course|
if!@added_course_ids.include?(course.id)
@courses<<course
end
end
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})"
@ -225,15 +226,17 @@ class OrganizationsController < ApplicationController
if!params[:name].nil?
condition="%#{params[:name].strip}%".gsub("","")
end
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}'"
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})"
标准答案:<%= 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%>
@ -14,7 +14,7 @@ class AddCourseContributorTotalScore < ActiveRecord::Migration
message_reply_count=Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.student_id} and me.parent_id is not null").count*1
common_reply_count=Comment.find_by_sql("select cm.* from comments cm, news n where cm.author_id = #{s.student_id} and n.course_id = #{course.id} and cm.commented_id = n.id and cm.commented_type ='News'").count*1
# attachment_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "Attachment").count * 5
attachment_count=Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and author_id = #{s.student_id};").count*5
attachment_count=Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and author_id = #{s.student_id} and container_type ='Course'").count*5
journal_count=JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ",s.student_id,course.id,"Course").count*1
# journal_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "JournalsForMessage").count * 1
# journal_reply_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? and status =?", s.student_id, course.id, "Course",1).count * 1