import React, { Component } from "react"; import { SnackbarHOC, getImageUrl } from 'educoder'; import axios from 'axios'; import { Spin, Table, Pagination, } from "antd"; import Colleagechart from './colleagechart/Colleagechart' import Colleagechartzu from './colleagechart/Colleagechartzu' import TPMIndexHOC from "../modules/tpm/TPMIndexHOC"; import NoneData from './../modules/courses/coursesPublic/NoneData'; import './colleagecss/colleage.css'; class College extends Component { constructor(props) { super(props); this.state = { coursesloading: false, columns: [ { title: '名称', dataIndex: 'name', key: 'name', align: 'center', className: "edu-txt-center font-14 maxnamewidth247", render: (text, record) => ( { record.name } ) }, { title: '管理教师', dataIndex: 'teachers', key: 'teachers', align: 'center', className: "edu-txt-center font-14 maxnamewidth340", render: (text, record) => ( { record.teachers } ) }, { title: '评测次数', dataIndex: 'times', key: 'times', align: 'center', className: "edu-txt-center font-14 maxnamewidth175", render: (text, record) => ( { record.evaluating_count } ), }, { title: '学生', key: 'student', dataIndex: 'student', align: 'center', className: "edu-txt-center font-14 maxnamewidth255", render: (text, record) => ( { record.student_count } ) }, { title: '实训作业', dataIndex: 'training', key: 'training', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.shixun_work_count } ) }, { title: '资源', dataIndex: 'resources', key: 'resources', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.attachment_count } ), }, { title: '帖子', dataIndex: 'posts', key: 'posts', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.message_count } ) }, { title: '其它任务', dataIndex: 'othertasks', key: 'othertasks', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.other_work_count } ) }, { title: '状态', dataIndex: 'states', key: 'states', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.is_end ? "已结束" : "正在进行" } ) }, { title: '时间', dataIndex: 'timemy', key: 'timemy', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.activity_time } ) }, ], page: 1, limit: 10, total_users: 50, teachersloading: false, teacherranking: [ { title: '排名', dataIndex: 'ranking', key: 'ranking', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.id } ) }, { title: '姓名', dataIndex: 'name', key: 'name', align: 'center', className: "edu-txt-center font-14 maxnamewidth105", render: (text, record) => ( { record.name } ) }, { title: '管理课堂', dataIndex: 'classroom', key: 'classroom', align: 'center', className: "edu-txt-center font-14 maxnamewidth175", render: (text, record) => ( { record.course_count } ), }, { title: '已发布实训作业', key: 'assignment', dataIndex: 'assignment', align: 'center', className: "edu-txt-center font-14 maxnamewidth255", render: (text, record) => ( { record.shixun_work_count } ) }, { title: '未发布实训作业', dataIndex: 'released', key: 'released', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.un_shixun_work_count } ) }, { title: '学生数', dataIndex: 'studentnumber', key: 'studentnumber', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.student_count } ), }, { title: '完成率', dataIndex: 'completionrate', key: 'completionrate', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.complete_rate + "%" } ) }, { title: '发布实训', dataIndex: 'releasetraining', key: 'releasetraining', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.publish_shixun_count } ) } ], studentranking: [ { title: '排名', dataIndex: 'ranking', key: 'ranking', align: 'center', className: "edu-txt-center font-14", width: '100px', render: (text, record) => ( { record.id === 1 ? : record.id === 2 ? : record.id === 3 ? : record.id } ) }, { title: '姓名', dataIndex: 'name', key: 'name', align: 'center', className: "edu-txt-center font-14 maxnamewidth105", width: '100px', render: (text, record) => ( { record.name } ) }, { title: '学号', dataIndex: 'studentid', key: 'studentid', align: 'center', className: "edu-txt-center font-14 maxnamewidth175", render: (text, record) => ( { record.student_id } ), }, { title: '完成实训', key: 'training', dataIndex: 'training', align: 'center', className: "edu-txt-center font-14 maxnamewidth255", render: (text, record) => ( { record.shixun_count } ) }, { title: '在学实训', dataIndex: 'learning', key: 'learning', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.study_shixun_count } ) }, { title: '金币', dataIndex: 'goldcoin', key: 'goldcoin', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.grade } ), }, { title: '经验值', dataIndex: 'empirical', key: 'empirical', align: 'center', className: "edu-txt-center font-14", render: (text, record) => ( { record.experience } ) }, ], school: "", teachers_count: null, students_count: null, courses_count: null, shixuns_count: null, shixun_report_count: null, shixun_time: null, courses: null, course_count: 0, pages: 1, limits: 10, teachers: null, teacher_count: 0, students: null, student_count: 0, shixun_chart_data: null, shixun_chart_datanames: null, studentionsnames: null, studentionsvalues: null } } componentDidMount() { console.log("College"); console.log(this.props.match.params.id); this.gettop(); this.Numberofinternshipreports(); this.Actualcombattimeoftrainees(); this.Classnumber(1, 10); this.Teacherranking(1, 10); this.Studentranking(1, 10); this.Onlinetraining(); this.Hottest(); } //头部 gettop = () => { const id = this.props.match.params.id; const url = `/colleges/${id}/statistics.json`; axios.get(url).then((response) => { if (response === null || response === undefined) { this.setState({ teachers_count: 0, students_count: 0, courses_count: 0, shixuns_count: 0, school: "", }) return } if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { this.setState({ teachers_count: 0, students_count: 0, courses_count: 0, shixuns_count: 0, school: "", }) } else { this.setState({ teachers_count: response.data.teachers_count, students_count: response.data.students_count, courses_count: response.data.courses_count, shixuns_count: response.data.shixuns_count, school: response.data.school, }) } }).catch((error) => { console.log(error) this.setState({ teachers_count: 0, students_count: 0, courses_count: 0, shixuns_count: 0, school: "", }) }); } //获取实训报告数 Numberofinternshipreports = () => { const id = this.props.match.params.id; const url = `/colleges/${id}/shixun_report_count.json`; axios.get(url).then((response) => { if (response === null || response === undefined) { this.setState({ shixun_report_count: 0, }) return } if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { this.setState({ shixun_report_count: 0, }) } else { if (response.data.status === -1) { this.setState({ shixun_report_count: 0, }) return } this.setState({ shixun_report_count: response.data.shixun_report_count, }) } }).catch((error) => { console.log(error) this.setState({ shixun_report_count: 0, }) }); } //学员实战时间 Actualcombattimeoftrainees = () => { const id = this.props.match.params.id; const url = `/colleges/${id}/shixun_time.json`; axios.get(url).then((response) => { if (response === null || response === undefined) { this.setState({ shixun_time: 0, }) return } if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { this.setState({ shixun_time: 0, }) } else { if (response.data.status === -1) { this.setState({ shixun_time: 0, }) return } this.setState({ shixun_time: response.data.shixun_time, }) } }).catch((error) => { console.log(error) this.setState({ shixun_time: 0, }) }); } //课堂信息 Classnumber = (page, per_page) => { const id = this.props.match.params.id; const url = `/colleges/${id}/course_statistics.json`; this.setState({ coursesloading: true }) axios.get(url, { params: { page: page, per_page: per_page, } }).then((response) => { if (response === null || response === undefined) { this.setState({ courses: [], course_count: 0 }) return } if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { this.setState({ courses: [], course_count: 0 }) } else { if (response.data.status === -1) { this.setState({ courses: [], course_count: 0 }) return } this.setState({ courses: response.data.courses, course_count: response.data.course_count, page: page, limit: per_page }) } this.setState({ coursesloading: false }) }).catch((error) => { this.setState({ courses: [], course_count: 0, coursesloading: false }) }); } //教师排名 Teacherranking = (page, per_page) => { const id = this.props.match.params.id; const url = `/colleges/${id}/teachers.json`; this.setState({ teachersloading: true }) axios.get(url, { params: { page: page, per_page: per_page, } }).then((response) => { if (response === null || response === undefined) { this.setState({ teachers: [], teacher_count: 0 }) return } if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { this.setState({ teachers: [], teacher_count: 0 }) } else { if (response.data.status === -1) { this.setState({ teachers: [], teacher_count: 0 }) return } let teachers = []; if (response.data.teachers) { for (let i = 0; i < response.data.teachers.length; i++) { let datay = { id: (i + (page - 1) * 10) + 1, login: response.data.teachers[i].login, name: response.data.teachers[i].name, // 姓名 course_count: response.data.teachers[i].course_count, // 课堂数 shixun_work_count: response.data.teachers[i].shixun_work_count, // 已发布实训作业 un_shixun_work_count: response.data.teachers[i].un_shixun_work_count, // 未发布实训作业 student_count: response.data.teachers[i].student_count, // 学生数 complete_rate: response.data.teachers[i].complete_rate, // 完成率 publish_shixun_count: response.data.teachers[i].publish_shixun_count, // 发布实训数 } teachers.push(datay); } } this.setState({ teachers: teachers, teacher_count: response.data.teacher_count, pages: page, limits: per_page, }) } this.setState({ teachersloading: false }) }).catch((error) => { this.setState({ teachers: [], teacher_count: 0, teachersloading: false }) }); } //学生排名 Studentranking = (page, per_page) => { const id = this.props.match.params.id; const url = `/colleges/${id}/student_shixun.json`; this.setState({ studentsloading: true }) axios.get(url, { params: { page: page, per_page: per_page, } }).then((response) => { if (response === null || response === undefined) { this.setState({ students: [], student_count: 0, }) return } if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { this.setState({ students: [], student_count: 0, }) } else { if (response.data.status === -1) { this.setState({ students: [], student_count: 0, }) return } let students = []; if (response.data.teachers) { for (let i = 0; i < response.data.teachers.length; i++) { let datay = { id: (i + (page - 1) * 10) + 1, login: response.data.teachers[i].login, name: response.data.teachers[i].name, // 姓名 student_id: response.data.teachers[i].student_id, shixun_count: response.data.teachers[i].shixun_count, study_shixun_count: response.data.teachers[i].study_shixun_count, grade: response.data.teachers[i].grade, experience: response.data.teachers[i].experience, } students.push(datay); } } this.setState({ students: students, student_count: response.data.student_count, pagess: page, limitss: per_page, }) } this.setState({ studentsloading: false }) }).catch((error) => { this.setState({ students: [], student_count: 0, studentsloading: false }) }); } //在线实训情况 Onlinetraining = () => { const id = this.props.match.params.id; const url = `/colleges/${id}/shixun_chart_data.json`; axios.get(url).then((response) => { if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { this.setState({ shixun_chart_data: [], shixun_chart_datanames: [] }) } else { if (response.data.status === -1) { this.setState({ shixun_chart_data: [], shixun_chart_datanames: [] }) return } this.setState({ shixun_chart_data: response.data.data, shixun_chart_datanames: response.data.names }) } }).catch((error) => { this.setState({ shixun_chart_data: [], shixun_chart_datanames: [] }) }); } //最热测评 Hottest = () => { const id = this.props.match.params.id; const url = `/colleges/${id}/student_hot_evaluations.json`; axios.get(url).then((response) => { if (response.data.status === 403 || response.data.status === 401 || response.data.status === 500) { this.setState({ studentionsnames: [], studentionsvalues: [] }) } else { if (response.data.status === -1) { this.setState({ studentionsnames: [], studentionsvalues: [] }) return } this.setState({ studentionsnames: response.data.names, studentionsvalues: response.data.values }) } }).catch((error) => { this.setState({ studentionsnames: [], studentionsvalues: [] }) }); } table1handleChange() { } //塞选 paginationonChange = (pageNumber) => { this.Classnumber(pageNumber, 10); } paginationonChanges = (pageNumber) => { this.Teacherranking(pageNumber, 10); } paginationonChangess = (pageNumber) => { this.Studentranking(pageNumber, 10); } render() { let { columns, page, limit, total_users, teacherranking, studentranking, teachers_count, students_count, courses_count, shixuns_count, shixun_report_count, shixun_time, courses, course_count, school, teachers, pages, limits, teacher_count, teachersloading, coursesloading, pagess, limitss, studentsloading, students, student_count, shixun_chart_data, shixun_chart_datanames, studentionsnames, studentionsvalues } = this.state; return (
{school}
{/*//教师1*/}
教师
{teachers_count ? teachers_count : 0}
学生
{students_count ? students_count : 0}
课堂
{courses_count ? courses_count : 0}
共建实训
{shixuns_count ? shixuns_count : 0}
{/*//教师2*/}

基本使用情况

{/*基本使用情况1*/}

教师

学生

课堂

共建实训

实训报告

学员实战时间

{/*基本使用情况2*/}
{ teachers_count ?
{teachers_count}
: }
{ students_count ?
{students_count}
: }
{ courses_count ?
{courses_count}
: }
{ shixuns_count ?
{shixuns_count}
: }
{ shixun_report_count ?
{shixun_report_count}
: }
{ shixun_time ?
{shixun_time}
: }
{/*基本使用情况3结束*/}

课堂

{ courses === null ?
: JSON.stringify(courses) === "[]" ? :
{courses === undefined ? "" : } { course_count >= 11 ?
: "" } }

教师排名

{ teachers === null ?
: JSON.stringify(teachers) === "[]" ? :
{teachers === undefined ? "" :
} } {/*
*/} {/*
*/} {/* */} {/*
*/} {/*
*/}

在线实训情况

{ shixun_chart_data === null ?
: JSON.stringify(shixun_chart_data) === "[]" ? : }

学生排名

{ students === null ?
: JSON.stringify(students) === "[]" ? :
{students === undefined ? "" :
} } {/*
*/} {/*
*/} {/* */} {/*
*/} {/*
*/}

最热评测

{ studentionsnames === null ?
: JSON.stringify(studentionsnames) === "[]" ? : }
) } } export default SnackbarHOC()(TPMIndexHOC(College));