caishi 5 years ago
commit 56e4f483f9

@ -23,22 +23,31 @@ export function SnackbarHOC(options = {}) {
} }
// 全局的snackbar this.props.showSnackbar调用即可 // 全局的snackbar this.props.showSnackbar调用即可
showSnackbar(description, message = "提示",icon) { // showSnackbar(description, message = "提示",icon) {
// this.setState({ // // this.setState({
// snackbarOpen: true, // // snackbarOpen: true,
// snackbarText: text, // // snackbarText: text,
// snackbarVertical: vertical, // // snackbarVertical: vertical,
// snackbarHorizontal: horizontal, // // snackbarHorizontal: horizontal,
// }) // // })
const data = { // const data = {
message, // message,
description // description
} // }
if (icon) { // if (icon) {
data.icon = icon; // data.icon = icon;
// }
// notification.open(data);
// }
showSnackbar(text, vertical, horizontal) {
this.setState({
snackbarOpen: true,
snackbarText: text,
snackbarVertical: vertical,
snackbarHorizontal: horizontal,
})
} }
notification.open(data);
}
render() { render() {
const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical } = this.state; const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical } = this.state;

@ -54,6 +54,8 @@ const testSetsExpandedArrayInitVal = [false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false,
false, false, false, false, false] false, false, false, false, false]
window.__fetchAllFlag = false; // 是否调用过fetchAll TODO 如何多次使用provider window.__fetchAllFlag = false; // 是否调用过fetchAll TODO 如何多次使用provider
const $ = window.$
class TPIContextProvider extends Component { class TPIContextProvider extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
@ -592,13 +594,49 @@ pop_box_new(htmlvalue, 480, 182);
currentPassedGameGainExperience: experience, currentPassedGameGainExperience: experience,
}) })
} }
initDisplayInterval = () => {
const challenge = this.state.challenge
if (this.showWebDisplayButtonTimeout) {
window.clearTimeout(this.showWebDisplayButtonTimeout)
}
this.showWebDisplayButtonTimeout = window.setTimeout(() => {
this.setState({ challenge: update(challenge,
{
showWebDisplayButton: { $set: false },
})
})
this.showWebDisplayButtonTimeout = null
}, 61 * 1000)
let remain = 60
if (this.displayInterval) {
window.clearInterval(this.displayInterval)
}
this.displayInterval = window.setInterval(() => {
const button = $('#showWebDisplayButton');
if (button.length) {
button.html(`查看效果(${remain})`)
if (remain == 0) {
button.html('查看效果')
}
}
if (remain == 0) {
window.clearInterval(this.displayInterval)
this.displayInterval = null
return;
}
remain -= 1;
}, 1000)
}
language_display(data) { language_display(data) {
const { game, tomcat_url } = this.state; const { game, tomcat_url } = this.state;
const $ = window.$;
const challenge = Object.assign({}, this.state.challenge) const challenge = Object.assign({}, this.state.challenge)
if(challenge.isWeb && data.port != -1) { if(challenge.isWeb && data.port != -1) {
// var $result = $("#php_display"); // var $result = $("#php_display");
challenge.showWebDisplayButton = true; // ActionView处是否出现查看效果按钮 challenge.showWebDisplayButton = true; // ActionView处是否出现查看效果按钮
this.initDisplayInterval()
const path = challenge.web_route || challenge.path const path = challenge.web_route || challenge.path
const webDisplayUrl = `${tomcat_url}:${data.port}/${path}` const webDisplayUrl = `${tomcat_url}:${data.port}/${path}`
challenge.webDisplayUrl = webDisplayUrl challenge.webDisplayUrl = webDisplayUrl
@ -653,24 +691,11 @@ pop_box_new(htmlvalue, 480, 182);
const currentGamePassed = this.props.game !== 2 && status === 2 const currentGamePassed = this.props.game !== 2 && status === 2
currentGamePassed && this.language_display(response);
// 评测通过了立即同步costTime // 评测通过了立即同步costTime
currentGamePassed && this._updateCostTime(true, true); currentGamePassed && this._updateCostTime(true, true);
if (currentGamePassed) {
game.status = 2;
game.next_game = next_game;
} else {
this.showDialog({
contentText: <div>
<div>评测未通过</div>
<div>详情请参见测试结果</div>
</div>,
isSingleButton: true
})
}
const output_sets = { const output_sets = {
"test_sets": test_sets, "test_sets": test_sets,
@ -689,6 +714,31 @@ pop_box_new(htmlvalue, 480, 182);
// output_sets.test_sets_array = test_sets_array; // output_sets.test_sets_array = test_sets_array;
// } // }
// 检查是否编译通过
let compileSuccess = false;
if (test_sets && test_sets.length) {
test_sets.some((item) => {
if (item.compile_success) {
compileSuccess = true;
return true;
}
})
}
compileSuccess && this.language_display(response);
if (currentGamePassed) {
game.status = 2;
game.next_game = next_game;
} else {
this.showDialog({
contentText: <div>
<div>评测未通过</div>
<div>详情请参见测试结果</div>
</div>,
isSingleButton: true
})
}
this.setState({ this.setState({
testSetsExpandedArray: testSetsExpandedArrayInitVal.slice(0), // 重置测试集展开状态 testSetsExpandedArray: testSetsExpandedArrayInitVal.slice(0), // 重置测试集展开状态

@ -5,7 +5,8 @@ import {Link} from 'react-router-dom';
import {getImageUrl} from 'educoder'; import {getImageUrl} from 'educoder';
import axios from 'axios' import axios from 'axios'
import {getUrl} from 'educoder'; import {getUrl} from 'educoder';
import moment from 'moment'; import moment from 'moment'
import { Base64 } from 'js-base64';
import CoursesListType from '../coursesPublic/CoursesListType'; import CoursesListType from '../coursesPublic/CoursesListType';
import Showoldfiles from "../coursesPublic/Showoldfiles"; import Showoldfiles from "../coursesPublic/Showoldfiles";
import Modals from '../../modals/Modals'; import Modals from '../../modals/Modals';
@ -26,8 +27,18 @@ class Fileslistitem extends Component{
}) })
this.props.Settingtypes(discussMessage.id) this.props.Settingtypes(discussMessage.id)
} }
showfiles=(value)=>{
downloadfiles=(url,name)=>{
const aLink = document.createElement('a');
aLink.style.display='none';
console.log(name)
aLink.setAttribute('download',name)
aLink.href = url;
document.body.appendChild(aLink);
aLink.click();
// document.body.removeChild(aLink);
}
showfiles=(value)=>{
let {discussMessage,coursesId}=this.props let {discussMessage,coursesId}=this.props
let file_id=discussMessage.id let file_id=discussMessage.id
let url="/files/"+file_id+"/histories.json" let url="/files/"+file_id+"/histories.json"
@ -38,35 +49,14 @@ class Fileslistitem extends Component{
}).then((result)=>{ }).then((result)=>{
if(result.data.attachment_histories.length===0){ if(result.data.attachment_histories.length===0){
this.downloadfiles(result.data.url,result.data.title)
let link = document.createElement('a'); }else{
document.body.appendChild(link);
link.href = result.data.url;
console.log(value)
link.download = value;
//兼容火狐浏览器
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
link.dispatchEvent(evt);
document.body.removeChild(link);
// // window.location.href=result.data.url;
// let url = window.URL.createObjectURL(new Blob([result.data.url]));
// let link = document.createElement('a');
// link.style.display = 'none';
// link.href = url;
// link.setAttribute('download',result.data.title);
// document.body.appendChild(link);
// link.click();
}else{
this.setState({ this.setState({
Showoldfiles:true, Showoldfiles:true,
allfiles:result.data allfiles:result.data
}) })
} }
// console.log(result)
}).catch((error)=>{ }).catch((error)=>{
console.log(error) console.log(error)
}) })

@ -1340,14 +1340,15 @@ class Listofworks extends Component {
// 导出实习报告批量 // 导出实习报告批量
internshipreport = (url)=>{ internshipreport = (url)=>{
console.log("internshipreport"); console.log("internshipreport");
// params: { var struy="";
// homework_common_id: homeworkid, try {
// work_status: this.state.course_groupyslstwo, struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm');
// course_group: this.state.checkedValuesineinfo, struy=struy.replace(/-/g,"");
// search: this.state.searchtext, }catch (e) {
// } console.log(1347);
// let url = "/zip/shixun_report"; console.log(e);
// let homeworkid = this.props.match.params.homeworkid; }
axios.get((url),{responseType: 'blob'}).then((response) => { axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("1350"); console.log("1350");
console.log(response); console.log(response);
@ -1363,19 +1364,10 @@ class Listofworks extends Component {
const blob = new Blob([response.data], { type: type }) const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a') const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob) const href = window.URL.createObjectURL(blob)
//后台再header中传文件名
// console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]); const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
console.log(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href downloadElement.href = href
var now=""; downloadElement.download = string+struy+".zip"
try {
now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log(now);
} catch (e) {
console.log("1376");
}
downloadElement.download = string+now+".zip"
document.body.appendChild(downloadElement) document.body.appendChild(downloadElement)
downloadElement.click() downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素 document.body.removeChild(downloadElement) // 下载完成移除元素
@ -1388,6 +1380,17 @@ class Listofworks extends Component {
// 课堂学生成绩的导出下载 // 课堂学生成绩的导出下载
Classstudentachievement=(url)=>{ Classstudentachievement=(url)=>{
console.log("Classstudentachievement"); console.log("Classstudentachievement");
// console.log();
var struy="";
try {
struy = moment().format('YYYY-MM-DD')+"-"+moment().format('hh-mm');
struy=struy.replace(/-/g,"");
}catch (e) {
console.log(1397);
console.log(e);
}
axios.get((url),{responseType: 'blob'}).then((response) => { axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("1374"); console.log("1374");
console.log(response); console.log(response);
@ -1401,21 +1404,10 @@ class Listofworks extends Component {
const blob = new Blob([response.data], { type: type }) const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a') const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob) const href = window.URL.createObjectURL(blob)
//后台再header中传文件名
// console.log("1409");
// console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]); const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
var now=""; console.log(response.headers['content-disposition'].split('=')[1]);
try {
now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log("1422");
console.log(now);
} catch (e) {
console.log("1432");
}
downloadElement.href = href downloadElement.href = href
downloadElement.download =string+now+".xlsx"; downloadElement.download =string+struy+".xlsx";
document.body.appendChild(downloadElement) document.body.appendChild(downloadElement)
downloadElement.click() downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素 document.body.removeChild(downloadElement) // 下载完成移除元素

@ -25,7 +25,14 @@ const styles = theme => ({
color: '#4CACFF', color: '#4CACFF',
border: '1px solid #4CACFF' border: '1px solid #4CACFF'
} }
},
hoverButton: {
margin: theme.spacing.unit,
height: '30px',
padding: '0 16px',
color: '#4CACFF',
border: '1px solid #4CACFF'
}, },
buttonText: { buttonText: {
color: '#1B4061 !important', color: '#1B4061 !important',
@ -64,11 +71,12 @@ class ActionView extends Component {
</span> </span>
{/*将第一个按钮改为visibility方式隐藏不然加载时测评按钮会出现没有垂直居中的情况*/} {/*将第一个按钮改为visibility方式隐藏不然加载时测评按钮会出现没有垂直居中的情况*/}
<Button size="small" className={classes.button + ' actionViewfirstButton'} onClick={()=>this.showWebDisplay(challenge)} <Tooltip title={ "倒计时为0时服务将被关闭" }>
style={{ visibility: challenge.showWebDisplayButton ? '': 'hidden'}}> <Button size="small" className={classes.button + ' actionViewfirstButton'} onClick={()=>this.showWebDisplay(challenge)}
查看效果 style={{ visibility: challenge.showWebDisplayButton ? '': 'hidden'}} id="showWebDisplayButton">
</Button> 查看效果
</Button>
</Tooltip>
{ {
!gameBuilding && !gameBuilding &&

Loading…
Cancel
Save