From 7de671b0536076226d686627bfae8d8789a11566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 6 Jan 2020 20:25:23 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/shixunHomework/Trainingjobsetting.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index 03ae5ec33..8a0f25ec3 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -302,7 +302,7 @@ class Trainingjobsetting extends Component { work_efficiencys: result.data.work_efficiency, latedeductiontwo: result.data.eff_score, proportion: result.data.shixun_evaluation === 0 ? "均分比例" : result.data.shixun_evaluation === 1 ? "经验值比例" : result.data.shixun_evaluation === 2 ? "自定义分值" : "", - publicwork: result.data.work_public, + publicwork: result.data.score_open, challenge_settings: result.data.challenge_settings, code_review: result.data.code_review, total_scoretwo:result.data.total_score, @@ -672,6 +672,7 @@ class Trainingjobsetting extends Component { // this.props.showNotification(`总分值+效率效率分之和要等于100,现在分值为` + max); // return; // } + debugger if (this.state.proportion === "自定义分值") { try { if(parseFloat(this.state.CalculateMax)!==parseFloat(max)){ @@ -718,8 +719,8 @@ class Trainingjobsetting extends Component { late_penalty: parseInt(this.state.latededuction), //迟交扣分 late_time: moment(this.state.late_time).format('YYYY-MM-DD HH:mm'), //结束时间 answer_open_evaluation: this.state.level === "满分" ? true : false, //扣分项 - work_efficiency: this.state.completionefficiencyscore, //完成效率评分占比 - eff_score: this.state.completionefficiencyscore === true ? this.state.latedeductiontwo : undefined,//效率分 + work_efficiency: this.state.work_efficiencys, //完成效率评分占比 + eff_score: this.state.work_efficiencys === true ? this.state.latedeductiontwo : undefined,//效率分 shixun_evaluation: this.state.proportion === "均分比例" ? 0 : this.state.proportion === "经验值比例" ? 1 : this.state.proportion === "自定义分值" ? 2 : 0, challenge_settings: array, score_open: this.state.publicwork, @@ -752,7 +753,7 @@ class Trainingjobsetting extends Component { late_time: moment(this.state.late_time).format('YYYY-MM-DD HH:mm'), //结束时间 answer_open_evaluation: this.state.level === "满分" ? true : false, //扣分项 work_efficiency: this.state.work_efficiencys, //完成效率评分占比 - eff_score: this.state.completionefficiencyscore === true ? this.state.latedeductiontwo : undefined,//效率分 + eff_score: this.state.work_efficiencys=== true ? this.state.latedeductiontwo : undefined,//效率分 shixun_evaluation: this.state.proportion === "均分比例" ? 0 : this.state.proportion === "经验值比例" ? 1 : this.state.proportion === "自定义分值" ? 2 : 0, challenge_settings: array, score_open: this.state.publicwork, From 1ff295f05ea1d5fdf6879e98f2cd8509b7324684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 6 Jan 2020 20:31:18 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/shixunHomework/Trainingjobsetting.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index adaf77f2d..030e2cde7 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -157,9 +157,9 @@ class Trainingjobsetting extends Component { this.props.triggerRef(this); - // if (this.props.isAdmin() === false) { - // this.cancelEdit() - // } + if (this.props.isAdmin() === false) { + this.cancelEdit() + } } // componentWillReceiveProps(nextProps) { @@ -676,7 +676,7 @@ class Trainingjobsetting extends Component { // this.props.showNotification(`总分值+效率效率分之和要等于100,现在分值为` + max); // return; // } - debugger + if (this.state.proportion === "自定义分值") { try { if(parseFloat(this.state.CalculateMax)!==parseFloat(max)){ From 4b6b51a0ce609c1bc9d1e06a8c866bbe781ab749 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Mon, 6 Jan 2020 20:48:16 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=86=E6=9E=90?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/edu_datas.js | 2 ++ app/assets/stylesheets/edu_datas.scss | 3 ++ app/controllers/edu_datas_controller.rb | 29 +++++++++++++++++++ app/helpers/edu_datas_helper.rb | 2 ++ app/views/edu_datas/code_lines.json.jbuilder | 1 + app/views/edu_datas/game.json.jbuilder | 6 ++++ config/routes.rb | 7 +++++ spec/controllers/edu_datas_controller_spec.rb | 5 ++++ spec/helpers/edu_datas_helper_spec.rb | 15 ++++++++++ 9 files changed, 70 insertions(+) create mode 100644 app/assets/javascripts/edu_datas.js create mode 100644 app/assets/stylesheets/edu_datas.scss create mode 100644 app/controllers/edu_datas_controller.rb create mode 100644 app/helpers/edu_datas_helper.rb create mode 100644 app/views/edu_datas/code_lines.json.jbuilder create mode 100644 app/views/edu_datas/game.json.jbuilder create mode 100644 spec/controllers/edu_datas_controller_spec.rb create mode 100644 spec/helpers/edu_datas_helper_spec.rb diff --git a/app/assets/javascripts/edu_datas.js b/app/assets/javascripts/edu_datas.js new file mode 100644 index 000000000..dee720fac --- /dev/null +++ b/app/assets/javascripts/edu_datas.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/edu_datas.scss b/app/assets/stylesheets/edu_datas.scss new file mode 100644 index 000000000..761de8ec4 --- /dev/null +++ b/app/assets/stylesheets/edu_datas.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the edu_datas controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/edu_datas_controller.rb b/app/controllers/edu_datas_controller.rb new file mode 100644 index 000000000..bb6f7776e --- /dev/null +++ b/app/controllers/edu_datas_controller.rb @@ -0,0 +1,29 @@ +class EduDatasController < ApplicationController + before_action :find_game + skip_before_action :user_setup + skip_before_action :setup_laboratory + # layout :false + include GitHelper + + # params[:game_id] + def game + @shixun = @challenge.shixun + @shixun_env = @shixun.mirror_name + @shixun_tags = @challenge.challenge_tags.map(&:name) + end + + def code_lines + path = @challenge.path + myshixun = @game.myshixun + # content = git_fle_content(myshixun.repo_path, path) || "" + @content = {"content":"#coding=utf-8\n\n#请在此处添加代码完成输出“Hello Python”,注意要区分大小写!\n###### Begin ######\n\n\n\n###### End ######\n\n"} + @content[:content].include?("Begin") + end + + private + def find_game + game_id = params[:game_id] + @game = Game.find(game_id) + @challenge = @game.challenge + end +end diff --git a/app/helpers/edu_datas_helper.rb b/app/helpers/edu_datas_helper.rb new file mode 100644 index 000000000..1a8584d15 --- /dev/null +++ b/app/helpers/edu_datas_helper.rb @@ -0,0 +1,2 @@ +module EduDatasHelper +end diff --git a/app/views/edu_datas/code_lines.json.jbuilder b/app/views/edu_datas/code_lines.json.jbuilder new file mode 100644 index 000000000..d4cccf0a7 --- /dev/null +++ b/app/views/edu_datas/code_lines.json.jbuilder @@ -0,0 +1 @@ +json.content @content \ No newline at end of file diff --git a/app/views/edu_datas/game.json.jbuilder b/app/views/edu_datas/game.json.jbuilder new file mode 100644 index 000000000..3f4a0335e --- /dev/null +++ b/app/views/edu_datas/game.json.jbuilder @@ -0,0 +1,6 @@ +json.challenge @challenge +json.game @game + +json.shixun @shixun +json.shixun_env @env +json.shixun_tags @shixun_tags \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c8abff94e..4a3aec214 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1032,6 +1032,13 @@ Rails.application.routes.draw do get :student_hot_evaluations end end + + resources :edu_datas do + collection do + get :game + get :code_lines + end + end end namespace :admins do diff --git a/spec/controllers/edu_datas_controller_spec.rb b/spec/controllers/edu_datas_controller_spec.rb new file mode 100644 index 000000000..08fd0c8df --- /dev/null +++ b/spec/controllers/edu_datas_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EduDatasController, type: :controller do + +end diff --git a/spec/helpers/edu_datas_helper_spec.rb b/spec/helpers/edu_datas_helper_spec.rb new file mode 100644 index 000000000..2d82005b1 --- /dev/null +++ b/spec/helpers/edu_datas_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the EduDatasHelper. For example: +# +# describe EduDatasHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe EduDatasHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end From 51339a5d5e003f0f4a98ed2a9766f88ee98c3be1 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 7 Jan 2020 10:26:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/concerns/git_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/git_helper.rb b/app/controllers/concerns/git_helper.rb index efc073c86..7c031f24c 100644 --- a/app/controllers/concerns/git_helper.rb +++ b/app/controllers/concerns/git_helper.rb @@ -41,8 +41,8 @@ module GitHelper # 更新文件代码 # content: 文件内容;message:提交描述 def update_file_content(content, repo_path, path, mail, username, message) - content = Base64.encode64(content) - GitService.update_file_base64(repo_path: repo_path, file_path: path, message: message, + #content = Base64.encode64(content) + GitService.update_file(repo_path: repo_path, file_path: path, message: message, content: content, author_name: username, author_email: mail) end