import React,{ Component } from "react"; import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin } from "antd"; import { WordsBtn,on, off, trigger } from 'educoder'; import {BrowserRouter as Router,Route,Switch,Link} from 'react-router-dom'; import axios from'axios'; import HomeworkModal from "../coursesPublic/HomeworkModal"; import ShixunModal from "../coursesPublic/ShixunModal"; import PathModal from "../coursesPublic/PathModal"; import NewShixunModel from '../coursesPublic/NewShixunModel'; import AddcoursesNav from "../coursesPublic/AddcoursesNav"; import Modals from '../../modals/Modals'; import moment from 'moment'; import '../css/members.css'; import '../css/busyWork.css' import ShixunhomeWorkItem from "./ShixunhomeWorkItem"; import NoneData from "../coursesPublic/NoneData"; const Search = Input.Search; class ShixunHomework extends Component{ constructor(props){ super(props); this.state={ modalname:undefined, modaltype:undefined, visible:false, Topval:undefined, Topvalright:undefined, Botvalleft:undefined, Botval:undefined, starttime:undefined, endtime:undefined, Cancelname:undefined, Savesname:undefined, Cancel:undefined, Saves:undefined, StudentList_value:undefined, addname:undefined, addnametype:false, addnametab:undefined, addcanner:undefined, addsave:undefined, datas:undefined, page:1, Coursename:"", order:"", shixunmodal:false, shixunmodallist:undefined, hometypepvisible:false, newshixunmodallist:undefined, category_id:undefined, homework_ids:undefined, patheditarry:[], course_groups:undefined, course_groupslist:[], checkedtype:false, checkBoxValues:[], isSpin:false, antIcon:false } } updateNavSuccess=()=>{ this.setState({ isSpin:true }) if(this.props.match.params.main_id){ this.setState({ isSpin:true }) this.seactall(); if(this.props.isAdmin()===true){ this.updadatalist() } }else if(this.props.match.params.category_id){ this.setState({ isSpin:true }) this.seactall(parseInt(this.props.match.params.category_id)) if(this.props.isAdmin()===true){ this.updadatalist() } } } componentDidMount() { this.setState({ isSpin:true, }) if(this.props.match.params.main_id){ this.setState({ isSpin:true }) this.seactall(); if(this.props.isAdmin()===true){ this.updadatalist() } }else if(this.props.match.params.category_id){ this.setState({ isSpin:true }) this.seactall(parseInt(this.props.match.params.category_id)) if(this.props.isAdmin()===true){ this.updadatalist() } } on('updateNavSuccess', this.updateNavSuccess) } seactall=(id)=>{ this.setState({ isSpin:true, checkBoxValues:[] }) let coursesId=this.props.match.params.coursesId; let url="/courses/"+coursesId+"/homework_commons.json?type=4"; axios.get(encodeURI(url),{ params: { search:undefined, page:1, order:undefined, category:id } }).then((result)=>{ this.setState({ isSpin:false, datas:result.data, }) }).catch((error)=>{ console.log(error); }) } componentDidUpdate = (prevProps) => { if(prevProps.match.params.main_id != this.props.match.params.main_id){ if(this.props.match.params.main_id!=undefined){ this.seactall(); } } if(prevProps.match.params.category_id != this.props.match.params.category_id){ if(this.props.match.params.category_id!=undefined){ this.seactall(parseInt(this.props.match.params.category_id)) } } } homeworkupdatalist=(search,page,order)=>{ let {datas}=this.state; // let newhomework_idsval=checkBoxValues; let coursesId=this.props.match.params.coursesId; let category_id=this.props.match.params.category_id let url="/courses/"+coursesId+"/homework_commons.json?type=4"; let neworder=order; if(order==="null"){ neworder="" } axios.get(url, { params: { search: search, page:page, order:neworder, category: category_id===undefined?undefined:category_id } }).then((result)=>{ if(result.status===200){ // if(checkedtype===true&&page>1){ // for(var value of result.data.homeworks){ // checkBoxValues.push(value.homework_id) // } // } this.setState({ datas:result.data, isSpin:false }) } }).catch((error)=>{ console.log(error); }) } homeworkhide=()=>{ let {Coursename,page,order}=this.state; this.setState({ modalname:undefined, modaltype:undefined, visible:false, Topval:undefined, Topvalright:undefined, Botvalleft:undefined, Botval:undefined, starttime:undefined, endtime:undefined, Cancelname:undefined, Savesname:undefined, Cancel:undefined, Saves:undefined, StudentList_value:undefined, addname:undefined, addnametype:false, addnametab:undefined, typs:undefined, starttimes:undefined, }) this.props.updataleftNavfun() this.homeworkupdatalist(Coursename,page,order); this.cancelmodel() } //立即发布 homeworkstart=()=>{ let selectnum= this.testonSelect(); if(selectnum===true){ this.noSelect(); return } let coursesId=this.props.match.params.coursesId; let url="/courses/"+coursesId+"/all_course_groups.json"; axios.get(url).then((response) => { if(response.status===200){ let starttime= this.props.getNowFormatDates(1); let endtime=this.props.getNowFormatDates(2); this.setState({ modalname:"立即发布", modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1, visible:true, typs:"start", Topval:"学生将立即收到作业", // Botvalleft:"暂不发布", Botval:`本操作只对"未发布"的分班有效`, starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"), starttimes:starttime, endtime:"截止时间:"+endtime, Cancelname:"暂不发布", Savesname:"立即发布", Cancel:this.homeworkhide, Saves:this.homeworkstartend, course_groups:response.data.course_groups, }) } }).catch((error) => { console.log(error) }); } cancelmodels=()=>{ this.setState({ Modalstype:false, Loadtype:false, Modalstopval:"" }) } // 立即发布 homeworkstartend=(ds,endtime)=>{ let {Coursename,page,order,checkBoxValues,course_groupslist,datas,course_groups}=this.state; let category_id=this.props.match.params.category_id; if(course_groups.length>0){ if(course_groupslist.length===0){ this.setState({ Modalstype:true, Loadtype:true, Modalstopval:"请先选择分班", ModalSave:this.cancelmodels, }) return } } let coursesId=this.props.match.params.coursesId; let url ="/courses/"+coursesId+"/homework_commons/publish_homework.json"; axios.post(url,{ category_id:category_id===undefined?undefined:category_id, homework_ids:checkBoxValues, group_ids:course_groupslist, end_time:endtime, }).then((result)=>{ if(result.status===200){ if(result.data.status===0){ this.setState({ Modalstype:false, // Modalstopval:result.data.message, Loadtype:false, visible:false, course_groups:[], ModalSave:this.cancelmodel, }) } this.props.showNotification(result.data.message) this.props.updataleftNavfun() this.homeworkupdatalist(Coursename,page,order); this.cancelmodel() } }).catch((error)=>{ console.log(error); }) } homeworkends=()=>{ let selectnum= this.testonSelect(); if(selectnum===true){ this.noSelect(); return } let coursesId=this.props.match.params.coursesId; let url="/courses/"+coursesId+"/all_course_groups.json"; axios.get(url).then((response) => { if(response.status===200){ this.setState({ }) this.setState({ modalname:"立即截止", modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1, visible:true, Topval:"学生将不能再提交作业", // Botvalleft:"暂不截止", Botval:`本操作只对"提交中"的分班有效`, Cancelname:"暂不截止", Savesname:"立即截止", Cancel:this.homeworkhide, Saves:this.coursetaskend, starttime:undefined, endtime:undefined, typs:"end", course_groups:response.data.course_groups, }) } }).catch((error) => { console.log(error) }); } getcourse_groupslist=(id)=>{ this.setState({ course_groupslist:id }) } //立即截止确定按钮 coursetaskend=()=>{ let {Coursename,page,order,datas,checkBoxValues,course_groupslist,course_groups}=this.state; this.setState({ Modalstype:false, }) let category_id=this.props.match.params.category_id; if(course_groups.length>0){ if(course_groupslist.length===0){ this.setState({ Modalstype:true, Loadtype:true, Modalstopval:"请先选择分班", ModalSave:this.cancelmodels, }) return } } const cid = this.props.match.params.coursesId; let url="/courses/"+cid+"/homework_commons/end_homework.json"; axios.post(url, { category_id:category_id===undefined?undefined:category_id, group_ids:course_groupslist, homework_ids: checkBoxValues, }) .then((response) => { if (response.data.status == 0) { this.setState({ Modalstype:false, Modalstopval:"", ModalsBottomval:"", ModalSave:this.cancelmodel, Loadtype:false, course_groups:[] }) this.props.showNotification(response.data.message) this.props.updataleftNavfun() this.homeworkupdatalist(Coursename,page,order); this.cancelmodel() } }) .catch(function (error) { console.log(error); }); } //发布实训,立即发布回调 newhomeworkstart=(category_id,homework_ids)=>{ this.setState({ category_id:category_id, checkBoxValues:homework_ids, shixunmodal:false }) let starttime= this.props.getNowFormatDates(1); let endtime=this.props.getNowFormatDates(2); let coursesId=this.props.match.params.coursesId; let url="/courses/"+coursesId+"/all_course_groups.json"; axios.get(url).then((response) => { if(response.status===200){ this.setState({ modalname:"立即发布", course_groups:response.data.course_groups, modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1, visible:true, Topval:"学生将立即收到作业", // Botvalleft:"暂不发布", Botval:`本操作只对"未发布"的分班有效`, starttime:"发布时间:"+ moment(moment(new Date())).format("YYYY-MM-DD HH:mm"), starttimes:starttime, typs:"start", endtime:"截止时间:"+ endtime, Cancelname:"暂不发布", Savesname:"立即发布", Cancel:this.homeworkhide, Saves:this.homeworkstartend, }) } }).catch((error) => { console.log(error) }); } // // 选用实训 // createCommonWork=()=>{ // // this.setState({ // hometypepvisible:true, // shixunmodal:true, // patheditarry:[], // checkBoxValues:[] // }) // // // } // 选用实训路径 createCommonpath=()=>{ this.setState({ hometypepvisible:true, patheditarry:[], checkBoxValues:[], shixunpath: true, }) } hidecouseShixunModal=()=>{ this.setState({ shixunmodal:false, shixunpath:false, shixunpathlist:[], newshixunpathlist:[], }) } // funshixunmodallist=(search,type,loading,page)=>{ // let{newshixunmodallist}=this.state; // let newshixunmodallists=[] // if(page>1){ // newshixunmodallists=newshixunmodallist; // } // this.setState({ // hometypepvisible:loading // }) // let coursesId=this.props.match.params.coursesId; // let url ="/courses/"+coursesId+"/homework_commons/shixuns.json"; // // axios.get(url, { // params: { // search: search, // type:type, // page:page // } // }).then((result)=>{ // if(result.status===200){ // // let shixun_lists=result.data.shixun_lists; // for(var i=0; i{ // console.log(error); // }) // } // funshixunpathlist=(search,type,loading,page)=>{ // let{newshixunpathlist}=this.state; // let newshixunmodallists=[] // if(page>1){ // newshixunmodallists=newshixunpathlist; // } // this.setState({ // hometypepvisible:loading // }) // let coursesId=this.props.match.params.coursesId; // let url ="/courses/"+coursesId+"/homework_commons/subjects.json"; // // axios.get(url, { // params: { // search: search, // type:type, // page:page // } // }).then((result)=>{ // if(result.status===200){ // // let shixun_lists=result.data.subject_list; // for(var i=0; i{ // console.log(error); // }) // } PaginationCourse=(pageNumber)=>{ let {Coursename,order}=this.state; this.setState({ page:pageNumber, checkBoxValues:[] }) this.homeworkupdatalist(Coursename,pageNumber,order); } SearchCoursenames=(e)=>{ this.setState({ Coursename:e.target.value }) } SearchCoursename=(value)=>{ let {page,order}=this.state; this.setState({ Coursename:value }) this.homeworkupdatalist(value,page,order); } handleClick = (e) => { let {Coursename,page}=this.state; this.setState({ order: e.key, checkBoxValues:[], checkedtype:false, isSpin:true }); let newkey=e.key; if(newkey==="null"){ newkey="" } this.homeworkupdatalist(Coursename,page,newkey); } funpatheditarry=(list)=>{ this.setState({ patheditarry:list }) } funselect=(e)=>{ let{page,datas}=this.state; let newhomework_idsval=[]; this.setState({ checkedtype:e.target.checked }) if(e.target.checked===true){ for (var value of datas.homeworks) { newhomework_idsval.push(value.homework_id); } } // console.log(newhomework_idsval) this.setState({ checkBoxValues:newhomework_idsval }) } onselectfifteen = () => { this.setState({ Modalstype:true, Modalstopval:"选择条数不能大于15条", ModalSave:this.cancelmodel, Loadtype:true }) } onCheckBoxChange=(checkedValues)=>{ // debugger let {checkBoxValues,tasks} =this.state; console.log(checkBoxValues) let type=false; if(checkBoxValues15||checkedValues.length>15){ this.onselectfifteen() return } this.setState({ checkBoxValues: checkedValues, checkAllValue:type }) } savedelete=()=>{ this.setState({ antIcon:true }) let {Coursename,page,order,checkBoxValues,datas}=this.state; let category_id=this.props.match.params.category_id; const cid = this.props.match.params.coursesId const url = `/courses/`+cid+`/homework_commons/multi_destroy.json`; axios.post(url, { category_id:category_id===undefined?undefined:category_id, homework_ids: checkBoxValues, }) .then((response) => { if (response.data.status === 0) { // this.setState({ // Modalstype:true, // Modalstopval:response.data.message, // ModalsBottomval:"", // ModalSave:this.cancelmodel, // Loadtype:true, // checkBoxValues:[], // checkAllValue:false // }) this.setState({ Modalstype:false, Modalstopval:"", ModalsBottomval:"", ModalSave:this.cancelmodel, Loadtype:false, checkBoxValues:[], checkedtype:false, antIcon:false }) this.props.showNotification(response.data.message) this.homeworkupdatalist(Coursename,page,order); this.props.updataleftNavfun() }else{ this.setState({ antIcon:false }) this.props.showNotification(response.data.message) } }) .catch(function (error) { console.log(error); }); } testonSelect=()=>{ let {checkBoxValues,checkedtype}=this.state; if(checkedtype===false){ if(checkBoxValues.length===0){ return true } } } onDelete = () => { let selectnum= this.testonSelect(); if(selectnum===true){ this.noSelect(); return } this.setState({ Modalstype:true, Modalstopval:"已提交作品将全部被删除,不可恢复", ModalsBottomval:"是否确认删除?", ModalCancel:this.cancelmodel, ModalSave:this.savedelete, }) } noSelect=()=>{ // this.setState({ // Modalstype:true, // Loadtype:true, // Modalstopval:"请选择你要操作的任务", // ModalSave:this.cancelmodel, // }) this.props.showNotification("请选择你要操作的任务"); } cancelmodel=()=>{ this.setState({ Modalstype:false, Loadtype:false, visible:false, Modalstopval:"", ModalCancel:"", ModalSave:"", checkBoxValues:[], checkedtype:false }) } onOpen=()=>{ let selectnum= this.testonSelect(); if(selectnum===true){ this.noSelect(); return } this.setState({ Modalstype:true, Modalstopval:"设为公开后,非课堂成员也可以访问查看", ModalsBottomval:"是否确认设为公开?", ModalCancel:this.cancelmodel, ModalSave:this.saveonOpen, }) } saveonOpen=()=>{ let {Coursename,page,order,checkBoxValues,datas}=this.state; this.setState({ Modalstype:false, }) let category_id=this.props.match.params.category_id; const cid = this.props.match.params.coursesId; let url="/courses/"+cid+"/homework_commons/set_public.json"; axios.post(url, { category_id:category_id===undefined?undefined:category_id, homework_ids: checkBoxValues, }) .then((response) => { if (response.data.status == 0) { this.setState({ Modalstype:false, Modalstopval:"", ModalsBottomval:"", ModalSave:this.cancelmodel, Loadtype:false, checkBoxValues:[] }) this.props.showNotification(response.data.message) this.homeworkupdatalist(Coursename,page,order); } }) .catch(function (error) { console.log(error); }); } updadatalist=(id)=>{ // this.seactall(id) let coursesId=this.props.match.params.coursesId; let url="/courses/"+coursesId+"/homework_commons/choose_category.json"; axios.get(url, { }).then((response) => { if(response!=undefined){ if(response.data&&response.data){ this.setState({ course_modules:response.data, homework_categorys:response.data.homework_category }) } } }) } moveTos=(id)=>{ let {checkBoxValues,Coursename,page,order}=this.state; let selectnum= this.testonSelect(); if(selectnum===true){ this.noSelect(); return } const cid = this.props.match.params.coursesId; const url = `/courses/`+cid+`/homework_commons/move_to_category.json` axios.post(url, { homework_ids: checkBoxValues, new_category_id:id, }) .then((response) => { if (response.data.status == 0) { this.setState({ // Modalstype:true, // Modalstopval:response.data.message, // ModalsBottomval:"", // ModalSave:this.cancelmodel, // Loadtype:true, checkBoxValues:[], checkAllValue:false }) this.props.showNotification('已完成') this.props.updataleftNavfun() this.homeworkupdatalist(Coursename,page,order); } }) } addDir = () => { this.setState({ checkBoxValues:[] }) let {datas}=this.state; trigger('shixun_homeworkadd', parseInt(datas.main_category_id)) } // // editname = (name) => { // let {datas}=this.state; // let data={id:parseInt(datas.main_category_id),name:name} // trigger('editshixunmainname', data) // } editDir = (name) => { this.setState({ checkBoxValues:[] }) let {datas}=this.state; let data={id:parseInt(datas.category_id),name:name} trigger('editshixunname', data) } gotohome=()=>{ let courseId=this.props.match.params.coursesId; if(courseId===undefined){ this.props.history.push("/courses"); }else{ this.props.history.push(this.props.current_user.first_category_url); } } showNewShixunModelType=()=>{ this.setState({ NewShixunModelType:true, patheditarry:[], checkBoxValues:[] }) } hideNewShixunModelType=()=>{ this.setState({ NewShixunModelType:false, shixunpath:false }) } render(){ let { modalname, modaltype, visible, Topval, Topvalright, Botvalleft, Botval, starttime, endtime, Cancelname, Savesname, Cancel, Saves, addname, addnametype, addnametab, addcanner, addsave, datas, page, Coursename, shixunmodal, shixunmodallist, hometypepvisible, newshixunmodallist, patheditarry, course_groups, Modalstype, checkedtype, checkBoxValues, course_modules, shixunpath, order, NewShixunModelType, }=this.state; let main_id=this.props.match.params.main_id; let category_id=this.props.match.params.category_id; return(
{/*新版实训model*/} {NewShixunModelType===true?this.hideNewShixunModelType()} coursesId={this.props.match.params.coursesId} homeworkupdatalists={(Coursename,page,order)=>this.homeworkupdatalist(Coursename,page,order)} Coursename={Coursename} page={page} order={order} statustype={'published'} />:""} {/*新版实训model*/} {shixunpath===true?this.hideNewShixunModelType()} coursesId={this.props.match.params.coursesId} homeworkupdatalists={(Coursename,page,order)=>this.homeworkupdatalist(Coursename,page,order)} Coursename={Coursename} page={page} order={order} />:""} {/*提示*/} {Modalstype&&Modalstype===true?:""} {/*立即发布*/} {visible===true?this.getcourse_groupslist(id)} />:""} {shixunmodal===true||shixunpath===true?:""} {/*添加目录/选择目录*/}

{datas&&datas.category_name===undefined||datas&&datas.category_name===null?datas&&datas.main_category_name:datas&&datas.category_name+" 作业列表"}

  • {datas===undefined?"":datas.homeworks && datas.homeworks.length>1?this.props.isAdminOrCreator()===true?datas&&datas.category_name===undefined||datas&&datas.category_name===null? 调整排序 :"":"":""} {this.props.isAdmin()===true?datas&&datas.category_name===undefined||datas&&datas.category_name===null? this.addDir()} className={"mr30 font-16"}>添加目录 {/*this.editname(datas&&datas.main_category_name)} className={"mr30"}>目录重命名*/} : this.editDir(datas&&datas.category_name)} className={"mr30 font-16"}>目录重命名:""} {this.props.isAdmin()===true?datas&&datas.category_name===undefined||datas&&datas.category_name===null?选用实践课程:"":""} {this.props.isAdmin()===true?this.showNewShixunModelType()}>选用实训项目:""}
  • 共 {datas&&datas.all_count}个实训作业 已发布:{datas&&datas.published_count}个 未发布: {datas&&datas.unpublished_count}个

    全部 {this.props.isAdmin()?未发布:""} 提交中 补交中 评阅中
    this.SearchCoursename(value)} >
    {this.props.isAdmin()===true? datas===undefined?'' :datas.homeworks.length===0?"":
    已选 {checkBoxValues&&checkBoxValues.length} 个 (不支持跨页勾选)
  • 删除
  • 立即发布
  • {/*onClick={this.homeworkstart}*/}
  • 立即截止
  • 设为公开
  • {/*onClick={()=>this.selectBlank(4)}*/} 移动到...
      { course_modules&&course_modules.homework_category.length > 10 &&

      {this.setState({dirSearchValue: e.target.value})}}/>

      } {course_modules&&course_modules.main_category.map((item,key)=>{ return( datas&&datas.category_id===null?"":
    • this.moveTos(item.main_category_id)} title={item.main_category_name.length>18?item.main_category_name:""}>{item.main_category_name}
    • ) })} { course_modules&&course_modules.homework_category.filter((item,key)=> { return (!this.state.dirSearchValue || item.category_name.indexOf(this.state.dirSearchValue) != -1) }).map( (item,key) => { if(datas&&datas.category_id!=null&&datas&&datas.category_id===item.category_id===false){ return
    • this.moveTos(item.category_id )} title={item.category_name.length>18?item.category_name:""}>{item.category_name}
    • } if(datas&&datas.category_id===null){ return
    • this.moveTos(item.category_id )} title={item.category_name.length>18?item.category_name:""}>{item.category_name}
    • } })} {course_modules&&course_modules.homework_category.length===0&&datas&&datas.category_id===null?
      暂无数据
      :""} {/*{course_modules&&course_modules.homework_category.map((item,key)=>{*/} {/*return(*/} {/*
    • this.moveTos(item.category_id )}>{item.category_name}
    • */} {/*)*/} {/*})}*/} {this.props.isAdmin()?datas&&datas.category_name===undefined||datas&&datas.category_name===null?

      this.addDir()}>添加目录...

      :"":""}
  • :""} {/*onChange={this.onCheckBoxChange} value={checkBoxValues}*/} {datas===undefined?"": { datas.homeworks && datas.homeworks.map((item, index) => { // console.log("ShixunhomeWorkItem") // console.log("++++++++++++++++++++++++++++++++++++++++++") // console.log(JSON.stringify(this.props)) return (
    :""} match={this.props.match} index={index} coursedata={this.props.coursedata} coursupdata={()=>this.homeworkupdatalist(Coursename,page,order)} course_identity={datas.course_identity} // onItemClick={this.onItemClick} // onSticky={this.onSticky} // funlist={()=>this.fetchAll(search,page,order)} // coursename={this.props.coursedata&&this.props.coursedata.name} // graduationId={this.props.match.params.graduationId} // taskid={item.task_id} // coursesId={this.props.match.params.coursesId} // categoryid={this.props.match.params.category_id} // workid={item.work_id} >
    ) }) }
    }
    15 ? 'block':'none' } }>
    { datas===undefined?"":datas.homeworks && datas.homeworks.length===0? :"" }
    ) } } export default ShixunHomework; // {/*
    */} // {/*
    */} // {/**/} // {/*

    暂时还没有相关数据哦!

    */} // {/*
    */}