|
|
@ -162,6 +162,7 @@ class CoursesController < ApplicationController
|
|
|
|
@subPage_title = l :label_student_list
|
|
|
|
@subPage_title = l :label_student_list
|
|
|
|
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
|
|
|
|
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
|
|
|
|
# @is_remote = true
|
|
|
|
# @is_remote = true
|
|
|
|
|
|
|
|
@sort_type = 'score'
|
|
|
|
@score_sort_by = "desc"
|
|
|
|
@score_sort_by = "desc"
|
|
|
|
q = "#{params[:name].strip}"
|
|
|
|
q = "#{params[:name].strip}"
|
|
|
|
if params[:incourse]
|
|
|
|
if params[:incourse]
|
|
|
@ -185,9 +186,11 @@ class CoursesController < ApplicationController
|
|
|
|
group.course_id = @course.id
|
|
|
|
group.course_id = @course.id
|
|
|
|
group.save
|
|
|
|
group.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@sort_type = 'score'
|
|
|
|
|
|
|
|
@score_sort_by = "desc"
|
|
|
|
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
|
|
|
|
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
|
|
|
|
@is_remote = true
|
|
|
|
@is_remote = true
|
|
|
|
@members = student_homework_score(0,0, 10,"desc")
|
|
|
|
@members = student_homework_score(0,0, 10,@score_sort_by)
|
|
|
|
@course_groups = @course.course_groups
|
|
|
|
@course_groups = @course.course_groups
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -196,7 +199,9 @@ class CoursesController < ApplicationController
|
|
|
|
@subPage_title = l :label_student_list
|
|
|
|
@subPage_title = l :label_student_list
|
|
|
|
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
|
|
|
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
|
|
|
@is_remote = true
|
|
|
|
@is_remote = true
|
|
|
|
|
|
|
|
@sort_type = 'score'
|
|
|
|
|
|
|
|
@score_sort_by = "desc"
|
|
|
|
|
|
|
|
@members = student_homework_score(0,0, 10,@score_sort_by)
|
|
|
|
@course_groups = @course.course_groups
|
|
|
|
@course_groups = @course.course_groups
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -281,6 +286,7 @@ class CoursesController < ApplicationController
|
|
|
|
@render_file = 'new_member_list'
|
|
|
|
@render_file = 'new_member_list'
|
|
|
|
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
|
|
|
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
|
|
|
@is_remote = true
|
|
|
|
@is_remote = true
|
|
|
|
|
|
|
|
@sort_type = 'score'
|
|
|
|
@score_sort_by = "desc"
|
|
|
|
@score_sort_by = "desc"
|
|
|
|
if params[:group_id] && params[:group_id] != "0"
|
|
|
|
if params[:group_id] && params[:group_id] != "0"
|
|
|
|
@group = CourseGroup.find(params[:group_id])
|
|
|
|
@group = CourseGroup.find(params[:group_id])
|
|
|
@ -298,6 +304,7 @@ class CoursesController < ApplicationController
|
|
|
|
|
|
|
|
|
|
|
|
@render_file = 'new_member_list'
|
|
|
|
@render_file = 'new_member_list'
|
|
|
|
@score_sort_by = "desc"
|
|
|
|
@score_sort_by = "desc"
|
|
|
|
|
|
|
|
@sort_type = "score"
|
|
|
|
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
|
|
|
|
@canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1'
|
|
|
|
@role = params[:role].nil? ? '2':params[:role]
|
|
|
|
@role = params[:role].nil? ? '2':params[:role]
|
|
|
|
@is_remote = true
|
|
|
|
@is_remote = true
|
|
|
@ -312,7 +319,7 @@ class CoursesController < ApplicationController
|
|
|
|
if @course.open_student == 1 || User.current.member_of_course?(@course)
|
|
|
|
if @course.open_student == 1 || User.current.member_of_course?(@course)
|
|
|
|
@subPage_title = l :label_student_list
|
|
|
|
@subPage_title = l :label_student_list
|
|
|
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
|
|
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
|
|
|
@all_members = student_homework_score(0,page, 10,"desc")
|
|
|
|
@all_members = student_homework_score(0,page, 10,@score_sort_by)
|
|
|
|
@members = @all_members
|
|
|
|
@members = @all_members
|
|
|
|
else
|
|
|
|
else
|
|
|
|
render_403
|
|
|
|
render_403
|
|
|
@ -350,28 +357,29 @@ class CoursesController < ApplicationController
|
|
|
|
@subPage_title = l :label_student_list
|
|
|
|
@subPage_title = l :label_student_list
|
|
|
|
@render_file = 'new_member_list'
|
|
|
|
@render_file = 'new_member_list'
|
|
|
|
@is_remote = true
|
|
|
|
@is_remote = true
|
|
|
|
|
|
|
|
@sort_type = params[:sort_type] if params[:sort_type]
|
|
|
|
@score_sort_by = params[:sort_by] if params[:sort_by]
|
|
|
|
@score_sort_by = params[:sort_by] if params[:sort_by]
|
|
|
|
@search_name = params[:search_name] if params[:search_name]
|
|
|
|
@search_name = params[:search_name] if params[:search_name]
|
|
|
|
group_id = params[:group_id]
|
|
|
|
group_id = params[:group_id]
|
|
|
|
if !@search_name.nil?
|
|
|
|
if !@search_name.nil?
|
|
|
|
if group_id == '0'
|
|
|
|
if group_id == '0'
|
|
|
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
|
|
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
|
|
|
@results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by), @search_name)
|
|
|
|
@results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by,@sort_type), @search_name)
|
|
|
|
@result_count = @results.count
|
|
|
|
@result_count = @results.count
|
|
|
|
# @results = paginateHelper @results, 10
|
|
|
|
# @results = paginateHelper @results, 10
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@group = CourseGroup.find(group_id)
|
|
|
|
@group = CourseGroup.find(group_id)
|
|
|
|
@results = searchmember_by_name(student_homework_score(group_id, 0, 0,@score_sort_by),@search_name)
|
|
|
|
@results = searchmember_by_name(student_homework_score(group_id, 0, 0,@score_sort_by,@sort_type),@search_name)
|
|
|
|
@result_count = @results.count
|
|
|
|
@result_count = @results.count
|
|
|
|
# @results = paginateHelper @results, 10
|
|
|
|
# @results = paginateHelper @results, 10
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if group_id == '0'
|
|
|
|
if group_id == '0'
|
|
|
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
|
|
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
|
|
|
@results = student_homework_score(0,page, 10,@score_sort_by)
|
|
|
|
@results = student_homework_score(0,page, 10,@score_sort_by,@sort_type)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@group = CourseGroup.find(group_id)
|
|
|
|
@group = CourseGroup.find(group_id)
|
|
|
|
@results = student_homework_score(group_id, 0, 0,@score_sort_by)
|
|
|
|
@results = student_homework_score(group_id, 0, 0,@score_sort_by,@sort_type)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -384,6 +392,15 @@ class CoursesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 显示每个学生的作业评分详情
|
|
|
|
|
|
|
|
def show_member_act_score
|
|
|
|
|
|
|
|
@member = Member.find(params[:member_id]) if params[:member_id]
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
|
|
|
format.html {render :layout => 'course_base'}
|
|
|
|
|
|
|
|
format.js
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def handle_course courses, activities
|
|
|
|
def handle_course courses, activities
|
|
|
|
course_activity_count_array=activities.values()
|
|
|
|
course_activity_count_array=activities.values()
|
|
|
|
course_array=[]
|
|
|
|
course_array=[]
|
|
|
@ -1149,7 +1166,7 @@ class CoursesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def student_homework_score(groupid,start_from, nums, score_sort_by)
|
|
|
|
def student_homework_score(groupid,start_from, nums, score_sort_by, sort_type = 'score')
|
|
|
|
start_from = start_from * nums
|
|
|
|
start_from = start_from * nums
|
|
|
|
sql_select = ""
|
|
|
|
sql_select = ""
|
|
|
|
if groupid == 0
|
|
|
|
if groupid == 0
|
|
|
@ -1159,11 +1176,13 @@ class CoursesController < ApplicationController
|
|
|
|
WHERE student_works.homework_common_id = homework_commons.id
|
|
|
|
WHERE student_works.homework_common_id = homework_commons.id
|
|
|
|
AND homework_commons.course_id = #{@course.id}
|
|
|
|
AND homework_commons.course_id = #{@course.id}
|
|
|
|
AND student_works.user_id = members.user_id
|
|
|
|
AND student_works.user_id = members.user_id
|
|
|
|
) AS score
|
|
|
|
) 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 = 577 AND ccs.user_id = members.user_id
|
|
|
|
|
|
|
|
) AS act_score
|
|
|
|
FROM members
|
|
|
|
FROM members
|
|
|
|
JOIN students_for_courses
|
|
|
|
JOIN students_for_courses
|
|
|
|
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
|
|
|
|
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 score #{score_sort_by}"
|
|
|
|
WHERE members.course_id = #{@course.id} ORDER BY #{sort_type} #{score_sort_by}"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
sql_select = "SELECT members.*,(
|
|
|
|
sql_select = "SELECT members.*,(
|
|
|
|
SELECT SUM(student_works.work_score)
|
|
|
|
SELECT SUM(student_works.work_score)
|
|
|
@ -1171,11 +1190,13 @@ class CoursesController < ApplicationController
|
|
|
|
WHERE student_works.homework_common_id = homework_commons.id
|
|
|
|
WHERE student_works.homework_common_id = homework_commons.id
|
|
|
|
AND homework_commons.course_id = #{@course.id}
|
|
|
|
AND homework_commons.course_id = #{@course.id}
|
|
|
|
AND student_works.user_id = members.user_id
|
|
|
|
AND student_works.user_id = members.user_id
|
|
|
|
) AS score
|
|
|
|
) 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 = 577 AND ccs.user_id = members.user_id
|
|
|
|
|
|
|
|
) AS act_score
|
|
|
|
FROM members
|
|
|
|
FROM members
|
|
|
|
JOIN students_for_courses
|
|
|
|
JOIN students_for_courses
|
|
|
|
ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id
|
|
|
|
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 score #{score_sort_by}"
|
|
|
|
WHERE members.course_id = #{@course.id} AND members.course_group_id = #{groupid} ORDER BY #{sort_type} #{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)
|
|
|
@ -1225,8 +1246,7 @@ class CoursesController < ApplicationController
|
|
|
|
sheet1[5,i+4] = "第"+(i+1).to_s+"次"
|
|
|
|
sheet1[5,i+4] = "第"+(i+1).to_s+"次"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
sheet1[5,homeworks.count+4] = "总成绩"
|
|
|
|
sheet1[5,homeworks.count+4] = "总成绩"
|
|
|
|
sheet1[5,0] = "排名"
|
|
|
|
sheet1[5,homeworks.count+5] = "活跃度"
|
|
|
|
sheet1[5,0] = "排名"
|
|
|
|
|
|
|
|
count_row = 6
|
|
|
|
count_row = 6
|
|
|
|
members.each_with_index do |member, i|
|
|
|
|
members.each_with_index do |member, i|
|
|
|
|
sheet1[count_row,0]= i+1
|
|
|
|
sheet1[count_row,0]= i+1
|
|
|
@ -1236,14 +1256,15 @@ class CoursesController < ApplicationController
|
|
|
|
homeworks.each_with_index do |homework, j|
|
|
|
|
homeworks.each_with_index do |homework, j|
|
|
|
|
student_works = homework.student_works.where("user_id = #{member.user.id}")
|
|
|
|
student_works = homework.student_works.where("user_id = #{member.user.id}")
|
|
|
|
if student_works.empty?
|
|
|
|
if student_works.empty?
|
|
|
|
sheet1[count_row,j+4] = format("%0.2f",0)
|
|
|
|
sheet1[count_row,j+4] = 0
|
|
|
|
else
|
|
|
|
else
|
|
|
|
final_score = student_works.first.final_score.nil? ? 0 : student_works.first.final_score
|
|
|
|
final_score = student_works.first.final_score.nil? ? 0 : student_works.first.final_score
|
|
|
|
score = final_score - student_works.first.absence_penalty - student_works.first.late_penalty
|
|
|
|
score = final_score - student_works.first.absence_penalty - student_works.first.late_penalty
|
|
|
|
sheet1[count_row,j+4] = format("%0.2f",score <0 ? 0:score)
|
|
|
|
sheet1[count_row,j+4] = score <0 ? 0:score.round(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
sheet1[count_row,homeworks.count+4] = format("%0.2f",member.score.nil? ? 0:member.score.to_s)
|
|
|
|
sheet1[count_row,homeworks.count+4] = member.score.nil? ? 0:member.score.round(2)
|
|
|
|
|
|
|
|
sheet1[count_row,homeworks.count+5] = member.act_score.nil? ? 0:member.act_score
|
|
|
|
count_row += 1
|
|
|
|
count_row += 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|