fix: show count
This commit is contained in:
parent
a6ae24d066
commit
0aeeb57f37
|
@ -11,6 +11,7 @@ type TaskResponse struct {
|
|||
Learning bool `json:"learning"`
|
||||
Editable bool `json:"editable"`
|
||||
TeacherScore bool `json:"teacherScore"`
|
||||
ShowCount bool `json:"showCount"`
|
||||
}
|
||||
|
||||
// GetSectionTasksDetail
|
||||
|
@ -36,9 +37,13 @@ func (p *ProjectController) GetSectionTasksDetail() {
|
|||
p.ServeJSON()
|
||||
return
|
||||
}
|
||||
showCount := false
|
||||
if user.Tag != "student" {
|
||||
learning = false
|
||||
}
|
||||
if user.Tag == "teacher" {
|
||||
showCount = true
|
||||
}
|
||||
uid := user.Username
|
||||
pid := p.GetString(":projectId")
|
||||
learning = models.IsLearningProject(pid, uid)
|
||||
|
@ -60,6 +65,7 @@ func (p *ProjectController) GetSectionTasksDetail() {
|
|||
Tasks: tasks,
|
||||
Learning: learning,
|
||||
Editable: learning,
|
||||
ShowCount: showCount,
|
||||
}
|
||||
}
|
||||
p.ServeJSON()
|
||||
|
@ -75,11 +81,9 @@ func (p *ProjectController) GetSectionTasksDetail() {
|
|||
func (p *ProjectController) GetProjectTasks() {
|
||||
user := p.GetSessionUser()
|
||||
if user == nil {
|
||||
p.Data["json"] = TaskResponse{
|
||||
Response: Response{
|
||||
Code: 401,
|
||||
Msg: "请先登录",
|
||||
},
|
||||
p.Data["json"] = Response{
|
||||
Code: 401,
|
||||
Msg: "请先登录",
|
||||
}
|
||||
p.ServeJSON()
|
||||
return
|
||||
|
|
|
@ -14,6 +14,7 @@ function StudentEvidence(obj) {
|
|||
const [learning, setLearning] = useState(false)
|
||||
const [editable, setEditable] = useState(false)
|
||||
const [teacherScore, setTeacherScore] = useState(false)
|
||||
const [showCount, setShowCount] = useState(false)
|
||||
const [chapters, setChapters] = useState([])
|
||||
const [showMinute, setShowMinute] = useState(false)
|
||||
|
||||
|
@ -69,6 +70,7 @@ function StudentEvidence(obj) {
|
|||
setLearning(res.data.learning)
|
||||
setEditable(res.data.editable)
|
||||
setTeacherScore(res.data.teacherScore)
|
||||
setShowCount(res.data.showCount)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -205,6 +207,7 @@ function StudentEvidence(obj) {
|
|||
index={index}
|
||||
learning={learning}
|
||||
editable={editable}
|
||||
showCount={showCount}
|
||||
setTaskItem={setTaskItem}
|
||||
getTasks={getTasks}
|
||||
/>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import React, {useEffect, useState} from "react";
|
||||
import {Card, PageHeader, Input, Upload, message, Button, BackTop} from "antd";
|
||||
import DocumentTitle from 'react-document-title';
|
||||
import {InboxOutlined} from '@ant-design/icons'
|
||||
|
||||
import SectionApi from "../../../api/SectionApi";
|
||||
import "../CreateProject/Section/component/section-edit.less"
|
||||
|
@ -21,6 +20,7 @@ function PreviewSection(obj) {
|
|||
const [tasks, setTasks] = useState([])
|
||||
const [learning, setLearning] = useState(false)
|
||||
const [editable, setEditable] = useState(false)
|
||||
const [showCount, setShowCount] = useState(false)
|
||||
|
||||
const [minute, setMinute] = useState(0)
|
||||
const [second, setSecond] = useState(0)
|
||||
|
@ -33,8 +33,10 @@ function PreviewSection(obj) {
|
|||
getTasks()
|
||||
}, [])
|
||||
useEffect(()=>{
|
||||
window.onbeforeunload = leave
|
||||
}, [])
|
||||
if (learning) {
|
||||
window.onbeforeunload = leave
|
||||
}
|
||||
}, [learning])
|
||||
const leave = () => {
|
||||
if (timer != null) {
|
||||
clearTimeout(timer)
|
||||
|
@ -91,6 +93,7 @@ function PreviewSection(obj) {
|
|||
}
|
||||
setLearning(res.data.learning)
|
||||
setEditable(res.data.editable)
|
||||
setShowCount(res.data.showCount)
|
||||
|
||||
if (res.data.learning) {
|
||||
getTimer()
|
||||
|
@ -182,7 +185,7 @@ function PreviewSection(obj) {
|
|||
index={index}
|
||||
learning={learning}
|
||||
editable={editable}
|
||||
|
||||
showCount={showCount}
|
||||
setTaskItem={setTaskItem}
|
||||
getTasks={getTasks}
|
||||
/>
|
||||
|
|
|
@ -168,35 +168,34 @@ function FillSurvey(obj) {
|
|||
</div>
|
||||
<div style={{textAlign: 'right', marginTop: '10px'}}>
|
||||
{obj.item.submitted ?
|
||||
<>
|
||||
<Button disabled={!obj.editable} type="primary" onClick={updateSurvey} loading={submitLoading}>
|
||||
更新
|
||||
</Button>
|
||||
<div style={{textAlign: 'left', marginTop: '20px'}}>
|
||||
<Collapse onChange={showCount}>
|
||||
<Collapse.Panel key={1} header="查看统计结果">
|
||||
{obj.item.questions.map((subItem, subIndex)=>(
|
||||
<div key={subIndex.toString()}>
|
||||
{subItem.questionType==='singleChoice' || subItem.questionType==='multipleChoice'
|
||||
|| subItem.questionType==='scale5' || subItem.questionType==='scale7' ?
|
||||
<div style={{textAlign: "left", marginTop: '10px'}}>
|
||||
<p>{subItem.questionTitle}</p>
|
||||
<ReactEcharts option={getOption(subIndex)}/>
|
||||
<Divider />
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
</div>
|
||||
))}
|
||||
</Collapse.Panel>
|
||||
</Collapse>
|
||||
</div>
|
||||
</>
|
||||
<Button disabled={!obj.editable} type="primary" onClick={updateSurvey} loading={submitLoading}>更新</Button>
|
||||
:
|
||||
<Button disabled={!obj.editable} type="primary" onClick={submitSurvey} loading={submitLoading}>提交</Button>
|
||||
}
|
||||
</div>
|
||||
{obj.showCount || obj.item.submitted ?
|
||||
<div style={{textAlign: 'left', marginTop: '20px'}}>
|
||||
<Collapse onChange={showCount}>
|
||||
<Collapse.Panel key={1} header="查看统计结果">
|
||||
{obj.item.questions.map((subItem, subIndex)=>(
|
||||
<div key={subIndex.toString()}>
|
||||
{subItem.questionType==='singleChoice' || subItem.questionType==='multipleChoice'
|
||||
|| subItem.questionType==='scale5' || subItem.questionType==='scale7' ?
|
||||
<div style={{textAlign: "left", marginTop: '10px'}}>
|
||||
<p>{subItem.questionTitle}</p>
|
||||
<ReactEcharts option={getOption(subIndex)}/>
|
||||
<Divider />
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
</div>
|
||||
))}
|
||||
</Collapse.Panel>
|
||||
</Collapse>
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ function TaskCard(obj) {
|
|||
getTasks={obj.getTasks}
|
||||
learning={obj.learning}
|
||||
editable={obj.editable}
|
||||
showCount={obj.showCount}
|
||||
setTaskItem={obj.setTaskItem}
|
||||
/>
|
||||
: null
|
||||
|
|
|
@ -45,18 +45,18 @@ func init() {
|
|||
|
||||
beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"] = append(beego.GlobalControllerRouter["OpenPBL/controllers:ProjectController"],
|
||||
beego.ControllerComments{
|
||||
Method: "UpdateProject",
|
||||
Method: "GetProjectDetail",
|
||||
Router: "/:id",
|
||||
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: "GetProjectDetail",
|
||||
Method: "UpdateProject",
|
||||
Router: "/:id",
|
||||
AllowHTTPMethods: []string{"get"},
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
|
Loading…
Reference in New Issue