From d2fcd7208a4deb78bfd4220b1c9068679d7a3b33 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 11 Sep 2019 15:48:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- app/controllers/myshixuns_controller.rb | 3 ++- app/helpers/homework_commons_helper.rb | 2 +- app/views/homework_commons/works_list.json.jbuilder | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2ce52d405..1b7101199 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -247,7 +247,7 @@ class ApplicationController < ActionController::Base uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous")) if !User.current.logged? && Rails.env.development? - User.current = User.find 1 + User.current = User.find 8686 end diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 8c11e88c5..fc5db713f 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -25,7 +25,8 @@ class MyshixunsController < ApplicationController begin @shixun = Shixun.select(:id, :identifier, :challenges_count).find(@myshixun.shixun_id) @myshixun.destroy! - StudentWork.where(:myshixun_id => @myshixun.id).update_all(:myshixun_id => 0, :work_status => 0) + StudentWork.where(:myshixun_id => @myshixun.id).update_all(myshixun_id: 0, work_status: 0, work_score: nil, + final_score: nil, efficiency: 0, eff_score: 0, calculation_time: nil, cost_time: 0, compelete_status: 0) rescue Exception => e logger.error("######reset_my_game_failed:#{e.message}") raise("ActiveRecord::RecordInvalid") diff --git a/app/helpers/homework_commons_helper.rb b/app/helpers/homework_commons_helper.rb index e10917664..3e9ad2eaa 100644 --- a/app/helpers/homework_commons_helper.rb +++ b/app/helpers/homework_commons_helper.rb @@ -240,6 +240,6 @@ module HomeworkCommonsHelper def student_redo_work work, homework publish_time = homework.homework_group_setting(work.user_id)&.publish_time - work.myshixun && publish_time && work.myshixun.games.where("status = 2 and answer_open = 1 and end_time <= '#{publish_time}'").count > 0 + work.myshixun && publish_time && work.myshixun.games.where("status = 2 and answer_open = 1 and end_time <= '#{publish_time}'").count > 0 ? true : false end end diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index fe05866e6..09a7cbcc5 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -31,7 +31,7 @@ elsif @user_course_identity == Course::STUDENT json.left_time left_time @homework, @current_user.id if @homework.homework_type == "practice" - json.(@work, :id, :work_status, :update_time, :ultimate_score, :myshixun_id) + json.(@work, :id, :work_status, :update_time, :ultimate_score) json.calculation_time @work.calculation_time json.late_penalty @work.late_penalty if @homework.allow_late json.cost_time @work.myshixun.try(:total_spend_time) @@ -40,7 +40,8 @@ elsif @user_course_identity == Course::STUDENT json.efficiency work_score_format(@work.efficiency, true, @score_open) json.eff_score work_score_format(@work.eff_score, true, @score_open) json.complete_count @work.myshixun.try(:passed_count) - json.redo_work @homework.end_or_late ? false : student_redo_work(@work, @homework) + json.redo_work (@homework.end_or_late ? false : student_redo_work(@work, @homework)) + json.myshixun_identifier @work.myshixun&.identifier else json.(@work, :id, :work_status, :update_time, :ultimate_score)