Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

video_transcode
daiao 5 years ago
commit 7cfe99af39

@ -326,8 +326,8 @@ module.exports = {
comments: false
},
compress: {
drop_debugger: false,
drop_console: false
drop_debugger: true,
drop_console: true
}
}
}),

@ -1,7 +1,7 @@
/*
* @Description: 评论表单
* @Author: tangjiang
* @Github:
* @Github:
* @Date: 2019-12-17 17:32:55
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-06 18:42:09
@ -18,7 +18,7 @@ function CommentForm (props) {
const {
onCancel,
onSubmit,
onSubmit,
form,
type
} = props;
@ -47,7 +47,7 @@ function CommentForm (props) {
setShowQuill(false);
setCtx('');
props.form.resetFields();
onCancel && onCancel();
onCancel && onCancel();
}
// 编辑器内容变化时
@ -98,7 +98,7 @@ function CommentForm (props) {
{ required: true, message: '评论内容不能为空'}
],
})(
<Input
<Input
onClick={() => handleInputClick(type)}
placeholder="说点儿什么~"
className={showQuill ? '' : 'show_input'}
@ -110,13 +110,13 @@ function CommentForm (props) {
/>
)
}
<QuillForEditor
imgAttrs={{width: '60px', height: '30px'}}
wrapStyle={{
height: showQuill ? 'auto' : '0px',
opacity: showQuill ? 1 : 0,
overflow: showQuill ? 'none' : 'hidden',
overflow: showQuill ? 'none' : 'none',
transition: 'all 0.3s'
}}
autoFocus={focus}

@ -435,7 +435,7 @@ a.white-btn.use_scope-btn:hover{
.maxwidth190{max-width: 190px; color:#666666;font-size: 14px;}
.color05101A{color:#05101A;}
.liactive{border-left: 1px solid #4CACFF;}
.ant-btn-lg{height: 39px;}
.bannername{
max-width: 907px;
overflow: hidden;

@ -1,7 +1,7 @@
/*
* @Description: 自定义测试化用例
* @Author: tangjiang
* @Github:
* @Github:
* @Date: 2019-11-27 19:46:14
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-26 20:07:35
@ -50,11 +50,8 @@ function InitTabCtx (props, ref) {
>
{
getFieldDecorator('input', {
rules: [
{ required: true, message: '输入值不能为空'}
],
initialValue: inputValue
})(<TextArea
})(<TextArea
className="input_textarea_style"
rows={8}
placeholder="请填写测试用例的输入值,点击“调试代码”"

@ -93,7 +93,7 @@ const SettingDrawer = (props) => {
});
return (
<React.Fragment>
<h2 className={'setting_h2'}>{title}</h2>
<h3 className={'setting_h2'}>{title}</h3>
{ result }
</React.Fragment>
);

@ -9,15 +9,13 @@
import './index.scss';
import React, { useState, useRef, useEffect } from 'react';
import { Drawer, Tooltip, Badge } from 'antd';
import { fromStore, CNotificationHOC } from 'educoder';
import { fromStore, CNotificationHOC } from 'educoder';
import { connect } from 'react-redux';
import MonacoEditor from '@monaco-editor/react';
import SettingDrawer from '../../components/monacoSetting';
import CONST from '../../../../constants';
import MyIcon from '../../../../common/components/MyIcon';
// import actions from '../../../../redux/actions';
const { fontSetting, opacitySetting } = CONST;
const maps = {
'c': 'main.c',
@ -26,15 +24,15 @@ const maps = {
'python': 'main.py'
};
function MyMonacoEditor (props, ref) {
function MyMonacoEditor(props, ref) {
const {
code,
notice,
language,
language,
identifier,
hadCodeUpdate,
showOrHideControl,
showOrHideControl,
// saveUserInputCode,
onCodeChange,
onRestoreInitialCode,
@ -42,21 +40,16 @@ function MyMonacoEditor (props, ref) {
} = props;
const [showDrawer, setShowDrawer] = useState(false); // 控制配置滑框
// const [editCode, setEditCode] = useState('');
// const [curLang, setCurLang] = useState('C');
const [fontSize, setFontSize] = useState(() => { // 字体
return +fromStore('oj_fontSize') || 14;
});
const [theme, setTheme] = useState(() => { // 主题 theme
return fromStore('oj_theme') || 'dark';
});
const [ height, setHeight ] = useState('calc(100% - 56px)');
const [height, setHeight] = useState('calc(100% - 56px)');
const editorRef = useRef(null);
console.log(language, code, '-------========----------')
// useEffect(() => {
// setEditCode(props.code || '');
// }, [props]);
useEffect(() => {
setHeight(showOrHideControl ? 'calc(100% - 378px)' : 'calc(100% - 56px)');
}, [showOrHideControl]);
@ -78,45 +71,38 @@ function MyMonacoEditor (props, ref) {
setTheme(value);
}
// 文本框内容变化时,记录文本框内容
const handleEditorChange = (origin, monaco) => {
// 文本框内容变化时,记录文本框内容
const handleEditorChange = (_, monaco) => {
editorRef.current = monaco; // 获取当前monaco实例
// setEditCode(origin); // 保存编辑器初始值
editorRef.current.onDidChangeModelContent(e => { // 监听编辑器内容的变化
// TODO 需要优化 节流
const val = editorRef.current.getValue();
// setEditCode(val);
// console.log('编辑器代码====>>>>', val);
onCodeChange(val);
// 值一变化保存当前代码值
// saveUserInputCode(val);
});
}
useEffect(() => {
if (editorRef.current) {
editorRef.current.onDidChangeModelContent(e => { // 监听编辑器内容的变化
const val = editorRef.current.getValue();
onCodeChange(val);
});
}
}, [
editorRef.current
])
// 配置编辑器属性
const editorOptions = {
selectOnLineNumbers: true,
automaticLayout: true,
fontSize: `${fontSize}px`
}
// 恢复初始代码
const handleRestoreCode = () => {
props.confirm({
title: '提示',
content: '确定要恢复代码吗?',
onOk () {
onOk() {
onRestoreInitialCode && onRestoreInitialCode();
}
})
// Modal.confirm({
// content: '确定要恢复代码吗?',
// okText: '确定',
// cancelText: '取消',
// onOk () {
// onRestoreInitialCode && onRestoreInitialCode();
// }
// })
}
const handleUpdateNotice = () => {
@ -124,49 +110,38 @@ function MyMonacoEditor (props, ref) {
onUpdateNotice && onUpdateNotice();
}
}
// const renderRestore = identifier ? (
// <MyIcon type="iconzaicizairu" />
// ) : '';
// lex_has_save ${hadCodeUpdate} ? : ''
const _classnames = hadCodeUpdate ? `flex_strict flex_has_save` : 'flex_strict';
return (
<React.Fragment>
<div className={"monaco_editor_area"}>
<div className="code_title">
{/* 未保存时 ? '学员初始代码文件' : main.x */}
<span className='flex_strict' style={{ color: '#ddd'}}>{identifier ? language ? maps[language.toLowerCase()] : '' : '学员初始代码文件'}</span>
<span className='flex_strict' style={{ color: '#ddd' }}>{identifier ? language ? maps[language.toLowerCase()] : '' : '学员初始代码文件'}</span>
<span className={_classnames}>{hadCodeUpdate ? '已保存' : ''}</span>
{/* <Tooltip
style={{ background: 'gold' }}
className="tooltip_style"
title="通知"
placement="bottom"
> */}
<Tooltip
placement="bottom"
title="通知"
>
<Badge
className="flex_normal"
style={{ color: '#666'}}
<Badge
className="flex_normal"
style={{ color: '#666' }}
dot={notice}
onClick={handleUpdateNotice}
>
{/* <Icon type="bell" /> */}
<MyIcon type="iconxiaoxi1" style={{fontSize: '18px'}}/>
<MyIcon type="iconxiaoxi1" style={{ fontSize: '18px' }} />
</Badge>
</Tooltip>
<Tooltip
placement="bottom"
title="恢复"
>
<MyIcon
className="flex_normal"
onClick={handleRestoreCode}
<MyIcon
className="flex_normal"
onClick={handleRestoreCode}
type="iconzaicizairu"
style={{ display: identifier ? 'inline-block' : 'none', fontSize: '18px'}}
style={{ display: identifier ? 'inline-block' : 'none', fontSize: '18px' }}
/>
{/* <span onClick={handleRestoreCode} className="flex_normal" style={{ display: identifier ? 'inline-block' : 'none'}}>{renderRestore}</span> */}
</Tooltip>
@ -174,18 +149,18 @@ function MyMonacoEditor (props, ref) {
placement="bottom"
title="设置"
>
<MyIcon className='code-icon' type="iconshezhi" onClick={handleShowDrawer} style={{fontSize: '18px'}}/>
<MyIcon className='code-icon' type="iconshezhi" onClick={handleShowDrawer} style={{ fontSize: '18px' }} />
</Tooltip>
</div>
<MonacoEditor
height={height}
width="100%"
language={language && language.toLowerCase()}
value={code || ''}
options={editorOptions}
theme={theme} // dark || light
editorDidMount={handleEditorChange}
/>
height={height}
width="100%"
language={language && language.toLowerCase()}
value={code || ''}
options={editorOptions}
theme={theme} // dark || light
editorDidMount={handleEditorChange}
/>
</div>
<Drawer
@ -194,12 +169,12 @@ function MyMonacoEditor (props, ref) {
onClose={handleDrawerClose}
visible={showDrawer}
>
<SettingDrawer
{...fontSetting}
<SettingDrawer
{...fontSetting}
onChangeFontSize={handleChangeFontSize}
onChangeTheme={handleChangeTheme}
/>
<SettingDrawer {...opacitySetting}/>
<SettingDrawer {...opacitySetting} />
</Drawer>
</React.Fragment>
)
@ -212,12 +187,6 @@ const mapStateToProps = (state) => {
}
};
// const mapDispatchToProps = (dispatch) => ({
// // saveUserInputCode: (code) => dispatch(actions.saveUserInputCode(code)),
// });
// MyMonacoEditor = React.forwardRef(MyMonacoEditor);
export default connect(
mapStateToProps,
// mapDispatchToProps
)(CNotificationHOC() (MyMonacoEditor));
)(CNotificationHOC()(MyMonacoEditor));

@ -8,23 +8,19 @@
import './index.scss';
import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import SplitPane from 'react-split-pane';// import { Form } from 'antd';
import SplitPane from 'react-split-pane';
import { Button } from 'antd';
import LeftPane from './leftpane';
import RightPane from './rightpane';
import { withRouter } from 'react-router';
import { toStore, CNotificationHOC } from 'educoder';
import UserInfo from '../components/userInfo';
// import RightPane from './rightpane/index';
import actions from '../../../redux/actions';
// import {ModalConfirm} from '../../../common/components/ModalConfirm';
const NewOrEditTask = (props) => {
const {
publishLoading,
handlePublish,
// testCases = [],
// ojTestCaseValidate = [],
identifier,
isPublish,
userInfo,
@ -38,15 +34,10 @@ const NewOrEditTask = (props) => {
getQuestion,
saveSearchParams,
setOjInitialValue,
courseQuestions
// updateTestAndValidate,
} = props;
// 表单提交
const handleSubmitForm = () => {
// 改变loading状态
changeSubmitLoadingStatus(true);
// 调用输入表单验证功能
if (props.identifier) {
props.handleUpdateOjForm(props);
} else {
@ -54,12 +45,10 @@ const NewOrEditTask = (props) => {
}
};
const id = props.match.params.id;
useEffect(() => {
// 获取用户信息
getUserInfoForNew();
// console.log('获取路由参数: ====', props.match.params);
const id = props.match.params.id;
// 保存OJForm的id号指明是编辑还是新增
props.saveOJFormId(id);
// 获取地址栏查询参数
const $searchs = window.location.search && window.location.search.substring(1);
@ -80,21 +69,16 @@ const NewOrEditTask = (props) => {
tag_discipline_id: tag_arrs
});
}
saveSearchParams({searchParams: $searchs, curPage: obj['pages']});
saveSearchParams({ searchParams: $searchs, curPage: obj['pages'] });
}
// 获取课程列表
getQuestion({
source: 'question'
});
if (id) { // id号即 identifier
// TODO id 存在时, 编辑, 获取 store 中的记录数
props.getOJFormById(id);
} else {
// 清空store中的测试用例集合
// props.clearOJFormStore();
}
return () => {}
}, []);
}, [id])
// 模拟挑战
const imitationChallenge = () => {
@ -107,11 +91,9 @@ const NewOrEditTask = (props) => {
// 开始挑战
const startChallenge = () => {
// 调用 start 接口, 成功后跳转到开启实战
// TODO
identifier && validateOjForm(props, 'challenge', () => {
startProgramQuestion(identifier, props);
});
// identifier && startProgramQuestion(identifier, props);
}
// 取消
@ -120,20 +102,15 @@ const NewOrEditTask = (props) => {
props.clearOJFormStore();
// 清空描述信息
toStore('oj_description', '');
// props.history.push('/problems');
props.history.push(`/problemset?${props.searchParams}`);
}
// 发布
const handleClickPublish = () => {
// ModalConfirm('提示', (<p>发布后即可应用到自己管理的课堂<br /> 是否确认发布?</p>), () => {
// changePublishLoadingStatus(true);
// handlePublish(props, 'publish');
// });
props.confirm({
title: '提示',
content: (<p>发布后即可应用到自己管理的课堂<br /> 是否确认发布?</p>),
onOk () {
onOk() {
changePublishLoadingStatus(true);
handlePublish(props, 'publish');
}
@ -141,14 +118,10 @@ const NewOrEditTask = (props) => {
}
// 撤销发布
const handleClickCancelPublish = () => {
// ModalConfirm('提示', (<p>是否确认撤销发布?</p>), () => {
// changePublishLoadingStatus(true);
// handleCancelPublish(props, identifier);
// });
props.confirm({
title: '提示',
content: ((<p>是否确认撤销发布?</p>)),
onOk () {
onOk() {
changePublishLoadingStatus(true);
handleCancelPublish(props, identifier);
}
@ -174,33 +147,33 @@ const NewOrEditTask = (props) => {
// 发布/模拟挑战
const renderPubOrFight = () => {
const pubButton = isPublish
? (<Button
style={{ background: 'rgba(102,102,102,1)', border: 'none' }}
type="primary"
loading={publishLoading}
onClick={handleClickCancelPublish}
>撤销发布</Button>)
: (<Button
type="primary"
loading={publishLoading}
onClick={handleClickPublish}
>立即发布</Button>);
? (<Button
style={{ background: 'rgba(102,102,102,1)', border: 'none' }}
type="primary"
loading={publishLoading}
onClick={handleClickCancelPublish}
>撤销发布</Button>)
: (<Button
type="primary"
loading={publishLoading}
onClick={handleClickPublish}
>立即发布</Button>);
// 未发布: 模拟挑战 已发布: 开始挑战
const challengeBtn = isPublish ? (
<Button type="primary" onClick={startChallenge}>开始挑战</Button>
) : (
<Button type="primary" onClick={imitationChallenge}>模拟挑战</Button>
);
<Button type="primary" onClick={imitationChallenge}>模拟挑战</Button>
);
if (isPublish) {
return (
<React.Fragment>
{pubButton}
<Button
type="primary"
loading={submitLoading}
onClick={handleSubmitForm}
>保存</Button>
type="primary"
loading={submitLoading}
onClick={handleSubmitForm}
>保存</Button>
{challengeBtn}
</React.Fragment>
);
@ -208,10 +181,10 @@ const NewOrEditTask = (props) => {
return (
<React.Fragment>
<Button
type="primary"
loading={submitLoading}
onClick={handleSubmitForm}
>保存</Button>
type="primary"
loading={submitLoading}
onClick={handleSubmitForm}
>保存</Button>
{pubButton}
{challengeBtn}
</React.Fragment>
@ -233,9 +206,9 @@ const NewOrEditTask = (props) => {
return (
<div className={'new_add_task_wrap'}>
<div className={'task_header'}>
<UserInfo userInfo={userInfo}/>
<UserInfo userInfo={userInfo} />
<p className={'header_title'}>{props.name || ''}</p>
{ renderQuit() }
{renderQuit()}
</div>
<div className="split-pane-area">
<SplitPane className='outer-split-pane' split="vertical" minSize={350} maxSize={-350} defaultSize="40%">
@ -243,18 +216,17 @@ const NewOrEditTask = (props) => {
<LeftPane />
</div>
<SplitPane split="vertical" defaultSize="100%" allowResize={false}>
<RightPane onSubmitForm={handleSubmitForm}/>
<RightPane onSubmitForm={handleSubmitForm} />
<div />
</SplitPane>
</SplitPane>
</div>
{/* 控制台 */}
<div className='new_add_task_ctl'>
{
/* 录入时: 取消 保存 */
/* 保存未发布: 立即发布 模拟挑战 */
}
{ !identifier ? renderSaveOrCancel() : renderPubOrFight() }
{!identifier ? renderSaveOrCancel() : renderPubOrFight()}
</div>
</div>
)
@ -313,4 +285,4 @@ const mapDispatchToProps = (dispatch) => ({
export default withRouter(connect(
mapStateToProps,
mapDispatchToProps
)(CNotificationHOC() (NewOrEditTask)));
)(CNotificationHOC()(NewOrEditTask)));

@ -147,7 +147,7 @@ const AddTestDemo = (props) => {
return (
<Collapse className={'collapse_area'} activeKey={isOpen?'1':''} onChange={() => handleChangeCollapse()}>
<Panel header={`测试用例${props.index + 1}`} extra={genExtra()} key="1">
<Panel header={`测试用例${props.index + 1}`} extra={props.index===0?false:genExtra()} key="1">
<Form>
<FormItem
label={<span className={'label_text'}>输入</span>}

@ -20,27 +20,24 @@ import { toStore } from 'educoder'; // 保存和读取store值
import QuillForEditor from '../../../../../common/quillForEditor';
import KnowLedge from '../../../components/knowledge';
const scrollIntoView = require('scroll-into-view');
const {jcLabel} = CONST;
const { jcLabel } = CONST;
const FormItem = Form.Item;
const { Option } = Select;
const maps = {
language: [
{ title: (<span style={{ color: 'rgba(0, 0, 0, 0.35)' }}>请选择</span>), key: '' },
{ title: 'C', key: 'C' },
{ title: 'C++', key: 'C++' },
{ title: 'Python', key: 'Python' },
{ title: 'Java', key: 'Java' }
],
difficult: [
{ title: (<span style={{ color: 'rgba(0, 0, 0, 0.35)' }}>请选择</span>), key: '' },
{ title: '简单', key: '1' },
{ title: '中等', key: '2'},
{ title: '中等', key: '2' },
{ title: '困难', key: '3' }
],
category: [
{ title: (<span style={{ color: 'rgba(0, 0, 0, 0.35)' }}>请选择</span>), key: '' },
{ title: '程序设计', key: '1' },
{ title: '算法', key: '2'}
{ title: '算法', key: '2' }
],
openOrNot: [
{ title: '公开', key: '1' },
@ -49,7 +46,7 @@ const maps = {
}
class EditTab extends React.Component {
constructor (props) {
constructor(props) {
super(props);
// this.editorRef = React.createRef();
this.scrollRef = React.createRef();
@ -61,13 +58,13 @@ class EditTab extends React.Component {
top: 500,
bottom: 20,
offsetTop: 0,
showAdd: props.tag_discipline_id || false
showAdd: props.tag_discipline_id || false
// knowledges: [],
// coursers: [] // 选中的课程
}
}
componentDidMount () {
componentDidMount() {
const oWrap = document.getElementById('textCase');
const scrollHeight = oWrap.offsetHeight;
@ -85,13 +82,32 @@ class EditTab extends React.Component {
// this.props.getQuestion({
// source: 'question'
// });
const obj = { // 测试用例参数
input: '',
output: '',
position: 1,
isAdd: true // 新增的测试用例
}
const validateObj = { // 测试用例验证参数
input: {
validateStatus: '',
errMsg: ''
},
output: {
validateStatus: '',
errMsg: ''
}
}
// this.scrollRef.current.scrollTo(1000);
this.props.addTestCase({ testCase: obj, tcValidate: validateObj });
}
// componentDidUpdate (nextProp) {
// console.log(nextProp);
// }
componentWillUnmount (nextPro) {
componentWillUnmount(nextPro) {
this.state.scrollEl.removeEventListener('scroll', this.handleScroll, false);
}
@ -101,12 +117,12 @@ class EditTab extends React.Component {
const tOffsetTop = oTarget.offsetTop;
const tOffsetHeight = oTarget.offsetHeight;
const scrollTop = e.target.scrollTop;
const { scrollHeight, offsetTop} = this.state;
const { scrollHeight, offsetTop } = this.state;
// 滚动距离 + 元素的高度 大于 offsetTop值时 添加 fix_top 样式
// console.log(tOffsetTop, tOffsetHeight, scrollTop, scrollHeight, offsetTop);
if ((scrollTop + tOffsetHeight > tOffsetTop) && (tOffsetTop >= offsetTop)) {
oTarget.className = `test_demo_title fix_top`;
} else if ((scrollHeight + scrollTop < offsetTop) && (scrollHeight <= offsetTop)){
} else if ((scrollHeight + scrollTop < offsetTop) && (scrollHeight <= offsetTop)) {
oTarget.className = `test_demo_title`;
} else if ((tOffsetTop < offsetTop) && (tOffsetTop + tOffsetHeight + scrollTop) < offsetTop) {
oTarget.className = `test_demo_title`;
@ -169,9 +185,9 @@ class EditTab extends React.Component {
scrollIntoView(this.scrollRef.current);
}
render () {
render() {
const { showAdd } = this.state;
const {
ojForm,
ojFormValidate,
@ -224,19 +240,19 @@ class EditTab extends React.Component {
const renderTestCase = () => {
return this.props.testCases.map((item, i) => {
return <AddTestDemo
key={`${i}`}
isOpen={openTestCodeIndex.includes(i)}
onSubmitTest={handleSubmitTest}
onDeleteTest={handleDeleteTest}
testCase={item}
testCaseValidate={testCasesValidate[i]}
index={i}
/>
});
key={`${i}`}
isOpen={openTestCodeIndex.includes(i)}
onSubmitTest={handleSubmitTest}
onDeleteTest={handleDeleteTest}
testCase={item}
testCaseValidate={testCasesValidate[i]}
index={i}
/>
});
};
// 添加测试用例
const handleAddTest = () => {
const {position, testCases = []} = this.props;
const { position, testCases = [] } = this.props;
if (testCases.length >= 50) {
notification.warning({
message: '提示',
@ -262,7 +278,7 @@ class EditTab extends React.Component {
}
// this.scrollRef.current.scrollTo(1000);
addTestCase({testCase: obj, tcValidate: validateObj});
addTestCase({ testCase: obj, tcValidate: validateObj });
// TODO 点击新增时,需要滚到到最底部
this.scrollToBottom();
}
@ -281,12 +297,12 @@ class EditTab extends React.Component {
}
// 编辑器配置信息
const quillConfig = [
{ header: 1}, {header: 2},
{ header: 1 }, { header: 2 },
// {size: ['12px', '14px', '16px', '18px', '20px', false]},
'bold', 'italic', 'underline', 'strike', // 切换按钮
'blockquote', 'code-block', // 代码块
{align: []}, { 'list': 'ordered' }, { 'list': 'bullet' }, // 列表
{ 'script': 'sub'}, { 'script': 'super' },
{ align: [] }, { 'list': 'ordered' }, { 'list': 'bullet' }, // 列表
{ 'script': 'sub' }, { 'script': 'super' },
{ 'color': [] }, { 'background': [] }, // 字体颜色与背景色
// {font: []},
'image', 'formula', // 数学公式、图片、视频
@ -297,7 +313,7 @@ class EditTab extends React.Component {
const renderCourseQuestion = (arrs) => {
const tempArr = [];
const sub_id = this.props.ojForm.sub_discipline_id;
function loop (arrs, tempArr) {
function loop(arrs, tempArr) {
arrs.forEach(item => {
const obj = {};
obj.value = item.id;
@ -341,7 +357,7 @@ class EditTab extends React.Component {
}
// 知识点
const handleKnowledgeChange = (values= []) => {
const handleKnowledgeChange = (values = []) => {
const _result = [];
values.forEach(v => {
_result.push(v.id);
@ -355,11 +371,11 @@ class EditTab extends React.Component {
const handleAddKnowledge = (values) => {
// console.log('调用了新增知识点并返回了结果: ', values);
// 获取课程id
const {sub_discipline_id} = this.props.ojForm;
const obj = Object.assign({}, values, {sub_discipline_id})
const { sub_discipline_id } = this.props.ojForm;
const obj = Object.assign({}, values, { sub_discipline_id })
tagDisciplines(obj);
}
return (
<div className={'editor_area'} id="textCase">
<Form className={'editor_form'}>
@ -368,7 +384,7 @@ class EditTab extends React.Component {
label={<span>{myLabel(jcLabel['difficult'])}</span>}
validateStatus={ojFormValidate.difficult.validateStatus}
help={ojFormValidate.difficult.errMsg}
colon={ false }
colon={false}
>
<Select onChange={this.handleChangeDifficult} value={`${ojForm.difficult}`}>
{getOptions('difficult')}
@ -380,7 +396,7 @@ class EditTab extends React.Component {
label={<span>{myLabel(jcLabel['sub_discipline_id'], '合理的课程分类有利于快速检索')}</span>}
validateStatus={ojFormValidate.sub_discipline_id.validateStatus}
help={ojFormValidate.sub_discipline_id.errMsg}
colon={ false }
colon={false}
>
{/* <Select onChange={this.handleChangeCategory} value={`${ojForm.category}`}>
{getOptions('category')}
@ -390,11 +406,11 @@ class EditTab extends React.Component {
expandTrigger="hover"
onChange={this.handleChangeCategory}
/> */}
{ renderCourseQuestion(courseQuestions)}
{renderCourseQuestion(courseQuestions)}
</FormItem>
<FormItem
colon={ false }
colon={false}
className='input_area flex_100'
label={<span>{myLabel(jcLabel['knowledge'], '', 'nostar')}</span>}
>
@ -412,9 +428,9 @@ class EditTab extends React.Component {
label={<span>{myLabel(jcLabel['timeLimit'], '程序允许时间限制时长,单位:秒')}</span>}
validateStatus={ojFormValidate.timeLimit.validateStatus}
help={ojFormValidate.timeLimit.errMsg}
colon={ false }
colon={false}
>
<InputNumber value={ojForm.timeLimit} min={0} max={5} style={{ width: '100%' }} onChange={this.handleTimeLimitChange}/>
<InputNumber value={ojForm.timeLimit} min={0} max={5} style={{ width: '100%' }} onChange={this.handleTimeLimitChange} />
</FormItem>
<FormItem
@ -422,9 +438,9 @@ class EditTab extends React.Component {
label={<span>{myLabel(jcLabel['language'])}</span>}
validateStatus={ojFormValidate.language.validateStatus}
help={ojFormValidate.language.errMsg}
colon={ false }
colon={false}
>
<Select onChange={this.handleLanguageChange} value={`${ojForm.language}`}>
<Select onChange={this.handleLanguageChange} defaultValue={'C'} value={`${ojForm.language}`}>
{getOptions('language')}
</Select>
</FormItem>
@ -434,7 +450,7 @@ class EditTab extends React.Component {
label={<span>{myLabel(jcLabel['name'])}</span>}
validateStatus={ojFormValidate.name.validateStatus}
help={ojFormValidate.name.errMsg}
colon={ false }
colon={false}
>
<Input
maxLength={60}
@ -450,42 +466,30 @@ class EditTab extends React.Component {
label={<span>{myLabel(jcLabel['description'])}</span>}
validateStatus={ojFormValidate.description.validateStatus}
help={ojFormValidate.description.errMsg}
colon={ false }
colon={false}
>
<QuillForEditor
autoFocus={true}
style={{ height: '200px' }}
placeholder="请输入描述信息"
onContentChange={handleContentChange}
options={quillConfig}
value={ojForm.description}
/>
autoFocus={true}
style={{ height: '200px' }}
placeholder="请输入描述信息"
onContentChange={handleContentChange}
options={quillConfig}
value={ojForm.description}
/>
</FormItem>
{/* <FormItem
className={`input_area flex_50 flex_50_right`}
label={<span>{myLabel(jcLabel['openOrNot'], '社区:您的任务将向整个社会公开')}</span>}
validateStatus={ojFormValidate.openOrNot.validateStatus}
help={ojFormValidate.openOrNot.errMsg}
colon={ false }
>
<Select onChange={this.handleChangeOpenOrNot} value={`${ojForm.openOrNot}`}>
{getOptions('openOrNot')}
</Select>
</FormItem> */}
</Form>
{/* 添加测试用例 */}
<div className={'test_demo_title'} ref={this.headerRef}>
<h2>测试用例</h2>
<h3>测试用例</h3>
<Button type="primary" ghost onClick={handleAddTest}>添加测试用例</Button>
</div>
<div className="test_demo_ctx">
{ renderTestCase() }
{renderTestCase()}
</div>
<div style={ {float:"left", clear: "both", background: 'red' } } ref={this.scrollRef}></div>
<div style={{ float: "left", clear: "both", background: 'red' }} ref={this.scrollRef}></div>
</div>
)
}

@ -7,55 +7,25 @@
* @LastEditTime : 2019-12-27 19:33:50
*/
import './index.scss';
import React, { useState, useEffect } from 'react';
import React from 'react';
import { connect } from 'react-redux';
import MyMonacoEditor from '../../components/myMonacoEditor';
// import ControlSetting from '../../components/controlSetting';
import actions from '../../../../redux/actions';
function RightPane (props, ref) {
function RightPane(props) {
const { code, language = 'C', saveOjFormCode } = props;
const {
// identifier,
code,
showCode,
language,
// onSubmitForm,
saveOjFormCode
} = props;
// let timer = null;
// 代码改变时,保存
const handleCodeChange = (updateCode) => {
// if (props.identifier) {
// // 保存用户输入的代码
// if (!timer) {
// timer = setInterval(() => {
// clearInterval(timer);
// timer = null;
// }, 3000);
// }
// }
saveOjFormCode(updateCode);
}
// 启动调试代码
// const handleDebuggerCode = (value) => {
// console.log('调用的代码调试====', value);
// }
return (
<div className={'right_pane_code_wrap'}>
<MyMonacoEditor
language={language}
code={showCode}
onCodeChange={handleCodeChange}/>
{/* <ControlSetting
// identifier={identifier}
inputValue={props.input}
onSubmitForm={onSubmitForm}
// onDebuggerCode={handleDebuggerCode}
/> */}
<MyMonacoEditor
language={language}
code={code}
onCodeChange={handleCodeChange} />
</div>
)
}

@ -112,7 +112,7 @@ function RecordDetail (props) {
<span className="status_label pass_case" style={{ display: [-1, 0, 2, 5].includes(detail.status) ? 'inline-block' : 'none'}}>
<span className="status_label_sub">{detail.pass_sets_count}</span>
<span className="pass_case_span"> / {detail.set_count}</span>
个通过测试用例
个通过测试用例
</span>
</div>
<div className="result_error_area">
@ -134,9 +134,9 @@ function RecordDetail (props) {
<MonacoEditor
height="100%"
width="100%"
className="code_area_Style"
language={(detail.language && detail.language.toLowerCase()) || ''}
value={detail.code || ''}
theme="dark"
readOnly={true}
/>
</div>

@ -1,5 +1,19 @@
@import '../split_pane_resizer.scss';
.result_code_area .monaco-editor, .monaco-editor-background, .monaco-editor .inputarea.ime-input{
background-color: #f9f9f9!important;
}
.result_code_area .monaco-editor .line-numbers{
color: #999!important;
}
.result_code_area .monaco-editor .current-line ~ .line-numbers {
color: #0b216f!important;
}
.result_code_area .minimap-decorations-layer{
background: rgba(225,225,225,0.2)!important;
}
.result_code_area .monaco-editor .margin{
background-color: #eee!important;
}
.record_detail_area{
background: #fff;
.record_detail_ctx{

@ -6,22 +6,19 @@
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 14:23:43
*/
import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux';
import React, { useState } from 'react';
import { connect } from 'react-redux';
import MyMonacoEditor from '../../components/myMonacoEditor';
import ControlSetting from '../../components/controlSetting';
import actions from '../../../../redux/actions';
// import QuillForEditor from '../../../../common/quillForEditor';
// import TextArea from 'antd/lib/input/TextArea';
import { Input, Form, Button } from 'antd';
// import FormItem from 'antd/lib/form/FormItem';
const { TextArea } = Input;
const FormItem = Form.Item;
const RightPane = (props) => {
const {
identifier,
submitInput,
identifier,
submitInput,
submitUserCode,
input,
hack,
@ -33,54 +30,34 @@ const RightPane = (props) => {
updateNotice,
saveUserInputCode,
restoreInitialCode,
// saveOpacityType,
saveUserCodeForInterval,
addNotes,
changeLoadingState
} = props;
// const [editorCode, setEditorCode] = useState(editor_code || hack.code);
const [noteClazz, setNoteClazz] = useState('editor_nodte_area');
const [noteCount] = useState(5000);
// const [code, setCode] = useState(editor_code || hack.code);
// let initFlag = true;
// useEffect(() => {
// if (editor_code) {
// setEditorCode(editor_code);
// } else {
// setEditorCode(hack.code);
// }
// }, [hack, editor_code]);
const handleSubmitForm = () => {
// 提交时, 先调用提交接口,提交成功后,循环调用测评接口
// saveOpacityType('submit');
submitUserCode(identifier, submitInput, 'submit');
// // 提交时,先调用评测接口, 评测通过后才调用保存接口
// updateCode(identifier, submitInput, 'submit');
}
let timer = null; // 定时器
// 代码块内容变化时
const handleCodeChange = (value) => {
// console.log('编辑器代码 ======》》》》》》》》》++++++++++', value);
saveUserInputCode(value);
// setEditorCode(value);
if (!timer) {
timer = setInterval(function () {
clearInterval(timer);
timer = null;
saveUserCodeForInterval(identifier);
}, 3000);
}, 10000);
}
}
// 代码调试
const handleDebuggerCode = (value) => {
// 调用保存代码块接口,成功后,调用调试接口
// saveOpacityType('debug');
updateCode(identifier, value, 'debug');
}
// 恢复初始代码
@ -101,7 +78,7 @@ const RightPane = (props) => {
props.form.resetFields();
setNoteClazz('editor_nodte_area');
}
const handleSubmitNote = () => {
props.form.validateFields((err, values) => {
if (!err) {
@ -113,7 +90,6 @@ const RightPane = (props) => {
}
});
}
const { getFieldDecorator } = props.form;
return (
<div className={'right_pane_code_wrap'}>
@ -121,7 +97,7 @@ const RightPane = (props) => {
<MyMonacoEditor
notice={notice}
identifier={identifier}
language={hack.language}
language={hack.language}
code={editor_code || hack.code}
hadCodeUpdate={hadCodeUpdate}
onCodeChange={handleCodeChange}
@ -129,11 +105,11 @@ const RightPane = (props) => {
onRestoreInitialCode={handleRestoreInitialCode}
/>
<span
<span
className="iconfont icon-biji student_notes"
onClick={handleClickNote}
></span>
{/* <div className="student_notes">
<TextArea rows={5} />
</div> */}
@ -141,7 +117,7 @@ const RightPane = (props) => {
<Form>
<FormItem>
{
getFieldDecorator('notes',{
getFieldDecorator('notes', {
rules: [
{ required: true, message: '笔记不能为空' },
{ max: noteCount, message: `笔记最大字数为${noteCount}` }
@ -153,7 +129,7 @@ const RightPane = (props) => {
rows="5"
/>)
}
</FormItem>
<FormItem style={{ textAlign: 'right' }}>
<Button loading={loading} style={{ marginRight: '10px' }} onClick={handleCancelNote}>取消</Button>
@ -161,12 +137,12 @@ const RightPane = (props) => {
</FormItem>
</Form>
</div>
<ControlSetting
<ControlSetting
identifier={identifier}
inputValue={input}
onDebuggerCode={handleDebuggerCode}
onSubmitForm={handleSubmitForm}/>
onSubmitForm={handleSubmitForm} />
</div>
);
}
@ -174,10 +150,10 @@ const RightPane = (props) => {
const mapStateToProps = (state) => {
const {
user_program_identifier,
hack,
userTestInput,
editor_code,
user_program_identifier,
hack,
userTestInput,
editor_code,
notice,
hadCodeUpdate
} = state.ojForUserReducer;
@ -192,7 +168,7 @@ const mapStateToProps = (state) => {
hadCodeUpdate,
editor_code,
input: userTestInput,
submitInput: hack.input,
submitInput: hack.input,
identifier: user_program_identifier
};
}

@ -21,6 +21,7 @@ import NoneData from './component/NoneData';
import './questioncss/questioncom.css';
import Bottomsubmit from "../modals/Bottomsubmit";
import QuestionModalys from "./component/QuestionModalys";
import Listjihe from "./component/Listjihe";
//exam_id 试卷的id
var Undoclickable=true;
@ -264,12 +265,6 @@ class NewMyShixunModel extends Component {
}
this.callback(defaultActiveKeys);
}
if(prevProps.Contentdata !== this.props.Contentdata){
this.setState({
Contentdata:this.props.Contentdata,
})
}
}
//公共和我的
@ -721,33 +716,33 @@ class NewMyShixunModel extends Component {
getbasket_listdata = () => {
// 获取试题篮展开的数据
// const url = "/item_baskets/basket_list.json";
// axios.get(url)
// .then((result) => {
// // ////console.log("getbasket_listdata");
// // ////console.log(result.data);
// this.setState({
// completion_questions_count: result.data.completion_questions_count,
// judgement_questions_count: result.data.judgement_questions_count,
// multiple_questions_count: result.data.multiple_questions_count,
// practical_questions_count: result.data.practical_questions_count,
// program_questions_count: result.data.program_questions_count,
// single_questions_count: result.data.single_questions_count,
// subjective_questions_count: result.data.subjective_questions_count,
// })
//
// }).catch((error) => {
// // ////console.log(error);
// this.setState({
// completion_questions_count: 0,
// judgement_questions_count: 0,
// multiple_questions_count: 0,
// practical_questions_count: 0,
// program_questions_count: 0,
// single_questions_count: 0,
// subjective_questions_count: 0,
// })
// })
const url = "/item_baskets/basket_list.json";
axios.get(url)
.then((result) => {
// ////console.log("getbasket_listdata");
// ////console.log(result.data);
this.setState({
completion_questions_count: result.data.completion_questions_count,
judgement_questions_count: result.data.judgement_questions_count,
multiple_questions_count: result.data.multiple_questions_count,
practical_questions_count: result.data.practical_questions_count,
program_questions_count: result.data.program_questions_count,
single_questions_count: result.data.single_questions_count,
subjective_questions_count: result.data.subjective_questions_count,
})
}).catch((error) => {
// ////console.log(error);
this.setState({
completion_questions_count: 0,
judgement_questions_count: 0,
multiple_questions_count: 0,
practical_questions_count: 0,
program_questions_count: 0,
single_questions_count: 0,
subjective_questions_count: 0,
})
})
}
@ -1030,7 +1025,9 @@ class NewMyShixunModel extends Component {
+ subjective_questions_count;
// console.log("弹出框");
// console.log(Contentdata)
// console.log(Datacount)
// console.log(Contentdata)
return (
<div className="newMain clearfix " ref={this.saveContainer}>
@ -1103,6 +1100,8 @@ class NewMyShixunModel extends Component {
Contentdata={Contentdata}
exam_id={this.props.exam_id}
Isitapopup={"true"}
Datacount={Datacount}
Datacountbool={true}
chakanjiexiboolindex={this.state.chakanjiexiboolindex}
chakanjiexibool={(e)=>this.chakanjiexibool(e)}
getitem_basketss={(id)=>this.getitem_basketss(id)}

@ -788,12 +788,37 @@ class Question extends Component {
}
//全选试题库
selectallquestionsonthispage=(bool)=>{
if(bool===true){
//bool 是选中状态
let {
completion_questions_count, judgement_questions_count, multiple_questions_count, practical_questions_count,
program_questions_count, single_questions_count, subjective_questions_count,
} = this.state;
const Datacount = completion_questions_count + judgement_questions_count
+ multiple_questions_count + practical_questions_count
+ program_questions_count
+ single_questions_count
+ subjective_questions_count;
if(Datacount===100){
this.props.showNotification(`已选100个试题不能在选用更多试题`);
return;
}
}
if(myGrandtotal===true){
this.props.showNotification(`本页全部试题未发布,不能选择`);
return
}
var item_idsdata=[];
var arr= this.state.Contentdata.items;
@ -1083,6 +1108,8 @@ class Question extends Component {
<Contentpart {...this.state} {...this.props}
pages={this.state.page}
Isitapopup={"false"}
Datacount={Datacount}
Datacountbool={true}
chakanjiexiboolindex={this.state.chakanjiexiboolindex}
chakanjiexibool={(e)=>this.chakanjiexibool(e)}
getitem_basketss={(id)=>this.getitem_basketss(id)}

@ -143,7 +143,7 @@ class ChoquesEditor extends Component{
}
}
if(!answerArray || answerArray.length == 0) {
this.props.showNotification('请先点击选择本选择题的正确选项');
this.props.showNotification('请设置本题的正确答案点击选项A/B...即可完成设置');
return editordata;
}
if(!answerArray || answerArray.length < 2) {

@ -369,18 +369,16 @@ class Contentpart extends Component {
</style>
<div className="xaxisreverseorder">
{
defaultActiveKey===0||defaultActiveKey==="0"?
isysladmins===true||is_teacher===true?
this.props.Isitapopup&&this.props.Isitapopup==="true"?
""
:
<a onClick={(e)=>this.xinzenw(e)}>
<div className="newbutoon">
<p className="newbutoontes" >新增</p>
</div>
</a>
:""
:""
isysladmins===true||is_teacher===true?
this.props.Isitapopup&&this.props.Isitapopup==="true"?
""
:
<a onClick={(e)=>this.xinzenw(e)}>
<div className="newbutoon">
<p className="newbutoontes" >新增</p>
</div>
</a>
:""
}
{item_type==="PROGRAM"?
@ -400,33 +398,24 @@ class Contentpart extends Component {
{
defaultActiveKey===0||defaultActiveKey==="0"?
this.props.Isitapopup&&this.props.Isitapopup==="true"?
<Search
style={isysladmins===true||is_teacher===true?{ marginRight:"0px"}:{marginRight:"0px"}}
className={"xaxisreverseorder searchwidth"}
placeholder="请输入题目名称、内容"
enterButton
size="large"
onInput={(e)=>this.props.setdatafunsval(e)}
onSearch={ (value)=>this.props.setdatafuns(value)} />
:
<Search
style={isysladmins===true||is_teacher===true?{ marginRight:"30px"}:{marginRight:"0px"}}
className={"xaxisreverseorder searchwidth"}
placeholder="请输入题目名称、内容"
enterButton
size="large"
onInput={(e)=>this.props.setdatafunsval(e)}
onSearch={ (value)=>this.props.setdatafuns(value)} />
:
<Search
className={"xaxisreverseorder searchwidth"}
placeholder="请输入题目名称、内容"
enterButton
size="large"
onInput={(e)=>this.props.setdatafunsval(e)}
onSearch={ (value)=>this.props.setdatafuns(value)} />
this.props.Isitapopup&&this.props.Isitapopup==="true"?
<Search
style={isysladmins===true||is_teacher===true?{ marginRight:"0px"}:{marginRight:"0px"}}
className={"xaxisreverseorder searchwidth"}
placeholder="请输入题目名称、内容"
enterButton
size="large"
onInput={(e)=>this.props.setdatafunsval(e)}
onSearch={ (value)=>this.props.setdatafuns(value)} />
:
<Search
style={isysladmins===true||is_teacher===true?{ marginRight:"30px"}:{marginRight:"0px"}}
className={"xaxisreverseorder searchwidth"}
placeholder="请输入题目名称、内容"
enterButton
size="large"
onInput={(e)=>this.props.setdatafunsval(e)}
onSearch={ (value)=>this.props.setdatafuns(value)} />
}
</div>
@ -466,6 +455,8 @@ class Contentpart extends Component {
: this.props.Contentdata.items.map((object, index) => {
return (
<Listjihe {...this.state} {...this.props}
Datacountbool={this.props.Datacountbool}
Datacount={this.props.Datacount}
Isitapopup={this.props.Isitapopup}
chakanjiexiboolindex={this.props.chakanjiexiboolindex}
chakanjiexibool={(keindex)=>this.chakanjiexibool(keindex)}

@ -97,6 +97,19 @@ class Listjihe extends Component {
}
//选用
Selectingpracticaltraining = (id) => {
try {
if(this.props.Datacountbool){
if(this.props.Datacount===100){
this.props.showNotification(`已选100个试题不能在选用更多试题`);
return;
}
}
}catch (e) {
}
let data = {}
if (this.props.exam_id === undefined) {
data = {

@ -156,7 +156,7 @@ class SingleEditor extends Component{
}
if(!answerArray || answerArray.length == 0) {
this.props.showNotification('请先点击选择本选择题的正确选项');
this.props.showNotification('请设置本题的正确答案点击选项A/B...即可完成设置');
return editordata;
}

@ -25,11 +25,10 @@ import { notification } from "antd";
// 进入编程页面时,首先调用开启编程题接口
export const startProgramQuestion = (id, props) => {
return (dispatch, getState) => {
const {searchParams} = getState().ojFormReducer;
fetchStartProgram(id).then(res => {
const { status, data } = res;
if (status === 200) {
const {identifier} = data;
const { identifier } = data;
dispatch({
type: types.SAVE_USER_PROGRAM_ID,
payload: identifier
@ -41,13 +40,6 @@ export const startProgramQuestion = (id, props) => {
});
// 跳转至开启编程
if (identifier) {
// let data = Object.assign({}, props);
// const path = {
// pathname: `/myproblems/${identifier}`,
// state: data
// }
// console.log(path);
// props.history.push(`/myproblems/${identifier}`);
props.history.push({
pathname: `/myproblems/${identifier}`,
});
@ -115,24 +107,18 @@ export const saveUserCodeForInterval = (identifier, code) => {
type: types.AUTO_UPDATE_CODE,
payload: true
});
// console.log('+++', userCode);
fetchUpdateCode(identifier, {
code: Base64.encode(userCode)
}).then(res => {
if (res.data.status === 401) {
return;
};
// dispatch({
// type: types.RESTORE_INITIAL_CODE,
// payload: userCode
// });
setTimeout(() => {
dispatch({
type: types.AUTO_UPDATE_CODE,
payload: false
})
}, 1000);
// console.log('代码保存成功', res);
}).catch(() => {
dispatch({
type: types.AUTO_UPDATE_CODE,
@ -190,7 +176,7 @@ export const codeEvaluate = (dispatch, identifier, type, time_limit, hackStatus,
* @param {*} count 执行次数
* @param {*} timer 定时器
*/
function getCodeSubmit (intervalTime, finalTime, count, timer){
function getCodeSubmit(intervalTime, finalTime, count, timer) {
const excuteTime = (count++) * intervalTime; // 当前执行时间
fetchCodeSubmit(identifier, { mode: type }).then(res => {
const { status } = res.data; // 评测返回结果
@ -290,7 +276,7 @@ export const codeEvaluate = (dispatch, identifier, type, time_limit, hackStatus,
* @param {*} inputValue 输入值: 自定义 | 系统返回的
* @param {*} type 测评类型 debug | submit
*/
export const debuggerCode = (identifier,value, type) => {
export const debuggerCode = (identifier, value, type) => {
return (dispatch, getState) => {
// 调用之前 先保存 code
// TODO
@ -337,19 +323,26 @@ export const debuggerCode = (identifier,value, type) => {
// 获取提交记录
export const getUserCommitRecord = (identifier) => {
return (dispatch, getState) => {
const { pages: { limit, page } } = getState().ojForUserReducer;
fetchUserCommitRecord(identifier, {
limit,
page
}).then(res => {
const {status, data} = res;
if (status === 200) {
dispatch({
type: types.COMMIT_RECORD,
payload: data
})
}
});
try {
const { pages: { limit, page } } = getState().ojForUserReducer;
fetchUserCommitRecord(identifier, {
limit,
page
}).then(res => {
if (res) {
const { status, data } = res;
if (status === 200) {
dispatch({
type: types.COMMIT_RECORD,
payload: data
})
}
}
})
} catch (error) {
console.log(error, '-------')
}
;
}
}
// 获取提交记录详情
@ -401,11 +394,10 @@ export const changeUserCodeTab = (key) => {
*/
export const submitUserCode = (identifier, inputValue, type) => {
return (dispatch, getState) => {
const { userCode, isUpdateCode, hack} = getState().ojForUserReducer;
const { userCode, isUpdateCode, hack } = getState().ojForUserReducer;
function userCodeSubmit () {
function userCodeSubmit() {
fetchUserCodeSubmit(identifier).then(res => {
// console.log('用户提交代码成功======》》》》》', res);
if (res.status === 200) {
if (res.data.status === 401) {
dispatch({
@ -415,7 +407,6 @@ export const submitUserCode = (identifier, inputValue, type) => {
return;
};
// 测评
console.log('hack=====', hack);
codeEvaluate(dispatch, identifier, type, hack.time_limit, hack.status, hack.score, hack.passed);
}
}).catch(() => {
@ -427,10 +418,9 @@ export const submitUserCode = (identifier, inputValue, type) => {
}
if (isUpdateCode) {
fetchUpdateCode(identifier, {
code: userCode
code: Base64.encode(userCode)
}).then(res => {
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现
// TODO 需要优化
if (res.data.status === 401) {
dispatch({
type: types.SUBMIT_LOADING_STATUS,
@ -460,8 +450,7 @@ export const restoreInitialCode = (identifier, msg) => {
return (dispatch) => {
fetchRestoreInitialCode(identifier).then(res => {
if (res.data.status === 401) return;
// console.log('恢复初始代码====》》》》', res);
const {status, data} = res;
const { status, data } = res;
if (status === 200) {
dispatch({
type: types.RESTORE_INITIAL_CODE,
@ -515,7 +504,6 @@ export const changeRecordPagination = (page) => {
export const addNotes = (identifier, params, cb) => {
return (dispatch) => {
fetchAddNotes(identifier, params).then(res => {
// console.log('添加笔记成功===>>', res);
dispatch({
type: types.LOADING_STATUS,
payload: false

@ -12,9 +12,9 @@ import types from '../actions/actionTypes';
const init = {
ojForm: {
name: '', // 任务名称
language: '',
language: 'C',
description: '',
difficult: '',
difficult: '1',
sub_discipline_id: '', // 方向
// category: '',
// openOrNot: 1,
@ -114,7 +114,7 @@ const ojFormReducer = (state = initialState, action) => {
};
}
switch (action.type) {
case types.VALIDATE_OJ_FORM:
case types.VALIDATE_OJ_FORM:
// 验证成功后,调用后台接口
return returnState(state, ojForm, ojFormValidate);
case types.SAVE_OJ_FORM_CODE:
@ -278,7 +278,7 @@ const ojFormReducer = (state = initialState, action) => {
// 更新验证消息
const curIOjTestValidate = state.testCasesValidate.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, {input});
return Object.assign({}, tc, { input });
}
return tc;
});
@ -294,20 +294,20 @@ const ojFormReducer = (state = initialState, action) => {
testCases: [...curITestValues]
}
case types.TEST_CASE_OUTPUT_CHANGE:
const { output } = action.payload;
// 更新验证消息
const curOOjTestValidate = state.testCasesValidate.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, {output});
}
return tc;
});
let curOTestValues = state.testCases.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, { output: action.payload.value })
}
return tc;
});
const { output } = action.payload;
// 更新验证消息
const curOOjTestValidate = state.testCasesValidate.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, { output });
}
return tc;
});
let curOTestValues = state.testCases.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, { output: action.payload.value })
}
return tc;
});
return {
...state,
testCasesValidate: [...curOOjTestValidate],
@ -355,7 +355,7 @@ const ojFormReducer = (state = initialState, action) => {
console.log(_p.tag_discipline_id);
return {
...state,
ojForm: Object.assign({}, state.ojForm, {difficult: _p.difficult, sub_discipline_id: _p.sub_discipline_id}),
ojForm: Object.assign({}, state.ojForm, { difficult: _p.difficult, sub_discipline_id: _p.sub_discipline_id }),
tag_discipline_id: _p.tag_discipline_id || []
}
case types.SET_SEARCH_PARAMS:

Loading…
Cancel
Save