forked from Open-CT/OpenPBL
feat: student evidence page ui
This commit is contained in:
parent
9f2ba3f934
commit
735dc1365f
|
@ -82,9 +82,47 @@ func (p *ProjectController) GetProjectTasks() {
|
|||
return
|
||||
}
|
||||
|
||||
pid := p.GetString(":projectId")
|
||||
tasks, err := models.GetProjectTasks(pid, "")
|
||||
if err != nil {
|
||||
p.Data["json"] = Response{
|
||||
Code: 400,
|
||||
Msg: err.Error(),
|
||||
}
|
||||
} else {
|
||||
p.Data["json"] = Response{
|
||||
Code: 200,
|
||||
Data: tasks,
|
||||
}
|
||||
}
|
||||
p.ServeJSON()
|
||||
}
|
||||
|
||||
// GetProjectTasksAndSubmits
|
||||
// @Title
|
||||
// @Description get all the tasks of a section
|
||||
// @Param sid path string true ""
|
||||
// @Success 200 {object}
|
||||
// @Failure 400
|
||||
// @router /:projectId/tasks-submits [get]
|
||||
func (p *ProjectController) GetProjectTasksAndSubmits() {
|
||||
user := p.GetSessionUser()
|
||||
if user == nil {
|
||||
p.Data["json"] = TaskResponse{
|
||||
Response: Response{
|
||||
Code: 401,
|
||||
Msg: "请先登录",
|
||||
},
|
||||
}
|
||||
p.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
uid := ""
|
||||
if user.Tag == "student" {
|
||||
uid = user.Username
|
||||
} else if user.Tag == "teacher" {
|
||||
uid = p.GetString("StudentId")
|
||||
}
|
||||
|
||||
pid := p.GetString(":projectId")
|
||||
|
|
|
@ -14,6 +14,12 @@ const TaskApi = {
|
|||
method: 'get',
|
||||
})
|
||||
},
|
||||
getProjectTasksAndSubmits(pid) {
|
||||
return request({
|
||||
url: `/project/${pid}/tasks-submits`,
|
||||
method: 'get',
|
||||
})
|
||||
},
|
||||
createTask(pid, q) {
|
||||
return request({
|
||||
url: `/project/${pid}/task`,
|
||||
|
|
|
@ -151,7 +151,7 @@ function OutlineEditPage(obj) {
|
|||
sectionNumber: section.sectionNumber,
|
||||
chapterNumber: section.chapterNumber
|
||||
}
|
||||
SectionApi.updateChapterSection(s)
|
||||
SectionApi.updateChapterSection(pid, s)
|
||||
.then((res) => {
|
||||
if (res.data.code === 200) {
|
||||
chapters[index].sections[subIndex] = s
|
||||
|
|
|
@ -6,13 +6,14 @@ import 'echarts/lib/component/legend';
|
|||
import 'echarts/lib/component/markPoint';
|
||||
import ReactEcharts from 'echarts-for-react';
|
||||
import QueueAnim from 'rc-queue-anim';
|
||||
import {Button, Card, Col, Divider, InputNumber, Row, Table, message, Menu, Input} from "antd";
|
||||
import {Button, Card, Col, Divider, InputNumber, Row, Table, message, Menu, Input, List, Progress} from "antd";
|
||||
|
||||
import TaskApi from "../../../../api/TaskApi";
|
||||
import ProjectApi from "../../../../api/ProjectApi";
|
||||
import ChapterApi from "../../../../api/ChapterApi";
|
||||
import SectionApi from "../../../../api/SectionApi";
|
||||
|
||||
import "./index.less"
|
||||
|
||||
const {SubMenu} = Menu
|
||||
|
||||
|
@ -129,6 +130,8 @@ function ProjectEvaluation(obj) {
|
|||
setEditWeight(false)
|
||||
}
|
||||
const changeLearnMinute = (v, index, subIndex) => {
|
||||
console.log(index, subIndex)
|
||||
|
||||
chapters[index].sections[subIndex].sectionMinute = v
|
||||
setChapters([...chapters])
|
||||
}
|
||||
|
@ -210,8 +213,9 @@ function ProjectEvaluation(obj) {
|
|||
<div style={{textAlign: 'left', marginBottom: '30px'}} key="1">
|
||||
<ReactEcharts option={getOptions()}/>
|
||||
<div>
|
||||
<p style={{textAlign: 'center', fontWeight: 'bold', fontSize: '20px', marginTop: '20px'}}>
|
||||
章节学习时长</p>
|
||||
<Divider orientation="left">
|
||||
<p className="evidence-title">章节学习时长</p>
|
||||
</Divider>
|
||||
{!published ?
|
||||
<div style={{float: 'right'}}>
|
||||
{editMinute ?
|
||||
|
@ -226,7 +230,44 @@ function ProjectEvaluation(obj) {
|
|||
: null
|
||||
}
|
||||
</div>
|
||||
<Menu
|
||||
|
||||
|
||||
{chapters.map((item, index) => (
|
||||
<div key={index.toString()} style={{textAlign: 'left'}}>
|
||||
<p style={{fontWeight: 'bold', fontSize: '16px'}}>{item.chapterName}</p>
|
||||
{(item.sections === null || item.sections === undefined) ?
|
||||
null
|
||||
:
|
||||
<>
|
||||
<List
|
||||
size="large"
|
||||
dataSource={item.sections}
|
||||
renderItem={
|
||||
(item, subIndex) => (
|
||||
<List.Item>
|
||||
{item.sectionName}
|
||||
{editMinute ?
|
||||
<div style={{float: 'right'}}>
|
||||
学习时长不少于
|
||||
<InputNumber value={item.sectionMinute} onChange={v=>changeLearnMinute(v, index, subIndex)} min={0}/>
|
||||
分钟
|
||||
</div>
|
||||
:
|
||||
<div style={{float: 'right'}}>
|
||||
学习时长不少于 {item.sectionMinute} 分钟
|
||||
</div>
|
||||
}
|
||||
|
||||
</List.Item>
|
||||
)
|
||||
}
|
||||
/><br/>
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* <Menu
|
||||
style={{width: '100%'}}
|
||||
defaultSelectedKeys={['0']}
|
||||
mode="inline"
|
||||
|
@ -252,11 +293,14 @@ function ProjectEvaluation(obj) {
|
|||
}
|
||||
</SubMenu>
|
||||
))}
|
||||
</Menu>
|
||||
</Menu>*/}
|
||||
<div>
|
||||
<p style={{textAlign: 'center', fontWeight: 'bold', fontSize: '20px', marginTop: '20px'}}>
|
||||
权重占比
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<Divider orientation="left">
|
||||
<p className="evidence-title">权重占比</p>
|
||||
</Divider>
|
||||
{!published ?
|
||||
<div style={{float: 'right'}}>
|
||||
{editWeight ?
|
||||
|
|
|
@ -12,6 +12,9 @@ function ProjectOutline(obj) {
|
|||
const [chapters, setChapters] = useState([])
|
||||
|
||||
useEffect(() => {
|
||||
getChapters()
|
||||
}, [])
|
||||
const getChapters = () => {
|
||||
ChapterApi.getProjectChapters(pid)
|
||||
.then((res) => {
|
||||
if (res.data.chapters === null) {
|
||||
|
@ -21,7 +24,7 @@ function ProjectOutline(obj) {
|
|||
}
|
||||
})
|
||||
.catch(e=>{console.log(e)})
|
||||
}, [])
|
||||
}
|
||||
const gotoLearning = (item, subItem) => {
|
||||
window.open(`/project/${pid}/section/${subItem.id}/preview?back=/project/${pid}/info`)
|
||||
}
|
||||
|
|
|
@ -1,16 +1,35 @@
|
|||
import React, {useEffect, useState} from "react";
|
||||
import {InputNumber, Table} from "antd";
|
||||
import {Col, Collapse, Divider, List, Progress, Row, Table} from "antd";
|
||||
|
||||
import TaskApi from "../../../../api/TaskApi";
|
||||
import ChapterApi from "../../../../api/ChapterApi";
|
||||
|
||||
|
||||
function StudentEvidence(obj) {
|
||||
const pid = obj.project.id
|
||||
const [tasks, setTasks] = useState([])
|
||||
const [chapters, setChapters] = useState([])
|
||||
|
||||
useEffect(() => {
|
||||
getChapters()
|
||||
|
||||
getTasks()
|
||||
}, []);
|
||||
const getChapters = () => {
|
||||
ChapterApi.getProjectChapters(pid)
|
||||
.then((res) => {
|
||||
if (res.data.chapters === null) {
|
||||
setChapters([])
|
||||
} else {
|
||||
setChapters(res.data.chapters)
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
})
|
||||
}
|
||||
const getTasks = () => {
|
||||
TaskApi.getProjectTasks(pid)
|
||||
TaskApi.getProjectTasksAndSubmits(pid)
|
||||
.then(res => {
|
||||
if (res.data.code === 200) {
|
||||
if (res.data.data != null) {
|
||||
|
@ -18,7 +37,9 @@ function StudentEvidence(obj) {
|
|||
}
|
||||
}
|
||||
})
|
||||
.catch(e=>{console.log(e)})
|
||||
.catch(e => {
|
||||
console.log(e)
|
||||
})
|
||||
}
|
||||
const getColumns = () => {
|
||||
let c = [
|
||||
|
@ -59,7 +80,7 @@ function StudentEvidence(obj) {
|
|||
render: (text, item, index) => (
|
||||
<>
|
||||
{item.scored ?
|
||||
<span>已打分</span>
|
||||
<span style={{color: 'green'}}>已打分</span>
|
||||
:
|
||||
<span>未打分</span>
|
||||
}
|
||||
|
@ -74,6 +95,82 @@ function StudentEvidence(obj) {
|
|||
}
|
||||
return (
|
||||
<div>
|
||||
<Divider orientation="left">
|
||||
<p className="evidence-title">章节学习时长</p>
|
||||
</Divider>
|
||||
{chapters.map((item, index) => (
|
||||
<div key={index.toString()} style={{textAlign: 'left'}}>
|
||||
<p style={{fontWeight: 'bold', fontSize: '16px'}}>{item.chapterName}</p>
|
||||
{(item.sections === null || item.sections === undefined) ?
|
||||
null
|
||||
:
|
||||
<>
|
||||
<List
|
||||
size="large"
|
||||
dataSource={item.sections}
|
||||
renderItem={
|
||||
item => (
|
||||
<List.Item>
|
||||
{item.sectionName}
|
||||
{obj.project.learning ?
|
||||
<>
|
||||
<span style={{float: 'right'}}>
|
||||
<Progress
|
||||
trailColor="lightgray"
|
||||
width={30}
|
||||
strokeWidth={10}
|
||||
type="circle"
|
||||
percent={((item.learnMinute + item.learnSecond / 60) / item.sectionMinute * 100).toFixed(1)}
|
||||
/>
|
||||
</span>
|
||||
<span style={{float: 'right', marginRight: '20px'}}>
|
||||
学习进度:
|
||||
{item.learnMinute} : {item.learnSecond} /
|
||||
{item.sectionMinute}
|
||||
</span>
|
||||
</>
|
||||
: null}
|
||||
</List.Item>
|
||||
)
|
||||
}
|
||||
/><br/>
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
))}
|
||||
|
||||
<Divider orientation="left">
|
||||
<p className="evidence-title">学生任务</p>
|
||||
</Divider>
|
||||
|
||||
<Collapse style={{textAlign: 'left'}}>
|
||||
{tasks.map((item, index) => (
|
||||
<Collapse.Panel
|
||||
key={index.toString()}
|
||||
header={
|
||||
<>
|
||||
{item.taskTitle}
|
||||
<span style={{float: 'right', marginRight: '20px'}}>
|
||||
{item.scored ?
|
||||
<span style={{color: 'green'}}>已打分</span>
|
||||
:
|
||||
<span>未打分</span>
|
||||
}
|
||||
</span>
|
||||
<span style={{float: 'right', marginRight: '20px'}}>
|
||||
权重:{item.taskWeight}
|
||||
</span>
|
||||
<span style={{float: 'right', marginRight: '20px'}}>
|
||||
得分:{getScore(item.score, item.taskWeight)} / {item.taskWeight}
|
||||
</span>
|
||||
</>
|
||||
}
|
||||
>
|
||||
neironog
|
||||
</Collapse.Panel>
|
||||
))}
|
||||
</Collapse>
|
||||
|
||||
<Table
|
||||
columns={getColumns()}
|
||||
dataSource={tasks}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
.evidence-title{
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
margin-top: 20px
|
||||
}
|
|
@ -279,18 +279,18 @@ func init() {
|
|||
|
||||
beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"] = append(beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"],
|
||||
beego.ControllerComments{
|
||||
Method: "CreateSurvey",
|
||||
Method: "GetSurveyDetailByTaskId",
|
||||
Router: "/:projectId/task/:taskId/survey",
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"] = append(beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetSurveyDetailByTaskId",
|
||||
Method: "CreateSurvey",
|
||||
Router: "/:projectId/task/:taskId/survey",
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
@ -349,6 +349,15 @@ func init() {
|
|||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"] = append(beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetProjectTasksAndSubmits",
|
||||
Router: "/:projectId/tasks-submits",
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"] = append(beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"],
|
||||
beego.ControllerComments{
|
||||
Method: "ExchangeTask",
|
||||
|
|
Loading…
Reference in New Issue