微信回复的回复后台功能完善
This commit is contained in:
parent
fd3c0effe5
commit
a07462076d
|
@ -78,13 +78,12 @@ module Mobile
|
|||
subscribe = 0 #默认未关注
|
||||
|
||||
#-------------------获取用户是否关注此公众号-----------------------------
|
||||
# openid = session[:wechat_openid]
|
||||
# raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
# user_info = Wechat.api.user(openid)
|
||||
# Rails.logger.info "user_info!!!!!!!!!"
|
||||
# Rails.logger.info user_info
|
||||
# subscribe = user_info["subscribe"]
|
||||
subscribe = "123"
|
||||
openid = session[:wechat_openid]
|
||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
user_info = Wechat.api.user(openid)
|
||||
Rails.logger.info "user_info!!!!!!!!!"
|
||||
Rails.logger.info user_info
|
||||
subscribe = user_info["subscribe"]
|
||||
|
||||
status = 0
|
||||
tip = 0 #0班级1项目
|
||||
|
@ -248,9 +247,16 @@ module Mobile
|
|||
end
|
||||
else
|
||||
#二级回复
|
||||
|
||||
|
||||
|
||||
issue = Issue.find params[:id]
|
||||
is_jour = Journal.new
|
||||
is_jour.user_id = current_user.id
|
||||
is_jour.notes = params[:content]
|
||||
is_jour.reply_id = params[:id]
|
||||
is_jour.parent_id = params[:id]
|
||||
is_jour.journalized = issue
|
||||
if is_jour.save
|
||||
result = 2
|
||||
end
|
||||
end
|
||||
end
|
||||
when 'BlogComment'
|
||||
|
|
|
@ -941,46 +941,36 @@ class CoursesService
|
|||
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation}
|
||||
end
|
||||
|
||||
|
||||
def student_homework_score(groupid,course_id, nums, score_sort_by)
|
||||
#teachers = find_course_teachers(@course)
|
||||
#start_from = start_from * nums
|
||||
def student_homework_score(groupid,course_id, nums, score_sort_by, sort_type = 'score')
|
||||
sql_select = ""
|
||||
if groupid == 0
|
||||
if nums == 0
|
||||
sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches
|
||||
WHERE members.course_id = #{course_id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{course_id}) AND members.user_id = homework_attaches.user_id
|
||||
AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id}) GROUP BY members.user_id
|
||||
UNION all
|
||||
SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{course_id} AND
|
||||
students_for_courses.course_id = #{course_id} and members.user_id = students_for_courses.student_id AND
|
||||
members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id} )
|
||||
)
|
||||
GROUP BY members.user_id ORDER BY score #{score_sort_by}"
|
||||
else
|
||||
sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches
|
||||
WHERE members.course_id = #{course_id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{course_id}) AND members.user_id = homework_attaches.user_id
|
||||
AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id}) GROUP BY members.user_id
|
||||
UNION all
|
||||
SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{course_id} AND
|
||||
students_for_courses.course_id = #{course_id} and members.user_id = students_for_courses.student_id AND
|
||||
members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id} )
|
||||
)
|
||||
GROUP BY members.user_id ORDER BY score #{score_sort_by} " #limit #{start_from}, #{nums}"
|
||||
|
||||
end
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT SUM(student_works.work_score)
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = course_id
|
||||
AND student_works.user_id = members.user_id
|
||||
) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 +
|
||||
resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{course_id} AND ccs.user_id = members.user_id
|
||||
) AS act_score
|
||||
FROM members
|
||||
JOIN students_for_courses
|
||||
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
|
||||
WHERE members.course_id = #{course_id} ORDER BY #{sort_type} #{score_sort_by}"
|
||||
else
|
||||
sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches
|
||||
WHERE members.course_id = #{course_id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{course_id}) AND members.user_id = homework_attaches.user_id
|
||||
and members.course_group_id = #{groupid} AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id})
|
||||
GROUP BY members.user_id
|
||||
UNION all
|
||||
SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{course_id}
|
||||
and members.course_group_id = #{groupid} AND
|
||||
students_for_courses.course_id = #{course_id} and members.user_id = students_for_courses.student_id AND
|
||||
members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id} )
|
||||
)
|
||||
GROUP BY members.user_id ORDER BY score #{score_sort_by}"
|
||||
sql_select = "SELECT members.*,(
|
||||
SELECT SUM(student_works.work_score)
|
||||
FROM student_works,homework_commons
|
||||
WHERE student_works.homework_common_id = homework_commons.id
|
||||
AND homework_commons.course_id = #{course_id}
|
||||
AND student_works.user_id = members.user_id
|
||||
) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 +
|
||||
resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{course_id} AND ccs.user_id = members.user_id
|
||||
) AS act_score
|
||||
FROM members
|
||||
JOIN students_for_courses
|
||||
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
|
||||
WHERE members.course_id = #{course_id} AND members.course_group_id = #{groupid} ORDER BY #{sort_type} #{score_sort_by}"
|
||||
end
|
||||
sql = ActiveRecord::Base.connection()
|
||||
homework_scores = Member.find_by_sql(sql_select)
|
||||
|
|
Loading…
Reference in New Issue