From 9036a443c06ac9ef6a44d0dc7d9b82844fc4ef0c Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 27 Dec 2019 17:55:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Jupyter=E6=8F=90=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 31 ++++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index c871c3064..8a752106c 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -772,7 +772,7 @@ class ShixunsController < ApplicationController # jupyter开启挑战 def jupyter_exec - begin + if is_shixun_opening? tip_show_exception(-3, "#{@shixun.opening_time.strftime('%Y-%m-%d %H:%M:%S')}") end @@ -786,22 +786,23 @@ class ShixunsController < ApplicationController commit_id = commit["id"] cloud_bridge = edu_setting('cloud_bridge') myshixun_identifier = generate_identifier Myshixun, 10 - ActiveRecord::Base.transaction do - @myshixun = @shixun.myshixuns.create!(user_id: current_user.id, identifier: myshixun_identifier, - modify_time: @shixun.modify_time, reset_time: @shixun.reset_time, - onclick_time: Time.now, commit_id: commit_id) - # fork仓库 - project_fork(@myshixun, @repo_path, current_user.login) - rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path) - uri = "#{cloud_bridge}/bridge/game/openGameInstance" - params = {tpiID: "#{@myshixun.id}", tpmGitURL: rep_url, tpiRepoName: @myshixun.repo_name.split("/").last} - interface_post uri, params, 83, "服务器出现问题,请重置环境" + begin + ActiveRecord::Base.transaction do + @myshixun = @shixun.myshixuns.create!(user_id: current_user.id, identifier: myshixun_identifier, + modify_time: @shixun.modify_time, reset_time: @shixun.reset_time, + onclick_time: Time.now, commit_id: commit_id) + # fork仓库 + project_fork(@myshixun, @repo_path, current_user.login) + rep_url = Base64.urlsafe_encode64(repo_ip_url @repo_path) + uri = "#{cloud_bridge}/bridge/game/openGameInstance" + params = {tpiID: "#{@myshixun.id}", tpmGitURL: rep_url, tpiRepoName: @myshixun.repo_name.split("/").last} + interface_post uri, params, 83, "服务器出现问题,请重置环境" + end + rescue => e + uid_logger_error(e.message) + tip_exception("服务器出现问题,请重置环境") end end - rescue => e - uid_logger_error(e.message) - tip_exception(e.message) - end end def publish From 34432615bff445e518424e30b05ac3c7ddd876bb Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Fri, 27 Dec 2019 18:08:50 +0800 Subject: [PATCH 2/2] upagte style --- public/react/src/App.js | 2 +- .../src/common/components/comment/CommentForm.js | 5 ++++- public/react/src/common/quillForEditor/index.js | 9 ++++++++- .../react/src/modules/developer/DeveloperHome.js | 1 - .../developer/components/controlSetting/index.js | 15 ++++++++++++--- .../developer/components/myMonacoEditor/index.js | 3 ++- .../src/modules/developer/studentStudy/index.js | 12 +++++++++--- .../studentStudy/leftpane/commitRecord/index.js | 11 ++++++++--- .../developer/studentStudy/leftpane/index.js | 6 ++++-- public/react/src/modules/message/js/MessagSub.js | 10 +++++++++- .../react/src/redux/reducers/ojForUserReducer.js | 2 +- 11 files changed, 58 insertions(+), 18 deletions(-) diff --git a/public/react/src/App.js b/public/react/src/App.js index 07fd13e49..be6f6a5d6 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -727,7 +727,7 @@ class App extends Component { (props) => () } /> - () } /> diff --git a/public/react/src/common/components/comment/CommentForm.js b/public/react/src/common/components/comment/CommentForm.js index da4814a9e..484940807 100644 --- a/public/react/src/common/components/comment/CommentForm.js +++ b/public/react/src/common/components/comment/CommentForm.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-12-17 17:32:55 * @LastEditors : tangjiang - * @LastEditTime : 2019-12-26 18:43:21 + * @LastEditTime : 2019-12-27 16:50:43 */ import './index.scss'; import React, { useState } from 'react'; @@ -25,6 +25,7 @@ function CommentForm (props) { const { getFieldDecorator } = form; const [ctx, setCtx] = useState(''); + const [focus, setFocus] = useState(false); const options = [ ['bold', 'italic', 'underline'], @@ -38,6 +39,7 @@ function CommentForm (props) { // 点击输入框 const handleInputClick = (type) => { setShowQuill(true); + setFocus(true); } // 取消 const handleCancle = () => { @@ -116,6 +118,7 @@ function CommentForm (props) { overflow: showQuill ? 'none' : 'hidden', transition: 'all 0.3s' }} + autoFocus={focus} style={{ height: '150px' }} placeholder="说点儿什么~" options={options} diff --git a/public/react/src/common/quillForEditor/index.js b/public/react/src/common/quillForEditor/index.js index 48c4224f3..cb214465c 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 : 2019-12-27 10:36:11 + * @LastEditTime : 2019-12-27 16:49:25 */ import './index.scss'; import 'quill/dist/quill.core.css'; // 核心样式 @@ -26,6 +26,7 @@ Quill.register(ImageBlot); function QuillForEditor ({ placeholder, readOnly, + autoFocus, options, value, imgAttrs = {}, // 指定图片的宽高 @@ -172,6 +173,12 @@ function QuillForEditor ({ } }, [quill, handleOnChange]); + useEffect(() => { + if (autoFocus) { + quill.focus(); + } + }, [quill, autoFocus]); + // 返回结果 return (
diff --git a/public/react/src/modules/developer/DeveloperHome.js b/public/react/src/modules/developer/DeveloperHome.js index ae230677a..0a738e6d5 100644 --- a/public/react/src/modules/developer/DeveloperHome.js +++ b/public/react/src/modules/developer/DeveloperHome.js @@ -120,7 +120,6 @@ const testMaps = { 2: '数据结构与算法' } } - class DeveloperHome extends React.PureComponent { /** * 表格列 diff --git a/public/react/src/modules/developer/components/controlSetting/index.js b/public/react/src/modules/developer/components/controlSetting/index.js index 5c970f00e..53b66a359 100644 --- a/public/react/src/modules/developer/components/controlSetting/index.js +++ b/public/react/src/modules/developer/components/controlSetting/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 16:02:36 * @LastEditors : tangjiang - * @LastEditTime : 2019-12-27 09:32:34 + * @LastEditTime : 2019-12-27 18:05:50 */ import './index.scss'; import React, { useState, useRef, useEffect } from 'react'; @@ -19,6 +19,7 @@ const ControlSetting = (props) => { const { hack, + userCode, inputValue, loading, submitLoading, @@ -58,7 +59,7 @@ const ControlSetting = (props) => { // 调试代码 const handleTestCode = (e) => { - if (!hack.code) { + if (!userCode) { notification.warning({ message: '提示', description: '代码块内容不能为空' @@ -77,6 +78,13 @@ const ControlSetting = (props) => { // 提交 const handleSubmit = (e) => { e.preventDefault(); + if (!userCode) { + notification.warning({ + message: '提示', + description: '代码块内容不能为空' + }); + return; + } changeSubmitLoadingStatus(true); onSubmitForm && onSubmitForm(); } @@ -145,9 +153,10 @@ const ControlSetting = (props) => { const mapStateToProps = (state) => { const {commonReducer, ojForUserReducer} = state; const {loading, excuteState, submitLoading, showOrHideControl } = commonReducer; - const { commitTestRecordDetail, hack } = ojForUserReducer; + const { commitTestRecordDetail, hack, userCode } = ojForUserReducer; return { hack, + userCode, loading, submitLoading, excuteState, diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.js b/public/react/src/modules/developer/components/myMonacoEditor/index.js index 7c98d7c09..0e2d9d01b 100644 --- a/public/react/src/modules/developer/components/myMonacoEditor/index.js +++ b/public/react/src/modules/developer/components/myMonacoEditor/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 15:02:52 * @LastEditors : tangjiang - * @LastEditTime : 2019-12-27 10:32:25 + * @LastEditTime : 2019-12-27 18:01:48 */ import './index.scss'; import React, { useState, useRef, useEffect } from 'react'; @@ -86,6 +86,7 @@ function MyMonacoEditor (props, ref) { // TODO 需要优化 节流 const val = editorRef.current.getValue(); // setEditCode(val); + // console.log('编辑器代码====>>>>', val); onCodeChange(val); // 值一变化保存当前代码值 // saveUserInputCode(val); diff --git a/public/react/src/modules/developer/studentStudy/index.js b/public/react/src/modules/developer/studentStudy/index.js index 391a6fbf4..2ef8c4ba9 100644 --- a/public/react/src/modules/developer/studentStudy/index.js +++ b/public/react/src/modules/developer/studentStudy/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 10:53:19 * @LastEditors : tangjiang - * @LastEditTime : 2019-12-27 10:25:14 + * @LastEditTime : 2019-12-27 16:22:47 */ import './index.scss'; import React, { useEffect, useState } from 'react'; @@ -30,6 +30,7 @@ function StudentStudy (props) { // hack_identifier, // user_program_identifier, restoreInitialCode, + changeUserCodeTab, changeShowOrHideControl } = props; @@ -39,13 +40,17 @@ function StudentStudy (props) { saveUserProgramIdentifier } = props; - let { id } = params; + let { id, tab } = params; useEffect(() => { // 保存当前的id saveUserProgramIdentifier(id); // startProgramQuestion(id); getUserProgramDetail(id); + + if (tab) { + changeUserCodeTab(tab); + } }, []); useEffect(() => { @@ -176,7 +181,8 @@ const mapDispatchToProps = (dispatch) => ({ // 恢复初始代码 restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)), changeShowOrHideControl: (flag) => dispatch(actions.changeShowOrHideControl(flag)), - clearOjForUserReducer: () => dispatch(actions.clearOjForUserReducer()) + clearOjForUserReducer: () => dispatch(actions.clearOjForUserReducer()), + changeUserCodeTab: (tab) => dispatch(actions.changeUserCodeTab(tab)) }); export default withRouter(connect( diff --git a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js index ac1b784c6..e7a8eae9c 100644 --- a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js +++ b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 09:49:33 * @LastEditors : tangjiang - * @LastEditTime : 2019-12-27 10:39:00 + * @LastEditTime : 2019-12-27 17:14:04 */ import './index.scss'; import React, { useState, useEffect } from 'react'; @@ -116,6 +116,7 @@ const CommitRecord = (props) => { 执行结果: {reviewResult[status]}

@@ -158,7 +159,7 @@ const CommitRecord = (props) => { // 复制功能 let count = 0; useEffect(() => { - clipboard = new ClipboardJS('.copy_error'); + clipboard = new ClipboardJS('#copyError'); clipboard && clipboard.on('success', (e) => { e.clearSelection(); if (count > 0) return; @@ -166,8 +167,12 @@ const CommitRecord = (props) => { message.success('复制成功'); setTimeout(() => { message.destroy(); - }, 300); + }, 3000); }); + + return () => { + clipboard = null; + } }, []); const clickCopyErrInfo = () => { diff --git a/public/react/src/modules/developer/studentStudy/leftpane/index.js b/public/react/src/modules/developer/studentStudy/leftpane/index.js index 30eedea18..ac8d89321 100644 --- a/public/react/src/modules/developer/studentStudy/leftpane/index.js +++ b/public/react/src/modules/developer/studentStudy/leftpane/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-23 11:33:41 * @LastEditors : tangjiang - * @LastEditTime : 2019-12-25 17:10:30 + * @LastEditTime : 2019-12-27 16:03:04 // */ import './index.scss'; import React, { useState, useEffect, useMemo } from 'react'; @@ -28,7 +28,7 @@ const LeftPane = (props) => { comments_count, /* 评论数*/ user_praise // 用户是否点赞 } = hack; - const [defaultActiveKey, setDefaultActiveKey] = useState('comment'); + const [defaultActiveKey, setDefaultActiveKey] = useState('task'); const navItem = [ { @@ -51,6 +51,8 @@ const LeftPane = (props) => { comment: () }; + console.log('======>>>>>>>', props); + useEffect(() => { setDefaultActiveKey(userCodeTab); }, [userCodeTab]) diff --git a/public/react/src/modules/message/js/MessagSub.js b/public/react/src/modules/message/js/MessagSub.js index 98036301e..29f31f77c 100644 --- a/public/react/src/modules/message/js/MessagSub.js +++ b/public/react/src/modules/message/js/MessagSub.js @@ -475,7 +475,11 @@ class MessagSub extends Component { // } } case "Discuss": - return window.open(`/shixuns/${item.identifier}/shixun_discuss`); + if (item.parent_container_type === 'Hack' && item.extra) { + return window.open(`/myproblems/${item.extra}/comment`); + } else { + return window.open(`/shixuns/${item.identifier}/shixun_discuss`); + } case "Video": if (item.tiding_type === "Apply") { return window.open(`/admins/video_applies`); @@ -506,6 +510,10 @@ class MessagSub extends Component { //分组作业 return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}`); } + case 'Hack': + if (item.extra) { + return window.open(`/problems/${item.extra}/edit`); + } default : return } diff --git a/public/react/src/redux/reducers/ojForUserReducer.js b/public/react/src/redux/reducers/ojForUserReducer.js index f78385049..cbf0a04f3 100644 --- a/public/react/src/redux/reducers/ojForUserReducer.js +++ b/public/react/src/redux/reducers/ojForUserReducer.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 13:41:48 * @LastEditors : tangjiang - * @LastEditTime : 2019-12-27 09:18:02 + * @LastEditTime : 2019-12-27 16:52:30 */ import types from "../actions/actionTypes"; import { Base64 } from 'js-base64';