diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index da2b9eb2d..5d27de7b8 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -440,6 +440,7 @@ class HomeworkCommonsController < ApplicationController @user = current_user @work = @homework.user_work(current_user.id) if @user_course_identity == Course::STUDENT @course_groups = @course.course_groups.where(id: @course.charge_group_ids(@user)) + @shixun = @homework.shixuns.take if @homework.homework_type == "practice" end def update_settings diff --git a/app/models/challenge.rb b/app/models/challenge.rb index da88b0fca..73079d82b 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -46,7 +46,16 @@ class Challenge < ApplicationRecord #self.challenge_chooses.pluck(:score).sum end - # 关卡总分 + def challenge_difficulty + case difficulty + when 1 then "简单" + when 2 then "中等" + when 3 then "困难" + else '' + end + end + + # 关卡总分 def all_score self.score # if self.st == 1 diff --git a/app/views/homework_commons/settings.json.jbuilder b/app/views/homework_commons/settings.json.jbuilder index f62dde87e..52e3f1cdf 100644 --- a/app/views/homework_commons/settings.json.jbuilder +++ b/app/views/homework_commons/settings.json.jbuilder @@ -15,17 +15,19 @@ json.group_settings @course_groups do |group| end if @homework.homework_type == "practice" - json.shixun_identifier @homework.shixuns.first.try(:identifier) + json.shixun_identifier @shixun.try(:identifier) + json.task_pass @shixun&.task_pass json.(@homework, :work_efficiency, :eff_score) json.(@homework.homework_detail_manual, :answer_open_evaluation, :shixun_evaluation) total_exp = 0 - json.challenge_settings @homework.shixuns.first.try(:challenges).each do |challenge| + json.challenge_settings @shixun.try(:challenges).each do |challenge| json.challenge_id challenge.id json.challenge_name challenge.subject json.checked challenge_setting(@homework, challenge.id).present? json.challenge_score challenge_setting(@homework, challenge.id).try(:score).to_f json.challenge_exp challenge.score + json.difficulty challenge.challenge_difficulty total_exp += challenge.score end