diff --git a/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js b/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js index d7614459c..ccaa3c04b 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkAnswer.js @@ -56,7 +56,11 @@ class CommonWorkAnswer extends Component{ } componentDidMount() { this.fetchData() + try { + this.props.triggerRef(this); + }catch (e) { + } on('commonwork_fetch_all', this.fetchAllListener) } componentWillUnmount() { diff --git a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js index 4d82f4182..8c77aaab2 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js @@ -17,7 +17,7 @@ import PublishRightnow from './PublishRightnow' import '../css/Courses.css' import CBreadcrumb from '../common/CBreadcrumb' import DownloadMessageysl from "../../modals/DownloadMessageysl"; - +import ConnectProject from './ConnectProject' import { Spin } from 'antd' //引入对应跳转的组件 @@ -158,6 +158,30 @@ class CommonWorkDetailIndex extends Component{ } bindRef = ref => { this.child = ref }; + // 关联项目 + openConnectionProject = (work) => { + this.refs['connectProject'].openConnectionProject(work) + } + connectSuccess = () => { + this.child.fetchData && this.child.fetchData() + } + + cancelConnectionProject = (work) => { + let workId=this.props.match.params.workId; + let courseId=this.props.match.params.coursesId; + + const url = `/homework_commons/${work.homework_id}/student_works/cancel_relate_project.json` + axios.get(url).then((response)=> { + if (response.data.status == 0) { + this.child.fetchData && this.child.fetchData() + + this.props.showNotification('取消关联成功') + } + }).catch((error)=>{ + console.log(error) + }) + } + // 关联项目 END render() { let {course_name, homework_name, homework_status, noTab @@ -180,7 +204,8 @@ class CommonWorkDetailIndex extends Component{ const childModuleName = this.state.moduleName const commonHandler = { - initWorkDetailCommonState: this.initWorkDetailCommonState + initWorkDetailCommonState: this.initWorkDetailCommonState, + triggerRef: this.bindRef } const isAdmin = this.props.isAdmin() @@ -191,7 +216,7 @@ class CommonWorkDetailIndex extends Component{ let params = {} if (isListModule) { // TODO - if(this.child!=undefined) { + if(this.child && this.child._getRequestParams) { params = this.child._getRequestParams() !== undefined ? this.child._getRequestParams() : {}; } } @@ -341,6 +366,20 @@ class CommonWorkDetailIndex extends Component{ {/*项目在线质量检测*/} {isAdmin && this.props.toEditPage(this.props.match.params, workId)}>编辑作业} + { // + work_statuses && work_statuses.indexOf('关联项目') != -1 && + + + this.openConnectionProject({ homework_id: workId })}>关联项目 + this.props.toCreateProject()}>创建项目 + + } + + { // + work_statuses && work_statuses.indexOf('取消关联') != -1 && + this.cancelConnectionProject( {homework_id: workId} )}>取消关联 + } + {work_statuses && work_statuses.indexOf('提交作品') != -1 && { this.props.toWorkPostPage(this.props.match.params)}} >提交作品} diff --git a/public/react/src/modules/courses/busyWork/CommonWorkList.js b/public/react/src/modules/courses/busyWork/CommonWorkList.js index 10bbca9f3..528aa1d9e 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkList.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkList.js @@ -38,10 +38,10 @@ function renderScore(score, content) { function getScoreTip(score, dom) { return score == '--' ? '未评分' : score == '**' ? '未公开' : dom } -function buildColumns(that, student_works) { +function buildColumns(that, student_works, studentData) { let gotWorkGroup = false; let gotProjectInfo = false; - if (student_works) { + if (student_works && student_works.length) { student_works.forEach(item => { if (item.work_group) { gotWorkGroup = true @@ -50,6 +50,13 @@ function buildColumns(that, student_works) { gotProjectInfo = true; } }) + } else if (studentData && studentData[0]) { + if (studentData[0].work_group) { + gotWorkGroup = true + } + if (studentData[0].project_info) { + gotProjectInfo = true; + } } let courseId= that.props.match.params.coursesId; let workId= that.props.match.params.workId; @@ -431,6 +438,9 @@ class CommonWorkList extends Component{ group_id:arg_course_group, } } + fetchData = () => { + this.fetchList() + } fetchList = () => { let workId=this.props.match.params.workId; let courseId=this.props.match.params.coursesId; @@ -542,7 +552,7 @@ class CommonWorkList extends Component{ late_penalty, absence_penalty, appeal_penalty ,end_immediately ,publish_immediately - , homework_id, visible + , homework_id, visible, work_group, project_info } =this.state; @@ -566,7 +576,6 @@ class CommonWorkList extends Component{ return { label: `${item.name}(${item.count})`, value: item.id } }) - const columns = buildColumns(this, student_works) const isAdmin = this.props.isAdmin() const isStudent = this.props.isStudent() @@ -579,9 +588,11 @@ class CommonWorkList extends Component{ }else{ StudentData=isStudent ? [{ id, user_name, user_login, student_id, group_name, work_status, update_time, teacher_score, teaching_asistant_score, student_score, ultimate_score, work_score, student_comment_count, appeal_all_count, appeal_deal_count, - late_penalty, absence_penalty, appeal_penalty, - work_group: '', isMine: true }] : [] + late_penalty, absence_penalty, appeal_penalty, project_info, + work_group, isMine: true }] : [] } + const columns = buildColumns(this, student_works, StudentData) + let params = this._getRequestParams() let exportUrl = `/api/homework_commons/${workId}/works_list.zip?${queryString.stringify(params)}`; const exportResultUrl = `/api/homework_commons/${workId}/works_list.xlsx`; diff --git a/public/react/src/modules/courses/busyWork/CommonWorkQuestion.js b/public/react/src/modules/courses/busyWork/CommonWorkQuestion.js index 49f1e5158..f400cd9a2 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkQuestion.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkQuestion.js @@ -55,7 +55,11 @@ class CommonWorkQuestion extends Component{ } componentDidMount() { this.fetchData() - + try { + this.props.triggerRef(this); + }catch (e) { + + } on('commonwork_fetch_all', this.fetchAllListener) } componentWillUnmount() { diff --git a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js index aeda66ae1..4683e4e88 100644 --- a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js +++ b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js @@ -77,7 +77,7 @@ class CommonWorkSetting extends Component{ } } - getsettings=()=>{ + fetchData=()=>{ let workId=this.props.match.params.workId; const isAdmin = this.props.isAdmin() const url = `/homework_commons/${workId}/settings.json` @@ -160,14 +160,19 @@ class CommonWorkSetting extends Component{ componentDidMount(){ - this.getsettings(); + this.fetchData(); + try { + this.props.triggerRef(this); + }catch (e) { + + } on('commonwork_fetch_all', this.fetchAllListener) } componentWillUnmount() { off('commonwork_fetch_all', this.fetchAllListener) } fetchAllListener = () => { - this.getsettings() + this.fetchData() } @@ -477,7 +482,7 @@ class CommonWorkSetting extends Component{ // checkBoxValues:[], // checkAllValue:false // }) - // this.getsettings(); + // this.fetchData(); // } // }).catch((error)=>{ @@ -988,11 +993,11 @@ class CommonWorkSetting extends Component{ Saves={Saves} course_groups={course_groups} /> */} - -