diff --git a/.env b/.env index 03769e3..b3d5b98 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ #TARO_APP_API=http://192.168.1.19:9898 TARO_APP_API=https://yjx.dev.yaojiankang.top +#TARO_APP_API=https://playedu.yaojiankang.top diff --git a/src/api/curriculum.ts b/src/api/curriculum.ts index c53fa3c..e780da9 100644 --- a/src/api/curriculum.ts +++ b/src/api/curriculum.ts @@ -12,7 +12,7 @@ export interface CourseDepData { hours: Hours /** 是否必修 */ is_required: boolean - learn_hour_records: LearnHourRecords + learn_hour_records: LearnHourRecords[] learn_record: LearnRecord | null } @@ -29,6 +29,7 @@ export interface HourPlayData { } /** 断点 */ timeList: number[] + hour_test?: { id: number } } export interface Course { @@ -39,14 +40,25 @@ export interface Course { } interface AnswerRecord { + question_id: number + question_type: number is_pass: boolean user_id: number - question_position: number + time: number +} + +interface RecordTextParam { + is_pass: boolean; + test_id: number; + /** true true false 拼成的string */ + test_info: string; + test_score: number; + user_id: number; } export const curriculum = { - use() { - return request('/api/v1/user/all', 'GET') + department() { + return request<{data: Manage[] }>('/api/v1/department/index', 'GET') }, /** 学习记录 */ record(id: number) { @@ -72,10 +84,18 @@ export const curriculum = { curEnd(courseId: number, id: number, duration: number) { return request(`/api/v1/course/${courseId}/hour/${id}/record`, "POST", {duration}) }, - categoryCur(categoryId: number, companyId: number, type: string) { - return request(`/api/v1/category/${categoryId}/${companyId}/${type}`, "GET") + answerRecord(hourId: number, data: AnswerRecord) { + return request<{ time: number }>(`/api/v1/test/video/record/${hourId}`, "POST", data) + }, + /** 获取考卷 */ + getText(testId: string) { + return request>(`/api/v1/test/bank/create/${testId}`, "GET") + }, + /** 考卷记录 */ + recordText(hourId: number, data: RecordTextParam) { + return request(`/api/v1/test/record/${hourId}`, 'POST', data) }, - answerRecord(id: number, data: AnswerRecord) { - return request<{ time: number }>(`/api/v1/test/video/record/${id}`, "POST", data) + putRecordText(hour_id: number, is_pass: boolean) { + return request(`/api/v1/test/record/${hour_id}`, "PUT", {is_pass}) } } diff --git a/src/api/manage.ts b/src/api/manage.ts index b84a4fd..398e06a 100644 --- a/src/api/manage.ts +++ b/src/api/manage.ts @@ -23,7 +23,6 @@ interface setRoleTypeData { role_type: number } -type DepList = Record export interface AddDepProps { id?: number | null @@ -64,6 +63,11 @@ export interface CurLearningRecord { total: number } +interface DepListData { + data: User[] + department: Manage[] +} + export const ManageApi = { /** 添加学员 */ @@ -84,8 +88,8 @@ export const ManageApi = { return request(`/api/v1/user/${id}`, "PUT", data) }, /** 部门 */ - depList() { - return request('/api/v1/department/index', "GET") + depList(dep_id: number | string) { + return request('/api/v1/department/index?dep_id=' + dep_id, "GET") }, addDep(data: AddDepProps) { return request('/api/v1/department/save', "POST", data) diff --git a/src/api/public.ts b/src/api/public.ts index 4e85c47..8337e6d 100644 --- a/src/api/public.ts +++ b/src/api/public.ts @@ -22,17 +22,11 @@ export interface Courses { /** 必修 */ is_required: Curriculum[] /** 总时长 */ - total_course_duration: number + total_course_duration?: number } export type CoursesKey = keyof Omit -export type Cur = Category & { - courses: Courses - name: string - resourceCategory?: Cur[] -} - export const publicApi = { /** 分类 */ @@ -40,7 +34,7 @@ export const publicApi = { return request('/api/v1/category/all', "GET") }, /** 课程 */ - curs() { - return request('/api/v1/category/index', "GET") + course(data: { page: number, pageSize: number }) { + return request('/api/v1/category/course/index', "GET", data) } } diff --git a/src/app.config.ts b/src/app.config.ts index 9243d8f..51a9fff 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -40,17 +40,15 @@ export default defineAppConfig({ { root: 'pages/business', pages: [ - // 'course/course', 'userInfo/userInfo', 'videoInfo/videoInfo', - 'categoryCur/categoryCur' + 'test/test', ] }, { root: 'pages/manage', pages: [ 'depAdmin/depAdmin', - 'studentAdmin/studentAdmin', 'college/college', 'curriculum/curriculum', 'addStudent/addStudent', diff --git a/src/pages/business/videoInfo/components/judge.tsx b/src/components/topic/judge.tsx similarity index 69% rename from src/pages/business/videoInfo/components/judge.tsx rename to src/components/topic/judge.tsx index 29407ed..47337dc 100644 --- a/src/pages/business/videoInfo/components/judge.tsx +++ b/src/components/topic/judge.tsx @@ -1,16 +1,17 @@ import {FC, useEffect, useState} from "react"; import {Button, Radio, RadioGroup, Text, View} from "@tarojs/components"; +import './topic.scss' interface Props { data: ShareSubject onAnswer: (isAnswer: boolean) => void - onUpAndDown: (index: number) => void + onUpAndDown?: (index: number) => void index: number validate: boolean - frequency:number + frequency?: number } -const Judge: FC = ({data, onAnswer, onUpAndDown, index, validate,frequency}) => { +const Judge: FC = ({data, onAnswer, onUpAndDown, index, validate, frequency}) => { const [rightAnswer, setRightAnswer] = useState(null) //答案 const rightKey = data.right_answer ? 'correct' : 'error' // 正确答案数组 const [error, setError] = useState(false) @@ -31,7 +32,19 @@ const Judge: FC = ({data, onAnswer, onUpAndDown, index, validate,frequenc return ( + + 判断题 {data.question} @@ -39,26 +52,27 @@ const Judge: FC = ({data, onAnswer, onUpAndDown, index, validate,frequenc 正确 错误 - + {onUpAndDown && {index > 0 && } - + } + - {error && frequency === 0 && + {error && frequency == 0 && 错误答案解析 {data.analysis} } diff --git a/src/pages/business/videoInfo/components/multi.tsx b/src/components/topic/multi.tsx similarity index 74% rename from src/pages/business/videoInfo/components/multi.tsx rename to src/components/topic/multi.tsx index bee1a49..0f2a3cc 100644 --- a/src/pages/business/videoInfo/components/multi.tsx +++ b/src/components/topic/multi.tsx @@ -1,16 +1,17 @@ import {FC, useEffect, useState} from "react"; import {Button, Checkbox, CheckboxGroup, Radio, RadioGroup, Text, View} from "@tarojs/components"; +import './topic.scss' interface Props { data: Multi onAnswer: (isAnswer: boolean) => void - onUpAndDown: (index: number) => void + onUpAndDown?: (index: number) => void index: number validate: boolean - frequency:number + frequency?: number } -const Multi: FC = ({data, onAnswer, onUpAndDown, index, validate,frequency}) => { +const Multi: FC = ({data, onAnswer, onUpAndDown, index, validate, frequency}) => { const [rightAnswer, setRightAnswer] = useState([]) //答案 const rightKey = data?.right_answer?.split(',') || [] // 正确答案数组 @@ -43,11 +44,22 @@ const Multi: FC = ({data, onAnswer, onUpAndDown, index, validate,frequenc return ( + {data.type ? "多选题" : '单选题'} {data.question} - {!data.type ? + {data.type ? {answers.map(d => = ({data, onAnswer, onUpAndDown, index, validate,frequenc } - - {index > 0 && } - - - + {onUpAndDown && + {index > 0 && } + + } {error && frequency == 0 && diff --git a/src/pages/business/videoInfo/components/shortAnswer.tsx b/src/components/topic/shortAnswer.tsx similarity index 65% rename from src/pages/business/videoInfo/components/shortAnswer.tsx rename to src/components/topic/shortAnswer.tsx index 57172d4..2f817ba 100644 --- a/src/pages/business/videoInfo/components/shortAnswer.tsx +++ b/src/components/topic/shortAnswer.tsx @@ -1,14 +1,15 @@ import {Button, Text, Textarea, View} from "@tarojs/components"; import {FC, useEffect, useState} from "react"; import Taro from "@tarojs/taro"; +import './topic.scss' interface Props { data: ShareSubject onAnswer: (isAnswer: boolean) => void - onUpAndDown: (index: number) => void + onUpAndDown?: (index: number) => void index: number validate: boolean - frequency: number + frequency?: number } const ShortAnswer: FC = ({data, onAnswer, onUpAndDown, index, validate, frequency}) => { @@ -33,6 +34,17 @@ const ShortAnswer: FC = ({data, onAnswer, onUpAndDown, index, validate, f return ( + 简答题 {data.question}