课堂成绩导出调整

dev_haigong
cxt 6 years ago
parent 12cb81b3e8
commit 1192a3c93d

@ -1190,9 +1190,9 @@ class CoursesController < ApplicationController
@all_members = searchmember_by_name(student_homework_score(0, 0, 10,"desc"), q)
end
@homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("publish_time asc")
@exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("publish_time asc")
@tasks = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").order("publish_time asc")
@homeworks = @course.homework_commons.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC")
@exercises = @course.exercises.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC")
@tasks = @course.graduation_tasks.where("publish_time <= '#{Time.now}'").order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC")
respond_to do |format|
format.xls {
@ -2425,7 +2425,7 @@ class CoursesController < ApplicationController
sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name
# current_col = 5
shixun_score = 0
homeworks.where(:homework_type => 4).each do |homework|
homeworks.where(:homework_type => 4).includes(:student_works).each do |homework|
student_works = homework.student_works.where("user_id = #{member.user.id}")
if student_works.empty?
sheet1[count_row,column+=1] = 0
@ -2437,7 +2437,7 @@ class CoursesController < ApplicationController
# current_col += 1
end
common_score = 0
homeworks.where(:homework_type => 1).each do |homework|
homeworks.where(:homework_type => 1).includes(:student_works).each do |homework|
student_works = homework.student_works.where("user_id = #{member.user.id}")
if student_works.empty?
sheet1[count_row,column+=1] = 0
@ -2449,7 +2449,7 @@ class CoursesController < ApplicationController
# current_col += 1
end
group_score = 0
homeworks.where(:homework_type => 3).each do |homework|
homeworks.where(:homework_type => 3).includes(:student_works).each do |homework|
student_works = homework.student_works.where("user_id = #{member.user.id}")
if student_works.empty?
sheet1[count_row,column+=1] = 0
@ -2461,7 +2461,7 @@ class CoursesController < ApplicationController
# current_col += 1
end
exercise_score = 0
exercises.each do |exercise|
exercises.includes(:exercise_users).each do |exercise|
exercise_user = exercise.exercise_users.where("user_id = #{member.user.id}")
if exercise_user.empty?
sheet1[count_row,column+=1] = 0
@ -2474,7 +2474,7 @@ class CoursesController < ApplicationController
end
graduation_score = 0
tasks.each do |task|
tasks.includes(:graduation_works).each do |task|
graduation_works = task.graduation_works.where("user_id = #{member.user.id}")
if graduation_works.empty?
sheet1[count_row,column+=1] = 0
@ -2550,7 +2550,7 @@ class CoursesController < ApplicationController
count_row += 1
end
homeworks.where(:homework_type => 4).each_with_index do |home, i|
homeworks.where(:homework_type => 4).includes(:student_works).each_with_index do |home, i|
sheet = book.create_worksheet :name => "实训作业第#{i+1}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id
@ -2567,6 +2567,10 @@ class CoursesController < ApplicationController
sheet.row(4).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_des),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)])
count_row = 5
items = home.student_works.where("work_status != 0").order("work_score desc")
if items.count == 0 && home.publish_time < Time.now && !course.is_end
update_shixun_work_status home
items = StudentWork.where("work_status != 0 and homework_common_id = #{home.id}").order("work_score desc")
end
items.each_with_index do |stu, j|
sheet[count_row,0]= j + 1
sheet[count_row,1] = stu.user.show_real_name
@ -2580,7 +2584,7 @@ class CoursesController < ApplicationController
end
end
homeworks.where(:homework_type => 1).each_with_index do |home, i|
homeworks.where(:homework_type => 1).includes(:student_works).each_with_index do |home, i|
sheet = book.create_worksheet :name => "普通作业第#{i+1}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id
@ -2627,7 +2631,7 @@ class CoursesController < ApplicationController
end
homeworks.where(:homework_type => 3).each_with_index do |home, i|
homeworks.where(:homework_type => 3).includes(:student_works).each_with_index do |home, i|
sheet = book.create_worksheet :name => "分组作业第#{i+1}"
sheet[0,0] = "课程编号"
sheet[0,1] = course.id

@ -6521,6 +6521,67 @@ def visible_task_count course, is_teacher
task_count
end
def update_shixun_work_status homework
shixun = homework.shixuns.first
student_works = homework.student_works.where(:work_status => 0)
homework_challenge_settings = homework.homework_challenge_settings
challeng_ids = homework_challenge_settings.map(&:challenge_id)
# 取已发布的作品
if homework.unified_setting
student_works = student_works
else
setting = homework.homework_group_settings.where("publish_time < '#{Time.now}'")
if setting.blank?
student_works = student_works.where("0=1")
else
users = homework.course.members.where(:course_group_id => setting.map(&:course_group_id))
student_works = student_works.where(:user_id => users.map(&:user_id))
end
end
# 已发布作品且状态为未提交的作品 如果有开启过实训则更新状态
myshixuns = Myshixun.where(:shixun_id => shixun.id, :user_id => student_works.map(&:user_id))
myshixuns.each do |myshixun|
work = student_works.where(:user_id => myshixun.user_id).first
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{work.user_id}").first
setting_time = homework_group_setting homework, member.try(:course_group_id)
games = myshixun.games.where(:challenge_id => challeng_ids)
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
compelete_status = 0
if myshixun_endtime.present? && myshixun_endtime < setting_time.end_time
if myshixun_endtime < setting_time.publish_time
compelete_status = 2
else
compelete_status = 1
end
end
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
# 更新所有学生的效率分
update_student_eff_score HomeworkCommon.where(:id => homework.id).first
=begin
student_works.each do |work|
if work.work_status == 0
myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => work.user_id).first
if myshixun
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first
setting_time = homework_group_setting homework, member.try(:course_group_id)
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id)
end
end
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
=end
end
#成绩计算
def set_final_score homework,student_work
if homework && homework.homework_detail_manual && !student_work.ultimate_score

@ -3,67 +3,6 @@ include UserScoreHelper
module StudentWorkHelper
def update_shixun_work_status homework
shixun = homework.homework_commons_shixuns.shixun
student_works = homework.student_works.where(:work_status => 0)
homework_challenge_settings = homework.homework_challenge_settings
challeng_ids = homework_challenge_settings.map(&:challenge_id)
# 取已发布的作品
if homework.unified_setting
student_works = student_works
else
setting = homework.homework_group_settings.where("publish_time < '#{Time.now}'")
if setting.blank?
student_works = student_works.where("0=1")
else
users = homework.course.members.where(:course_group_id => setting.map(&:course_group_id))
student_works = student_works.where(:user_id => users.map(&:user_id))
end
end
# 已发布作品且状态为未提交的作品 如果有开启过实训则更新状态
myshixuns = Myshixun.where(:shixun_id => shixun.id, :user_id => student_works.map(&:user_id))
myshixuns.each do |myshixun|
work = student_works.where(:user_id => myshixun.user_id).first
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{work.user_id}").first
setting_time = homework_group_setting homework, member.try(:course_group_id)
games = myshixun.games.where(:challenge_id => challeng_ids)
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
compelete_status = 0
if myshixun_endtime.present? && myshixun_endtime < setting_time.end_time
if myshixun_endtime < setting_time.publish_time
compelete_status = 2
else
compelete_status = 1
end
end
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id, :compelete_status => compelete_status)
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
# 更新所有学生的效率分
update_student_eff_score HomeworkCommon.where(:id => homework.id).first
=begin
student_works.each do |work|
if work.work_status == 0
myshixun = Myshixun.where(:shixun_id => shixun.id, :user_id => work.user_id).first
if myshixun
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first
setting_time = homework_group_setting homework, member.try(:course_group_id)
if setting_time.end_time > Time.now
work.update_attributes(:work_status => 1, :late_penalty => 0, :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id)
else
work.update_attributes(:work_status => ((myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)) ? 1 : 2), :late_penalty => (myshixun.is_complete? && (myshixun.done_time < setting_time.end_time) ? 0 : homework.late_penalty), :commit_time => myshixun.updated_at, :update_time => myshixun.updated_at, :myshixun_id => myshixun.id)
end
end
end
set_shixun_final_score work, homework.homework_detail_manual.answer_open_evaluation, homework_challenge_settings
end
=end
end
#获取当前用户的项目列表
def user_projects_option
projects = User.current.projects.visible

Loading…
Cancel
Save