《作业优化》

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2014-12-25 10:23:59 +08:00
parent 0e7f7a4254
commit b17d4840b1
2 changed files with 20 additions and 13 deletions

View File

@ -213,10 +213,10 @@ class CoursesController < ApplicationController
q = "#{params[:name].strip}"
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
if params[:incourse]
@results = searchmember_by_name(@@member_scores, q)
@results = searchmember_by_name(student_homework_score, q)
elsif params[:ingroup]
@group = CourseGroup.find(params[:search_group_id])
@results = @results =searchgroupmember_by_name(@@member_scores, @group, q)
@results = @results =searchgroupmember_by_name(student_homework_score, @group, q)
end
@result_count = @results.count
@ -285,7 +285,7 @@ class CoursesController < ApplicationController
member.course_group_id = group.id
member.save
@group = group
@members = searchStudent(@course)
@course_groups = @course.course_groups
@membercount = @members.count
search_group_members group
@ -298,7 +298,7 @@ class CoursesController < ApplicationController
member.save
@group = group
@course_groups = @course.course_groups
@members = searchStudent(@course)
@membercount = @members.count
search_group_members group
end
@ -309,9 +309,9 @@ class CoursesController < ApplicationController
@is_remote = true
if params[:group_id] && params[:group_id] != "0"
@group = CourseGroup.find(params[:group_id])
@results = @@member_scores.find_all {|mem| mem.course_group_id == group.id}
@results = student_homework_score.find_all {|mem| mem.course_group_id == group.id}
else
@results = @@member_scores
@results = student_homework_score
end
@@result = @results
@ -336,8 +336,8 @@ class CoursesController < ApplicationController
@members = searchTeacherAndAssistant(@course)
when '2'
@subPage_title = l :label_student_list
@@member_scores = student_homework_score
@members = @@member_scores
@members = student_homework_score
# @member_scores = @@member_scores
# @members = searchStudent_sort(@course, 'desc', @@member_scores)
@membercount = @members.count
@ -886,8 +886,8 @@ class CoursesController < ApplicationController
homework_scores = Member.find_by_sql("SELECT id, user_id,course_id, course_group_id,created_on,IFNULL(SUM(CASE WHEN t_score <> 0 AND t_score IS NOT NULL THEN t_score ELSE s_score END),0) as score
FROM (
SELECT members.id as id, members.user_id AS user_id, members.course_id AS course_id, members.created_on as created_on,members.course_group_id AS course_group_id,
(SELECT AVG(seems_rateable_rates.stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN (3040,4762,4765)) AS t_score,
(SELECT AVG(seems_rateable_rates.stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (3040,4762,4765)) AS s_score
(SELECT AVG(seems_rateable_rates.stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN (#{teachers})) AS t_score,
(SELECT AVG(seems_rateable_rates.stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN (#{teachers})) AS s_score
FROM `homework_attaches` , members
WHERE members.course_id = #{@course.id}
AND members.user_id NOT IN (#{teachers}) AND homework_attaches.bid_id IN (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id})
@ -909,7 +909,7 @@ class CoursesController < ApplicationController
@members = searchStudent(@course)
@membercount = @members.count
@results = @@member_scores.find_all {|mem| mem.course_group_id == group.id}
@results = student_homework_score.find_all {|mem| mem.course_group_id == group.id}
@@result = @results
@results = paginateHelper @results
end

View File

@ -194,19 +194,23 @@ module CoursesHelper
def searchmember_by_name members, name
#searchPeopleByRoles(project, StudentRoles)
mems = []
if name != ""
members.each do |m|
username = m.user[:lastname].to_s + m.user[:firstname].to_s
if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name))
mems << m
end
end
else
mems = members
end
mems
end
def searchgroupmember_by_name members, name, group
#searchPeopleByRoles(project, StudentRoles)
mems = []
if name != ""
members.each do |m|
if m.course_group_id == group.id
username = m.user[:lastname].to_s + m.user[:firstname].to_s
@ -215,6 +219,9 @@ module CoursesHelper
end
end
end
else
mems = members
end
mems
end
def searchgroupstudent_by_name(group, project, name)