diff --git a/controllers/task.go b/controllers/task.go
index 4d6b6c7..6b40085 100644
--- a/controllers/task.go
+++ b/controllers/task.go
@@ -16,9 +16,9 @@ func (p *ProjectController) GetSectionTasks() {
sid := p.GetString(":sid")
tasks, err := models.GetSectionTasks(sid)
if err != nil {
- p.Data["json"] = map[string][]models.Task{"tasks": nil}
+ p.Data["json"] = map[string][]models.TaskDetail{"tasks": nil}
} else {
- p.Data["json"] = map[string][]models.Task{"tasks": tasks}
+ p.Data["json"] = map[string][]models.TaskDetail{"tasks": tasks}
}
p.ServeJSON()
}
diff --git a/models/survey.go b/models/survey.go
index bc19e6b..ea91224 100644
--- a/models/survey.go
+++ b/models/survey.go
@@ -21,7 +21,7 @@ type Question struct {
QuestionCount string `json:"question" xorm:"text"`
}
type SurveyDetail struct {
- Survey `xorm:"extends"`
+ Survey `json:"survey" xorm:"extends"`
Questions []Question `json:"questions" xorm:"extends"`
}
diff --git a/models/task.go b/models/task.go
index f6432a3..9b67b5d 100644
--- a/models/task.go
+++ b/models/task.go
@@ -14,6 +14,12 @@ type Task struct {
TaskType string `json:"taskType" xorm:"index"`
}
+type TaskDetail struct {
+ Task `xorm:"extends"`
+ SurveyDetail `xorm:"extends"`
+
+}
+
func (t *Task) GetEngine() *xorm.Session {
return adapter.Engine.Table(t)
}
@@ -40,11 +46,26 @@ func (t *Task) Delete() (err error) {
return
}
-func GetSectionTasks(sid string) (t []Task, err error) {
+func GetSectionTasks(sid string) (t []TaskDetail, err error) {
err = (&Task{}).GetEngine().
Where("section_id = ?", sid).
Asc("task_order").
Find(&t)
+ var s Survey
+ var qs []Question
+ for i := 0; i < len(t); i ++ {
+ if t[i].TaskType == "survey" {
+ _, err = (&Survey{}).GetEngine().
+ Where("task_id = ?", t[i].Id).
+ Get(&s)
+ err = (&Question{}).GetEngine().
+ Where("survey_id = ?", s.Id).
+ Asc("question_order").
+ Find(&qs)
+ t[i].Survey = s
+ t[i].Questions = qs
+ }
+ }
return
}
diff --git a/openpbl-landing/package.json b/openpbl-landing/package.json
index d084c36..8839a1c 100644
--- a/openpbl-landing/package.json
+++ b/openpbl-landing/package.json
@@ -39,8 +39,9 @@
"web-vitals": "^1.0.1"
},
"scripts": {
+ "analyze": "source-map-explorer 'build/static/js/*.js'",
"start": "craco start",
- "build": "craco --max_old_space_size=2048 build",
+ "build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
diff --git a/openpbl-landing/src/pages/Project/CreateProject/PreviewResource.jsx b/openpbl-landing/src/pages/Project/CreateProject/PreviewResource.jsx
index c21a33f..a0f1d72 100644
--- a/openpbl-landing/src/pages/Project/CreateProject/PreviewResource.jsx
+++ b/openpbl-landing/src/pages/Project/CreateProject/PreviewResource.jsx
@@ -1,26 +1,72 @@
import React, {useEffect, useState} from "react";
-import {Card, PageHeader} from "antd";
+import {Card, PageHeader, Input, Upload, message, Button, Collapse, Spin, Radio, Divider} from "antd";
import DocumentTitle from 'react-document-title';
-
+import {InboxOutlined} from '@ant-design/icons'
import SectionApi from "../../../api/SectionApi";
import "./section-edit.less"
+import "./preview.less"
+import TaskApi from "../../../api/TaskApi";
+import FillSurvey from "./component/FillSurvey";
+
function PreviewResource(obj) {
const sid = obj.match.params.sid
const pid = obj.match.params.pid
const [section, setSection] = useState({resource:{}})
+ const [tasks, setTasks] = useState([])
+
useEffect(()=>{
+ getSectionResource()
+ getTasks()
+ }, [])
+ const getSectionResource = () => {
SectionApi.getSectionDetail(sid)
.then(res=>{
setSection(res.data.section)
})
.catch(e=>{console.log(e)})
- }, [])
-
+ }
+ const getTasks = () => {
+ TaskApi.getSectionTasks(sid)
+ .then(res=>{
+ if (res.data.tasks === null) {
+ setTasks([])
+ } else {
+ let t = res.data.tasks
+ for (let i = 0; i < t.length; i++) {
+ if (t[i].questions !== undefined && t[i].questions != null) {
+ for (let j = 0; j < t[i].questions.length; j++) {
+ t[i].questions[j].questionOptions = t[i].questions[j].questionOptions.split(",")
+ }
+ }
+ }
+ setTasks(t)
+ }
+ })
+ .catch(e=>{console.log(e)})
+ }
const back = e => {
window.location.href = '/project/edit/section/' + pid + '/' + sid
}
-
+ const props = {
+ name: 'file',
+ multiple: true,
+ action: '',
+ onChange(info) {
+ const { status } = info.file;
+ if (status !== 'uploading') {
+ console.log(info.file, info.fileList);
+ }
+ if (status === 'done') {
+ message.success(`${info.file.name} 上传成功`);
+ } else if (status === 'error') {
+ message.error(`${info.file.name} 上传失败`);
+ }
+ },
+ onDrop(e) {
+ console.log('Dropped files', e.dataTransfer.files);
+ },
+ };
return (
文件 文件资源 {section.resource.fileTitle} {section.resource.fileIntroduce} 学生任务 {section.resource.homeWorkTitle} {section.resource.homeWorkIntroduce} {item.taskTitle} {item.taskIntroduce}
+ 点击或拖动文件上传 hint
+ {section.sectionName}
{subItem.questionTitle}
+{subItem.questionTitle}
+ {subItem.questionOptions.map((optItem, optIndex) => ( +{subItem.questionTitle}
+ {subItem.questionOptions.map((optItem, optIndex) => ( +{subItem.questionOptions[0]}
+