From 5f120bcf875c9fb95181ceb436d5c31417162318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 10 Jan 2020 16:29:01 +0800 Subject: [PATCH 01/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/boards/TopicDetail.js | 1 + .../courses/common/comments/CommonReply.js | 1 + .../tasks/GraduationTaskssettingReply.js | 46 +++++++++---------- .../graduation/topics/GraduateTopicReply.js | 2 +- public/react/src/modules/forums/MemoDetail.js | 4 +- 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/public/react/src/modules/courses/boards/TopicDetail.js b/public/react/src/modules/courses/boards/TopicDetail.js index e8767fb87..f4df177c7 100644 --- a/public/react/src/modules/courses/boards/TopicDetail.js +++ b/public/react/src/modules/courses/boards/TopicDetail.js @@ -682,6 +682,7 @@ class TopicDetail extends Component { {!isCourseEnd && } {/* onClick={ this.createNewComment } diff --git a/public/react/src/modules/courses/common/comments/CommonReply.js b/public/react/src/modules/courses/common/comments/CommonReply.js index 42ec3d65a..50f2b60cb 100644 --- a/public/react/src/modules/courses/common/comments/CommonReply.js +++ b/public/react/src/modules/courses/common/comments/CommonReply.js @@ -252,6 +252,7 @@ class CommonReply extends Component{ {/* bor-bottom-greyE */} diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js index 4281d0ec6..ce0554488 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js @@ -18,7 +18,7 @@ import { generateComments, generateChildComments, _findById, handleContentBefore const REPLY_PAGE_COUNT = 10 const $ = window.$; -/* +/* 相比较GraduateTopicReply 改动的地方 列表接口名 /graduation_tasks/${graduation_topic_id}/show_comment.json?parent_id=${parent.id}&limit=500 回复类型名 jour_type: 'GraduationTask', @@ -34,7 +34,7 @@ class GraduationTaskssettingReply extends Component{ componentDidMount(){ this.fetchReplies() - + } _getUser() { const { current_user } = this.props; @@ -58,7 +58,7 @@ class GraduationTaskssettingReply extends Component{ // m_parent_id reply_id: memo.user_id } - } + } ).then((response) => { if (response.data.status === -1) { console.error('服务端异常') @@ -66,18 +66,18 @@ class GraduationTaskssettingReply extends Component{ } // this.props.showNotification('帖子发表成功') - if (response.data && response.data.id) { + if (response.data && response.data.id) { const _id = response.data.id; // md editor.setValue && editor.setValue('') - + const user = this._getUser(); this.setState({ comments: addNewComment(this.state.comments, _id, content, user, this.props.isSuperAdmin(), this), total_count: this.state.total_count + 1 }) this.refs.editor.showEditor(); - + } }).catch((error) => { console.log(error) @@ -95,13 +95,13 @@ class GraduationTaskssettingReply extends Component{ return; } const url = `/users/reply_message.json`; - + const { comments } = this.state; const user = this._getUser(); const graduation_topic_id = this.props.memo.id const commentIndex = this._findById(id, comments); let comment = comments[commentIndex]; - + commentContent = handleContentBeforeCreateSecondLevelComment(commentContent) axios.post(url, { journals_for_message: { @@ -113,9 +113,9 @@ class GraduationTaskssettingReply extends Component{ } }, { - } + } ).then((response) => { - if (response.data.id) { + if (response.data.id) { let newId = response.data.id; this.setState({ @@ -128,7 +128,7 @@ class GraduationTaskssettingReply extends Component{ memo: newMemo2 }) } - + }).catch((error) => { console.log(error) }) @@ -142,7 +142,7 @@ class GraduationTaskssettingReply extends Component{ }) .then((response) => { const { comments } = response.data - + // const memo = Object.assign({}, this.state.memo) // memo.sum_replies_count = sum_replies_count; @@ -160,7 +160,7 @@ class GraduationTaskssettingReply extends Component{ this.fetchReplies() }) } - + fetchReplies = () => { const graduation_topic_id = this.props.memo.id const course_id = this.props.course_id @@ -170,7 +170,7 @@ class GraduationTaskssettingReply extends Component{ }) .then((response) => { const { comments, messages_count } = response.data - + this.setState({ comments: generateComments(comments, this.transformReply), // : this.state.comments.concat(comments), @@ -180,7 +180,7 @@ class GraduationTaskssettingReply extends Component{ console.log(error) }) } - + transformReply = (reply, children = []) => { const isAdmin = this.props.isAdmin() const isSuperAdmin = this.props.isSuperAdmin() @@ -189,7 +189,7 @@ class GraduationTaskssettingReply extends Component{ isSuperAdmin: isSuperAdmin, permission: true, // children: children, - hidden: reply.hidden, + hidden: reply.hidden, id: reply.id, image_url: reply.author.image_url, reward: null, // @@ -235,7 +235,7 @@ class GraduationTaskssettingReply extends Component{ -
- - - {/* { true ? : + + + {/* { true ? :
写评论
} */}
- - { total_count > REPLY_PAGE_COUNT && + + { total_count > REPLY_PAGE_COUNT &&
写评论
diff --git a/public/react/src/modules/courses/graduation/topics/GraduateTopicReply.js b/public/react/src/modules/courses/graduation/topics/GraduateTopicReply.js index df6152c04..f08938b4e 100644 --- a/public/react/src/modules/courses/graduation/topics/GraduateTopicReply.js +++ b/public/react/src/modules/courses/graduation/topics/GraduateTopicReply.js @@ -226,7 +226,7 @@ class GraduateTopicReply extends Component{ return( -
{ window.__useKindEditor === true ? - + : - + } {/* onClick={ this.createNewComment } */} From 9417970f62fca11e382a1aef4ff1ebea65eb8465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 10 Jan 2020 16:32:14 +0800 Subject: [PATCH 02/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/common/educoder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index 9a19c6ee2..b0ef6d692 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -4,7 +4,7 @@ export { getImageUrl as getImageUrl, getRandomNumber as getRandomNumber,getUrl as getUrl, publicSearchs as publicSearchs,getRandomcode as getRandomcode,getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl , getUploadActionUrl as getUploadActionUrl,getUploadActionUrltwo as getUploadActionUrltwo ,getUploadActionUrlthree as getUploadActionUrlthree, getUploadActionUrlOfAuth as getUploadActionUrlOfAuth - , getTaskUrlById as getTaskUrlById, TEST_HOST ,htmlEncode as htmlEncode } from './UrlTool'; + , getTaskUrlById as getTaskUrlById, TEST_HOST ,htmlEncode as htmlEncode ,getupload_git_file as getupload_git_file} from './UrlTool'; export {setmiyah as setmiyah} from './Component'; export { default as queryString } from './UrlTool2'; From 4d9c4e42927f0b5ee1ba938eff4695d90ae14256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 10 Jan 2020 16:54:29 +0800 Subject: [PATCH 03/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/forums/MemoDetailMDEditor.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/forums/MemoDetailMDEditor.js b/public/react/src/modules/forums/MemoDetailMDEditor.js index 8076c5e6a..b8bcc47fb 100644 --- a/public/react/src/modules/forums/MemoDetailMDEditor.js +++ b/public/react/src/modules/forums/MemoDetailMDEditor.js @@ -75,7 +75,10 @@ class MemoDetailMDEditor extends Component { } onCommit = () => { - + if(this.props.checkIfLogin()===false){ + this.props.showLoginDialog() + return + } if(this.props.checkIfProfileCompleted()===false){ this.props.showhideAccountPhoneemailDialog() return From 59ed6bd1f669fbf45bbca158a8c22208e98db451 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 10 Jan 2020 17:03:17 +0800 Subject: [PATCH 04/34] =?UTF-8?q?HTML=E5=AE=9E=E8=AE=AD=E8=B7=B3=E8=BF=87?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 7847d58ed..350ee581f 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -3,7 +3,7 @@ class MyshixunsController < ApplicationController before_action :find_myshixun, :except => [:training_task_status, :code_runinng_message] before_action :find_repo_name, :except => [:training_task_status, :code_runinng_message] skip_before_action :verify_authenticity_token, :only => [:html_content] - skip_before_action :check_sign, only: [:training_task_status, :code_runinng_message] + skip_before_action :check_sign, only: [:training_task_status, :code_runinng_message, :html_content] ## TPI关卡列表 def challenges From 9c4bd37ea2da0c67e8fb94495e32d25dc815fe09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 10 Jan 2020 17:38:02 +0800 Subject: [PATCH 05/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/tpm/shixuns/ShixunCardList.js | 9 +++++---- public/react/src/modules/tpm/shixuns/ShixunsIndex.js | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/public/react/src/modules/tpm/shixuns/ShixunCardList.js b/public/react/src/modules/tpm/shixuns/ShixunCardList.js index 948bbed48..46abc5bf0 100644 --- a/public/react/src/modules/tpm/shixuns/ShixunCardList.js +++ b/public/react/src/modules/tpm/shixuns/ShixunCardList.js @@ -75,17 +75,18 @@ class ShixunCardList extends Component { type="new"; } + if(typekeyid===key){ if(upcircle===true){ this.setState({ upcircle:false, }) - this.props.Shixunsupcircles("desc") + // this.props.Shixunsupcircles("desc") }else if(upcircle===false){ this.setState({ upcircle:true, }) - this.props.Shixunsupcircles("asc") + // this.props.Shixunsupcircles("desc") } }else{ this.setState({ @@ -93,8 +94,8 @@ class ShixunCardList extends Component { }) } - //allevent - this.props.ShixunsState(false,type); + + this.props.ShixunsState(false,type,"desc"); } diff --git a/public/react/src/modules/tpm/shixuns/ShixunsIndex.js b/public/react/src/modules/tpm/shixuns/ShixunsIndex.js index f14afb0ac..82fa6a3f9 100644 --- a/public/react/src/modules/tpm/shixuns/ShixunsIndex.js +++ b/public/react/src/modules/tpm/shixuns/ShixunsIndex.js @@ -296,21 +296,23 @@ class ShixunsIndex extends Component { console.log(error) }); } - ShixunsState=(val,type)=>{ + ShixunsState=(val,type,sorts)=>{ // sort, let {tag_level, tag_id, page, limit, keyword, status, diff,sort} = this.state; - let newsort=sort; + let newsort=sorts?sorts:sort; this.setState({ order_by:type, typepvisible:true, pages:1, - // sort:sort + sort:sorts?sorts:sort }) let params // let vals=false if(newsort===undefined){ newsort="desc" + }else{ + newsort=sorts?sorts:sort } params= { order_by:type, From 207ad7753c23e8609b1fb6e3b3a17e4d5836314f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 18:11:59 +0800 Subject: [PATCH 06/34] =?UTF-8?q?=E5=90=8C=E6=AD=A5trustie=E7=BC=96?= =?UTF-8?q?=E7=A8=8B=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/hack_set.rb | 4 +- app/models/program_bank.rb | 34 ++++++++++ app/models/program_bank_test.rb | 2 + lib/tasks/sync_trustie_program_question.rake | 70 ++++++++++++++++++++ spec/models/program_bank_spec.rb | 5 ++ spec/models/program_bank_test_spec.rb | 5 ++ 6 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 app/models/program_bank.rb create mode 100644 app/models/program_bank_test.rb create mode 100644 lib/tasks/sync_trustie_program_question.rake create mode 100644 spec/models/program_bank_spec.rb create mode 100644 spec/models/program_bank_test_spec.rb diff --git a/app/models/hack_set.rb b/app/models/hack_set.rb index 4dafd94a7..9b03ee8d0 100644 --- a/app/models/hack_set.rb +++ b/app/models/hack_set.rb @@ -1,6 +1,6 @@ class HackSet < ApplicationRecord - validates_length_of :input, maximum: 500 - validates_length_of :output, maximum: 500 + validates_length_of :input, maximum: 1000 + validates_length_of :output, maximum: 1000 validates :input, presence: { message: "测试集输入不能为空" } validates :output, presence: { message: "测试集输出不能为空" } validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同" diff --git a/app/models/program_bank.rb b/app/models/program_bank.rb new file mode 100644 index 000000000..c9be9af9f --- /dev/null +++ b/app/models/program_bank.rb @@ -0,0 +1,34 @@ +class ProgramBank < ApplicationRecord + + def oj_language + result = case language + when '1' + then 'C' + when '2' + then 'C++' + when '3' + then 'Python' + when '4' + then 'Java' + end + result + end + + def strip_description + strip_html description + end + + def oj_sub_discipline_id + result = case language + when '1' + then 3 + when '2' + then 4 + when '3' + then 5 + when '4' + then 2 + end + result + end +end diff --git a/app/models/program_bank_test.rb b/app/models/program_bank_test.rb new file mode 100644 index 000000000..ea336ae91 --- /dev/null +++ b/app/models/program_bank_test.rb @@ -0,0 +1,2 @@ +class ProgramBankTest < ApplicationRecord +end diff --git a/lib/tasks/sync_trustie_program_question.rake b/lib/tasks/sync_trustie_program_question.rake new file mode 100644 index 000000000..679164229 --- /dev/null +++ b/lib/tasks/sync_trustie_program_question.rake @@ -0,0 +1,70 @@ +desc "同步trustie的编程作业" + +namespace :sync_program do + DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) + task data: :environment do + ProgramBank.where(homework_type: 2).each do |program| + unless Hack.where(name: program.name).exists? + strip_des = strip_html(program.description, 5000) + description = strip_des.present? ? strip_des : program.name + hack_params = {name: program.name[0..59], description: description, difficult: 1, open_or_not: 1, score: 200, sub_discipline_id: program.oj_sub_discipline_id} + puts "language::::#{program.language}" + puts "program_bank::::#{program.id}" + hack = Hack.new(hack_params) + hack.user_id = 1 + hack.identifier = generate_identifier Hack, 8 + ActiveRecord::Base.transaction do + hack.save! + # 创建测试集与代码 + position = 1 + ProgramBankTest.where(homework_bank_id: program.id).each do |test_set| + if !test_set.input.blank? && !test_set.output.blank? && !hack.hack_sets.where(input: test_set.input).exists? && test_set.input.length <= 1000 && test_set.output.length <= 1000 + hack.hack_sets.create!(input: test_set.input, output: test_set.output, position: position) + position += 1 + end + end + # 新建知识点 + hack_code_params = {code: program.standard_code, language: program.oj_language} + hack_codes = hack.hack_codes.new(hack_code_params) + hack_codes.modify_time = Time.now + hack_codes.save! + new_item_params = {name: program.name, sub_discipline_id: program.oj_sub_discipline_id, container: hack, item_type: 'PROGRAM', public: 1, difficulty: 1, user_id: 1} + ItemBank.create!(new_item_params) + end + puts hack.id + end + end + end + + # 随机生成字符 + def generate_identifier(container, num) + code = DCODES.sample(num).join + if container == User + while container.exists?(login: code) do + code = DCODES.sample(num).join + end + else + while container.exists?(identifier: code) do + code = DCODES.sample(num).join + end + end + code + end + + def strip_html(text, len=0, endss="...") + ss = "" + if !text.nil? && text.length>0 + ss=text.gsub(/<\/?.*?>/, '').strip + ss = ss.gsub(/ */, '') + ss = ss.gsub(/\r\n/,'') #新增 + ss = ss.gsub(/\n/,'') #新增 + if len > 0 && ss.length > len + ss = ss[0, len-4] + endss + elsif len > 0 && ss.length <= len + ss = ss + #ss = truncate(ss, :length => len) + end + end + ss + end +end \ No newline at end of file diff --git a/spec/models/program_bank_spec.rb b/spec/models/program_bank_spec.rb new file mode 100644 index 000000000..d8a764494 --- /dev/null +++ b/spec/models/program_bank_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ProgramBank, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/program_bank_test_spec.rb b/spec/models/program_bank_test_spec.rb new file mode 100644 index 000000000..22720f254 --- /dev/null +++ b/spec/models/program_bank_test_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ProgramBankTest, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From fb5981f166d5173eb1b4c5b3e536e90d793c85d1 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 18:16:32 +0800 Subject: [PATCH 07/34] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=8E=89zip=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f68784db8..5ac40fbc0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -26,7 +26,7 @@ class ApplicationController < ActionController::Base if !Rails.env.development? && EduSetting.get("host_name") != "https://test-newweb.educoder.net" Rails.logger.info("66666 #{params}") suffix = request.url.split(".").last.split("?").first - suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释 + suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释 unless suffix_arr.include?(suffix) if params[:client_key].present? randomcode = params[:randomcode] From 896278d7cfb21c2c502af45155b59b53906e8de6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 18:19:48 +0800 Subject: [PATCH 08/34] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=8E=89zip=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5ac40fbc0..739ff0a28 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,10 +23,10 @@ class ApplicationController < ActionController::Base # 所有请求必须合法签名 def check_sign - if !Rails.env.development? && EduSetting.get("host_name") != "https://test-newweb.educoder.net" + if !Rails.env.development? Rails.logger.info("66666 #{params}") suffix = request.url.split(".").last.split("?").first - suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释 + suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释 unless suffix_arr.include?(suffix) if params[:client_key].present? randomcode = params[:randomcode] From 68fa947dd2fc9747d833a2b2a3daefc34af492ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 10 Jan 2020 18:19:58 +0800 Subject: [PATCH 09/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 2 +- .../react/src/modules/forums/MemoDetailMDEditor.js | 2 +- public/react/src/modules/tpm/TPMIndexHOC.js | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 5f870b683..4e500334e 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -42,7 +42,7 @@ if (isDev) { // 老师 //debugType="teacher"; // 学生 -//debugType="student"; +debugType="student"; function railsgettimes(proxy) { diff --git a/public/react/src/modules/forums/MemoDetailMDEditor.js b/public/react/src/modules/forums/MemoDetailMDEditor.js index b8bcc47fb..29bb08833 100644 --- a/public/react/src/modules/forums/MemoDetailMDEditor.js +++ b/public/react/src/modules/forums/MemoDetailMDEditor.js @@ -80,7 +80,7 @@ class MemoDetailMDEditor extends Component { return } if(this.props.checkIfProfileCompleted()===false){ - this.props.showhideAccountPhoneemailDialog() + this.props.showaccountprofileDialog() return } const content = this.commentMDEditor.getValue(); diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index 363acdba1..7d37ea073 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -396,7 +396,7 @@ export function TPMIndexHOC(WrappedComponent) { }); } - + fetchUser = () => { let url = `/users/get_user_info.json` let courseId; @@ -590,6 +590,17 @@ export function TPMIndexHOC(WrappedComponent) { checkIfProfileCompleted = () => { return this.state.current_user && this.state.current_user.profile_completed } + + showaccountprofileDialog = () => { + this.dialogObj = { + content: '您需要去完成您的个人资料,才能使用此功能', + okText: '立即完成', + okHref: '/account/profile' + } + this.setState({ + AccountProfiletype: true, + }) + } showProfessionalCertificationDialog = () => { this.dialogObj = { content: '您需要去完成您的职业认证,才能使用此功能', @@ -713,6 +724,7 @@ export function TPMIndexHOC(WrappedComponent) { showProfileCompleteDialog: this.showProfileCompleteDialog, showhideAccountPhoneemailDialog:this.showhideAccountPhoneemailDialog, checkIfProfileCompleted: this.checkIfProfileCompleted, + showaccountprofileDialog:this.showaccountprofileDialog, checkIfProfessionalCertification: this.checkIfProfessionalCertification, showProfessionalCertificationDialog: this.showProfessionalCertificationDialog, From 81f47c8deaea43a47afffa14a1b40f2b2ddc3a9f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 18:21:14 +0800 Subject: [PATCH 10/34] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=8E=89zip=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 739ff0a28..47e43351d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -26,7 +26,7 @@ class ApplicationController < ActionController::Base if !Rails.env.development? Rails.logger.info("66666 #{params}") suffix = request.url.split(".").last.split("?").first - suffix_arr = ["xls", "xlsx", "pdf"] # excel文件先注释 + suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释 unless suffix_arr.include?(suffix) if params[:client_key].present? randomcode = params[:randomcode] From e3511f95028ad0a2cf9b359675423057503c0fdf Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 18:22:15 +0800 Subject: [PATCH 11/34] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=8E=89zip=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 47e43351d..5ac40fbc0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,7 +23,7 @@ class ApplicationController < ActionController::Base # 所有请求必须合法签名 def check_sign - if !Rails.env.development? + if !Rails.env.development? && EduSetting.get("host_name") != "https://test-newweb.educoder.net" Rails.logger.info("66666 #{params}") suffix = request.url.split(".").last.split("?").first suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释 From 018ab4e5762a074cd49e7c7b178462b565be3167 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 10 Jan 2020 18:40:59 +0800 Subject: [PATCH 12/34] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hacks_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index fb4f497bd..0e98e771b 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -62,9 +62,9 @@ class HacksController < ApplicationController ItemBank.create!(new_item_params) end render_ok({identifier: hack.identifier}) - rescue Exception => e + rescue => e logger.error("########create_hack_error: #{e.message}") - render_error("创建失败") + render_error("创建失败: #{e.message}") end end @@ -96,7 +96,7 @@ class HacksController < ApplicationController render_ok rescue Exception => e logger.error("####update_hack_error: #{e.message}") - render_error("更新失败") + render_error("更新失败: #{e.message}") end end From 674383d57527dea1c8f0e5c96f06a78a654d798d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 10 Jan 2020 18:43:29 +0800 Subject: [PATCH 13/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tpm/shixunchild/Challenges/Challengesjupyter.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js index 86a2e287d..0586df638 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js @@ -77,7 +77,7 @@ class Challengesjupyter extends Component { }else{ if(boxoffsetHeigh>=300){ - if(this.props&&this.props.is_jupyter===true&&this.props&&this.props.user.user_identity==="学生"){ + if(this.state.enlarge===false){ this.setState({ opentitletype:false, isopentitletype:"greater", @@ -284,7 +284,7 @@ class Challengesjupyter extends Component { .then((result) => { if (result.data.status === 0) { // this.props.showNotification(`应用成功`); - console.log("应用成功了"); + // console.log("应用成功了"); this.props.showNotification('保存成功!'); setTimeout(() => { this.setState({ @@ -646,7 +646,7 @@ class Challengesjupyter extends Component { } - {this.props&&this.props.is_jupyter===true&&this.props&&this.props.user.user_identity==="学生"?"":this.state.isopentitletype==="Less"?"":this.state.opentitletype===true?this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}> + {this.state.enlarge===false?"":this.state.isopentitletype==="Less"?"":this.state.opentitletype===true?this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}> 阅读全文 :this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}> 收起全文 @@ -725,10 +725,11 @@ class Challengesjupyter extends Component {
- :"" + : "" : ( admin===true||business===true||mysidentity===true? +
From 31d1f268e8fa598f83c630de6a2fe8ca1c1b9069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 10 Jan 2020 18:59:53 +0800 Subject: [PATCH 14/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Challenges/Challengesjupyter.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js index 0586df638..61782d69f 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js @@ -77,20 +77,20 @@ class Challengesjupyter extends Component { }else{ if(boxoffsetHeigh>=300){ - if(this.state.enlarge===false){ - this.setState({ - opentitletype:false, - isopentitletype:"greater", - boxoffsetHeigh:boxoffsetHeigh - }) - }else{ - this.setState({ - opentitletype:true, - isopentitletype:"greater", - boxoffsetHeigh:boxoffsetHeigh - }) - } - + // if(this.state.enlarge===false){ + // this.setState({ + // opentitletype:false, + // isopentitletype:"greater", + // boxoffsetHeigh:boxoffsetHeigh + // }) + // }else{ + // + // } + this.setState({ + opentitletype:true, + isopentitletype:"greater", + boxoffsetHeigh:boxoffsetHeigh + }) }else{ this.setState({ isopentitletype:"Less", @@ -645,8 +645,8 @@ class Challengesjupyter extends Component { ` } - - {this.state.enlarge===false?"":this.state.isopentitletype==="Less"?"":this.state.opentitletype===true?this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}> + {/*this.state.enlarge===false?"":*/} + {this.state.isopentitletype==="Less"?"":this.state.opentitletype===true?this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}> 阅读全文 :this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}> 收起全文 From d1ce7997b07a78942ea806dac3d2975b1a730428 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 19:05:32 +0800 Subject: [PATCH 15/34] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=9A=84=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms/examination_banks/save_exam_form.rb | 2 +- app/forms/item_banks/save_item_form.rb | 6 +++--- app/forms/validate/user.rb | 2 +- app/models/attachment.rb | 2 +- app/models/challenge.rb | 2 +- app/models/challenge_answer.rb | 2 +- app/models/challenge_choose.rb | 2 +- app/models/challenge_question.rb | 2 +- app/models/chart_rule.rb | 2 +- app/models/competition.rb | 2 +- app/models/competition_module_md_content.rb | 2 +- app/models/course.rb | 2 +- app/models/course_group.rb | 2 +- app/models/course_module.rb | 2 +- app/models/course_second_category.rb | 2 +- app/models/course_stage.rb | 4 ++-- app/models/discuss.rb | 2 +- app/models/exercise.rb | 4 ++-- app/models/exercise_answer.rb | 2 +- app/models/exercise_answer_comment.rb | 2 +- app/models/exercise_bank.rb | 4 ++-- app/models/exercise_bank_choice.rb | 2 +- app/models/exercise_bank_question.rb | 2 +- app/models/exercise_bank_standard_answer.rb | 2 +- app/models/exercise_choice.rb | 2 +- app/models/exercise_question.rb | 2 +- app/models/exercise_standard_answer.rb | 2 +- app/models/graduation_task.rb | 4 ++-- app/models/graduation_topic.rb | 6 ++---- app/models/graduation_work.rb | 2 +- app/models/graduation_work_score.rb | 2 +- app/models/gtask_bank.rb | 4 ++-- app/models/gtopic_bank.rb | 6 ++---- app/models/hack.rb | 4 ++-- app/models/hack_set.rb | 4 ++-- app/models/homework_bank.rb | 6 +++--- app/models/homework_common.rb | 8 ++++---- app/models/inform.rb | 4 ++-- app/models/journals_for_message.rb | 2 +- app/models/library.rb | 2 +- app/models/memo.rb | 2 +- app/models/message.rb | 2 +- app/models/message_detail.rb | 2 +- app/models/poll.rb | 4 ++-- app/models/poll_answer.rb | 2 +- app/models/poll_question.rb | 2 +- app/models/poll_vote.rb | 2 +- app/models/shixun_info.rb | 4 ++-- app/models/shixun_work_comment.rb | 4 ++-- app/models/stage.rb | 4 ++-- app/models/student_work.rb | 2 +- app/models/student_works_score.rb | 2 +- app/models/subject.rb | 6 +++--- app/models/test_set.rb | 4 ++-- app/models/trustie_hack.rb | 2 +- 55 files changed, 79 insertions(+), 83 deletions(-) diff --git a/app/forms/examination_banks/save_exam_form.rb b/app/forms/examination_banks/save_exam_form.rb index b84b32eb1..1fc690a2f 100644 --- a/app/forms/examination_banks/save_exam_form.rb +++ b/app/forms/examination_banks/save_exam_form.rb @@ -6,7 +6,7 @@ class ExaminationBanks::SaveExamForm validates :discipline_id, presence: true validates :sub_discipline_id, presence: true validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true } - validates :name, presence: true, length: { maximum: 60 } + validates :name, presence: true, length: { maximum: 60, too_long: "名称不能超过60个字符" } validate :validate_duration def validate_duration diff --git a/app/forms/item_banks/save_item_form.rb b/app/forms/item_banks/save_item_form.rb index 2bfd99fc3..d0a5649db 100644 --- a/app/forms/item_banks/save_item_form.rb +++ b/app/forms/item_banks/save_item_form.rb @@ -7,8 +7,8 @@ class ItemBanks::SaveItemForm validates :sub_discipline_id, presence: true validates :item_type, presence: true, inclusion: {in: %W(SINGLE MULTIPLE JUDGMENT COMPLETION SUBJECTIVE PRACTICAL PROGRAM)} validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true } - validates :name, presence: true, length: { maximum: 1000 } - validates :analysis, length: { maximum: 1000 } + validates :name, presence: true, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } + validates :analysis, length: { maximum: 1000, too_long: "解析不能超过1000个字符" } def validate! super @@ -27,7 +27,7 @@ class ItemBanks::SaveItemForm attr_accessor :choice_text, :is_answer - validates :choice_text, presence: true, length: { maximum: 100 } + validates :choice_text, presence: true, length: { maximum: 500, too_long: "选项不能超过500个字符" } validates :is_answer, presence: true, inclusion: {in: 0..1}, numericality: { only_integer: true } end end \ No newline at end of file diff --git a/app/forms/validate/user.rb b/app/forms/validate/user.rb index 0f8f5e9ba..c378a36c4 100644 --- a/app/forms/validate/user.rb +++ b/app/forms/validate/user.rb @@ -4,7 +4,7 @@ module Validate attr_accessor :nickname, :lastname - validates :nickname, presence: true, length: { maximum: 10 } + validates :nickname, presence: true, length: { maximum: 10, too_long: "昵称不能超过10个字符" } validates :lastname, presence: true end end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index ac051428f..64531db46 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -25,7 +25,7 @@ class Attachment < ApplicationRecord scope :search_by_container, -> (ids) {where(container_id: ids)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} - validates_length_of :description, maximum: 100 + validates_length_of :description, maximum: 100, message: "资源描述不能超过100个字符" DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index e9bef0c9d..4cada46bc 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -28,7 +28,7 @@ class Challenge < ApplicationRecord scope :fields_for_list, -> { select([:id, :subject, :st, :score, :position, :shixun_id]) } - validates :task_pass, length: { maximum: 10000 } + validates :task_pass, length: { maximum: 10000, too_long: "过关任务不能超过10000个字符" } after_commit :create_diff_record diff --git a/app/models/challenge_answer.rb b/app/models/challenge_answer.rb index d3fd69cd0..8fc3c4a21 100644 --- a/app/models/challenge_answer.rb +++ b/app/models/challenge_answer.rb @@ -3,7 +3,7 @@ class ChallengeAnswer < ApplicationRecord belongs_to :challenge has_many :game_answers, :dependent => :destroy - validates :contents, length: { maximum: 5000 } + validates :contents, length: { maximum: 5000 , too_long: "答案内容不能超过5000个字符"} def view_answer_time(user_id) game_answers.where(user_id: user_id).last&.view_time diff --git a/app/models/challenge_choose.rb b/app/models/challenge_choose.rb index 2b8858f21..9a73fbc0a 100644 --- a/app/models/challenge_choose.rb +++ b/app/models/challenge_choose.rb @@ -4,6 +4,6 @@ class ChallengeChoose < ApplicationRecord has_many :challenge_tags, :dependent => :destroy has_many :challenge_questions, dependent: :destroy - validates :subject, length: { maximum: 1000 } + validates :subject, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } end diff --git a/app/models/challenge_question.rb b/app/models/challenge_question.rb index 959b033f9..7267f1bb4 100644 --- a/app/models/challenge_question.rb +++ b/app/models/challenge_question.rb @@ -1,6 +1,6 @@ class ChallengeQuestion < ApplicationRecord belongs_to :challenge_choose - validates :option_name, length: { maximum: 500 } + validates :option_name, length: { maximum: 500, too_long: "选项不能超过500个字符" } end diff --git a/app/models/chart_rule.rb b/app/models/chart_rule.rb index de8fceaf1..532c7f0e7 100644 --- a/app/models/chart_rule.rb +++ b/app/models/chart_rule.rb @@ -2,5 +2,5 @@ class ChartRule < ApplicationRecord belongs_to :competition belongs_to :competition_stage, optional: true - validates :content, length: { maximum: 1000 } + validates :content, length: { maximum: 1000, too_long: "内容不能超过1000个字符" } end diff --git a/app/models/competition.rb b/app/models/competition.rb index 1d10e2032..90f2f63da 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -33,7 +33,7 @@ class Competition < ApplicationRecord has_many :competition_prizes, dependent: :destroy has_many :competition_prize_users, dependent: :destroy - validates :introduction, length: { maximum: 500 } + validates :introduction, length: { maximum: 500, too_long: "简介不能超过500个字符" } before_save :set_laboratory after_create :create_competition_modules diff --git a/app/models/competition_module_md_content.rb b/app/models/competition_module_md_content.rb index 936ded8ef..919859236 100644 --- a/app/models/competition_module_md_content.rb +++ b/app/models/competition_module_md_content.rb @@ -5,6 +5,6 @@ class CompetitionModuleMdContent < ApplicationRecord # validates :name, presence: true validates :content, presence: true - validates :content, length: { maximum: 10000 } + validates :content, length: { maximum: 10000 , too_long: "内容不能超过10000个字符"} end \ No newline at end of file diff --git a/app/models/course.rb b/app/models/course.rb index 83d2bb56e..5808d2295 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -108,7 +108,7 @@ class Course < ApplicationRecord NORMAL = 6 # 普通用户 Anonymous = 7 # 普未登录 - validates :name, presence: true, length: { maximum: 60 } + validates :name, presence: true, length: { maximum: 60, too_long: "课堂名称不能超过60个字符" } before_save :set_laboratory after_create :create_board_sync, :act_as_course_activity, :send_tiding diff --git a/app/models/course_group.rb b/app/models/course_group.rb index 9486c9043..b49f88bde 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -9,7 +9,7 @@ class CourseGroup < ApplicationRecord has_many :homework_group_settings, :dependent => :destroy scope :by_group_ids, lambda { |ids| where(id: ids)} - validates :name, length: { maximum: 60 } + validates :name, length: { maximum: 60, too_long: "分班名称不能超过60个字符" } validates_uniqueness_of :name, scope: :course_id, message: "不能创建相同名称的分班" after_create :generate_invite_code diff --git a/app/models/course_module.rb b/app/models/course_module.rb index 641c70425..a1b6a7345 100644 --- a/app/models/course_module.rb +++ b/app/models/course_module.rb @@ -5,7 +5,7 @@ class CourseModule < ApplicationRecord # 二级目录 has_many :course_second_categories - validates :module_name, length: { maximum: 20 } + validates :module_name, length: { maximum: 20, too_long: "目录名称不能超过20个字符" } scope :not_hidden, -> { where(hidden: 0) } scope :graduation_module, -> { where(module_type: "graduation") } diff --git a/app/models/course_second_category.rb b/app/models/course_second_category.rb index 630b74807..6a0ae24bb 100644 --- a/app/models/course_second_category.rb +++ b/app/models/course_second_category.rb @@ -5,7 +5,7 @@ class CourseSecondCategory < ApplicationRecord belongs_to :course_module has_many :homework_commons - validates :name, length: { maximum: 60 } + validates :name, length: { maximum: 60, too_long: "名称不能超过60个字符" } def category_type_str category_type == "graduation" && name == "毕设选题" ? "graduation_topics" : ( diff --git a/app/models/course_stage.rb b/app/models/course_stage.rb index f105e25f6..c29737484 100644 --- a/app/models/course_stage.rb +++ b/app/models/course_stage.rb @@ -4,6 +4,6 @@ class CourseStage < ApplicationRecord has_many :course_stage_shixuns, -> { order("course_stage_shixuns.position ASC") }, dependent: :destroy has_many :shixuns, :through => :course_stage_shixuns - validates :name, length: { maximum: 60 } - validates :description, length: { maximum: 300 } + validates :name, length: { maximum: 60 , too_long: "章节名称不能超过60个字符"} + validates :description, length: { maximum: 1000, too_long: "章节描述不能超过1000个字符" } end diff --git a/app/models/discuss.rb b/app/models/discuss.rb index f35ca4751..743a436e0 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -13,7 +13,7 @@ class Discuss < ApplicationRecord belongs_to :challenge, optional: true validate :validate_sensitive_string - validates :content, length: { maximum: 1000 } + validates :content, length: { maximum: 1000, too_long: "内容不能超过1000个字符" } after_create :send_tiding diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 1fd84d1f7..86e85b2d0 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -19,8 +19,8 @@ class Exercise < ApplicationRecord scope :exercise_search, lambda { |keywords| where("exercise_name LIKE ?", "%#{keywords}%") unless keywords.blank?} - validates :exercise_name, length: { maximum: 60, too_long: "60 characters is the maximum allowed" } - validates :exercise_description, length: { maximum: 100 } + validates :exercise_name, length: { maximum: 60, too_long: "试卷名称不能超过60个字符" } + validates :exercise_description, length: { maximum: 100, too_long: "试卷须知不能超过100个字符" } after_create :create_exercise_list diff --git a/app/models/exercise_answer.rb b/app/models/exercise_answer.rb index 00c08dd77..fb9c8d51f 100644 --- a/app/models/exercise_answer.rb +++ b/app/models/exercise_answer.rb @@ -11,6 +11,6 @@ class ExerciseAnswer < ApplicationRecord scope :exercise_answer_is_right, -> {where("score > ?",0.0)} #判断答案是否正确,根据分数总和大于0 scope :score_reviewed, lambda {where("score >= ?",0.0)} #是否评分,用于判断主观题的 - validates :answer_text, length: { maximum: 5000 } + validates :answer_text, length: { maximum: 5000, too_long: "答案不能超过5000个字符" } end \ No newline at end of file diff --git a/app/models/exercise_answer_comment.rb b/app/models/exercise_answer_comment.rb index 110efc737..62c7360c9 100644 --- a/app/models/exercise_answer_comment.rb +++ b/app/models/exercise_answer_comment.rb @@ -7,5 +7,5 @@ class ExerciseAnswerComment < ApplicationRecord scope :search_answer_comments, lambda {|name,ids| where("#{name}":ids)} - validates :comment, length: { maximum: 100 } + validates :comment, length: { maximum: 100, too_long: "评语不能超过100个字符" } end diff --git a/app/models/exercise_bank.rb b/app/models/exercise_bank.rb index 067d080b5..fb089ecbc 100644 --- a/app/models/exercise_bank.rb +++ b/app/models/exercise_bank.rb @@ -18,7 +18,7 @@ class ExerciseBank < ApplicationRecord scope :exercise_bank_search, lambda { |keywords| where("name LIKE ?", "%#{keywords}%") unless keywords.blank?} - validates :name, length: { maximum: 60, too_long: "60 characters is the maximum allowed" } - validates :description, length: { maximum: 100, too_long: "100 characters is the maximum allowed" } + validates :name, length: { maximum: 60, too_long: "试卷名称不能超过60个字符" } + validates :description, length: { maximum: 100, too_long: "试卷须知不能超过100个字符" } end \ No newline at end of file diff --git a/app/models/exercise_bank_choice.rb b/app/models/exercise_bank_choice.rb index 8f1dc9028..542b27e97 100644 --- a/app/models/exercise_bank_choice.rb +++ b/app/models/exercise_bank_choice.rb @@ -5,6 +5,6 @@ class ExerciseBankChoice < ApplicationRecord scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 - validates :choice_text, length: { maximum: 500 } + validates :choice_text, length: { maximum: 500, too_long: "选项不能超过500个字符" } end \ No newline at end of file diff --git a/app/models/exercise_bank_question.rb b/app/models/exercise_bank_question.rb index fbb6da88f..4857b1a55 100644 --- a/app/models/exercise_bank_question.rb +++ b/app/models/exercise_bank_question.rb @@ -11,7 +11,7 @@ class ExerciseBankQuestion < ApplicationRecord scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题 - validates :question_title, length: { maximum: 1000 } + validates :question_title, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } def question_type_name case self.question_type diff --git a/app/models/exercise_bank_standard_answer.rb b/app/models/exercise_bank_standard_answer.rb index 9bfbd67aa..4eabd2790 100644 --- a/app/models/exercise_bank_standard_answer.rb +++ b/app/models/exercise_bank_standard_answer.rb @@ -4,6 +4,6 @@ class ExerciseBankStandardAnswer < ApplicationRecord #attr_accessible :answer_text scope :standard_by_ids, lambda { |s| where(exercise_bank_choice_id: s) } - validates :answer_text, length: { maximum: 5000 } + validates :answer_text, length: { maximum: 5000, too_long: "参考答案不能超过5000个字符" } end \ No newline at end of file diff --git a/app/models/exercise_choice.rb b/app/models/exercise_choice.rb index 54b844ad9..1d3e78d8e 100644 --- a/app/models/exercise_choice.rb +++ b/app/models/exercise_choice.rb @@ -7,6 +7,6 @@ class ExerciseChoice < ApplicationRecord scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 - validates :choice_text, length: { maximum: 500 } + validates :choice_text, length: { maximum: 500, too_long: "选项不能超过500个字符" } end \ No newline at end of file diff --git a/app/models/exercise_question.rb b/app/models/exercise_question.rb index 3f1a49625..ea588cba5 100644 --- a/app/models/exercise_question.rb +++ b/app/models/exercise_question.rb @@ -16,7 +16,7 @@ class ExerciseQuestion < ApplicationRecord scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题 - validates :question_title, length: { maximum: 1000 } + validates :question_title, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } def question_type_name diff --git a/app/models/exercise_standard_answer.rb b/app/models/exercise_standard_answer.rb index ccf5c1203..d527809ef 100644 --- a/app/models/exercise_standard_answer.rb +++ b/app/models/exercise_standard_answer.rb @@ -6,5 +6,5 @@ class ExerciseStandardAnswer < ApplicationRecord scope :find_standard_answer_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :standard_by_ids, lambda { |s| where(exercise_choice_id: s) } - validates :answer_text, length: { maximum: 5000 } + validates :answer_text, length: { maximum: 5000, too_long: "参考答案不能超过5000个字符" } end diff --git a/app/models/graduation_task.rb b/app/models/graduation_task.rb index c9838954a..9776eb564 100644 --- a/app/models/graduation_task.rb +++ b/app/models/graduation_task.rb @@ -29,8 +29,8 @@ class GraduationTask < ApplicationRecord belongs_to :gtask_bank, optional: true - validates :name, length: { maximum: 60 } - validates :description, length: { maximum: 5000 } + validates :name, length: { maximum: 60, too_long: "任务名称不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "任务描述不能超过5000个字符" } # 未提交 scope :unfinished, -> {where(status: 0)} diff --git a/app/models/graduation_topic.rb b/app/models/graduation_topic.rb index 294bfa785..96e7ea353 100644 --- a/app/models/graduation_topic.rb +++ b/app/models/graduation_topic.rb @@ -19,10 +19,8 @@ class GraduationTopic < ApplicationRecord #after_create :act_as_course_activity # 课题名称和描述字段长度限制 - validates :name, length: { maximum: 60, - too_long: "60 characters is the maximum allowed" } - validates :description, length: { maximum: 5000, - too_long: "5000 characters is the maximum allowed" } + validates :name, length: { maximum: 60, too_long: "选题名称不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "选题描述不能超过5000个字符" } def status_name case self.status diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb index 7fb0ecc24..33f09d2f8 100644 --- a/app/models/graduation_work.rb +++ b/app/models/graduation_work.rb @@ -19,7 +19,7 @@ class GraduationWork < ApplicationRecord # has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation" # has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation" - validates :description, length: { maximum: 5000 } + validates :description, length: { maximum: 5000, too_long: "作品描述不能超过5000个字符" } scope :has_committed, lambda { where("work_status != 0") } diff --git a/app/models/graduation_work_score.rb b/app/models/graduation_work_score.rb index 853b996a1..71bd9e00f 100644 --- a/app/models/graduation_work_score.rb +++ b/app/models/graduation_work_score.rb @@ -5,5 +5,5 @@ class GraduationWorkScore < ApplicationRecord belongs_to :graduation_task has_many :attachments, as: :container, dependent: :destroy - validates :comment, length: { maximum: 1000 } + validates :comment, length: { maximum: 1000, too_long: "评语不能超过1000个字符" } end diff --git a/app/models/gtask_bank.rb b/app/models/gtask_bank.rb index f9d38d33f..5e9b580c4 100644 --- a/app/models/gtask_bank.rb +++ b/app/models/gtask_bank.rb @@ -9,6 +9,6 @@ class GtaskBank < ApplicationRecord scope :myself, ->(user_id) { where(user_id: user_id)} scope :is_public, -> { where(:is_public => true) } - validates :name, length: { maximum: 60 } - validates :description, length: { maximum: 5000 } + validates :name, length: { maximum: 60, too_long: "任务名称不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "任务描述不能超过5000个字符" } end diff --git a/app/models/gtopic_bank.rb b/app/models/gtopic_bank.rb index fe9f184eb..76ed122e4 100644 --- a/app/models/gtopic_bank.rb +++ b/app/models/gtopic_bank.rb @@ -10,8 +10,6 @@ class GtopicBank < ApplicationRecord # 课题名称和描述字段长度限制 - validates :name, length: { maximum: 60, - too_long: "60 characters is the maximum allowed" } - validates :description, length: { maximum: 5000, - too_long: "5000 characters is the maximum allowed" } + validates :name, length: { maximum: 60, too_long: "选题名称不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "选题描述不能超过5000个字符" } end diff --git a/app/models/hack.rb b/app/models/hack.rb index e89212cc3..d0a874f76 100644 --- a/app/models/hack.rb +++ b/app/models/hack.rb @@ -2,8 +2,8 @@ class Hack < ApplicationRecord # status: 0 未发布; 1已发布 # diffcult: 难度 1:简单;2:中等; 3:困难 # 编程题 - validates_length_of :name, maximum: 60 - validates_length_of :description, maximum: 5000 + validates_length_of :name, maximum: 60, message: "名称不能超过60个字符" + validates_length_of :description, maximum: 5000, message: "描述不能超过5000个字符" validates :description, presence: { message: "描述不能为空" } validates :name, presence: { message: "名称不能为空" } # 测试集 diff --git a/app/models/hack_set.rb b/app/models/hack_set.rb index 9b03ee8d0..dd4cac7b2 100644 --- a/app/models/hack_set.rb +++ b/app/models/hack_set.rb @@ -1,6 +1,6 @@ class HackSet < ApplicationRecord - validates_length_of :input, maximum: 1000 - validates_length_of :output, maximum: 1000 + validates_length_of :input, maximum: 1000, message: "测试集输入不能超过5000个字符" + validates_length_of :output, maximum: 1000, message: "测试集输出不能超过5000个字符" validates :input, presence: { message: "测试集输入不能为空" } validates :output, presence: { message: "测试集输出不能为空" } validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同" diff --git a/app/models/homework_bank.rb b/app/models/homework_bank.rb index d6db7bfab..e4f941375 100644 --- a/app/models/homework_bank.rb +++ b/app/models/homework_bank.rb @@ -10,7 +10,7 @@ class HomeworkBank < ApplicationRecord scope :is_public, -> { where(is_public: true)} scope :myself, ->(user_id) { where(user_id: user_id)} - validates :name, length: { maximum: 60 } - validates :description, length: { maximum: 15000 } - validates :reference_answer, length: { maximum: 15000 } + validates :name, length: { maximum: 60, too_long: "作业名称不能超过60个字符" } + validates :description, length: { maximum: 15000, too_long: "作业描述不能超过15000个字符" } + validates :reference_answer, length: { maximum: 15000, too_long: "参考答案不能超过15000个字符" } end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 58b52bdd2..040ab65f9 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -35,10 +35,10 @@ class HomeworkCommon < ApplicationRecord # 学生的查重情况 has_many :homework_review_results, :dependent => :destroy - validates :name, length: { maximum: 60 } - validates :description, length: { maximum: 15000 } - validates :explanation, length: { maximum: 5000 } - validates :reference_answer, length: { maximum: 15000 } + validates :name, length: { maximum: 60, too_long: "作业名称不能超过60个字符" } + validates :description, length: { maximum: 15000, too_long: "作业描述不能超过15000个字符" } + validates :explanation, length: { maximum: 5000, too_long: "说明不能超过5000个字符" } + validates :reference_answer, length: { maximum: 15000, too_long: "参考答案不能超过15000个字符" } # after_update :update_activity before_destroy :update_homework_bank_quotes diff --git a/app/models/inform.rb b/app/models/inform.rb index dc979ef32..ce549b2b9 100644 --- a/app/models/inform.rb +++ b/app/models/inform.rb @@ -1,8 +1,8 @@ class Inform < ApplicationRecord belongs_to :container, polymorphic: true, optional: true - validates :name, length: { maximum: 60 } - validates :description, length: { maximum: 5000 } + validates :name, length: { maximum: 60, too_long: "名称不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "内容不能超过5000个字符" } has_many :attachments, as: :container, dependent: :destroy diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 66ab98c9b..e1482d52b 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -26,7 +26,7 @@ class JournalsForMessage < ApplicationRecord # "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言 # "hidden", 隐藏、 - validates :notes, length: { maximum: 1000 } + validates :notes, length: { maximum: 1000, too_long: "内容不能超过1000个字符" } after_create :send_tiding diff --git a/app/models/library.rb b/app/models/library.rb index 982db732b..e9920c7b4 100644 --- a/app/models/library.rb +++ b/app/models/library.rb @@ -13,7 +13,7 @@ class Library < ApplicationRecord has_one :praise_tread_cache, foreign_key: :object_id has_many :praise_treads, as: :praise_tread_object, dependent: :destroy - validates :content, length: { maximum: 5000 } + validates :content, length: { maximum: 5000, too_long: "内容不能超过5000个字符" } validates :uuid, presence: true, uniqueness: true diff --git a/app/models/memo.rb b/app/models/memo.rb index 9140fb5db..8b38a911e 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -27,7 +27,7 @@ class Memo < ApplicationRecord scope :hot, -> { order("all_replies_count desc, updated_at desc") } scope :posts, -> { where(root_id: nil, forum_id: [3, 5]) } - validates :content, length: { maximum: 10000 } + validates :content, length: { maximum: 10000, too_long: "帖子内容不能超过10000个字符" } after_create :send_tiding diff --git a/app/models/message.rb b/app/models/message.rb index 7620ef11d..76ea303a9 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -33,7 +33,7 @@ class Message < ApplicationRecord #转发表 # has_many :forwards, as: :from, dependent: :destroy - validates :subject, length: { maximum: 255 } + validates :subject, length: { maximum: 255, too_long: "标题不能超过255个字符" } def update_content(content) message_detail.update_attributes(content: content) diff --git a/app/models/message_detail.rb b/app/models/message_detail.rb index 0d7aaa1c1..9f5269bc5 100644 --- a/app/models/message_detail.rb +++ b/app/models/message_detail.rb @@ -1,5 +1,5 @@ class MessageDetail < ApplicationRecord belongs_to :message, :touch => true - validates :content, length: { maximum: 5000 } + validates :content, length: { maximum: 5000, too_long: "内容不能超过5000个字符" } end diff --git a/app/models/poll.rb b/app/models/poll.rb index 1c38d2426..432bb01d2 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -24,8 +24,8 @@ class Poll < ApplicationRecord scope :poll_search, lambda { |keywords| where("polls_name LIKE ?", "%#{keywords}%") unless keywords.blank?} - validates :polls_name, length: { maximum: 60, too_long: "60 characters is the maximum allowed" } - validates :polls_description, length: { maximum: 100 } + validates :polls_name, length: { maximum: 60, too_long: "问卷名称不能超过60个字符" } + validates :polls_description, length: { maximum: 100, too_long: "问卷须知不能超过100个字符" } after_create :create_polls_list diff --git a/app/models/poll_answer.rb b/app/models/poll_answer.rb index c7fa7e75c..156be0974 100644 --- a/app/models/poll_answer.rb +++ b/app/models/poll_answer.rb @@ -8,6 +8,6 @@ class PollAnswer < ApplicationRecord scope :find_answer_by_custom, lambda {|k,v| where("#{k}":v)} #根据传入的参数查找问题 scope :left_answer_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 - validates :answer_text, length: { maximum: 500 } + validates :answer_text, length: { maximum: 500, too_long: "选项不能超过500个字符" } end \ No newline at end of file diff --git a/app/models/poll_question.rb b/app/models/poll_question.rb index dd7f3f95f..98c1201da 100644 --- a/app/models/poll_question.rb +++ b/app/models/poll_question.rb @@ -9,7 +9,7 @@ class PollQuestion < ApplicationRecord scope :ques_necessary, -> {where("is_necessary = ?",1)} scope :insert_question, lambda {|k| where("question_number > ?",k)} - validates :question_title, length: { maximum: 1000 } + validates :question_title, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } def question_type_name case self.question_type diff --git a/app/models/poll_vote.rb b/app/models/poll_vote.rb index 2e70f1342..440881871 100644 --- a/app/models/poll_vote.rb +++ b/app/models/poll_vote.rb @@ -9,6 +9,6 @@ class PollVote < ApplicationRecord scope :find_current_vote,lambda {|k,v| where("#{k}": v)} scope :find_vote_text,-> {where("vote_text IS NOT NULL")} - validates :vote_text, length: { maximum: 5000 } + validates :vote_text, length: { maximum: 5000, too_long: "内容不能超过5000个字符" } end \ No newline at end of file diff --git a/app/models/shixun_info.rb b/app/models/shixun_info.rb index e3a8d334b..a7da422da 100644 --- a/app/models/shixun_info.rb +++ b/app/models/shixun_info.rb @@ -1,10 +1,10 @@ class ShixunInfo < ApplicationRecord belongs_to :shixun validates_uniqueness_of :shixun_id - validates_length_of :fork_reason, maximum: 60 + validates_length_of :fork_reason, maximum: 60, message: "fork原因不能超过60个字符" after_commit :create_diff_record - validates :description, length: { maximum: 5000 } + validates :description, length: { maximum: 5000, too_long: "简介不能超过5000个字符" } private diff --git a/app/models/shixun_work_comment.rb b/app/models/shixun_work_comment.rb index 1d23718d3..c20f5c509 100644 --- a/app/models/shixun_work_comment.rb +++ b/app/models/shixun_work_comment.rb @@ -2,6 +2,6 @@ class ShixunWorkComment < ApplicationRecord belongs_to :student_work belongs_to :user belongs_to :challenge, optional: true - validates :comment, length: { maximum: 500 } - validates :hidden_comment, length: { maximum: 500 } + validates :comment, length: { maximum: 500, too_long: "评语不能超过500个字符" } + validates :hidden_comment, length: { maximum: 500, too_long: "隐藏评语不能超过500个字符" } end diff --git a/app/models/stage.rb b/app/models/stage.rb index 84873b01f..f6d6b3e56 100644 --- a/app/models/stage.rb +++ b/app/models/stage.rb @@ -6,6 +6,6 @@ class Stage < ApplicationRecord has_many :stage_shixuns, -> { order("stage_shixuns.position ASC") }, dependent: :destroy has_many :shixuns, :through => :stage_shixuns - validates :name, length: { maximum: 60 } - validates :description, length: { maximum: 1000 } + validates :name, length: { maximum: 60 , too_long: "章节名称不能超过60个字符" } + validates :description, length: { maximum: 1000, too_long: "章节描述不能超过1000个字符" } end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 473efa756..83e6c7b94 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -19,7 +19,7 @@ class StudentWork < ApplicationRecord before_save :set_work_score - validates :description, length: { maximum: 5000 } + validates :description, length: { maximum: 5000, too_long: "描述不能超过5000个字符" } scope :has_committed, lambda { where("work_status != 0") } # 未提交 diff --git a/app/models/student_works_score.rb b/app/models/student_works_score.rb index f9f4f4220..dc8c1451b 100644 --- a/app/models/student_works_score.rb +++ b/app/models/student_works_score.rb @@ -7,7 +7,7 @@ class StudentWorksScore < ApplicationRecord has_many :tidings, as: :container, dependent: :destroy has_many :attachments, as: :container, dependent: :destroy - validates :comment, length: { maximum: 1000 } + validates :comment, length: { maximum: 1000, too_long: "评语不能超过1000个字符" } scope :shixun_comment, lambda { where(is_ultimate: 0) } diff --git a/app/models/subject.rb b/app/models/subject.rb index df9271e5f..459889004 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -31,9 +31,9 @@ class Subject < ApplicationRecord has_many :subject_shixun_infos, dependent: :destroy has_many :subject_user_infos, dependent: :destroy - validates :name, length: { maximum: 60 } - validates :description, length: { maximum: 8000 } - validates :learning_notes, length: { maximum: 2000 } + validates :name, length: { maximum: 60, too_long: "实践课程名称不能超过60个字符" } + validates :description, length: { maximum: 8000, too_long: "实践课程简介不能超过8000个字符" } + validates :learning_notes, length: { maximum: 2000, too_long: "实践课程须知不能超过2000个字符" } scope :visible, lambda{where(status: 2)} scope :published, lambda{where(status: 1)} diff --git a/app/models/test_set.rb b/app/models/test_set.rb index 1fae89afa..f843bfc43 100644 --- a/app/models/test_set.rb +++ b/app/models/test_set.rb @@ -1,7 +1,7 @@ class TestSet < ApplicationRecord # match_rule: 匹配规则: full: 完全匹配, last: 末尾匹配 # - validates :input, length: { maximum: 5000 } - validates :input, length: { maximum: 5000 } + validates :input, length: { maximum: 5000, too_long: "输入不能超过5000个字符" } + validates :output, length: { maximum: 5000, too_long: "输出不能超过5000个字符" } end diff --git a/app/models/trustie_hack.rb b/app/models/trustie_hack.rb index 7c2f3264b..eb2cc06e4 100644 --- a/app/models/trustie_hack.rb +++ b/app/models/trustie_hack.rb @@ -1,5 +1,5 @@ class TrustieHack < ApplicationRecord - validates_length_of :description, maximum: 500 + validates_length_of :description, maximum: 500, message: "描述不能超过500个字符" has_many :hack_users, :dependent => :destroy belongs_to :trustie_hackathon, counter_cache: true From 0d7e81d150a64e02d377bfd617072ac89c6d6949 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 19:08:25 +0800 Subject: [PATCH 16/34] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=9A=84=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_tasks_controller.rb | 8 ++++---- app/controllers/memos_controller.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index dcb9a3bc3..cac763344 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -606,10 +606,10 @@ class GraduationTasksController < ApplicationController end def graduation_task_params - tip_exception("task_type参数不能为空") if params[:task_type].blank? - tip_exception("name参数不能为空") if params[:name].blank? - tip_exception("name参数不能超过60个字符") if params[:name].length > 60 #6.11 -hs - tip_exception("description参数不能为空") if params[:description].blank? + tip_exception("类型参数不能为空") if params[:task_type].blank? + tip_exception("名称不能为空") if params[:name].blank? + tip_exception("名称不能超过60个字符") if params[:name].length > 60 #6.11 -hs + tip_exception("描述不能为空") if params[:description].blank? params.require(:graduation_task).permit(:task_type, :name, :description) end diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 3c76972b8..a4d72371c 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -144,7 +144,7 @@ class MemosController < ApplicationController def reply tip_exception("parent_id不能为空") if params[:parent_id].blank? tip_exception("content不能为空") if params[:content].blank? - tip_exception("content不能超过1000字符") if params[:content].length > 1000 + tip_exception("内容不能超过1000字符") if params[:content].length > 1000 ActiveRecord::Base.transaction do begin From 0c6e09a75ee64dfe85b376db0a6df284702b8792 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 19:24:56 +0800 Subject: [PATCH 17/34] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=9A=84=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index e1482d52b..ec59c6dca 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -26,7 +26,7 @@ class JournalsForMessage < ApplicationRecord # "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言 # "hidden", 隐藏、 - validates :notes, length: { maximum: 1000, too_long: "内容不能超过1000个字符" } + validates :notes, length: { maximum: 1000, message: "内容不能超过1000个字符" } after_create :send_tiding From a22eb6abd855a2bb1959a74afa0ee65a5e2674e9 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 19:26:50 +0800 Subject: [PATCH 18/34] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=9A=84=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index ec59c6dca..35a58ec4c 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -26,7 +26,7 @@ class JournalsForMessage < ApplicationRecord # "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言 # "hidden", 隐藏、 - validates :notes, length: { maximum: 1000, message: "内容不能超过1000个字符" } + validates_length_of :notes, maximum: 1000, message: "内容不能超过1000个字符" after_create :send_tiding From 51aa5ea566ee163e724f8eeba5a9051e31ea5bf7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 10 Jan 2020 19:36:00 +0800 Subject: [PATCH 19/34] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E9=99=90=E5=88=B6?= =?UTF-8?q?=E7=9A=84=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 35a58ec4c..e1482d52b 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -26,7 +26,7 @@ class JournalsForMessage < ApplicationRecord # "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言 # "hidden", 隐藏、 - validates_length_of :notes, maximum: 1000, message: "内容不能超过1000个字符" + validates :notes, length: { maximum: 1000, too_long: "内容不能超过1000个字符" } after_create :send_tiding From 35a81bdb01317d5c3d5e5b2290f09ab7b7e8d14f Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 11 Jan 2020 09:44:33 +0800 Subject: [PATCH 20/34] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=9A=84rake=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/statistic_subject_info.rake | 104 ++++++++++++++++---------- 1 file changed, 65 insertions(+), 39 deletions(-) diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index 6373d7170..04e6c1195 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -16,15 +16,20 @@ namespace :subjects do passed_count = (study_count == sr.study_count ? sr.passed_count : data.passed_count) course_used_count = (study_count == sr.study_count ? sr.course_used_count : data.course_used_count) school_used_count = (study_count == sr.study_count ? sr.school_used_count : data.school_used_count) - update_params = { - study_count: study_count, - course_study_count: course_study_count, - initiative_study: (study_count - course_study_count), - passed_count: passed_count, - course_used_count: course_used_count, - school_used_count: school_used_count - } - sr.update_attributes!(update_params) + unless course_study_count == sr.course_study_count && + passed_count == sr.passed_count && + course_used_count == sr.course_used_count && + school_used_count == sr.school_used_count + update_params = { + study_count: study_count, + course_study_count: course_study_count, + initiative_study: (study_count - course_study_count), + passed_count: passed_count, + course_used_count: course_used_count, + school_used_count: school_used_count + } + sr.update_attributes!(update_params) + end end puts("---------------------data_statistic_end") Rails.logger.info("---------------------data_statistic_end") @@ -40,14 +45,20 @@ namespace :subjects do data = Subjects::CourseUsedInfoService.call(subject) data.each do |key| scr = SubjectCourseRecord.find_or_create_by!(school_id: key[:school_id], subject_id: subject.id) - update_params = { - school_name: key[:school_name], - course_count: key[:course_count], - student_count: key[:student_count], - choice_shixun_num: key[:choice_shixun_num], - choice_shixun_frequency: key[:choice_shixun_frequency] - } - scr.update_attributes(update_params) + unless key[:school_name] == scr.school_name && + key[:course_count] == scr.course_count && + key[:student_count] == scr.student_count && + key[:choice_shixun_num] == scr.choice_shixun_num && + key[:choice_shixun_frequency] == scr.choice_shixun_frequency + update_params = { + school_name: key[:school_name], + course_count: key[:course_count], + student_count: key[:student_count], + choice_shixun_num: key[:choice_shixun_num], + choice_shixun_frequency: key[:choice_shixun_frequency] + } + scr.update_attributes(update_params) + end end end puts("---------------------course_info_statistic_end") @@ -64,18 +75,26 @@ namespace :subjects do data = Subjects::ShixunUsedInfoService.call(subject) data.each do |key| ssi = SubjectShixunInfo.find_or_create_by!(shixun_id: key[:shixun_id], subject_id: subject.id) - update_params = { - stage: key[:stage], - shixun_name: key[:name], - challenge_count: key[:challenge_count], - course_count: key[:course_count], - school_count: key[:school_count], - used_count: key[:used_count], - passed_count: key[:passed_count], - evaluate_count: key[:evaluate_count], - passed_ave_time: key[:passed_ave_time] - } - ssi.update_attributes(update_params) + unless key[:challenge_count] == ssi.challenge_count && + key[:course_count] == ssi.course_count && + key[:school_count] == ssi.school_count && + key[:used_count] == ssi.used_count && + key[:passed_count] == ssi.passed_count && + key[:evaluate_count] == ssi.evaluate_count && + key[:passed_ave_time] == ssi.passed_ave_time + update_params = { + stage: key[:stage], + shixun_name: key[:name], + challenge_count: key[:challenge_count], + course_count: key[:course_count], + school_count: key[:school_count], + used_count: key[:used_count], + passed_count: key[:passed_count], + evaluate_count: key[:evaluate_count], + passed_ave_time: key[:passed_ave_time] + } + ssi.update_attributes(update_params) + end end end puts("---------------------shixun_info_statistic_end") @@ -83,7 +102,7 @@ namespace :subjects do end task user_info_statistic: :environment do - puts("---------------------user_info_statistic_begin") + puts("---------------------vim ./") Rails.logger.info("---------------------user_info_statistic_begin") subjects = Subject.where(status: 2) subjects.find_each(batch_size: 100) do |subject| @@ -91,15 +110,22 @@ namespace :subjects do data = Subjects::UserUsedInfoService.call(subject) data.each do |key| sui = SubjectUserInfo.find_or_create_by!(user_id: key[:user_id], subject_id: subject.id) - update_params = { - username: key[:name], - passed_myshixun_count: key[:passed_myshixun_count], - passed_games_count: key[:passed_games_count], - code_line_count: key[:code_line_count], - evaluate_count: key[:evaluate_count], - cost_time: key[:cost_time] - } - sui.update_attributes(update_params) + unless key[:passed_myshixun_count] == sui.passed_myshixun_count && + key[:passed_games_count] == sui.passed_games_count && + key[:code_line_count] == sui.code_line_count && + key[:evaluate_count] == sui.evaluate_count && + key[:cost_time] == sui.cost_time + update_params = { + username: key[:name], + passed_myshixun_count: key[:passed_myshixun_count], + passed_games_count: key[:passed_games_count], + code_line_count: key[:code_line_count], + evaluate_count: key[:evaluate_count], + cost_time: key[:cost_time] + } + sui.update_attributes(update_params) + end + end end puts("---------------------user_info_statistic_end") From 1185eb6683b805baa3686020f40b68f9f0b92441 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 10:33:33 +0800 Subject: [PATCH 21/34] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/discuss.rb | 2 +- app/models/journals_for_message.rb | 2 +- config/locales/zh-CN.yml | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/models/discuss.rb b/app/models/discuss.rb index 743a436e0..b563a6295 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -13,7 +13,7 @@ class Discuss < ApplicationRecord belongs_to :challenge, optional: true validate :validate_sensitive_string - validates :content, length: { maximum: 1000, too_long: "内容不能超过1000个字符" } + validates :content, length: { maximum: 1000, too_long: "不能超过1000个字符" } after_create :send_tiding diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index e1482d52b..190fa4351 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -26,7 +26,7 @@ class JournalsForMessage < ApplicationRecord # "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言 # "hidden", 隐藏、 - validates :notes, length: { maximum: 1000, too_long: "内容不能超过1000个字符" } + validates :notes, length: { maximum: 1000, too_long: "不能超过1000个字符" } after_create :send_tiding diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index f11271ff5..f80982a03 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -13,4 +13,14 @@ zh-CN: 'pending': '待审批' 'processed': '已审批' 'refused': '已拒绝' - 'agreed': '已同意' \ No newline at end of file + 'agreed': '已同意' + + activerecord: + attributes: + user: + login: '登录名' + lastname: '姓名' + discuss: + content: '内容' + journals_for_message: + notes: '内容' \ No newline at end of file From 04f8acca4f1e7ad7736fc0a8d14031d7cca8be46 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 11 Jan 2020 11:44:58 +0800 Subject: [PATCH 22/34] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20200109062658_create_subject_records.rb | 2 +- ...111024736_add_index_for_subject_records.rb | 6 +++ lib/tasks/statistic_subject_info.rake | 43 +++++++++++-------- 3 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 db/migrate/20200111024736_add_index_for_subject_records.rb diff --git a/db/migrate/20200109062658_create_subject_records.rb b/db/migrate/20200109062658_create_subject_records.rb index 97741fd8c..b990b8bdc 100644 --- a/db/migrate/20200109062658_create_subject_records.rb +++ b/db/migrate/20200109062658_create_subject_records.rb @@ -1,7 +1,7 @@ class CreateSubjectRecords < ActiveRecord::Migration[5.2] def change create_table :subject_records do |t| - t.references :subject, unique: true + t.references :subject t.integer :study_count, default: 0 t.integer :course_study_count, default: 0 t.integer :initiative_study, default: 0 diff --git a/db/migrate/20200111024736_add_index_for_subject_records.rb b/db/migrate/20200111024736_add_index_for_subject_records.rb new file mode 100644 index 000000000..c27c9b9ae --- /dev/null +++ b/db/migrate/20200111024736_add_index_for_subject_records.rb @@ -0,0 +1,6 @@ +class AddIndexForSubjectRecords < ActiveRecord::Migration[5.2] + def change + remove_index :subject_records, :subject_id + add_index :subject_records, :subject_id, unique: true + end +end diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index 04e6c1195..7eed62b3c 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -1,36 +1,41 @@ desc "统计实践课程的学习统计数据" namespace :subjects do + buffer_size = 1000 task data_statistic: :environment do puts("---------------------data_statistic_begin") Rails.logger.info("---------------------data_statistic_begin") subjects = Subject.where(status: 2) + str = "" + column_value = "subject_id, study_count, course_study_count, initiative_study, passed_count, course_used_count, " + + "school_used_count, created_at, updated_at" subjects.find_each do |subject| puts("---------------------data_statistic: #{subject.id}") Rails.logger.info("---------------------data_statistic: #{subject.id}") - sr = SubjectRecord.find_or_create_by!(subject_id: subject.id) + #sr = SubjectRecord.find_or_create_by!(subject_id: subject.id) data = Subjects::DataStatisticService.new(subject) study_count = data.study_count - # 总人数没有变化的话,不同课堂之类的变化了 - course_study_count = (study_count == sr.study_count ? sr.course_study_count : data.course_study_count) - passed_count = (study_count == sr.study_count ? sr.passed_count : data.passed_count) - course_used_count = (study_count == sr.study_count ? sr.course_used_count : data.course_used_count) - school_used_count = (study_count == sr.study_count ? sr.school_used_count : data.school_used_count) - unless course_study_count == sr.course_study_count && - passed_count == sr.passed_count && - course_used_count == sr.course_used_count && - school_used_count == sr.school_used_count - update_params = { - study_count: study_count, - course_study_count: course_study_count, - initiative_study: (study_count - course_study_count), - passed_count: passed_count, - course_used_count: course_used_count, - school_used_count: school_used_count - } - sr.update_attributes!(update_params) + next if study_count == 0 + course_study_count = data.course_study_count + initiative_study = study_count - course_study_count + str += ", " unless str.empty? + str += ("(#{subject.id}, #{study_count}, #{course_study_count}, #{initiative_study}, " + + "#{data.passed_count}, #{data.course_used_count}, #{data.school_used_count}, " + + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") + buffer_size += 1 + if buffer_size == 1000 + sql = "REPLACE INTO subject_records(#{column_value}) VALUES #{str}" + puts sql + ActiveRecord::Base.connection.execute sql + str = "" + buffer_size = 0 end end + if buffer_size > 0 + sql = "REPLACE INTO subject_records(#{column_value}) VALUES #{str}" + puts sql + ActiveRecord::Base.connection.execute sql + end puts("---------------------data_statistic_end") Rails.logger.info("---------------------data_statistic_end") end From d39fbd6df2266c11242c5394e46b8cb8e1832da7 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 11 Jan 2020 12:41:40 +0800 Subject: [PATCH 23/34] 1 --- lib/tasks/statistic_subject_info.rake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index 7eed62b3c..e7be4de15 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -44,6 +44,9 @@ namespace :subjects do puts("---------------------course_info_statistic_begin") Rails.logger.info("---------------------course_info_statistic_begin") subjects = Subject.where(status: 2) + str = "" + column_value = "subject_id, school_id, school_name, course_count, student_count, choice_shixun_num, " + + "choice_shixun_frequency, created_at, updated_at" subjects.find_each do |subject| puts("---------------------course_info_statistic: #{subject.id}") Rails.logger.info("---------------------course_info_statistic: #{subject.id}") From 26dd6312a7fe560ca5bf03eeb1d17454f4babef7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 13:39:19 +0800 Subject: [PATCH 24/34] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E9=99=90=E5=88=B6?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E7=9A=84=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms/examination_banks/save_exam_form.rb | 2 +- app/forms/item_banks/save_item_form.rb | 6 +- app/forms/validate/user.rb | 2 +- app/models/attachment.rb | 2 +- app/models/challenge.rb | 2 +- app/models/challenge_answer.rb | 2 +- app/models/challenge_choose.rb | 2 +- app/models/challenge_question.rb | 2 +- app/models/challenge_work_score.rb | 2 + app/models/chart_rule.rb | 2 +- app/models/competition.rb | 2 +- app/models/competition_module_md_content.rb | 2 +- app/models/course.rb | 2 +- app/models/course_group.rb | 2 +- app/models/course_module.rb | 2 +- app/models/course_second_category.rb | 2 +- app/models/course_stage.rb | 4 +- app/models/exercise.rb | 4 +- app/models/exercise_answer.rb | 2 +- app/models/exercise_answer_comment.rb | 2 +- app/models/exercise_bank.rb | 4 +- app/models/exercise_bank_choice.rb | 2 +- app/models/exercise_bank_question.rb | 2 +- app/models/exercise_bank_standard_answer.rb | 2 +- app/models/exercise_choice.rb | 2 +- app/models/exercise_question.rb | 2 +- app/models/exercise_standard_answer.rb | 2 +- app/models/graduation_task.rb | 4 +- app/models/graduation_topic.rb | 4 +- app/models/graduation_work.rb | 2 +- app/models/graduation_work_score.rb | 2 +- app/models/gtask_bank.rb | 4 +- app/models/gtopic_bank.rb | 4 +- app/models/hack.rb | 4 +- app/models/hack_set.rb | 4 +- app/models/hack_user_lastest_code.rb | 2 +- app/models/homework_bank.rb | 6 +- app/models/homework_common.rb | 8 +- app/models/inform.rb | 4 +- app/models/library.rb | 2 +- app/models/memo.rb | 2 +- app/models/message.rb | 2 +- app/models/poll.rb | 4 +- app/models/poll_answer.rb | 2 +- app/models/poll_question.rb | 2 +- app/models/poll_vote.rb | 2 +- app/models/shixun_info.rb | 4 +- app/models/shixun_work_comment.rb | 4 +- app/models/stage.rb | 4 +- app/models/student_work.rb | 2 +- app/models/student_works_score.rb | 2 +- app/models/subject.rb | 6 +- app/models/test_set.rb | 4 +- app/models/trustie_hack.rb | 2 +- config/locales/zh-CN.yml | 145 +++++++++++++++++- 55 files changed, 223 insertions(+), 78 deletions(-) diff --git a/app/forms/examination_banks/save_exam_form.rb b/app/forms/examination_banks/save_exam_form.rb index 1fc690a2f..d066300be 100644 --- a/app/forms/examination_banks/save_exam_form.rb +++ b/app/forms/examination_banks/save_exam_form.rb @@ -6,7 +6,7 @@ class ExaminationBanks::SaveExamForm validates :discipline_id, presence: true validates :sub_discipline_id, presence: true validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true } - validates :name, presence: true, length: { maximum: 60, too_long: "名称不能超过60个字符" } + validates :name, presence: true, length: { maximum: 60, too_long: "不能超过60个字符" } validate :validate_duration def validate_duration diff --git a/app/forms/item_banks/save_item_form.rb b/app/forms/item_banks/save_item_form.rb index d0a5649db..b4a2f775c 100644 --- a/app/forms/item_banks/save_item_form.rb +++ b/app/forms/item_banks/save_item_form.rb @@ -7,8 +7,8 @@ class ItemBanks::SaveItemForm validates :sub_discipline_id, presence: true validates :item_type, presence: true, inclusion: {in: %W(SINGLE MULTIPLE JUDGMENT COMPLETION SUBJECTIVE PRACTICAL PROGRAM)} validates :difficulty, presence: true, inclusion: {in: 1..3}, numericality: { only_integer: true } - validates :name, presence: true, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } - validates :analysis, length: { maximum: 1000, too_long: "解析不能超过1000个字符" } + validates :name, presence: true, length: { maximum: 1000, too_long: "不能超过1000个字符" } + validates :analysis, length: { maximum: 1000, too_long: "不能超过1000个字符" } def validate! super @@ -27,7 +27,7 @@ class ItemBanks::SaveItemForm attr_accessor :choice_text, :is_answer - validates :choice_text, presence: true, length: { maximum: 500, too_long: "选项不能超过500个字符" } + validates :choice_text, presence: true, length: { maximum: 500, too_long: "不能超过500个字符" } validates :is_answer, presence: true, inclusion: {in: 0..1}, numericality: { only_integer: true } end end \ No newline at end of file diff --git a/app/forms/validate/user.rb b/app/forms/validate/user.rb index c378a36c4..4387950dd 100644 --- a/app/forms/validate/user.rb +++ b/app/forms/validate/user.rb @@ -4,7 +4,7 @@ module Validate attr_accessor :nickname, :lastname - validates :nickname, presence: true, length: { maximum: 10, too_long: "昵称不能超过10个字符" } + validates :nickname, presence: true, length: { maximum: 10, too_long: "不能超过10个字符" } validates :lastname, presence: true end end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 64531db46..3ff9a6a90 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -25,7 +25,7 @@ class Attachment < ApplicationRecord scope :search_by_container, -> (ids) {where(container_id: ids)} scope :unified_setting, -> {where("unified_setting = ? ", 1)} - validates_length_of :description, maximum: 100, message: "资源描述不能超过100个字符" + validates_length_of :description, maximum: 100, message: "不能超过100个字符" DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 4cada46bc..9608b6e37 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -28,7 +28,7 @@ class Challenge < ApplicationRecord scope :fields_for_list, -> { select([:id, :subject, :st, :score, :position, :shixun_id]) } - validates :task_pass, length: { maximum: 10000, too_long: "过关任务不能超过10000个字符" } + validates :task_pass, length: { maximum: 10000, too_long: "不能超过10000个字符" } after_commit :create_diff_record diff --git a/app/models/challenge_answer.rb b/app/models/challenge_answer.rb index 8fc3c4a21..514f3471a 100644 --- a/app/models/challenge_answer.rb +++ b/app/models/challenge_answer.rb @@ -3,7 +3,7 @@ class ChallengeAnswer < ApplicationRecord belongs_to :challenge has_many :game_answers, :dependent => :destroy - validates :contents, length: { maximum: 5000 , too_long: "答案内容不能超过5000个字符"} + validates :contents, length: { maximum: 5000 , too_long: "不能超过5000个字符"} def view_answer_time(user_id) game_answers.where(user_id: user_id).last&.view_time diff --git a/app/models/challenge_choose.rb b/app/models/challenge_choose.rb index 9a73fbc0a..70997a925 100644 --- a/app/models/challenge_choose.rb +++ b/app/models/challenge_choose.rb @@ -4,6 +4,6 @@ class ChallengeChoose < ApplicationRecord has_many :challenge_tags, :dependent => :destroy has_many :challenge_questions, dependent: :destroy - validates :subject, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } + validates :subject, length: { maximum: 1000, too_long: "不能超过1000个字符" } end diff --git a/app/models/challenge_question.rb b/app/models/challenge_question.rb index 7267f1bb4..d5c26d90e 100644 --- a/app/models/challenge_question.rb +++ b/app/models/challenge_question.rb @@ -1,6 +1,6 @@ class ChallengeQuestion < ApplicationRecord belongs_to :challenge_choose - validates :option_name, length: { maximum: 500, too_long: "选项不能超过500个字符" } + validates :option_name, length: { maximum: 500, too_long: "不能超过500个字符" } end diff --git a/app/models/challenge_work_score.rb b/app/models/challenge_work_score.rb index 1e7c9f7fe..8d27b8107 100644 --- a/app/models/challenge_work_score.rb +++ b/app/models/challenge_work_score.rb @@ -4,6 +4,8 @@ class ChallengeWorkScore < ApplicationRecord belongs_to :challenge has_many :tidings, as: :container, dependent: :destroy + validates :comment, length: { maximum: 500, too_long: "不能超过500个字符" } + def create_tiding trigger_user_id tidings << Tiding.new(user_id: student_work.user_id, trigger_user_id: trigger_user_id, container_id: id, container_type: "ChallengeWorkScore", parent_container_id: student_work_id, diff --git a/app/models/chart_rule.rb b/app/models/chart_rule.rb index 532c7f0e7..a4cca9a1c 100644 --- a/app/models/chart_rule.rb +++ b/app/models/chart_rule.rb @@ -2,5 +2,5 @@ class ChartRule < ApplicationRecord belongs_to :competition belongs_to :competition_stage, optional: true - validates :content, length: { maximum: 1000, too_long: "内容不能超过1000个字符" } + validates :content, length: { maximum: 1000, too_long: "不能超过1000个字符" } end diff --git a/app/models/competition.rb b/app/models/competition.rb index 90f2f63da..55331c3c2 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -33,7 +33,7 @@ class Competition < ApplicationRecord has_many :competition_prizes, dependent: :destroy has_many :competition_prize_users, dependent: :destroy - validates :introduction, length: { maximum: 500, too_long: "简介不能超过500个字符" } + validates :introduction, length: { maximum: 500, too_long: "不能超过500个字符" } before_save :set_laboratory after_create :create_competition_modules diff --git a/app/models/competition_module_md_content.rb b/app/models/competition_module_md_content.rb index 919859236..2d7ae5e36 100644 --- a/app/models/competition_module_md_content.rb +++ b/app/models/competition_module_md_content.rb @@ -5,6 +5,6 @@ class CompetitionModuleMdContent < ApplicationRecord # validates :name, presence: true validates :content, presence: true - validates :content, length: { maximum: 10000 , too_long: "内容不能超过10000个字符"} + validates :content, length: { maximum: 10000 , too_long: "不能超过10000个字符"} end \ No newline at end of file diff --git a/app/models/course.rb b/app/models/course.rb index 5808d2295..1d5175ed3 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -108,7 +108,7 @@ class Course < ApplicationRecord NORMAL = 6 # 普通用户 Anonymous = 7 # 普未登录 - validates :name, presence: true, length: { maximum: 60, too_long: "课堂名称不能超过60个字符" } + validates :name, presence: true, length: { maximum: 60, too_long: "不能超过60个字符" } before_save :set_laboratory after_create :create_board_sync, :act_as_course_activity, :send_tiding diff --git a/app/models/course_group.rb b/app/models/course_group.rb index b49f88bde..5bd27804f 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -9,7 +9,7 @@ class CourseGroup < ApplicationRecord has_many :homework_group_settings, :dependent => :destroy scope :by_group_ids, lambda { |ids| where(id: ids)} - validates :name, length: { maximum: 60, too_long: "分班名称不能超过60个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } validates_uniqueness_of :name, scope: :course_id, message: "不能创建相同名称的分班" after_create :generate_invite_code diff --git a/app/models/course_module.rb b/app/models/course_module.rb index a1b6a7345..32a6a7794 100644 --- a/app/models/course_module.rb +++ b/app/models/course_module.rb @@ -5,7 +5,7 @@ class CourseModule < ApplicationRecord # 二级目录 has_many :course_second_categories - validates :module_name, length: { maximum: 20, too_long: "目录名称不能超过20个字符" } + validates :module_name, length: { maximum: 20, too_long: "不能超过20个字符" } scope :not_hidden, -> { where(hidden: 0) } scope :graduation_module, -> { where(module_type: "graduation") } diff --git a/app/models/course_second_category.rb b/app/models/course_second_category.rb index 6a0ae24bb..963367e0b 100644 --- a/app/models/course_second_category.rb +++ b/app/models/course_second_category.rb @@ -5,7 +5,7 @@ class CourseSecondCategory < ApplicationRecord belongs_to :course_module has_many :homework_commons - validates :name, length: { maximum: 60, too_long: "名称不能超过60个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } def category_type_str category_type == "graduation" && name == "毕设选题" ? "graduation_topics" : ( diff --git a/app/models/course_stage.rb b/app/models/course_stage.rb index c29737484..0fecfb434 100644 --- a/app/models/course_stage.rb +++ b/app/models/course_stage.rb @@ -4,6 +4,6 @@ class CourseStage < ApplicationRecord has_many :course_stage_shixuns, -> { order("course_stage_shixuns.position ASC") }, dependent: :destroy has_many :shixuns, :through => :course_stage_shixuns - validates :name, length: { maximum: 60 , too_long: "章节名称不能超过60个字符"} - validates :description, length: { maximum: 1000, too_long: "章节描述不能超过1000个字符" } + validates :name, length: { maximum: 60 , too_long: "不能超过60个字符"} + validates :description, length: { maximum: 1000, too_long: "不能超过1000个字符" } end diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 86e85b2d0..bf752fb92 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -19,8 +19,8 @@ class Exercise < ApplicationRecord scope :exercise_search, lambda { |keywords| where("exercise_name LIKE ?", "%#{keywords}%") unless keywords.blank?} - validates :exercise_name, length: { maximum: 60, too_long: "试卷名称不能超过60个字符" } - validates :exercise_description, length: { maximum: 100, too_long: "试卷须知不能超过100个字符" } + validates :exercise_name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :exercise_description, length: { maximum: 100, too_long: "不能超过100个字符" } after_create :create_exercise_list diff --git a/app/models/exercise_answer.rb b/app/models/exercise_answer.rb index fb9c8d51f..60269366c 100644 --- a/app/models/exercise_answer.rb +++ b/app/models/exercise_answer.rb @@ -11,6 +11,6 @@ class ExerciseAnswer < ApplicationRecord scope :exercise_answer_is_right, -> {where("score > ?",0.0)} #判断答案是否正确,根据分数总和大于0 scope :score_reviewed, lambda {where("score >= ?",0.0)} #是否评分,用于判断主观题的 - validates :answer_text, length: { maximum: 5000, too_long: "答案不能超过5000个字符" } + validates :answer_text, length: { maximum: 5000, too_long: "不能超过5000个字符" } end \ No newline at end of file diff --git a/app/models/exercise_answer_comment.rb b/app/models/exercise_answer_comment.rb index 62c7360c9..c769fd077 100644 --- a/app/models/exercise_answer_comment.rb +++ b/app/models/exercise_answer_comment.rb @@ -7,5 +7,5 @@ class ExerciseAnswerComment < ApplicationRecord scope :search_answer_comments, lambda {|name,ids| where("#{name}":ids)} - validates :comment, length: { maximum: 100, too_long: "评语不能超过100个字符" } + validates :comment, length: { maximum: 100, too_long: "不能超过100个字符" } end diff --git a/app/models/exercise_bank.rb b/app/models/exercise_bank.rb index fb089ecbc..2d1931e01 100644 --- a/app/models/exercise_bank.rb +++ b/app/models/exercise_bank.rb @@ -18,7 +18,7 @@ class ExerciseBank < ApplicationRecord scope :exercise_bank_search, lambda { |keywords| where("name LIKE ?", "%#{keywords}%") unless keywords.blank?} - validates :name, length: { maximum: 60, too_long: "试卷名称不能超过60个字符" } - validates :description, length: { maximum: 100, too_long: "试卷须知不能超过100个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :description, length: { maximum: 100, too_long: "不能超过100个字符" } end \ No newline at end of file diff --git a/app/models/exercise_bank_choice.rb b/app/models/exercise_bank_choice.rb index 542b27e97..4a4c46251 100644 --- a/app/models/exercise_bank_choice.rb +++ b/app/models/exercise_bank_choice.rb @@ -5,6 +5,6 @@ class ExerciseBankChoice < ApplicationRecord scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 - validates :choice_text, length: { maximum: 500, too_long: "选项不能超过500个字符" } + validates :choice_text, length: { maximum: 500, too_long: "不能超过500个字符" } end \ No newline at end of file diff --git a/app/models/exercise_bank_question.rb b/app/models/exercise_bank_question.rb index 4857b1a55..75d6bfedf 100644 --- a/app/models/exercise_bank_question.rb +++ b/app/models/exercise_bank_question.rb @@ -11,7 +11,7 @@ class ExerciseBankQuestion < ApplicationRecord scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题 - validates :question_title, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } + validates :question_title, length: { maximum: 1000, too_long: "不能超过1000个字符" } def question_type_name case self.question_type diff --git a/app/models/exercise_bank_standard_answer.rb b/app/models/exercise_bank_standard_answer.rb index 4eabd2790..c147c07c9 100644 --- a/app/models/exercise_bank_standard_answer.rb +++ b/app/models/exercise_bank_standard_answer.rb @@ -4,6 +4,6 @@ class ExerciseBankStandardAnswer < ApplicationRecord #attr_accessible :answer_text scope :standard_by_ids, lambda { |s| where(exercise_bank_choice_id: s) } - validates :answer_text, length: { maximum: 5000, too_long: "参考答案不能超过5000个字符" } + validates :answer_text, length: { maximum: 5000, too_long: "不能超过5000个字符" } end \ No newline at end of file diff --git a/app/models/exercise_choice.rb b/app/models/exercise_choice.rb index 1d3e78d8e..3cfd7a17c 100644 --- a/app/models/exercise_choice.rb +++ b/app/models/exercise_choice.rb @@ -7,6 +7,6 @@ class ExerciseChoice < ApplicationRecord scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 - validates :choice_text, length: { maximum: 500, too_long: "选项不能超过500个字符" } + validates :choice_text, length: { maximum: 500, too_long: "不能超过500个字符" } end \ No newline at end of file diff --git a/app/models/exercise_question.rb b/app/models/exercise_question.rb index ea588cba5..2b8d88c57 100644 --- a/app/models/exercise_question.rb +++ b/app/models/exercise_question.rb @@ -16,7 +16,7 @@ class ExerciseQuestion < ApplicationRecord scope :left_question_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 scope :find_objective_questions, -> {where("question_type != ?",4)} #查找全部客观题 - validates :question_title, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } + validates :question_title, length: { maximum: 1000, too_long: "不能超过1000个字符" } def question_type_name diff --git a/app/models/exercise_standard_answer.rb b/app/models/exercise_standard_answer.rb index d527809ef..cec6c6d46 100644 --- a/app/models/exercise_standard_answer.rb +++ b/app/models/exercise_standard_answer.rb @@ -6,5 +6,5 @@ class ExerciseStandardAnswer < ApplicationRecord scope :find_standard_answer_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题 scope :standard_by_ids, lambda { |s| where(exercise_choice_id: s) } - validates :answer_text, length: { maximum: 5000, too_long: "参考答案不能超过5000个字符" } + validates :answer_text, length: { maximum: 5000, too_long: "不能超过5000个字符" } end diff --git a/app/models/graduation_task.rb b/app/models/graduation_task.rb index 9776eb564..4b6465bde 100644 --- a/app/models/graduation_task.rb +++ b/app/models/graduation_task.rb @@ -29,8 +29,8 @@ class GraduationTask < ApplicationRecord belongs_to :gtask_bank, optional: true - validates :name, length: { maximum: 60, too_long: "任务名称不能超过60个字符" } - validates :description, length: { maximum: 5000, too_long: "任务描述不能超过5000个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" } # 未提交 scope :unfinished, -> {where(status: 0)} diff --git a/app/models/graduation_topic.rb b/app/models/graduation_topic.rb index 96e7ea353..2efef271a 100644 --- a/app/models/graduation_topic.rb +++ b/app/models/graduation_topic.rb @@ -19,8 +19,8 @@ class GraduationTopic < ApplicationRecord #after_create :act_as_course_activity # 课题名称和描述字段长度限制 - validates :name, length: { maximum: 60, too_long: "选题名称不能超过60个字符" } - validates :description, length: { maximum: 5000, too_long: "选题描述不能超过5000个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" } def status_name case self.status diff --git a/app/models/graduation_work.rb b/app/models/graduation_work.rb index 33f09d2f8..76ecbb515 100644 --- a/app/models/graduation_work.rb +++ b/app/models/graduation_work.rb @@ -19,7 +19,7 @@ class GraduationWork < ApplicationRecord # has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation" # has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation" - validates :description, length: { maximum: 5000, too_long: "作品描述不能超过5000个字符" } + validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" } scope :has_committed, lambda { where("work_status != 0") } diff --git a/app/models/graduation_work_score.rb b/app/models/graduation_work_score.rb index 71bd9e00f..5c2627c88 100644 --- a/app/models/graduation_work_score.rb +++ b/app/models/graduation_work_score.rb @@ -5,5 +5,5 @@ class GraduationWorkScore < ApplicationRecord belongs_to :graduation_task has_many :attachments, as: :container, dependent: :destroy - validates :comment, length: { maximum: 1000, too_long: "评语不能超过1000个字符" } + validates :comment, length: { maximum: 1000, too_long: "不能超过1000个字符" } end diff --git a/app/models/gtask_bank.rb b/app/models/gtask_bank.rb index 5e9b580c4..8b14d74b1 100644 --- a/app/models/gtask_bank.rb +++ b/app/models/gtask_bank.rb @@ -9,6 +9,6 @@ class GtaskBank < ApplicationRecord scope :myself, ->(user_id) { where(user_id: user_id)} scope :is_public, -> { where(:is_public => true) } - validates :name, length: { maximum: 60, too_long: "任务名称不能超过60个字符" } - validates :description, length: { maximum: 5000, too_long: "任务描述不能超过5000个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" } end diff --git a/app/models/gtopic_bank.rb b/app/models/gtopic_bank.rb index 76ed122e4..1187fd9bc 100644 --- a/app/models/gtopic_bank.rb +++ b/app/models/gtopic_bank.rb @@ -10,6 +10,6 @@ class GtopicBank < ApplicationRecord # 课题名称和描述字段长度限制 - validates :name, length: { maximum: 60, too_long: "选题名称不能超过60个字符" } - validates :description, length: { maximum: 5000, too_long: "选题描述不能超过5000个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" } end diff --git a/app/models/hack.rb b/app/models/hack.rb index d0a874f76..0c5970af4 100644 --- a/app/models/hack.rb +++ b/app/models/hack.rb @@ -2,8 +2,8 @@ class Hack < ApplicationRecord # status: 0 未发布; 1已发布 # diffcult: 难度 1:简单;2:中等; 3:困难 # 编程题 - validates_length_of :name, maximum: 60, message: "名称不能超过60个字符" - validates_length_of :description, maximum: 5000, message: "描述不能超过5000个字符" + validates_length_of :name, maximum: 60, message: "不能超过60个字符" + validates_length_of :description, maximum: 5000, message: "不能超过5000个字符" validates :description, presence: { message: "描述不能为空" } validates :name, presence: { message: "名称不能为空" } # 测试集 diff --git a/app/models/hack_set.rb b/app/models/hack_set.rb index dd4cac7b2..e2ca60549 100644 --- a/app/models/hack_set.rb +++ b/app/models/hack_set.rb @@ -1,6 +1,6 @@ class HackSet < ApplicationRecord - validates_length_of :input, maximum: 1000, message: "测试集输入不能超过5000个字符" - validates_length_of :output, maximum: 1000, message: "测试集输出不能超过5000个字符" + validates_length_of :input, maximum: 1000, message: "不能超过5000个字符" + validates_length_of :output, maximum: 1000, message: "不能超过5000个字符" validates :input, presence: { message: "测试集输入不能为空" } validates :output, presence: { message: "测试集输出不能为空" } validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同" diff --git a/app/models/hack_user_lastest_code.rb b/app/models/hack_user_lastest_code.rb index 99582af41..afea69ed5 100644 --- a/app/models/hack_user_lastest_code.rb +++ b/app/models/hack_user_lastest_code.rb @@ -12,6 +12,6 @@ class HackUserLastestCode < ApplicationRecord scope :mine_hack, ->(author_id){ where(user_id: author_id) } scope :passed, -> {where(status: 1)} - validates_length_of :notes, maximum: 5000, message: "笔记不能超过5000个字" + validates_length_of :notes, maximum: 5000, message: "不能超过5000个字" end diff --git a/app/models/homework_bank.rb b/app/models/homework_bank.rb index e4f941375..7e13891d3 100644 --- a/app/models/homework_bank.rb +++ b/app/models/homework_bank.rb @@ -10,7 +10,7 @@ class HomeworkBank < ApplicationRecord scope :is_public, -> { where(is_public: true)} scope :myself, ->(user_id) { where(user_id: user_id)} - validates :name, length: { maximum: 60, too_long: "作业名称不能超过60个字符" } - validates :description, length: { maximum: 15000, too_long: "作业描述不能超过15000个字符" } - validates :reference_answer, length: { maximum: 15000, too_long: "参考答案不能超过15000个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :description, length: { maximum: 15000, too_long: "不能超过15000个字符" } + validates :reference_answer, length: { maximum: 15000, too_long: "不能超过15000个字符" } end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 040ab65f9..8f084befd 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -35,10 +35,10 @@ class HomeworkCommon < ApplicationRecord # 学生的查重情况 has_many :homework_review_results, :dependent => :destroy - validates :name, length: { maximum: 60, too_long: "作业名称不能超过60个字符" } - validates :description, length: { maximum: 15000, too_long: "作业描述不能超过15000个字符" } - validates :explanation, length: { maximum: 5000, too_long: "说明不能超过5000个字符" } - validates :reference_answer, length: { maximum: 15000, too_long: "参考答案不能超过15000个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :description, length: { maximum: 15000, too_long: "不能超过15000个字符" } + validates :explanation, length: { maximum: 5000, too_long: "不能超过5000个字符" } + validates :reference_answer, length: { maximum: 15000, too_long: "不能超过15000个字符" } # after_update :update_activity before_destroy :update_homework_bank_quotes diff --git a/app/models/inform.rb b/app/models/inform.rb index ce549b2b9..689d52bae 100644 --- a/app/models/inform.rb +++ b/app/models/inform.rb @@ -1,8 +1,8 @@ class Inform < ApplicationRecord belongs_to :container, polymorphic: true, optional: true - validates :name, length: { maximum: 60, too_long: "名称不能超过60个字符" } - validates :description, length: { maximum: 5000, too_long: "内容不能超过5000个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" } has_many :attachments, as: :container, dependent: :destroy diff --git a/app/models/library.rb b/app/models/library.rb index e9920c7b4..baed383a9 100644 --- a/app/models/library.rb +++ b/app/models/library.rb @@ -13,7 +13,7 @@ class Library < ApplicationRecord has_one :praise_tread_cache, foreign_key: :object_id has_many :praise_treads, as: :praise_tread_object, dependent: :destroy - validates :content, length: { maximum: 5000, too_long: "内容不能超过5000个字符" } + validates :content, length: { maximum: 5000, too_long: "不能超过5000个字符" } validates :uuid, presence: true, uniqueness: true diff --git a/app/models/memo.rb b/app/models/memo.rb index 8b38a911e..7be2cf080 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -27,7 +27,7 @@ class Memo < ApplicationRecord scope :hot, -> { order("all_replies_count desc, updated_at desc") } scope :posts, -> { where(root_id: nil, forum_id: [3, 5]) } - validates :content, length: { maximum: 10000, too_long: "帖子内容不能超过10000个字符" } + validates :content, length: { maximum: 10000, too_long: "不能超过10000个字符" } after_create :send_tiding diff --git a/app/models/message.rb b/app/models/message.rb index 76ea303a9..59dd84b5b 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -33,7 +33,7 @@ class Message < ApplicationRecord #转发表 # has_many :forwards, as: :from, dependent: :destroy - validates :subject, length: { maximum: 255, too_long: "标题不能超过255个字符" } + validates :subject, length: { maximum: 255, too_long: "不能超过255个字符" } def update_content(content) message_detail.update_attributes(content: content) diff --git a/app/models/poll.rb b/app/models/poll.rb index 432bb01d2..2ebf4c9ef 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -24,8 +24,8 @@ class Poll < ApplicationRecord scope :poll_search, lambda { |keywords| where("polls_name LIKE ?", "%#{keywords}%") unless keywords.blank?} - validates :polls_name, length: { maximum: 60, too_long: "问卷名称不能超过60个字符" } - validates :polls_description, length: { maximum: 100, too_long: "问卷须知不能超过100个字符" } + validates :polls_name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :polls_description, length: { maximum: 100, too_long: "不能超过100个字符" } after_create :create_polls_list diff --git a/app/models/poll_answer.rb b/app/models/poll_answer.rb index 156be0974..43588502f 100644 --- a/app/models/poll_answer.rb +++ b/app/models/poll_answer.rb @@ -8,6 +8,6 @@ class PollAnswer < ApplicationRecord scope :find_answer_by_custom, lambda {|k,v| where("#{k}":v)} #根据传入的参数查找问题 scope :left_answer_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题 - validates :answer_text, length: { maximum: 500, too_long: "选项不能超过500个字符" } + validates :answer_text, length: { maximum: 500, too_long: "不能超过500个字符" } end \ No newline at end of file diff --git a/app/models/poll_question.rb b/app/models/poll_question.rb index 98c1201da..b38dc1f24 100644 --- a/app/models/poll_question.rb +++ b/app/models/poll_question.rb @@ -9,7 +9,7 @@ class PollQuestion < ApplicationRecord scope :ques_necessary, -> {where("is_necessary = ?",1)} scope :insert_question, lambda {|k| where("question_number > ?",k)} - validates :question_title, length: { maximum: 1000, too_long: "题干不能超过1000个字符" } + validates :question_title, length: { maximum: 1000, too_long: "不能超过1000个字符" } def question_type_name case self.question_type diff --git a/app/models/poll_vote.rb b/app/models/poll_vote.rb index 440881871..2f9715ebc 100644 --- a/app/models/poll_vote.rb +++ b/app/models/poll_vote.rb @@ -9,6 +9,6 @@ class PollVote < ApplicationRecord scope :find_current_vote,lambda {|k,v| where("#{k}": v)} scope :find_vote_text,-> {where("vote_text IS NOT NULL")} - validates :vote_text, length: { maximum: 5000, too_long: "内容不能超过5000个字符" } + validates :vote_text, length: { maximum: 5000, too_long: "不能超过5000个字符" } end \ No newline at end of file diff --git a/app/models/shixun_info.rb b/app/models/shixun_info.rb index a7da422da..c2498067f 100644 --- a/app/models/shixun_info.rb +++ b/app/models/shixun_info.rb @@ -1,10 +1,10 @@ class ShixunInfo < ApplicationRecord belongs_to :shixun validates_uniqueness_of :shixun_id - validates_length_of :fork_reason, maximum: 60, message: "fork原因不能超过60个字符" + validates_length_of :fork_reason, maximum: 60, message: "不能超过60个字符" after_commit :create_diff_record - validates :description, length: { maximum: 5000, too_long: "简介不能超过5000个字符" } + validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" } private diff --git a/app/models/shixun_work_comment.rb b/app/models/shixun_work_comment.rb index c20f5c509..b3b7cfdcd 100644 --- a/app/models/shixun_work_comment.rb +++ b/app/models/shixun_work_comment.rb @@ -2,6 +2,6 @@ class ShixunWorkComment < ApplicationRecord belongs_to :student_work belongs_to :user belongs_to :challenge, optional: true - validates :comment, length: { maximum: 500, too_long: "评语不能超过500个字符" } - validates :hidden_comment, length: { maximum: 500, too_long: "隐藏评语不能超过500个字符" } + validates :comment, length: { maximum: 500, too_long: "不能超过500个字符" } + validates :hidden_comment, length: { maximum: 500, too_long: "不能超过500个字符" } end diff --git a/app/models/stage.rb b/app/models/stage.rb index f6d6b3e56..061efcde3 100644 --- a/app/models/stage.rb +++ b/app/models/stage.rb @@ -6,6 +6,6 @@ class Stage < ApplicationRecord has_many :stage_shixuns, -> { order("stage_shixuns.position ASC") }, dependent: :destroy has_many :shixuns, :through => :stage_shixuns - validates :name, length: { maximum: 60 , too_long: "章节名称不能超过60个字符" } - validates :description, length: { maximum: 1000, too_long: "章节描述不能超过1000个字符" } + validates :name, length: { maximum: 60 , too_long: "不能超过60个字符" } + validates :description, length: { maximum: 1000, too_long: "不能超过1000个字符" } end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 83e6c7b94..3aee0611b 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -19,7 +19,7 @@ class StudentWork < ApplicationRecord before_save :set_work_score - validates :description, length: { maximum: 5000, too_long: "描述不能超过5000个字符" } + validates :description, length: { maximum: 5000, too_long: "不能超过5000个字符" } scope :has_committed, lambda { where("work_status != 0") } # 未提交 diff --git a/app/models/student_works_score.rb b/app/models/student_works_score.rb index dc8c1451b..dec4512a8 100644 --- a/app/models/student_works_score.rb +++ b/app/models/student_works_score.rb @@ -7,7 +7,7 @@ class StudentWorksScore < ApplicationRecord has_many :tidings, as: :container, dependent: :destroy has_many :attachments, as: :container, dependent: :destroy - validates :comment, length: { maximum: 1000, too_long: "评语不能超过1000个字符" } + validates :comment, length: { maximum: 1000, too_long: "不能超过1000个字符" } scope :shixun_comment, lambda { where(is_ultimate: 0) } diff --git a/app/models/subject.rb b/app/models/subject.rb index 459889004..51ef88b3b 100644 --- a/app/models/subject.rb +++ b/app/models/subject.rb @@ -31,9 +31,9 @@ class Subject < ApplicationRecord has_many :subject_shixun_infos, dependent: :destroy has_many :subject_user_infos, dependent: :destroy - validates :name, length: { maximum: 60, too_long: "实践课程名称不能超过60个字符" } - validates :description, length: { maximum: 8000, too_long: "实践课程简介不能超过8000个字符" } - validates :learning_notes, length: { maximum: 2000, too_long: "实践课程须知不能超过2000个字符" } + validates :name, length: { maximum: 60, too_long: "不能超过60个字符" } + validates :description, length: { maximum: 8000, too_long: "不能超过8000个字符" } + validates :learning_notes, length: { maximum: 2000, too_long: "不能超过2000个字符" } scope :visible, lambda{where(status: 2)} scope :published, lambda{where(status: 1)} diff --git a/app/models/test_set.rb b/app/models/test_set.rb index f843bfc43..01bc2b767 100644 --- a/app/models/test_set.rb +++ b/app/models/test_set.rb @@ -1,7 +1,7 @@ class TestSet < ApplicationRecord # match_rule: 匹配规则: full: 完全匹配, last: 末尾匹配 # - validates :input, length: { maximum: 5000, too_long: "输入不能超过5000个字符" } - validates :output, length: { maximum: 5000, too_long: "输出不能超过5000个字符" } + validates :input, length: { maximum: 5000, too_long: "不能超过5000个字符" } + validates :output, length: { maximum: 5000, too_long: "不能超过5000个字符" } end diff --git a/app/models/trustie_hack.rb b/app/models/trustie_hack.rb index eb2cc06e4..87d9d31d8 100644 --- a/app/models/trustie_hack.rb +++ b/app/models/trustie_hack.rb @@ -1,5 +1,5 @@ class TrustieHack < ApplicationRecord - validates_length_of :description, maximum: 500, message: "描述不能超过500个字符" + validates_length_of :description, maximum: 500, message: "不能超过500个字符" has_many :hack_users, :dependent => :destroy belongs_to :trustie_hackathon, counter_cache: true diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index f80982a03..6b8d421ef 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -20,7 +20,150 @@ zh-CN: user: login: '登录名' lastname: '姓名' + nickname: '昵称' discuss: content: '内容' journals_for_message: - notes: '内容' \ No newline at end of file + notes: '内容' + subject: + name: '课程名称' + description: '课程简介' + learning_notes: '学习须知' + stage: + name: '章节名称' + description: '章节描述' + shixun_info: + description: '简介' + fork_reason: 'fork原因' + challenge: + task_pass: '过关任务' + test_set: + input: '输入' + output: '输出' + challenge_question: + option_name: '选项' + challenge_choose: + subject: '题干' + challenge_answer: + contents: '答案内容' + memo: + content: '帖子内容' + course: + name: '课堂名称' + course_group: + name: '分班名称' + course_module: + module_name: '目录名称' + course_second_category: + name: '目录名称' + inform: + name: '标题' + description: '内容' + course_stage: + name: '章节名称' + description: '章节描述' + attachment: + description: '资源描述' + message: + subject: '标题' + message_detail: + content: '内容' + homework_common: + name: '标题' + description: '内容' + explanation: '内容' + reference_answer: '参考答案' + student_work: + description: '内容' + student_work_score: + comment: '评语' + challenge_work_score: + comment: '评语' + shixun_work_comment: + comment: '评语' + hidden_comment: '隐藏评语' + graduation_topic: + name: '选题名称' + description: '选题简介' + graduation_task: + name: '任务标题' + description: '内容' + graduation_work: + description: '作品内容' + graduation_work_score: + comment: '评语' + poll: + polls_name: '问卷标题' + polls_description: '问卷须知' + poll_question: + question_title: '题干' + poll_answer: + answer_text: '选项' + poll_vote: + vote_text: '内容' + exercise: + exercise_name: '试卷标题' + exercise_description: '试卷须知' + exercise_question: + question_title: '题干' + exercise_choice: + choice_text: '选项' + exercise_answer: + answer_text: '答案' + exercise_standard_answer: + answer_text: '参考答案' + exercise_answer_comment: + comment: '评语' + homework_bank: + name: '标题' + description: '内容' + reference_answer: '参考答案' + gtask_bank: + name: '任务标题' + description: '内容' + gtopic_bank: + name: '选题名称' + description: '选题简介' + exercise_bank: + name: '试卷标题' + description: '试卷须知' + exercise_bank_question: + question_title: '题干' + exerise_bank_choice: + choice_text: '选项' + exercise_bank_standard_answer: + answer_text: '参考答案' + library: + title: '标题' + content: '内容' + author_name: '作者姓名' + author_school_name: '作者单位名称' + competition: + introduction: '简介' + competition_module_md_content: + content: '内容' + chart_rule: + content: '内容' + project_package: + title: '标题' + examination_bank: + name: '试卷名称' + item_bank: + name: '题干' + item_analysis: + analysis: '解析' + item_choice: + choice_text: '选项' + hack: + name: '任务名称' + description: '描述' + hack_set: + input: '测试集输入' + output: '测试集输出' + hack_user_lastest_code: + notes: '笔记' + trustie_hack: + description: '描述' + + + From 2a0aa91d16fb78c485cbad229711e44b82269ea5 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Sat, 11 Jan 2020 13:47:25 +0800 Subject: [PATCH 25/34] update quill editor --- .../react/src/common/quillForEditor/index.js | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/public/react/src/common/quillForEditor/index.js b/public/react/src/common/quillForEditor/index.js index 525feba09..d9717078c 100644 --- a/public/react/src/common/quillForEditor/index.js +++ b/public/react/src/common/quillForEditor/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-12-18 08:49:30 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-10 15:05:27 + * @LastEditTime : 2020-01-11 13:43:31 */ import './index.scss'; import 'quill/dist/quill.core.css'; // 核心样式 @@ -18,7 +18,7 @@ import deepEqual from './deepEqual.js' import { fetchUploadImage } from '../../services/ojService.js'; import { getImageUrl } from 'educoder' import ImageBlot from './ImageBlot'; -import FillBlot from './FillBlot'; +// import FillBlot from './FillBlot'; const Size = Quill.import('attributors/style/size'); const Font = Quill.import('formats/font'); // const Color = Quill.import('attributes/style/color'); @@ -31,9 +31,9 @@ Quill.register(ImageBlot); Quill.register(Size); Quill.register(Font, true); // Quill.register({'modules/toolbar': Toolbar}); -Quill.register({ - 'formats/fill': FillBlot -}); +// Quill.register({ +// 'formats/fill': FillBlot +// }); // Quill.register(Color); @@ -87,12 +87,6 @@ function QuillForEditor ({ console.log('调用了tab=====>>>>'); } }, - enter: { - key: 'Enter', - handler: function () { - console.log('enter====>>>>>>'); - } - }, backspace: { key: 'Backspace', /** @@ -103,7 +97,7 @@ function QuillForEditor ({ * @param {*} context 上下文 */ handler: function (range, context) { - console.log('调用了删除按钮', range, context); + // console.log('调用了删除按钮', range, context); /** * 1. 根据range中的index及length值获取删除的起始位置 * length === 0 -> start = index - 1; @@ -112,13 +106,13 @@ function QuillForEditor ({ * ctx = this.quill.getText(start, length === 0 ? 1 : length); * 3. 判断当前删除的下划线是第几个 */ - const {index, length} = range; - const _start = length === 0 ? index - 1 : index; - const _length = length || 1; - let delCtx = this.quill.getText(_start, _length); + // const {index, length} = range; + // const _start = length === 0 ? index - 1 : index; + // const _length = length || 1; + // let delCtx = this.quill.getText(_start, _length); // aa - console.log(delCtx.match(/▁/g)); - console.log('删除的文本信息=====>>>>', delCtx); + // console.log(delCtx.match(/▁/g)); + // console.log('删除的文本信息=====>>>>', delCtx); // const r = window.confirm('确定要删除吗?') // if (r) { // // 调用传入的删除事件 @@ -153,12 +147,6 @@ function QuillForEditor ({ editorRef.current.appendChild(quillNode); const _quill = new Quill(editorRef.current, quillOption); - // _quill.keyboard.addBinding({ - // key: 'tab' - // }, function (range, context) { - // console.log('点击了键盘的删除按钮: ', range, context); - // }); - setQuill(_quill); // 处理图片上传功能 _quill.getModule('toolbar').addHandler('image', (e) => { From 87db175195fb21ab1798cf060b9d2b067dd9e399 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 13:51:13 +0800 Subject: [PATCH 26/34] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=9A=84=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5ac40fbc0..fdb41c114 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,11 +23,11 @@ class ApplicationController < ActionController::Base # 所有请求必须合法签名 def check_sign - if !Rails.env.development? && EduSetting.get("host_name") != "https://test-newweb.educoder.net" + if !Rails.env.development? Rails.logger.info("66666 #{params}") - suffix = request.url.split(".").last.split("?").first - suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释 - unless suffix_arr.include?(suffix) + # suffix = request.url.split(".").last.split("?").first + # suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释 + # unless suffix_arr.include?(suffix) if params[:client_key].present? randomcode = params[:randomcode] # tip_exception(501, "请求不合理") unless (Time.now.to_i - randomcode.to_i).between?(0,5) @@ -38,7 +38,7 @@ class ApplicationController < ActionController::Base else tip_exception(501, "请求不合理") end - end + # end end end From 676a73ed6b40ea6b8223107a36b2147daa45a935 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 14:34:05 +0800 Subject: [PATCH 27/34] =?UTF-8?q?rake=E4=BB=BB=E5=8A=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_trustie_program_question.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/sync_trustie_program_question.rake b/lib/tasks/sync_trustie_program_question.rake index 679164229..a544cff45 100644 --- a/lib/tasks/sync_trustie_program_question.rake +++ b/lib/tasks/sync_trustie_program_question.rake @@ -7,7 +7,7 @@ namespace :sync_program do unless Hack.where(name: program.name).exists? strip_des = strip_html(program.description, 5000) description = strip_des.present? ? strip_des : program.name - hack_params = {name: program.name[0..59], description: description, difficult: 1, open_or_not: 1, score: 200, sub_discipline_id: program.oj_sub_discipline_id} + hack_params = {name: program.name[0..59], description: description, difficult: 1, open_or_not: 1, score: 200, status:0, time_limit: 3, sub_discipline_id: program.oj_sub_discipline_id} puts "language::::#{program.language}" puts "program_bank::::#{program.id}" hack = Hack.new(hack_params) @@ -24,11 +24,11 @@ namespace :sync_program do end end # 新建知识点 - hack_code_params = {code: program.standard_code, language: program.oj_language} + hack_code_params = {code: Base64.encode64(program.standard_code), language: program.oj_language} hack_codes = hack.hack_codes.new(hack_code_params) hack_codes.modify_time = Time.now hack_codes.save! - new_item_params = {name: program.name, sub_discipline_id: program.oj_sub_discipline_id, container: hack, item_type: 'PROGRAM', public: 1, difficulty: 1, user_id: 1} + new_item_params = {name: program.name, sub_discipline_id: program.oj_sub_discipline_id, container: hack, item_type: 'PROGRAM', public: 0, difficulty: 1, user_id: 1} ItemBank.create!(new_item_params) end puts hack.id From 2fe3752aa78a84499ae5cbe51d4853693a4ada2f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 14:34:39 +0800 Subject: [PATCH 28/34] =?UTF-8?q?rake=E4=BB=BB=E5=8A=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_trustie_program_question.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/sync_trustie_program_question.rake b/lib/tasks/sync_trustie_program_question.rake index a544cff45..cd214e438 100644 --- a/lib/tasks/sync_trustie_program_question.rake +++ b/lib/tasks/sync_trustie_program_question.rake @@ -24,7 +24,7 @@ namespace :sync_program do end end # 新建知识点 - hack_code_params = {code: Base64.encode64(program.standard_code), language: program.oj_language} + hack_code_params = {code: program.standard_code.blank? ? nil : Base64.encode64(program.standard_code), language: program.oj_language} hack_codes = hack.hack_codes.new(hack_code_params) hack_codes.modify_time = Time.now hack_codes.save! From 1bfabb9c42fb20a7c4d5e33c6f28102166142966 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 14:44:50 +0800 Subject: [PATCH 29/34] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=9A=84=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 1d47fa293..f67e7d543 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -306,7 +306,7 @@ class HomeworkCommonsController < ApplicationController def alter_name tip_exception("作业名称不能为空") if params[:name].blank? - @homework.update_attributes(name: params[:name].strip) + @homework.update_attributes!(name: params[:name].strip) normal_status("更新成功") end @@ -348,7 +348,7 @@ class HomeworkCommonsController < ApplicationController end def update_explanation - @homework.update_attributes(explanation: params[:explanation]) + @homework.update_attributes!(explanation: params[:explanation]) normal_status(0, "更新成功") end @@ -416,7 +416,7 @@ class HomeworkCommonsController < ApplicationController ActiveRecord::Base.transaction do begin - @homework.update_attributes(homework_params) + @homework.update_attributes!(homework_params) if @homework.homework_type == "group" homework_detail_group = @homework.homework_detail_group @@ -521,7 +521,7 @@ class HomeworkCommonsController < ApplicationController score = challenge[:challenge_score] if setting && setting.score != score score_change = true - setting.update_attributes(score: score) + setting.update_attributes!(score: score) elsif setting.blank? score_change = true HomeworkChallengeSetting.create!(homework_common_id: @homework.id, challenge_id: challenge[:challenge_id], @@ -1159,11 +1159,11 @@ class HomeworkCommonsController < ApplicationController if homework_bank.present? # 如果作业加入过题库则更新参数 if homework_bank.homework_type == 1 - homework_bank.update_attributes(name: homework.name, description: homework.description, + homework_bank.update_attributes!(name: homework.name, description: homework.description, reference_answer: homework.reference_answer, course_list_id: @course.course_list_id) elsif homework_bank.homework_type == 3 homework_detail_group = homework.homework_detail_group - homework_bank.update_attributes(name: homework.name, description: homework.description, + homework_bank.update_attributes!(name: homework.name, description: homework.description, reference_answer: homework.reference_answer, course_list_id: @course.course_list_id, min_num: homework_detail_group.min_num, max_num: homework_detail_group.max_num, base_on_project: homework_detail_group.base_on_project) @@ -1449,7 +1449,7 @@ class HomeworkCommonsController < ApplicationController # 如果用户已有查重记录则更新相似度 否则新建一条记录 user_review = homework.homework_review_results.find_by(:user_id => user) if user_review.present? - user_review.update_attributes(:code_rate => user_rate) + user_review.update_attributes!(:code_rate => user_rate) else homework.homework_review_results.create(:user_id => user, :code_rate => user_rate) end From 1734ce22670a0087befebe506aeaa4bcaf074c16 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 14:57:03 +0800 Subject: [PATCH 30/34] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E9=80=89=E9=A1=B9=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_votes_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/poll_votes_controller.rb b/app/controllers/poll_votes_controller.rb index 17223a955..6dd62153d 100644 --- a/app/controllers/poll_votes_controller.rb +++ b/app/controllers/poll_votes_controller.rb @@ -57,6 +57,8 @@ class PollVotesController < ApplicationController :vote_text => question_answer_text } PollVote.create(answer_option) + # 重新取一次poll_votes + user_votes = @poll_question.poll_votes.find_current_vote("user_id",current_user.id) end # if current_vote_text.present? #已有其他输入文字的选项 # current_vote_text.update_attribute("vote_text", question_answer_text) From 80a1eadb87d33eb2a4e90a437fab2de54c2a0ef4 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 11 Jan 2020 15:03:47 +0800 Subject: [PATCH 31/34] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subjects/shixun_used_info_service.rb | 12 +- lib/tasks/statistic_subject_info.rake | 118 ++++++++++-------- 2 files changed, 71 insertions(+), 59 deletions(-) diff --git a/app/services/subjects/shixun_used_info_service.rb b/app/services/subjects/shixun_used_info_service.rb index 32309fd59..dfd8485e0 100644 --- a/app/services/subjects/shixun_used_info_service.rb +++ b/app/services/subjects/shixun_used_info_service.rb @@ -2,23 +2,25 @@ class Subjects::ShixunUsedInfoService < ApplicationService attr_reader :subject, :stages def initialize(subject) @subject = subject - @stages = subject.stages.includes(shixuns: [myshixuns: :games, homework_commons_shixuns: [homework_common: :course]]) + @stages = subject.stages end def call shixun_infos = [] stages.each do |stage| position = stage.position - stage.shixuns.each_with_index do |shixun, index| + shixuns = stage.shixuns.includes(myshixuns: :games, homework_commons: :course) + shixuns.each_with_index do |shixun, index| stage = "#{position}-#{index+1}" name = shixun.name + myshixuns = shixun.myshixuns challenge_count = shixun.challenges_count course_count = shixun.homework_commons.map{|hc| hc.course_id}.uniq.size school_count = shixun.homework_commons.map{|hc| hc.course&.school_id}.uniq.size used_count = shixun.myshixuns_count - passed_count = shixun.myshixuns.select{|m| m.status == 1}.size - evaluate_count = shixun.myshixuns.map{|m| m.output_times }.sum - passed_ave_time = passed_count > 0 ? shixun.myshixuns.map{|m| m.total_cost_time}.sum : 0 + passed_count = myshixuns.select{|m| m.status == 1}.size + evaluate_count = myshixuns.map{|m| m.output_times }.sum + passed_ave_time = passed_count > 0 ? myshixuns.map{|m| m.total_cost_time}.sum : 0 shixun_infos << {stage: stage, name: name, challenge_count: challenge_count, course_count: course_count, school_count: school_count, used_count: used_count, passed_count: passed_count, evaluate_count: evaluate_count, passed_ave_time: passed_ave_time, shixun_id: shixun.id} diff --git a/lib/tasks/statistic_subject_info.rake b/lib/tasks/statistic_subject_info.rake index e7be4de15..0385e3b5a 100644 --- a/lib/tasks/statistic_subject_info.rake +++ b/lib/tasks/statistic_subject_info.rake @@ -1,18 +1,17 @@ desc "统计实践课程的学习统计数据" namespace :subjects do - buffer_size = 1000 task data_statistic: :environment do puts("---------------------data_statistic_begin") Rails.logger.info("---------------------data_statistic_begin") subjects = Subject.where(status: 2) str = "" + buffer_size = 0 column_value = "subject_id, study_count, course_study_count, initiative_study, passed_count, course_used_count, " + "school_used_count, created_at, updated_at" subjects.find_each do |subject| puts("---------------------data_statistic: #{subject.id}") Rails.logger.info("---------------------data_statistic: #{subject.id}") - #sr = SubjectRecord.find_or_create_by!(subject_id: subject.id) data = Subjects::DataStatisticService.new(subject) study_count = data.study_count next if study_count == 0 @@ -45,6 +44,7 @@ namespace :subjects do Rails.logger.info("---------------------course_info_statistic_begin") subjects = Subject.where(status: 2) str = "" + buffer_size = 0 column_value = "subject_id, school_id, school_name, course_count, student_count, choice_shixun_num, " + "choice_shixun_frequency, created_at, updated_at" subjects.find_each do |subject| @@ -52,23 +52,26 @@ namespace :subjects do Rails.logger.info("---------------------course_info_statistic: #{subject.id}") data = Subjects::CourseUsedInfoService.call(subject) data.each do |key| - scr = SubjectCourseRecord.find_or_create_by!(school_id: key[:school_id], subject_id: subject.id) - unless key[:school_name] == scr.school_name && - key[:course_count] == scr.course_count && - key[:student_count] == scr.student_count && - key[:choice_shixun_num] == scr.choice_shixun_num && - key[:choice_shixun_frequency] == scr.choice_shixun_frequency - update_params = { - school_name: key[:school_name], - course_count: key[:course_count], - student_count: key[:student_count], - choice_shixun_num: key[:choice_shixun_num], - choice_shixun_frequency: key[:choice_shixun_frequency] - } - scr.update_attributes(update_params) + next if key[:school_id].nil? + str += ", " unless str.empty? + str += ("(#{subject.id}, #{key[:school_id]}, '#{key[:school_name]}', #{key[:course_count]}, " + + "#{key[:student_count]}, #{key[:choice_shixun_num]}, #{key[:choice_shixun_frequency]}, " + + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") + buffer_size += 1 + if buffer_size == 1000 + sql = "REPLACE INTO subject_course_records(#{column_value}) VALUES #{str}" + puts sql + ActiveRecord::Base.connection.execute sql + str = "" + buffer_size = 0 end end end + if buffer_size > 0 + sql = "REPLACE INTO subject_course_records(#{column_value}) VALUES #{str}" + puts sql + ActiveRecord::Base.connection.execute sql + end puts("---------------------course_info_statistic_end") Rails.logger.info("---------------------course_info_statistic_end") end @@ -77,65 +80,72 @@ namespace :subjects do puts("---------------------shixun_info_statistic_begin") Rails.logger.info("---------------------shixun_info_statistic_begin") subjects = Subject.where(status: 2) + str = "" + buffer_size = 0 + column_value = "subject_id, shixun_id, stage, shixun_name, challenge_count, course_count, " + + "school_count, used_count, passed_count, evaluate_count, passed_ave_time, created_at, updated_at" subjects.find_each(batch_size: 100) do |subject| puts("---------------------shixun_info_statistic: #{subject.id}") Rails.logger.info("---------------------shixun_info_statistic: #{subject.id}") data = Subjects::ShixunUsedInfoService.call(subject) data.each do |key| - ssi = SubjectShixunInfo.find_or_create_by!(shixun_id: key[:shixun_id], subject_id: subject.id) - unless key[:challenge_count] == ssi.challenge_count && - key[:course_count] == ssi.course_count && - key[:school_count] == ssi.school_count && - key[:used_count] == ssi.used_count && - key[:passed_count] == ssi.passed_count && - key[:evaluate_count] == ssi.evaluate_count && - key[:passed_ave_time] == ssi.passed_ave_time - update_params = { - stage: key[:stage], - shixun_name: key[:name], - challenge_count: key[:challenge_count], - course_count: key[:course_count], - school_count: key[:school_count], - used_count: key[:used_count], - passed_count: key[:passed_count], - evaluate_count: key[:evaluate_count], - passed_ave_time: key[:passed_ave_time] - } - ssi.update_attributes(update_params) + next if key[:shixun_id].nil? + str += ", " unless str.empty? + str += ("(#{subject.id}, #{key[:shixun_id]}, '#{key[:stage]}', '#{key[:name]}', #{key[:challenge_count]}, " + + "#{key[:course_count]}, #{key[:school_count]}, #{key[:used_count]}, #{key[:passed_count]}, " + + "#{key[:evaluate_count]}, #{key[:passed_ave_time]}, " + + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") + buffer_size += 1 + if buffer_size == 1000 + sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str}" + puts sql + ActiveRecord::Base.connection.execute sql + str = "" + buffer_size = 0 end end end + if buffer_size > 0 + sql = "REPLACE INTO subject_shixun_infos(#{column_value}) VALUES #{str}" + puts sql + ActiveRecord::Base.connection.execute sql + end puts("---------------------shixun_info_statistic_end") Rails.logger.info("---------------------shixun_info_statistic_end") end task user_info_statistic: :environment do - puts("---------------------vim ./") + puts("---------------------user_info_statistic_begin") Rails.logger.info("---------------------user_info_statistic_begin") subjects = Subject.where(status: 2) - subjects.find_each(batch_size: 100) do |subject| + str = "" + buffer_size = 0 + column_value = "user_id, subject_id, username, passed_myshixun_count, passed_games_count, " + + "code_line_count, evaluate_count, cost_time, created_at, updated_at" + subjects.find_each(batch_size: 50) do |subject| puts("---------------------user_info_statistic: #{subject.id}") data = Subjects::UserUsedInfoService.call(subject) data.each do |key| - sui = SubjectUserInfo.find_or_create_by!(user_id: key[:user_id], subject_id: subject.id) - unless key[:passed_myshixun_count] == sui.passed_myshixun_count && - key[:passed_games_count] == sui.passed_games_count && - key[:code_line_count] == sui.code_line_count && - key[:evaluate_count] == sui.evaluate_count && - key[:cost_time] == sui.cost_time - update_params = { - username: key[:name], - passed_myshixun_count: key[:passed_myshixun_count], - passed_games_count: key[:passed_games_count], - code_line_count: key[:code_line_count], - evaluate_count: key[:evaluate_count], - cost_time: key[:cost_time] - } - sui.update_attributes(update_params) + next if key[:user_id].nil? + str += ", " unless str.empty? + str += ("(#{key[:user_id]}, #{subject.id}, '#{key[:name]}', '#{key[:passed_myshixun_count]}', " + + "#{key[:passed_games_count]}, #{key[:code_line_count]}, #{key[:evaluate_count]}, #{key[:cost_time]}, " + + "'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')") + buffer_size += 1 + if buffer_size == 1000 + sql = "REPLACE INTO subject_user_infos(#{column_value}) VALUES #{str}" + puts sql + ActiveRecord::Base.connection.execute sql + str = "" + buffer_size = 0 end - end end + if buffer_size > 0 + sql = "REPLACE INTO subject_user_infos(#{column_value}) VALUES #{str}" + puts sql + ActiveRecord::Base.connection.execute sql + end puts("---------------------user_info_statistic_end") Rails.logger.info("---------------------user_info_statistic_end") end From 6fbf7704f035ac787cad1f840f0a1010d1373b33 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 15:08:34 +0800 Subject: [PATCH 32/34] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E9=80=89=E9=A1=B9=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_votes_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/poll_votes_controller.rb b/app/controllers/poll_votes_controller.rb index 6dd62153d..6e4a9b470 100644 --- a/app/controllers/poll_votes_controller.rb +++ b/app/controllers/poll_votes_controller.rb @@ -46,9 +46,9 @@ class PollVotesController < ApplicationController if question_answer_ids.present? if question_answer_text.present? #有文字输入,但是不存在其他选项的 ques_vote_id = question_answer_ids.map(&:to_i).max - if user_votes.find_vote_text.present? - current_vote_text = user_votes.find_vote_text.first - current_vote_text.update_attribute("vote_text", question_answer_text) + ques_vote = user_votes.find_by(poll_answer_id: ques_vote_id) + if ques_vote.present? + ques_vote.update_attribute!("vote_text", question_answer_text) else answer_option = { :user_id => current_user.id, @@ -56,7 +56,7 @@ class PollVotesController < ApplicationController :poll_answer_id => ques_vote_id, :vote_text => question_answer_text } - PollVote.create(answer_option) + PollVote.create!(answer_option) # 重新取一次poll_votes user_votes = @poll_question.poll_votes.find_current_vote("user_id",current_user.id) end From 41181021be5f8560e308acd45e8aa3fed4bf81b1 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 15:21:05 +0800 Subject: [PATCH 33/34] =?UTF-8?q?=E8=AF=84=E9=98=85=E4=B8=8D=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_works_controller.rb | 44 ++++++++++----------- config/locales/zh-CN.yml | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 734229501..98bb6a999 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -68,7 +68,7 @@ class StudentWorksController < ApplicationController begin work = @homework.student_works.find_by!(user_id: params[:user_id]) tip_exception("只有组长才能删除组员") if work.commit_user_id != current_user.id - work.update_attributes(description: nil, project_id: 0, + work.update_attributes!(description: nil, project_id: 0, late_penalty: 0, work_status: 0, commit_time: nil, update_time: nil, group_id: 0, commit_user_id: nil, final_score: nil, work_score: nil, teacher_score: nil, teaching_asistant_score: nil) @@ -112,7 +112,7 @@ class StudentWorksController < ApplicationController student_ids += members for i in 0 .. members.count-1 stu_work = @homework.student_works.find_or_initialize_by(user_id: members[i].to_i) - stu_work.update_attributes(user_id: members[i].to_i, description: student_work.description, + stu_work.update_attributes!(user_id: members[i].to_i, description: student_work.description, homework_common_id: @homework.id, project_id: student_work.project_id, late_penalty: student_work.late_penalty, work_status: student_work.work_status, commit_time: Time.now, update_time: Time.now, group_id: student_work.group_id, @@ -177,7 +177,7 @@ class StudentWorksController < ApplicationController # 原成员更新描述、更新时间以及附件 @homework.student_works.where(group_id: @work.group_id, user_id: (work_user_ids & params_user_ids)).each do |work| # work.update_attributes(update_time: Time.now, description: @work.description, commit_user_id: current_user.id) - work.update_attributes(update_time: Time.now, description: @work.description, update_user_id: current_user.id) + work.update_attributes!(update_time: Time.now, description: @work.description, update_user_id: current_user.id) work.attachments.destroy_all @work.attachments.each do |attachment| att = attachment.copy @@ -202,7 +202,7 @@ class StudentWorksController < ApplicationController # 新增加的成员 (params_user_ids - work_user_ids).each do |user_id| stu_work = @homework.student_works.find_or_initialize_by(user_id: user_id) - stu_work.update_attributes(user_id: user_id, description: @work.description, homework_common_id: @homework.id, + stu_work.update_attributes!(user_id: user_id, description: @work.description, homework_common_id: @homework.id, project_id: @work.project_id, late_penalty: @work.late_penalty, work_status: @work.work_status, commit_time: Time.now, update_time: Time.now, group_id: @work.group_id, commit_user_id: @work.commit_user_id, update_user_id: current_user.id) @@ -257,12 +257,12 @@ class StudentWorksController < ApplicationController work = @homework.student_works.find_or_create_by(user_id: current_user.id) if work.work_status == 0 && work.project_id == 0 - work.update_attributes(project_id: project.id, update_time: Time.now) + work.update_attributes!(project_id: project.id, update_time: Time.now) # 将老师加入项目 project_member = project.members.find_by_user_id(@homework.user_id) if project_member.present? - project_member.member_roles.take.update_attributes(role_id: 3) if project_member.member_roles.take.present? + project_member.member_roles.take.update_attributes!(role_id: 3) if project_member.member_roles.take.present? else member = Member.create(user_id: @homework.user_id, project_id: project.id) member.member_roles << MemberRole.new(role_id: 3) @@ -295,7 +295,7 @@ class StudentWorksController < ApplicationController Tiding.where(user_id: @homework.user_id, trigger_user_id: current_user.id, container_id: work.project.id, container_type: 'ManagerJoinProject').destroy_all - work.update_attributes(project_id: 0) + work.update_attributes!(project_id: 0) normal_status(0,"取消关联成功") rescue Exception => e @@ -329,9 +329,9 @@ class StudentWorksController < ApplicationController # end Attachment.associate_container(params[:attachment_ids], @work.id, @work.class, 7) revise_attachment = Attachment.where(attachtype: 7, container_id: @work.id, container_type: "StudentWork").last - revise_attachment.update_attributes(description: params[:description]) if revise_attachment.present? + revise_attachment.update_attributes!(description: params[:description]) if revise_attachment.present? - @work.update_attributes(update_time: Time.now) + @work.update_attributes!(update_time: Time.now) # 补交附件时给评阅过作品的教师、助教发消息 unless @work.student_works_scores.where.not(score: nil).where(reviewer_role: [1, 2]).pluck(:user_id).uniq.blank? @@ -376,9 +376,9 @@ class StudentWorksController < ApplicationController # 如果作品是未提交的状态则更新为已提交 if @user_course_identity < Course::STUDENT && !new_score.score.nil? && @work.work_status == 0 - @work.update_attributes(work_status: 1, commit_time: Time.now) + @work.update_attributes!(work_status: 1, commit_time: Time.now) # 分组作业更新分组id - @work.update_attributes(group_id: @homework.max_group_id) if @homework.homework_type == "group" + @work.update_attributes!(group_id: @homework.max_group_id) if @homework.homework_type == "group" end new_score.reviewer_role = reviewer_role @@ -442,7 +442,7 @@ class StudentWorksController < ApplicationController # 实训作品的总结 def update_des - @work.update_attributes(des_params) + @work.update_attributes!(des_params) tip_exception(0, "提交成功") end @@ -590,7 +590,7 @@ class StudentWorksController < ApplicationController begin score = @work.student_works_scores.find_by!(id: params[:score_id]) jour = score.journals_for_messages.new(user_id: current_user.id, notes: params[:comment], reply_id: score.user_id) - jour.save + jour.save! normal_status(0,"回复成功") rescue Exception => e uid_logger(e.message) @@ -624,7 +624,7 @@ class StudentWorksController < ApplicationController score_appeal = nil ActiveRecord::Base.transaction do begin - score.update_attributes(appeal_status: 1) + score.update_attributes!(appeal_status: 1) score_appeal = StudentWorksScoresAppeal.create!(user_id: current_user.id, student_works_score_id: score.id, comment: params[:comment], appeal_status: 1) @@ -645,9 +645,9 @@ class StudentWorksController < ApplicationController if score.present? && score.appeal_status == 1 ActiveRecord::Base.transaction do begin - score.update_attributes(appeal_status: 2) + score.update_attributes!(appeal_status: 2) score_appeal = score.student_works_scores_appeal - score_appeal.update_attributes(appeal_status: 2) + score_appeal.update_attributes!(appeal_status: 2) score_appeal.tidings.destroy_all normal_status(0,"撤销成功") rescue Exception => e @@ -670,18 +670,18 @@ class StudentWorksController < ApplicationController ActiveRecord::Base.transaction do begin # 更新appeal_status的值 - score.update_attributes(appeal_status: params[:status].to_i) + score.update_attributes!(appeal_status: params[:status].to_i) score_appeal = score.student_works_scores_appeal - score_appeal.update_attributes(appeal_status: params[:status].to_i) + score_appeal.update_attributes!(appeal_status: params[:status].to_i) score_appeal.tidings.update_all(status: 1) if params[:status].to_i == 3 # 申诉成功后该评分失效 - score.update_attributes(is_invalid: 1) + score.update_attributes!(is_invalid: 1) # 申诉成功后 扣匿评学生的违规匿评扣分 sw = @homework.student_works.find_by(user_id: score.user_id) - sw.update_attribute("appeal_penalty", @homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty) if sw.present? + sw.update_attribute!("appeal_penalty", @homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty) if sw.present? # 申诉成功 重新计算申诉者的匿评分 if @work.student_works_scores.where("reviewer_role = 3 AND appeal_status != 3").count > 0 @@ -689,7 +689,7 @@ class StudentWorksController < ApplicationController else @work.student_score = nil end - @work.save + @work.save! end # todo tiding @@ -862,7 +862,7 @@ class StudentWorksController < ApplicationController else st_work.student_score = student_work.student_score end - st_work.save + st_work.save! Tiding.create(user_id: st_work.user_id, trigger_user_id: current_user.id, container_id: st_score.id, container_type: "StudentWorksScore", parent_container_id: st_work.id, parent_container_type: "StudentWork", diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 6b8d421ef..33aaa1192 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -75,7 +75,7 @@ zh-CN: reference_answer: '参考答案' student_work: description: '内容' - student_work_score: + student_works_score: comment: '评语' challenge_work_score: comment: '评语' From 8ca9339d2418cb11ca0013328761c100128c39a5 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 11 Jan 2020 15:34:31 +0800 Subject: [PATCH 34/34] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 8 ++++---- app/controllers/poll_votes_controller.rb | 2 +- app/controllers/student_works_controller.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index f67e7d543..f386ad1b2 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -976,7 +976,7 @@ class HomeworkCommonsController < ApplicationController elsif homework.max_group_end_time homework.end_time = homework.max_group_end_time end - homework.homework_detail_manual.update_attribute('comment_status', 1) + homework.homework_detail_manual.update_attributes!(comment_status: 1) if homework.course_acts.size == 0 homework.course_acts << CourseActivity.new(user_id: homework.user_id, course_id: homework.course_id) @@ -1004,7 +1004,7 @@ class HomeworkCommonsController < ApplicationController if homework.end_time > Time.now && homework.homework_detail_manual.try(:comment_status) > 1 - homework.homework_detail_manual.update_attribute("comment_status", 1) + homework.homework_detail_manual.update_attributes!(comment_status: 1) end # 补交结束时间 @@ -1071,7 +1071,7 @@ class HomeworkCommonsController < ApplicationController homework.end_time = homework.max_group_end_time if homework.end_time > time && homework_detail_manual.try(:comment_status) > 1 - homework_detail_manual.update_attribute("comment_status", 1) + homework_detail_manual.update_attributes!(comment_status: 1) end # 统一设置 @@ -1080,7 +1080,7 @@ class HomeworkCommonsController < ApplicationController homework.end_time = time end - homework_detail_manual.update_attribute("comment_status", 2) if homework.end_time <= time + homework_detail_manual.update_attributes!(comment_status: 2) if homework.end_time <= time # 实训作业的作品需要计算是否迟交 if homework.homework_type == "practice" diff --git a/app/controllers/poll_votes_controller.rb b/app/controllers/poll_votes_controller.rb index 6e4a9b470..72207f488 100644 --- a/app/controllers/poll_votes_controller.rb +++ b/app/controllers/poll_votes_controller.rb @@ -48,7 +48,7 @@ class PollVotesController < ApplicationController ques_vote_id = question_answer_ids.map(&:to_i).max ques_vote = user_votes.find_by(poll_answer_id: ques_vote_id) if ques_vote.present? - ques_vote.update_attribute!("vote_text", question_answer_text) + ques_vote.update_attributes!(vote_text: question_answer_text) else answer_option = { :user_id => current_user.id, diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 98bb6a999..80d8738a9 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -681,7 +681,7 @@ class StudentWorksController < ApplicationController # 申诉成功后 扣匿评学生的违规匿评扣分 sw = @homework.student_works.find_by(user_id: score.user_id) - sw.update_attribute!("appeal_penalty", @homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty) if sw.present? + sw.update_attributes!(appeal_penalty: @homework.homework_detail_manual.appeal_penalty + sw.appeal_penalty) if sw.present? # 申诉成功 重新计算申诉者的匿评分 if @work.student_works_scores.where("reviewer_role = 3 AND appeal_status != 3").count > 0