import '../katex.css'; import '../css/Courses.css'; import React,{Component} from "react"; import {markdownToHTML, ImageLayer2 } from 'educoder'; import {Button, Row, Col} from "antd"; import axios from 'axios'; import Modals from '../../modals/Modals'; import moment from 'moment'; import WorkDetailPageHeader from './common/WorkDetailPageHeader' import CommonWorkAppraiseReply from './reply/CommonWorkAppraiseReply' import CommonWorkAppraiseReviseAttachments from './CommonWorkAppraiseReviseAttachments' import LeaderIcon from './common/LeaderIcon'; import showdown from 'showdown' import showdownKatex from 'showdown-katex' class CommonWorkAppraise extends Component{ constructor(props){ super(props) this.state={ course_name:"", homework_name:"", search: '', get_next_work:undefined, attachments: [], revise_attachments: [], get_next_worktype:false } } getWork = () => { let workId =this.props.match.params.workId; let studentWorkId =this.props.match.params.studentWorkId; // https://www.showdoc.cc/127895880302646?page_id=1957586480118445 const url = `/student_works/${studentWorkId}.json` axios.get(url).then((result)=> { if (result.data.course_id) { this.setState({ ...result.data }) } }).catch((error)=>{ console.log(error) }) } exportMdtoHtml=(md)=> { let newmd=md; const converter = new showdown.Converter({ extensions: [ showdownKatex({ // maybe you want katex to throwOnError throwOnError: true, // disable displayMode displayMode: false, // change errorColor to blue errorColor: '#1500ff', }), ], }); return converter.makeHtml(newmd); } getReviseAttachments = () => { let studentWorkId =this.props.match.params.studentWorkId; const url = `/student_works/${studentWorkId}/supply_attachments.json`; axios.get(url).then((result)=> { if (result.data.revise_attachments) { this.setState({ ...result.data }) } }).catch((error)=>{ console.log(error) }) } componentDidUpdate(prevProps, prevState) { if (this.props.match.params.studentWorkId != prevProps.match.params.studentWorkId) { this.getWork(); this.getReviseAttachments() this.commonWorkAppraiseReply && this.commonWorkAppraiseReply.fetchAllComments() } } componentDidMount() { this.getWork(); this.getReviseAttachments() } get_next_works=(id)=>{ let workId =this.props.match.params.workId; let url if(id){ url=`/homework_commons/${workId}/get_next_work.json?work_id=${id}`; }else{ url=`/homework_commons/${workId}/get_next_work.json?work_id=${this.props.match.params.studentWorkId}`; } axios.get(url).then((result)=> { this.setState({ get_next_work:result.data, get_next_worktype:true }) }).catch((error)=>{ console.log(error) }) } gotoget_next_work=(id)=>{ if(this.props.match.path===`/classrooms/:coursesId/common_homeworks/:workId/:studentWorkId/appraise`){ this.props.history.replace(`/classrooms/${this.props.match.params.coursesId}/common_homeworks/${this.props.match.params.workId}/${id}/appraise`); } if(this.props.match.path===`/classrooms/:coursesId/group_homeworks/:workId/:studentWorkId/appraise`){ this.props.history.replace(`/classrooms/${this.props.match.params.coursesId}/common_homeworks/${this.props.match.params.workId}/${id}/appraise`); } this.setState({ get_next_worktype:false }) } onAttachmentRemove = (id) => { this.setState({ Modalstype:true, // Modalstopval:'确定要删除这个附件吗?', Modalstopval: '是否确认删除?', ModalSave: ()=>this.deleteAttachment(id), ModalCancel:this.cancelAttachment }) } deleteAttachment = (id) => { const url = `/attachments/${id}.json` axios.delete(url, { }) .then((response) => { if (response.data) { const { status } = response.data; if (status == 0) { this.getWork() this.getReviseAttachments(); this.cancelAttachment(); } } }) .catch(function (error) { console.log(error); }); } cancelAttachment=()=>{ this.setState({ Modalstype:false, Modalstopval:'', ModalSave:"", ModalCancel:"" }) } onReplySuccess = () => { this.getReviseAttachments(); } render(){ let {course_name, get_next_work,get_next_worktype, attachments, project_info, work_members, is_evaluation, description, update_user_name, commit_user_name, update_time, commit_time, author_name, Modalstype,Modalstopval,ModalCancel,ModalSave,loadtype, is_leader_work } =this.state; // let courseId=this.props.match.params.coursesId; // let category_id=this.props.match.params.category_id; let studentWorkId=this.props.match.params.studentWorkId; const isAdmin = this.props.isAdmin() document.title=course_name&&course_name; return(
{/*提示*/} {/* 内容区 */} {/*
*/}
{(description || (attachments && attachments.length != 0)) &&
内容
{attachments.map((item,key)=>{ return(
40 ? item.title : ''}`}> {item.title} {item.filesize} {/*{item.delete===true?:""}*/} {item.delete===true?:""} {/* style={{display: 'none'}} */}
) })}
{ update_time && 更新 {update_user_name} {moment(update_time).format('YYYY-MM-DD HH:mm')==="Invalid date"?"":moment(update_time).format('YYYY-MM-DD HH:mm')} } { commit_time && 提交 {commit_user_name} {moment(commit_time).format('YYYY-MM-DD HH:mm')==="Invalid date"?"":moment(commit_time).format('YYYY-MM-DD HH:mm')} }
} {is_evaluation != true && project_info && project_info.name &&
关联项目
} {is_evaluation != true && work_members && !!work_members.length &&
全部组员
当前组员:{author_name} {is_leader_work && }
其他组员: {work_members.map((item, index) => { return {isAdmin ? this.props.toWorkDetailPage(this.props.match.params, null, item.work_id)} > {item.user_name} : {item.user_name}} {item.is_leader && } })}
{isAdmin &&
温馨提示: 点击其他组员的姓名,可以快速评阅TA的作品
}
}
{/* task_type={datalist&&datalist.task_type} */} {this.commonWorkAppraiseReply = ref}} get_next_works={()=>this.get_next_works()} >
{isAdmin===true&&get_next_worktype===true?:""} {isAdmin===true&&get_next_worktype===true?
{get_next_work&&get_next_work.work_id===null?
已全部评阅完
:
{get_next_work&&get_next_work?`下一位待评阅人员:${get_next_work&&get_next_work.user_name}`:""}
this.get_next_works(get_next_work&&get_next_work.work_id)}>跳过
} {get_next_work&&get_next_work.work_id===null?"": }
:""}
) } } export default CommonWorkAppraise;