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/models"
|
||||||
"OpenPBL/util"
|
"OpenPBL/util"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/casdoor/casdoor-go-sdk/auth"
|
"github.com/casdoor/casdoor-go-sdk/auth"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -90,8 +89,8 @@ func (p *ProjectController) CreateProject() {
|
||||||
uid := util.GetUserId(user)
|
uid := util.GetUserId(user)
|
||||||
project := &models.Project{
|
project := &models.Project{
|
||||||
TeacherId: uid,
|
TeacherId: uid,
|
||||||
|
LearnMinuteWeight: 100,
|
||||||
}
|
}
|
||||||
fmt.Println(project)
|
|
||||||
err := project.Create()
|
err := project.Create()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resp = Response{
|
resp = Response{
|
||||||
|
@ -538,4 +537,28 @@ func (p *ProjectController) GetProjectSubjectsAndSkills() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.ServeJSON()
|
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").
|
Distinct("skill").
|
||||||
Find(&skills)
|
Find(&skills)
|
||||||
return
|
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`,
|
url: `/project/${pid}/subjects-skills`,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
viewProject(pid) {
|
||||||
|
return request({
|
||||||
|
url: `/project/${pid}/view`,
|
||||||
|
method: 'post'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,11 @@ function SectionEditPage(obj) {
|
||||||
<FileResource section={section}/>
|
<FileResource section={section}/>
|
||||||
<StudentTask section={section} pid={pid}/>
|
<StudentTask section={section} pid={pid}/>
|
||||||
</div>
|
</div>
|
||||||
<Link to={`/project/${pid}/section/${sid}/preview?back=/project/${pid}/section/${sid}/edit`}>
|
<div style={{textAlign: 'center'}}>
|
||||||
<Button style={{marginBottom: '20px'}}>预览</Button>
|
<Link to={`/project/${pid}/section/${sid}/preview?back=/project/${pid}/section/${sid}/edit`}>
|
||||||
</Link>
|
<Button style={{marginBottom: '20px'}}>预览</Button>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DocumentTitle>
|
</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`
|
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)}
|
<Input.TextArea placeholder="任务描述" value={item.taskIntroduce} onChange={e => changeIntroduce(e, index)}
|
||||||
style={{marginTop: '20px'}}/>
|
style={{marginTop: '20px'}}/>
|
||||||
{item.taskType === 'survey' ?
|
{item.taskType === 'survey' ?
|
||||||
<Button style={{marginTop: '10px'}} onClick={e => gotoSurvey(item)}>查看问卷</Button>
|
<Button style={{marginTop: '10px'}} onClick={e => gotoSurvey(item, index)}>查看问卷</Button>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,16 @@ function ProjectList(obj) {
|
||||||
setSelectedSkills(selected)
|
setSelectedSkills(selected)
|
||||||
updateProjectList(page, size, selectedSubjects.toString(), selected.toString(), value)
|
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) => {
|
const onSearch = (v) => {
|
||||||
setValue(v)
|
setValue(v)
|
||||||
|
@ -176,10 +186,10 @@ function ProjectList(obj) {
|
||||||
{
|
{
|
||||||
learningProjectList.map((item, index) => (
|
learningProjectList.map((item, index) => (
|
||||||
<Col key={index.toString()} {...topColResponsiveProps}>
|
<Col key={index.toString()} {...topColResponsiveProps}>
|
||||||
<Link to={`/project/${item.id}/info`}>
|
|
||||||
<Card
|
<Card
|
||||||
hoverable
|
hoverable
|
||||||
bordered={false}
|
bordered={false}
|
||||||
|
onClick={e=>viewProject(item)}
|
||||||
style={{
|
style={{
|
||||||
borderRadius: '10px',
|
borderRadius: '10px',
|
||||||
}}
|
}}
|
||||||
|
@ -239,7 +249,6 @@ function ProjectList(obj) {
|
||||||
{util.FilterMoment(item.createAt)}
|
{util.FilterMoment(item.createAt)}
|
||||||
</span>
|
</span>
|
||||||
</Card>
|
</Card>
|
||||||
</Link>
|
|
||||||
</Col>
|
</Col>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue