Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
jasder 5 years ago
commit 64989686d1

@ -45,7 +45,13 @@ class CommonsController < ApplicationController
code = code =
case params[:object_type].strip case params[:object_type].strip
when 'message' when 'message'
if current_user.course_identity(@object.board.course) >= 5 && @object.author != current_user if current_user.course_identity(@object.board.course) >= Course::STUDENT && @object.author != current_user
403
else
200
end
when 'journals_for_message'
if current_user.course_identity(@object.jour.course) >= Course::STUDENT && @object.user != current_user
403 403
else else
200 200

@ -1040,6 +1040,7 @@ class ExercisesController < ApplicationController
@exercise_questions = @exercise_questions.order("question_number ASC") @exercise_questions = @exercise_questions.order("question_number ASC")
end end
# 判断问题是否已回答还是未回答 # 判断问题是否已回答还是未回答
@exercise_questions = @exercise_questions.includes(:exercise_stand_answers,:exercise_answers,:exercise_shixun_answers)
if @t_user_exercise_status == 3 if @t_user_exercise_status == 3
get_each_student_exercise(@exercise.id,@exercise_questions,@exercise_current_user_id) get_each_student_exercise(@exercise.id,@exercise_questions,@exercise_current_user_id)
@ -1129,7 +1130,7 @@ class ExercisesController < ApplicationController
@is_teacher_or = @user_course_identity < Course::STUDENT ? 1 : 0 @is_teacher_or = @user_course_identity < Course::STUDENT ? 1 : 0
@student_status = 2 @student_status = 2
# @exercise_answerer = User.find_by(id:@exercise_current_user_id) #试卷回答者 # @exercise_answerer = User.find_by(id:@exercise_current_user_id) #试卷回答者
@exercise_questions = @exercise.exercise_questions.order("question_number ASC") @exercise_questions = @exercise.exercise_questions.includes(:exercise_shixun_challenges,:exercise_standard_answers,:exercise_answers,:exercise_shixun_answers).order("question_number ASC")
@question_status = [] @question_status = []
get_exercise_status = @exercise.get_exercise_status(current_user) get_exercise_status = @exercise.get_exercise_status(current_user)
if @ex_user.present? && @is_teacher_or == 0 if @ex_user.present? && @is_teacher_or == 0
@ -1188,7 +1189,7 @@ class ExercisesController < ApplicationController
elsif @user_course_identity > Course::ASSISTANT_PROFESSOR #当前为学生或者有过答题的(提交/未提交) elsif @user_course_identity > Course::ASSISTANT_PROFESSOR #当前为学生或者有过答题的(提交/未提交)
@ex_user_end_time = @exercise.get_exercise_end_time(current_user.id) #当前用户所看到的剩余时间 @ex_user_end_time = @exercise.get_exercise_end_time(current_user.id) #当前用户所看到的剩余时间
@exercise_all_users = @exercise.get_stu_exercise_users @exercise_all_users = @exercise.get_stu_exercise_users
get_exercise_answers(@exercise_users_list, @exercise_status) # 未答和已答的 get_exercise_answers(@exercise_all_users, @exercise_status) # 未答和已答的
exercise_current_user = @exercise_all_users.exercise_commit_users(current_user.id) #当前用户是否开始做试卷(提交/未提交/没做) exercise_current_user = @exercise_all_users.exercise_commit_users(current_user.id) #当前用户是否开始做试卷(提交/未提交/没做)
if exercise_current_user.present? if exercise_current_user.present?
@exercise_current_user_status = 1 #当前用户的状态,为学生 @exercise_current_user_status = 1 #当前用户的状态,为学生
@ -1202,7 +1203,7 @@ class ExercisesController < ApplicationController
end end
else else
@exercise_all_users = @exercise.get_stu_exercise_users @exercise_all_users = @exercise.get_stu_exercise_users
get_exercise_answers(@exercise_users_list, @exercise_status) # 未答和已答的 get_exercise_answers(@exercise_all_users, @exercise_status) # 未答和已答的
@exercise_current_user_status = 2 #当前用户非课堂成员 @exercise_current_user_status = 2 #当前用户非课堂成员
@exercise_users_list = [] @exercise_users_list = []
end end

@ -118,11 +118,11 @@ class HomeworkCommonsController < ApplicationController
# 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段
if @work&.work_status.to_i > 0 && (@homework.work_public || @homework.score_open) && if @work&.work_status.to_i > 0 && (@homework.work_public || @homework.score_open) &&
((!@homework.anonymous_comment && @homework.end_or_late) || @homework_detail_manual.comment_status > 4) ((!@homework.anonymous_comment && @homework.end_or_late) || (@homework_detail_manual.comment_status > 4 && @homework.end_or_late))
@student_works = student_works.where("user_id != #{@work.user_id}") @student_works = student_works.where("user_id != #{@work.user_id}")
# 匿评、申诉阶段只能看到分配给自己的匿评作品 # 匿评、申诉阶段只能看到分配给自己的匿评作品
elsif @work&.work_status.to_i > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2 elsif @work&.work_status.to_i > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2 && @homework_detail_manual.comment_status <= 4
@is_evaluation = true @is_evaluation = true
@student_works = student_works.joins(:student_works_evaluation_distributions).where( @student_works = student_works.joins(:student_works_evaluation_distributions).where(
"student_works_evaluation_distributions.user_id = #{@current_user.id}") "student_works_evaluation_distributions.user_id = #{@current_user.id}")
@ -240,7 +240,7 @@ class HomeworkCommonsController < ApplicationController
end end
def update_score def update_score
tip_exception("作业还未发布,暂不能计算成绩") if @homework.end_or_late_none_group tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now
begin begin
if @homework.unified_setting if @homework.unified_setting
student_works = @homework.student_works student_works = @homework.student_works
@ -1354,7 +1354,7 @@ class HomeworkCommonsController < ApplicationController
if results.status == 0 if results.status == 0
code_info = results.code_info code_info = results.code_info
homework_challenge_settings = @homework.homework_challenge_settings homework_challenge_settings = @homework.homework_challenge_settings
@challenges = @shixun.challenges.where(id: homework_challenge_settings.pluck(:challenge_id), st: 0).includes(:games) @challenges = @shixun.challenges.where(id: homework_challenge_settings.pluck(:challenge_id), st: 0)
@challenges = @challenges =
@challenges.map do |challenge| @challenges.map do |challenge|
code_rate = 0 code_rate = 0
@ -1368,24 +1368,8 @@ class HomeworkCommonsController < ApplicationController
game = challenge.games.find_by(user_id: @user.id) game = challenge.games.find_by(user_id: @user.id)
end_time = game.end_time end_time = game.end_time
# 用户关卡的得分 # 用户关卡的得分
all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score) all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f
final_score = final_score = @student_work.work_challenge_score game, all_score
if @student_work.challenge_work_scores.where(challenge_id: challenge.id).last.present?
@student_work.challenge_work_scores.where(:challenge_id => game.challenge_id).last.score
else
if game.status == 2 && ((game.end_time && game.end_time < @homework.end_time) ||
(@homework.allow_late && (@course.end_date.nil? ||
(game.end_time && game.end_time < @course.end_date.end_of_day))))
answer_open_evaluation = @homework.homework_detail_manual.answer_open_evaluation
# 设置了查看答案也获得满分的话就取总分。否则取关卡的百分比分支
if answer_open_evaluation.present?
all_score
else
# 关卡的百分比 * 作业设置的分数 = 总得分
((game.final_score) / challenge.score) * all_score
end
end
end
# 抄袭用户 # 抄袭用户
copy_user = User.find_by_id(game_codes[0].target_user_id) copy_user = User.find_by_id(game_codes[0].target_user_id)
copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present? copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present?

@ -631,16 +631,35 @@ class StudentWorksController < ApplicationController
# 查重作品调分 # 查重作品调分
def adjust_review_score def adjust_review_score
if params[:score].nil? || params[:challenge_id].nil? || params[:code_rate].nil? || params[:copy_user_id].nil? tip_exception("缺少type参数") if params[:type].blank? || !["review", "report"].include?(params[:type])
if params[:type] == "review" && (params[:score].nil? || params[:challenge_id].nil? || params[:code_rate].nil? || params[:copy_user_id].nil?)
tip_exception("参数错误score和challenge_id和code_rate和copy_user_id不能为空") tip_exception("参数错误score和challenge_id和code_rate和copy_user_id不能为空")
elsif params[:type] == "report" && (params[:score].nil? || params[:challenge_id].nil?)
tip_exception("参数错误score和challenge_id")
end end
challenge_setting = @homework.homework_challenge_settings.find_by(challenge_id: params[:challenge_id])
challenge = challenge_setting&.challenge
tip_exception("不能小于零") if params[:score] < 0
tip_exception("不能大于关卡分值:#{challenge_setting.score}") if challenge_setting.score < params[:score]
ActiveRecord::Base.transaction do
begin
if params[:type] == "review"
copy_user = User.find params[:copy_user_id] copy_user = User.find params[:copy_user_id]
comment = "代码查重结果显示与#{copy_user.try(:show_real_name)}的代码相似度#{params[:code_rate]}%" comment = "代码查重结果显示与#{copy_user.try(:show_real_name)}的代码相似度#{params[:code_rate]}%"
@work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score], else
comment = "根据实训报告中最终提交的代码调整第#{challenge.position}关分数"
end
challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
comment: comment) comment: comment)
HomeworksService.new.set_shixun_final_score(@work) challenge_score.create_tiding current_user.id
@work_score = @homework.student_works.find_by(id: @work.id).try(:work_score) HomeworksService.new.update_myshixun_work_score @work, @work&.myshixun, @work&.myshixun&.games, @homework, @homework.homework_challenge_settings
rescue Exception => e
uid_logger(e.message)
tip_exception(e.message)
raise ActiveRecord::Rollback
end
end
end end

@ -9,9 +9,29 @@ module ExercisesHelper
@ex_obj_array = [] @ex_obj_array = []
exercise_obj_status.each do |q| exercise_obj_status.each do |q|
if q.question_type == 5 if q.question_type == 5
ques_score = q.exercise_shixun_answers.search_shixun_answers("user_id",user_id).pluck(:score).sum answers_content = q.exercise_shixun_answers.search_shixun_answers("user_id",user_id)
else else
ques_score = q.exercise_answers.search_answer_users("user_id",user_id).score_reviewed.pluck(:score).sum answers_content = q.exercise_answers.search_answer_users("user_id",user_id)
end
if q.question_type <= 2
if answers_content.present? #学生有回答时
answer_choice_array = []
answers_content.each do |a|
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
end
user_answer_content = answer_choice_array.sort
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
ques_score = q.question_score
else
ques_score = 0.0
end
else
ques_score = 0.0
end
else
ques_score = answers_content.select(:score).pluck(:score).sum
end end
if ques_score >= q.question_score #满分作答为正确 if ques_score >= q.question_score #满分作答为正确
@ -370,7 +390,8 @@ module ExercisesHelper
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
if standard_answer.count > 0 if standard_answer.count > 0
q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时每个answer的分数均摊。 q_score_1 = q.question_score
# q_score_1 = (q.question_score.to_f / standard_answer.count) #当多选答案正确时每个answer的分数均摊。
else else
q_score_1 = 0.0 q_score_1 = 0.0
end end
@ -641,6 +662,7 @@ module ExercisesHelper
user_score = nil user_score = nil
shixun_type = 0 shixun_type = 0
question_comment = [] question_comment = []
# user_score_pre = nil
if ques_type == 5 if ques_type == 5
exercise_answers = q.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer_id) exercise_answers = q.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer_id)
else else
@ -648,10 +670,26 @@ module ExercisesHelper
end end
if student_status == 2 #当前为老师,或为学生且已提交 if student_status == 2 #当前为老师,或为学生且已提交
user_score_pre = exercise_answers.score_reviewed user_score_pre = exercise_answers.score_reviewed
if ques_type == 4 && user_score_pre.blank? #主观题时且没有大于0的分数时为空 if ques_type == 4 #主观题时且没有大于0的分数时为空
user_score = nil user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil
else elsif ques_type == 5 || ques_type == 3
user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0 user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : 0.0
else
if exercise_answers.present? #判断题和选择题时,
answer_choice_array = []
exercise_answers.each do |a|
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
end
user_answer_content = answer_choice_array.sort
standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个
if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分
user_score = q.question_score
else
user_score = 0.0
end
else
user_score = 0.0
end
end end
end end
@ -659,9 +697,9 @@ module ExercisesHelper
user_score = q.question_score user_score = q.question_score
end end
if ques_type <= 2 if ques_type <= 2
answered_content = exercise_answers.pluck(:exercise_choice_id) answered_content = exercise_answers&.pluck(:exercise_choice_id)
elsif ques_type == 3 elsif ques_type == 3
exercise_answers.each do |a| exercise_answers&.each do |a|
u_answer = { u_answer = {
"choice_id":a.exercise_choice_id, "choice_id":a.exercise_choice_id,
"answer_text": a.answer_text "answer_text": a.answer_text
@ -669,7 +707,7 @@ module ExercisesHelper
answered_content.push(u_answer) answered_content.push(u_answer)
end end
elsif ques_type == 4 elsif ques_type == 4
answered_content = exercise_answers.pluck(:answer_text) answered_content = exercise_answers&.pluck(:answer_text)
end end
if ques_type == 5 #存在实训题,及已经做了实训题的 if ques_type == 5 #存在实训题,及已经做了实训题的
if ex_status == 3 || is_teacher_or == 1 #如果试卷已截止,则可以看到分数,否则不能查看分数 if ex_status == 3 || is_teacher_or == 1 #如果试卷已截止,则可以看到分数,否则不能查看分数

@ -100,7 +100,7 @@ module ExportHelper
user_time = format_time(t.updated_at) user_time = format_time(t.updated_at)
user_score = t&.score user_score = t&.score
user_comment = t.comment.present? ? t.comment : "--" user_comment = t.comment.present? ? t.comment : "--"
comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}\n评语:#{user_comment}\n\n" comment_title = "#{user_name} #{user_time.to_s} #{user_score.to_s}\n#{user_comment}\n\n"
w_18 = w_18 + comment_title w_18 = w_18 + comment_title
end end
else else
@ -172,7 +172,7 @@ module ExportHelper
user_time = format_time(t.updated_at) user_time = format_time(t.updated_at)
user_score = t&.score user_score = t&.score
user_comment = t.comment.present? ? t.comment : "--" user_comment = t.comment.present? ? t.comment : "--"
comment_title = "教师:#{user_name}\n时间:#{user_time.to_s}\n分数:#{user_score.to_s}\n评语:#{user_comment}\n\n" comment_title = "#{user_name} #{user_time.to_s} #{user_score.to_s}\n#{user_comment}\n\n"
# ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n") # ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n")
w_18 = w_18 + comment_title w_18 = w_18 + comment_title
end end
@ -206,7 +206,7 @@ module ExportHelper
head_cells_format = head_cells_format + ["交叉评分"] head_cells_format = head_cells_format + ["交叉评分"]
end end
head_cells_format = head_cells_format + %w(迟交扣分 最终成绩 提交时间 更新时间) head_cells_format = head_cells_format + %w(迟交扣分 最终成绩 提交时间 更新时间 评语)
@head_cells_column = head_cells_format @head_cells_column = head_cells_format
@task_cells_column = [] @task_cells_column = []
@ -257,8 +257,22 @@ module ExportHelper
w_13 = work.work_score.nil? ? "未评分" : work.work_score.round(1) w_13 = work.work_score.nil? ? "未评分" : work.work_score.round(1)
w_14 = work.commit_time.present? ? format_time(work.commit_time) : "--" w_14 = work.commit_time.present? ? format_time(work.commit_time) : "--"
w_15 = work.update_time.present? ? format_time(work.update_time) : "--" w_15 = work.update_time.present? ? format_time(work.update_time) : "--"
teacher_comments = work.graduation_work_scores
row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15] if teacher_comments.present?
w_16 = ""
teacher_comments.each do |t|
user_name = t.user&.real_name
user_time = format_time(t.updated_at)
user_score = t&.score
user_comment = t.comment.present? ? t.comment : "--"
comment_title = "#{user_name} #{user_time.to_s} #{user_score.to_s}\n#{user_comment}\n\n"
# ("教师:" + user_name + "\n" + "时间:" + user_time.to_s + "\n" + "分数:" + user_score.to_s + "分" + "\n" + "评语:" + user_comment + "\n\n")
w_16 = w_16 + comment_title
end
else
w_16 = "--"
end
row_cells_column = [w_1,w_2,w_3,w_3_1,w_4,w_5,w_6,w_7,w_8,w_9,w_10,w_11,w_12,w_13,w_14,w_15,w_16]
row_cells_column = row_cells_column.reject(&:blank?) row_cells_column = row_cells_column.reject(&:blank?)
@task_cells_column.push(row_cells_column) @task_cells_column.push(row_cells_column)

@ -2,4 +2,12 @@ class ChallengeWorkScore < ApplicationRecord
belongs_to :user belongs_to :user
belongs_to :student_work belongs_to :student_work
belongs_to :challenge belongs_to :challenge
has_many :tidings, as: :container, dependent: :destroy
def create_tiding trigger_user_id
tidings << Tiding.new(user_id: student_work.user_id, trigger_user_id: trigger_user_id, container_id: id,
container_type: "ChallengeWorkScore", parent_container_id: student_work_id,
parent_container_type: "StudentWork", belong_container_id: student_work&.homework_common&.course_id,
belong_container_type: "Course", viewed: 0, tiding_type: "HomeworkCommon")
end
end end

@ -104,7 +104,6 @@ class Exercise < ApplicationRecord
published_group_ids published_group_ids
end end
#判断用户是否属于试卷分班的学生中 #判断用户是否属于试卷分班的学生中
def check_user_in_course(user_id,user_identity) def check_user_in_course(user_id,user_identity)
ex_group_settings = exercise_group_settings.pluck(:course_group_id) ex_group_settings = exercise_group_settings.pluck(:course_group_id)

@ -260,4 +260,8 @@ class HomeworkCommon < ApplicationRecord
self.homework_group_settings.where("end_time is not null").pluck(:end_time).max self.homework_group_settings.where("end_time is not null").pluck(:end_time).max
end end
def challenge_score challenge_id
homework_challenge_settings.find_by(challenge_id: challenge_id)&.score.to_f
end
end end

@ -86,15 +86,16 @@ class Poll < ApplicationRecord
def poll_published_ids(user_id) def poll_published_ids(user_id)
current_user_groups = course.teacher_course_ids(user_id) current_user_groups = course.teacher_course_ids(user_id)
if unified_setting if unified_setting
if course.none_group_count > 0 #有未分班的,则发布到未发布 current_user_groups.uniq
un_group_ids = [0] # if course.none_group_count > 0 #有未分班的,则发布到未发布
else # un_group_ids = [0]
un_group_ids = [] # else
end # un_group_ids = []
(current_user_groups + un_group_ids).uniq #统一设置时为当前用户的分班id # end
# (current_user_groups + un_group_ids).uniq #统一设置时为当前用户的分班id
else else
ex_group_setting = poll_group_settings.select(:course_group_id).pluck("course_group_id").uniq ex_group_setting = poll_group_settings.select(:course_group_id).pluck("course_group_id").uniq
ex_group_setting & current_user_groups #当前用户有权限的已发布的分班id #非统一设置时为当前用户有权限的且已发布分班的id (ex_group_setting & current_user_groups).uniq #当前用户有权限的已发布的分班id #非统一设置时为当前用户有权限的且已发布分班的id
end end
end end

@ -73,9 +73,8 @@ class Shixun < ApplicationRecord
# 实训用户tag # 实训用户tag
def user_tags_name(user = User.current) def user_tags_name(user = User.current)
challenge_ids = challenges.pluck(:id) Shixun.joins(challenges: [:challenge_tags, :games]).where(games: {status: 2, user_id: user.id}, shixuns: {id:id})
user_challenge_ids = user.games.where(challenge_id: challenge_ids, status: 2).pluck(:challenge_id) .pluck("challenge_tags.name").uniq
ChallengeTag.where(challenge_id: user_challenge_ids).pluck(:name).uniq
end end
# 实训关卡tag # 实训关卡tag
@ -158,13 +157,11 @@ class Shixun < ApplicationRecord
# 实训评分信息 # 实训评分信息
# return [实训评分, 5星评分比例 4星评分比例 3星评分比例 2星评分比例 1星评分比例] # return [实训评分, 5星评分比例 4星评分比例 3星评分比例 2星评分比例 1星评分比例]
def shixun_preference_info def shixun_preference_info
game_star_info = Game.find_by_sql("select g.star from game_star_info = Game.joins(challenge: :shixun).where(shixuns: {id: id}).where.not(games: {star: 0}).pluck(:star)
(games g left join (myshixuns m join shixuns s on s.id = m.shixun_id) on m.id = g.myshixun_id)
where g.star != 0 and s.id = #{self.id}")
star_info = [] star_info = []
if game_star_info.present? if game_star_info.present?
5.downto(1) do |i| 5.downto(1) do |i|
star_info << ((game_star_info.select{|s| s.star == i}.count / game_star_info.count.to_f) * 100).round star_info << ((game_star_info.select{|s| s == i}.count / game_star_info.count.to_f) * 100).round
end end
sum = star_info.sum sum = star_info.sum
max = star_info.max max = star_info.max
@ -175,7 +172,7 @@ class Shixun < ApplicationRecord
star_info = star_info.map{|s| s == max ? s + 1 : s} star_info = star_info.map{|s| s == max ? s + 1 : s}
end end
cnt = game_star_info.count cnt = game_star_info.count
sum = game_star_info.sum(&:star) sum = game_star_info.sum
star_info.unshift((sum / cnt.to_f).round(1)) star_info.unshift((sum / cnt.to_f).round(1))
else else
star_info = [5.0, 100, 0, 0, 0, 0] star_info = [5.0, 100, 0, 0, 0, 0]

@ -193,4 +193,19 @@ class StudentWork < ApplicationRecord
def scored? def scored?
student_works_scores.where.not(reviewer_role: 3).exists? student_works_scores.where.not(reviewer_role: 3).exists?
end end
def work_challenge_score game, score
game_score = 0
adjust_score = challenge_work_scores.where(challenge_id: game.challenge_id).last
if adjust_score.present?
game_score = adjust_score.score
else
setting = homework_common.homework_group_setting user_id
if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && game.end_time && game.end_time < homework_common.late_time))
answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation
game_score = answer_open_evaluation ? score : (game.final_score > 0 ? game.real_score(score) : 0)
end
end
game_score
end
end end

@ -4,7 +4,7 @@ wb.styles do |s|
no_wrap_sz = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: false,:horizontal => :center,:vertical => :center } no_wrap_sz = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: false,:horizontal => :center,:vertical => :center }
sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center } sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
row_cell = s.add_style :bg_color=> "FAEBDC",:border => { :style => :thin, :color =>"000000" },alignment: {wrap_text: true,:horizontal => :center,:vertical => :center } row_cell = s.add_style :bg_color=> "FAEBDC",:border => { :style => :thin, :color =>"000000" },alignment: {wrap_text: true,:horizontal => :center,:vertical => :center }
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
#课堂信息摘要 #课堂信息摘要
wb.add_worksheet(name:course_info[0]) do |sheet| wb.add_worksheet(name:course_info[0]) do |sheet|
@ -32,12 +32,12 @@ wb.styles do |s|
sheet.sheet_view.show_grid_lines = false sheet.sheet_view.show_grid_lines = false
sheet_title = activity_level[1] sheet_title = activity_level[1]
sheet_content = activity_level[2] sheet_content = activity_level[2]
sheet.add_row sheet_title, :style => blue_cell sheet.add_row sheet_title, :height => 25,:style => blue_cell
if sheet_content.count > 0 if sheet_content.count > 0
sheet_content.each_with_index do |c,index| sheet_content.each_with_index do |c,index|
c_1 = (index+1) c_1 = (index+1)
c_2 = [c_1] + c.values c_2 = [c_1] + c.values
sheet.add_row c_2, :style => sz_all #用户id sheet.add_row c_2, :height => 25, :style => sz_all #用户id
end end
sheet.column_widths *([20]*sheet.column_info.count) sheet.column_widths *([20]*sheet.column_info.count)
sheet.column_info.first.width = 8 sheet.column_info.first.width = 8
@ -82,7 +82,7 @@ wb.styles do |s|
sheet_content.each_with_index do |c,index| sheet_content.each_with_index do |c,index|
c_1 = (index+1) c_1 = (index+1)
c_2 = [c_1] + c c_2 = [c_1] + c
sheet.add_row c_2, :style => sz_all #用户id sheet.add_row c_2, :height => 25,:style => sz_all #用户id
end end
end end
sheet.column_widths *([15]*sheet.column_info.count) sheet.column_widths *([15]*sheet.column_info.count)
@ -100,7 +100,7 @@ wb.styles do |s|
sheet.add_row head_title, :style => blue_cell sheet.add_row head_title, :style => blue_cell
if content_shixun.count > 0 if content_shixun.count > 0
content_shixun.each do |user| content_shixun.each do |user|
sheet.add_row user, :style => sz_all sheet.add_row user, :height => 25,:style => sz_all
end #each_widh_index end #each_widh_index
end end
sheet.column_widths *([20]*sheet.column_info.count) sheet.column_widths *([20]*sheet.column_info.count)
@ -119,7 +119,7 @@ wb.styles do |s|
sheet.add_row head_title, :style => blue_cell sheet.add_row head_title, :style => blue_cell
if content_.count > 0 if content_.count > 0
content_.each do |user| content_.each do |user|
sheet.add_row user, :style => no_wrap_sz sheet.add_row user, :height => 25,:style => no_wrap_sz
end #each_widh_index end #each_widh_index
end end
sheet.column_widths *([20]*sheet.column_info.count) sheet.column_widths *([20]*sheet.column_info.count)
@ -138,7 +138,7 @@ wb.styles do |s|
sheet.add_row head_title, :style => blue_cell sheet.add_row head_title, :style => blue_cell
if content_.count > 0 if content_.count > 0
content_.each do |user| content_.each do |user|
sheet.add_row user, :style => sz_all sheet.add_row user, :height => 25,:style => sz_all
end #each_widh_index end #each_widh_index
end end
sheet.column_widths *([20]*sheet.column_info.count) sheet.column_widths *([20]*sheet.column_info.count)
@ -155,7 +155,7 @@ wb.styles do |s|
content_ = task[2] content_ = task[2]
sheet.add_row task[1], :style => blue_cell sheet.add_row task[1], :style => blue_cell
content_.each do |user| content_.each do |user|
sheet.add_row user, :style => sz_all sheet.add_row user, :height => 25,:style => sz_all
end #each_widh_index end #each_widh_index
sheet.column_widths *([20]*sheet.column_info.count) sheet.column_widths *([20]*sheet.column_info.count)
sheet.column_info.first.width = 12 sheet.column_info.first.width = 12
@ -171,7 +171,7 @@ wb.styles do |s|
content_ = ex[2] content_ = ex[2]
sheet.add_row ex[1], :style => blue_cell sheet.add_row ex[1], :style => blue_cell
content_.each do |user| content_.each do |user|
sheet.add_row user, :style => sz_all #用户id sheet.add_row user, :height => 25,:style => sz_all #用户id
end #each_widh_index end #each_widh_index
sheet.column_widths *([20]*sheet.column_info.count) sheet.column_widths *([20]*sheet.column_info.count)
sheet.column_info.first.width = 12 sheet.column_info.first.width = 12

@ -5,10 +5,12 @@ wb.styles do |s|
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center} blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 20,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {:horizontal => :center}
wb.add_worksheet(:name =>"学生成绩") do |sheet| wb.add_worksheet(:name =>"学生成绩") do |sheet|
sheet.add_row table_columns, :style => blue_cell sheet.add_row table_columns,:height =>20, :style => blue_cell
sheet.column_info.first.width = 12 sheet.column_info.first.width = 12
task_users.each do |user| task_users.each do |user|
sheet.add_row user, :style => sz_all sheet.add_row user, :height =>20, :style => sz_all
end #each_widh_index end #each_widh_index
sheet.column_widths *([25]*sheet.column_info.count)
sheet.column_info.first.width = 12
end #add_worksheet end #add_worksheet
end end

@ -3,6 +3,8 @@ json.task_type @task.task_type
json.work_id @work.id json.work_id @work.id
json.description @work.description json.description @work.description
json.user_name @task_user.real_name json.user_name @task_user.real_name
json.max_num @task.max_num
json.min_num @task.min_num
json.attachments @work.attachments do |atta| json.attachments @work.attachments do |atta|
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: @work.delete_atta(atta)} json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: @work.delete_atta(atta)}

@ -6,4 +6,6 @@ if @task.task_type == 2
json.user_id @user.id json.user_id @user.id
json.user_student_id @user.student_id json.user_student_id @user.student_id
json.group_name @course.course_member(@user.id).try(:course_group_name) json.group_name @course.course_member(@user.id).try(:course_group_name)
json.max_num @task.max_num
json.min_num @task.min_num
end end

@ -2,18 +2,26 @@ json.course_id @course.id
json.course_name @course.name json.course_name @course.name
json.homework_common_id @homework.id json.homework_common_id @homework.id
json.homework_common_name @homework.name json.homework_common_name @homework.name
json.work_id @student_work.id
json.work_name @student_work.name json.work_name @student_work.name
json.username @user.full_name json.username @user.full_name
json.user_id @user.id json.user_id @user.id
json.user_login @user.login json.user_login @user.login
json.work_score @student_work.work_score json.work_score @student_work.work_score
if @student_work.ultimate_score if @student_work.ultimate_score
json.adjust_score @student_work.work_score < 0 ? 0 : number_with_precision(@student_work.work_score, precision: 1) json.adjust_score @student_work.work_score < 0 ? 0 : number_with_precision(@student_work.work_score, precision: 1)
else else
json.final_score @student_work.final_score json.final_score @student_work.final_score
json.late_penalty @student_work.late_penalty json.late_penalty @student_work.late_penalty
json.score @student_work.work_score < 0 ? 0 : number_with_precision(@student_work.work_score, precision: 1) json.score @student_work.work_score < 0 ? 0 : number_with_precision(@student_work.work_score, precision: 1)
if @homework.work_efficiency
json.eff_score_full number_with_precision @homework.eff_score, precision: 1
json.eff_score number_with_precision @student_work.eff_score, precision: 1
json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1
json.challenge_score number_with_precision @student_work.final_score, precision: 1
end
end end
json.challenge_list do json.challenge_list do
@ -25,6 +33,7 @@ json.challenge_list do
json.final_score challenge[:final_score] json.final_score challenge[:final_score]
json.username challenge[:username] json.username challenge[:username]
json.all_score challenge[:all_score] json.all_score challenge[:all_score]
json.copy_user_id challenge[:copy_user_id]
json.copy_username challenge[:copy_username] json.copy_username challenge[:copy_username]
json.copy_end_time challenge[:copy_end_time] json.copy_end_time challenge[:copy_end_time]
json.code_rate challenge[:code_rate] json.code_rate challenge[:code_rate]

@ -0,0 +1,4 @@
json.status 0
json.message "调分成功"
json.work_score number_with_precision @work.work_score, 1
json.challenge_score number_with_precision @work.final_score, 1

@ -1,6 +1,7 @@
json.homework_common_id @homework.id json.homework_common_id @homework.id
json.category @homework.category_info json.category @homework.category_info
json.course_name @course.name json.course_name @course.name
json.work_id @work.id
if @shixun if @shixun
json.shixun_name @shixun.name json.shixun_name @shixun.name
# 总体评价 # 总体评价
@ -8,9 +9,15 @@ if @shixun
json.myself_experience @work.myshixun.try(:total_score) json.myself_experience @work.myshixun.try(:total_score)
json.total_experience @shixun.all_score json.total_experience @shixun.all_score
json.work_score number_with_precision @work.work_score, precision: 1 json.work_score number_with_precision @work.work_score, precision: 1
json.all_work_score 100 json.all_work_score number_with_precision 100, precision: 1
json.time_consuming @work.myshixun_consume json.time_consuming @work.myshixun_consume
json.evaluate_count @user_evaluate_count.to_i json.evaluate_count @user_evaluate_count.to_i
if @homework.work_efficiency
json.eff_score_full number_with_precision @homework.eff_score, precision: 1
json.eff_score number_with_precision @work.eff_score, precision: 1
json.challenge_score_full number_with_precision (100 - @homework.eff_score), precision: 1
json.challenge_score number_with_precision @work.final_score, precision: 1
end
# 阶段成绩 # 阶段成绩
json.stage_list do json.stage_list do
@ -24,6 +31,10 @@ if @shixun
json.myself_experience game.final_score json.myself_experience game.final_score
json.experience game.challenge.all_score json.experience game.challenge.all_score
json.complete_status game_status(game, @homework) json.complete_status game_status(game, @homework)
json.challenge_id game.challenge_id
challenge_score = @homework.challenge_score game.challenge_id
json.game_score_full challenge_score
json.game_score @work.work_challenge_score game, challenge_score
end end
end end

Loading…
Cancel
Save