Merge branches 'dev_aliyun' and 'topic_bank' of https://bdgit.educoder.net/Hjqreturn/educoder into topic_bank

dev_aliyun_beta
杨树明 5 years ago
commit 803c02c90d

@ -32,7 +32,7 @@ module.exports = {
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s
// devtool: "cheap-module-eval-source-map",
// 开启调试
// devtool: "source-map", // 开启调试
devtool: "eval", // 开启调试
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS.

@ -222,6 +222,12 @@ const InfosIndex = Loadable({
loader: () => import('./modules/user/usersInfo/InfosIndex'),
loading: Loading,
})
// 题库
const BanksIndex = Loadable({
loader: () => import('./modules/user/usersInfo/banks/BanksIndex'),
loading: Loading,
})
// 教学案例
const MoopCases = Loadable({
@ -245,6 +251,36 @@ const Messagerouting= Loadable({
loader: () => import('./modules/message/js/Messagerouting'),
loading: Loading,
})
const Topicbank= Loadable({
loader: () => import('./modules/topic_bank/Topic_bank'),
loading: Loading,
})
//普通作业题库详情
const Generaljobbankdetails =Loadable({
loader: () => import('./modules/courses/questionbank/Generaljobbankdetails'),
loading: Loading,
});
//分组作业题库详情
const GroupjobbankPage =Loadable({
loader: () => import('./modules/courses/groupjobbank/GroupjobbankPage'),
loading: Loading,
});
//毕设选题详情
const CompletetopicdePage =Loadable({
loader: () => import('./modules/courses/comtopicdetails/CompletetopicdePage'),
loading: Loading,
});
//毕设任务详情
const Completetaskpage =Loadable({
loader: () => import('./modules/courses/completetaskdetails/Completetaskpage'),
loading: Loading,
});
//问卷编辑
const PollNewQuestbank =Loadable({
loader: () => import('./modules/courses/poll/PollNewQuestbank'),
loading: Loading,
});
class App extends Component {
constructor(props) {
super(props)
@ -337,6 +373,15 @@ class App extends Component {
<Router>
<Switch>
{/*题库*/}
<Route path="/topicbank/:username/:topicstype"
render={
(props) => {
return (<Topicbank {...this.props} {...props} {...this.state} />)
}
}></Route>
{/*众包创新*/}
<Route path={"/crowdsourcing"} component={ProjectPackages}/>
{/*认证*/}
@ -365,6 +410,13 @@ class App extends Component {
}
}></Route>
<Route path="/banks"
render={
(props) => {
return (<BanksIndex {...this.props} {...props} {...this.state} />)
}
}></Route>
<Route
path="/changepassword" component={EducoderLogin}
/>

@ -48,7 +48,17 @@ export function SnackbarHOC(options = {}) {
snackbarHorizontal: horizontal,
})
}
//个别情况需要走
showNotification = (description, message = "提示", icon) => {
const data = {
message,
description
}
if (icon) {
data.icon = icon;
}
notification.open(data);
}
render() {
const { snackbarOpen, snackbarText, snackbarHorizontal, snackbarVertical } = this.state;
@ -70,7 +80,7 @@ export function SnackbarHOC(options = {}) {
resumeHideDuration={2000}
message={<span id="message-id">{this.state.snackbarText}</span>}
/>
<WrappedComponent {...this.props} showSnackbar={ this.showSnackbar } >
<WrappedComponent {...this.props} showSnackbar={ this.showSnackbar } showNotification= { this.showNotification } >
</WrappedComponent>
</React.Fragment>

@ -263,26 +263,7 @@ const GraduationTasksSubmiteditApp=Loadable({
loader: () => import('./graduation/tasks/GraduationTasksSubmitedit'),
loading: Loading,
})
//普通作业题库详情
const Generaljobbankdetails =Loadable({
loader: () => import('../../modules/courses/questionbank/Generaljobbankdetails'),
loading: Loading,
});
//分组作业题库详情
const GroupjobbankPage =Loadable({
loader: () => import('../../modules/courses/groupjobbank/GroupjobbankPage'),
loading: Loading,
});
//毕设选题详情
const CompletetopicdePage =Loadable({
loader: () => import('../../modules/courses/comtopicdetails/CompletetopicdePage'),
loading: Loading,
});
//毕设任务详情
const Completetaskpage =Loadable({
loader: () => import('../../modules/courses/completetaskdetails/Completetaskpage'),
loading: Loading,
});
class CoursesIndex extends Component{
constructor(props) {
super(props)
@ -461,30 +442,7 @@ class CoursesIndex extends Component{
// console.log(commons)
return (
<Switch {...this.props}>
{/*毕设任务题库详情*/}
<Route path="/banks/gtopic_topics/:workid"
render={
(props) => (<Completetaskpage {...this.props} {...props} {...this.state} />)
}
></Route>
{/*毕设内容题库详情*/}
<Route path="/banks/gtask_topics/:workid"
render={
(props) => (<CompletetopicdePage {...this.props} {...props} {...this.state} />)
}
></Route>
{/*分组作业题库详情*/}
<Route path="/banks/group_topics/:workid"
render={
(props) => (<GroupjobbankPage {...this.props} {...props} {...this.state} />)
}
></Route>
{/* 普通作业题库详情*/}
<Route path="/banks/normal_topics/:workid"
render={
(props) => (<Generaljobbankdetails {...this.props} {...props} {...this.state} />)
}
></Route>
{/* 资源列表页 */}
<Route path="/courses/:coursesId/file/:Id" exact
render={

@ -0,0 +1,469 @@
import React,{ Component } from "react";
import { Input, InputNumber, Form, Button, Checkbox, Upload, Icon, message, Modal } from "antd";
import axios from 'axios'
import '../css/busyWork.css'
import '../css/Courses.css'
import { WordsBtn, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder'
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import CBreadcrumb from '../common/CBreadcrumb'
const confirm = Modal.confirm;
const $ = window.$
const MAX_TITLE_LENGTH = 60;
/**
需要注意的props
isGroup
*/
class NewWorkForm extends Component{
constructor(props){
super(props);
this.contentMdRef = React.createRef();
this.answerMdRef = React.createRef();
this.state={
title_value:"",
title_num: 0,
contentFileList: [],
answerFileList: [],
workLoaded: false,
base_on_project: true,
category: {},
min_num: 2,
max_num: 10,
}
}
initValue = (data) => {
if (data.isEdit) {
const contentFileList = data.attachments.map(item => {
return {
id: item.id,
uid: item.id,
name: appendFileSizeToUploadFile(item),
url: item.url,
filesize: item.filesize,
status: 'done'
}
})
const answerFileList = data.ref_attachments.map(item => {
return {
id: item.id,
uid: item.id,
name: appendFileSizeToUploadFile(item),
url: item.url,
filesize: item.filesize,
status: 'done'
}
})
this.setState({
...data,
// course_id: data.course_id,
// course_name: data.course_name,
// category: data.category,
title_num: parseInt(data.name.length),
workLoaded: true,
init_min_num: data.min_num,
init_max_num: data.max_num,
// description: data.description,
reference_answer: data.reference_answer,
contentFileList,
answerFileList,
}, () => {
setTimeout(() => {
this.contentMdRef.current.setValue(data.description || '')
this.answerMdRef.current.setValue(data.reference_answer || '')
}, 2000)
this.props.form.setFieldsValue({
title: data.name,
description: data.description || '',
reference_answer: data.reference_answer || '',
});
})
} else { // new
}
}
// 输入title
changeTitle=(e)=>{
console.log(e.target.value.length);
this.setState({
title_num: parseInt(e.target.value.length)
})
}
handleSubmit = () => {
const courseId = this.state.course_id || this.props.match.params.coursesId ;
this.props.form.validateFieldsAndScroll((err, values) => {
console.log(values)
const mdContnet = this.contentMdRef.current.getValue().trim();
console.log(mdContnet)
values.description = mdContnet;
// return;
{/* max={has_commit ? init_min_num : null } */}
{/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */}
// 已有提交作品,人数范围只能扩大
const { has_commit, max_num, init_max_num, min_num, init_min_num } = this.state;
if (has_commit) {
if (max_num < init_max_num || min_num > init_min_num) {
this.props.showNotification(`已有提交作品,人数范围只能扩大(原设置为:${init_min_num} - ${init_max_num})`)
return;
}
}
// const errKeys = Object.keys(err); // || errKeys.length == 1 && errKeys[0] == 'content' && mdContnet
if (!err) {
if (this.state.isEdit) {
this.doEdit(courseId, values)
} else {
this.doNew(courseId, values)
}
} else {
$("html").animate({ scrollTop: $('html').scrollTop() - 100 })
}
})
}
doEdit = (courseId, values) => {
let attachment_ids = this.state.contentFileList.map(item => {
return item.response ? item.response.id : item.id
})
let reference_attachment_ids = this.state.answerFileList.map(item => {
return item.response ? item.response.id : item.id
})
const { min_num, max_num, base_on_project, category } = this.state
const isGroup = this.props.isGroup()
const params = {
type: isGroup ? 3 : 1,
name: values.title,
description: values.description,
reference_answer: values.reference_answer,
attachment_ids,
reference_attachment_ids,
min_num,
max_num,
base_on_project
}
this.props.doEdit && this.props.doEdit(params)
}
doNew = (courseId, values) => {
let attachment_ids = this.state.contentFileList.map(item => {
return item.response ? item.response.id : item.id
})
let reference_attachment_ids = this.state.answerFileList.map(item => {
return item.response ? item.response.id : item.id
})
const isGroup = this.props.isGroup()
const { min_num, max_num, base_on_project, category } = this.state
const params = {
type: isGroup ? 3 : 1,
name: values.title,
description: values.description,
reference_answer: values.reference_answer,
attachment_ids,
reference_attachment_ids,
min_num,
max_num,
base_on_project
}
this.props.doNew && this.props.doNew(params)
}
handleContentUploadChange = (info) => {
let contentFileList = info.fileList;
this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList) });
}
handleAnswerUploadChange = (info) => {
let answerFileList = info.fileList;
this.setState({ answerFileList: appendFileSizeToUploadFileAll(answerFileList) });
}
onAttachmentRemove = (file, stateName) => {
if(file.response!=undefined){
this.props.confirm({
content: '是否确认删除?',
onOk: () => {
this.deleteAttachment(file, stateName)
},
onCancel() {
console.log('Cancel');
},
});
}
return false;
}
deleteAttachment = (file, stateName) => {
// 初次上传不能直接取uid
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})
.then((response) => {
if (response.data) {
const { status } = response.data;
if (status == 0) {
console.log('--- success')
this.setState((state) => {
const index = state[stateName].indexOf(file);
const newFileList = state[stateName].slice();
newFileList.splice(index, 1);
return {
[stateName]: newFileList,
};
});
}
}
})
.catch(function (error) {
console.log(error);
});
}
max_num_change = (val) => {
if (val < 2) {
this.setState({
max_num: 2,
})
return;
}
const { min_num } = this.state;
this.setState({
max_num: val,
min_num: val <= min_num ? val - 1 : min_num
})
}
min_num_change = (val) => {
this.setState({ min_num: val })
}
base_on_project_change = () => {
this.setState({ base_on_project: !this.state.base_on_project })
}
render(){
let {typeId,coursesId,pageType}=this.props.match.params;
const { getFieldDecorator } = this.props.form;
const isGroup = this.props.isGroup()
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
const { current_user } = this.props
const courseId = this.state.course_id || this.props.match.params.coursesId ;
if ((isEdit) && !this.state.workLoaded) {
return ''
}
const uploadProps = {
width: 600,
fileList: contentFileList,
multiple: true,
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
onChange: this.handleContentUploadChange,
onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'),
beforeUpload: (file) => {
console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) {
message.error('文件大小必须小于150MB!');
}
return isLt150M;
},
};
const answerUploadProps = {
width: 600,
fileList: answerFileList,
multiple: true,
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
onChange: this.handleAnswerUploadChange,
onRemove: (file) => this.onAttachmentRemove(file, 'answerFileList'),
beforeUpload: (file) => {
console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) {
message.error('文件大小必须小于150MB!');
}
return isLt150M;
},
};
return(
<React.Fragment>
<style>
{
`
.yslnewworkinputaddonAfter .ant-input{
border-right: none !important;
height: 40px !important;
}
`
}
</style>
<Form className="courseForm">
<Form.Item
label="标题"
className="AboutInputForm"
>
{getFieldDecorator('title', {
rules: [{
required: true, message: '请输入标题'
}],
})(
<Input placeholder="请输入作业标题最大限制60个字符" onInput={this.changeTitle} className="searchView yslnewworkinputaddonAfter searchViewAfter" style={{"width":"100%"}} maxLength={MAX_TITLE_LENGTH} addonAfter={`${String(title_num)}/${MAX_TITLE_LENGTH}`}/>
)}
</Form.Item>
<style>{`
.uploadBtn.ant-btn {
border: none;
color: #4CACFF;
box-shadow: none;
background: transparent;
padding: 0 6px;
}
.ant-upload-list-item:hover .ant-upload-list-item-info{
background-color:#fff;
}
.upload_1 .ant-upload-list {
width: 350px;
}
.ant-input-number {
height: 40px;
line-height: 40px;
}
.workContent.AboutInputForm.ant-form-item {
border-bottom: none;
padding-bottom: 0px !important;
}
.newWorkUpload {
padding: 0px 30px 30px 30px!important;
background: #fff;
width: 100%;
display: inline-block;
border-bottom: 1px solid #EDEDED;
}
`}</style>
{ <Form.Item
label="内容"
className="AboutInputForm workContent mdInForm"
>
{getFieldDecorator('description', {
rules: [{
required: true, message: '请输入作业内容和要求'
}],
})(
<TPMMDEditor ref={this.contentMdRef} placeholder="请在此输入作业内容和要求,最大限制5000个字符" mdID={'courseContentMD'} refreshTimeout={1500}
className="courseMessageMD" initValue={this.state.description}></TPMMDEditor>
)}
</Form.Item> }
<Upload {...uploadProps} className="upload_1 newWorkUpload">
<Button className="uploadBtn">
<Icon type="upload" /> 上传附件
</Button>
(单个文件150M以内)
</Upload>
{ isGroup &&
<Form.Item
label="分组设置"
className="AboutInputForm"
>
{getFieldDecorator('personNum', {
rules: [{
required: false
// required: true, message: '请输入最小人数和最大人数'
}],
})(
<div>
<p className="clearfix">
<ConditionToolTip condition={has_commit} title={'已有提交作品,人数范围只能扩大'}>
{/* max={has_commit ? init_min_num : null } */}
<InputNumber placeholder="请填写每组最小人数" min={1} className="winput-240-40" value={min_num}
onChange={this.min_num_change} style={{width:'180px'}} />
</ConditionToolTip>
<span className="ml15 mr15">~</span>
{/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */}
<ConditionToolTip condition={has_commit} title={'已有提交作品,人数范围只能扩大'}>
<InputNumber className="winput-240-40" placeholder="请填写每组最大人数" value={max_num} max={10}
onChange={this.max_num_change} style={{width:'180px'}} />
</ConditionToolTip>
<label className="color-grey-9 ml20 font-14">项目管理员角色的成员都可以提交作品提交作品时需要关联同组成员组内成员作品共享</label>
</p>
<p className="mt20">
<ConditionToolTip condition={has_commit || has_project} title={'已有关联项目或作品,不能修改'}>
<Checkbox checked={base_on_project} onChange={this.base_on_project_change}
disabled={has_project || has_commit}
>基于项目实施</Checkbox>
</ConditionToolTip>
<label className="color-grey-9 ml12 font-14">勾选后各小组必须在educoder平台创建项目教师可随时观察平台对各小组最新进展的实时统计</label>
</p>
</div>
)}
</Form.Item>
}
<Form.Item
label="参考答案"
className="AboutInputForm"
style={{"borderBottom":"none"}}
>
{getFieldDecorator('reference_answer', {
rules: [{
required: false
}],
})(
<TPMMDEditor ref={this.answerMdRef} placeholder="请在此输入作业的参考答案,最大限制5000个字符" mdID={'workAnswerMD'}
className="courseMessageMD" refreshTimeout={1500} initValue={this.state.reference_answer || ''}></TPMMDEditor>
)}
<Upload {...answerUploadProps} className="upload_1">
<Button className="uploadBtn">
<Icon type="upload" /> 上传附件
</Button>
(单个文件150M以内)
</Upload>
</Form.Item>
<Form.Item>
<div className="clearfix mt30 mb30">
{/* htmlType="submit" */}
<Button type="primary" onClick={this.handleSubmit} className="defalutSubmitbtn fl mr20">提交</Button>
<a className="defalutCancelbtn fl" onClick={() => this.props.onCancel()}>取消</ a>
</div>
</Form.Item>
</Form>
</React.Fragment>
)
}
}
const WrappedWorkForm = Form.create({ name: 'NewWorkForm' })(NewWorkForm);
export default WrappedWorkForm;

@ -57,20 +57,22 @@ class Groupjobbandetails extends Component {
render() {
let{datas}=this.props;
return (
<div className=" clearfix edu-back-white" ref='targetElementTrainingjobsetting' style={{margin: "auto", minWidth:"1200px"}}>
<div className="yslquestionbank1">
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML("C++是C语言的面向对象扩展是C语言的一个超集同时也是历史最悠久、最受欢迎的程序设计语言之一。根据C++创始人Stroustrup的自述C++是一个“更好的C语言”。\n" +
"\n" +
"输入输出是计算机程序的基本功能。程序本质上是对数据进行处理的一系列操作,一般程序都可以分解为:“数据输入”、“数据处理”和“数据输出”三个步骤。标准输入输出(键盘输入和显示器输出)是程序的重要组成部分。\n" +
"\n" +
"本实训项目的主要目标是学习和掌握C++程序的基本结构和基本输入输出主要内容包括标准C语言自有的单个字符的输入输出、格式化的输入输出以及C++扩展的使用流对象的输入输出").replace(/▁/g, "▁▁▁")}}/>
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML(datas&&datas.description).replace(/▁/g, "▁▁▁")}}/>
{datas.attachments === undefined ? "" : datas.attachments.map((item, key) => {
return (
<GroupPackage key={key} attachments={item}></GroupPackage>
)
})}
<GroupPackage2 datas={datas} bool={false}></GroupPackage2>
<GroupPackage></GroupPackage>
<GroupPackage2></GroupPackage2>
</div>

@ -18,17 +18,20 @@ class Completetaskpage extends Component {
constructor(props) {
super(props);
// this.answerMdRef = React.createRef();
this.setState({
this.state={
workid:1,
isSpin:false,
datas:[],
})
}
}
componentDidMount() {
// console.log("父组件加载框");
this.getonedata();
}
getonedata(){
if( this.props.match.params.workid){
this.setState({
workid: this.props.match.params.workid,
@ -47,13 +50,13 @@ class Completetaskpage extends Component {
this.setState({
isSpin:true,
})
let url = `/homework_banks/${workids}.json`;
let url = `/task_banks/${workids}.json`;
//
axios.get(url).then((response) => {
if(response){
if(response.data){
this.setState({
datas:response.data.informs,
datas:response.data,
})
}else {
this.setState({
@ -86,8 +89,8 @@ class Completetaskpage extends Component {
///////////////教师截止
render() {
let{datas}=this.state;
const isAdmin = this.props.isAdmin();
// console.log(119)
@ -108,10 +111,10 @@ class Completetaskpage extends Component {
</div>
<div className="educontent mb20">
<p className=" fl color-black summaryname" style={{heigth: "33px"}}>
MySQL数据库编程开发实训基础篇
{datas&&datas.name}
</p>
<CoursesListType
typelist={["公开"]}
typelist={datas&&datas.is_public?["公开"]:["私有"]}
/>
</div>
@ -126,7 +129,7 @@ class Completetaskpage extends Component {
</div>
</div>
<Completetaskdetails/>
<Completetaskdetails {...this.state} {...this.props} datas={datas}/>
</div>
</div>

@ -19,11 +19,11 @@ class CompletetopicdePage extends Component {
constructor(props) {
super(props);
// this.answerMdRef = React.createRef();
this.setState({
this.state={
workid:1,
isSpin:false,
datas:[],
})
}
}
@ -48,13 +48,13 @@ class CompletetopicdePage extends Component {
this.setState({
isSpin:true,
})
let url = `/homework_banks/${workids}.json`;
let url = `/gtopic_banks/${workids}.json`;
//
axios.get(url).then((response) => {
if(response){
if(response.data){
this.setState({
datas:response.data.informs,
datas:response.data,
})
}else {
this.setState({
@ -88,9 +88,8 @@ class CompletetopicdePage extends Component {
///////////////教师截止
render() {
const isAdmin = this.props.isAdmin();
// console.log(119)
let{datas}=this.state;
// console.log(119)
return (
@ -110,10 +109,10 @@ class CompletetopicdePage extends Component {
</div>
<div className="educontent mb20">
<p className=" fl color-black summaryname" style={{heigth: "33px"}}>
MySQL数据库编程开发实训基础篇
{datas&&datas.name}
</p>
<CoursesListType
typelist={["公开"]}
typelist={datas&&datas.is_public?["公开"]:["私有"]}
/>
</div>
@ -128,7 +127,7 @@ class CompletetopicdePage extends Component {
</div>
</div>
<Completetopicdetails/>
<Completetopicdetails {...this.state} {...this.props} datas={datas}/>
{/*{parseInt(tab) === 1 ? <Completetopicdeswer/>:""}*/}
</div>

@ -56,52 +56,52 @@ class Completetopicdetails extends Component {
render() {
let{datas}=this.props;
return (
<div className=" clearfix edu-back-white " ref='targetElementTrainingjobsetting' style={{margin: "auto", minWidth:"1200px"}}>
<div className="bor-bottom-greyE">
<div className="yslquestionbank1">
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML("C++是C语言的面向对象扩展是C语言的一个超集同时也是历史最悠久、最受欢迎的程序设计语言之一。根据C++创始人Stroustrup的自述C++是一个“更好的C语言”。\n" +
"\n" +
"输入输出是计算机程序的基本功能。程序本质上是对数据进行处理的一系列操作,一般程序都可以分解为:“数据输入”、“数据处理”和“数据输出”三个步骤。标准输入输出(键盘输入和显示器输出)是程序的重要组成部分。\n" +
"\n" +
"本实训项目的主要目标是学习和掌握C++程序的基本结构和基本输入输出主要内容包括标准C语言自有的单个字符的输入输出、格式化的输入输出以及C++扩展的使用流对象的输入输出").replace(/▁/g, "▁▁▁")}}/>
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML(datas&&datas.description).replace(/▁/g, "▁▁▁")}}/>
<GroupPackage></GroupPackage>
{datas.attachment_list === undefined ? "" : datas.attachment_list.map((item, key) => {
return (
<GroupPackage key={key} attachments={item}></GroupPackage>
)
})}
</div>
</div>
<div style={{width:"100%", padding: "36px"}}>
<div className="yslboomdivs">
<p>
<span className="yslboomdivsy">课题类型</span>
<span className="yslboomdivsys">设计</span>
<span className="yslboomdivsys">{datas&&datas.topic_type===1?"设计":datas&&datas.topic_type===2?"论文":datas&&datas.topic_type===3?"创作":"设计"}</span>
</p>
<p>
<span className="yslboomdivsy">课题来源</span>
<span className="yslboomdivsys">生产/社会实践</span>
<span className="yslboomdivsys">{datas&&datas.topic_source===1?"生产/社会实际":datas&&datas.topic_source===2?"结合科研":datas&&datas.topic_source===3?"其它":"生产/社会实际"}</span>
</p>
<p>
<span className="yslboomdivsy">课题性质1</span>
<span className="yslboomdivsys">设计</span>
<span className="yslboomdivsys">{datas&&datas.topic_property_first===1?"真题":datas&&datas.topic_property_first===2?"模拟题":"真题"}</span>
</p>
<p>
<span className="yslboomdivsy">课题性质2</span>
<span className="yslboomdivsys">设计</span>
<span className="yslboomdivsys">{datas&&datas.topic_property_second===1?"纵向课题":datas&&datas.topic_property_second===2?"横向课题":datas&&datas.topic_property_second===3?"自选":"纵向课题"}</span>
</p>
</div>
<div className="yslboomdivs">
<p>
<span className="yslboomdivsy">课题重复情况 </span>
<span className="yslboomdivsys">新需求</span>
<span className="yslboomdivsys">{datas&&datas.topic_repeat===1?"新题":datas&&datas.topic_repeat===2?"往届题,有新要求":datas&&datas.topic_repeat===3?"往届题,无新要求":"新题"}</span>
</p>
<p>
<span className="yslboomdivsy">调研或实习地点</span>
<span className="yslboomdivsys">长沙</span>
<span className="yslboomdivsys">{datas&&datas.province}{datas&&datas.city}</span>
</p>
<p style={{width:"564px"}}>
<span className="yslboomdivsy">课题单位来源</span>
<span className="yslboomdivsys">湖南省据C++创始人Stroustrup有限公司</span>
<span className="yslboomdivsys">{datas&&datas.source_unit}</span>
</p>
</div>
</div>

@ -37,7 +37,7 @@ class ShixunChooseModal extends Component{
hometypepvisible:loading
})
let coursesId=this.props.match.params.coursesId;
let url ="/courses/"+coursesId+"/homework_commons/shixuns.json";
let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json";
axios.get(url, {
params: {
@ -76,7 +76,7 @@ class ShixunChooseModal extends Component{
})
let coursesId=this.props.match.params.coursesId;
let url ="/courses/"+coursesId+"/homework_commons/shixuns.json";
let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json";
axios.get(url).then((result)=>{
if(result.status===200){

@ -25,7 +25,7 @@ class ShixunModal extends Component{
hometypepvisible:true,
})
let coursesId=this.props.match.params.coursesId;
let url ="/courses/"+coursesId+"/homework_commons/shixuns.json";
let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json";
axios.get(url).then((result)=>{
if(result.status===200){
@ -51,7 +51,7 @@ class ShixunModal extends Component{
hometypepvisible:loading
})
let coursesId=this.props.match.params.coursesId;
let url ="/courses/"+coursesId+"/homework_commons/shixuns.json";
let url = this.props.shixunsUrl || "/courses/"+coursesId+"/homework_commons/shixuns.json";
axios.get(url, {
params: {

@ -5,440 +5,63 @@ import {
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import { Q_TYPE_SINGLE, Q_TYPE_MULTI, Q_TYPE_JUDGE, Q_TYPE_NULL, Q_TYPE_MAIN, Q_TYPE_SHIXUN } from './new/common'
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
// import './board.css'
import "../common/formCommon.css"
// import "../common/formCommon.css"
// import { RouteHOC } from './common.js'
import CBreadcrumb from '../common/CBreadcrumb'
import {getUrl, ActionBtn} from 'educoder';
import SingleEditor from './new/SingleEditor'
import SingleDisplay from './new/SingleDisplay'
import JudgeEditor from './new/JudgeEditor'
import JudgeDisplay from './new/JudgeDisplay'
import NullEditor from './new/NullEditor'
import NullDisplay from './new/NullDisplay'
import MainEditor from './new/MainEditor'
import MainDisplay from './new/MainDisplay'
import ShixunEditor from './new/ShixunEditor'
import ShixunDisplay from './new/ShixunDisplay'
// import { Q_TYPE_SINGLE, Q_TYPE_MULTI, Q_TYPE_JUDGE, Q_TYPE_NULL, Q_TYPE_MAIN, Q_TYPE_SHIXUN } from './new/common'
// import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
// import CBreadcrumb from '../common/CBreadcrumb'
import {getUrl, ActionBtn, CBreadcrumb} from 'educoder';
// import SingleEditor from './new/SingleEditor'
// import SingleDisplay from './new/SingleDisplay'
// import JudgeEditor from './new/JudgeEditor'
// import JudgeDisplay from './new/JudgeDisplay'
// import NullEditor from './new/NullEditor'
// import NullDisplay from './new/NullDisplay'
// import MainEditor from './new/MainEditor'
// import MainDisplay from './new/MainDisplay'
// import ShixunEditor from './new/ShixunEditor'
// import ShixunDisplay from './new/ShixunDisplay'
import ShixunChooseModal from '../coursesPublic/ShixunChooseModal'
import update from 'immutability-helper'
import './new/common.css'
import '../css/Courses.css'
import ExerciseNewCommon from './ExerciseNewCommon'
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const TITLE_MAX_LENGTH = 60;
class ExerciceNew extends Component{
constructor(props){
super(props);
this.state = {
exercise_questions: [],
exercise_name: '',
exercise_description: '',
exercise_types: {},
editMode: !this.props.match.params.Id,
}
}
// 已发布试卷编辑保存的确认弹框
changeScore = (question_id,answerArray) =>{
this.props.confirm({
content:'修改了标准答案',
subContent:"是否重新计算学生答题的成绩?",
onOk:()=>{
this.sureChangeScore(question_id,answerArray)
},
onCancel:()=>{
this.addSuccess();
}
})
}
// 已发布试卷修改答案确认修改分数
sureChangeScore = (question_id,answerArray) =>{
let url=`/exercise_questions/${question_id}/update_scores.json`
axios.post((url),{
standard_answers:answerArray
}).then((result)=>{
if(result){
this.props.showNotification(`${result.data.message}`);
this.addSuccess();
}
}).catch((error)=>{
console.log(error);
})
}
fetchExercise = () => {
const Id = this.props.match.params.Id
this.isEdit = !!Id
if (Id) {
const url = `/exercises/${Id}/edit.json`
axios.get(url)
.then((response) => {
if (response.data.status == 0) {
const { exercise, ...others } = response.data
this.setState({
...exercise,
...others,
editMode: false
})
}
})
.catch(function (error) {
console.log(error);
});
} else {
const courseId=this.props.match.params.coursesId;
const newUrl = `/courses/${courseId}/exercises/new.json`
axios.get(newUrl)
.then((response) => {
if (response.data.status == 0) {
this.setState({
...response.data
})
}
})
.catch(function (error) {
console.log(error);
});
}
}
componentDidMount = () => {
this.fetchExercise()
}
handleSubmit = (e) => {
}
onSaveExercise = () => {
const { exercise_name, exercise_description } = this.state;
const exercise_id = this.props.match.params.Id
const courseId = this.props.match.params.coursesId
if (this.isEdit) {
const editUrl = `/exercises/${exercise_id}.json`
axios.put(editUrl, {
exercise_name,
exercise_description
})
.then((response) => {
if (response.data.status == 0) {
this.setState({editMode: false})
this.props.showNotification('试卷编辑成功')
}
})
.catch(function (error) {
console.log(error);
});
} else {
const url = `/courses/${courseId}/exercises.json`
axios.post(url, {
exercise_name,
exercise_description
})
.then((response) => {
if (response.data.status == 0) {
this.setState({editMode: false})
this.props.showNotification('试卷新建成功')
const exercise_id = response.data.data.exercise_id;
this.isEdit = true;
this.props.history.replace(`/courses/${courseId}/exercises/${exercise_id}/edit`);
}
})
.catch(function (error) {
console.log(error);
});
}
}
exercise_name_change = (e) => {
this.setState({exercise_name: e.target.value})
}
exercise_description_change = (e) => {
this.setState({exercise_description: e.target.value})
}
// #问题的类型0为单选题1为多选题2为判断题3为填空题4为主观题5为实训题
_checkIsEditing = () => {
if (this.editingId && $(this.editingId).length ) {
this.props.showNotification('请先保存或取消当前正在编辑的问题。')
$("html").animate({ scrollTop: $(this.editingId).offset().top - 100})
return true
}
return false
}
onEditorCancel = () => {
this.editingId = null;
// 找到编辑或新建的item新建就删掉item编辑就isNew改为false
const { exercise_questions } = this.state
let index = -1;
for(let i = 0; i < exercise_questions.length; i++) {
if (exercise_questions[i].isNew == true) {
index = i;
break;
}
}
if (exercise_questions[index].question_id) { // 编辑
this.setState(
(prevState) => ({
exercise_questions : update(prevState.exercise_questions, {[index]: { isNew: {$set: false}}})
// update(prevState.exercise_questions, {$splice: [[index, 1]]})
})
)
} else { // 新建
this.setState(
(prevState) => ({
exercise_questions : update(prevState.exercise_questions, {$splice: [[index, 1]]})
})
)
}
}
addQuestion = (question_id_to_insert_after, type) => {
if (!this.isEdit) {
this.props.showNotification('请先输入试卷标题,并保存试卷')
return;
}
if (this._checkIsEditing()) {
return;
}
if (type == Q_TYPE_SHIXUN) {
this.addShixun(question_id_to_insert_after)
} else {
this.addEditingQuestion(type, question_id_to_insert_after)
}
}
chooseShixun = (array) => {
this.addEditingQuestion(Q_TYPE_SHIXUN, this.question_id_to_insert_after, {
shixun_id: array[0]
})
}
chooseShixunSuccess = () => {
this.refs.shixunChooseModal.setVisible(false)
}
addShixun = (question_id_to_insert_after) => {
if (!this.isEdit) {
this.props.showNotification('请先输入试卷标题,并保存试卷')
return;
}
// TODO 弹框选择实训
if (this._checkIsEditing()) {
return;
}
this.refs.shixunChooseModal.setVisible(true)
this.question_id_to_insert_after = question_id_to_insert_after;
return;
// 拉取实训items
this.addEditingQuestion(Q_TYPE_SHIXUN, question_id_to_insert_after, {
shixun_id: 50
})
}
editQestion = (index) => {
if (this._checkIsEditing()) {
return;
}
this.editingId = `#question_${index}`
this.setState(
(prevState) => ({
exercise_questions : update(prevState.exercise_questions, {[index]: { isNew: {$set: true}}})
})
)
}
onSort = (index, question_id, isUp) => {
if (this._checkIsEditing()) {
return;
}
const url = `/exercise_questions/${question_id}/up_down.json`
axios.post(url, { opr: isUp ? 'up' : 'down'})
.then((response) => {
if (response.data.status == 0) {
// this.props.showNotification('移动成功')
this.fetchExercise()
}
})
.catch(function (error) {
console.log(error);
});
}
onSortDown = (index, question_id) => {
this.onSort(index, question_id, false)
}
onSortUp = (index, question_id) => {
this.onSort(index, question_id, true)
}
getInitScore = (question_type, question_id_to_insert_after) => {
/**
1.每个题型的首个题目默认值规则如下
选择题5 01
判断题2 2
填空题2 3
简答题10 4
实训题每个关卡5分 5
*/
let init_question_score = 0;
if (question_type == 0 || question_type == 1) {
init_question_score = 5
} else if (question_type == 2) {
init_question_score = 2
} else if (question_type == 3) {
init_question_score = 2
} else if (question_type == 4) {
init_question_score = 10
} else if (question_type == 5) {
init_question_score = 5
}
const _indexBefore = question_id_to_insert_after ? this.findIndexById(question_id_to_insert_after) : this.state.exercise_questions.length - 1
for (let i = _indexBefore; i >= 0; i--) {
if(this.state.exercise_questions[i].question_type == question_type) {
init_question_score = this.state.exercise_questions[i].question_score
break;
}
}
return init_question_score;
}
addEditingQuestion = (question_type, question_id_to_insert_after, otherAttributes) => {
let init_question_score = this.getInitScore(question_type, question_id_to_insert_after)
let questionObj = {
question_type: question_type, // 需要这个通过类型判断
init_question_score: init_question_score,
isNew: true, // 新建或编辑用是否有id区分是新建还是编辑
question_id_to_insert_after,
...otherAttributes
}
const { exercise_questions } = this.state;
let new_exercise_questions = exercise_questions.slice(0)
let newIndex = new_exercise_questions.length;
if (question_id_to_insert_after) {
const _indexBefore = this.findIndexById(question_id_to_insert_after)
new_exercise_questions.splice(_indexBefore + 1, 0, questionObj)
newIndex = _indexBefore + 1
} else {
new_exercise_questions.push(questionObj)
}
this.editingId = `#question_${newIndex}`
this.setState({ exercise_questions: new_exercise_questions }, () => {
setTimeout(() => {
$(this.editingId).length && $("html").animate({ scrollTop: $(this.editingId).offset().top - 100})
}, 500)
})
}
findIndexById = (id) => {
const { exercise_questions } = this.state
for(let i = 0; i < exercise_questions.length; i++) {
if (exercise_questions[i].question_id == id) {
return i;
}
}
}
onQestionDelete = (question_id) => {
this.props.confirm({
content: `确认要删除这个问题吗?`,
onOk: () => {
const url = `/exercise_questions/${question_id}.json`
axios.delete(url)
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification('删除成功')
this.fetchExercise()
// const { exercise_questions } = this.state
// const index = this.findIndexById(question_id)
// this.setState(
// (prevState) => ({
// exercise_questions : update(prevState.exercise_questions, {$splice: [[index, 1]]})
// })
// )
}
})
.catch(function (error) {
console.log(error);
});
}
})
}
addSuccess = () => {
this.editingId = null;
this.fetchExercise()
}
goToPreview = () => {
const exercise_id = this.props.match.params.Id
const courseId = this.props.match.params.coursesId
this.props.history.push(`/courses/${courseId}/exercises/${exercise_id}/student_exercise_list?tab=2`)
initData = (data) => {
this.setState({left_banner_id: data.left_banner_id})
}
render() {
let { exercise_name, exercise_description, course_id, exercise_types,
exercise_questions, left_banner_id } = this.state;
// if (this.isEdit && !exercise_types) {
// return ''
// }
// const { getFieldDecorator } = this.props.form;
const { q_counts, q_scores, q_doubles, q_doubles_scores, q_judges, q_judges_scores,
q_mains, q_mains_scores, q_nulls, q_nulls_scores, q_shixuns, q_shixuns_scores, q_singles, q_singles_scores} = exercise_types;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
// sm: { span: 8 },
sm: { span: 24 },
},
wrapperCol: {
xs: { span: 24 },
// sm: { span: 16 },
sm: { span: 24 },
},
};
let { left_banner_id } = this.state;
const { current_user } = this.props
const isAdmin = this.props.isAdmin()
const courseId=this.props.match.params.coursesId;
const exercise_id = this.props.match.params.Id
const isEdit = this.isEdit
const commonHandler = {
onQestionDelete: this.onQestionDelete,
addSuccess: this.addSuccess,
addQuestion: this.addQuestion,
onEditorCancel: this.onEditorCancel,
changeScore:this.changeScore,
editQestion: this.editQestion,
onSortDown: this.onSortDown,
onSortUp: this.onSortUp,
displayCount: exercise_questions.length,
exercise_status: this.state.exercise_status,
exerciseIsPublish: this.state.exercise_status >= 2
}
return(
<div className="newMain exerciseNew">
<ShixunChooseModal
ref="shixunChooseModal"
chooseShixun={this.chooseShixun}
{...this.props}
singleChoose={true}
></ShixunChooseModal>
<style>{`
.courseForm .formBlock {
padding: 20px 30px 30px 30px;
border-bottom: 1px solid #EDEDED;
margin-bottom: 0px;
background: #fff;
}
.exerciseNew .markdown-body {
max-width: 1128px;
}
`}</style>
<div className="edu-class-container edu-position courseForm">
{ current_user && <CBreadcrumb items={[
{ to: current_user&&current_user.first_category_url, name: this.props.coursedata ? this.props.coursedata.name : ''},
@ -455,160 +78,12 @@ class ExerciceNew extends Component{
</a>
</p>
{!this.state.editMode && <div className="padding20-30" style={{ background: '#fff'}}>
<div className="displayTitle font-16">
<span>{exercise_name}</span>
<a className="fr mr6" onClick={() => { this.setState({editMode: true}) }} style={{ lineHeight: '32px'}}>
<Tooltip title="编辑"><i className="iconfont icon-bianjidaibeijing font-20 color-green"></i></Tooltip>
</a>
</div>
<div className="displayDescription color-grey-9" dangerouslySetInnerHTML={{__html: exercise_description}}
style={{whiteSpace: 'pre-wrap'}}
></div>
</div>}
{this.state.editMode && <Form {...formItemLayout} onSubmit={this.handleSubmit}>
<div className="formBlock" style={{paddingBottom: '2px',borderBottom:"none"}}>
<Form.Item
label="试卷标题"
required
className="topicTitle "
>
{/* {getFieldDecorator('subject', {
rules: [{
required: true, message: '请输入标题',
}, {
max: 20, message: '最大限制为20个字符',
}],
})( */}
<style>
{
`
.exercicenewinputysl .ant-input{
border-right: none !important;
height: 40px !important;
}
`
}
</style>
<Input placeholder={`请输入试卷标题,最大限制${TITLE_MAX_LENGTH}个字符`} maxLength={TITLE_MAX_LENGTH} className="mt5 exercicenewinputysl" value={exercise_name}
onChange={this.exercise_name_change} addonAfter={`${exercise_name ? exercise_name.length : 0}/${TITLE_MAX_LENGTH}`}
/>
{/* )} */}
</Form.Item>
<Form.Item
label="&nbsp;&nbsp;试卷须知"
>
{/* {getFieldDecorator('select_board_id', {
// initialValue: '3779',
})( */}
<TextArea placeholder="请在此输入本次试卷答题的相关说明最大限制100个字符" className="mt5" style={{height:"120px"}} value={exercise_description}
onChange={this.exercise_description_change}
/>
{/* )} */}
</Form.Item>
<Form.Item>
{/* defalutSubmitbtn */}
<a className="task-btn task-btn-orange fr mt4" style={{height: '30px', width: '70px'}}
onClick={this.onSaveExercise}
>保存</a>
{ this.isEdit && <a onClick={() => this.setState({editMode: false})} className="defalutCancelbtn fr mt4"
style={{height: '30px', width: '70px', fontSize: '14px', lineHeight: '30px', marginRight: '16px'}}>取消</a>}
{/* <Button type="primary" onClick={this.onSaveExercise} className="fr">保存</Button> */}
</Form.Item>
</div>
{/* <div className="clearfix mt30 mb30">
<a className="defalutCancelbtn fl" onClick={() => {}}>取消</ a>
</div> */}
</Form>}
<p className="clearfix padding20-30 color-grey-9">
<span className="fl">
{ !!q_singles && <span className="mr20">单选题{q_singles}{q_singles_scores}</span>}
{ !!q_doubles && <span className="mr20">多选题{q_doubles}{q_doubles_scores}</span>}
{ !!q_judges && <span className="mr20">判断题{q_judges}{q_judges_scores}</span>}
{ !!q_nulls && <span className="mr20">填空题{q_nulls}{q_nulls_scores}</span>}
{ !!q_mains && <span className="mr20">简答题{q_mains}{q_mains_scores}</span>}
{ !!q_shixuns && <span className="mr20">实训题{q_shixuns}{q_shixuns_scores}</span> }
</span>
<span className="fr">
{ !!q_counts &&
<span>
合计 <span className="color-blue">{q_counts}</span>
<span className={`${q_scores > 100 ? 'color-red font-bd' : 'color-orange'}`}>{q_scores}</span>
</span>
}
</span>
</p>
<div className="edu-back-white">
{ exercise_questions.map((item, index) => {
if (item.question_type == 0 || item.question_type == 1) {
if (item.isNew) {
return <SingleEditor {...this.props} {...item} index={index} {...commonHandler}></SingleEditor>
} else {
return <SingleDisplay {...this.props} {...item} index={index} {...commonHandler}
displayCount={exercise_questions.length}
></SingleDisplay>
}
} else if (item.question_type == 2) {
if (item.isNew) {
return <JudgeEditor {...this.props} {...item} index={index} {...commonHandler}></JudgeEditor>
} else {
return <JudgeDisplay {...this.props} {...item} index={index} {...commonHandler} ></JudgeDisplay>
}
} else if (item.question_type == 3) {
if (item.isNew) {
return <NullEditor {...this.props} {...item} index={index} {...commonHandler}></NullEditor>
} else {
return <NullDisplay {...this.props} {...item} index={index} {...commonHandler} ></NullDisplay>
}
} else if (item.question_type == 4) {
if (item.isNew) {
return <MainEditor {...this.props} {...item} index={index} {...commonHandler} ></MainEditor>
} else {
return <MainDisplay {...this.props} {...item} index={index} {...commonHandler} ></MainDisplay>
}
} else if (item.question_type == 5) {
if (item.isNew) {
return <ShixunEditor {...this.props} {...item} index={index} {...commonHandler}
chooseShixunSuccess={this.chooseShixunSuccess}
></ShixunEditor>
} else {
return <ShixunDisplay {...this.props} {...item} index={index} {...commonHandler} ></ShixunDisplay>
}
}
return <div></div>
})}
{!commonHandler.exerciseIsPublish && <div className="problemShow padding30">
<ActionBtn style="green" className="mr20" onClick={() => this.addQuestion(null, Q_TYPE_SINGLE)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
<ActionBtn style="green" className="mr20" onClick={() => this.addQuestion(null, Q_TYPE_JUDGE)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
<ActionBtn style="green" className="mr20" onClick={() => this.addQuestion(null, Q_TYPE_NULL)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
<ActionBtn style="green" className="mr20" onClick={() => this.addQuestion(null, Q_TYPE_MAIN)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
<ActionBtn style="green" className="mr20" onClick={() => this.addShixun(null)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
{exercise_id && <ActionBtn style="blue" className="fr" onClick={() => this.goToPreview()}>
{/* <i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i> */}
试卷预览
</ActionBtn>}
</div>}
</div>
<ExerciseNewCommon
{...this.props}
{...this.state}
isEdit={this.isEdit}
initData={this.initData}
></ExerciseNewCommon>
</div>
</div>
)

@ -0,0 +1,619 @@
import React,{ Component } from "react";
import {
Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal, Tooltip
} from 'antd';
import { Q_TYPE_SINGLE, Q_TYPE_MULTI, Q_TYPE_JUDGE, Q_TYPE_NULL, Q_TYPE_MAIN, Q_TYPE_SHIXUN } from './new/common'
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
// import './board.css'
import "../common/formCommon.css"
// import { RouteHOC } from './common.js'
import CBreadcrumb from '../common/CBreadcrumb'
import {getUrl, ActionBtn} from 'educoder';
import SingleEditor from './new/SingleEditor'
import SingleDisplay from './new/SingleDisplay'
import JudgeEditor from './new/JudgeEditor'
import JudgeDisplay from './new/JudgeDisplay'
import NullEditor from './new/NullEditor'
import NullDisplay from './new/NullDisplay'
import MainEditor from './new/MainEditor'
import MainDisplay from './new/MainDisplay'
import ShixunEditor from './new/ShixunEditor'
import ShixunDisplay from './new/ShixunDisplay'
import ShixunChooseModal from '../coursesPublic/ShixunChooseModal'
import update from 'immutability-helper'
import './new/common.css'
import '../css/Courses.css'
const { TextArea } = Input;
const confirm = Modal.confirm;
const $ = window.$
const { Option } = Select;
const TITLE_MAX_LENGTH = 60;
class ExerciseNewCommon extends Component{
constructor(props){
super(props);
this.state = {
exercise_questions: [],
exercise_name: '',
exercise_description: '',
exercise_types: {},
editMode: !this.props.match.params.Id,
}
}
// 已发布试卷编辑保存的确认弹框
changeScore = (question_id,answerArray) =>{
this.props.confirm({
content:'修改了标准答案',
subContent:"是否重新计算学生答题的成绩?",
onOk:()=>{
this.sureChangeScore(question_id,answerArray)
},
onCancel:()=>{
this.addSuccess();
}
})
}
// 已发布试卷修改答案确认修改分数
sureChangeScore = (question_id,answerArray) =>{
let url=`/exercise_questions/${question_id}/update_scores.json`
axios.post((url),{
standard_answers:answerArray
}).then((result)=>{
if(result){
this.props.showNotification(`${result.data.message}`);
this.addSuccess();
}
}).catch((error)=>{
console.log(error);
})
}
fetchExercise = () => {
const Id = this.props.match.params.Id
this.isEdit = this.props.isEdit || !!Id
if (this.isEdit) {
const url = this.props.exercise_url ? `/${this.props.exercise_url }/${Id}.json` : `/exercises/${Id}/edit.json`
axios.get(url)
.then((response) => {
if (response.data.exercise) {
const { exercise, ...others } = response.data
exercise.exercise_name = exercise.exercise_name || exercise.name
exercise.exercise_description = exercise.exercise_description || exercise.description
this.setState({
...exercise,
...others,
editMode: false
})
this.props.initData && this.props.initData(response.data)
}
})
.catch(function (error) {
console.log(error);
});
} else {
const courseId=this.props.match.params.coursesId;
const newUrl = `/courses/${courseId}/exercises/new.json`
axios.get(newUrl)
.then((response) => {
if (response.data.status == 0) {
this.setState({
...response.data
})
}
})
.catch(function (error) {
console.log(error);
});
}
}
componentDidMount = () => {
this.fetchExercise()
}
handleSubmit = (e) => {
}
onSaveExercise = () => {
const { exercise_name, exercise_description } = this.state;
const exercise_id = this.props.match.params.Id
const courseId = this.props.match.params.coursesId
if (this.isEdit) {
// /exercise_banks/:id.json
const editUrl = `/${this.props.exercise_url ? this.props.exercise_url : 'exercises'}/${exercise_id}.json`
axios.put(editUrl, {
exercise_name,
exercise_description
})
.then((response) => {
if (response.data.status == 0) {
this.setState({editMode: false})
this.props.showNotification('试卷编辑成功')
}
})
.catch(function (error) {
console.log(error);
});
} else {
const url = `/courses/${courseId}/exercises.json`
axios.post(url, {
exercise_name,
exercise_description
})
.then((response) => {
if (response.data.status == 0) {
this.setState({editMode: false})
this.props.showNotification('试卷新建成功')
const exercise_id = response.data.data.exercise_id;
this.isEdit = true;
this.props.history.replace(`/courses/${courseId}/exercises/${exercise_id}/edit`);
}
})
.catch(function (error) {
console.log(error);
});
}
}
exercise_name_change = (e) => {
this.setState({exercise_name: e.target.value})
}
exercise_description_change = (e) => {
this.setState({exercise_description: e.target.value})
}
// #问题的类型0为单选题1为多选题2为判断题3为填空题4为主观题5为实训题
_checkIsEditing = () => {
if (this.editingId && $(this.editingId).length ) {
this.props.showNotification('请先保存或取消当前正在编辑的问题。')
$("html").animate({ scrollTop: $(this.editingId).offset().top - 100})
return true
}
return false
}
onEditorCancel = () => {
this.editingId = null;
// 找到编辑或新建的item新建就删掉item编辑就isNew改为false
const { exercise_questions } = this.state
let index = -1;
for(let i = 0; i < exercise_questions.length; i++) {
if (exercise_questions[i].isNew == true) {
index = i;
break;
}
}
if (exercise_questions[index].question_id) { // 编辑
this.setState(
(prevState) => ({
exercise_questions : update(prevState.exercise_questions, {[index]: { isNew: {$set: false}}})
// update(prevState.exercise_questions, {$splice: [[index, 1]]})
})
)
} else { // 新建
this.setState(
(prevState) => ({
exercise_questions : update(prevState.exercise_questions, {$splice: [[index, 1]]})
})
)
}
}
addQuestion = (question_id_to_insert_after, type) => {
if (!this.isEdit) {
this.props.showNotification('请先输入试卷标题,并保存试卷')
return;
}
if (this._checkIsEditing()) {
return;
}
if (type == Q_TYPE_SHIXUN) {
this.addShixun(question_id_to_insert_after)
} else {
this.addEditingQuestion(type, question_id_to_insert_after)
}
}
chooseShixun = (array) => {
this.addEditingQuestion(Q_TYPE_SHIXUN, this.question_id_to_insert_after, {
shixun_id: array[0]
})
}
chooseShixunSuccess = () => {
this.refs.shixunChooseModal.setVisible(false)
}
addShixun = (question_id_to_insert_after) => {
if (!this.isEdit) {
this.props.showNotification('请先输入试卷标题,并保存试卷')
return;
}
// TODO 弹框选择实训
if (this._checkIsEditing()) {
return;
}
this.refs.shixunChooseModal.setVisible(true)
this.question_id_to_insert_after = question_id_to_insert_after;
return;
// 拉取实训items
this.addEditingQuestion(Q_TYPE_SHIXUN, question_id_to_insert_after, {
shixun_id: 50
})
}
editQestion = (index) => {
if (this._checkIsEditing()) {
return;
}
this.editingId = `#question_${index}`
this.setState(
(prevState) => ({
exercise_questions : update(prevState.exercise_questions, {[index]: { isNew: {$set: true}}})
})
)
}
onSort = (index, question_id, isUp) => {
if (this._checkIsEditing()) {
return;
}
const url = `/exercise_questions/${question_id}/up_down.json`
axios.post(url, { opr: isUp ? 'up' : 'down'})
.then((response) => {
if (response.data.status == 0) {
// this.props.showNotification('移动成功')
this.fetchExercise()
}
})
.catch(function (error) {
console.log(error);
});
}
onSortDown = (index, question_id) => {
this.onSort(index, question_id, false)
}
onSortUp = (index, question_id) => {
this.onSort(index, question_id, true)
}
getInitScore = (question_type, question_id_to_insert_after) => {
/**
1.每个题型的首个题目默认值规则如下
选择题5 01
判断题2 2
填空题2 3
简答题10 4
实训题每个关卡5分 5
*/
let init_question_score = 0;
if (question_type == 0 || question_type == 1) {
init_question_score = 5
} else if (question_type == 2) {
init_question_score = 2
} else if (question_type == 3) {
init_question_score = 2
} else if (question_type == 4) {
init_question_score = 10
} else if (question_type == 5) {
init_question_score = 5
}
const _indexBefore = question_id_to_insert_after ? this.findIndexById(question_id_to_insert_after) : this.state.exercise_questions.length - 1
for (let i = _indexBefore; i >= 0; i--) {
if(this.state.exercise_questions[i].question_type == question_type) {
init_question_score = this.state.exercise_questions[i].question_score
break;
}
}
return init_question_score;
}
addEditingQuestion = (question_type, question_id_to_insert_after, otherAttributes) => {
let init_question_score = this.getInitScore(question_type, question_id_to_insert_after)
let questionObj = {
question_type: question_type, // 需要这个通过类型判断
init_question_score: init_question_score,
isNew: true, // 新建或编辑用是否有id区分是新建还是编辑
question_id_to_insert_after,
...otherAttributes
}
const { exercise_questions } = this.state;
let new_exercise_questions = exercise_questions.slice(0)
let newIndex = new_exercise_questions.length;
if (question_id_to_insert_after) {
const _indexBefore = this.findIndexById(question_id_to_insert_after)
new_exercise_questions.splice(_indexBefore + 1, 0, questionObj)
newIndex = _indexBefore + 1
} else {
new_exercise_questions.push(questionObj)
}
this.editingId = `#question_${newIndex}`
this.setState({ exercise_questions: new_exercise_questions }, () => {
setTimeout(() => {
$(this.editingId).length && $("html").animate({ scrollTop: $(this.editingId).offset().top - 100})
}, 500)
})
}
findIndexById = (id) => {
const { exercise_questions } = this.state
for(let i = 0; i < exercise_questions.length; i++) {
if (exercise_questions[i].question_id == id) {
return i;
}
}
}
onQestionDelete = (question_id) => {
this.props.confirm({
content: `确认要删除这个问题吗?`,
onOk: () => {
const url = `/exercise_questions/${question_id}.json`
axios.delete(url)
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification('删除成功')
this.fetchExercise()
// const { exercise_questions } = this.state
// const index = this.findIndexById(question_id)
// this.setState(
// (prevState) => ({
// exercise_questions : update(prevState.exercise_questions, {$splice: [[index, 1]]})
// })
// )
}
})
.catch(function (error) {
console.log(error);
});
}
})
}
addSuccess = () => {
this.editingId = null;
this.fetchExercise()
}
goToPreview = () => {
const exercise_id = this.props.match.params.Id
const courseId = this.props.match.params.coursesId
this.props.history.push(`/courses/${courseId}/exercises/${exercise_id}/student_exercise_list?tab=2`)
}
getAddQuestionUrl = () => {
const Id = this.props.match.params.Id
const url = this.props.exercise_url_questions ? `/${this.props.exercise_url_questions}.json` : `/exercises/${Id}/exercise_questions.json`
return url;
}
getEditQuestionUrl = (question_id) => {
const editUrl = this.props.exercise_url_questions ? `/${this.props.exercise_url_questions}/${question_id}.json` : `/exercise_questions/${question_id}.json`
return editUrl;
}
render() {
let { exercise_name, exercise_description, course_id, exercise_types,
exercise_questions, left_banner_id } = this.state;
// if (this.isEdit && !exercise_types) {
// return ''
// }
// const { getFieldDecorator } = this.props.form;
const { q_counts, q_scores, q_doubles, q_doubles_scores, q_judges, q_judges_scores,
q_mains, q_mains_scores, q_nulls, q_nulls_scores, q_shixuns, q_shixuns_scores, q_singles, q_singles_scores} = exercise_types;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
// sm: { span: 8 },
sm: { span: 24 },
},
wrapperCol: {
xs: { span: 24 },
// sm: { span: 16 },
sm: { span: 24 },
},
};
const { current_user } = this.props
const isAdmin = this.props.isAdmin()
const courseId=this.props.match.params.coursesId;
const exercise_id = this.props.match.params.Id
const isEdit = this.isEdit
const commonHandler = {
onQestionDelete: this.onQestionDelete,
addSuccess: this.addSuccess,
addQuestion: this.addQuestion,
onEditorCancel: this.onEditorCancel,
changeScore:this.changeScore,
editQestion: this.editQestion,
onSortDown: this.onSortDown,
onSortUp: this.onSortUp,
displayCount: exercise_questions.length,
exercise_status: this.state.exercise_status,
exerciseIsPublish: this.state.exercise_status >= 2,
getAddQuestionUrl: this.getAddQuestionUrl,
getEditQuestionUrl: this.getEditQuestionUrl,
}
return(
<React.Fragment>
<ShixunChooseModal
ref="shixunChooseModal"
chooseShixun={this.chooseShixun}
{...this.props}
singleChoose={true}
shixunsUrl={this.props.shixunsUrl}
></ShixunChooseModal>
<style>{`
.courseForm .formBlock {
padding: 20px 30px 30px 30px;
border-bottom: 1px solid #EDEDED;
margin-bottom: 0px;
background: #fff;
}
.exerciseNew .markdown-body {
max-width: 1128px;
}
`}</style>
{!this.state.editMode && <div className="padding20-30" style={{ background: '#fff'}}>
<div className="displayTitle font-16">
<span>{exercise_name}</span>
<a className="fr mr6" onClick={() => { this.setState({editMode: true}) }} style={{ lineHeight: '32px'}}>
<Tooltip title="编辑"><i className="iconfont icon-bianjidaibeijing font-20 color-green"></i></Tooltip>
</a>
</div>
<div className="displayDescription color-grey-9" dangerouslySetInnerHTML={{__html: exercise_description}}
style={{whiteSpace: 'pre-wrap'}}
></div>
</div>}
{this.state.editMode && <Form {...formItemLayout} onSubmit={this.handleSubmit}>
<div className="formBlock" style={{paddingBottom: '2px',borderBottom:"none"}}>
<Form.Item
label="试卷标题"
required
className="topicTitle "
>
{/* {getFieldDecorator('subject', {
rules: [{
required: true, message: '请输入标题',
}, {
max: 20, message: '最大限制为20个字符',
}],
})( */}
<style>
{
`
.exercicenewinputysl .ant-input{
border-right: none !important;
height: 40px !important;
}
`
}
</style>
<Input placeholder={`请输入试卷标题,最大限制${TITLE_MAX_LENGTH}个字符`} maxLength={TITLE_MAX_LENGTH} className="mt5 exercicenewinputysl" value={exercise_name}
onChange={this.exercise_name_change} addonAfter={`${exercise_name ? exercise_name.length : 0}/${TITLE_MAX_LENGTH}`}
/>
{/* )} */}
</Form.Item>
<Form.Item
label="&nbsp;&nbsp;试卷须知"
>
{/* {getFieldDecorator('select_board_id', {
// initialValue: '3779',
})( */}
<TextArea placeholder="请在此输入本次试卷答题的相关说明最大限制100个字符" className="mt5" style={{height:"120px"}} value={exercise_description}
onChange={this.exercise_description_change}
/>
{/* )} */}
</Form.Item>
<Form.Item>
{/* defalutSubmitbtn */}
<a className="task-btn task-btn-orange fr mt4" style={{height: '30px', width: '70px'}}
onClick={this.onSaveExercise}
>保存</a>
{ this.isEdit && <a onClick={() => this.setState({editMode: false})} className="defalutCancelbtn fr mt4"
style={{height: '30px', width: '70px', fontSize: '14px', lineHeight: '30px', marginRight: '16px'}}>取消</a>}
{/* <Button type="primary" onClick={this.onSaveExercise} className="fr">保存</Button> */}
</Form.Item>
</div>
{/* <div className="clearfix mt30 mb30">
<a className="defalutCancelbtn fl" onClick={() => {}}>取消</ a>
</div> */}
</Form>}
<p className="clearfix padding20-30 color-grey-9">
<span className="fl">
{ !!q_singles && <span className="mr20">单选题{q_singles}{q_singles_scores}</span>}
{ !!q_doubles && <span className="mr20">多选题{q_doubles}{q_doubles_scores}</span>}
{ !!q_judges && <span className="mr20">判断题{q_judges}{q_judges_scores}</span>}
{ !!q_nulls && <span className="mr20">填空题{q_nulls}{q_nulls_scores}</span>}
{ !!q_mains && <span className="mr20">简答题{q_mains}{q_mains_scores}</span>}
{ !!q_shixuns && <span className="mr20">实训题{q_shixuns}{q_shixuns_scores}</span> }
</span>
<span className="fr">
{ !!q_counts &&
<span>
合计 <span className="color-blue">{q_counts}</span>
<span className={`${q_scores > 100 ? 'color-red font-bd' : 'color-orange'}`}>{q_scores}</span>
</span>
}
</span>
</p>
<div className="edu-back-white">
{ exercise_questions.map((item, index) => {
if (item.question_type == 0 || item.question_type == 1) {
if (item.isNew) {
return <SingleEditor {...this.props} {...item} index={index} {...commonHandler}></SingleEditor>
} else {
return <SingleDisplay {...this.props} {...item} index={index} {...commonHandler}
displayCount={exercise_questions.length}
></SingleDisplay>
}
} else if (item.question_type == 2) {
if (item.isNew) {
return <JudgeEditor {...this.props} {...item} index={index} {...commonHandler}></JudgeEditor>
} else {
return <JudgeDisplay {...this.props} {...item} index={index} {...commonHandler} ></JudgeDisplay>
}
} else if (item.question_type == 3) {
if (item.isNew) {
return <NullEditor {...this.props} {...item} index={index} {...commonHandler}></NullEditor>
} else {
return <NullDisplay {...this.props} {...item} index={index} {...commonHandler} ></NullDisplay>
}
} else if (item.question_type == 4) {
if (item.isNew) {
return <MainEditor {...this.props} {...item} index={index} {...commonHandler} ></MainEditor>
} else {
return <MainDisplay {...this.props} {...item} index={index} {...commonHandler} ></MainDisplay>
}
} else if (item.question_type == 5) {
if (item.isNew) {
return <ShixunEditor {...this.props} {...item} index={index} {...commonHandler}
chooseShixunSuccess={this.chooseShixunSuccess}
></ShixunEditor>
} else {
return <ShixunDisplay {...this.props} {...item} index={index} {...commonHandler} ></ShixunDisplay>
}
}
return <div></div>
})}
{!commonHandler.exerciseIsPublish && <div className="problemShow padding30">
<ActionBtn style="green" className="mr20" onClick={() => this.addQuestion(null, Q_TYPE_SINGLE)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
<ActionBtn style="green" className="mr20" onClick={() => this.addQuestion(null, Q_TYPE_JUDGE)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
<ActionBtn style="green" className="mr20" onClick={() => this.addQuestion(null, Q_TYPE_NULL)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
<ActionBtn style="green" className="mr20" onClick={() => this.addQuestion(null, Q_TYPE_MAIN)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
<ActionBtn style="green" className="mr20" onClick={() => this.addShixun(null)}>
<i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i>
</ActionBtn>
{exercise_id && <ActionBtn style="blue" className="fr" onClick={() => this.goToPreview()}>
{/* <i className="iconfont icon-tianjiafangda color-white font-14 mr5" style={{ marginTop: '-1px', display: 'inline-block'}}></i> */}
试卷预览
</ActionBtn>}
</div>}
</div>
</React.Fragment>
)
}
}
// RouteHOC()
export default (ExerciseNewCommon);

@ -85,7 +85,7 @@ class SingleEditor extends Component{
}*/
const Id = this.props.match.params.Id
if (question_id) {
const editUrl = `/exercise_questions/${question_id}.json`
const editUrl = this.props.getEditQuestionUrl(question_id);
axios.put(editUrl, {
question_title,
question_type: 2,
@ -105,9 +105,10 @@ class SingleEditor extends Component{
console.log(error);
});
} else {
const url = `/exercises/${Id}/exercise_questions.json`
const url = this.props.getAddQuestionUrl();
axios.post(url, {
exercise_bank_id: Id,
question_title,
question_type: 2,
question_score,

@ -70,7 +70,7 @@ class MainEditor extends Component{
}*/
const Id = this.props.match.params.Id
if (question_id) {
const editUrl = `/exercise_questions/${question_id}.json`
const editUrl = this.props.getEditQuestionUrl(question_id);
axios.put(editUrl, {
question_title,
question_type: 4,
@ -88,9 +88,10 @@ class MainEditor extends Component{
console.log(error);
});
} else {
const url = `/exercises/${Id}/exercise_questions.json`
const url = this.props.getAddQuestionUrl();
axios.post(url, {
exercise_bank_id: Id,
question_title,
question_type: 4,
question_score,

@ -124,7 +124,7 @@ class NullEditor extends Component{
}*/
const Id = this.props.match.params.Id
if (question_id) {
const editUrl = `/exercise_questions/${question_id}.json`
const editUrl = this.props.getEditQuestionUrl(question_id);
axios.put(editUrl, {
question_title,
question_type: 3,
@ -145,9 +145,10 @@ class NullEditor extends Component{
console.log(error);
});
} else {
const url = `/exercises/${Id}/exercise_questions.json`
const url = this.props.getAddQuestionUrl();
axios.post(url, {
exercise_bank_id: Id,
question_title,
question_type: 3,
question_score,

@ -113,7 +113,7 @@ class ShixunEditor extends Component{
}*/
const Id = this.props.match.params.Id
if (question_id) {
const editUrl = `/exercise_questions/${question_id}.json`
const editUrl = this.props.getEditQuestionUrl(question_id);
axios.put(editUrl, {
question_title,
question_type: 5,
@ -131,9 +131,10 @@ class ShixunEditor extends Component{
console.log(error);
});
} else {
const url = `/exercises/${Id}/exercise_questions.json`
const url = this.props.getAddQuestionUrl();
axios.post(url, {
exercise_bank_id: Id,
question_title,
question_type: 5,
question_scores,

@ -123,7 +123,7 @@ class SingleEditor extends Component{
}*/
const Id = this.props.match.params.Id
if (question_id) {
const editUrl = `/exercise_questions/${question_id}.json`
const editUrl = this.props.getEditQuestionUrl(question_id);
axios.put(editUrl, {
question_title,
question_type: answerArray.length > 1 ? 1 : 0,
@ -143,9 +143,10 @@ class SingleEditor extends Component{
console.log(error);
});
} else {
const url = `/exercises/${Id}/exercise_questions.json`
const url = this.props.getAddQuestionUrl();
axios.post(url, {
exercise_bank_id: Id,
question_title,
question_type: answerArray.length > 1 ? 1 : 0,
question_score,

@ -0,0 +1,519 @@
import React,{ Component } from "react";
import {
Form, Input, Button, Upload, Icon , message, Select
} from 'antd';
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
import axios from 'axios'
import { City , getUploadActionUrl , appendFileSizeToUploadFileAll } from 'educoder';
const NAME_COUNT=60;
class GraduateTopicNewForm extends Component{
constructor(props){
super(props);
this.mdRef = React.createRef();
this.state = {
fileList: [],
teacherList:[],
topic_property_first:[],
topic_property_second:[],
topic_repeat:[],
topic_source:[],
topic_type:[],
addonAfter:0,
cityDefaultValue:undefined
}
}
// init编辑信息
initValue=(result)=>{
this.setState({
teacherList:result.data.teacher_list,
topic_property_first:result.data.topic_property_first,
topic_property_second:result.data.topic_property_second,
topic_repeat:result.data.topic_repeat,
topic_source:result.data.topic_source,
topic_type:result.data.topic_type,
addonAfter:parseInt(result.data.selected_data.name.length)
})
this.props.form.setFieldsValue({
tea_id:result.data.selected_data.tea_id,
name:result.data.selected_data.name,
city: [result.data.selected_data.province,result.data.selected_data.city],
topic_type:result.data.selected_data.topic_type || undefined,
topic_source:result.data.selected_data.topic_source || undefined,
topic_property_first:result.data.selected_data.topic_property_first || undefined,
topic_property_second:result.data.selected_data.topic_property_second || undefined,
source_unit:result.data.selected_data.source_unit,
topic_repeat:result.data.selected_data.topic_repeat || undefined
});
this.mdRef.current.setValue(result.data.selected_data.description)
const _fileList = result.data.attachments.map(item => {
return {
id: item.id,
uid: item.id,
name: item.title,
url: item.url,
status: 'done'
}
})
this.setState({ fileList: _fileList, cityDefaultValue: [result.data.selected_data.province,result.data.selected_data.city] })
}
//init新建信息
initNewInfo=(result)=>{
this.setState({
teacherList:result.data.teacher_list,
topic_property_first:result.data.topic_property_first,
topic_property_second:result.data.topic_property_second,
topic_repeat:result.data.topic_repeat,
topic_source:result.data.topic_source,
topic_type:result.data.topic_type
})
this.props.form.setFieldsValue({
tea_id:this.props.current_user && this.props.current_user.user_id
})
}
// 附件相关 START
handleChange = (info) => {
if (info.file.status === 'done' || info.file.status === 'uploading') {
let contentFileList = info.fileList;
// this.setState({ fileList: appendFileSizeToUploadFileAll(contentFileList)});
// let list = appendFileSizeToUploadFileAll(contentFileList);
// let arr = list.map(item=>{
// return ( item.response && item.response.id )
// })
this.setState({
fileList:contentFileList
});
}
}
onAttachmentRemove = (file) => {
this.props.confirm({
content: '确定要删除这个附件吗?',
onOk: () => {
this.deleteAttachment(file)
},
onCancel() {
console.log('Cancel');
},
});
return false;
}
deleteAttachment = (file) => {
console.log(file);
let id=file.response ==undefined ? file.id : file.response.id
const url = `/attachments/${id}.json`
axios.delete(url).then((response) => {
if (response.data) {
const { status } = response.data;
if (status == 0) {
console.log('--- success')
this.setState((state) => {
const index = state.fileList.indexOf(file);
const newFileList = state.fileList.slice();
newFileList.splice(index, 1);
return {
fileList: newFileList,
};
});
}
}
})
.catch(function (error) {
console.log(error);
});
}
changeTopicName=(e)=>{
// let num= 60 - parseInt(e.target.value.length);
this.setState({
addonAfter:e.target.value.length
})
}
handleSubmit = (e) => {
e.preventDefault();
const topicId = this.props.topicId
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
if (topicId !=undefined) {
// 编辑
// const editTopic = this.editTopic
let attachment_ids = undefined
if (this.state.fileList) {
attachment_ids = this.state.fileList.map(item => {
return item.response ? item.response.id : item.id
})
}
const param = {
...values,
province: values.city==undefined?"":values.city[0],
city: values.city==undefined?"":values.city[1],
}
this.props.editSave && this.props.editSave(param,attachment_ids,topicId);
} else {
// 新建
let attachment_ids = undefined
if (this.state.fileList) {
attachment_ids = this.state.fileList.map(item => {
return item.response.id
})
}
const param ={
...values,
province: values.city==undefined?"":values.city[0],
city: values.city==undefined?"":values.city[1],
}
this.props.newSubmit && this.props.newSubmit(param,attachment_ids,topicId);
}
} else {
$("html").animate({ scrollTop: $('html').scrollTop() - 100 })
}
});
}
// 附件相关 ------------ END
render(){
let{
fileList,
teacherList,
topic_property_first,
topic_property_second,
topic_repeat,
topic_source,
topic_type,
addonAfter,
cityDefaultValue
}=this.state;
const { getFieldDecorator } = this.props.form;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
// sm: { span: 8 },
sm: { span: 24 },
},
wrapperCol: {
xs: { span: 24 },
// sm: { span: 16 },
sm: { span: 24 },
},
};
const uploadProps = {
width: 600,
fileList,
multiple: true,
action: `${getUploadActionUrl()}`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: (file) => {
const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) {
//message.error('文件大小必须小于150MB!');
this.props.define({
title:'提示',
content:"该文件无法上传。超过文件大小限制(150MB),建议上传到百度云等其它共享工具里然后再txt文档里给出链接以及共享密码并上传"
})
return isLt150M;
}
}
};
let { topicId , teacherName }=this.props;
return(
<React.Fragment>
<Form {...formItemLayout} onSubmit={this.handleSubmit}>
<div className="createPage">
{
teacherName &&
<Form.Item
label="指导老师"
>
{getFieldDecorator('tea_id', {
rules: [{
required: true, message: '请选择指导老师'
}],
})(
<Select style={{"width":"20%"}} placeholder="请选择指导老师">
{
teacherList && teacherList.map((item,key)=>{
return(
<Option value={item.id} id={key}>{item.name}</Option>
)
})
}
</Select>
)}
</Form.Item>
}
<style>
{
`
.exercicenewinputysl .ant-input{
border-right: none !important;
height: 40px !important;
}
`
}
</style>
<Form.Item
label="选题名称"
className="mt15"
>
{getFieldDecorator('name', {
rules: [{
required: true, message: '请输入选题名称',
}, {
max: 60, message: '最大限制为60个字符',
}],
})(
<Input placeholder="请输入帖子选题名称最大限制60个字符" maxLength="60" onInput={this.changeTopicName} autoComplete="off" addonAfter={`${String(addonAfter)}/${NAME_COUNT}`} className="searchViewAfter exercicenewinputysl" />
)}
</Form.Item>
</div>
<style>{`
.courseMessageMD {
width: 1140px;
}
.uploadBtn.ant-btn {
border: none;
color: #4CACFF;
box-shadow: none;
background: transparent;
padding: 0 6px;
}
.upload_1 .ant-upload-list {
width: 350px;
margin-bottom:10px;
}
.ant-upload-list-item{
margin-top:0px!important;
}
.ant-form-item-children{
position:unset
}
.rememberTip{
position:absolute;
right:0px;
bottom:-10px;
}
.chooseDes .ant-form-explain{
position:absolute;
bottom:-10px;
left:0px;
}
.setUploadStyle .uploadBtn{
height:20px;
line-height:20px;
}
.setUploadStyle .ant-form-item-control{
margin-top:15px!important;
line-height:22px!important;
}
.setUploadStyle .ant-upload-list{
margin-top:5px;
}
`}</style>
<div className="createPage">
<Form.Item
label="选题简介"
style={{"borderBottom":'none'}}
className="chooseDes pr"
>
{getFieldDecorator('description', {
rules: [{
required: true, message: '请输入选题简介',
}, {
max: 10000, message: '最大限制为10000个字符',
}],
})(
// initValue={this.editTopic ? this.editTopic.content : ''}
<TPMMDEditor ref={this.mdRef} placeholder={'请简要说明选题内容最大限制5000个字符'}
mdID={'courseMessageMD'} className="courseMessageMD"></TPMMDEditor>
)}
</Form.Item>
<Form.Item
className="setUploadStyle"
>
{
getFieldDecorator('file',{
rules:[{
required:false
}]
})(
<Upload {...uploadProps} className="upload_1 ">
<Button className="uploadBtn">
<Icon type="upload" /> 上传附件
</Button>
<span className="color-grey-c">(单个文件150M以内)</span>
</Upload>
)
}
</Form.Item>
<div className="clearfix">
<Form.Item className="fl mr20 with20" style={{"marginRight":"20px"}}>
{getFieldDecorator('topic_type', {
rules: [{
required: false, message: '',
}],
})(
<Select placeholder="请选择选题类型">
{
topic_type && topic_type.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})
}
</Select>
)}
</Form.Item>
<Form.Item className="fl mr20 with20" style={{"marginRight":"20px"}}>
{getFieldDecorator('topic_source', {
rules: [{
required: false, message: '',
}],
})(
<Select placeholder="请输入选题来源">
{
topic_source && topic_source.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})
}
</Select>
)}
</Form.Item>
<Form.Item className="fl mr20 with20" style={{"marginRight":"20px"}}>
{getFieldDecorator('topic_property_first', {
rules: [{
required: false, message: '',
}],
})(
<Select placeholder="请输入选题性质1">
{
topic_property_first && topic_property_first.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})
}
</Select>
)}
</Form.Item>
<Form.Item className="fl mr20 with20" style={{"marginRight":"20px"}}>
{getFieldDecorator('topic_property_second', {
rules: [{
required: false, message: '',
}],
})(
<Select placeholder="请输入选题性质2">
{
topic_property_second && topic_property_second.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})
}
</Select>
)}
</Form.Item>
</div>
</div>
<style>{`
.courseForm .flexBlock.formBlock {
align-items: flex-end;
display: flex;
flex-wrap: wrap;
}
.courseForm .flexBlock .tag {
margin-left: 8px;
margin-right: 6px;
margin-bottom: 16px;
}
.flexBlock .ant-row.ant-form-item {
margin-bottom: 6px;
}
.ant-cascader-menu{
min-width:125px!important;
}
`}</style>
<div className="createPage" style={{"borderBottom":"none"}}>
<Form.Item
label="选题来源单位"
className="with22"
>
{getFieldDecorator('source_unit', {
rules: [{
required: false, message: '',
}],
})(
<Input placeholder="请填写来源单位" autoComplete="off" className="searchView"/>
)}
</Form.Item>
<Form.Item
label="选择重复情况"
className="mt15 with22"
>
{getFieldDecorator('topic_repeat', {
rules: [{
required: false, message: '',
}],
})(
<Select placeholder="请选择选题重复情况">
{
topic_repeat && topic_repeat.map((item,key)=>{
return(
<Option value={item.id} key={key}>{item.name}</Option>
)
})
}
</Select>
)}
</Form.Item>
<Form.Item
label="调研或实习地点"
className="mt15 with22 setAreaStyle"
>
{getFieldDecorator('city', {
rules: [{
initialValue: cityDefaultValue,
type: 'array',
required: false, message: '',
}],
})(
<City ></City>
)}
</Form.Item>
</div>
<Form.Item>
<div className="clearfix mt30 mb30">
<Button type="primary" htmlType="submit" className="defalutSubmitbtn fl mr20">{topicId==undefined?"提交":"保存"}</Button>
<a className="defalutCancelbtn fl" onClick={this.props.editCancel}>取消</ a>
</div>
</Form.Item>
</Form>
</React.Fragment>
)
}
}
const WrappedGraduateTopicNewForm = Form.create({ name: 'topicPostWorksNew' })(GraduateTopicNewForm);
// RouteHOC()
export default (WrappedGraduateTopicNewForm);

@ -21,7 +21,9 @@ class GroupPackage extends Component {
}
}
DownloadOpenPdf=(type,url)=>{
type===true?window.open(url):window.location.href=url;
}
componentDidMount() {
console.log("Groupjobquesanswer");
console.log("componentDidMount");
@ -54,9 +56,9 @@ class GroupPackage extends Component {
render() {
let{attachments}=this.props;
return (
<div className="color-grey df yslquesmat26" key={0} style={{ lineHeight: '17px'}}>
<div className="color-grey df yslquesmat26" key={this.props.key} style={{ lineHeight: '17px'}}>
<a className="color-grey ">
<i className="font-14 color-green iconfont icon-fujian mr8" aria-hidden="true"></i>
</a>
@ -73,11 +75,11 @@ class GroupPackage extends Component {
`
}
</style>
<a href={"/"} title={''}
<a onClick={()=>this.DownloadOpenPdf(attachments.is_pdf,attachments.url)} title={attachments&&attachments.title}
className="mr12 yslahover overflowHidden1" length="58" style={{maxWidth:'480px',fontSize:"16px",}}>
<span>清除浏览器缓存或换个浏览器操作指南更新版本.zip</span>
<span>{attachments&&attachments.title}</span>
</a>
<span className="color656565 color-grey-6 font-12 mr8">{2}</span>
<span className="color656565 color-grey-6 font-12 mr8">{attachments&&attachments.filesize}</span>
</div>
)

@ -54,18 +54,42 @@ class GroupPackage extends Component {
render() {
let{datas,bool}=this.props;
return (
bool===true?
<div className="ml47text">
<p>
<span className="ysltextcolor66">分组要求</span>
<span className="ysltextcolor05">2~ 5学生提交作品时需要关联同组成员组内成员作品共享</span>
</p>
{
datas===undefined?"":datas.min_num===undefined||datas.max_num===undefined?"":datas.min_num===null||datas.max_num===null?"":
<p>
<span className="ysltextcolor66">分组要求</span>
<span className="ysltextcolor05">{datas&&datas.min_num}~ {datas&&datas.max_num}学生提交作品时需要关联同组成员组内成员作品共享</span>
</p>
}
<p>
<span className="ysltextcolor66">基于项目实施</span>
<span className="ysltextcolor05">学生必须在本平台创建项目项目管理员可以提交作品</span>
</p>
</div>
:<div className="ml47text">
{
datas===undefined?"":datas.group_info===undefined?"":datas.group_info.min_number===undefined||datas.group_info.max_number===undefined?"":
datas.group_info.min_number===null||datas.group_info.max_number===null?"":
<p>
<span className="ysltextcolor66">分组要求</span>
<span className="ysltextcolor05">{datas&&datas.group_info&&datas.group_info.min_number}~ {datas&&datas.group_info&&datas.group_info.max_number}学生提交作品时需要关联同组成员组内成员作品共享</span>
</p>
}
{
datas&&datas.group_info&&datas.group_info.base_on_project?
<p>
<span className="ysltextcolor66">基于项目实施</span>
<span className="ysltextcolor05">学生必须在本平台创建项目项目管理员可以提交作品</span>
</p>
:""
}
</div>
)
}
}

@ -57,20 +57,21 @@ class Groupjobbandetails extends Component {
render() {
let{datas}=this.props;
return (
<div className=" clearfix edu-back-white" ref='targetElementTrainingjobsetting' style={{margin: "auto", minWidth:"1200px"}}>
<div className="yslquestionbank1">
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML("C++是C语言的面向对象扩展是C语言的一个超集同时也是历史最悠久、最受欢迎的程序设计语言之一。根据C++创始人Stroustrup的自述C++是一个“更好的C语言”。\n" +
"\n" +
"输入输出是计算机程序的基本功能。程序本质上是对数据进行处理的一系列操作,一般程序都可以分解为:“数据输入”、“数据处理”和“数据输出”三个步骤。标准输入输出(键盘输入和显示器输出)是程序的重要组成部分。\n" +
"\n" +
"本实训项目的主要目标是学习和掌握C++程序的基本结构和基本输入输出主要内容包括标准C语言自有的单个字符的输入输出、格式化的输入输出以及C++扩展的使用流对象的输入输出").replace(/▁/g, "▁▁▁")}}/>
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML(datas&&(datas.description===null?"无":datas.description==="null"?"无":datas.description)).replace(/▁/g, "▁▁▁")}}/>
<GroupPackage></GroupPackage>
{datas.attachments === undefined ? "" : datas.attachments.map((item, key) => {
return (
<GroupPackage key={key} attachments={item}></GroupPackage>
)
})}
<GroupPackage2></GroupPackage2>
<GroupPackage2 datas={datas} bool={true}></GroupPackage2>
</div>

@ -14,6 +14,7 @@ import "../common/formCommon.css";
import '../css/Courses.css';
import '../css/busyWork.css';
import '../poll/pollStyle.css';
import Generaljobdetails from "../questionbank/Generaljobdetails";
class GroupjobbankPage extends Component {
//分组作业内容详情
@ -43,7 +44,7 @@ class GroupjobbankPage extends Component {
console.log(e);
console.log("44");
}
this.getonedata();
}
@ -64,6 +65,9 @@ class GroupjobbankPage extends Component {
this.setState({
shixuntypes: types[3]
})
this.getonedata();
}
getonedata=()=>{
if( this.props.match.params.workid){
this.setState({
workid: this.props.match.params.workid,
@ -88,7 +92,7 @@ class GroupjobbankPage extends Component {
if(response){
if(response.data){
this.setState({
datas:response.data.informs,
datas:response.data,
})
}else {
this.setState({
@ -120,9 +124,8 @@ class GroupjobbankPage extends Component {
///////////////教师截止
render() {
let {tab} = this.state;
let {tab,datas} = this.state;
const isAdmin = this.props.isAdmin();
// console.log(119)
@ -143,10 +146,10 @@ class GroupjobbankPage extends Component {
</div>
<div className="educontent mb20">
<p className=" fl color-black summaryname" style={{heigth: "33px"}}>
MySQL数据库编程开发实训基础篇
{datas&&datas.name}
</p>
<CoursesListType
typelist={["公开"]}
typelist={datas.is_public===true?["公开"]:["私有"]}
/>
</div>
@ -155,15 +158,15 @@ class GroupjobbankPage extends Component {
<div className=" clearfix edu-back-white poll_list">
<a className={parseInt(tab) === 0 ? "active ml12" : "ml12"} onClick={(e) => this.ChangeTab(0)}>内容详情</a>
<a className={parseInt(tab) === 1 ? "active ml12" : "ml12"} onClick={(e) => this.ChangeTab(1)}>参考答案</a>
<a className="fr color-blue font-16" >发送</a>
<a className="fr color-blue font-16" >编辑</a>
<a className="fr color-blue font-16" >删除</a>
<a className="fr color-blue font-16" >发送</a>
<a className="fr color-blue font-16" >编辑</a>
<a className="fr color-blue font-16" >删除</a>
</div>
</div>
</div>
<Spin size="large" spinning={this.state.isSpin} id={"cdiv"}>
{parseInt(tab) === 0 ? <Groupjobbandetails/>:""}
{parseInt(tab) === 1 ? <Groupjobquesanswer/>:""}
{parseInt(tab) === 0 ? <Groupjobbandetails {...this.props} {...this.state} datas={datas}/>:""}
{parseInt(tab) === 1 ? <Groupjobquesanswer {...this.props} {...this.state} datas={datas}/>:""}
</Spin>
</div>
</div>

@ -10,6 +10,7 @@ import {
Tooltip,
notification,
} from "antd";
import AttachmentsList from '../../../common/components/attachment/AttachmentList'
import GroupPackage from './GroupPackage';
import GroupPackage2 from './GroupPackage2';
import './questionbanks.css';
@ -56,20 +57,18 @@ class Groupjobquesanswer extends Component {
render() {
let{datas}=this.props;
return (
<div className=" clearfix edu-back-white" ref='targetElementTrainingjobsetting' style={{margin: "auto", minWidth:"1200px"}}>
<div className="yslquestionbank1">
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML("C++是C语言的面向对象扩展是C语言的一个超集同时也是历史最悠久、最受欢迎的程序设计语言之一。根据C++创始人Stroustrup的自述C++是一个“更好的C语言”。\n" +
"\n" +
"输入输出是计算机程序的基本功能。程序本质上是对数据进行处理的一系列操作,一般程序都可以分解为:“数据输入”、“数据处理”和“数据输出”三个步骤。标准输入输出(键盘输入和显示器输出)是程序的重要组成部分。\n" +
"\n" +
"本实训项目的主要目标是学习和掌握C++程序的基本结构和基本输入输出主要内容包括标准C语言自有的单个字符的输入输出、格式化的输入输出以及C++扩展的使用流对象的输入输出").replace(/▁/g, "▁▁▁")}}/>
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML(datas&&(datas.description===null?"无":datas.description==="null"?"无":datas.description)).replace(/▁/g, "▁▁▁")}}/>
{datas.attachments === undefined ? "" :
<AttachmentsList {...this.state} {...this.props} attachments={datas.attachments} ></AttachmentsList>}
<GroupPackage></GroupPackage>
<GroupPackage2></GroupPackage2>
<GroupPackage2 datas={datas} bool={true}></GroupPackage2>
</div>

@ -1,14 +1,13 @@
import React,{ Component } from "react";
import {Checkbox,Radio} from "antd";
import '../css/members.css'
import '../css/busyWork.css'
import './pollStyle.css'
import PollDetailTabThirdInfo from './PollDetailTabThirdInfo'
import axios from 'axios';
const map={1:"单选题",2:"多选题",3:"主观题",4:"主观题"}
class PollDetailTabThird extends Component{
constructor(props){
super(props);
@ -36,105 +35,7 @@ class PollDetailTabThird extends Component{
let {pollDetail}=this.state;
return(
<div>
{
pollDetail && pollDetail.poll.polls_description &&
<p style={{backgroundColor:"#F2F9FF",whiteSpace:"pre-wrap"}} className="color-blue pt15 pb15 pl30 pr30">{ pollDetail.poll.polls_description }</p>
}
<div className="edu-back-white">
<p className="padding20-30 clearfix bor-bottom-greyE edu-txt-left">
{ pollDetail && pollDetail.question_types.q_counts===0 ? "" :
<span className="color-grey-3">
{
pollDetail && pollDetail.question_types.q_counts > 0 &&
<span>合计{pollDetail.question_types.q_counts}</span>
}
{
pollDetail && pollDetail.question_types.q_singles > 0 &&
<span className="mr15 color-grey-9">单选题{pollDetail.question_types.q_singles}</span>
}
{
pollDetail && pollDetail.question_types.q_doubles > 0 &&
<span className="mr15 color-grey-9">多选题{pollDetail.question_types.q_doubles}</span>
}
{
pollDetail && pollDetail.question_types.q_mains > 0 &&
<span className="color-grey-9">主观题{pollDetail.question_types.q_mains}</span>
}
</span>
}
</p>
{
pollDetail && pollDetail.questions.map((item,key)=>{
console.log("ddd");
console.log(item.question.min_choices);
return(
<div className="previewList">
<p className="pl30 pr30 pt30 pb15 font-16 clearfix">
<span className="color-blue mr8 fl">{item.question.question_number}{map[item.question.question_type]}</span>
{ item.question.is_necessary==1 ? <span className="mustAnswer fl ml10 mr10">必答</span>:<span className="mustAnswer fl ml10 mr10"></span> }
{ item.question.question_type == 2 && item.question.min_choices != undefined && item.question.min_choices != null && item.question.max_choices != undefined && item.question.max_choices != null ?
<span className="color-grey-9 font-14 fl mt2">
{
item.question.min_choices == item.question.max_choices ? "可选"+item.question.max_choices+"项" :
"可选"+item.question.min_choices+"-"+item.question.max_choices+"项"
}
</span>:""
}
</p>
<li className="pl30 pr30 pb15">{item.question.question_title}</li>
{
// 单选题
item.question.question_type==1 &&
<Radio.Group className="answerList" disabled>
{
item.question.answers.map((index,k)=>{
return(
<li className="df">
<Radio className="fl" value={index.answer_id}></Radio>
<span className={index.answer_text=="其他"?"break-word":"break-word flex1"}>{index.answer_text}</span>
{
index.answer_text=="其他" ? <p className="textLine"></p>:""
}
</li>
)
})
}
</Radio.Group>
}
{
// 多选题
item.question.question_type==2 &&
<Checkbox.Group className="answerList" disabled>
{
item.question.answers.map((index,k)=>{
return(
<li className="df" key={k}>
<Checkbox className="fl mr8" value={index.answer_id} key={index.answer_id}></Checkbox>
<span className={index.answer_text=="其他"?"break-word":"break-word flex1"}>{index.answer_text}</span>
{
index.answer_text=="其他" ? <p className="textLine"></p>:""
}
</li>
)
})
}
</Checkbox.Group>
}
{
// 主观题
item.question.question_type == 3 &&
<div className="mt10 pl30 pr30 pb20">
<textarea placeholder="在此填入答案" readOnly className="winput-100-130"></textarea>
</div>
}
</div>
)
})
}
</div>
<PollDetailTabThirdInfo {...this.props} {...this.state} pollDetail = {pollDetail}></PollDetailTabThirdInfo>
</div>
)
}

@ -0,0 +1,117 @@
import React,{ Component } from "react";
import {Checkbox,Radio} from "antd";
import '../css/members.css'
import '../css/busyWork.css'
import './pollStyle.css'
const map={1:"单选题",2:"多选题",3:"主观题",4:"主观题"}
class PollDetailTabThirdInfo extends Component{
constructor(props){
super(props);
}
render(){
let { pollDetail }=this.props;
return(
<div className="edu-back-white">
{
pollDetail && pollDetail.poll.polls_description &&
<p style={{whiteSpace:"pre-wrap"}} className="color-grey-3 padding20-30">{ pollDetail.poll.polls_description }</p>
}
<p className="padding20-30 clearfix edu-txt-left" style={{background:"#fafafa"}}>
{ pollDetail && pollDetail.question_types.q_counts===0 ? "" :
<span className="color-grey-3">
{
pollDetail && pollDetail.question_types.q_counts > 0 &&
<span>合计{pollDetail.question_types.q_counts}</span>
}
{
pollDetail && pollDetail.question_types.q_singles > 0 &&
<span className="mr15 color-grey-9">单选题{pollDetail.question_types.q_singles}</span>
}
{
pollDetail && pollDetail.question_types.q_doubles > 0 &&
<span className="mr15 color-grey-9">多选题{pollDetail.question_types.q_doubles}</span>
}
{
pollDetail && pollDetail.question_types.q_mains > 0 &&
<span className="color-grey-9">主观题{pollDetail.question_types.q_mains}</span>
}
</span>
}
</p>
{
pollDetail && pollDetail.questions.map((item,key)=>{
return(
<div className="previewList">
<p className="pl30 pr30 pt30 pb15 font-16 clearfix">
<span className="color-blue mr8 fl">{item.question.question_number}{map[item.question.question_type]}</span>
{ item.question.is_necessary==1 ? <span className="mustAnswer fl ml10 mr10">必答</span>:<span className="mustAnswer fl ml10 mr10"></span> }
{ item.question.question_type == 2 && item.question.min_choices != undefined && item.question.min_choices != null && item.question.max_choices != undefined && item.question.max_choices != null ?
<span className="color-grey-9 font-14 fl mt2">
{
item.question.min_choices == item.question.max_choices ? "可选"+item.question.max_choices+"项" :
"可选"+item.question.min_choices+"-"+item.question.max_choices+"项"
}
</span>:""
}
</p>
<li className="pl30 pr30 pb15">{item.question.question_title}</li>
{
// 单选题
item.question.question_type==1 &&
<Radio.Group className="answerList" disabled>
{
item.question.answers.map((index,k)=>{
return(
<li className="df">
<Radio className="fl" value={index.answer_id}></Radio>
<span className={index.answer_text=="其他"?"break-word":"break-word flex1"}>{index.answer_text}</span>
{
index.answer_text=="其他" ? <p className="textLine"></p>:""
}
</li>
)
})
}
</Radio.Group>
}
{
// 多选题
item.question.question_type==2 &&
<Checkbox.Group className="answerList" disabled>
{
item.question.answers.map((index,k)=>{
return(
<li className="df" key={k}>
<Checkbox className="fl mr8" value={index.answer_id} key={index.answer_id}></Checkbox>
<span className={index.answer_text=="其他"?"break-word":"break-word flex1"}>{index.answer_text}</span>
{
index.answer_text=="其他" ? <p className="textLine"></p>:""
}
</li>
)
})
}
</Checkbox.Group>
}
{
// 主观题
item.question.question_type == 3 &&
<div className="pl30 pr30 pb20">
<textarea placeholder="在此填入答案" readOnly className="winput-100-130"></textarea>
</div>
}
</div>
)
})
}
</div>
)
}
}
export default PollDetailTabThirdInfo

File diff suppressed because it is too large Load Diff

@ -185,7 +185,7 @@
width: 100%;
}
.answerList li:hover{
background: #F8F8F8;
background: #F0F8FF;
}
textarea:read-only{
background: #f3f3f3;

@ -55,18 +55,19 @@ class Generaljobanswer extends Component {
render() {
let{datas}=this.props
return (
<div className=" clearfix edu-back-white" ref='targetElementTrainingjobsetting' style={{margin: "auto", minWidth:"1200px"}}>
<div className="yslquestionbank1">
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML("C++是C语言的面向对象扩展是C语言的一个超集同时也是历史最悠久、最受欢迎的程序设计语言之一。根据C++创始人Stroustrup的自述C++是一个“更好的C语言”。\n" +
"\n" +
"输入输出是计算机程序的基本功能。程序本质上是对数据进行处理的一系列操作,一般程序都可以分解为:“数据输入”、“数据处理”和“数据输出”三个步骤。标准输入输出(键盘输入和显示器输出)是程序的重要组成部分。\n" +
"\n" +
"本实训项目的主要目标是学习和掌握C++程序的基本结构和基本输入输出主要内容包括标准C语言自有的单个字符的输入输出、格式化的输入输出以及C++扩展的使用流对象的输入输出").replace(/▁/g, "▁▁▁")}}/>
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML(datas&&(datas.reference_answer===null?"无":datas.reference_answer==="null"?"无":datas.reference_answer)).replace(/▁/g, "▁▁▁")}}/>
{datas.attachments === undefined ? "" : datas.attachments.map((item, key) => {
return (
<GroupPackage key={key} attachments={item}></GroupPackage>
)
})}
<GroupPackage></GroupPackage>
</div>

@ -43,7 +43,7 @@ class Generaljobbankdetails extends Component {
console.log(e);
console.log("44");
}
this.getonedata();
}
@ -58,17 +58,19 @@ class Generaljobbankdetails extends Component {
this.setState({
tab: type[1],
});
console.log("Generaljobbankdetails");
console.log(this.props);
this.getonedata();
}
getonedata=()=>{
if( this.props.match.params.workid){
this.setState({
workid: this.props.match.params.workid,
})
}
this.getdata(this.props.match.params.workid);
}
};
//获取数据的地方
getdata=(workid)=>{
var workids= workid;
@ -86,7 +88,7 @@ class Generaljobbankdetails extends Component {
if(response){
if(response.data){
this.setState({
datas:response.data.informs,
datas:response.data,
})
}else {
this.setState({
@ -118,9 +120,9 @@ class Generaljobbankdetails extends Component {
///////////////教师截止
render() {
let {tab} = this.state;
let {tab,datas} = this.state;
const isAdmin = this.props.isAdmin();
// console.log(119)
@ -141,10 +143,10 @@ class Generaljobbankdetails extends Component {
</div>
<div className="educontent mb20">
<p className=" fl color-black summaryname" style={{heigth: "33px"}}>
MySQL数据库编程开发实训基础篇
{datas&&datas.name}
</p>
<CoursesListType
typelist={["公开"]}
typelist={datas.is_public===true?["公开"]:["私有"]}
/>
</div>
@ -160,8 +162,8 @@ class Generaljobbankdetails extends Component {
</div>
</div>
<Spin size="large" spinning={this.state.isSpin} id={"cdiv"}>
{parseInt(tab) === 0 ? <Generaljobdetails {...this.props} {...this.state}/> :""}
{parseInt(tab) === 1 ? <Generaljobanswer{...this.props} {...this.state}/>:""}
{parseInt(tab) === 0 ? <Generaljobdetails {...this.props} {...this.state} datas={datas}/> :""}
{parseInt(tab) === 1 ? <Generaljobanswer{...this.props} {...this.state} datas={datas}/>:""}
</Spin>
</div>
</div>

@ -13,14 +13,13 @@ import {
import GroupPackage from '../groupjobbank/GroupPackage'
import './questionbank.css';
//内容详情
class Generaljobdetails extends Component {
constructor(props) {
super(props);
this.state = {
}
}
@ -56,18 +55,18 @@ class Generaljobdetails extends Component {
render() {
let{datas}=this.props;
return (
<div className=" clearfix edu-back-white" ref='targetElementTrainingjobsetting' style={{margin: "auto", minWidth:"1200px"}}>
<div className="yslquestionbank1">
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML("C++是C语言的面向对象扩展是C语言的一个超集同时也是历史最悠久、最受欢迎的程序设计语言之一。根据C++创始人Stroustrup的自述C++是一个“更好的C语言”。\n" +
"\n" +
"输入输出是计算机程序的基本功能。程序本质上是对数据进行处理的一系列操作,一般程序都可以分解为:“数据输入”、“数据处理”和“数据输出”三个步骤。标准输入输出(键盘输入和显示器输出)是程序的重要组成部分。\n" +
"\n" +
"本实训项目的主要目标是学习和掌握C++程序的基本结构和基本输入输出主要内容包括标准C语言自有的单个字符的输入输出、格式化的输入输出以及C++扩展的使用流对象的输入输出").replace(/▁/g, "▁▁▁")}}/>
<div id="MakedownHTML"className="markdown-body yslquesHeigth yslquesmarkdowntext" dangerouslySetInnerHTML={{__html: markdownToHTML(datas&&(datas.description===null?"无":datas.description==="null"?"无":datas.description)).replace(/▁/g, "▁▁▁")}}/>
{datas.attachments === undefined ? "" : datas.attachments.map((item, key) => {
return (
<GroupPackage key={key} attachments={item}></GroupPackage>
)
})}
<GroupPackage></GroupPackage>
</div>

@ -0,0 +1,165 @@
import React,{ Component } from "react";
import { Modal,Radio,Input,Tooltip,Checkbox,Select, Row,Col } from "antd";
import axios from 'axios';
const { Search } = Input;
class SendTopics extends Component{
constructor(props){
super(props);
this.state={
courses:[],
search:null,
Radiolist:undefined,
showcheck:false
}
}
componentDidMount(){
let{search}=this.state;
this.onupdatalist(search)
}
onupdatalist=(search)=>{
let url="/question_banks/my_courses.json";
axios.get(url,{params:{
search
}
}).then((result)=>{
this.setState({
courses:result.data.courses
})
}).catch((error)=>{
console.log(error);
})
}
onSearchChange=(e)=>{
this.setState({
search:e.target.value
})
// this.onupdatalist(e.target.value)
}
onSearch=(search)=>{
this.onupdatalist(search)
}
onChange=(e)=>{
this.setState({
Radiolist:e.target.value
})
}
submitInfo=()=>{
let{Radiolist}=this.state;
let url=`/question_banks/send_to_course.json`;
let object_id=this.props.checkBoxValues;
let object_type=this.props.category;
if(Radiolist===undefined){
this.setState({
showcheck:true
})
}else{
axios.post(url,{
object_id: object_id,
object_type:object_type,
course_id:Radiolist
}
).then((result)=>{
if(result.data.status===0){
this.props.updataslist()
this.props.topicscancelmodel()
this.props.showNotification(result.data.message)
}else{
this.props.showNotification(result.data.message)
}
}).catch((error)=>{
console.log(error)
})
}
}
render(){
let{courses,Radiolist,showcheck}= this.state;
const radioStyle = {
display: 'block',
height: '30px',
lineHeight: '30px',
};
return(
<div>
<style>
{
`
.ant-modal-body{
padding:20px 40px;
}
.onSearchtopics input{
height:40px;
}
.over221{
height:221px;
overflow-y: auto;
}
`
}
</style>
<Modal
keyboard={false}
title="发送至课堂"
visible={this.props.visible}
closable={false}
footer={null}
destroyOnClose={true}
width={600}
>
<div className="newupload_conbox">
<div className="mb15 font-14 edu-txt-center color-orange-tip">
温馨提示选择的题将会发送到指定课堂
</div>
<div className="mb5"
// onMouseLeave={this.closeList}
>
<Search
className="mb14 onSearchtopics"
placeholder="请输入课堂名称进行搜索"
onChange={this.onSearchChange}
onSearch={this.onSearch}
></Search>
</div>
<div className="edu-back-skyblue pl15 pr15 clearfix over221 pt5">
<Radio.Group onChange={this.onChange} value={Radiolist}>
{
courses && courses.map((item,key)=>{
return(
<div className="mt5" key={key}>
<Radio style={radioStyle} value={item.course_id} key={item.course_id}>
{item.course_name}
</Radio>
</div>
)
})
}
</Radio.Group>
</div>
{showcheck===true?<div className={"color-red mt10"}>请先选择课堂</div>:""}
<div className="mt20 clearfix edu-txt-center">
<a onClick={()=>this.props.topicscancelmodel()} className="pop_close task-btn mr30">取消</a>
<a className="task-btn task-btn-orange" onClick={()=>this.submitInfo()}>确定</a>
</div>
</div>
</Modal>
</div>
)
}
}
export default SendTopics;

@ -49,7 +49,7 @@ class CaseNew extends Component{
onAttachmentRemove = (file, stateName) => {
if(file.response!=undefined){
this.props.confirm({
content: '是否确认删除?',
content: '是否确认删除?',
onOk: () => {
this.deleteAttachment(file, stateName)
},
@ -244,7 +244,10 @@ class CaseNew extends Component{
// 选择标签
changeType=(type)=>{
// console.log(this.state.casesTags);
// debugger
let tags = [];
if(this.state.casesTags.indexOf(type) > -1){
tags = this.state.casesTags.filter(item => item != type);
}else{

@ -295,11 +295,11 @@
.topsj{
position: absolute;
top: -6px;
top: -3px;
}
.bottomsj{
position: absolute;
bottom: -6px;
bottom: -5px;
}
.touchSelect .ant-spin-dot-spin{
margin-top: 30% !important;

@ -0,0 +1,47 @@
import React, { Component } from 'react';
import { Redirect } from 'react-router';
import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom";
import Loading from '../../Loading'
import Loadable from 'react-loadable';
import { TPMIndexHOC } from '../tpm/TPMIndexHOC'
import { SnackbarHOC } from 'educoder'
const PackageIndex = Loadable({
loader: () => import('../user/usersInfo/InfosTopics'),
loading: Loading,
})
class Topic_bank extends Component {
constructor(props) {
super(props)
}
componentDidMount(){
}
render() {
return (
<div className="newMain clearfix">
<Switch>
{/*众包首页*/}
<Route path="/topicbank/:username/:topicstype"
render={
(props) => (<PackageIndex {...this.props} {...props} {...this.state} />)
}
></Route>
</Switch>
</div>
);
}
}
export default SnackbarHOC() (TPMIndexHOC (Topic_bank)) ;

@ -43,7 +43,10 @@ const InfosVideo = Loadable({
loader: () => import('./video/InfosVideo'),
loading:Loading,
})
const InfosTopics=Loadable({
loader: () => import('./InfosTopics'),
loading:Loading,
})
const $ = window.$;
class Infos extends Component{
@ -258,13 +261,10 @@ class Infos extends Component{
<Switch {...this.props}>
{/* --------------------------------------------------------------------- */}
{/* 众包 */}
{/* http://localhost:3007/courses/1309/homework/9300/setting */}
<Route exact path="/users/:username/package"
{/* 题库 */}
<Route exact path="/users/:username/topics/:topicstype"
render={
(props) => (<InfosPackage {...this.props} {...props} {...this.state} {..._commonProps}/>)
(props) => (<InfosTopics {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
@ -297,7 +297,15 @@ class Infos extends Component{
}
></Route>
{/* 项目 */}
{/* 众包 */}
{/* http://localhost:3007/courses/1309/homework/9300/setting */}
<Route exact path="/users/:username/package"
render={
(props) => (<InfosPackage {...this.props} {...props} {...this.state} {..._commonProps}/>)
}
></Route>
{/* 视频 */}
<Route exact path="/users/:username/videos"
render={
(props) => (<InfosVideo {...this.props} {...props} {...this.state} {..._commonProps}/>)
@ -305,6 +313,7 @@ class Infos extends Component{
></Route>
<Route exact path="/users/:username"
render={
(props) => (<InfosCourse {...this.props} {...props} {...this.state} {..._commonProps}/>)

@ -27,6 +27,9 @@ class InfosBanner extends Component{
let {pathname}=this.props.location;
moduleName=pathname.split("/")[3];
let user_id=this.props.current_user&&this.props.current_user.user_id;
let user_type=this.props.current_user&&this.props.current_user.user_identity;
let targetuserid=this.props.data&&this.props.data.id;
return(
<div className="bannerPanel mb60">
<div className="educontent">
@ -115,6 +118,13 @@ class InfosBanner extends Component{
to={`/users/${username}/videos`}>视频</Link>
</li>}
{/*自己的主页且不是学生显示题库按钮*/}
{ user_id===targetuserid&&user_type!="学生"?<li className={`${moduleName == 'topics' ? 'active' : '' }`}>
<Link
onClick={() => this.setState({moduleName: 'topics'})}
to={`/users/${username}/topics/personal`}>题库</Link>
</li>:""}
</div>
</div>
</div>

@ -0,0 +1,522 @@
import React, { Component } from 'react';
import { SnackbarHOC } from 'educoder';
import {BrowserRouter as Router,Route,Switch,Link} from 'react-router-dom';
import {Tooltip,Menu,Pagination,Spin, Dropdown,Checkbox} from 'antd';
import axios from 'axios';
import {getImageUrl,WordsBtn} from 'educoder';
import moment from 'moment';
import Modals from '../../modals/Modals';
import SendTopics from '../../modals/SendTopics'
import NoneData from '../../courses/coursesPublic/NoneData';
import "./usersInfo.css";
import Withoutpermission from './Withoutpermission.png';
class InfosTopics extends Component{
constructor(props){
super(props);
this.state={
isSpin:false,
category:"normal",
course_list_id:undefined,
sort_by:"updated_at",
sort_direction:"desc",
page:1,
data:undefined,
checkBoxValues:[],
per_page:15,
isshowprofes:false
}
}
componentDidMount(){
let types=this.props.match.params.topicstype;
let professional_certification=this.props.current_user&&this.props.current_user.professional_certification;
if(professional_certification===false&&types==="publicly"){
this.setState({
isshowprofes:true
})
}else{
this.updataslist()
}
}
componentDidUpdate(prevProps) {
if(prevProps.current_user!=this.props.current_user){
let types=this.props.match.params.topicstype;
let professional_certification=this.props.current_user&&this.props.current_user.professional_certification;
console.log(professional_certification)
if(professional_certification===false&&types==="publicly"){
this.setState({
isshowprofes:true
})
}else{
this.updataslist()
}
}
}
updataslist=()=>{
let types=this.props.match.params.topicstype;
let { category,course_list_id,sort_by,sort_direction,page}=this.state;
this.searchAlldata(types,category,course_list_id,sort_by,sort_direction,page)
}
searchAlldata=(type,category,course_list_id,sort_by,sort_direction,page)=>{
let user_id=this.props.current_user&&this.props.current_user.user_id;
if(user_id!=undefined){
let {per_page}=this.state;
let url=`/users/${user_id}/question_banks.json`;
axios.get(url,{params:{
type,
object_type:category,
course_list_id,
sort_by,
sort_direction,
page,
per_page
}
}).then((response) => {
this.setState({
data:response.data
})
}).catch((error) => {
});
}
}
searchCategory=(type)=>{
this.setState({
category:type
})
let types=this.props.match.params.topicstype;
let { category,course_list_id,sort_by,sort_direction,page}=this.state;
this.searchAlldata(types,type,course_list_id,sort_by,sort_direction,page)
}
searchCourselistid=(id)=>{
this.setState({
course_list_id:id
})
let types=this.props.match.params.topicstype;
let { category,course_list_id,sort_by,sort_direction,page}=this.state;
this.searchAlldata(types,category,id,sort_by,sort_direction,page)
}
onCheckBoxChange=(checkedValues)=>{
if(checkedValues.length>15){
this.props.showNotification("选择条数不能大于15条")
}else{
this.setState({
checkBoxValues:checkedValues
})
}
}
updatedlist=(updatedtype)=>{
let types=this.props.match.params.topicstype;
let { category,course_list_id,sort_by,sort_direction,page}=this.state;
if(updatedtype===sort_by){
if(sort_direction==="desc"){
this.setState({
sort_direction:"asc",
sort_by:updatedtype
})
this.searchAlldata(types,category,course_list_id,updatedtype,"asc",page)
}else{
this.setState({
sort_direction:"desc",
sort_by:updatedtype
})
this.searchAlldata(types,category,course_list_id,updatedtype,"desc",page)
}
}else{
this.setState({
sort_direction:"desc",
sort_by:updatedtype
})
this.searchAlldata(types,category,course_list_id,updatedtype,"desc",page)
}
}
changePage=(pageNumber)=>{
let types=this.props.match.params.topicstype;
let { category,course_list_id,sort_by,sort_direction,page}=this.state;
this.searchAlldata(types,category,course_list_id,sort_by,sort_direction,pageNumber)
this.setState({
page:pageNumber,
checkBoxValues:[]
})
}
deletecheckBoxValues=()=>{
let {checkBoxValues}=this.state;
if(checkBoxValues.length===0){
this.props.showNotification("请选择题库")
}else{
this.setState({
Modalstype:true,
Modalstopval:"是否确认删除?",
ModalCancel:this.topicscancelmodel,
ModalSave:this.topicssavedelete,
})
}
}
topicssavedelete=()=>{
let {checkBoxValues,category}=this.state;
const url = `/question_banks/multi_delete.json`;
axios.delete(url, { data: {
object_id: checkBoxValues,
object_type:category
}})
.then((response) => {
if(response.data.status===0){
this.updataslist()
this.props.showNotification(response.data.message)
}else{
this.props.showNotification(response.data.message)
}
})
.catch(function (error) {
console.log(error);
});
this.topicscancelmodel()
}
topicscancelmodel=()=>{
this.setState({
Modalstype:false,
Loadtype:false,
visible:false,
Modalstopval:"",
ModalCancel:"",
ModalSave:"",
checkBoxValues:[],
checkedtype:false
})
}
openTopics=(id)=>{
this.setState({
Modalstype:true,
Modalstopval:"公开后不能重设为私有",
ModalsBottomval:"是否确认设为公开?",
ModalCancel:this.topicscancelmodel,
ModalSave:()=>this.topicssaveonOpen(id),
})
}
topicssaveonOpen=(id)=>{
let {category}=this.state;
const url = `/question_banks/multi_public.json`;
axios.post(url,{
object_id:[id],
object_type:category
}).then((response) => {
if(response.data.status===0){
this.updataslist()
this.props.showNotification(response.data.message)
}else{
this.props.showNotification(response.data.message)
}
}).catch(function (error) {
console.log(error);
});
this.topicscancelmodel()
}
sendTopics=()=>{
let {checkBoxValues}=this.state;
if(checkBoxValues.length===0){
this.props.showNotification("请选择题库")
}else{
this.setState({
visible:true
})
}
}
render(){
let{
category,
course_list_id,
isSpin,
data,
page,
sort_direction,
sort_by,
checkBoxValues,
Modalstype,
visible,
isshowprofes
} = this.state;
let categorylist=[
{val:"普通作业",type:"normal"},
{val:"分组作业",type:"group"},
{val:"毕设选题",type:"gtopic"},
{val:"毕设任务",type:"gtask"},
{val:"试卷",type:"exercise"},
{val:"问卷",type:"poll"},
]
let types=this.props.match.params.topicstype;
let username=this.props.match.params.username;
//types===publicly 公共
//types===personal 私有
let user_id=this.props.current_user&&this.props.current_user.user_id;
let user_type=this.props.current_user&&this.props.current_user.user_identity;
let targetuserid=this.props.data&&this.props.data.id;
const menu = (
<Menu>
<Menu.Item onClick={()=>this.updatedlist("updated_at")}>
最近更新
</Menu.Item>
<Menu.Item onClick={()=>this.updatedlist("name")}>
题目更新
</Menu.Item>
{types==="publicly"?<Menu.Item onClick={()=>this.updatedlist("contributor")}>
贡献者
</Menu.Item>:""}
</Menu>
);
return(
<div className="educontent mb50 mt40">
{/*提示*/}
<style>
{
`
.mt40{
margin-top: 40px !important;
}
`
}
</style>
{Modalstype&&Modalstype===true?<Modals
modalsType={this.state.Modalstype}
modalsTopval={this.state.Modalstopval}
modalCancel={this.state.ModalCancel}
modalSave={this.state.ModalSave}
modalsBottomval={this.state.ModalsBottomval}
loadtype={this.state.Loadtype}
/>:""}
{/*发送至弹窗*/}
{
visible&&visible===true?
<SendTopics
{...this.state}
{...this.props}
visible={visible}
updataslist={()=>this.updataslist()}
topicscancelmodel={()=>this.topicscancelmodel()}
/>:""
}
<style>
{
`
.shaiContent li.shaiItem {
padding: 3px 15px;
float: left;
border-radius: 4px;
color: #4C4C4C;
cursor: pointer;
margin-right: 20px;
display: block;
margin-bottom: 5px;
}
.mr38{
margin-right:38px;
}
.maxwidth900{
max-width: 900px;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap
}
.homepagePostSettingname{
width:192px !important;
}
.homepagePostSettingbox{
width:139px !important;
}
`
}
</style>
<Spin size="large" spinning={isSpin}>
<div className="clearfix topicsbox">
{types==="publicly"?<div className={"topcschild"}>
<a className={types==="personal"?"topicstopfont fr topcsactive":"topicstopfont fr"}
href={`/users/${username}/topics/personal`}>个人题库</a>
<a className={types==="publicly"?"topicstopfont fl topcsactive":"topicstopfont fl"}
>公共题库</a>
</div>:<div className={"topcschild"}>
<a className={types==="personal"?"topicstopfont fl topcsactive":"topicstopfont fl"}
>我的题库</a>
<a className={types==="publicly"?"topicstopfont fr topcsactive":"topicstopfont fr"}
href={`/topicbank/${username}/publicly`}
>公共题库</a>
</div>}
{isshowprofes===false?
<div>
<div className={"topcsmid"}>
{categorylist.map((item,key)=>{
return(
<span key={key} className={category===item.type?"topicsmidfont fl mr38 topcsactive":"topicsmidfont fl mr38"} onClick={()=>this.searchCategory(item.type)}>{item.val}</span>
)
})}
</div>
<div className={"shaiContent"}>
<div className="fl pr topicsItem pagetype mb20">
<li className={course_list_id===undefined?"shaiItem shixun_repertoire active":"shaiItem shixun_repertoire"} onClick={()=>this.searchCourselistid(undefined)}>全部</li>
{data===undefined?"":data.course_list===undefined||data.course_list.length===0?"":data.course_list.map((item,key)=>{
return(
<li key={key} className={course_list_id===item.id?"shaiItem shixun_repertoire active":"shaiItem shixun_repertoire"} onClick={()=>this.searchCourselistid(item.id)}>{item.name}</li>
)
})}
</div>
</div>
</div>:<div className={"professional_certificationbox"}>
<p className="clearfix ">
<div className={"stud-class-set pd115200 coursenavbox edu-back-white"}>
<div className={"sumbtongs mb10"}><img className={"topicsItemimg"} src={Withoutpermission}/></div>
<div className={"terraces mb5 topicsItemfont"}>通过职业认证的教师才能访问公共题库</div>
<div className="clearfix mt30 mb30 padding251">
<a className="defalutSubmitbtn fl ml60 defalutSubmitbtns" target="_blank" href="/account/certification">立即认证</a>
</div>
</div>
</p>
</div>}
</div>
{isshowprofes===false?<div className="clearfix font-12 mt20">
<p className="font-12 alltopisc ml25 fl">
<span className="fl color-grey-9"> <span className={"color-orange"}>{data&&data.count===undefined?0:data&&data.count}</span> </span>
<span className="fr color-grey-9">已选择 <span className={"color-orange"}>{checkBoxValues.length}</span> ()</span>
</p>
<p className="font-12 alltopiscright ml25 fr">
<Dropdown overlay={menu}>
<span className="fr color-grey-9 mr10 pointer">
{sort_by==="updated_at"?'最近更新':sort_by==="name"?'题目更新':sort_by==="contributor"?"贡献者":""}
<sapn className="relativef ml20">
<i className={sort_direction==="asc"?
"iconfont icon-sanjiaoxing-up font-12 topsj color-blue" :"iconfont icon-sanjiaoxing-up font-12 topsj"}></i>
<i className={sort_direction==="desc"?
"iconfont icon-sanjiaoxing-down font-12 bottomsj color-blue":"iconfont icon-sanjiaoxing-down font-12 bottomsj"}></i>
</sapn>
</span>
</Dropdown>
{user_type!="学生"?<span className="fr mr30 topcsactive pointer" onClick={()=>this.sendTopics()}>发送</span>:""}
{types==="personal"?user_id===targetuserid&&user_type!="学生"?<span className="fr mr30 topcsactive pointer" onClick={()=>this.deletecheckBoxValues()}>删除</span>:"":""}
</p>
</div>:""}
{isshowprofes===true?"":data===undefined?<NoneData></NoneData>:data.question_banks===undefined||data.question_banks.length===0?<NoneData></NoneData>:
<Checkbox.Group style={{ width: '100%' ,minHeight:'297px'}} onChange={this.onCheckBoxChange} value={checkBoxValues}>
{data.question_banks.map((item,key)=>{
return(
<div className="mt20 edu-back-white pd1323 relativef" key={key} >
<div className="clearfix">
<div className="item-body">
<div className="clearfix ds pr pt5 contentSection" >
{user_type!="学生"?<Checkbox value={item.id} key={item.id} className={"fl mt5"}></Checkbox>:""}
<a title={item.name} className="ml10 fl mt3 font-16 color-dark maxwidth900" href={
category==="normal"?`/banks/normal/${item.id}?tab=0`:
category==="group"?`/banks/group/${item.id}?tab=0`:
category==="poll"?`/banks/poll/${item.id}`:
category==="exercise"?`/banks/exercise/${item.id}`:
category==="gtask"?`/banks/gtask/${item.id}`:
category==="gtopic"?`/banks/gtopic/${item.id}`:""
}
>
{item.name}
</a>
{item.is_public===true?<span className="edu-filter-btn ml15 fl typestyle mt3 topiscfilterbtn">公开</span>:""}
{types==="personal"&&item.is_public===false?user_id===targetuserid&&user_type!="学生"?<a className="btn colorblue mr25 fr font-16" onClick={()=>this.openTopics(item.id)}>设为公开</a>:"":""}
<div className="cl"></div>
<p className="color-grey panel-lightgrey mt16 fl">
<span className={types==="personal"?"topicswidth300":"topicswidth400"}>
{types==="publicly"?<span className="topsics100 color-grey9">{item.creator_name}</span>:""}
<span className="mr50 color-grey9">{item.quotes_count} 次引用</span>
<span className="mr50 color-grey9">{item.solve_count} 次答题</span>
<span className="mr50 color-grey9">{moment(item.updated_at).fromNow()}</span>
</span>
<span className="topicsbtn">{item.course_list_name}</span>
</p>
<div className="homepagePostSetting homepagePostSettingname topscisright">
{types==="personal"?user_id===targetuserid&&user_type!="学生"?
<a className="btn colorblue mr25 font-16 fr"
href={category==="normal"?`/banks/normal/${item.id}/edit`:
category==="group"?`/banks/group/${item.id}/edit`:
category==="poll"?`/banks/poll/${item.id}/edit`:
category==="exercise"?`/banks/exercise/${item.id}/edit`:
category==="gtask"?`/banks/gtask/${item.id}/edit`:
category==="gtopic"?`/banks/gtopic/${item.id}/edit`:""
}
>编辑</a>
:"":""}
</div>
</div>
</div>
</div>
</div>
)})}
</Checkbox.Group>
}
{
isshowprofes===true?"":data&&data.count >15 &&
<div className="mt30 mb50 edu-txt-center">
<Pagination showQuickJumper total={data&&data.count} onChange={this.changePage} pageSize={15} current={page}/>
</div>
}
</Spin>
</div>
)
}
}
export default InfosTopics;

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

@ -0,0 +1,213 @@
import React, { Component } from 'react';
import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
import { Breadcrumb } from 'antd';
import { SnackbarHOC } from 'educoder';
import { TPMIndexHOC } from '../../../tpm/TPMIndexHOC';
import { CNotificationHOC } from '../../../courses/common/CNotificationHOC'
import "../usersInfo.css"
import "../../../courses/css/members.css"
import "../../../courses/css/Courses.css"
import Loadable from 'react-loadable';
import Loading from '../../../../Loading';
// 毕设选题
const GtopicBanks = Loadable({
loader: () => import('./GtopicBanks'),
loading: Loading,
})
const BanksTabIndex = Loadable({
loader: () => import('./BanksTabIndex'),
loading: Loading,
})
const GtopicBanksEdit = Loadable({
loader: () => import('./GtopicBanksEdit'),
loading: Loading,
})
const HomeworkBanksEdit = Loadable({
loader: () => import('./HomeworkBanksEdit'),
loading: Loading,
});
const ExerciseBanksEdit = Loadable({
loader: () => import('./ExerciseBanksEdit'),
loading: Loading,
});
//普通作业题库详情
const Generaljobbankdetails =Loadable({
loader: () => import('../../../courses/questionbank/Generaljobbankdetails'),
loading: Loading,
});
//分组作业题库详情
const GroupjobbankPage =Loadable({
loader: () => import('../../../courses/groupjobbank/GroupjobbankPage'),
loading: Loading,
});
//毕设选题详情
const CompletetopicdePage =Loadable({
loader: () => import('../../../courses/comtopicdetails/CompletetopicdePage'),
loading: Loading,
});
//毕设任务详情
const Completetaskpage =Loadable({
loader: () => import('../../../courses/completetaskdetails/Completetaskpage'),
loading: Loading,
});
//问卷编辑
const PollNewQuestbank =Loadable({
loader: () => import('../../../courses/poll/PollNewQuestbank'),
loading: Loading,
});
const GtaskBanksEdit = Loadable({
loader: () => import('./GtaskBanksEdit'),
loading: Loading,
})
class BanksIndex extends Component{
constructor(props){
super(props);
this.state={
crumbData:undefined
}
}
initPublic = (crumbData) =>{
this.setState({
crumbData
})
}
render(){
let { crumbData }=this.state
const common = {
initPublic:this.initPublic
}
return(
<div className="newMain">
<div className="educontent">
{
crumbData &&
<Breadcrumb separator=">" className="breadcrumb mt22">
<Breadcrumb.Item href="/users/innov/banks">题库</Breadcrumb.Item>
{
crumbData.crumbArray && crumbData.crumbArray.map((item,key)=>{
return(
<Breadcrumb.Item href={item.to || ""}>{item.content}</Breadcrumb.Item>
)
})
}
</Breadcrumb>
}
{
crumbData &&<p className="clearfix mt10 mb10 ">
<span className="fl font-24 color-grey-3 task-hide lineh-30" style={{maxWidth:'800px'}}>{crumbData && crumbData.title}</span>
<span className="bank_is_public">{crumbData.is_public == true ? '公开':'私有'}</span>
</p> }
<Switch {...this.props}>
{/*毕设任务编辑*/}
<Route path='/banks/gtask/:workId/edit'
render={
(props) => {
return (<GtaskBanksEdit {...this.props} {...props} {...this.state} {...common}/>)
}
}></Route>
<Route path='/banks/normal/:workId/edit'
render={
(props) => {
return (<HomeworkBanksEdit {...this.props} {...props} {...this.state} {...common}
isGroup={false}
/>)
}
}></Route>
<Route path='/banks/group/:workId/edit'
render={
(props) => {
return (<HomeworkBanksEdit {...this.props} {...props} {...this.state} {...common}
isGroup={true}
/>)
}
}></Route>
<Route path='/banks/exercise/:Id/edit'
render={
(props) => {
return (<ExerciseBanksEdit {...this.props} {...props} {...this.state} {...common}
/>)
}
}></Route>
<Route path='/banks/gtopic/:bankId/edit'
render={
(props) => {
return (<GtopicBanksEdit {...this.props} {...props} {...this.state} {...common}/>)
}
}></Route>
{/*题库问卷编辑详情*/}
<Route path="/banks/poll/:workid/edit"
render={
(props) => (<PollNewQuestbank {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path='/banks/poll/:bankId'
render={
(props) => {
return (<BanksTabIndex {...this.props} {...props} {...this.state} {...common} />)
}
}></Route>
{/*毕设任务题库详情*/}
<Route path="/banks/gtask/:workid"
render={
(props) => (<Completetaskpage {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/*毕设内容题库详情*/}
<Route path="/banks/gtopic/:workid"
render={
(props) => (<CompletetopicdePage {...this.props} {...props} {...this.state} {...common}/>)
}
></Route>
{/*分组作业题库详情*/}
<Route path="/banks/group/:workid"
render={
(props) => (<GroupjobbankPage {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
{/* 普通作业题库详情*/}
<Route path="/banks/normal/:workid"
render={
(props) => (<Generaljobbankdetails {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
</Switch>
</div>
</div>
)
}
}
export default CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(BanksIndex) ));
// <Route path='/banks/gtopic/:bankId'
// render={
// (props) => {
// return (<BanksTabIndex {...this.props} {...props} {...this.state} {...common}/>)
// }
// }></Route>

@ -0,0 +1,76 @@
import React, { Component } from 'react';
import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
import Loadable from 'react-loadable';
import Loading from '../../../../Loading';
import BanksMenu from './banksMenu'
// 毕设选题
const GtopicBanks = Loadable({
loader: () => import('./GtopicBanks'),
loading: Loading,
})
// 问卷内容
const PollBanks = Loadable({
loader: () => import('./PollBanksContent'),
loading: Loading,
})
class BanksTabIndex extends Component{
constructor(props){
super(props);
this.state={
banksMenu:undefined
}
}
initPublic = (crumbData,menuData) =>{
this.setState({
banksMenu:menuData
})
this.props.initPublic(crumbData);
}
render(){
let{
banksMenu
}=this.state
const common={
initPublic:this.initPublic,
}
return(
<React.Fragment>
{
banksMenu &&
<BanksMenu
banksMenu={banksMenu}
{...this.props}
{...this.state}
{...common}
></BanksMenu>
}
<Switch {...this.props}>
<Route path='/banks/gtopic/:bankId'
render={
(props) => {
return (<GtopicBanks {...this.props} {...props} {...this.state} {...common} />)
}
}></Route>
<Route path='/banks/poll/:bankId'
render={
(props) => {
return (<PollBanks {...this.props} {...props} {...this.state} {...common} />)
}
}></Route>
</Switch>
</React.Fragment>
)
}
}
export default (BanksTabIndex);

@ -0,0 +1,66 @@
import React, { Component } from 'react';
import axios from 'axios'
import ExerciseNewCommon from '../../../courses/exercise/ExerciseNewCommon'
class ExerciseBanksEdit extends Component {
constructor(props){
super(props);
this.state = {
isPublic: undefined,
// isGroup: false
}
}
componentDidMount = () =>{
}
initData = (responseData) =>{
const Id = this.props.match.params.Id
const crumbData={
title:'编辑',
is_public: responseData && responseData.data && responseData.data.exercise.is_public,
crumbArray:[
{to:`/banks/exercise/${Id}`,content:'详情'},
{content:'编辑'}
]
}
this.props.initPublic(crumbData);
}
render(){
let { workId } = this.props.match.params
const common = {
// onCancel:this.onCancel,
// isGroup: this.isGroup,
// doNew: this.doNew,
// doEdit: this.doEdit,
initData: this.initData
}
return(
<div className="courseForm">
<style>
{`
.courseForm .ant-col-sm-24{
text-align:left;
}
`}
</style>
<ExerciseNewCommon
{...this.props}
{...this.state}
{...common}
wrappedComponentRef={(ref) => this.exerciseNewCommonRef = ref}
isEdit={true}
shixunsUrl={`/exercise_banks/choose_shixun.json`}
exercise_url={'exercise_banks'}
exercise_url_questions={'exercise_bank_questions'}
></ExerciseNewCommon>
</div>
)
}
}
export default ExerciseBanksEdit;

@ -0,0 +1,99 @@
import React, { Component } from 'react';
import axios from 'axios'
import NewGtaskForm from './NewGtaskForm';
import NewWorkForm from "./HomeworkBanksEdit";
class GtaskBanksEdit extends Component {
constructor(props){
super(props);
this.state = {
isPublic: undefined,
isGroup: false
}
}
componentDidMount = () =>{
let workId = this.props.match.params.workId;
this.initData(workId);
}
initData = (workId) =>{
let url = `/task_banks/${workId}.json`;
axios.get(url).then((result)=>{
if(result){
const crumbData={
title:'编辑',
is_public:result && result.data && result.data.is_public,
crumbArray:[
{to:`/banks/gtask/${workId}/edit`,content:'详情'},
{content:'编辑'}
]
}
this.props.initPublic(crumbData);
result.data.isEdit = true;
this.setState({ data:result.data})
this.newWorkFormRef.initValue(result.data);
}
}).catch((error)=>{
console.log(error)
})
}
doNew = () => {
}
doEdit = (params) => {
const workId = this.props.match.params.workId
const newUrl = `/homework_banks/${workId}.json`
// const isGroup = this.props.isGroup()
axios.put(newUrl, params)
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification('保存成功')
this.toWorkDetail()
}
})
.catch(function (error) {
console.log(error);
});
}
toWorkDetail = () => {
this.props.history.push(`/banks/gtask/${this.props.match.params.workId}`);
this.props.initPublic(undefined);
}
onCancel = () => {
this.toWorkDetail()
}
isGroup = () => {
return this.state.isGroup;
}
render(){
const common = {
onCancel:this.onCancel,
isGroup: this.isGroup,
doNew: this.doNew,
doEdit: this.doEdit,
}
return(
<div className="courseForm">
<style>
{`
.courseForm .ant-col-sm-24{
text-align:left;
}
`}
</style>
<NewGtaskForm
{...this.props}
{...this.state}
{...common}
wrappedComponentRef={(ref) => this.newWorkFormRef = ref}
topicId={this.props.match.params.workId}
></NewGtaskForm>
</div>
)
}
}
export default GtaskBanksEdit;

@ -0,0 +1,36 @@
import React, { Component } from 'react';
class GtopicBanks extends Component{
constructor(props){
super(props);
}
componentDidMount = () =>{
let bankId = this.props.match.params.bankId
const crumbData={
title:'MySQL数据库编程开发实训基础篇111',
is_public:true,
crumbArray:[
{content:'详情'},
]
}
const menuData={
tab:'0',//tab选中的index
menuArray:[//tab以及tab路由
{to:'/banks/gtopic/1',content:'内容详情'},
// {to:'/banks/gtopic/1/answer',content:'参考答案'},
],
category:'topic',//毕设选题
id:bankId
}
this.props.initPublic(crumbData,menuData);
}
render(){
return(
<div>
</div>
)
}
}
export default GtopicBanks;

@ -0,0 +1,89 @@
import React, { Component } from 'react';
import axios from 'axios'
import GraduateTopicNewFrom from '../../../courses/graduation/topics/GraduateTopicNewFrom'
class GtopicBanksEdit extends Component{
constructor(props){
super(props);
this.state = {
isPublic:undefined
}
}
componentDidMount = () =>{
let bankId = this.props.match.params.bankId;
this.initData(bankId);
}
initData = (bankId) =>{
let url = `/gtopic_banks/${bankId}/edit.json`;
axios.get(url).then((result)=>{
if(result){
const crumbData={
title:'编辑',
is_public:result && result.data.selected_data && result.data.selected_data.is_public,
crumbArray:[
{to:`/banks/gtopic/${bankId}/edit`,content:'详情'},
{content:'编辑'}
]
}
this.props.initPublic(crumbData);
this.GraduateTopicNewFromRef.initValue(result);
}
}).catch((error)=>{
console.log(error)
})
}
// 编辑保存
editSave = (param,attachments,bankId) =>{
const url = `/gtopic_banks/${bankId}.json`;
let params = {
gtopic_bank:param,
attachment_ids:attachments
}
axios.put(url,params).then((result)=>{
if(result){
this.props.showNotification('保存成功!');
this.props.history.push(`/banks/gtopic/${bankId}`);
}
}).catch((error)=>{
console.log(error);
})
}
// 取消
editCancel = () =>{
this.props.history.push(`/banks/gtopic/${this.props.match.params.bankId}`);
this.props.initPublic(undefined);
}
render(){
let { bankId } = this.props.match.params
const common = {
editSave:this.editSave,
editCancel:this.editCancel
}
return(
<div className="courseForm">
<style>
{`
.courseForm .ant-col-sm-24{
text-align:left;
}
`}
</style>
<GraduateTopicNewFrom
{...this.props}
{...this.state}
{...common}
wrappedComponentRef={(ref) => this.GraduateTopicNewFromRef = ref}
topicId={bankId}
></GraduateTopicNewFrom>
</div>
)
}
}
export default GtopicBanksEdit;

@ -0,0 +1,104 @@
import React, { Component } from 'react';
import axios from 'axios'
import NewWorkForm from '../../../courses/busyWork/NewWorkForm'
class HomeworkBanksEdit extends Component {
constructor(props){
super(props);
this.state = {
isPublic: undefined,
// isGroup: false
}
}
componentDidMount = () =>{
let workId = this.props.match.params.workId;
this.initData(workId);
}
initData = (workId) =>{
let url = `/homework_banks/${workId}.json`;
axios.get(url).then((result)=>{
if(result){
const crumbData={
title:'编辑',
is_public:result && result.data && result.data.is_public,
crumbArray:[
{to:`/banks/${this.getModuleName()}/${workId}`,content:'详情'},
{content:'编辑'}
]
}
this.props.initPublic(crumbData);
result.data.isEdit = true;
result.data.ref_attachments = result.data.reference_attachments
// this.setState({ isGroup: result.data.min_num || result.data.max_num })
this.newWorkFormRef.initValue(result.data);
}
}).catch((error)=>{
console.log(error)
})
}
doNew = () => {
}
doEdit = (params) => {
const workId = this.props.match.params.workId
const newUrl = `/homework_banks/${workId}.json`
// const isGroup = this.props.isGroup()
axios.put(newUrl, params)
.then((response) => {
if (response.data.status == 0) {
this.props.showNotification('保存成功')
this.toWorkDetail()
}
})
.catch(function (error) {
console.log(error);
});
}
getModuleName = () => {
return this.props.isGroup ? 'group' : 'normal'
}
toWorkDetail = () => {
this.props.history.push(`/banks/${this.getModuleName()}/${this.props.match.params.workId}?tab=0`)
this.props.initPublic(undefined);
}
onCancel = () => {
this.toWorkDetail()
}
isGroup = () => {
return this.props.isGroup;
}
render(){
let { bankId } = this.props.match.params
const common = {
onCancel:this.onCancel,
isGroup: this.isGroup,
doNew: this.doNew,
doEdit: this.doEdit,
}
return(
<div className="courseForm">
<style>
{`
.courseForm .ant-col-sm-24{
text-align:left;
}
`}
</style>
<NewWorkForm
{...this.props}
{...this.state}
{...common}
wrappedComponentRef={(ref) => this.newWorkFormRef = ref}
topicId={bankId}
></NewWorkForm>
</div>
)
}
}
export default HomeworkBanksEdit;

@ -0,0 +1,358 @@
import React,{ Component } from "react";
import { Input, InputNumber, Form, Button, Checkbox, Upload, Icon, message, Modal } from "antd";
import axios from 'axios'
import { WordsBtn, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder'
import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
const MAX_TITLE_LENGTH = 60;
class NewGtaskForms extends Component{
constructor(props){
super(props);
this.contentMdRef = React.createRef();
this.state={
title_num:0,
description:"",
contentFileList: [],
}
}
initValue = (data) => {
if (data.isEdit) {
const contentFileList = data.attachments.map(item => {
return {
id: item.id,
uid: item.id,
name: appendFileSizeToUploadFile(item),
url: item.url,
filesize: item.filesize,
status: 'done'
}
})
this.setState({
...data,
base_on_project: data.group_info.base_on_project,
title_num: parseInt(data.name.length),
min_num: data.group_info.min_number,
max_num: data.group_info.max_number,
contentFileList,
}, () => {
setTimeout(() => {
this.contentMdRef.current.setValue(data.description || '')
}, 2000)
this.props.form.setFieldsValue({
title: data.name,
description: data.description || '',
});
})
} else { // new
}
}
// 输入title
changeTitle=(e)=>{
console.log(e.target.value.length);
this.setState({
title_num: parseInt(e.target.value.length)
})
}
handleContentUploadChange = (info) => {
let contentFileList = info.fileList;
this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList) });
}
deleteAttachment = (file, stateName) => {
// 初次上传不能直接取uid
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})
.then((response) => {
if (response.data) {
const { status } = response.data;
if (status == 0) {
console.log('--- success')
this.setState((state) => {
const index = state[stateName].indexOf(file);
const newFileList = state[stateName].slice();
newFileList.splice(index, 1);
return {
[stateName]: newFileList,
};
});
}
}
})
.catch(function (error) {
console.log(error);
});
}
onAttachmentRemove = (file, stateName) => {
if(file.response!=undefined){
this.props.confirm({
content: '是否确认删除?',
onOk: () => {
this.deleteAttachment(file, stateName)
},
onCancel() {
console.log('Cancel');
},
});
return false;
}
}
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
this.props.form.validateFieldsAndScroll((err, values) => {
const mdContnet = this.contentMdRef.current.getValue().trim();
values.description = mdContnet;
if (!err) {
if (this.state.isEdit) {
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?undefined:base_on_project===true?1:0
},
attachment_ids:contentFileList
}
).then((response) => {
if(response.data.status===0){
this.props.showNotification(response.data.message)
}else{
this.props.showNotification(response.data.message)
}
}).catch((error) => {
console.log(error)
})
} else {
}
} else {
$("html").animate({ scrollTop: $('html').scrollTop() - 100 })
}
})
}
max_num_change = (val) => {
if (val < 2) {
this.setState({
max_num: 2,
})
return;
}
const { min_num } = this.state;
this.setState({
max_num: val,
min_num: val <= min_num ? val - 1 : min_num
})
}
min_num_change = (val) => {
this.setState({ min_num: val })
}
base_on_project_change = () => {
this.setState({ base_on_project: !this.state.base_on_project })
}
render(){
const { getFieldDecorator } = this.props.form;
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
const uploadProps = {
width: 600,
fileList: contentFileList,
multiple: true,
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
onChange: this.handleContentUploadChange,
onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'),
beforeUpload: (file) => {
console.log('beforeUpload', file.name);
const isLt150M = file.size / 1024 / 1024 < 150;
if (!isLt150M) {
message.error('文件大小必须小于150MB!');
}
return isLt150M;
},
};
return(
<div>
<style>
{
`
.newAboutInputForm.ant-form-item, .newAboutInputForm .ant-form-item{padding:20px 30px 20px 30px!important}
.margin0{margin: 0px!important}
.tasktypes{width:64px;
height:22px;
font-size:16px;
font-family:Microsoft YaHei;
font-weight:400;
line-height:25px;
color:rgba(51,51,51,1);
opacity:1;}
`
}
</style>
<Form className="courseForm">
<div className={"ant-row ant-form-item AboutInputForm newAboutInputForm "}>
<div className="ant-col ant-form-item-label margin0">
<label htmlFor="coursesNew_course" className="ant-form-item-required ">类型</label> <span className={"tasktypes"}>{this.props.data&&this.props.data.task_type===1?"":this.props.data&&this.props.data.task_type===2?"":""}</span>
</div>
</div>
<Form.Item
label="标题"
className="AboutInputForm"
>
{getFieldDecorator('title', {
rules: [{
required: true, message: '请输入标题'
}],
})(
<Input placeholder="请输入毕设任务标题最大限制60个字符"
onInput={this.changeTitle}
className="searchView yslnewworkinputaddonAfter searchViewAfter"
style={{"width":"100%"}}
maxLength={MAX_TITLE_LENGTH} addonAfter={`${String(title_num)}/${MAX_TITLE_LENGTH}`}
/>
)}
</Form.Item>
<style>{`
.uploadBtn.ant-btn {
border: none;
color: #4CACFF;
box-shadow: none;
background: transparent;
padding: 0 6px;
}
.ant-upload-list-item:hover .ant-upload-list-item-info{
background-color:#fff;
}
.upload_1 .ant-upload-list {
width: 350px;
}
.ant-input-number {
height: 40px;
line-height: 40px;
}
.workContent.AboutInputForm.ant-form-item {
border-bottom: none;
padding-bottom: 0px !important;
}
.newWorkUpload {
padding: 0px 30px 30px 30px!important;
background: #fff;
width: 100%;
display: inline-block;
border-bottom: 1px solid #EDEDED;
}
`}</style>
{ <Form.Item
label="内容"
className="AboutInputForm workContent mdInForm"
>
{getFieldDecorator('description', {
rules: [{
required: true, message: '请输入任务内容说明'
}],
})(
<TPMMDEditor ref={this.contentMdRef} placeholder="请输入任务内容说明最大限制5000个字符" mdID={'courseContentMD'} refreshTimeout={1500}
className="courseMessageMD" initValue={this.state.description}></TPMMDEditor>
)}
</Form.Item> }
<Upload {...uploadProps} className="upload_1 newWorkUpload">
<Button className="uploadBtn">
<Icon type="upload" /> 上传附件
</Button>
(单个文件150M以内)
</Upload>
{this.props.data&&this.props.data.task_type===2?
<Form.Item
label="分组设置"
className="AboutInputForm"
>
{getFieldDecorator('personNum', {
rules: [{
required: false
// required: true, message: '请输入最小人数和最大人数'
}],
})(
<div>
<p className="clearfix">
<ConditionToolTip condition={has_commit} title={'已有提交作品,人数范围只能扩大'}>
{/* max={has_commit ? init_min_num : null } */}
每组最小人数<InputNumber placeholder="请填写每组最小人数" min={1} className="winput-240-40 mr10" value={min_num}
onChange={this.min_num_change} style={{width:'180px'}} />
</ConditionToolTip>
<span className="ml15 mr15"></span>
{/* min={has_commit ? init_max_num : (min_num == undefined ? 2 : min_num + 1) } */}
<ConditionToolTip condition={has_commit} title={'已有提交作品,人数范围只能扩大'}>
每组最大人数<InputNumber className="winput-240-40 mr10" placeholder="请填写每组最大人数" value={max_num} max={10}
onChange={this.max_num_change} style={{width:'180px'}} />
</ConditionToolTip>
<div className="color-grey-9 mt20 font-14">学生提交作品时需要关联同组成员组内成员作品共享</div>
</p>
<p className="mt20">
<ConditionToolTip condition={has_commit || has_project} title={'已有关联项目或作品,不能修改'}>
<Checkbox checked={base_on_project} onChange={this.base_on_project_change}
disabled={has_project || has_commit}
className="color-grey-9 font-14"
>基于项目选中则必须在本平台创建项目项目管理员可以提交作品不选中无需在平台创建项目任意小组成员均可以提交作品</Checkbox>
</ConditionToolTip>
</p>
</div>
)}
</Form.Item>:""
}
<Form.Item>
<div className="clearfix mt30 mb30">
{/* htmlType="submit" */}
<Button type="primary" onClick={this.handleSubmit} className="defalutSubmitbtn fl mr20">提交</Button>
<a className="defalutCancelbtn fl" onClick={() => this.props.onCancel()}>取消</ a>
</div>
</Form.Item>
</Form>
</div>
)
}
}
const NewGtaskForm = Form.create({ name: 'NewGtaskForm' })(NewGtaskForms);
export default NewGtaskForm;

@ -0,0 +1,64 @@
import React, { Component } from 'react';
import axios from 'axios'
import PollDetailTabThirdInfo from '../../../courses/poll/PollDetailTabThirdInfo'
class PollBanksContent extends Component{
constructor(props){
super(props);
this.state={
pollDetail:undefined
}
}
componentDidMount = () =>{
let bankId=this.props.match.params.bankId;
let url = `/exercise_banks/${bankId}.json`
axios.get(url).then((result)=>{
if(result){
let pollDetail = {
poll:{
id: result.data.poll && result.data.poll.id ,
polls_description: result.data.poll && result.data.poll.description,
polls_name: result.data.poll && result.data.poll.name,
is_public:result.data.poll && result.data.poll.is_public
},
question_types:result.data.question_types,
questions:result.data.questions,
}
const crumbData={
title:result.data.poll && result.data.poll.name,
is_public:result.data.poll && result.data.poll.is_public,
crumbArray:[
{content:'详情'},
]
}
const menuData={
tab:'0',//tab选中的index
menuArray:[//tab以及tab路由
{to:`/banks/poll/${bankId}`,content:'内容详情'}
],
category:'poll',//毕设选题
id:bankId
}
this.props.initPublic(crumbData,menuData);
this.setState({
pollDetail
})
}
}).catch((error)=>{
console.log(error);
})
}
render(){
let { pollDetail } = this.state
return(
<div>
<PollDetailTabThirdInfo {...this.props} {...this.state} pollDetail = {pollDetail}></PollDetailTabThirdInfo>
</div>
)
}
}
export default PollBanksContent

@ -0,0 +1,42 @@
import React, { Component } from 'react';
import { Menu } from 'antd'
import { Link } from 'react-router-dom'
import { WordsBtn } from 'educoder'
import "../usersInfo.css"
import "../../../courses/css/Courses.css"
import "../../../courses/css/busyWork.css"
class BanksMenu extends Component{
constructor(props){
super(props);
}
render(){
let { banksMenu } = this.props;
return(
<div className="clearfix bor-bottom-greyE edu-back-white" style={{padding:"2px 30px"}}>
{
banksMenu &&
<div className="task_menu_ul fl">
<Menu mode="horizontal" selectedKeys={[`${banksMenu && banksMenu.tab}`]}>
{
banksMenu.menuArray && banksMenu.menuArray.map((item,key)=>{
return(
<Menu.Item key={key}><Link to={`${item.to}`}>{item.content}</Link></Menu.Item>
)
})
}
</Menu>
</div>
}
<span className="fr mt18">
<WordsBtn to={''} style="blue" className="ml20 font-16">删除</WordsBtn>
<WordsBtn to={''} style="blue" className="ml20 font-16">编辑</WordsBtn>
<WordsBtn to={''} style="blue" className="ml20 font-16">发送</WordsBtn>
</span>
</div>
)
}
}
export default BanksMenu;

@ -226,4 +226,158 @@
content: '';
left:0px;
background: #4CACFF;
}
/* 题库相关 */
.breadcrumb{
height: 18px;
line-height: 18px;
margin:10px 0px 0px;
}
.breadcrumb .ant-breadcrumb-separator{
margin:0px 2px!important;
}
.breadcrumb span.ant-breadcrumb-link{
cursor: default;
}
.bank_is_public{
background: #E4F2FE;
float: left;
height: 30px;
line-height: 30px;
padding:0px 20px;
color: #4CACFF;
font-size: 16px;
margin-left: 10px;
}
.topicsbox{
width: 1200px;
/*min-height: 216px;*/
background: rgba(255,255,255,1);
padding: 0px 30px 0px 40px;
}
.topicstopfont{
width:64px;
height:16px;
font-size:16px;
font-family:PingFangSC;
font-weight:400;
color:rgba(51,51,51,1);
cursor: pointer;
}
.topcschild{
width:1128px;
height:55px;
line-height: 54px;
border-bottom:1px solid rgba(235,235,235,1);
}
.topcsmid{
width:1128px;
height:55px;
line-height: 55px;
}
.topcsactive{
color: #4CACFF !important;
}
.topicsmidfont{
max-width: 56px;
height: 55px;
font-size: 14px;
font-family: PingFangSC;
font-weight: 400;
cursor: pointer;
line-height: 55px;
}
.alltopisc{
width:230px;
height:20px;
font-size:14px;
font-family:PingFangSC;
font-weight:400;
color:rgba(153,153,153,1);
line-height:20px;
}
.alltopiscright{
/* width: 141px; */
height: 20px;
font-size: 14px;
font-family: PingFangSC;
font-weight: 400;
color: rgba(153,153,153,1);
line-height: 20px;
}
.topicsbtn{
padding: 3px 15px;
border-radius: 2px;
color: #4C4C4C;
cursor: pointer;
display: inline-block;
background-color: #4CACFF!important;
color: #fff!important;
}
.pd1323{
padding: 10px 6px 25px 40px;
cursor: pointer;
}
.pd1323:hover {
box-shadow: 0px 2px 6px rgba(51,51,51,0.09);
opacity: 1;
border-radius: 2px;
}
.topicswidth400{
width: 400px;
display: inline-block;
}
.topicswidth300{
width: 300px;
display: inline-block;
}
.topiscfilterbtn{
font-size: 14px;
color: #4CACFF !important;
border-radius: 5px;
border: 1px solid #4CACFF !important;
line-height: 23px !important;
}
.topscisright{
right: 0px;
top: 50px;
display: block;
position: absolute;
}
.topsics100{
width: 100px;
display: inline-block;
}
.professional_certificationbox{
height:431px;
background:rgba(255,255,255,1);
}
.pd115200{
padding: 55px 200px 0px 200px;
}
.topicsItemimg{
width:150px;
}
.topicsItemfont{
font-size: 18px;
font-family: PingFang-SC;
font-weight: 400;
color: rgba(51,51,51,1);
line-height: 35px;
}

@ -170,7 +170,7 @@ input::-ms-clear{display:none;}
.newContainer{ min-height:100%; height: auto !important; height: 100%; /*IE6不识别min-height*/position: relative;}
.educontent{width: 1200px;margin:0px auto;box-sizing: border-box}/*中间部分宽度固定为1200*/
.newMain{ margin: 0 auto; padding-bottom: 235px; min-width:1200px;}/*padding-bottom根据底部的高度而定*/
.newMain{ padding-bottom: 120px !important; }
.newMain{ padding-bottom: 124px !important; }
/*高度*/
.height-100{height: 100%;}

Loading…
Cancel
Save