From 1c5ac52b68b6d4ea791ae0a72f7c1a36a443e16c Mon Sep 17 00:00:00 2001 From: harry Date: Wed, 4 Mar 2020 14:34:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/common/Component.js | 6 +- public/react/src/common/UrlTool.js | 88 +- .../src/common/components/SetAppModel.js | 14 +- public/react/src/common/educoder.js | 11 +- public/react/src/components/test-panel.jsx | 3 +- .../PackageIndexNEIBannerConcent.js | 918 ++++++++------- .../TPMUpdatepropaede/TPMUpdatepropaede.js | 90 +- .../modules/tpm/TPMsettings/oldTPMsettings.js | 5 +- .../modules/tpm/challengesnew/TPMMDEditor.js | 5 +- .../modules/tpm/challengesnew/TPMquestion.js | 1012 ++++++++--------- .../tpm/challengesnew/old/TPMchallengesnew.js | 432 ++++--- .../user/account/ChangeHeaderPicModal.js | 144 ++- .../user/usersInfo/banks/NewGtaskForm.js | 196 ++-- 13 files changed, 1437 insertions(+), 1487 deletions(-) diff --git a/public/react/src/common/Component.js b/public/react/src/common/Component.js index e49d83b84..c4de22177 100644 --- a/public/react/src/common/Component.js +++ b/public/react/src/common/Component.js @@ -1,5 +1,5 @@ import md5 from 'md5'; -export function setmiyah(logins){ - const opens ="79e33abd4b6588941ab7622aed1e67e8"; - return md5(opens+logins); +export default function setmiyah(logins) { + const opens = "79e33abd4b6588941ab7622aed1e67e8"; + return md5(opens + logins); } diff --git a/public/react/src/common/UrlTool.js b/public/react/src/common/UrlTool.js index 27be52c43..8c781fa2e 100644 --- a/public/react/src/common/UrlTool.js +++ b/public/react/src/common/UrlTool.js @@ -1,47 +1,35 @@ import React from "react"; import md5 from 'md5'; -import {Input} from "antd"; +import { Input } from "antd"; const { Search } = Input; const $ = window.$; const isDev = window.location.port == 3007; export const TEST_HOST = "https://test-newweb.educoder.net" export function getImageUrl(path) { - // https://www.educoder.net - // https://testbdweb.trustie.net - // const local = 'http://localhost:3000' - const local = 'https://test-newweb.educoder.net' + const local = 'https://test-newweb.educoder.net' if (isDev) { return `${local}/${path}` } return `/${path}`; } -export function setImagesUrl(path){ +export function setImagesUrl(path) { const local = 'https://test-newweb.educoder.net' - let firstStr=path.substr(0,1); - // console.log(firstStr); - if(firstStr=="/"){ - return isDev?`${local}${path}`:`${path}`; - }else{ - return isDev?`${local}/${path}`:`/${path}`; + let firstStr = path.substr(0, 1); + if (firstStr == "/") { + return isDev ? `${local}${path}` : `${path}`; + } else { + return isDev ? `${local}/${path}` : `/${path}`; } } -export function getUrl(path, goTest) { - // https://www.educoder.net - // https://testbdweb.trustie.net - - // 如果想所有url定位到测试版,可以反注释掉下面这行 - //goTest = true - // testbdweb.educoder.net testbdweb.trustie.net - // const local = goTest ? 'https://testeduplus2.educoder.net' : 'http://localhost:3000' - // const local = 'https://testeduplus2.educoder.net' +export function getUrl(path) { const local = 'https://test-newweb.educoder.net' if (isDev) { - return `${local}${path?path:''}` + return `${local}${path ? path : ''}` } - return `${path ? path: ''}`; + return `${path ? path : ''}`; } export function getUrlmys(path, goTest) { @@ -55,9 +43,9 @@ export function getUrlmys(path, goTest) { // const local = 'https://testeduplus2.educoder.net' const local = 'https://test-jupyterweb.educoder.net' if (isDev) { - return `${local}${path?path:''}` + return `${local}${path ? path : ''}` } - return `${path ? path: ''}`; + return `${path ? path : ''}`; } export function getStaticUrl() { const local = TEST_HOST; @@ -68,27 +56,29 @@ export function getStaticUrl() { return '' } export function getUrl2(path, goTest) { - const local = 'http://localhost:3000' + const local = 'http://localhost:3000' if (isDev) { - return `${local}${path?path:''}` + return `${local}${path ? path : ''}` } - return `${path ? path: ''}`; + return `${path ? path : ''}`; } -const newopens ="79e33abd4b6588941ab7622aed1e67e8"; +const newopens = "79e33abd4b6588941ab7622aed1e67e8"; let newtimestamp; let checkSubmitFlgs = false; function railsgettimess(proxy) { - if(checkSubmitFlgs===false){ - $.ajax({url:proxy, - async:false,success:function(data){ - if(data.status===0){ - newtimestamp=data.message; + if (checkSubmitFlgs === false) { + $.ajax({ + url: proxy, + async: false, success: function (data) { + if (data.status === 0) { + newtimestamp = data.message; checkSubmitFlgs = true; } - }}) + } + }) window.setTimeout(function () { - checkSubmitFlgs=false; + checkSubmitFlgs = false; }, 2500); } } @@ -107,32 +97,32 @@ export function getmyUrl(geturl) { export function getUploadActionUrl(path, goTest) { Railsgettimes() - let anewopens=md5(newopens+newtimestamp); + let anewopens = md5(newopens + newtimestamp); return `${getUrl()}/api/attachments.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}`; } export function getUploadActionUrltwo(id) { Railsgettimes() - let anewopens=md5(newopens+newtimestamp); + let anewopens = md5(newopens + newtimestamp); return `${getUrlmys()}/api/shixuns/${id}/upload_data_sets.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}` } export function getUploadActionUrlthree() { Railsgettimes() - let anewopens=md5(newopens+newtimestamp); + let anewopens = md5(newopens + newtimestamp); return `${getUrlmys()}/api/jupyters/import_with_tpm.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}` } export function getUploadActionUrlOfAuth(id) { Railsgettimes() - let anewopens=md5(newopens+newtimestamp); + let anewopens = md5(newopens + newtimestamp); return `${getUrl()}/api/users/accounts/${id}/auth_attachment.json${isDev ? `?debug=${window._debugType || 'admin'}&randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}`}` } export function getRandomNumber(type) { - Railsgettimes() - let anewopens=md5(newopens+newtimestamp); - return type===true?`randomcode=${newtimestamp}&client_key=${anewopens}`:`?randomcode=${newtimestamp}&client_key=${anewopens}` + Railsgettimes() + let anewopens = md5(newopens + newtimestamp); + return type === true ? `randomcode=${newtimestamp}&client_key=${anewopens}` : `?randomcode=${newtimestamp}&client_key=${anewopens}` } export function test(path) { @@ -150,11 +140,11 @@ export function getTaskUrlById(id) { export function getRandomcode(url) { Railsgettimes() - let anewopens=md5(newopens+newtimestamp); + let anewopens = md5(newopens + newtimestamp); if (url.indexOf('?') == -1) { return `${url}?randomcode=${newtimestamp}&client_key=${anewopens}` - }else { + } else { return `${url}&randomcode=${newtimestamp}&client_key=${anewopens}` } @@ -174,14 +164,14 @@ export function htmlEncode(str) { return s; } -export function publicSearchs(Placeholder,onSearch,onInputs,onChanges,loadings) { - return() } diff --git a/public/react/src/common/components/SetAppModel.js b/public/react/src/common/components/SetAppModel.js index b71a408c6..fd29a803f 100644 --- a/public/react/src/common/components/SetAppModel.js +++ b/public/react/src/common/components/SetAppModel.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { Modal } from 'antd'; -export function SetAppModel(options={}) { +export default function SetAppModel(options = {}) { return function wrap(WrappedComponent) { return class Wrapper extends Component { constructor(props) { @@ -10,14 +10,14 @@ export function SetAppModel(options={}) { } } - modalCancel=()=>{ + modalCancel = () => { window.location.href = "/"; } - setDownload=()=>{ - window.location.href ='/account/profile'; + setDownload = () => { + window.location.href = '/account/profile'; } - componentDidMount(){ + componentDidMount() { console.log(this.props) } @@ -38,8 +38,8 @@ export function SetAppModel(options={}) {

您尚未完善个人资料

请在完成资料后,提交试用申请

- this.modalCancel()}>取消 - this.setDownload()}>立即完善资料 + this.modalCancel()}>取消 + this.setDownload()}>立即完善资料
diff --git a/public/react/src/common/educoder.js b/public/react/src/common/educoder.js index 715dca135..b6ce1a8de 100644 --- a/public/react/src/common/educoder.js +++ b/public/react/src/common/educoder.js @@ -4,7 +4,7 @@ export { , getTaskUrlById as getTaskUrlById, TEST_HOST, htmlEncode as htmlEncode } from './UrlTool'; -export { setmiyah as setmiyah } from './Component'; +export { default as setmiyah } from './Component'; export { default as queryString } from './UrlTool2'; export { default as SnackbarHOC } from './SnackbarHOC'; @@ -44,7 +44,7 @@ export { themes, ThemeContext } from './context/ThemeContext' export { default as ModalHOC } from './components/ModalHOC' -export { SetAppModel } from './components/SetAppModel' +export { default as SetAppModel } from './components/SetAppModel' export { default as LinkAfterLogin } from './components/LinkAfterLogin' export { default as Cropper } from './components/Cropper' @@ -58,19 +58,12 @@ export { default as City } from './components/form/City' // course export { default as WordsBtn } from './course/WordsBtn' - export { default as ActionBtn } from './course/ActionBtn' - export { default as MarkdownToHtml } from './components/markdown/MarkdownToHtml' - export { default as DMDEditor } from './components/markdown/DMDEditor' - export { default as Clappr } from './components/media/Clappr' export { default as AliyunUploader } from './components/media/AliyunUploader' - - export { default as ImageLayer2 } from './hooks/ImageLayer2' - // 外部 export { default as CBreadcrumb } from '../modules/courses/common/CBreadcrumb' export { default as CNotificationHOC } from '../modules/courses/common/CNotificationHOC' diff --git a/public/react/src/components/test-panel.jsx b/public/react/src/components/test-panel.jsx index 5f81f8380..716be5e2f 100644 --- a/public/react/src/components/test-panel.jsx +++ b/public/react/src/components/test-panel.jsx @@ -1,5 +1,5 @@ import React, { Fragment } from 'react'; -import { getUploadActionUrl, getUrl } from 'educoder'; +import { getUploadActionUrl, getUrl, setmiyah } from 'educoder'; import TPMMDEditor from '../modules/tpm/challengesnew/TPMMDEditor'; import moment from 'moment' @@ -118,6 +118,7 @@ export default () => { return (

{getUrl()}

+

{setmiyah()}

{getUploadActionUrl()}

diff --git a/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBannerConcent.js b/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBannerConcent.js index 562ca08ae..1cde267c5 100644 --- a/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBannerConcent.js +++ b/public/react/src/modules/projectPackages/PackageIndexNewandEdit/PackageIndexNEIBannerConcent.js @@ -1,11 +1,9 @@ -import React, {Component} from 'react'; -import {Link} from "react-router-dom"; +import React, { Component } from 'react'; import axios from 'axios'; -import { Input , Spin, Icon ,Button,Pagination,DatePicker} from 'antd'; -import { handleDateString,getUrl,setmiyah} from 'educoder'; +import { Input, Spin, Icon, Button, Pagination, DatePicker } from 'antd'; +import { handleDateString, getUrl, setmiyah } from 'educoder'; import locale from 'antd/lib/date-picker/locale/zh_CN'; import MDEditors from '../MDEditors'; -import PhoneModel from './PhoneModel'; import moment from 'moment'; import '../packageconcnet.css'; const { Search } = Input; @@ -22,9 +20,9 @@ if (!window.postUpMsg) { } -function checkPhone(phone){ +function checkPhone(phone) { - if(!(/^1[3456789]\d{9}$/.test(phone))){ + if (!(/^1[3456789]\d{9}$/.test(phone))) { // alert("手机号码有误,请重填"); return false; } @@ -54,62 +52,62 @@ class PackageIndexNEIBannerConcent extends Component { super(props) this.contentMdRef = React.createRef(); this.state = { - modalCancel:false, - getverificationcodes:true, - seconds:60, - springtype:false, - category:undefined, - title:undefined, - content:undefined, - attachment_ids:undefined, - deadline_at:undefined, - min_price:undefined, - max_price:undefined, - contact_name:undefined, - contact_phone:undefined, - code:undefined, - publish:false, - categories:[] + modalCancel: false, + getverificationcodes: true, + seconds: 60, + springtype: false, + category: undefined, + title: undefined, + content: undefined, + attachment_ids: undefined, + deadline_at: undefined, + min_price: undefined, + max_price: undefined, + contact_name: undefined, + contact_phone: undefined, + code: undefined, + publish: false, + categories: [] } } componentDidMount() { window.document.title = '众包创新' - if(this.props.match.params.id!=undefined){ - - let url=`/project_packages/${this.props.match.params.id}.json` - axios.get((url)).then((response) => { - - let data=response.data - this.setState({ - category:data.category_id, - title:data.title, - content:data.content, - deadline_at:moment(data.deadline_at), - min_price:data.min_price, - max_price:data.max_price, - contact_name:data.contact_name==null||data.contact_name==undefined?this.props.current_user.real_name:data.contact_name, - phones:data.contact_phone, - attachments:data.attachments, - - }) - }).catch((error) => { - console.log(error); - - }) - }else{ - console.log(this.props.current_user&&this.props.current_user.real_name) + if (this.props.match.params.id != undefined) { + + let url = `/project_packages/${this.props.match.params.id}.json` + axios.get((url)).then((response) => { + + let data = response.data + this.setState({ + category: data.category_id, + title: data.title, + content: data.content, + deadline_at: moment(data.deadline_at), + min_price: data.min_price, + max_price: data.max_price, + contact_name: data.contact_name == null || data.contact_name == undefined ? this.props.current_user.real_name : data.contact_name, + phones: data.contact_phone, + attachments: data.attachments, + + }) + }).catch((error) => { + console.log(error); + + }) + } else { + console.log(this.props.current_user && this.props.current_user.real_name) } let Url = `/project_package_categories.json`; axios.get(Url).then((response) => { // console.log(response) - if(response.data.status===-1){ + if (response.data.status === -1) { - }else{ + } else { this.setState({ - categories:response.data.categories + categories: response.data.categories }) } @@ -118,7 +116,7 @@ class PackageIndexNEIBannerConcent extends Component { }) this.setState({ - contact_name:this.props.current_user&&this.props.current_user.real_name + contact_name: this.props.current_user && this.props.current_user.real_name }) // this.contentMdRef.current.setValue("测试赋值") @@ -126,25 +124,25 @@ class PackageIndexNEIBannerConcent extends Component { componentDidUpdate = (prevProps) => { - if(prevProps.current_user!=this.props.current_user){ - if(this.props.current_user!=undefined){ + if (prevProps.current_user != this.props.current_user) { + if (this.props.current_user != undefined) { this.setState({ - contact_name:this.props.current_user.real_name + contact_name: this.props.current_user.real_name }) } } } //获取验证码; - getverificationcode =()=>{ + getverificationcode = () => { // if (this.state.logins&&this.state.logins.length === 0) { // // 判断没有输入手机号 // return // } - if(this.state.getverificationcodes === undefined){ - console.log("undefined"); - return; - } + if (this.state.getverificationcodes === undefined) { + console.log("undefined"); + return; + } if (this.state.getverificationcodes === true) { this.setState({ getverificationcodes: undefined, @@ -188,22 +186,22 @@ class PackageIndexNEIBannerConcent extends Component { } //短信验证 SMSverification = () => { - let {contact_phone,code}=this.state; + let { contact_phone, code } = this.state; var url = `/accounts/get_verification_code.json`; axios.get((url), { params: { login: contact_phone, type: 5, - smscode:setmiyah(contact_phone) + smscode: setmiyah(contact_phone) } }).then((result) => { //验证有问题{"status":1,"message":"success"} // console.log(result); // this.openNotification("验证码已发送,请注意查收"); - if(result.data.status===1){ + if (result.data.status === 1) { this.openNotification("验证码已发送,请注意查收"); - }else if(result.data.status===-2){ + } else if (result.data.status === -2) { this.openNotification(result.data.message); } }).catch((error) => { @@ -214,27 +212,27 @@ class PackageIndexNEIBannerConcent extends Component { onChangeTimePicker = (value, dateString) => { - if(value===null){ + if (value === null) { this.setState({ - deadline_at:"" + deadline_at: "" }) - }else{ - if(moment(handleDateString(dateString))===undefined||moment(handleDateString(dateString))===null||moment(handleDateString(dateString))===""){ + } else { + if (moment(handleDateString(dateString)) === undefined || moment(handleDateString(dateString)) === null || moment(handleDateString(dateString)) === "") { this.setState({ - deadline_attypes:true + deadline_attypes: true }) - }else{ + } else { this.setState({ - deadline_attypes:false + deadline_attypes: false }) } - if(moment(handleDateString(dateString)){ + setcheckoutcontent = () => { const content = this.contentMdRef.current.getValue().trim(); - if(content===undefined||content===null||content===""){ - this.setState({ - contenttypes:true - }) - }else{ - this.setState({ - contenttypes:false - }) + if (content === undefined || content === null || content === "") { + this.setState({ + contenttypes: true + }) + } else { + this.setState({ + contenttypes: false + }) } } - setcheckout=(min_price,max_price)=>{ - // if(min_price===undefined){ + setcheckout = (min_price, max_price) => { + // if(min_price===undefined){ // this.setState({ // min_pricetype:true // }) - // }else{ + // }else{ // this.setState({ // min_pricetype:false // }) - // } + // } - // if(parseInt(min_price)===undefined||parseInt(min_price)===null||parseInt(min_price)===""){ - // + // if(parseInt(min_price)===undefined||parseInt(min_price)===null||parseInt(min_price)===""){ + // // this.setState({ // min_pricetype:true // }) - // }else{ + // }else{ // this.setState({ // min_pricetype:false // }) - // } + // } - // if(parseInt(max_price)===undefined||parseInt(max_price)===null||parseInt(max_price)===""){ - // + // if(parseInt(max_price)===undefined||parseInt(max_price)===null||parseInt(max_price)===""){ + // // this.setState({ // min_pricetype:true // }) - // - // }else{ + // + // }else{ // this.setState({ // min_pricetype:false // }) - // } + // } - if(parseInt(min_price)<=0){ - this.setState({ - smallstype:true - }) - }else{ - this.setState({ - smallstype:false - }) - } + if (parseInt(min_price) <= 0) { + this.setState({ + smallstype: true + }) + } else { + this.setState({ + smallstype: false + }) + } - if(parseInt(max_price){ + setPublication = (type) => { const content = this.contentMdRef.current.getValue().trim(); // console.log(content) // console.log(this.state.deadline_at._i) - this.setState({ - publish:type + this.setState({ + publish: type }) - let types=type; - let {category,title,attachment_ids,deadline_at,min_price,max_price,contact_name,contact_phone,code,modalCancel}=this.state; + let types = type; + let { category, title, attachment_ids, deadline_at, min_price, max_price, contact_name, contact_phone, code, modalCancel } = this.state; - if(category===undefined||category===null||category===""){ + if (category === undefined || category === null || category === "") { this.setState({ - categorytypes:true + categorytypes: true }) this.scrollToAnchor("publishtimestart"); return } - if(title===undefined||title===null||title===""){ + if (title === undefined || title === null || title === "") { this.setState({ - titletypes:true + titletypes: true }) this.scrollToAnchor("publishtimestart"); return } - if(content===undefined||content===null||content===""){ + if (content === undefined || content === null || content === "") { this.setState({ - contenttypes:true + contenttypes: true }) this.scrollToAnchor("publishtimestart"); return } - if(deadline_at===undefined||deadline_at===null||deadline_at===""){ + if (deadline_at === undefined || deadline_at === null || deadline_at === "") { this.setState({ - deadline_attypes:true + deadline_attypes: true }) this.scrollToAnchor("publishtime"); return } - if(moment(deadline_at) { - if(response.data.status===0){ - if(type===true){ - this.props.setPublicationfun(response.data.id) - }else{ - window.location.href="/crowdsourcing/"+response.data.id - } - this.setState({ - springtype:false - }) - }else if(response.data.status===-1){ - if(response.data.message==="无效的验证码"){ - this.setState({ - codeypesno:true, - springtype:false - }) - } - } - this.setState({ - springtype:false - }) - }).catch((error) => { - console.log(error) - this.setState({ - springtype:false - }) - }) - - - }else{ - - // edit - - const url = `/project_packages/${this.props.match.params.id}.json`; - - axios.put(url, { - category_id: category, - title: title, - content: content, - attachment_ids: attachment_ids, - deadline_at:deadline_at._i, - min_price:parseInt(min_price), - max_price:parseInt(max_price), - contact_name: contact_name===null||contact_name===undefined?this.props.current_user.real_name:contact_name, - contact_phone: contact_phone===undefined?this.props.current_user&&this.props.current_user.phone:contact_phone, - code:code, - publish:types - } - ).then((response) => { - if(response.data.status===0){ - if(type===true){ - this.props.setPublicationfun(response.data.id) - }else{ - window.location.href="/crowdsourcing/"+response.data.id - } - this.setState({ - springtype:false - }) - }else if(response.data.status===-1){ - if(response.data.message==="无效的验证码"){ - this.setState({ - codeypesno:true, - springtype:false - }) - } - } - this.setState({ - springtype:false - }) - }).catch((error) => { - console.log(error) - this.setState({ - springtype:false - }) - }) - - - } + if (this.props.match.params.id === undefined) { + const url = `/project_packages.json`; + + axios.post(url, { + category_id: category, + title: title, + content: content, + attachment_ids: attachment_ids, + deadline_at: deadline_at._i, + min_price: parseInt(min_price), + max_price: parseInt(max_price), + contact_name: contact_name === null || contact_name === undefined ? this.props.current_user.real_name : contact_name, + contact_phone: contact_phone === undefined ? this.props.current_user && this.props.current_user.phone : contact_phone, + code: code, + publish: types + } + ).then((response) => { + if (response.data.status === 0) { + if (type === true) { + this.props.setPublicationfun(response.data.id) + } else { + window.location.href = "/crowdsourcing/" + response.data.id + } + this.setState({ + springtype: false + }) + } else if (response.data.status === -1) { + if (response.data.message === "无效的验证码") { + this.setState({ + codeypesno: true, + springtype: false + }) + } + } + this.setState({ + springtype: false + }) + }).catch((error) => { + console.log(error) + this.setState({ + springtype: false + }) + }) + + + } else { + + // edit + + const url = `/project_packages/${this.props.match.params.id}.json`; + + axios.put(url, { + category_id: category, + title: title, + content: content, + attachment_ids: attachment_ids, + deadline_at: deadline_at._i, + min_price: parseInt(min_price), + max_price: parseInt(max_price), + contact_name: contact_name === null || contact_name === undefined ? this.props.current_user.real_name : contact_name, + contact_phone: contact_phone === undefined ? this.props.current_user && this.props.current_user.phone : contact_phone, + code: code, + publish: types + } + ).then((response) => { + if (response.data.status === 0) { + if (type === true) { + this.props.setPublicationfun(response.data.id) + } else { + window.location.href = "/crowdsourcing/" + response.data.id + } + this.setState({ + springtype: false + }) + } else if (response.data.status === -1) { + if (response.data.message === "无效的验证码") { + this.setState({ + codeypesno: true, + springtype: false + }) + } + } + this.setState({ + springtype: false + }) + }).catch((error) => { + console.log(error) + this.setState({ + springtype: false + }) + }) + + + } } - modalCancel=()=>{ + modalCancel = () => { this.setState({ - modalCancel:false, - contact_phone:undefined, - code:undefined, + modalCancel: false, + contact_phone: undefined, + code: undefined, }) } - editmodels=()=>{ + editmodels = () => { this.setState({ - modalCancel:true + modalCancel: true }) } - setcategory=(value)=>{ - if(value===undefined||value===null||value===""){ + setcategory = (value) => { + if (value === undefined || value === null || value === "") { this.setState({ - categorytypes:true + categorytypes: true }) - }else{ + } else { this.setState({ - categorytypes:false + categorytypes: false }) } this.setState({ - category:value + category: value }) } - settitlefun=(e)=>{ + settitlefun = (e) => { - if(e.target.value===undefined||e.target.value===null||e.target.value===""){ + if (e.target.value === undefined || e.target.value === null || e.target.value === "") { this.setState({ - titletypes:true + titletypes: true }) - }else{ + } else { this.setState({ - titletypes:false + titletypes: false }) } this.setState({ - title:e.target.value + title: e.target.value }) } - onChangemin_prices=(e)=>{ - let{max_price}=this.state; + onChangemin_prices = (e) => { + let { max_price } = this.state; this.setState({ - min_price:e.target.value + min_price: e.target.value }) - this.setcheckout(e.target.value,max_price) + this.setcheckout(e.target.value, max_price) } - onChangemax_prices=(e)=>{ - let{min_price}=this.state; + onChangemax_prices = (e) => { + let { min_price } = this.state; this.setState({ - max_price:e.target.value + max_price: e.target.value }) - this.setcheckout(min_price,e.target.value) + this.setcheckout(min_price, e.target.value) } - onChangeContact_name=(e)=>{ + onChangeContact_name = (e) => { - if(e.target.value===undefined||e.target.value===""||e.target.value===null){ + if (e.target.value === undefined || e.target.value === "" || e.target.value === null) { this.setState({ - contact_nametype:true + contact_nametype: true }) - }else{ + } else { this.setState({ - contact_nametype:false + contact_nametype: false }) } this.setState({ - contact_name:e.target.value + contact_name: e.target.value }) } - onChangeContact_phone=(e)=>{ - let {modalCancel}=this.state; + onChangeContact_phone = (e) => { + let { modalCancel } = this.state; // if(modalCancel===false){ // if(this.props.current_user.phone===undefined||this.props.current_user.phone===null||this.props.current_user.phone===""){ // this.setState({ @@ -648,46 +646,46 @@ class PackageIndexNEIBannerConcent extends Component { // }) // } // } - if(this.props.current_user&&this.props.current_user.phone===null||modalCancel===true){ - if(e.target.value===undefined||e.target.value===null||e.target.value===""){ + if (this.props.current_user && this.props.current_user.phone === null || modalCancel === true) { + if (e.target.value === undefined || e.target.value === null || e.target.value === "") { this.setState({ - contact_phonetype:true + contact_phonetype: true }) - }else{ + } else { this.setState({ - contact_phonetype:false + contact_phonetype: false }) } - if(checkPhone(e.target.value)===false){ + if (checkPhone(e.target.value) === false) { this.setState({ - contact_phonetypes:true + contact_phonetypes: true }) - }else{ + } else { this.setState({ - contact_phonetypes:false + contact_phonetypes: false }) } } this.setState({ - contact_phone:e.target.value + contact_phone: e.target.value }) } - onChangeCode=(e)=>{ - if(e.target.value===undefined||e.target.value===""||e.target.value===null){ + onChangeCode = (e) => { + if (e.target.value === undefined || e.target.value === "" || e.target.value === null) { this.setState({ - codeypes:true + codeypes: true }) - }else{ + } else { this.setState({ - codeypes:false + codeypes: false }) } this.setState({ - code:e.target.value + code: e.target.value }) } @@ -697,35 +695,35 @@ class PackageIndexNEIBannerConcent extends Component { // 找到锚点 let anchorElement = document.getElementById(anchorName); // 如果对应id的锚点存在,就跳转到锚点 - if(anchorElement) { anchorElement.scrollIntoView(); } + if (anchorElement) { anchorElement.scrollIntoView(); } } } render() { - let {modalCancel,seconds,getverificationcodes,attachments, - category,title}=this.state; - let categorylist=[ - {name:"前端开发",value:"front"}, - {name:"后端开发",value:"backend"}, - {name:"移动开发",value:"mobile"}, - {name:"数据库",value:"database"}, - {name:"云计算和大数据",value:"cloud_compute_and_big_data"}, - {name:"人工智能",value:"ai"}, - {name:"其他",value:"other"}, + let { modalCancel, seconds, getverificationcodes, attachments, + category, title } = this.state; + let categorylist = [ + { name: "前端开发", value: "front" }, + { name: "后端开发", value: "backend" }, + { name: "移动开发", value: "mobile" }, + { name: "数据库", value: "database" }, + { name: "云计算和大数据", value: "cloud_compute_and_big_data" }, + { name: "人工智能", value: "ai" }, + { name: "其他", value: "other" }, ] return ( -
- {/* + {/**/} - -

+ {/*/>*/} + +

-

+
@@ -733,171 +731,171 @@ class PackageIndexNEIBannerConcent extends Component {

- {this.state.categories.map((item,key)=>{ - return( -
  • this.setcategory(item.id)}>{item.name}
  • + {this.state.categories.map((item, key) => { + return ( +
  • this.setcategory(item.id)}>{item.name}
  • ) })}

    - {this.state.categorytypes===true?
    请选择类型
    :""} + {this.state.categorytypes === true ?
    请选择类型
    : ""} -
    - -
    +
    + +
    - - {this.state.titletypes===true?
    不能为空
    :""} - this.setcheckoutcontent()}> + + {this.state.titletypes === true ?
    不能为空
    : ""} + this.setcheckoutcontent()}> {/* 请求status 422 */} - {this.state.contenttypes===true?
    不能为空
    :""} + {this.state.contenttypes === true ?
    不能为空
    : ""} {/*
    */} - {/* window.$('#_file').click()}*/} - {/*data-tip-down="请选择文件上传">*/} - {/*/!**!/*/} - {/*上传附件*/} - {/**/} - {/*(最多可添加 5 个图片/文件,每个大小不超过 10MB)*/} + {/* window.$('#_file').click()}*/} + {/*data-tip-down="请选择文件上传">*/} + {/*/!**!/*/} + {/*上传附件*/} + {/**/} + {/*(最多可添加 5 个图片/文件,每个大小不超过 10MB)*/} {/*
    */} {/*{attachments&&attachments.map((item,key)=>{*/} - {/*return(*/} - {/**/} - {/*)})}*/} + {/*return(*/} + {/**/} + {/*)})}*/} {/*
    */} - {/**/} - {/**/} - {/**/} - {/* {*/} - {/*debugger;*/} - {/*console.log(window.$('.file_selector')[0])*/} - {/*window.addInputFiles(window.$('.file_selector')[0])*/} - {/*}}*/} - {/*style={{'display': 'none'}}*/} - {/*type="file">*/} - {/**/} - {/**/} + {/**/} + {/**/} + {/**/} + {/* {*/} + {/*debugger;*/} + {/*console.log(window.$('.file_selector')[0])*/} + {/*window.addInputFiles(window.$('.file_selector')[0])*/} + {/*}}*/} + {/*style={{'display': 'none'}}*/} + {/*type="file">*/} + {/**/} + {/**/} {/*
    */} +
    -
    -
    -
    -
    - -
    -

    - 竞标截止: - - - {this.state.deadline_attypes===true?

    不能为空
    :""} - - {this.state.deadline_attypexy===true?
    不能早于当前时间
    :""} -

    -

    - 支付费用: - this.onChangemin_prices(e)} - suffix={ - ¥ - } - /> - - this.onChangemax_prices(e)} - suffix={ - ¥ - } - />不填,则表示可议价 - {this.state.min_pricetype===true?

    不能为空
    :""} - {this.state.smallstype===true?
    不能小于零
    :""} - {this.state.minmaxtype===true?
    最高费用不能小于最低费用
    :""} -

    -
    - -
    -

    - 姓名: - this.onChangeContact_name(e)} - /> - {this.state.contact_nametype===true?

    不能为空
    :""} -

    - - {this.props.current_user&&this.props.current_user.phone!=null&&modalCancel===false?

    - 手机号: - - - this.editmodels()}> - -

    :""} - {/*{this.state.current_userphonetype===true?
    不能为空
    :""}*/} - {this.props.current_user&&this.props.current_user.phone===null||modalCancel===true?

    +

    +
    +
    + +
    +

    + 竞标截止: + + + {this.state.deadline_attypes === true ?

    不能为空
    : ""} + + {this.state.deadline_attypexy === true ?
    不能早于当前时间
    : ""} +

    +

    + 支付费用: + this.onChangemin_prices(e)} + suffix={ + ¥ + } + /> + + this.onChangemax_prices(e)} + suffix={ + ¥ + } + />不填,则表示可议价 + {this.state.min_pricetype === true ?

    不能为空
    : ""} + {this.state.smallstype === true ?
    不能小于零
    : ""} + {this.state.minmaxtype === true ?
    最高费用不能小于最低费用
    : ""} +

    +
    + +
    +

    + 姓名: + this.onChangeContact_name(e)} + /> + {this.state.contact_nametype === true ?

    不能为空
    : ""} +

    + + {this.props.current_user && this.props.current_user.phone != null && modalCancel === false ?

    + 手机号: + + + this.editmodels()}> + +

    : ""} + {/*{this.state.current_userphonetype===true?
    不能为空
    :""}*/} + {this.props.current_user && this.props.current_user.phone === null || modalCancel === true ?

    - - {/*未注册才显示!*/} + + {/*未注册才显示!*/} - 手机号: + 手机号: this.onChangeContact_phone(e)} + onInput={(e) => this.onChangeContact_phone(e)} /> - {this.state.contact_phonetype===true?

    不能为空
    :""} - {this.state.contact_phonetypes===true?
    请输入正确的手机号
    :""} + {this.state.contact_phonetype === true ?
    不能为空
    : ""} + {this.state.contact_phonetypes === true ?
    请输入正确的手机号
    : ""} @@ -908,32 +906,32 @@ class PackageIndexNEIBannerConcent extends Component { className="fafas" placeholder="请输入验证码" enterButton={ - getverificationcodes === undefined ? 重新发送 ({seconds}s): getverificationcodes === true ?获取验证码 :重新发送} - onSearch={()=>this.getverificationcode()} - onInput={(e)=>this.onChangeCode(e)} + getverificationcodes === undefined ? 重新发送 ({seconds}s) : getverificationcodes === true ? 获取验证码 : 重新发送} + onSearch={() => this.getverificationcode()} + onInput={(e) => this.onChangeCode(e)} /> - {this.state.codeypes===true?
    验证码不能为空
    :""} - {this.state.codeypesno===true?
    验证码不正确
    :""} + {this.state.codeypes === true ?
    验证码不能为空
    : ""} + {this.state.codeypesno === true ?
    验证码不正确
    : ""}
    {/**/} - this.modalCancel()}>X + this.modalCancel()}>X -

    :""} +

    : ""} +
    -
    -

    +

    -
    - - this.setPublication(false)}>保存 -
    - + +
    ) diff --git a/public/react/src/modules/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js b/public/react/src/modules/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js index d79c4885e..245d6ea64 100644 --- a/public/react/src/modules/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js +++ b/public/react/src/modules/tpm/TPMUpdatepropaede/TPMUpdatepropaede.js @@ -1,46 +1,40 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd'; - -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; +import { Link } from "react-router-dom"; import axios from 'axios'; import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; -import {getUrl} from 'educoder'; - - - export default class TPMUpdatepropaede extends Component { constructor(props) { super(props) - this.neweditanswerRef=React.createRef(); + this.neweditanswerRef = React.createRef(); this.state = { - shixunId:undefined, + shixunId: undefined, } } componentDidMount() { let id = this.props.match.params.shixunId; - let url="/shixuns/"+id+"/propaedeutics.json"; + let url = "/shixuns/" + id + "/propaedeutics.json"; axios.get(url).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { + if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { - }else{ + } else { this.setState({ - shixunId:id, + shixunId: id, }) - if(response.data.content[0]!=null){ - this.setState({ - editanswersRefval:response.data.content, - }) - this.neweditanswerRef.current.setValue(response.data.content) - }else{ - this.setState({ - editanswersRefval:"", - }) - this.neweditanswerRef.current.setValue('') + if (response.data.content[0] != null) { + this.setState({ + editanswersRefval: response.data.content, + }) + this.neweditanswerRef.current.setValue(response.data.content) + } else { + this.setState({ + editanswersRefval: "", + }) + this.neweditanswerRef.current.setValue('') } } }).catch((error) => { @@ -49,21 +43,21 @@ export default class TPMUpdatepropaede extends Component { } - updatepropaedeuticsvalue=()=>{ + updatepropaedeuticsvalue = () => { let id = this.props.match.params.shixunId; - let {shixunId} = this.state; - let url="/shixuns/"+id+"/update_propaedeutics.json"; + let { shixunId } = this.state; + let url = "/shixuns/" + id + "/update_propaedeutics.json"; const update_propaedeuticsvalue = this.neweditanswerRef.current.getValue().trim(); - axios.post(url,{ - content:update_propaedeuticsvalue - } - ).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { + axios.post(url, { + content: update_propaedeuticsvalue + } + ).then((response) => { + if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { - }else{ + } else { this.props.showNotification(response.data.message); - if(response.data.status===1){ - this.props.history.replace("/shixuns/"+shixunId+"/propaedeutics"); + if (response.data.status === 1) { + this.props.history.replace("/shixuns/" + shixunId + "/propaedeutics"); } } }).catch((error) => { @@ -71,27 +65,27 @@ export default class TPMUpdatepropaede extends Component { }); } render() { - let {shixunId} = this.state; + let { shixunId } = this.state; return (
    -
    -
    - 背景知识 - 返回 -
    +
    +
    + 背景知识 + 返回 +
    -
    - -
    -
    +
    + +
    +
    保存 - 保存 + 取消
    diff --git a/public/react/src/modules/tpm/TPMsettings/oldTPMsettings.js b/public/react/src/modules/tpm/TPMsettings/oldTPMsettings.js index a582ebfca..5de43cc4f 100644 --- a/public/react/src/modules/tpm/TPMsettings/oldTPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/oldTPMsettings.js @@ -3,7 +3,7 @@ import React, { Component } from 'react'; import MonacoEditor from 'react-monaco-editor'; //MonacoDiffEditor 对比模式 -import { Input, Select, Radio, Checkbox, Popconfirm, message, Modal, Icon, DatePicker, Breadcrumb, Upload, Button, notification, Tooltip } from 'antd'; +import { Input, Select, Radio, Checkbox, Modal, Icon, DatePicker, Breadcrumb, Upload, Button, notification, Tooltip } from 'antd'; // import "antd/dist/antd.css"; @@ -15,9 +15,8 @@ import axios from 'axios'; import './css/TPMsettings.css'; -import { getImageUrl, toPath, getUrl, getUploadActionUrl } from 'educoder'; +import { getImageUrl, getUrl, getUploadActionUrl } from 'educoder'; -let origin = getUrl(); let path = getUrl("/editormd/lib/") diff --git a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js index a9562dea1..69a7d832f 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js +++ b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js @@ -4,11 +4,8 @@ import '../../courses/css/Courses.css' import './css/TPMchallengesnew.css'; -let path = '/editormd/lib/' -path = getUrl("/editormd/lib/") const $ = window.$; - // 保存数据 function md_add_data(k, mdu, d) { window.sessionStorage.setItem(k + mdu, d); @@ -86,7 +83,7 @@ function create_editorMD(id, width, high, placeholder, imageUrl, callback, initV var editorName = window.editormd(id, { width: width, height: high === undefined ? 400 : high, - path: path, // "/editormd/lib/" + path: getUrl("/editormd/lib/"), // "/editormd/lib/" markdown: initValue, dialogLockScreen: false, diff --git a/public/react/src/modules/tpm/challengesnew/TPMquestion.js b/public/react/src/modules/tpm/challengesnew/TPMquestion.js index b76e17b17..e31a76f78 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMquestion.js +++ b/public/react/src/modules/tpm/challengesnew/TPMquestion.js @@ -1,37 +1,27 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Tooltip,notification} from 'antd'; +import { Select, Popconfirm, message, Tooltip, notification } from 'antd'; -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -// import "antd/dist/antd.css"; +import { Link } from "react-router-dom"; import axios from 'axios'; -import { getImageUrl, toPath } from 'educoder'; +import { getImageUrl } from 'educoder'; import './css/TPMchallengesnew.css'; -import {getUrl} from 'educoder'; - import TpmQuestionMain from './TpmQuestionMain'; import TpmQuestionNew from './TpmQuestionNew'; import TpmQuestionEdit from './TpmQuestionEdit'; -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") - const $ = window.$; - const Option = Select.Option; -const RadioGroup = Radio.Group; var letterArr = []; -for (var i = 65, j = 0; i < 91; i++, j++) { +for (var i = 65, j = 0; i < 91; i++ , j++) { letterArr[j] = String.fromCharCode(i); } @@ -39,11 +29,11 @@ for (var i = 65, j = 0; i < 91; i++, j++) { export default class TPMquestion extends Component { constructor(props) { super(props) - this.contentMdRef = React.createRef(); - this.newquestioMDMdRef = React.createRef(); - this.newquestioMDMdCont=React.createRef(); - this.neweditanswerRef=React.createRef(); - this.editanswersRef=React.createRef(); + this.contentMdRef = React.createRef(); + this.newquestioMDMdRef = React.createRef(); + this.newquestioMDMdCont = React.createRef(); + this.neweditanswerRef = React.createRef(); + this.editanswersRef = React.createRef(); this.state = { choice_url: undefined, practice_url: undefined, @@ -51,72 +41,72 @@ export default class TPMquestion extends Component { position: undefined, task_pass_default: undefined, submit_url: undefined, - questionsInputvalue:undefined, - questionaddsum:0, - questionaddarray:[], - questionaddtype:true, - activetype:"", - questionlists:[{str:"A",val:"",type:false},{str:"B",val:"",type:false},{str:"C",val:"",type:false},{str:"D",val:"",type:false}], + questionsInputvalue: undefined, + questionaddsum: 0, + questionaddarray: [], + questionaddtype: true, + activetype: "", + questionlists: [{ str: "A", val: "", type: false }, { str: "B", val: "", type: false }, { str: "C", val: "", type: false }, { str: "D", val: "", type: false }], answeshixunsGroup: 1, - answeoptions:[10,20], - answeonshixunsmark:10, - shixunssanswerkillvalue:"", - shixunsskillanswerlist:[], - challenge_id:"", - challenge_choose_id:undefined, - questionlistss:[], - newcnttype:false, - newquestioMDvaluetype:false, - challenge_tagtype:false, - editquestionaddtype:false, - mancheckpointId:undefined, - power:false, - questionInputvaluetype:false, - questioMD:"", - standard_answer:"", - subject:"", - newquestioMDvaluetypes:false, - questionInputvaluetypes:false, - prev_challenge:undefined, - next_challenge:undefined, - newcnttypesum:1, - marktype:false, - answer:"", - sumittype:false + answeoptions: [10, 20], + answeonshixunsmark: 10, + shixunssanswerkillvalue: "", + shixunsskillanswerlist: [], + challenge_id: "", + challenge_choose_id: undefined, + questionlistss: [], + newcnttype: false, + newquestioMDvaluetype: false, + challenge_tagtype: false, + editquestionaddtype: false, + mancheckpointId: undefined, + power: false, + questionInputvaluetype: false, + questioMD: "", + standard_answer: "", + subject: "", + newquestioMDvaluetypes: false, + questionInputvaluetypes: false, + prev_challenge: undefined, + next_challenge: undefined, + newcnttypesum: 1, + marktype: false, + answer: "", + sumittype: false } } - questionInputvalue=(e)=>{ + questionInputvalue = (e) => { this.setState({ - questionsInputvalue: e.target.value + questionsInputvalue: e.target.value }) } componentDidMount() { - if(this.props.status===2){ + if (this.props.status === 2) { } let id = this.props.match.params.shixunId; - let checkpointId=this.props.match.params.checkpointId; + let checkpointId = this.props.match.params.checkpointId; this.setState({ - mancheckpointId:id, + mancheckpointId: id, }) - let newchoice_url= "/shixuns/"+id+"/challenges/newquestion"; - let newpractice_url= "/shixuns/"+id+"/challenges/new"; - let newgo_back_url="/shixuns/"+id+"/challenges"; + let newchoice_url = "/shixuns/" + id + "/challenges/newquestion"; + let newpractice_url = "/shixuns/" + id + "/challenges/new"; + let newgo_back_url = "/shixuns/" + id + "/challenges"; - if(this.props.match.params.choose_id===undefined){ - if(checkpointId===undefined){ + if (this.props.match.params.choose_id === undefined) { + if (checkpointId === undefined) { //新建模式 let nurl = "/shixuns/" + id + "/challenges/new.json" axios.get(nurl).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { + if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { - }else { + } else { this.setState({ choice_url: newchoice_url, practice_url: newpractice_url, @@ -124,20 +114,20 @@ export default class TPMquestion extends Component { position: response.data.position, task_pass_default: response.data.task_pass_default, submit_url: response.data.submit_url, - power:true, - activetype:"first", + power: true, + activetype: "first", }) - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { + if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { this.setState({ - contentMdRefval:"" + contentMdRefval: "" }) } else { this.setState({ - contentMdRefval:response.data.task_pass_default + contentMdRefval: response.data.task_pass_default }) - this.contentMdRef.current.setValue(response.data.task_pass_default || '') + this.contentMdRef.current.setValue(response.data.task_pass_default || '') } this.shixunsautoHeight() } @@ -146,54 +136,54 @@ export default class TPMquestion extends Component { console.log(error) }); - }else{ + } else { //编辑模式 - let url = "/shixuns/"+ id +"/challenges/"+checkpointId+"/edit.json?st=1" + let url = "/shixuns/" + id + "/challenges/" + checkpointId + "/edit.json?st=1" axios.get(url).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { + if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { - }else { - let newprev_challenge=response.data.prev_challenge; - let next_challenge=response.data.next_challenge; + } else { + let newprev_challenge = response.data.prev_challenge; + let next_challenge = response.data.next_challenge; if (newprev_challenge != undefined) { - if(newprev_challenge.st===0){ + if (newprev_challenge.st === 0) { newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editcheckpoint"; - }else{ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; + } else { + newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; } } if (next_challenge != undefined) { - if(next_challenge.st===0){ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editcheckpoint"; - }else{ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editquestion"; + if (next_challenge.st === 0) { + next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id + "/editcheckpoint"; + } else { + next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id + "/editquestion"; } } this.setState({ - questionaddtype:false, - newquestionaddtype:false, - activetype:"first", - prev_challenge:newprev_challenge, - next_challenge:next_challenge, - questionsInputvalue:response.data.subject, - questionaddarray:response.data.chooses, - challenge_id:response.data.id, - mancheckpointId:checkpointId, + questionaddtype: false, + newquestionaddtype: false, + activetype: "first", + prev_challenge: newprev_challenge, + next_challenge: next_challenge, + questionsInputvalue: response.data.subject, + questionaddarray: response.data.chooses, + challenge_id: response.data.id, + mancheckpointId: checkpointId, position: response.data.position, choice_url: newchoice_url, practice_url: newpractice_url, go_back_url: newgo_back_url, - power:response.data.power, + power: response.data.power, // questioMD:response.data.task_pass, - answer:response.data.answer + answer: response.data.answer }) - this.setState({ - contentMdRefval:response.data.task_pass - }) - // this.contentMdRef.current.setValue(response.data.task_pass || '') - if(response.data.chooses.length===0){ + this.setState({ + contentMdRefval: response.data.task_pass + }) + // this.contentMdRef.current.setValue(response.data.task_pass || '') + if (response.data.chooses.length === 0) { // 新建选择题时,没法切回 ‘本关任务’ tab // this.questionadd() } @@ -206,58 +196,58 @@ export default class TPMquestion extends Component { }); } - }else{ + } else { $('html').animate({ - scrollTop:10 + scrollTop: 10 }, 500); - let{challenge_id} =this.state; + let { challenge_id } = this.state; let id = this.props.match.params.shixunId; - let url = "/shixuns/"+ id +"/challenges/"+checkpointId+"/edit.json?st=1" + let url = "/shixuns/" + id + "/challenges/" + checkpointId + "/edit.json?st=1" axios.get(url).then((response) => { - if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { + if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { - }else { - let newprev_challenge=response.data.prev_challenge; - let next_challenge=response.data.next_challenge; + } else { + let newprev_challenge = response.data.prev_challenge; + let next_challenge = response.data.next_challenge; if (newprev_challenge != undefined) { - if(newprev_challenge.st===0){ + if (newprev_challenge.st === 0) { newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editcheckpoint"; - }else{ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; + } else { + newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; } } if (next_challenge != undefined) { - if(next_challenge.st===0){ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editcheckpoint"; - }else{ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editquestion"; + if (next_challenge.st === 0) { + next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id + "/editcheckpoint"; + } else { + next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id + "/editquestion"; } } this.setState({ - questionaddtype:false, - newquestionaddtype:false, - prev_challenge:newprev_challenge, - next_challenge:next_challenge, - questionsInputvalue:response.data.subject, - questionaddarray:response.data.chooses, - challenge_id:response.data.id, - mancheckpointId:checkpointId, + questionaddtype: false, + newquestionaddtype: false, + prev_challenge: newprev_challenge, + next_challenge: next_challenge, + questionsInputvalue: response.data.subject, + questionaddarray: response.data.chooses, + challenge_id: response.data.id, + mancheckpointId: checkpointId, position: response.data.position, choice_url: newchoice_url, practice_url: newpractice_url, go_back_url: newgo_back_url, - power:response.data.power, + power: response.data.power, // questioMD:response.data.task_pass, }) - this.setState({ - contentMdRefval:response.data.task_pass - }) - // this.contentMdRef.current.setValue(response.data.task_pass || '') - if(response.data.chooses.length===0){ + this.setState({ + contentMdRefval: response.data.task_pass + }) + // this.contentMdRef.current.setValue(response.data.task_pass || '') + if (response.data.chooses.length === 0) { this.questionadd() } this.shixunsautoHeight() @@ -267,35 +257,35 @@ export default class TPMquestion extends Component { console.log(error) }); - let zrl ='/shixuns/'+this.props.match.params.shixunId+'/challenges/'+this.props.match.params.checkpointId+'/edit_choose_question.json?choose_id='+this.props.match.params.choose_id; + let zrl = '/shixuns/' + this.props.match.params.shixunId + '/challenges/' + this.props.match.params.checkpointId + '/edit_choose_question.json?choose_id=' + this.props.match.params.choose_id; axios.get(zrl).then((response) => { - if(response.status===200){ - let choose_contents=response.data.choose_contents; - let newchoose_contentslist=[] - for(var i=0; i{ - this.setState({ - sumittype:true - }) - let checkpointId=this.props.match.params.checkpointId; - if(this.props.status===2&&checkpointId===undefined){ + clickquestionsumit = () => { + this.setState({ + sumittype: true + }) + let checkpointId = this.props.match.params.checkpointId; + if (this.props.status === 2 && checkpointId === undefined) { this.props.showSnackbar("该实训已经发布不能新建") this.setState({ - sumittype:false + sumittype: false }) return } - let {questionsInputvalue} =this.state; + let { questionsInputvalue } = this.state; // const exercise_editormdvalue = this.questio_editormd.getValue(); - const exercise_editormdvalue = this.contentMdRef.current.getValue().trim(); + const exercise_editormdvalue = this.contentMdRef.current.getValue().trim(); let id = this.props.match.params.shixunId; - if(questionsInputvalue===undefined||questionsInputvalue===null||questionsInputvalue===""){ + if (questionsInputvalue === undefined || questionsInputvalue === null || questionsInputvalue === "") { this.setState({ - questionInputvaluetype:true + questionInputvaluetype: true }) $('html').animate({ scrollTop: 10 }, 1000); this.setState({ - sumittype:false + sumittype: false }) return } - if(exercise_editormdvalue===null ||exercise_editormdvalue===""){ + if (exercise_editormdvalue === null || exercise_editormdvalue === "") { this.setState({ - questionInputvaluetypes:true + questionInputvaluetypes: true }) $('html').animate({ scrollTop: 500 }, 1000); this.setState({ - sumittype:false + sumittype: false }) return } - if(checkpointId===undefined){ + if (checkpointId === undefined) { let url = "/shixuns/" + id + "/challenges.json"; axios.post(url, { - identifier:id, + identifier: id, subject: questionsInputvalue, task_pass: exercise_editormdvalue, st: 1 @@ -370,29 +360,29 @@ export default class TPMquestion extends Component { // // this.questionadd() // } - window.location.href = '/shixuns/'+id+'/challenges/'+response.data.challenge_id+'/editquestion'; + window.location.href = '/shixuns/' + id + '/challenges/' + response.data.challenge_id + '/editquestion'; }).catch((error) => { console.log(error) }); - }else{ - let url ="/shixuns/"+id+"/challenges/"+checkpointId+".json"; + } else { + let url = "/shixuns/" + id + "/challenges/" + checkpointId + ".json"; axios.put(url, { - tab:0, + tab: 0, subject: questionsInputvalue, task_pass: exercise_editormdvalue, }).then((response) => { - if(response.data.status===1){ + if (response.data.status === 1) { this.setState({ - questionaddtype:false, - challenge_id:response.data.challenge_id + questionaddtype: false, + challenge_id: response.data.challenge_id }) } $('html').animate({ scrollTop: 10 }, 200); this.props.showSnackbar(response.data.messages); - window.location.href = '/shixuns/'+id+'/challenges/'+response.data.challenge_id+'/editquestion'; + window.location.href = '/shixuns/' + id + '/challenges/' + response.data.challenge_id + '/editquestion'; }).catch((error) => { console.log(error) }); @@ -400,126 +390,126 @@ export default class TPMquestion extends Component { } - questionall=()=>{ + questionall = () => { // this.setState({ // activetype:"first", // newquestionaddtype:false, // editquestionaddtype:false, - // questionaddtype:false + // questionaddtype:false // }) - window.location.href = '/shixuns/'+this.props.match.params.shixunId+'/challenges/'+this.props.match.params.checkpointId+'/editquestion'; + window.location.href = '/shixuns/' + this.props.match.params.shixunId + '/challenges/' + this.props.match.params.checkpointId + '/editquestion'; } - questionadd=()=>{ + questionadd = () => { - let{questionaddarray}=this.state; + let { questionaddarray } = this.state; - let questionaddsums=questionaddarray.length; + let questionaddsums = questionaddarray.length; - if(questionaddsums-1>9){ - this.props.showSnackbar("选择题目最大支持设置9道题") + if (questionaddsums - 1 > 9) { + this.props.showSnackbar("选择题目最大支持设置9道题") return } - let questionaddarrays=questionaddarray; + let questionaddarrays = questionaddarray; - questionaddarrays.map((item,key)=>{ - if(item.choose_id===0){ - questionaddarrays.splice(key,1) - } - }) + questionaddarrays.map((item, key) => { + if (item.choose_id === 0) { + questionaddarrays.splice(key, 1) + } + }) - questionaddarrays.push({type:0,choose_id:0}); + questionaddarrays.push({ type: 0, choose_id: 0 }); this.setState({ - activetype:0, - questionaddarray:questionaddarrays, - questionaddtype:true, - editquestionaddtype:false, - newquestionaddtype:true, - questionlists:[{str:"A",val:"",type:false},{str:"B",val:"",type:false},{str:"C",val:"",type:false},{str:"D",val:"",type:false}], + activetype: 0, + questionaddarray: questionaddarrays, + questionaddtype: true, + editquestionaddtype: false, + newquestionaddtype: true, + questionlists: [{ str: "A", val: "", type: false }, { str: "B", val: "", type: false }, { str: "C", val: "", type: false }, { str: "D", val: "", type: false }], answeshixunsGroup: 1, - answeoptions:[10,20], - answeonshixunsmark:10, - shixunssanswerkillvalue:"", - shixunsskillanswerlist:[], - contentMdRefval:"", - newquestioMDMdContval:"", + answeoptions: [10, 20], + answeonshixunsmark: 10, + shixunssanswerkillvalue: "", + shixunsskillanswerlist: [], + contentMdRefval: "", + newquestioMDMdContval: "", }) - setTimeout(() => { - this.newquestioMDMdRef.current.setValue('') - }, 1000) - setTimeout(() => { - this.newquestioMDMdCont.current.setValue('') - }, 1500) - // this.shixunsautoHeight() + setTimeout(() => { + this.newquestioMDMdRef.current.setValue('') + }, 1000) + setTimeout(() => { + this.newquestioMDMdCont.current.setValue('') + }, 1500) + // this.shixunsautoHeight() } - editquestionlists=(newquestionlists)=>{ - let newlist=newquestionlists; - let list=[] - for(var i=0; i { + let newlist = newquestionlists; + let list = [] + for (var i = 0; i < newlist.length; i++) { + if (newlist[i].type === true) { list.push(newlist[i].str) } } this.setState({ - questionlists:newquestionlists, - questionlistss:list + questionlists: newquestionlists, + questionlistss: list }) } - addquestionlists=()=>{ - let{questionlists} = this.state; - let newquestionlists=questionlists; - let newli={str:letterArr[questionlists.length],val:"",type:false}; + addquestionlists = () => { + let { questionlists } = this.state; + let newquestionlists = questionlists; + let newli = { str: letterArr[questionlists.length], val: "", type: false }; newquestionlists.push(newli); this.editquestionlists(newquestionlists); } - delquestionlists=(key)=>{ - let{questionlists} = this.state; - let newquestionlists=questionlists; - newquestionlists.splice(key,1); - for(var i=0; i { + let { questionlists } = this.state; + let newquestionlists = questionlists; + newquestionlists.splice(key, 1); + for (var i = 0; i < newquestionlists.length; i++) { + newquestionlists[i].str = letterArr[i]; } this.editquestionlists(newquestionlists); } - selquestionlists=(key)=>{ - let{questionlists} = this.state; - let newquestionlists=questionlists; - if(newquestionlists[key].type===true){ - newquestionlists[key].type=false; - }else if(newquestionlists[key].type===false){ - newquestionlists[key].type=true; + selquestionlists = (key) => { + let { questionlists } = this.state; + let newquestionlists = questionlists; + if (newquestionlists[key].type === true) { + newquestionlists[key].type = false; + } else if (newquestionlists[key].type === false) { + newquestionlists[key].type = true; } this.editquestionlists(newquestionlists); } - onshixunGroupanswe=(e)=> { + onshixunGroupanswe = (e) => { let optionsum; let onshixunsmark; - if(e.target.value===1){ - optionsum=[10,20]; - onshixunsmark=10; - }else if(e.target.value===2){ - optionsum=[30,40,50,60]; - onshixunsmark=30; - }else if(e.target.value===3){ - optionsum=[70,80,90,100] - onshixunsmark=70; + if (e.target.value === 1) { + optionsum = [10, 20]; + onshixunsmark = 10; + } else if (e.target.value === 2) { + optionsum = [30, 40, 50, 60]; + onshixunsmark = 30; + } else if (e.target.value === 3) { + optionsum = [70, 80, 90, 100] + onshixunsmark = 70; } this.setState({ answeshixunsGroup: e.target.value, - answeoptions:optionsum, - answeonshixunsmark:onshixunsmark + answeoptions: optionsum, + answeonshixunsmark: onshixunsmark }) } shixunssanswerkill = (e) => { @@ -530,14 +520,14 @@ export default class TPMquestion extends Component { } clickshixunsanswerskill = () => { - let {shixunssanswerkillvalue, shixunsskillanswerlist} = this.state; + let { shixunssanswerkillvalue, shixunsskillanswerlist } = this.state; if (shixunssanswerkillvalue === "") { return } else if (shixunssanswerkillvalue === undefined) { return } - if(shixunssanswerkillvalue == "" || shixunssanswerkillvalue == undefined || shixunssanswerkillvalue == null || (shixunssanswerkillvalue.length>0 && shixunssanswerkillvalue.trim().length == 0)){ + if (shixunssanswerkillvalue == "" || shixunssanswerkillvalue == undefined || shixunssanswerkillvalue == null || (shixunssanswerkillvalue.length > 0 && shixunssanswerkillvalue.trim().length == 0)) { message.error("输入为空,不能保存!"); return } @@ -549,129 +539,129 @@ export default class TPMquestion extends Component { shixunssanswerkillvalue: "" }) } - delshixunssnswerllist=(key)=>{ - let {shixunsskillanswerlist} = this.state; + delshixunssnswerllist = (key) => { + let { shixunsskillanswerlist } = this.state; let newshixunsskillanswerlist = shixunsskillanswerlist; newshixunsskillanswerlist.splice(key, 1); - this.setState({ + this.setState({ shixunsskillanswerlist: newshixunsskillanswerlist }) } - onInputoquestionption=(e,key)=>{ + onInputoquestionption = (e, key) => { - $.fn.autoHeight = function(){ - function autoHeight(elem){ + $.fn.autoHeight = function () { + function autoHeight(elem) { elem.style.height = 'auto'; elem.style.maxHeight = '140px'; elem.scrollTop = 0; //防抖动 elem.style.height = elem.scrollHeight + 'px'; } - this.each(function(){ + this.each(function () { autoHeight(this); - $(this).on('keyup', function(){ + $(this).on('keyup', function () { autoHeight(this); }); }); } - $("#"+e.target.id).autoHeight(); + $("#" + e.target.id).autoHeight(); - let {questionlists}=this.state; - let newquestionlists=questionlists; - newquestionlists[key].val=e.target.value; + let { questionlists } = this.state; + let newquestionlists = questionlists; + newquestionlists[key].val = e.target.value; this.editquestionlists(newquestionlists); } - onshixunsansweSelect=(value)=>{ + onshixunsansweSelect = (value) => { this.setState({ answeonshixunsmark: value }) } - answer_subit=(sumtype,challenge_choose_id)=>{ - $('html').animate({ - scrollTop:10 - }, 500); + answer_subit = (sumtype, challenge_choose_id) => { + $('html').animate({ + scrollTop: 10 + }, 500); - let {challenge_id,questionlists,shixunsskillanswerlist,answeonshixunsmark,answeshixunsGroup,questionaddarray} =this.state; - if(challenge_id===undefined){ + let { challenge_id, questionlists, shixunsskillanswerlist, answeonshixunsmark, answeshixunsGroup, questionaddarray } = this.state; + if (challenge_id === undefined) { message.error("关卡id为空"); return } - let newquestionlists=questionlists; - let newlist=""; - let newtype=[]; - let newcnt=[]; - let list=0; - for(var i=0; i { console.log(error) }); - }else{ + } else { - let newquestioMDvalue = this.newquestioMDMdRef.current.getValue().trim(); - if(newquestioMDvalue===""||newquestioMDvalue==="请输入选择题的题干内容"){ + let newquestioMDvalue = this.newquestioMDMdRef.current.getValue().trim(); + if (newquestioMDvalue === "" || newquestioMDvalue === "请输入选择题的题干内容") { this.setState({ - newquestioMDvaluetype:true, + newquestioMDvaluetype: true, }) $('html').animate({ - scrollTop:100 + scrollTop: 100 }, 200); message.error("题干为空"); return } let newnewanswerMDvalue = this.newquestioMDMdCont.current.getValue().trim(); - if(newnewanswerMDvalue===""||newnewanswerMDvalue===" "){ - newnewanswerMDvalue=undefined + if (newnewanswerMDvalue === "" || newnewanswerMDvalue === " ") { + newnewanswerMDvalue = undefined } - url="/shixuns/" + id + "/challenges/" + challenge_id + "/create_choose_question.json"; - axios.post(url, { - challenge_choose: {subject: newquestioMDvalue, answer: newnewanswerMDvalue, standard_answer:newlist , score: answeonshixunsmark, difficult: answeshixunsGroup}, + url = "/shixuns/" + id + "/challenges/" + challenge_id + "/create_choose_question.json"; + axios.post(url, { + challenge_choose: { subject: newquestioMDvalue, answer: newnewanswerMDvalue, standard_answer: newlist, score: answeonshixunsmark, difficult: answeshixunsGroup }, challenge_tag: shixunsskillanswerlist, - question: {cnt: newcnt}, - choice: {answer: newtype} + question: { cnt: newcnt }, + choice: { answer: newtype } }).then((response) => { - let questionaddsums=questionaddarray.length; - let questionaddarrays=questionaddarray; - questionaddarrays[questionaddsums-1].choose_id=response.data.challenge_choose_id; - if(newlist.length===1){ - questionaddarrays[questionaddsums-1].type=1; - }else if(newlist.length>1){ - questionaddarrays[questionaddsums-1].type=2; + let questionaddsums = questionaddarray.length; + let questionaddarrays = questionaddarray; + questionaddarrays[questionaddsums - 1].choose_id = response.data.challenge_choose_id; + if (newlist.length === 1) { + questionaddarrays[questionaddsums - 1].type = 1; + } else if (newlist.length > 1) { + questionaddarrays[questionaddsums - 1].type = 2; } this.setState({ - challenge_choose_id:response.data.challenge_choose_id, - questionaddtype:false, - editquestionaddtype:false, - newquestioMDvaluetype:false, - newquestioMDvaluetypes:false, - questionaddarray:questionaddarrays + challenge_choose_id: response.data.challenge_choose_id, + questionaddtype: false, + editquestionaddtype: false, + newquestioMDvaluetype: false, + newquestioMDvaluetypes: false, + questionaddarray: questionaddarrays }) $('html').animate({ scrollTop: 10 }, 200); - notification.open({ - message: '提示', - description: - '新建成功,请点击右侧加号继续添加', - }); - window.location.href=`/shixuns/${id}/challenges/${checkpointId}/editquestion/${response.data.challenge_choose_id}`; + notification.open({ + message: '提示', + description: + '新建成功,请点击右侧加号继续添加', + }); + window.location.href = `/shixuns/${id}/challenges/${checkpointId}/editquestion/${response.data.challenge_choose_id}`; - // this.getanswer_subitlist() + // this.getanswer_subitlist() // this.gochooseid("/shixuns/"+this.props.match.params.shixunId+"/challenges/"+this.props.match.params.checkpointId+"/editquestion"+"/"+response.data.challenge_choose_id) }).catch((error) => { console.log(error) @@ -794,65 +784,65 @@ export default class TPMquestion extends Component { } - questionlist=(key,challenge_choose_id,type)=>{ + questionlist = (key, challenge_choose_id, type) => { $('html').animate({ - scrollTop:10 + scrollTop: 10 }, 500); - let{challenge_id} =this.state; + let { challenge_id } = this.state; - if(challenge_choose_id===""||type===0){ + if (challenge_choose_id === "" || type === 0) { - // this.neweditanswerRef.current.setValue('') - // this.editanswersRef.current.setValue('') + // this.neweditanswerRef.current.setValue('') + // this.editanswersRef.current.setValue('') this.setState({ - activetype:challenge_choose_id, - editquestionaddtype:true, - questionaddtype:true, - newquestionaddtype:false, - questionlists:[{str:"A",val:"",type:false},{str:"B",val:"",type:false},{str:"C",val:"",type:false},{str:"D",val:"",type:false}], + activetype: challenge_choose_id, + editquestionaddtype: true, + questionaddtype: true, + newquestionaddtype: false, + questionlists: [{ str: "A", val: "", type: false }, { str: "B", val: "", type: false }, { str: "C", val: "", type: false }, { str: "D", val: "", type: false }], answeshixunsGroup: 1, - answeoptions:[10,20], - answeonshixunsmark:10, - shixunssanswerkillvalue:"", - shixunsskillanswerlist:[], - neweditanswerRefval:'', - editanswersRefval:'' + answeoptions: [10, 20], + answeonshixunsmark: 10, + shixunssanswerkillvalue: "", + shixunsskillanswerlist: [], + neweditanswerRefval: '', + editanswersRefval: '' }) - this.newquestioMDMdRef.current.setValue('') - this.newquestioMDMdCont.current.setValue('') - }else{ + this.newquestioMDMdRef.current.setValue('') + this.newquestioMDMdCont.current.setValue('') + } else { let id = this.props.match.params.shixunId; - let url ='/shixuns/'+id+'/challenges/'+challenge_id+'/edit_choose_question.json?choose_id='+challenge_choose_id; + let url = '/shixuns/' + id + '/challenges/' + challenge_id + '/edit_choose_question.json?choose_id=' + challenge_choose_id; axios.get(url).then((response) => { - if(response.status===200){ - let choose_contents=response.data.choose_contents; - let newchoose_contentslist=[] - for(var i=0; i{ - $.fn.autoHeight = function(){ - function autoHeight(elem){ - elem.style.height = 'auto'; - elem.style.maxHeight = '140px'; - elem.scrollTop = 0; //防抖动 - if(elem.scrollHeight===0){ - elem.style.height = 62 + 'px'; - }else{ + shixunsautoHeight = () => { + $.fn.autoHeight = function () { + function autoHeight(elem) { + elem.style.height = 'auto'; + elem.style.maxHeight = '140px'; + elem.scrollTop = 0; //防抖动 + if (elem.scrollHeight === 0) { + elem.style.height = 62 + 'px'; + } else { + + elem.style.height = elem.scrollHeight + 'px'; + } - elem.style.height = elem.scrollHeight + 'px'; } - - } - this.each(function(){ - autoHeight(this); - $(this).on('keyup', function(){ + this.each(function () { autoHeight(this); + $(this).on('keyup', function () { + autoHeight(this); + }); }); - }); - } - $('textarea[autoHeight]').autoHeight(); + } + $('textarea[autoHeight]').autoHeight(); } - gochooseid=(url)=>{ - window.location.href =url - // window.location.Reload(url) - // this.props.history.replace( url ); - // this.props.history.push( url ); - // 返回 - // this.props.history.goBack(); + gochooseid = (url) => { + window.location.href = url + // window.location.Reload(url) + // this.props.history.replace( url ); + // this.props.history.push( url ); + // 返回 + // this.props.history.goBack(); } render() { - let {choice_url, + let { choice_url, practice_url, go_back_url, position, @@ -914,7 +904,7 @@ export default class TPMquestion extends Component { next_challenge, answer, - } = this.state; + } = this.state; let options; @@ -929,51 +919,51 @@ export default class TPMquestion extends Component {
    - - - + + + 第{position}关 返回 - { prev_challenge===undefined?"": + className="color-grey-6 fr font-15 mt3">返回 + {prev_challenge === undefined ? "" : 上一关 } - { next_challenge===undefined?"": - 下一关 + {next_challenge === undefined ? "" : + 下一关 } 4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"none":'block'}} - data-tip-down="新增代码编辑类型的任务">+ 实践类型 + className="fr color-blue mr15 mt4" + style={{ display: this.props.identity > 4 || this.props.identity === undefined || this.props.status === 2 || this.props.status === 1 ? "none" : 'block' }} + data-tip-down="新增代码编辑类型的任务">+ 实践类型 4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"none":'block'}} - data-tip-down="新增选择题类型的任务">+ 选择题类型 + style={{ display: this.props.identity > 4 || this.props.identity === undefined || this.props.status === 2 || this.props.status === 1 ? "none" : 'block' }} + data-tip-down="新增选择题类型的任务">+ 选择题类型
    - -
  • - 本关任务 -
  • -
    + +
  • + 本关任务 +
  • +
    { - questionaddarray.length===0?"":questionaddarray.map((item,key)=>{ - return( + questionaddarray.length === 0 ? "" : questionaddarray.map((item, key) => { + return (
  • this.questionlist(key,item.choose_id,item.type):""} + className={parseInt(activetype) === item.choose_id ? "click_active active" : ""} + onClick={parseInt(activetype) === item.choose_id ? () => this.questionlist(key, item.choose_id, item.type) : ""} > { - item.choose_id!=0? - this.gochooseid("/shixuns/"+this.props.match.params.shixunId+"/challenges/"+this.props.match.params.checkpointId+"/editquestion"+"/"+item.choose_id)}> - {key+1}.{item.type===2?"多选题":item.type===1?"单选题":'选择题'} - :activetype==="first"?"":{key+1}.{item.type===2?"多选题":item.type===1?"单选题":'选择题'} + item.choose_id != 0 ? + this.gochooseid("/shixuns/" + this.props.match.params.shixunId + "/challenges/" + this.props.match.params.checkpointId + "/editquestion" + "/" + item.choose_id)}> + {key + 1}.{item.type === 2 ? "多选题" : item.type === 1 ? "单选题" : '选择题'} + : activetype === "first" ? "" : {key + 1}.{item.type === 2 ? "多选题" : item.type === 1 ? "单选题" : '选择题'} }
  • @@ -983,66 +973,66 @@ export default class TPMquestion extends Component {
  • + style={{ display: questionaddtype === true || this.props.status === 2 ? "none" : "block" }}> - + + +
  • - {/*x选择题首页*/} - {activetype==="first"?this.questionInputvalue(e)} - clickquestionsumit={(e)=>this.clickquestionsumit(e)} + {/*x选择题首页*/} + {activetype === "first" ? this.questionInputvalue(e)} + clickquestionsumit={(e) => this.clickquestionsumit(e)} - />:""} + /> : ""} {/*新建*/} - {newquestionaddtype===true? - this.selquestionlists(key)} - onInputoquestionption={(e,key)=>this.onInputoquestionption(e,key)} - delquestionlists={(key)=>this.delquestionlists(key)} - addquestionlists={(e)=>this.addquestionlists(e)} - onshixunGroupanswe={(e)=>this.onshixunGroupanswe(e)} - onshixunsansweSelect={(e)=>this.onshixunsansweSelect(e)} - shixunssanswerkill={(e)=>this.shixunssanswerkill(e)} - clickshixunsanswerskill={(e)=>this.clickshixunsanswerskill(e)} - delshixunssnswerllist={(key)=>this.delshixunssnswerllist(key)} - answer_subit={()=>this.answer_subit()} - />:""} - - - {/*修改*/} - {editquestionaddtype===true? - this.selquestionlists(key)} - onInputoquestionption={(e,key)=>this.onInputoquestionption(e,key)} - delquestionlists={(key)=>this.delquestionlists(key)} - addquestionlists={(e)=>this.addquestionlists(e)} - onshixunGroupanswe={(e)=>this.onshixunGroupanswe(e)} - onshixunsansweSelect={(e)=>this.onshixunsansweSelect(e)} - shixunssanswerkill={(e)=>this.shixunssanswerkill(e)} - clickshixunsanswerskill={(e)=>this.clickshixunsanswerskill(e)} - delshixunssnswerllist={(key)=>this.delshixunssnswerllist(key)} - answer_subit={()=>this.answer_subit("edit",challenge_choose_id)} - /> - :""} + {newquestionaddtype === true ? + this.selquestionlists(key)} + onInputoquestionption={(e, key) => this.onInputoquestionption(e, key)} + delquestionlists={(key) => this.delquestionlists(key)} + addquestionlists={(e) => this.addquestionlists(e)} + onshixunGroupanswe={(e) => this.onshixunGroupanswe(e)} + onshixunsansweSelect={(e) => this.onshixunsansweSelect(e)} + shixunssanswerkill={(e) => this.shixunssanswerkill(e)} + clickshixunsanswerskill={(e) => this.clickshixunsanswerskill(e)} + delshixunssnswerllist={(key) => this.delshixunssnswerllist(key)} + answer_subit={() => this.answer_subit()} + /> : ""} + + + {/*修改*/} + {editquestionaddtype === true ? + this.selquestionlists(key)} + onInputoquestionption={(e, key) => this.onInputoquestionption(e, key)} + delquestionlists={(key) => this.delquestionlists(key)} + addquestionlists={(e) => this.addquestionlists(e)} + onshixunGroupanswe={(e) => this.onshixunGroupanswe(e)} + onshixunsansweSelect={(e) => this.onshixunsansweSelect(e)} + shixunssanswerkill={(e) => this.shixunssanswerkill(e)} + clickshixunsanswerskill={(e) => this.clickshixunsanswerskill(e)} + delshixunssnswerllist={(key) => this.delshixunssnswerllist(key)} + answer_subit={() => this.answer_subit("edit", challenge_choose_id)} + /> + : ""}
    diff --git a/public/react/src/modules/tpm/challengesnew/old/TPMchallengesnew.js b/public/react/src/modules/tpm/challengesnew/old/TPMchallengesnew.js index 6dfc04eef..6451b151a 100644 --- a/public/react/src/modules/tpm/challengesnew/old/TPMchallengesnew.js +++ b/public/react/src/modules/tpm/challengesnew/old/TPMchallengesnew.js @@ -1,10 +1,8 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal} from 'antd'; +import { Input, Select, Radio, message } from 'antd'; -import {BrowserRouter as Router, Route, Link, Switch} from "react-router-dom"; - -// import "antd/dist/antd.css"; +import { Link } from "react-router-dom"; import TPMMDEditor from '../TPMMDEditor'; @@ -12,19 +10,13 @@ import axios from 'axios'; import '../css/TPMchallengesnew.css'; -import { getImageUrl, toPath } from 'educoder'; - -import {getUrl} from 'educoder'; +import { getImageUrl } from 'educoder'; -let origin = getUrl(); +import { getUrl } from 'educoder'; -let path = getUrl("/editormd/lib/") const $ = window.$; -let timeout; - -let currentValue; const Option = Select.Option; @@ -33,7 +25,7 @@ const RadioGroup = Radio.Group; export default class TPMchallengesnew extends Component { constructor(props) { super(props) - this.exercisememoMDRef=React.createRef(); + this.exercisememoMDRef = React.createRef(); this.state = { choice_url: undefined, practice_url: undefined, @@ -41,8 +33,8 @@ export default class TPMchallengesnew extends Component { task_pass_default: undefined, submit_url: undefined, shixunCreatePracticeGroup: 1, - optionsums:[100,200], - activetype:0, + optionsums: [100, 200], + activetype: 0, setopen: false, shixunCreatePractice: undefined, onshixunsmarkvalue: 100, @@ -50,28 +42,28 @@ export default class TPMchallengesnew extends Component { shixunsskillvaluelist: [], tab2url: "", tab3url: "", - prev_challenge:undefined, - next_challenge:undefined, + prev_challenge: undefined, + next_challenge: undefined, power: false, shixunCreatePracticetype: false, shixunsskillvaluelisttype: false, - marktype:false, - editPracticesendtype:false, - CreatePracticesendtype:false, - exec_time:20, - shixunExec_timeType:false + marktype: false, + editPracticesendtype: false, + CreatePracticesendtype: false, + exec_time: 20, + shixunExec_timeType: false } } componentDidMount() { let id = this.props.match.params.shixunId; - let checkpointId=this.props.match.params.checkpointId; + let checkpointId = this.props.match.params.checkpointId; - let newchoice_url= "/shixuns/"+id+"/challenges/newquestion"; - let newpractice_url= "/shixuns/"+id+"/challenges/new"; - let newgo_back_url="/shixuns/"+id+"/challenges" - if(checkpointId===undefined){ + let newchoice_url = "/shixuns/" + id + "/challenges/newquestion"; + let newpractice_url = "/shixuns/" + id + "/challenges/new"; + let newgo_back_url = "/shixuns/" + id + "/challenges" + if (checkpointId === undefined) { //新建模式 let url = "/shixuns/" + id + "/challenges/new.json" axios.get(url).then((response) => { @@ -82,67 +74,67 @@ export default class TPMchallengesnew extends Component { position: response.data.position, task_pass_default: response.data.task_pass_default, submit_url: response.data.submit_url, - checkpointId:checkpointId, - exercisememoMDRefval:response.data.task_pass_default + checkpointId: checkpointId, + exercisememoMDRefval: response.data.task_pass_default }) - this.exercisememoMDRef.current.setValue(response.data.task_pass_default||'') + this.exercisememoMDRef.current.setValue(response.data.task_pass_default || '') }).catch((error) => { console.log(error) }); - }else{ + } else { //编辑模式 - let url="/shixuns/"+id+"/challenges/"+checkpointId+".json?tab=0"; + let url = "/shixuns/" + id + "/challenges/" + checkpointId + ".json?tab=0"; axios.get(url).then((response) => { let optionsum; - if(response.data.difficulty===1){ - optionsum=[100,200]; - }else if(response.data.difficulty===2){ - optionsum=[300,400,500,600]; - }else if(response.data.difficulty===3){ - optionsum=[700,800,900,1000] + if (response.data.difficulty === 1) { + optionsum = [100, 200]; + } else if (response.data.difficulty === 2) { + optionsum = [300, 400, 500, 600]; + } else if (response.data.difficulty === 3) { + optionsum = [700, 800, 900, 1000] } - let newprev_challenge=response.data.prev_challenge; - let next_challenge=response.data.next_challenge; + let newprev_challenge = response.data.prev_challenge; + let next_challenge = response.data.next_challenge; if (newprev_challenge != undefined) { - if(newprev_challenge.st===0){ + if (newprev_challenge.st === 0) { newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editcheckpoint"; - }else{ - newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; + } else { + newprev_challenge = "/shixuns/" + id + "/challenges/" + newprev_challenge.id + "/editquestion"; } } if (next_challenge != undefined) { - if(next_challenge.st===0){ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editcheckpoint"; - }else{ - next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id+ "/editquestion"; + if (next_challenge.st === 0) { + next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id + "/editcheckpoint"; + } else { + next_challenge = "/shixuns/" + id + "/challenges/" + next_challenge.id + "/editquestion"; } } this.setState({ power: response.data.power, - prev_challenge:newprev_challenge, - next_challenge:next_challenge, + prev_challenge: newprev_challenge, + next_challenge: next_challenge, choice_url: newchoice_url, practice_url: newpractice_url, go_back_url: newgo_back_url, - shixunCreatePractice:response.data.subject, - position:response.data.position, - shixunCreatePracticeGroup:response.data.difficulty, - optionsums:optionsum, - onshixunsmarkvalue:response.data.score, - shixunsskillvaluelist:response.data.tags, - checkpointId:checkpointId, - exec_time:response.data.exec_time, - tab2url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=2", - tab3url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=3", - exercisememoMDRefval:response.data.task_pass + shixunCreatePractice: response.data.subject, + position: response.data.position, + shixunCreatePracticeGroup: response.data.difficulty, + optionsums: optionsum, + onshixunsmarkvalue: response.data.score, + shixunsskillvaluelist: response.data.tags, + checkpointId: checkpointId, + exec_time: response.data.exec_time, + tab2url: "/shixuns/" + id + "/challenges/" + checkpointId + "/tab=2", + tab3url: "/shixuns/" + id + "/challenges/" + checkpointId + "/tab=3", + exercisememoMDRefval: response.data.task_pass }) - if(response.data.power===false){ + if (response.data.power === false) { this.props.showSnackbar("你没有权限修改"); } - this.exercisememoMDRef.current.setValue(response.data.task_pass||'') + this.exercisememoMDRef.current.setValue(response.data.task_pass || '') }).catch((error) => { console.log(error) }); @@ -154,20 +146,20 @@ export default class TPMchallengesnew extends Component { onshixunCreatePracticeChange = (e) => { let optionsum; let onshixunsmark; - if(e.target.value===1){ - optionsum=[100,200]; - onshixunsmark=100; - }else if(e.target.value===2){ - optionsum=[300,400,500,600]; - onshixunsmark=300; - }else if(e.target.value===3){ - optionsum=[700,800,900,1000] - onshixunsmark=700; + if (e.target.value === 1) { + optionsum = [100, 200]; + onshixunsmark = 100; + } else if (e.target.value === 2) { + optionsum = [300, 400, 500, 600]; + onshixunsmark = 300; + } else if (e.target.value === 3) { + optionsum = [700, 800, 900, 1000] + onshixunsmark = 700; } this.setState({ shixunCreatePracticeGroup: e.target.value, - optionsums:optionsum, - onshixunsmarkvalue:onshixunsmark + optionsums: optionsum, + onshixunsmarkvalue: onshixunsmark }) } @@ -180,48 +172,48 @@ export default class TPMchallengesnew extends Component { CreatePracticesend = () => { - this.setState({ - CreatePracticesendtype:true - }) + this.setState({ + CreatePracticesendtype: true + }) - if(this.props.status===2){ + if (this.props.status === 2) { this.props.showSnackbar("该实训已经发布不能新建") this.setState({ - CreatePracticesendtype:false + CreatePracticesendtype: false }) return } - let {shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvaluelist,exec_time} = this.state; - if (shixunCreatePractice === undefined||shixunCreatePractice=="") { + let { shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvaluelist, exec_time } = this.state; + if (shixunCreatePractice === undefined || shixunCreatePractice == "") { this.setState({ shixunCreatePracticetype: true }) this.props.showSnackbar("任务名称为空") - $('html').animate({ + $('html').animate({ scrollTop: 10 }, 1000); - this.setState({ - CreatePracticesendtype:false - }) + this.setState({ + CreatePracticesendtype: false + }) return } if (shixunsskillvaluelist.length === 0) { this.setState({ shixunsskillvaluelisttype: true, - CreatePracticesendtype:false + CreatePracticesendtype: false }) this.props.showSnackbar("技能标签为空") return } - if(exec_time===null||exec_time===undefined||exec_time===""){ + if (exec_time === null || exec_time === undefined || exec_time === "") { - this.setState({ - shixunExec_timeType:false - }) - return - } + this.setState({ + shixunExec_timeType: false + }) + return + } const exercise_editormdvalue = this.exercisememoMDRef.current.getValue().trim(); let id = this.props.match.params.shixunId; @@ -229,28 +221,28 @@ export default class TPMchallengesnew extends Component { let url = "/shixuns/" + id + "/challenges.json"; axios.post(url, { - identifier:id, + identifier: id, subject: shixunCreatePractice, task_pass: exercise_editormdvalue, difficulty: shixunCreatePracticeGroup, score: onshixunsmarkvalue, challenge_tag: shixunsskillvaluelist, st: 0, - exec_time:exec_time + exec_time: exec_time }).then((response) => { if (response.data.status === 1) { - // $("html").animate({ scrollTop: 0 }) - //window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/editcheckpoint?tab=2`; - window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/tab=2`; - // this.setState({ - // setopen: true, - // CreatePracticesendtype:false, - // tab2url: "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=2", - // tab3url: "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=3", - // }) + // $("html").animate({ scrollTop: 0 }) + //window.location.href=`/shixuns/${id}/challenges/${response.data.challenge_id}/editcheckpoint?tab=2`; + window.location.href = `/shixuns/${id}/challenges/${response.data.challenge_id}/tab=2`; + // this.setState({ + // setopen: true, + // CreatePracticesendtype:false, + // tab2url: "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=2", + // tab3url: "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=3", + // }) } - // this.props.showSnackbar(response.data.messages); + // this.props.showSnackbar(response.data.messages); }).catch((error) => { console.log(error) }); @@ -273,19 +265,19 @@ export default class TPMchallengesnew extends Component { clickshixunsskill = () => { - let {shixunsskillvalue, shixunsskillvaluelist} = this.state; + let { shixunsskillvalue, shixunsskillvaluelist } = this.state; if (shixunsskillvalue === "") { return } else if (shixunsskillvalue === undefined) { return } - if(shixunsskillvalue == "" || shixunsskillvalue == undefined || shixunsskillvalue == null || (shixunsskillvalue.length>0 && shixunsskillvalue.trim().length == 0)){ + if (shixunsskillvalue == "" || shixunsskillvalue == undefined || shixunsskillvalue == null || (shixunsskillvalue.length > 0 && shixunsskillvalue.trim().length == 0)) { message.error("输入为空,不能保存!"); return } - let list = shixunsskillvaluelist; + let list = shixunsskillvaluelist; list.push(shixunsskillvalue); this.setState({ shixunsskillvaluelist: list, @@ -294,7 +286,7 @@ export default class TPMchallengesnew extends Component { } delshixunsskilllist = (key) => { - let {shixunsskillvaluelist} = this.state; + let { shixunsskillvaluelist } = this.state; let newshixunsskillvaluelist = shixunsskillvaluelist; newshixunsskillvaluelist.splice(key, 1); this.setState({ @@ -302,21 +294,21 @@ export default class TPMchallengesnew extends Component { }) } - editPracticesend=()=>{ + editPracticesend = () => { this.setState({ - editPracticesendtype:true + editPracticesendtype: true }) - let {shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvaluelist,checkpointId,exec_time} = this.state; + let { shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvaluelist, checkpointId, exec_time } = this.state; - const exercise_editormdvalue = this.exercisememoMDRef.current.getValue().trim(); + const exercise_editormdvalue = this.exercisememoMDRef.current.getValue().trim(); let id = this.props.match.params.shixunId; - let url = "/shixuns/"+id+"/challenges/"+checkpointId+".json"; + let url = "/shixuns/" + id + "/challenges/" + checkpointId + ".json"; - if (shixunCreatePractice === undefined||shixunCreatePractice=="") { + if (shixunCreatePractice === undefined || shixunCreatePractice == "") { // this.setState({ // shixunCreatePracticetype: true // }) @@ -325,7 +317,7 @@ export default class TPMchallengesnew extends Component { scrollTop: 10 }, 1000); this.setState({ - editPracticesendtype:false + editPracticesendtype: false }) return } @@ -336,39 +328,39 @@ export default class TPMchallengesnew extends Component { // }) this.props.showSnackbar("技能标签为空") this.setState({ - editPracticesendtype:false + editPracticesendtype: false }) return } - if(exec_time===null||exec_time===undefined||exec_time===""){ + if (exec_time === null || exec_time === undefined || exec_time === "") { - this.setState({ - shixunExec_timeType:false - }) - return - } + this.setState({ + shixunExec_timeType: false + }) + return + } axios.put(url, { - tab:0, - identifier:id, - id:checkpointId, - challenge:{ + tab: 0, + identifier: id, + id: checkpointId, + challenge: { subject: shixunCreatePractice, task_pass: exercise_editormdvalue, difficulty: shixunCreatePracticeGroup, score: onshixunsmarkvalue, - exec_time:exec_time + exec_time: exec_time }, - challenge_tag:shixunsskillvaluelist + challenge_tag: shixunsskillvaluelist }).then((response) => { this.props.showSnackbar(response.data.messages); if (response.data.status === 1) { - window.location.href=`/shixuns/${id}/challenges/${checkpointId}/tab=2`; + window.location.href = `/shixuns/${id}/challenges/${checkpointId}/tab=2`; this.setState({ setopen: true, - editPracticesendtype:false, - tab2url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=2", - tab3url: "/shixuns/" + id + "/challenges/"+checkpointId+"/tab=3", + editPracticesendtype: false, + tab2url: "/shixuns/" + id + "/challenges/" + checkpointId + "/tab=2", + tab3url: "/shixuns/" + id + "/challenges/" + checkpointId + "/tab=3", }) // window.location.href = "/shixuns/" + id + "/challenges/"+response.data.challenge_id+"/tab=2" } @@ -379,59 +371,59 @@ export default class TPMchallengesnew extends Component { } - onshixunsmarks=()=> { + onshixunsmarks = () => { this.setState({ - marktype:true + marktype: true }) } - onshixunsmarkss=()=> { + onshixunsmarkss = () => { this.setState({ - marktype:false + marktype: false }) } - setexec_time=(e)=>{ - this.setState({ - exec_time:e.target.value - }) - } + setexec_time = (e) => { + this.setState({ + exec_time: e.target.value + }) + } render() { let shixuntype = this.props.match.params.type; - let {marktype, + let { marktype, shixunCreatePracticetype, shixunsskillvaluelisttype, - choice_url, practice_url, go_back_url, position, task_pass_default, submit_url, setopen,checkpointId,prev_challenge,next_challenge,power, - shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvalue, shixunsskillvaluelist, tab2url, tab3url,optionsums, - CreatePracticesendtype,editPracticesendtype + choice_url, practice_url, go_back_url, position, task_pass_default, submit_url, setopen, checkpointId, prev_challenge, next_challenge, power, + shixunCreatePractice, shixunCreatePracticeGroup, onshixunsmarkvalue, shixunsskillvalue, shixunsskillvaluelist, tab2url, tab3url, optionsums, + CreatePracticesendtype, editPracticesendtype } = this.state; let options; - if(optionsums!=undefined){ - options = optionsums.map((d, k) => { - return ( - - ) - }) - } + if (optionsums != undefined) { + options = optionsums.map((d, k) => { + return ( + + ) + }) + } return (
    - + 第{position}关 返回 - { next_challenge===undefined?"": - 下一关 - } - { prev_challenge===undefined?"": + className="color-grey-6 fr font-15 mt3">返回 + {next_challenge === undefined ? "" : + 下一关 + } + {prev_challenge === undefined ? "" : 上一关 } @@ -439,14 +431,14 @@ export default class TPMchallengesnew extends Component { 4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"none":'block'}} - data-tip-down="新增代码编辑类型的任务">+ 实践类型 + className="fr color-blue mr15 mt4" + style={{ display: this.props.identity > 4 || this.props.identity === undefined || this.props.status === 2 || this.props.status === 1 ? "none" : 'block' }} + data-tip-down="新增代码编辑类型的任务">+ 实践类型 4||this.props.identity===undefined||this.props.status===2||this.props.status===1?"none":'block'}} - data-tip-down="新增选择题类型的任务">+ 选择题类型 + className="fr color-blue mr15 mt4" + style={{ display: this.props.identity > 4 || this.props.identity === undefined || this.props.status === 2 || this.props.status === 1 ? "none" : 'block' }} + data-tip-down="新增选择题类型的任务">+ 选择题类型
    @@ -473,19 +465,19 @@ export default class TPMchallengesnew extends Component { *
    + // className="input-100-45 greyInput" + className={shixunCreatePracticetype === true ? "input-100-45 greyInpus wind100" : "input-100-45 greyInput "} + maxLength="50" + name="challenge[subject]" + value={shixunCreatePractice} + onInput={this.shixunCreatePractice} + placeholder="请输入任务名称(此信息将提前展示给学员),例:计算学生的课程成绩绩点" />
    -
    - 必填项 +
    + 必填项
    @@ -496,8 +488,8 @@ export default class TPMchallengesnew extends Component {

    过关任务

    - +

    @@ -509,8 +501,8 @@ export default class TPMchallengesnew extends Component {
    + disabled={this.props.status === 2 ? true : false} + onChange={this.props.status === 2 ? "" : this.onshixunCreatePracticeChange}> 简单 中等 困难 @@ -519,24 +511,24 @@ export default class TPMchallengesnew extends Component {

    奖励经验值

    + // onMouseLeave={this.props.status===2?"":this.onshixunsmarkss} + > * - triggerNode.parentNode} > {options}

    - 如果学员答题错误,则不能得到相应的经验值
    + 如果学员答题错误,则不能得到相应的经验值
    如果学员成功得到经验值,那么将同时获得等值的金币奖励,如:+10经验值、+10金币

    @@ -552,21 +544,21 @@ export default class TPMchallengesnew extends Component { *
    {/*+ 添加*/} + {/*onClick={this.clickshixunsskill}>+ 添加*/}
    学员答题正确将获得技能,否则不能获得技能
    { - shixunsskillvaluelist===undefined?"":shixunsskillvaluelist.length === 0 ? "" : shixunsskillvaluelist.map((itme, key) => { + shixunsskillvaluelist === undefined ? "" : shixunsskillvaluelist.length === 0 ? "" : shixunsskillvaluelist.map((itme, key) => { return (
  • {itme} this.delshixunsskilllist(key)}>× @@ -581,32 +573,32 @@ export default class TPMchallengesnew extends Component { - 必填项 + 必填项
  • -
    -

    服务配置

    -
    - * - -
    - -
    - 必填项 -
    -
    -
    +
    +

    服务配置

    +
    + * + +
    + +
    + 必填项 +
    +
    +
    4||this.props.identity===undefined?"none":'block'}} + style={{ display: this.props.identity > 4 || this.props.identity === undefined ? "none" : 'block' }} > - {checkpointId===undefined?提交: - 提交} - {/*取消*/} - 取消 + {checkpointId === undefined ? 提交 : + 提交} + {/*取消*/} + 取消
    diff --git a/public/react/src/modules/user/account/ChangeHeaderPicModal.js b/public/react/src/modules/user/account/ChangeHeaderPicModal.js index 0a2205261..cec3d06a7 100644 --- a/public/react/src/modules/user/account/ChangeHeaderPicModal.js +++ b/public/react/src/modules/user/account/ChangeHeaderPicModal.js @@ -1,18 +1,15 @@ import React, { Component } from "react"; -import { Spin } from "antd"; import axios from 'axios' import ModalWrapper from "../../courses/common/ModalWrapper" import { Cropper, getUrl } from 'educoder' const imageId = 'changeHeaderPic' const previewId = 'changeHeader_imagePreview' -let uploadedImageType; -let uploadedImageName; let uploadedImageURL; -class ChangeHeaderPicModal extends Component{ - constructor(props){ +class ChangeHeaderPicModal extends Component { + constructor(props) { super(props); - this.state={ + this.state = { uploading: false } } @@ -29,7 +26,7 @@ class ChangeHeaderPicModal extends Component{ if (/^image\/\w+/.test(file.type)) { if (file.size > 2 * 1024 * 1024) { - this.props.showNotification && this.props.showNotification("仅支持文件大小小于2M的文件") + this.props.showNotification && this.props.showNotification("仅支持文件大小小于2M的文件") return; } uploadedImageType = file.type; @@ -38,28 +35,28 @@ class ChangeHeaderPicModal extends Component{ if (uploadedImageURL) { URL.revokeObjectURL(uploadedImageURL); } - const image = document.getElementById( imageId ); + const image = document.getElementById(imageId); // base64 var reader = new FileReader(); reader.readAsBinaryString(file); reader.onload = () => { - let base64_content = btoa(reader.result); - console.log(); - - image.src = `data:${file.type};base64,${base64_content}` // uploadedImageURL = URL.createObjectURL(file); - that.fileUploaded = true; - that.refs['cropper'].renew(image) - // cropper.destroy(); - // cropper = new Cropper(image, options); - inputImage.value = null; + let base64_content = btoa(reader.result); + console.log(); + + image.src = `data:${file.type};base64,${base64_content}` // uploadedImageURL = URL.createObjectURL(file); + that.fileUploaded = true; + that.refs['cropper'].renew(image) + // cropper.destroy(); + // cropper = new Cropper(image, options); + inputImage.value = null; }; - reader.onerror = function() { - console.log('there are some problems'); + reader.onerror = function () { + console.log('there are some problems'); }; - + } else { this.props.showNotification && this.props.showNotification("请选择一个图片格式的文件") // window.alert('Please choose an image file.'); @@ -82,7 +79,7 @@ class ChangeHeaderPicModal extends Component{ } onSendOk = () => { - + } onOk = () => { @@ -97,44 +94,44 @@ class ChangeHeaderPicModal extends Component{ console.log(new Date().getTime()) this._onOk() }, 10) - + }) } _onOk = () => { - - var img_lg = document.getElementById(previewId); + + var img_lg = document.getElementById(previewId); // https://github.com/niklasvh/html2canvas/issues/1908 // 截图小的显示框内的内容 window.html2canvas(img_lg).then((canvas) => { - var dataUrl = canvas.toDataURL("image/jpeg"); - console.log(dataUrl) + var dataUrl = canvas.toDataURL("image/jpeg"); + console.log(dataUrl) const url = `/users/accounts/${this.props.userLogin}/avatar.json` - axios.put(url, { + axios.put(url, { image: dataUrl }) - .then((response) => { - // {"status":0,"message":"success","avatar_url":"avatars/User/15739"} - if (response.data.status == 0) { - // this.props.getBasicInfo() - // https://www.trustie.net/issues/22461 - if ( this.props.current_user.image_url.indexOf('avatars/User/b') != -1 - || this.props.current_user.image_url.indexOf('avatars/User/g') != -1 ) { - window.setTimeout(() => { - this.doAfterUpdated() - }, 1000) - } else { - this.doAfterUpdated(); + .then((response) => { + // {"status":0,"message":"success","avatar_url":"avatars/User/15739"} + if (response.data.status == 0) { + // this.props.getBasicInfo() + // https://www.trustie.net/issues/22461 + if (this.props.current_user.image_url.indexOf('avatars/User/b') != -1 + || this.props.current_user.image_url.indexOf('avatars/User/g') != -1) { + window.setTimeout(() => { + this.doAfterUpdated() + }, 1000) + } else { + this.doAfterUpdated(); + } + this.setState({ uploading: false }) } + }) + .catch(function (error) { this.setState({ uploading: false }) - } - }) - .catch(function (error) { - this.setState({ uploading: false }) - console.log(error); - }); - }); + console.log(error); + }); + }); } doAfterUpdated = () => { this.props.fetchUser() @@ -143,15 +140,14 @@ class ChangeHeaderPicModal extends Component{ this.setVisible(false) } - render(){ - const { course_lists } = this.state - const { moduleName, current_user } = this.props + render() { + const { current_user } = this.props const userHeaderImgUrl = current_user ? `${getUrl()}/images/${current_user.image_url}` : '' - return( + return (
    -
    - - 仅支持JPG、GIF、PNG,且文件小于2M +
    + + 仅支持JPG、GIF、PNG,且文件小于2M +
    +
    +
    +
    + {userHeaderImgUrl && } +
    +
    头像预览
    -
    -
    -
    - {userHeaderImgUrl && } -
    -
    头像预览
    -
    -
    +
    ) diff --git a/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js index 70994e42d..0e60ddcc5 100644 --- a/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js +++ b/public/react/src/modules/user/usersInfo/banks/NewGtaskForm.js @@ -1,17 +1,17 @@ -import React,{ Component } from "react"; +import React, { Component } from "react"; import { Input, InputNumber, Form, Button, Checkbox, Upload, Icon, message, Modal } from "antd"; import axios from 'axios' -import { getUploadActionUrl, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder' +import { getUploadActionUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder' import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor'; const $ = window.$; const MAX_TITLE_LENGTH = 60; -class NewGtaskForms extends Component{ - constructor(props){ +class NewGtaskForms extends Component { + constructor(props) { super(props); this.contentMdRef = React.createRef(); - this.state={ - title_num:0, - description:"", + this.state = { + title_num: 0, + description: "", contentFileList: [], } } @@ -19,7 +19,7 @@ class NewGtaskForms extends Component{ initValue = (data) => { - if (data.isEdit===true) { + if (data.isEdit === true) { const contentFileList = data.attachments.map(item => { return { id: item.id, @@ -32,10 +32,10 @@ class NewGtaskForms extends Component{ }) this.setState({ ...data, - base_on_project: data.task_type===2?data.group_info.base_on_project:undefined, + base_on_project: data.task_type === 2 ? data.group_info.base_on_project : undefined, title_num: parseInt(data.name.length), - min_num: data.task_type===2?data.group_info.min_number:undefined, - max_num: data.task_type===2?data.group_info.max_number:undefined, + min_num: data.task_type === 2 ? data.group_info.min_number : undefined, + max_num: data.task_type === 2 ? data.group_info.max_number : undefined, contentFileList, }, () => { setTimeout(() => { @@ -55,7 +55,7 @@ class NewGtaskForms extends Component{ // 输入title - changeTitle=(e)=>{ + changeTitle = (e) => { console.log(e.target.value.length); this.setState({ title_num: parseInt(e.target.value.length) @@ -69,7 +69,7 @@ class NewGtaskForms extends Component{ // 初次上传不能直接取uid const url = `/attachments/${file.response ? file.response.id : file.uid}.json` axios.delete(url, { - }) + }) .then((response) => { if (response.data) { const { status } = response.data; @@ -93,7 +93,7 @@ class NewGtaskForms extends Component{ } onAttachmentRemove = (file, stateName) => { - if(file.response!=undefined){ + if (file.response != undefined) { this.props.confirm({ content: '是否确认删除?', @@ -111,10 +111,10 @@ class NewGtaskForms extends Component{ handleSubmit = () => { - let {contentFileList,min_num,max_num,base_on_project}=this.state; - let {data}=this.props; - let task_type=data.task_type - let topicId=this.props.topicId + let { contentFileList, min_num, max_num, base_on_project } = this.state; + let { data } = this.props; + let task_type = data.task_type + let topicId = this.props.topicId let attachment_ids = contentFileList.map(item => { return item.response ? item.response.id : item.id }) @@ -125,23 +125,23 @@ class NewGtaskForms extends Component{ values.description = mdContnet; if (!err) { - if (this.props.data.isEdit===true) { - let url="/task_banks/"+topicId+".json"; + if (this.props.data.isEdit === true) { + let url = "/task_banks/" + topicId + ".json"; axios.put(url, { - gtask_bank: { - name: values.title, - description: values.description, - min_num:task_type===1?undefined:min_num, - max_num:task_type===1?undefined:max_num, - base_on_project: task_type===1?task_type:base_on_project===true?1:0 - }, - attachment_ids:attachment_ids - } + gtask_bank: { + name: values.title, + description: values.description, + min_num: task_type === 1 ? undefined : min_num, + max_num: task_type === 1 ? undefined : max_num, + base_on_project: task_type === 1 ? task_type : base_on_project === true ? 1 : 0 + }, + attachment_ids: attachment_ids + } ).then((response) => { - if(response.data.status===0){ + if (response.data.status === 0) { this.props.showNotification(response.data.message) this.props.onCancel() - }else{ + } else { this.props.showNotification(response.data.message) } }).catch((error) => { @@ -176,14 +176,14 @@ class NewGtaskForms extends Component{ this.setState({ base_on_project: !this.state.base_on_project }) } - render(){ + render() { const { getFieldDecorator } = this.props.form; - let{ + let { title_value, contentFileList, answerFileList, max_num, min_num, base_on_project, init_max_num, init_min_num, title_num, course_name, category, has_commit, has_project, isEdit - }=this.state + } = this.state const uploadProps = { width: 600, fileList: contentFileList, @@ -205,11 +205,11 @@ class NewGtaskForms extends Component{ }; - return( -
    - -
    -
    -
    - {this.props.data&&this.props.data.task_type===1?"普通作业":this.props.data&&this.props.data.task_type===2?"分组作业":""} -
    + } + + +
    +
    + {this.props.data && this.props.data.task_type === 1 ? "普通作业" : this.props.data && this.props.data.task_type === 2 ? "分组作业" : ""}
    - - {getFieldDecorator('title', { - rules: [{ - required: true, message: '请输入标题' - }], - })( - - )} - - - - { - {getFieldDecorator('description', { - rules: [{ - required: true, message: '请输入任务内容说明' - }], - })( - - )} - } - - - (单个文件150M以内) + (单个文件150M以内) - {this.props.data&&this.props.data.task_type===2? + {this.props.data && this.props.data.task_type === 2 ? {/* max={has_commit ? init_min_num : null } */} 每组最小人数: 人 + onChange={this.min_num_change} style={{ width: '180px' }} /> 人 {/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */} 每组最大人数: 人 + onChange={this.max_num_change} style={{ width: '180px' }} /> 人
    学生提交作品时需要关联同组成员,组内成员作品共享

    基于项目(选中,则必须在本平台创建项目,项目管理员可以提交作品;不选中,无需在平台创建项目,任意小组成员均可以提交作品)

    )} - :"" - } - -
    - {/* htmlType="submit" */} - - this.props.onCancel()}>取消 -
    -
    - -
    + : "" + } + + + + +
    ) } }