作业 关联项目

dev_unstable
hjm 6 years ago
parent 01489d7f0f
commit 0365516e75

@ -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() {

@ -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{
{/*<a className={"fr color-blue font-16"}>项目在线质量检测</a>*/}
{isAdmin && <a className={"fr color-blue font-16"} onClick={() => this.props.toEditPage(this.props.match.params, workId)}>编辑作业</a>}
{ //
work_statuses && work_statuses.indexOf('关联项目') != -1 &&
<React.Fragment>
<ConnectProject ref="connectProject" {...this.props} connectSuccess={this.connectSuccess}></ConnectProject>
<WordsBtn style="blue" className={` font-16 fr`} onClick={() => this.openConnectionProject({ homework_id: workId })}>关联项目</WordsBtn>
<WordsBtn style="blue" className={` font-16 fr`} onClick={() => this.props.toCreateProject()}>创建项目</WordsBtn>
</React.Fragment>
}
{ //
work_statuses && work_statuses.indexOf('取消关联') != -1 &&
<WordsBtn style="blue" className={` font-16 fr`} onClick={() => this.cancelConnectionProject( {homework_id: workId} )}>取消关联</WordsBtn>
}
{work_statuses && work_statuses.indexOf('提交作品') != -1 && <a className={"fr color-blue font-16"} href={"javascript:void(0)"}
onClick={() => { this.props.toWorkPostPage(this.props.match.params)}}
>提交作品</a>}

@ -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`;

@ -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() {

@ -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}
/> */}
<PublishRightnow ref={this.publishModal} showActionButton={false} {...this.props} checkBoxValues={[workId]} action={this.getsettings}
<PublishRightnow ref={this.publishModal} showActionButton={false} {...this.props} checkBoxValues={[workId]} action={this.fetchData}
isPublish={true} doWhenSuccess={this.doWhenSuccess} checkBeforePost={this.saveWorkSetting}
onToPublishClick={this.onToPublishClick}
></PublishRightnow>
<PublishRightnow ref={this.endModal} showActionButton={false} {...this.props} checkBoxValues={[workId]} action={this.getsettings}
<PublishRightnow ref={this.endModal} showActionButton={false} {...this.props} checkBoxValues={[workId]} action={this.fetchData}
isPublish={false} doWhenSuccess={this.doWhenSuccess}></PublishRightnow>
<style>{`

Loading…
Cancel
Save