From f28300177bf6f90ba656932e57906ca5ab1d95aa Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 15 Jan 2020 17:36:55 +0800 Subject: [PATCH 01/78] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/item_banks_controller.rb | 3 ++- app/models/hack.rb | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/item_banks_controller.rb b/app/controllers/item_banks_controller.rb index 86b1523c3..f108c1fad 100644 --- a/app/controllers/item_banks_controller.rb +++ b/app/controllers/item_banks_controller.rb @@ -43,8 +43,9 @@ class ItemBanksController < ApplicationController ApplyAction.where(container_type: "ItemBank", container_id: @item.id).destroy_all if @item.item_type == "PROGRAM" @item.container&.destroy! + else + @item.destroy! end - @item.destroy! render_ok end end diff --git a/app/models/hack.rb b/app/models/hack.rb index 0c5970af4..9c8ca44fb 100644 --- a/app/models/hack.rb +++ b/app/models/hack.rb @@ -23,7 +23,6 @@ class Hack < ApplicationRecord belongs_to :sub_discipline has_one :item_bank, as: :container, dependent: :destroy - has_one :examination_bank, as: :container, dependent: :destroy scope :published, -> { where(status: 1) } scope :unpublish, -> { where(status: 0) } From 0a49a9a919ada940dd13671219a582af48c6790d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 15 Jan 2020 20:05:24 +0800 Subject: [PATCH 02/78] 1 --- app/controllers/item_banks_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/item_banks_controller.rb b/app/controllers/item_banks_controller.rb index 86b1523c3..f108c1fad 100644 --- a/app/controllers/item_banks_controller.rb +++ b/app/controllers/item_banks_controller.rb @@ -43,8 +43,9 @@ class ItemBanksController < ApplicationController ApplyAction.where(container_type: "ItemBank", container_id: @item.id).destroy_all if @item.item_type == "PROGRAM" @item.container&.destroy! + else + @item.destroy! end - @item.destroy! render_ok end end From 29161608b1a8218ebd1901ce93b63970f088750e Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 15 Jan 2020 20:51:12 +0800 Subject: [PATCH 03/78] qianyi --- .../20200115020230_add_choice_index_to_exercise_answers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20200115020230_add_choice_index_to_exercise_answers.rb b/db/migrate/20200115020230_add_choice_index_to_exercise_answers.rb index cb518bb42..da68e6ac8 100644 --- a/db/migrate/20200115020230_add_choice_index_to_exercise_answers.rb +++ b/db/migrate/20200115020230_add_choice_index_to_exercise_answers.rb @@ -1,6 +1,6 @@ class AddChoiceIndexToExerciseAnswers < ActiveRecord::Migration[5.2] def change - add_column :exercise_answers, :choice_index, :integer, default: 1 + # add_column :exercise_answers, :choice_index, :integer, default: 1 multi_questions = ExerciseQuestion.where(question_type: 1) multi_questions.includes(:exercise_choices, :exercise_answers).find_each do |question| From 75f892f1bdb700fb1629380c62a77f5439f0d640 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 15 Jan 2020 20:56:53 +0800 Subject: [PATCH 04/78] qianyi --- .../20200115020230_add_choice_index_to_exercise_answers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20200115020230_add_choice_index_to_exercise_answers.rb b/db/migrate/20200115020230_add_choice_index_to_exercise_answers.rb index da68e6ac8..cb518bb42 100644 --- a/db/migrate/20200115020230_add_choice_index_to_exercise_answers.rb +++ b/db/migrate/20200115020230_add_choice_index_to_exercise_answers.rb @@ -1,6 +1,6 @@ class AddChoiceIndexToExerciseAnswers < ActiveRecord::Migration[5.2] def change - # add_column :exercise_answers, :choice_index, :integer, default: 1 + add_column :exercise_answers, :choice_index, :integer, default: 1 multi_questions = ExerciseQuestion.where(question_type: 1) multi_questions.includes(:exercise_choices, :exercise_answers).find_each do |question| From 230959148167b529472f81349bbf13c03420e835 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 16 Jan 2020 09:40:56 +0800 Subject: [PATCH 05/78] =?UTF-8?q?=E9=A2=98=E5=BA=93=E7=9A=84=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/hack.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/hack.rb b/app/models/hack.rb index 0c5970af4..9c8ca44fb 100644 --- a/app/models/hack.rb +++ b/app/models/hack.rb @@ -23,7 +23,6 @@ class Hack < ApplicationRecord belongs_to :sub_discipline has_one :item_bank, as: :container, dependent: :destroy - has_one :examination_bank, as: :container, dependent: :destroy scope :published, -> { where(status: 1) } scope :unpublish, -> { where(status: 0) } From 443ff8d0b143e7302961d060b28403297b82961f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 16 Jan 2020 10:48:57 +0800 Subject: [PATCH 06/78] =?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/application_controller.rb | 2 +- app/controllers/subjects_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3c481e8b6..fdb41c114 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? Rails.logger.info("66666 #{params}") # suffix = request.url.split(".").last.split("?").first # suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释 diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index ce7fc575c..d8a0f4014 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -200,7 +200,7 @@ class SubjectsController < ApplicationController end def append_to_stage - @shixuns = Shixun.where(id: params[:shixun_id]).order("id desc") + @shixuns = Shixun.where(id: params[:shixun_id]).order("field(id, #{params[:shixun_id]})") end # 添加实训项目 From 63012e1ac70354502123ca399cc6de3ed3413c34 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 16 Jan 2020 11:33:36 +0800 Subject: [PATCH 07/78] =?UTF-8?q?=E9=80=89=E7=94=A8=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E7=9A=84=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index db8c688ad..432b83414 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -787,7 +787,7 @@ class HomeworkCommonsController < ApplicationController def create_shixun_homework tip_exception("请至少选择一个实训") if params[:shixun_ids].blank? - shixuns = Shixun.where(id: params[:shixun_ids]).reorder("id desc") + shixuns = Shixun.where(id: params[:shixun_ids]).order("field(id, #{params[:shixun_ids].reverse})") @homework_ids = [] unless params[:category_id].blank? @category = @course.course_second_categories.find_by(id: params[:category_id], category_type: "shixun_homework") From c751f2a96be277c7bdb1ca8acc69281b4e449859 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 16 Jan 2020 11:36:17 +0800 Subject: [PATCH 08/78] =?UTF-8?q?=E9=80=89=E7=94=A8=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E7=9A=84=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 3 ++- app/controllers/subjects_controller.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 432b83414..d68304bfe 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -787,7 +787,8 @@ class HomeworkCommonsController < ApplicationController def create_shixun_homework tip_exception("请至少选择一个实训") if params[:shixun_ids].blank? - shixuns = Shixun.where(id: params[:shixun_ids]).order("field(id, #{params[:shixun_ids].reverse})") + order_ids = params[:shixun_ids].size > 0 ? params[:shixun_ids].reverse.join(',') : -1 + shixuns = Shixun.where(id: params[:shixun_ids]).order("field(id, #{order_ids})") @homework_ids = [] unless params[:category_id].blank? @category = @course.course_second_categories.find_by(id: params[:category_id], category_type: "shixun_homework") diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index d8a0f4014..e820c383d 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -200,7 +200,8 @@ class SubjectsController < ApplicationController end def append_to_stage - @shixuns = Shixun.where(id: params[:shixun_id]).order("field(id, #{params[:shixun_id]})") + order_ids = params[:shixun_id].size > 0 ? params[:shixun_id].join(',') : -1 + @shixuns = Shixun.where(id: params[:shixun_id]).order("field(id, #{order_ids})") end # 添加实训项目 From 97dab335f3f6c83d159c434e4ae5a948de2dc483 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 16 Jan 2020 14:39:05 +0800 Subject: [PATCH 09/78] =?UTF-8?q?=E9=95=9C=E5=83=8F=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/edu_datas/game.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/edu_datas/game.json.jbuilder b/app/views/edu_datas/game.json.jbuilder index 3f4a0335e..963583d2f 100644 --- a/app/views/edu_datas/game.json.jbuilder +++ b/app/views/edu_datas/game.json.jbuilder @@ -3,4 +3,5 @@ json.game @game json.shixun @shixun json.shixun_env @env +json.shixun_image @shixun.main_mirror_name json.shixun_tags @shixun_tags \ No newline at end of file From 08012fb515a43e5c9e821e6a9992b013aca506c9 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Thu, 16 Jan 2020 15:34:41 +0800 Subject: [PATCH 10/78] add wxcode --- public/react/src/App.js | 10 + public/react/src/modules/wxcode/index.js | 271 +++++++++++++++++ public/react/src/modules/wxcode/index.scss | 275 ++++++++++++++++++ public/react/src/redux/actions/actionTypes.js | 9 +- public/react/src/redux/actions/index.js | 22 +- public/react/src/redux/actions/wxCode.js | 196 +++++++++++++ public/react/src/redux/reducers/index.js | 4 +- .../react/src/redux/reducers/wxcodeReducer.js | 68 +++++ public/react/src/services/wxcodeService.js | 44 +++ 9 files changed, 896 insertions(+), 3 deletions(-) create mode 100644 public/react/src/modules/wxcode/index.js create mode 100644 public/react/src/modules/wxcode/index.scss create mode 100644 public/react/src/redux/actions/wxCode.js create mode 100644 public/react/src/redux/reducers/wxcodeReducer.js create mode 100644 public/react/src/services/wxcodeService.js diff --git a/public/react/src/App.js b/public/react/src/App.js index 247e7939b..96a4f91b0 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -366,6 +366,11 @@ const JupyterTPI = Loadable({ loader: () => import('./modules/tpm/jupyter'), loading: Loading }); +// 微信代码编辑器 +const WXCode = Loadable({ + loader: () => import('./modules/wxcode'), + loading: Loading +}); // //个人竞赛报名 // const PersonalCompetit = Loadable({ // loader: () => import('./modules/competition/personal/PersonalCompetit.js'), @@ -823,6 +828,11 @@ class App extends Component { render={ (props) => () }/> + () + } + /> { + + const { + isShow, + wxCode, + path, + showLoading, + // userCode, + testCase = [], + getWXCode, + last_compile_output, + test_sets_count, + sets_error_count, + getWXCodeTestCase, + restoreWXCode, + updateWXCodeForEditor, + updateWXCodeForInterval, + evaluateWxCode, + showWXCodeTextCase, + changeWXCodeEvaluateLoading + } = props; + + const {identifier} = props.match.params; + const [isActive, setIsActive] = useState(-1); + // const [isVisible, setIsVisible] = useState(false); + const editorRef = useRef(null); + let timer = null; + useEffect(() => { + // 加载代码块内容 + getWXCode(identifier); + // 加载测试集 + const params = { + path, + status: 0, + retry: 1 + }; + getWXCodeTestCase(identifier, params); + }, []); + // 关闭 + const handleCloseTestCase = () => { + // setIsVisible(false); + showWXCodeTextCase(false) + } + // 测试集 + const handleClickTestCase = () => { + // setIsVisible(true); + showWXCodeTextCase(true) + } + // 编辑器代码 + const handleEditorChange = (origin, monaco) => { + editorRef.current = monaco; // 获取当前monaco实例 + // setEditCode(origin); // 保存编辑器初始值 + editorRef.current.onDidChangeModelContent(e => { // 监听编辑器内容的变化 + // TODO 需要优化 节流 + const val = editorRef.current.getValue(); + // console.log('编辑器代码====>>>>', val); + // updateWXCodeForEditor(val); + codeChange(val); + }); + }; + + const codeChange = (code) => { + // console.log(code); + updateWXCodeForEditor(code); + if (!timer) { + timer = setInterval(function () { + clearInterval(timer); + timer = null; + // 调用更新代码 + updateWXCodeForInterval(identifier, path); + }, 10000); + } + } + + // 关闭单个测试集 + const handleCloseItem = (i, flag) => { + if (!flag) return; + setIsActive(isActive === i ? -1 : i); + } + // 初始化 + const handleResetCode = () => { + const result = window.confirm('你在本文件中修改的内容将丢失, 是否确定重新加载初始代码?'); + if (result) { + identifier && restoreWXCode(identifier, { path }); + } + } + // 评测 + const handleEvalateCode = () => { + changeWXCodeEvaluateLoading(true); + evaluateWxCode(identifier, path); + } + + const tcclasses = isShow ? `wx-code-test-case active` : 'wx-code-test-case'; + const loading = showLoading ? 'code-evaluate-loading active' : 'code-evaluate-loading'; + const _val = sets_error_count === 0; + let resultTxt = (_val) ? '全部通过' : `${sets_error_count}组测试结果不匹配`; + const iclasses = _val ? 'iconfont icon-tishi1 icon success' : 'iconfont icon-tishi1 icon fail'; + const tclasses = _val ? 'result-txt success' : 'result-txt fail'; + const ulClasses = last_compile_output ? 'case-list hasResult' : 'case-list'; + return ( +
+
+
+ +
+
+
+ + + 初始化 + + + + 测试集 + +
+ {/* */} + +
+
+ {/* 测试集 */} +
+
+
+ 共{testCase.length}个测试用例 + 关闭 +
+
+ + {test_sets_count - sets_error_count}/{test_sets_count} + {resultTxt} +
+
    + { + testCase.map((item, i) => { + const {input, output, actual_output, is_public, result} = item; + const _classes = isActive === i ? 'case-item-desc active' : 'case-item-desc'; + const iconclasses = isActive === i ? 'iconfont icon-sanjiaoxing-down icon active' : 'iconfont icon-triangle icon'; + const headerClasses = is_public ? 'item-header-desc active' : 'item-header-desc'; + // console.log(_classes); + return ( +
  • +
    handleCloseItem(i, is_public)}> +

    + + 测试集{i + 1} +

    + { + is_public + ? (result + ? + : ) + : ( + 隐藏测试集,暂不支持解锁和查看 + {/* {result + ? + : + } */} + ) + } +
    + +
    + 测试输入 + {input || '-'} + 预期输出 + {/* */} + */} + 实际输出 +