From f4a87e9384031e3197265c1ede9c595b64dfcc3c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 30 Aug 2019 08:55:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E5=A1=AB=E7=A9=BA?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_questions_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index e6f17778a..dccdae809 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -680,8 +680,9 @@ class ExerciseQuestionsController < ApplicationController normal_status(-1,"已发布/已截止,不允许增删答案!") elsif standard_answer.present? if @exercise_question.question_type == Exercise::COMPLETION - exercise_answers_text = standard_answer.map{|a| a[:answer_text]}.sum.uniq - unless (standard_answer.count == exercise_choice_ids.count) && (standard_answers_text.count == exercise_answers_text.count) + # exercise_answers_text = standard_answer.map{|a| a[:answer_text]}.sum.uniq + # unless (standard_answer.count == exercise_choice_ids.count) && (standard_answers_text.count == exercise_answers_text.count) + unless standard_answer.count == exercise_choice_ids.count normal_status(-1,"已发布/已截止,不允许增删标准答案!") end elsif @exercise_question.question_type == Exercise::SUBJECTIVE From d116096ef64ccd56a3da941717ebb585852ba224 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Fri, 30 Aug 2019 08:58:42 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/git_common.rb | 13 +++++- app/controllers/games_controller.rb | 53 ------------------------ app/views/shixuns/add_file.json.jbuilder | 2 + 3 files changed, 14 insertions(+), 54 deletions(-) create mode 100644 app/views/shixuns/add_file.json.jbuilder diff --git a/app/controllers/concerns/git_common.rb b/app/controllers/concerns/git_common.rb index 452204419..1752df7cb 100644 --- a/app/controllers/concerns/git_common.rb +++ b/app/controllers/concerns/git_common.rb @@ -10,7 +10,6 @@ module GitCommon # ------------------------ # 版本库目录结构 def repository - logger.info("ssssssseeeeeeee#{params}") begin @repo_url = repo_url @repo_path @trees = GitService.file_tree(repo_path: @repo_path, path: @path) @@ -44,4 +43,16 @@ module GitCommon end end + # 为版本库添加文件 + def add_file + @path, message, content = params[:path].strip, params[:message], params[:content] + author_name, author_email = current_user.real_name, current_user.current_user.git_mail + @content = GitService.update_file(repo_path: @repo_path, + file_path: path, + message: message, + content: content, + author_name: author_name, + author_email: author_email) + end + end \ No newline at end of file diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 0064914d3..89b6dca27 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -392,59 +392,6 @@ class GamesController < ApplicationController end end - # # 文件更新;数据评测记录 - # # 生成重新评测认证码 - # # content_modified:0 表示文件没有更新;content_modified:1 表示文件有更新 - # def file_update - # path = params[:path].strip unless params[:path].blank? - # myshixun = @game.myshixun - # rev = params[:rev] ? params[:rev] : "master" - # @content_modified = 0 - # # params[:evaluate] 实训评测时更新必须给的参数,需要依据该参数做性能统计,其它类型的更新可以跳过 - # # 自动保存的时候evaluate为0;点评测的时候为1 - # if params[:evaluate] == 1 - # record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => myshixun.shixun_id, :game_id => @game.id) - # uid_logger("-- game is #{@game.id}, record id is #{record.id}, time is **** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") - # student_work_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f - # record.update_attributes!(:student_work => student_work_time) - # end - # # 远程版本库文件内容 - # last_content = GitService.file_content(repo_path: @repo_path, path: path)["content"] - # last_content = tran_base64_decode64(last_content) - # - # content = if @myshixun.mirror_name.select{|a| a.include?("MachineLearning") || a.include?("Python")}.present? && params[:content].present? - # params[:content].gsub(/\t/, ' ') - # else - # params[:content] - # end - # if content != last_content - # @content_modified = 1 - # code_file = @g.edit_file(myshixun.gpid, current_user.login, :content => content, :file_path => path, - # :branch_name => rev, :commit_message => params[:evaluate] == 0 ? "auto commit" : "task commit") - # uid_logger("-- file update #{code_file}") - # # REDO:更新失败的处理 - # raise("文件更新失败") unless code_file - # end - # - # if record.present? - # consume_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f - # record.update_attributes!(:file_update => consume_time) - # end - # - # # status为2说明是重新评测 - # if @game.status == 2 - # code = CODES.sample(8).join - # @resubmit = "#{code}_#{@myshixun.id}" - # end - # - # if content != last_content && code_file.blank? - # raise("实训平台繁忙(繁忙等级:81),请稍后刷新并重试") - # end - # rescue Exception => e - # uid_logger("-- file update failed #{e.message}") - # raise Educoder::TipException.new("#{e.message}") - # end - # 恢复初始代码 # 注意path为当前打开文件的path def reset_original_code diff --git a/app/views/shixuns/add_file.json.jbuilder b/app/views/shixuns/add_file.json.jbuilder new file mode 100644 index 000000000..6f22dabc8 --- /dev/null +++ b/app/views/shixuns/add_file.json.jbuilder @@ -0,0 +1,2 @@ +json.content @content +json.path @path \ No newline at end of file From eb791f8a74b26c327b9c10f427032d17a1d790b0 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 30 Aug 2019 09:11:27 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E5=A1=AB?= =?UTF-8?q?=E7=A9=BA=E9=A2=98=E4=BF=AE=E6=94=B9=E7=AD=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_questions_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_questions_controller.rb b/app/controllers/exercise_questions_controller.rb index dccdae809..8c3a04f61 100644 --- a/app/controllers/exercise_questions_controller.rb +++ b/app/controllers/exercise_questions_controller.rb @@ -255,8 +255,8 @@ class ExerciseQuestionsController < ApplicationController end elsif @exercise_question.question_type == Exercise::COMPLETION #填空题 old_ex_answer = @exercise_question.exercise_standard_answers #当前问题的全部标准答案 - old_ex_answer_choice_texts = old_ex_answer.pluck(:answer_text).uniq.sort - new_ex_answer_choice_texts = standard_answer.pluck(:answer_text).sum.uniq.sort + old_ex_answer_choice_texts = old_ex_answer.pluck(:answer_text).sort + new_ex_answer_choice_texts = standard_answer.pluck(:answer_text).sum.sort if old_ex_answer_choice_texts != new_ex_answer_choice_texts #填空题标准答案有更改时,才会更新标准答案 new_ex_answer_choice_ids = standard_answer.map {|a| a[:choice_id]}.uniq #新传入的答案数组序号 old_ex_answer_choice_ids = old_ex_answer.pluck(:exercise_choice_id).uniq #全部的答案数组序号