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

dev_forum
SylorHuang 5 years ago
commit 3e0dd85322

@ -1189,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 #当前用户的状态,为学生
@ -1203,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?)

@ -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

@ -73,9 +73,8 @@ class Shixun < ApplicationRecord
# 实训用户tag
def user_tags_name(user = User.current)
challenge_ids = challenges.pluck(:id)
user_challenge_ids = user.games.where(challenge_id: challenge_ids, status: 2).pluck(:challenge_id)
ChallengeTag.where(challenge_id: user_challenge_ids).pluck(:name).uniq
Shixun.joins(challenges: [:challenge_tags, :games]).where(games: {status: 2, user_id: user.id}, shixuns: {id:id})
.pluck("challenge_tags.name").uniq
end
# 实训关卡tag
@ -158,13 +157,11 @@ class Shixun < ApplicationRecord
# 实训评分信息
# return [实训评分, 5星评分比例 4星评分比例 3星评分比例 2星评分比例 1星评分比例]
def shixun_preference_info
game_star_info = Game.find_by_sql("select g.star from
(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}")
game_star_info = Game.joins(challenge: :shixun).where(shixuns: {id: id}).where.not(games: {star: 0}).pluck(:star)
star_info = []
if game_star_info.present?
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
sum = star_info.sum
max = star_info.max
@ -175,7 +172,7 @@ class Shixun < ApplicationRecord
star_info = star_info.map{|s| s == max ? s + 1 : s}
end
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))
else
star_info = [5.0, 100, 0, 0, 0, 0]

@ -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