diff --git a/app/models/item_bank.rb b/app/models/item_bank.rb index 840f488d8..242b7de92 100644 --- a/app/models/item_bank.rb +++ b/app/models/item_bank.rb @@ -19,38 +19,26 @@ class ItemBank < ApplicationRecord end def apply? - !public && ApplyAction.where(container_type: "ItemBank", container_id: id, status: 0).exists? + !public && ApplyAction.exists?(container_type: "ItemBank", container_id: id, status: 0) end def type_string - result = case item_type - when "SINGLE" - "单选题" - when "MULTIPLE" - "多选题" - when "JUDGMENT" - "判断题" - when "COMPLETION" - "填空题" - when "SUBJECTIVE" - "简答题" - when "PRACTICAL" - "实训题" - when "PROGRAM" - "编程题" - end - result + case item_type + when "SINGLE" then "单选题" + when "MULTIPLE" then "多选题" + when "JUDGMENT" then "判断题" + when "COMPLETION" then "填空题" + when "SUBJECTIVE" then "简答题" + when "PRACTICAL" then "实训题" + when "PROGRAM" then "编程题" + end end def difficulty_string - result = case difficulty - when 1 - "简单" - when 2 - "适中" - when 3 - "困难" - end - result + case difficulty + when 1 then "简单" + when 2 then "适中" + when 3 then "困难" + end end end