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

dev_forum
daiao 5 years ago
commit b8521f73e5

@ -1040,6 +1040,7 @@ class ExercisesController < ApplicationController
@exercise_questions = @exercise_questions.order("question_number ASC")
end
# 判断问题是否已回答还是未回答
@exercise_questions = @exercise_questions.includes(:exercise_stand_answers,:exercise_answers,:exercise_shixun_answers)
if @t_user_exercise_status == 3
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
@student_status = 2
# @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 = []
get_exercise_status = @exercise.get_exercise_status(current_user)
if @ex_user.present? && @is_teacher_or == 0
@ -1188,7 +1189,7 @@ class ExercisesController < ApplicationController
elsif @user_course_identity > Course::ASSISTANT_PROFESSOR #当前为学生或者有过答题的(提交/未提交)
@ex_user_end_time = @exercise.get_exercise_end_time(current_user.id) #当前用户所看到的剩余时间
@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) #当前用户是否开始做试卷(提交/未提交/没做)
if exercise_current_user.present?
@exercise_current_user_status = 1 #当前用户的状态,为学生
@ -1202,7 +1203,7 @@ class ExercisesController < ApplicationController
end
else
@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_users_list = []
end

@ -118,11 +118,11 @@ class HomeworkCommonsController < ApplicationController
# 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段
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}")
# 匿评、申诉阶段只能看到分配给自己的匿评作品
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
@student_works = student_works.joins(:student_works_evaluation_distributions).where(
"student_works_evaluation_distributions.user_id = #{@current_user.id}")
@ -240,7 +240,7 @@ class HomeworkCommonsController < ApplicationController
end
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
if @homework.unified_setting
student_works = @homework.student_works
@ -1354,7 +1354,7 @@ class HomeworkCommonsController < ApplicationController
if results.status == 0
code_info = results.code_info
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.map do |challenge|
code_rate = 0
@ -1368,24 +1368,8 @@ class HomeworkCommonsController < ApplicationController
game = challenge.games.find_by(user_id: @user.id)
end_time = game.end_time
# 用户关卡的得分
all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score)
final_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
all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f
final_score = @student_work.work_challenge_score game, all_score
# 抄袭用户
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?

@ -631,7 +631,7 @@ class StudentWorksController < ApplicationController
# 查重作品调分
def adjust_review_score
tip_exception("缺少type参数") if params[:type].blank? || ["review", "report"].include?(params[:type])
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不能为空")
elsif params[:type] == "report" && (params[:score].nil? || params[:challenge_id].nil?)

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

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

@ -193,4 +193,19 @@ class StudentWork < ApplicationRecord
def scored?
student_works_scores.where.not(reviewer_role: 3).exists?
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

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

@ -1,3 +1,4 @@
json.status 0
json.message "调分成功"
json.work_score @work.work_score
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.category @homework.category_info
json.course_name @course.name
json.work_id @work.id
if @shixun
json.shixun_name @shixun.name
# 总体评价
@ -8,9 +9,15 @@ if @shixun
json.myself_experience @work.myshixun.try(:total_score)
json.total_experience @shixun.all_score
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.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
@ -25,6 +32,9 @@ if @shixun
json.experience game.challenge.all_score
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

Loading…
Cancel
Save