forked from Open-CT/OpenPBL
feat: add project view num
This commit is contained in:
parent
aa1aee2fc9
commit
73c7e91891
|
@ -4,7 +4,6 @@ import (
|
|||
"OpenPBL/models"
|
||||
"OpenPBL/util"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/casdoor/casdoor-go-sdk/auth"
|
||||
"strings"
|
||||
|
@ -90,8 +89,8 @@ func (p *ProjectController) CreateProject() {
|
|||
uid := util.GetUserId(user)
|
||||
project := &models.Project{
|
||||
TeacherId: uid,
|
||||
LearnMinuteWeight: 100,
|
||||
}
|
||||
fmt.Println(project)
|
||||
err := project.Create()
|
||||
if err != nil {
|
||||
resp = Response{
|
||||
|
@ -538,4 +537,28 @@ func (p *ProjectController) GetProjectSubjectsAndSkills() {
|
|||
}
|
||||
}
|
||||
p.ServeJSON()
|
||||
}
|
||||
|
||||
// ViewProject
|
||||
// @Title
|
||||
// @Description create project
|
||||
// @Success 200 {object} Response
|
||||
// @Failure 401
|
||||
// @Failure 400
|
||||
// @Failure 403
|
||||
// @router /:id/view [post]
|
||||
func (p *ProjectController) ViewProject() {
|
||||
pid := p.GetString(":id")
|
||||
err := models.ViewProject(pid)
|
||||
if err != nil {
|
||||
p.Data["json"] = Response{
|
||||
Code: 400,
|
||||
Msg: err.Error(),
|
||||
}
|
||||
} else {
|
||||
p.Data["json"] = Response{
|
||||
Code: 200,
|
||||
}
|
||||
}
|
||||
p.ServeJSON()
|
||||
}
|
|
@ -224,4 +224,10 @@ func GetSkills() (skills []string, err error) {
|
|||
Distinct("skill").
|
||||
Find(&skills)
|
||||
return
|
||||
}
|
||||
|
||||
func ViewProject(pid string) (err error) {
|
||||
_, err = adapter.Engine.
|
||||
Exec("update project set read_num = read_num + 1 where id = ?", pid)
|
||||
return
|
||||
}
|
|
@ -91,6 +91,12 @@ const ProjectApi = {
|
|||
url: `/project/${pid}/subjects-skills`,
|
||||
method: 'get'
|
||||
})
|
||||
},
|
||||
viewProject(pid) {
|
||||
return request({
|
||||
url: `/project/${pid}/view`,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,11 @@ function SectionEditPage(obj) {
|
|||
<FileResource section={section}/>
|
||||
<StudentTask section={section} pid={pid}/>
|
||||
</div>
|
||||
<Link to={`/project/${pid}/section/${sid}/preview?back=/project/${pid}/section/${sid}/edit`}>
|
||||
<Button style={{marginBottom: '20px'}}>预览</Button>
|
||||
</Link>
|
||||
<div style={{textAlign: 'center'}}>
|
||||
<Link to={`/project/${pid}/section/${sid}/preview?back=/project/${pid}/section/${sid}/edit`}>
|
||||
<Button style={{marginBottom: '20px'}}>预览</Button>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</DocumentTitle>
|
||||
)
|
||||
|
|
|
@ -100,7 +100,8 @@ function StudentTask(obj) {
|
|||
})
|
||||
}
|
||||
}
|
||||
const gotoSurvey = item => {
|
||||
const gotoSurvey = (item, index) => {
|
||||
saveContent(item, index)
|
||||
window.location.href = `/project/${pid}/section/${obj.section.id}/task/${item.id}/survey/edit`
|
||||
}
|
||||
|
||||
|
@ -129,7 +130,7 @@ function StudentTask(obj) {
|
|||
<Input.TextArea placeholder="任务描述" value={item.taskIntroduce} onChange={e => changeIntroduce(e, index)}
|
||||
style={{marginTop: '20px'}}/>
|
||||
{item.taskType === 'survey' ?
|
||||
<Button style={{marginTop: '10px'}} onClick={e => gotoSurvey(item)}>查看问卷</Button>
|
||||
<Button style={{marginTop: '10px'}} onClick={e => gotoSurvey(item, index)}>查看问卷</Button>
|
||||
: null
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,16 @@ function ProjectList(obj) {
|
|||
setSelectedSkills(selected)
|
||||
updateProjectList(page, size, selectedSubjects.toString(), selected.toString(), value)
|
||||
}
|
||||
const viewProject = (item) => {
|
||||
if (item.published && !item.closed) {
|
||||
ProjectApi.viewProject(item.id)
|
||||
.then(res => {
|
||||
})
|
||||
.catch(e => {
|
||||
})
|
||||
}
|
||||
window.location.href = `/project/${item.id}/info`
|
||||
}
|
||||
|
||||
const onSearch = (v) => {
|
||||
setValue(v)
|
||||
|
@ -176,10 +186,10 @@ function ProjectList(obj) {
|
|||
{
|
||||
learningProjectList.map((item, index) => (
|
||||
<Col key={index.toString()} {...topColResponsiveProps}>
|
||||
<Link to={`/project/${item.id}/info`}>
|
||||
<Card
|
||||
hoverable
|
||||
bordered={false}
|
||||
onClick={e=>viewProject(item)}
|
||||
style={{
|
||||
borderRadius: '10px',
|
||||
}}
|
||||
|
@ -239,7 +249,6 @@ function ProjectList(obj) {
|
|||
{util.FilterMoment(item.createAt)}
|
||||
</span>
|
||||
</Card>
|
||||
</Link>
|
||||
</Col>
|
||||
))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue