Skip to content

Commit

Permalink
feat: paper submission function
Browse files Browse the repository at this point in the history
  • Loading branch information
webyang-male committed Nov 18, 2022
1 parent 8625807 commit 7d44f25
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 99 deletions.
40 changes: 20 additions & 20 deletions .nuxt/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ declare module 'vue' {
'PlayerAudio': typeof import("../components/Player/Audio.vue")['default'],
'PlayerLive': typeof import("../components/Player/Live.vue")['default'],
'PlayerVideo': typeof import("../components/Player/Video.vue")['default'],
'UiImage': typeof import("../components/Ui/Image.vue")['default'],
'UiMenu': typeof import("../components/Ui/Menu.vue")['default'],
'UiMenuItem': typeof import("../components/Ui/MenuItem.vue")['default'],
'UiTab': typeof import("../components/Ui/Tab.vue")['default'],
'UiTabItem': typeof import("../components/Ui/TabItem.vue")['default'],
'UserBuyList': typeof import("../components/User/BuyList.vue")['default'],
'UserCouponList': typeof import("../components/User/CouponList.vue")['default'],
'UserFavaList': typeof import("../components/User/FavaList.vue")['default'],
'UserHistoryList': typeof import("../components/User/HistoryList.vue")['default'],
'UserTestList': typeof import("../components/User/TestList.vue")['default'],
'UiImage': typeof import("../components/Ui/Image.vue")['default'],
'UiMenu': typeof import("../components/Ui/Menu.vue")['default'],
'UiMenuItem': typeof import("../components/Ui/MenuItem.vue")['default'],
'UiTab': typeof import("../components/Ui/Tab.vue")['default'],
'UiTabItem': typeof import("../components/Ui/TabItem.vue")['default'],
'UiCardBody': typeof import("../components/Ui/Card/Body.vue")['default'],
'UiCardFooter': typeof import("../components/Ui/Card/Footer.vue")['default'],
'UiCardHeader': typeof import("../components/Ui/Card/Header.vue")['default'],
Expand Down Expand Up @@ -94,16 +94,16 @@ declare module 'vue' {
'LazyPlayerAudio': typeof import("../components/Player/Audio.vue")['default'],
'LazyPlayerLive': typeof import("../components/Player/Live.vue")['default'],
'LazyPlayerVideo': typeof import("../components/Player/Video.vue")['default'],
'LazyUiImage': typeof import("../components/Ui/Image.vue")['default'],
'LazyUiMenu': typeof import("../components/Ui/Menu.vue")['default'],
'LazyUiMenuItem': typeof import("../components/Ui/MenuItem.vue")['default'],
'LazyUiTab': typeof import("../components/Ui/Tab.vue")['default'],
'LazyUiTabItem': typeof import("../components/Ui/TabItem.vue")['default'],
'LazyUserBuyList': typeof import("../components/User/BuyList.vue")['default'],
'LazyUserCouponList': typeof import("../components/User/CouponList.vue")['default'],
'LazyUserFavaList': typeof import("../components/User/FavaList.vue")['default'],
'LazyUserHistoryList': typeof import("../components/User/HistoryList.vue")['default'],
'LazyUserTestList': typeof import("../components/User/TestList.vue")['default'],
'LazyUiImage': typeof import("../components/Ui/Image.vue")['default'],
'LazyUiMenu': typeof import("../components/Ui/Menu.vue")['default'],
'LazyUiMenuItem': typeof import("../components/Ui/MenuItem.vue")['default'],
'LazyUiTab': typeof import("../components/Ui/Tab.vue")['default'],
'LazyUiTabItem': typeof import("../components/Ui/TabItem.vue")['default'],
'LazyUiCardBody': typeof import("../components/Ui/Card/Body.vue")['default'],
'LazyUiCardFooter': typeof import("../components/Ui/Card/Footer.vue")['default'],
'LazyUiCardHeader': typeof import("../components/Ui/Card/Header.vue")['default'],
Expand Down Expand Up @@ -153,16 +153,16 @@ export const LoadingSkeleton: typeof import("../components/Loading/Skeleton.vue"
export const PlayerAudio: typeof import("../components/Player/Audio.vue")['default']
export const PlayerLive: typeof import("../components/Player/Live.vue")['default']
export const PlayerVideo: typeof import("../components/Player/Video.vue")['default']
export const UiImage: typeof import("../components/Ui/Image.vue")['default']
export const UiMenu: typeof import("../components/Ui/Menu.vue")['default']
export const UiMenuItem: typeof import("../components/Ui/MenuItem.vue")['default']
export const UiTab: typeof import("../components/Ui/Tab.vue")['default']
export const UiTabItem: typeof import("../components/Ui/TabItem.vue")['default']
export const UserBuyList: typeof import("../components/User/BuyList.vue")['default']
export const UserCouponList: typeof import("../components/User/CouponList.vue")['default']
export const UserFavaList: typeof import("../components/User/FavaList.vue")['default']
export const UserHistoryList: typeof import("../components/User/HistoryList.vue")['default']
export const UserTestList: typeof import("../components/User/TestList.vue")['default']
export const UiImage: typeof import("../components/Ui/Image.vue")['default']
export const UiMenu: typeof import("../components/Ui/Menu.vue")['default']
export const UiMenuItem: typeof import("../components/Ui/MenuItem.vue")['default']
export const UiTab: typeof import("../components/Ui/Tab.vue")['default']
export const UiTabItem: typeof import("../components/Ui/TabItem.vue")['default']
export const UiCardBody: typeof import("../components/Ui/Card/Body.vue")['default']
export const UiCardFooter: typeof import("../components/Ui/Card/Footer.vue")['default']
export const UiCardHeader: typeof import("../components/Ui/Card/Header.vue")['default']
Expand Down Expand Up @@ -210,16 +210,16 @@ export const LazyLoadingSkeleton: typeof import("../components/Loading/Skeleton.
export const LazyPlayerAudio: typeof import("../components/Player/Audio.vue")['default']
export const LazyPlayerLive: typeof import("../components/Player/Live.vue")['default']
export const LazyPlayerVideo: typeof import("../components/Player/Video.vue")['default']
export const LazyUiImage: typeof import("../components/Ui/Image.vue")['default']
export const LazyUiMenu: typeof import("../components/Ui/Menu.vue")['default']
export const LazyUiMenuItem: typeof import("../components/Ui/MenuItem.vue")['default']
export const LazyUiTab: typeof import("../components/Ui/Tab.vue")['default']
export const LazyUiTabItem: typeof import("../components/Ui/TabItem.vue")['default']
export const LazyUserBuyList: typeof import("../components/User/BuyList.vue")['default']
export const LazyUserCouponList: typeof import("../components/User/CouponList.vue")['default']
export const LazyUserFavaList: typeof import("../components/User/FavaList.vue")['default']
export const LazyUserHistoryList: typeof import("../components/User/HistoryList.vue")['default']
export const LazyUserTestList: typeof import("../components/User/TestList.vue")['default']
export const LazyUiImage: typeof import("../components/Ui/Image.vue")['default']
export const LazyUiMenu: typeof import("../components/Ui/Menu.vue")['default']
export const LazyUiMenuItem: typeof import("../components/Ui/MenuItem.vue")['default']
export const LazyUiTab: typeof import("../components/Ui/Tab.vue")['default']
export const LazyUiTabItem: typeof import("../components/Ui/TabItem.vue")['default']
export const LazyUiCardBody: typeof import("../components/Ui/Card/Body.vue")['default']
export const LazyUiCardFooter: typeof import("../components/Ui/Card/Footer.vue")['default']
export const LazyUiCardHeader: typeof import("../components/Ui/Card/Header.vue")['default']
Expand Down
7 changes: 4 additions & 3 deletions .nuxt/imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ export { useHead, useMeta } from '#head';
export { isVue2, isVue3 } from 'vue-demi';
export { useAsyncData, useLazyAsyncData, refreshNuxtData, defineNuxtComponent, useNuxtApp, defineNuxtPlugin, useRuntimeConfig, useState, useFetch, useLazyFetch, useCookie, useRequestHeaders, useRequestEvent, useRouter, useRoute, useActiveRoute, defineNuxtRouteMiddleware, navigateTo, abortNavigation, addRouteMiddleware, throwError, clearError, useError, defineNuxtLink } from '#app';
export { withCtx, withDirectives, withKeys, withMemo, withModifiers, withScopeId, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, computed, customRef, isProxy, isReactive, isReadonly, isRef, markRaw, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, watch, watchEffect, isShallow, effect, effectScope, getCurrentScope, onScopeDispose, defineComponent, defineAsyncComponent, resolveComponent, getCurrentInstance, h, inject, nextTick, provide, useAttrs, useCssModule, useCssVars, useSlots, useTransitionState } from 'vue';
export { useUser, useRefreshUserInfo, useLogout, useHasAuth, useHandleSupportPost } from 'E:/WebProject/nuxt3-edu/composables/useAuth';
export { usePostSupportApi, useDeletePostApi } from 'E:/WebProject/nuxt3-edu/apis/bbs';
export { fetchConfig, useHttp, useHttpGet, useHttpPost } from 'E:/WebProject/nuxt3-edu/composables/useHttp';
export { useUser, useRefreshUserInfo, useLogout, useHasAuth, useHandleSupportPost } from 'E:/WebProject/nuxt3-edu/composables/useAuth';
export { usePage } from 'E:/WebProject/nuxt3-edu/composables/usePage';
export { useQueryToString, useEnterEvent, useTimeStatus } from 'E:/WebProject/nuxt3-edu/composables/useUtil';
export { usePostSupportApi, useDeletePostApi } from 'E:/WebProject/nuxt3-edu/apis/bbs';
export { useSearchListApi, useCouponListApi, useListApi, useReadDetailApi } from 'E:/WebProject/nuxt3-edu/apis/common';
export { usecourseListApi, useReadCourseApi, useHotCourseListApi, useLearnApi } from 'E:/WebProject/nuxt3-edu/apis/course';
export { useBookMenusApi, useBookDetailApi } from 'E:/WebProject/nuxt3-edu/apis/book';
export { useSubmitTestApi, useReadTestPaperApi } from 'E:/WebProject/nuxt3-edu/apis/test';
export { useGetGoodsInfoApi, useGetUseableUserCouponApi, useCreateOrderApi, useWxpayApi, useGetWxpayStatusApi, useGetGroupWorkListApi } from 'E:/WebProject/nuxt3-edu/apis/order';
export { usecourseListApi, useReadCourseApi, useHotCourseListApi, useLearnApi } from 'E:/WebProject/nuxt3-edu/apis/course';
export { useIndexDataApi, useGroupDataApi } from 'E:/WebProject/nuxt3-edu/apis/index';
export { useLoginApi, useGetinfoApi, useRegApi, useLogoutApi, useGetCaptchaApi, useBindPhoneApi, useForgetApi, useUserHistoryApi, useOrderListApi, useUserTestApi, useMypostListApi, useUserCouponApi, useMyFavaListApi, useUncollectApi, useUpdateUserInfoApi, useUploadConfig, useUpdatePasswordApi, useCollectApi, useReceiveUserCouponApi } from 'E:/WebProject/nuxt3-edu/apis/user';
export { definePageMeta } from 'E:/WebProject/nuxt3-edu/node_modules/nuxt/dist/pages/runtime/composables';
Expand Down
4 changes: 4 additions & 0 deletions .nuxt/types/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ declare global {
const useQueryToString: typeof import('../../composables/useUtil')['useQueryToString']
const useReadCourseApi: typeof import('../../apis/course')['useReadCourseApi']
const useReadDetailApi: typeof import('../../apis/common')['useReadDetailApi']
const useReadTestPaperApi: typeof import('../../apis/test')['useReadTestPaperApi']
const useReceiveUserCouponApi: typeof import('../../apis/user')['useReceiveUserCouponApi']
const useRefreshUserInfo: typeof import('../../composables/useAuth')['useRefreshUserInfo']
const useRegApi: typeof import('../../apis/user')['useRegApi']
Expand All @@ -120,6 +121,7 @@ declare global {
const useSearchListApi: typeof import('../../apis/common')['useSearchListApi']
const useSlots: typeof import('vue')['useSlots']
const useState: typeof import('../../node_modules/nuxt/dist/app')['useState']
const useSubmitTestApi: typeof import('../../apis/test')['useSubmitTestApi']
const useTimeStatus: typeof import('../../composables/useUtil')['useTimeStatus']
const useTransitionState: typeof import('vue')['useTransitionState']
const useUncollectApi: typeof import('../../apis/user')['useUncollectApi']
Expand Down Expand Up @@ -253,6 +255,7 @@ declare module '@vue/runtime-core' {
readonly useQueryToString: UnwrapRef<typeof import('../../composables/useUtil')['useQueryToString']>
readonly useReadCourseApi: UnwrapRef<typeof import('../../apis/course')['useReadCourseApi']>
readonly useReadDetailApi: UnwrapRef<typeof import('../../apis/common')['useReadDetailApi']>
readonly useReadTestPaperApi: UnwrapRef<typeof import('../../apis/test')['useReadTestPaperApi']>
readonly useReceiveUserCouponApi: UnwrapRef<typeof import('../../apis/user')['useReceiveUserCouponApi']>
readonly useRefreshUserInfo: UnwrapRef<typeof import('../../composables/useAuth')['useRefreshUserInfo']>
readonly useRegApi: UnwrapRef<typeof import('../../apis/user')['useRegApi']>
Expand All @@ -264,6 +267,7 @@ declare module '@vue/runtime-core' {
readonly useSearchListApi: UnwrapRef<typeof import('../../apis/common')['useSearchListApi']>
readonly useSlots: UnwrapRef<typeof import('vue')['useSlots']>
readonly useState: UnwrapRef<typeof import('../../node_modules/nuxt/dist/app')['useState']>
readonly useSubmitTestApi: UnwrapRef<typeof import('../../apis/test')['useSubmitTestApi']>
readonly useTimeStatus: UnwrapRef<typeof import('../../composables/useUtil')['useTimeStatus']>
readonly useTransitionState: UnwrapRef<typeof import('vue')['useTransitionState']>
readonly useUncollectApi: UnwrapRef<typeof import('../../apis/user')['useUncollectApi']>
Expand Down
11 changes: 11 additions & 0 deletions apis/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//交卷 /pc/user_test/save
export function useSubmitTestApi(body) {
return useHttpPost("SubmitTest", "user_test/save", {
body,
});
}

//开始考试 /pc/testpaper/read?id=12
export function useReadTestPaperApi(id) {
return useHttpPost("ReadTestPaper", "/testpaper/read?id="+id);
}
113 changes: 37 additions & 76 deletions pages/paper_test/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</n-grid>
<n-divider />
<div>
<n-button type="primary" class="w-full">交 卷</n-button>
<n-button type="primary" class="w-full" @click="submit()" :loading="loading">交 卷</n-button>
</div>
</n-card>
</n-grid-item>
Expand All @@ -54,81 +54,11 @@ import {
createDiscreteApi
} from "naive-ui"
const data = ref({
"id": 12,
"title": "测试试卷111",
"total_score": 100,
"pass_score": 60,
"expire": 60,
"testpaper_questions": [
{
"id": 42,
"score": 25,
"question_id": 73,
"title": "说说你的看法",
"remark": "问题解析",
"type": "answer",
"user_value": [
""
]
},
{
"id": 43,
"score": 25,
"question_id": 72,
"title": "请问我年龄多大",
"remark": "问题解析",
"type": "completion",
"user_value": [
"",
]
},
{
"id": 44,
"score": 0,
"question_id": 71,
"title": "请问我是男生还是女生",
"remark": "问题解析",
"type": "trueOrfalse",
"options": [
"正确",
"错误"
],
"user_value": -1
},
{
"id": 45,
"score": 25,
"question_id": 70,
"title": "<p>你的名字叫什么</p>",
"remark": "问题解析",
"type": "checkbox",
"options": [
"张三",
"李四",
"王五",
"王五哈"
],
"user_value": []
},
{
"id": 46,
"score": 25,
"question_id": 65,
"title": "你的名字叫什么",
"remark": "问题解析",
"type": "checkbox",
"options": [
"张三",
"李四",
"王五",
"王五哈"
],
"user_value": []
}
],
"user_test_id": 7
})
const route = useRoute()
let { data } = useReadDetailApi(route.params.id)
// 题目列表
const testpaper_questions = computed(() => {
Expand Down Expand Up @@ -194,4 +124,35 @@ onBeforeRouteLeave((to, from, next) => {
})
//交卷
const loading = ref(false)
async function submit() {
const { message } = createDiscreteApi(["message"])
let l = (testpaper_questions.value.fliter(v => !v.isTest)).length
if (l > 0) {
return message.warning("还有题目没完成,请检查~")
}
loading.value = true
const {
data: submitData,
error: submitError,
} = await useSubmitTestApi({
user_test_id: data.user_test_id,
value: testpaper_questions.value.map(o => o.value)
})
loading.value = false
if(submitError.value) return
//跳转前先把disabled_PageBack设置为false
disabled_PageBack.value = false;
message.success("交卷成功(^-^)V")
navigateTo(`/paper/1`,{
replace:true
})
}
//自动交卷
</script>

0 comments on commit 7d44f25

Please sign in to comment.