diff --git a/controllers/task.go b/controllers/task.go index b82ea92..a6072f5 100644 --- a/controllers/task.go +++ b/controllers/task.go @@ -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 diff --git a/openpbl-landing/src/pages/Project/Evidence/component/StudentEvidence.jsx b/openpbl-landing/src/pages/Project/Evidence/component/StudentEvidence.jsx index aa29da4..f9f234a 100644 --- a/openpbl-landing/src/pages/Project/Evidence/component/StudentEvidence.jsx +++ b/openpbl-landing/src/pages/Project/Evidence/component/StudentEvidence.jsx @@ -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} /> diff --git a/openpbl-landing/src/pages/Project/PreviewProject/PreviewSection.jsx b/openpbl-landing/src/pages/Project/PreviewProject/PreviewSection.jsx index f698bad..4fc5758 100644 --- a/openpbl-landing/src/pages/Project/PreviewProject/PreviewSection.jsx +++ b/openpbl-landing/src/pages/Project/PreviewProject/PreviewSection.jsx @@ -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} /> diff --git a/openpbl-landing/src/pages/Project/PreviewProject/component/FillSurvey.jsx b/openpbl-landing/src/pages/Project/PreviewProject/component/FillSurvey.jsx index b75b1a3..3edff6f 100644 --- a/openpbl-landing/src/pages/Project/PreviewProject/component/FillSurvey.jsx +++ b/openpbl-landing/src/pages/Project/PreviewProject/component/FillSurvey.jsx @@ -168,35 +168,34 @@ function FillSurvey(obj) {
{subItem.questionTitle}
-{subItem.questionTitle}
+