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