parent
7a727bfed7
commit
ba524675e0
|
@ -399,7 +399,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
@results = paginateHelper_for_members @results, 10
|
||||
else
|
||||
@group = Group.find(group_id)
|
||||
@group = CourseGroup.find(group_id)
|
||||
@results = student_homework_score(group_id, 0, 0,@score_sort_by)
|
||||
@results = paginateHelper @results, 10
|
||||
end
|
||||
|
@ -913,22 +913,22 @@ class CoursesController < ApplicationController
|
|||
if groupid == 0
|
||||
if nums == 0
|
||||
sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches
|
||||
WHERE members.course_id = 122 AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = 122) AND members.user_id = homework_attaches.user_id GROUP BY members.user_id
|
||||
|
||||
UNION
|
||||
SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = 122 AND
|
||||
students_for_courses.course_id = 122 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 = 122 )
|
||||
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 = 122 AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = 122) AND members.user_id = homework_attaches.user_id GROUP BY members.user_id
|
||||
|
||||
UNION
|
||||
SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = 122 AND
|
||||
students_for_courses.course_id = 122 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 = 122 )
|
||||
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}"
|
||||
|
||||
|
@ -936,13 +936,13 @@ GROUP BY members.user_id ORDER BY score #{score_sort_by} limit #{start_from}, #{
|
|||
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 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
|
||||
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 = 122 )
|
||||
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
|
||||
|
|
|
@ -451,7 +451,9 @@ class HomeworkAttachController < ApplicationController
|
|||
homework.score = @m_score
|
||||
homework.is_teacher_score = 1
|
||||
else
|
||||
homework.score = homework.rates(:quality).select("avg(stars)")
|
||||
sql = "SELECT AVG(stars) as stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{homework.id}"
|
||||
score= HomeworkAttach.find_by_sql(sql).first.stars
|
||||
homework.score = score
|
||||
end
|
||||
else
|
||||
if is_teacher == 1
|
||||
|
|
|
@ -117,25 +117,16 @@ class Member < ActiveRecord::Base
|
|||
# 查找每个学生每个作业的评分
|
||||
def student_homework_score
|
||||
score_count = 0
|
||||
homework_score = HomeworkAttach.find_by_sql("SELECT bids.`name`, 0 as score,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach'
|
||||
AND rateable_id = homework_attaches.id ) AS t_score,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach'
|
||||
AND rateable_id = homework_attaches.id ) AS s_score
|
||||
homework_score = HomeworkAttach.find_by_sql("SELECT bids.name, homework_attaches.score as score
|
||||
FROM homework_attaches, bids where homework_attaches.user_id = #{self.user_id}
|
||||
and homework_attaches.bid_id IN (SELECT bid_id FROM homework_for_courses where course_id = #{self.course_id})
|
||||
AND homework_attaches.bid_id = bids.id ")
|
||||
homework_score.each do |homework|
|
||||
if !homework.t_score.nil? && homework.t_score != 0
|
||||
score = homework.t_score
|
||||
else
|
||||
if !homework.s_score.nil?
|
||||
score= homework.s_score
|
||||
else
|
||||
score = 0
|
||||
end
|
||||
mem_score = 0
|
||||
if homework[:score]
|
||||
mem_score = homework[:score]
|
||||
end
|
||||
score_count = score_count + score
|
||||
score_count = score_count + mem_score
|
||||
end
|
||||
[homework_score, format("%0.2f", score_count)]
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<% else %>
|
||||
<li class="ml50" style="margin-left: 470px">
|
||||
</li>
|
||||
<li class="ml50">
|
||||
<li class="ml50" style="margin-left: 80%">
|
||||
<a href="#" >加入时间</a>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
|
@ -40,16 +40,8 @@
|
|||
<ul class="tscore_box">
|
||||
<li ><span class="c_blue02 w280">作业名称</span><span class="c_blue02 w70">得分</span></li>
|
||||
<% @member_score.student_homework_score[0].each do |homework_score| %>
|
||||
<% if !homework_score.t_score.nil? && homework_score.t_score != 0 %>
|
||||
<% score = homework_score.t_score %>
|
||||
<% else %>
|
||||
<% if !homework_score.s_score.nil? %>
|
||||
<% score = homework_score.s_score %>
|
||||
<% else %>
|
||||
<% score = 0 %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<li><span class="c_grey02 w280"><%= homework_score.name %></span><span class="c_red w70"><%= format("%0.2f",score) %></span></li>
|
||||
|
||||
<li><span class="c_grey02 w280"><%= homework_score.name %></span><span class="c_red w70"><%= format("%0.2f",homework_score[:score].nil? ? 0 : homework_score[:score]) %></span></li>
|
||||
<% end %>
|
||||
<li><span class="c_blue03 w280">作业积分(总得分)</span><span class="c_red w70"><%= @member_score.student_homework_score[1] %></span></li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue