This commit is contained in:
parent
80f23b27ec
commit
b41e37f2eb
|
|
@ -22,6 +22,7 @@ export default ({ identifier, onUpdateCostTime, status, defaultTime = 0,type })
|
|||
lastV.current = defaultTime
|
||||
setCostTime(defaultTime)
|
||||
//已经评测完成的不需要再计时
|
||||
|
||||
if (status !== 2) {
|
||||
let timeHandler = function () {
|
||||
setCostTime(costTime => costTime + 1)
|
||||
|
|
@ -36,7 +37,20 @@ export default ({ identifier, onUpdateCostTime, status, defaultTime = 0,type })
|
|||
return () => {
|
||||
clearInterval(tid)
|
||||
unSub()
|
||||
|
||||
|
||||
if(type===1){
|
||||
let bodys = {
|
||||
answer_long_time: lastV.current*1000,
|
||||
};
|
||||
let headers = {
|
||||
type: 'application/json',
|
||||
};
|
||||
let blob = new Blob([JSON.stringify(bodys)], headers);
|
||||
window.navigator.sendBeacon(
|
||||
`https://test-data.educoder.net/api/myproblems/${identifier}/save_long_time.json?answer_long_time=${lastV.current*1000}`,
|
||||
blob,
|
||||
);
|
||||
mediator.publish('reset-game')
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import React, { useState, useEffect, useRef, useCallback, Fragment } from 'react'
|
||||
import Editor from './ace-editor'
|
||||
import Modal from '../../../components/modal'
|
||||
import Modals from '../../../components/modal'
|
||||
import FooterBar from './footer-bar'
|
||||
import TestCaseList from './test-case-list'
|
||||
import './index.less'
|
||||
import { fetchWxCode, UpdateHackWxCode, restoreWxHackCode, fetchWxHackCodeGameBuild, sumbitCode, updateCostTime } from '../../../util/rest-api'
|
||||
import { fetchWxCode, UpdateHackWxCode, restoreWxHackCode, fetchWxHackCodeGameBuild, sumbitCode, updateCostTimes } from '../../../util/rest-api'
|
||||
import { useHistory, Route, Switch, useRouteMatch,useParams } from 'react-router-dom'
|
||||
import { Toast } from 'antd-mobile'
|
||||
import TestResultDialog from './test-result-dialog'
|
||||
|
|
@ -62,6 +62,8 @@ export default ({ source, taskId,callback }) => {
|
|||
const [isShowTest, setIsShowTest] = useState(false)
|
||||
const [isShowResult, setIsShowResult] = useState(false)
|
||||
const [language,setlanguage]=useState()
|
||||
const [isshow,setisshow]=useState(false);
|
||||
const [datas,setdatas]=useState();
|
||||
const [opacity, setOpacity] = useState(1)
|
||||
const [code, setCode] = useState({
|
||||
content: {
|
||||
|
|
@ -122,7 +124,9 @@ export default ({ source, taskId,callback }) => {
|
|||
fetchWxHackCodeGameBuilds()
|
||||
}, 1000);
|
||||
}else{
|
||||
Toast.show(ExecuteDict[rs?.data?.data?.status])
|
||||
setdatas(rs?.data?.data);
|
||||
// Toast.show(ExecuteDict[rs?.data?.data?.status])
|
||||
setisshow(true);
|
||||
setTimeout(() => {
|
||||
Toast.hide()
|
||||
}, 3000);
|
||||
|
|
@ -141,7 +145,6 @@ export default ({ source, taskId,callback }) => {
|
|||
}
|
||||
|
||||
async function onReset() {
|
||||
debugger
|
||||
if (taskId) {
|
||||
const response = await restoreWxHackCode(taskId,{})
|
||||
const { data } = response
|
||||
|
|
@ -165,9 +168,9 @@ export default ({ source, taskId,callback }) => {
|
|||
lastedValue.current = window.decodeURIComponent(
|
||||
escape(window.atob(hack?.code)))
|
||||
setEditValue(lastedValue.current)
|
||||
|
||||
}
|
||||
if (taskId) {
|
||||
|
||||
init()
|
||||
}
|
||||
}, [hack.code])
|
||||
|
|
@ -181,6 +184,10 @@ export default ({ source, taskId,callback }) => {
|
|||
setOpacity(routeMatch.isExact ? 1 : 0)
|
||||
}, [routeMatch.isExact])
|
||||
|
||||
useEffect(()=>{
|
||||
// mediator.publish('update-cost-time')
|
||||
},[])
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
document.body.addEventListener('focusout', scrollT)
|
||||
|
|
@ -198,9 +205,9 @@ export default ({ source, taskId,callback }) => {
|
|||
}
|
||||
const timePanelOpt = {
|
||||
identifier: taskId,
|
||||
// onUpdateCostTime: updateCostTime,
|
||||
onUpdateCostTime: updateCostTimes,
|
||||
type:1,
|
||||
defaultTime: hack.answer_long_time,
|
||||
defaultTime: hack.answer_long_time/1000,
|
||||
status: hack.status
|
||||
}
|
||||
|
||||
|
|
@ -254,14 +261,14 @@ export default ({ source, taskId,callback }) => {
|
|||
<TimerPanel {...timePanelOpt} />
|
||||
</FooterBar>
|
||||
</div>
|
||||
<Modal>
|
||||
{isShowTest ? <TestCaseList {...testCaseListProperty} /> : null}
|
||||
<Modals>
|
||||
{isshow ? <TestCaseList datas={datas} onClose={()=>{setisshow(false)}}/> : null}
|
||||
{isShowPath ? <PathTree paths={paths} onChangePath={onChangePath} activePath={path} /> : null}
|
||||
{isShowResult ? <TestResultDialog {...goldRef.current} onViewResult={onShowTestCase} onCloseResult={onCloseResult} onNext={onNext} /> : null}
|
||||
<Switch>
|
||||
<Route path='/educodermd/:identifier/:educoder_session/:autologin_trustie/code/picture' component={PicturePanel} />
|
||||
</Switch>
|
||||
</Modal>
|
||||
</Modals>
|
||||
</Fragment>
|
||||
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,18 @@ import markUrl from './mark.svg'
|
|||
import successUrl from '../test-case-item/success.svg'
|
||||
import './index.less'
|
||||
import RenderHtml from '../../../../components/render-html'
|
||||
import { Base64 } from 'js-base64'
|
||||
|
||||
const ExecuteDict = {
|
||||
[-1]: '测试用例结果不匹配',
|
||||
[0]: '调试通过',
|
||||
2: '调试超时',
|
||||
3: '调试pod失败',
|
||||
4: '编译失败',
|
||||
5: '执行失败'
|
||||
}
|
||||
|
||||
export default ({ test_sets = [], test_sets_count, sets_error_count, last_compile_output, onClose }) => {
|
||||
export default ({ onClose,datas }) => {
|
||||
const [index, setIndex] = useState(-1)
|
||||
|
||||
function trigger(id) {
|
||||
|
|
@ -17,10 +26,37 @@ export default ({ test_sets = [], test_sets_count, sets_error_count, last_compil
|
|||
<div className="test-case-wrapper">
|
||||
<div className="test-case-body">
|
||||
<div className="test-header">
|
||||
<span>共{test_sets.length}个测试用例</span>
|
||||
<span>执行结果:<span style={{color:'red'}}>{ExecuteDict[datas.status]}</span></span>
|
||||
<a onClick={onClose} >关闭</a>
|
||||
</div>
|
||||
{last_compile_output ?
|
||||
<div style={{marginLeft:10,marginTop:10,color:'#637da6',fontSize:16,fontWeight:500}}>
|
||||
实际输入:
|
||||
<div style={{border:"1px solid",minHeight:100,marginTop:10}}>
|
||||
{datas.input}
|
||||
{/* <RenderHtml value={last_compile_output} /> */}
|
||||
</div>
|
||||
</div>
|
||||
<div style={{marginLeft:10,marginTop:10,color:'#637da6',fontSize:16,fontWeight:500}}>
|
||||
实际输出:
|
||||
<div style={{border:"1px solid",minHeight:100,marginTop:10}}>
|
||||
{/* {
|
||||
(datas.status === 4 || datas.status === 5) && */}
|
||||
{Base64.decode(datas?.error_msg)}
|
||||
{/* // } */}
|
||||
{/* <RenderHtml value={last_compile_output} /> */}
|
||||
</div>
|
||||
</div>
|
||||
<div style={{marginLeft:10,marginTop:10,color:'#637da6',fontSize:16,fontWeight:500}}>
|
||||
预期输出:
|
||||
<div style={{border:"1px solid",minHeight:100,marginTop:10}}>
|
||||
{/* {
|
||||
(datas.status === 4 || datas.status === 5) && */}
|
||||
{Base64.decode(datas?.expected_output)}
|
||||
{/* // } */}
|
||||
{/* <RenderHtml value={last_compile_output} /> */}
|
||||
</div>
|
||||
</div>
|
||||
{/* {last_compile_output ?
|
||||
<div className={`test-result ${sets_error_count === 0 ? "success" : "failer"}`}>
|
||||
<span className='count'>
|
||||
<img width={15} src={sets_error_count === 0 ? successUrl : markUrl} />
|
||||
|
|
@ -28,10 +64,10 @@ export default ({ test_sets = [], test_sets_count, sets_error_count, last_compil
|
|||
</span>
|
||||
{sets_error_count == 0 ? <span>全部通过</span> : <RenderHtml value={last_compile_output} />}
|
||||
</div> : null
|
||||
}
|
||||
<ul className="test-case-list">
|
||||
} */}
|
||||
{/* <ul className="test-case-list">
|
||||
{test_sets.map((item, i) => <TestCaseItem key={'item' + i} last_compile_output={last_compile_output} title={`测试集${i + 1}`} {...item} isActive={index === i} id={i} onActive={trigger} />)}
|
||||
</ul>
|
||||
</ul> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -84,6 +84,11 @@ export function updateCostTime(identifier, params) {
|
|||
return axios.post(url, params);
|
||||
}
|
||||
|
||||
export function updateCostTimes(identifier, params) {
|
||||
const url = `/api/myproblems/${identifier}/save_long_time.json`;
|
||||
return axios.post(url, params);
|
||||
}
|
||||
|
||||
//获取公告详情信息
|
||||
export function getNoticeDetail(identifier, params) {
|
||||
const url = `/courses/${identifier}/inform_detail.json`;
|
||||
|
|
|
|||
Loading…
Reference in New Issue