小程序init考试
This commit is contained in:
parent
593c0d35f1
commit
94ee6f844f
|
@ -69,9 +69,9 @@ App({
|
|||
globalData: {
|
||||
userInfo: {},
|
||||
userinfo: {}, // 服务器传回的消费者信息
|
||||
host: 'https://apitest.ahctc.cn',
|
||||
//host: 'https://apitest.ahctc.cn',
|
||||
mediahost: 'https://apitest.ahctc.cn',
|
||||
//host: 'http://127.0.0.1:8000',
|
||||
host: 'http://127.0.0.1:8000',
|
||||
//mediahost: 'http://127.0.0.1:8000',
|
||||
token : '',
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
"pages/candidate/detail",
|
||||
"pages/material/video",
|
||||
"pages/qtest/form",
|
||||
"pages/main/start"
|
||||
"pages/main/start",
|
||||
"pages/exam/index"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1615988351221" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4995" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><defs><style type="text/css"></style></defs><path d="M504.5248 189.7472c-43.7248-25.1904-99.4304-13.1072-128.8192 27.9552l-15.36 21.6064c-31.8464 44.544-72.6016 82.0224-119.808 109.8752l-106.1888 62.7712C97.792 433.5616 79.36 476.16 88.4736 517.5296l106.496 482.304 159.5392-276.2752-5.9392-5.0176c-51.9168-46.7968-66.7648-123.2896-31.6416-184.1152 40.6528-70.3488 132.7104-93.2864 205.6192-51.0976 73.0112 42.0864 99.2256 133.2224 58.5728 203.6736l-4.096 6.5536c-37.888 58.2656-112.64 80.4864-178.4832 55.5008L240.2304 1022.7712 709.632 876.032c40.5504-12.6976 68.3008-49.8688 68.8128-92.3648l1.4336-121.2416c0.7168-54.784 12.9024-108.8512 35.7376-158.6176l11.5712-25.088c21.0944-45.9776 3.7888-100.4544-40.0384-125.8496l-282.624-163.1232zM586.752 10.6496C569.856 0.9216 549.7856-1.7408 530.944 3.2768c-18.8416 5.0176-34.9184 17.408-44.6464 34.304l-2.7648 5.3248c-16.384 34.6112-3.4816 75.9808 29.696 95.1296l312.9344 180.6336c16.896 9.728 36.9664 12.3904 55.808 7.3728 18.8416-5.0176 34.9184-17.408 44.6464-34.304l2.8672-5.3248c16.384-34.6112 3.3792-76.0832-29.7984-95.1296L586.752 10.6496z m0 0" p-id="4996" fill="#d81e06"></path></svg>
|
After Width: | Height: | Size: 1.4 KiB |
|
@ -0,0 +1,119 @@
|
|||
// pages/qtest/form.js
|
||||
const api = require("../../utils/request.js");
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
userInfo:{},
|
||||
form:{
|
||||
deptname:null,
|
||||
code:null
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
deptInput: function(e){
|
||||
this.data.form.deptname = e.detail.value
|
||||
},
|
||||
codeinput: function(e){
|
||||
this.data.form.code = e.detail.value
|
||||
},
|
||||
submit: function(){
|
||||
if(this.data.form.deptname&&this.data.form.code){
|
||||
wx.showToast({
|
||||
title: '加入考试成功',
|
||||
icon:'none'
|
||||
})
|
||||
let data = this.data.form
|
||||
api.request('/examtest/exam/attend/','POST', data).then(res=>{
|
||||
wx.showLoading({
|
||||
title: '正在组卷。。。',
|
||||
mask:true
|
||||
})
|
||||
let exam = res.data.exam
|
||||
api.request(`/examtest/exam/${exam}/init/`,'POST', data).then(res=>{
|
||||
console.log(res.data)
|
||||
wx.hideLoading({
|
||||
success: (res) => {},
|
||||
})
|
||||
}).catch(e=>{
|
||||
wx.hideLoading({
|
||||
success: (res) => {},
|
||||
})
|
||||
})
|
||||
})
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: '信息不完整',
|
||||
icon:'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
api.request('/crm/consumer/info/','GET').then(res=>{
|
||||
getApp().globalData.userinfo = res.data.userinfo
|
||||
this.setData(
|
||||
{
|
||||
userinfo: res.data.userinfo,
|
||||
form:{
|
||||
deptname:res.data.userinfo.deptname
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"usingComponents": {}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<view >
|
||||
<view class="weui-form__text-area" style="margin-top:20px;padding: 0 18px;">
|
||||
<h2 class="weui-form__title">正式考试</h2>
|
||||
<view class="weui-form__desc">请确认和完善个人信息,并输入考试号加入考试,如有问题请及时联系老师</view>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<view class="weui-cells__title">个人信息</view>
|
||||
<view class="weui-cells weui-cells_form">
|
||||
<view class="weui-cell weui-cell_active">
|
||||
<view class="weui-cell__hd"><label class="weui-label">姓名</label></view>
|
||||
<view class="weui-cell__bd">
|
||||
{{userinfo.name}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_active">
|
||||
<view class="weui-cell__hd"><label class="weui-label">身份证号</label></view>
|
||||
<view class="weui-cell__bd">
|
||||
{{userinfo.ID_number1}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_active">
|
||||
<view class="weui-cell__hd">
|
||||
<label class="weui-label">单位</label>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
{{userinfo.company_name}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_active">
|
||||
<view class="weui-cell__hd">
|
||||
<label class="weui-label">部门</label>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
<span wx:if="{{userinfo.deptname}}">{{userinfo.deptname}}</span>
|
||||
<input wx:else class="weui-input" placeholder="填写您的部门" placeholder-class="weui-input__placeholder" bindinput="deptInput" >
|
||||
{{userinfo.deptname}}
|
||||
</input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cell weui-cell_active">
|
||||
<view class="weui-cell__hd">
|
||||
<label class="weui-label">考试号</label>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
<input class="weui-input" placeholder="填写要加入的考试号" placeholder-class="weui-input__placeholder" bindinput="codeinput" >
|
||||
|
||||
</input>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-form__tips-area">
|
||||
<!-- <view class="weui-form__tips">
|
||||
表单页提示,居中对齐
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="weui-form__opr-area">
|
||||
<a class="weui-btn weui-btn_primary" bindtap="submit">确认</a>
|
||||
</view>
|
||||
</view>
|
|
@ -0,0 +1 @@
|
|||
/* pages/exam/index.wxss */
|
|
@ -4,21 +4,21 @@
|
|||
<view class="weui-panel__bd">
|
||||
<view class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active" bindtap="register">
|
||||
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg" style="border-radius:6px;overflow:hidden">
|
||||
<open-data type="userAvatarUrl" ></open-data>
|
||||
<open-data type="userAvatarUrl"></open-data>
|
||||
</view>
|
||||
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
|
||||
<view class="weui-media-box__title" wx:if="{{userinfo && userinfo.username}}">
|
||||
<span>账号:</span>
|
||||
<span style="font-weight:bold;">{{userinfo.username}}</span>
|
||||
</view>
|
||||
<view class="weui-media-box__title" wx:else>账号:
|
||||
<span style="color:red">未登陆</span>
|
||||
<view class="weui-media-box__title" wx:else>账号:
|
||||
<span style="color:red">未登陆</span>
|
||||
</view>
|
||||
<view class="weui-media-box__desc">昵称:
|
||||
<open-data type="userNickName"></open-data>
|
||||
</view>
|
||||
<view class="weui-media-box__desc">单位:
|
||||
<span wx:if="{{userinfo && userinfo.company_name}}">{{ userinfo.company_name }}</span>
|
||||
<view class="weui-media-box__desc">单位:
|
||||
<span wx:if="{{userinfo && userinfo.company_name}}">{{ userinfo.company_name }}</span>
|
||||
</view>
|
||||
<view class="weui-media-box__desc">如需解绑账号请联系课程顾问
|
||||
</view>
|
||||
|
@ -28,46 +28,55 @@
|
|||
</view>
|
||||
<view class="weui-cells__title">统计分析</view>
|
||||
<view class="weui-cells weui-cells_after-title">
|
||||
<view class="weui-cell" >
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/class.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image>
|
||||
<image src="/images/class.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;">
|
||||
</image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">工作类别</view>
|
||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue"
|
||||
wx:if="{{userinfo.workscope_name}}"
|
||||
>{{userinfo.workscope_name}}</view>
|
||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue"
|
||||
wx:else
|
||||
>无</view>
|
||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue" wx:if="{{userinfo.workscope_name}}">
|
||||
{{userinfo.workscope_name}}</view>
|
||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue" wx:else>无</view>
|
||||
</view>
|
||||
<!-- <l-list title="模考次数" tag-content="{{total}}" tag-position="right"/> -->
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/count.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image>
|
||||
<image src="/images/count.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;">
|
||||
</image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">模考次数</view>
|
||||
<view class="weui-cell__bd">考试次数</view>
|
||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue">{{total}}</view>
|
||||
</view>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/rate.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/rate.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;">
|
||||
</image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">通过率</view>
|
||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue">{{pass_rate}}%</view>
|
||||
</view>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/avg.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image>
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/avg.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;">
|
||||
</image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">平均分</view>
|
||||
<view class="weui-cell__ft" style="font-weight:bold;color:darkblue" wx:if="{{avg_score}}">{{avg_score}}</view>
|
||||
</view>
|
||||
<navigator url="/pages/exam/index" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/exam.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;">
|
||||
</image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">正式考试入口</view>
|
||||
<view class="weui-cell__ft weui-cell__ft_in-access" style="color:red"></view>
|
||||
</navigator>
|
||||
</view>
|
||||
<view class="weui-footer weui-footer_fixed-bottom">
|
||||
<!-- <view class="weui-footer__text" bindtap="intro">点击下载系统/小程序文档介绍</view> -->
|
||||
<view class="weui-footer__text">更多服务请联系课程顾问</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="weui-footer weui-footer_fixed-bottom">
|
||||
<!-- <view class="weui-footer__text" bindtap="intro">点击下载系统/小程序文档介绍</view> -->
|
||||
<view class="weui-footer__text">更多服务请联系课程顾问</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
</view>
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.0.4 on 2021-03-17 14:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('crm', '0026_auto_20210313_1109'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='consumer',
|
||||
name='deptname',
|
||||
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='所在部门'),
|
||||
),
|
||||
]
|
|
@ -9,7 +9,7 @@ from django.db.models import Q
|
|||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from openpyxl import Workbook, load_workbook
|
||||
from rest_framework import status
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.decorators import action, authentication_classes, permission_classes
|
||||
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.response import Response
|
||||
|
@ -365,17 +365,6 @@ class ConsumerViewSet(ModelViewSet):
|
|||
request.user.save()
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
|
||||
# @action(methods=['put'], detail=False,
|
||||
# url_path='process', url_name='exercise_processcat', perms_map=[{'*':'*'}])
|
||||
# def processcat(self, request):
|
||||
# '''
|
||||
# 练习进度单类别修改
|
||||
# '''
|
||||
# if hasattr(request.user, 'process'):
|
||||
# request.user.process = request.data['process']
|
||||
# request.user.save()
|
||||
# return Response(status=status.HTTP_200_OK)
|
||||
|
||||
@action(methods=['post'], detail=False,
|
||||
url_path='realinfo', url_name='get_realinfo', perms_map=[{'*':'*'}])
|
||||
def realinfo(self, request):
|
||||
|
@ -547,6 +536,11 @@ class ConsumerViewSet(ModelViewSet):
|
|||
except:
|
||||
raise Http404
|
||||
|
||||
@action(methods=['get'], detail = False, perms_map=[{'*':'*'}])
|
||||
def info(self, request, *args, **kwargs):
|
||||
serializer = ConsumerDetailSerializer(instance=request.user)
|
||||
return Response({"userinfo":serializer.data})
|
||||
|
||||
from .permission import get_consumerperm_list
|
||||
class ConsumerMPLoginView(APIView):
|
||||
"""
|
||||
|
|
|
@ -72,7 +72,7 @@ class ExamViewSet(ModelViewSet):
|
|||
return Response(status=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
@action(methods=['post'], detail = False,perms_map=[{'get':'exam_attend'}])
|
||||
@action(methods=['post'], detail = False,perms_map=[{'post':'exam_attend'}])
|
||||
def attend(self, request, *args, **kwargs):
|
||||
"""
|
||||
参加考试
|
||||
|
@ -89,20 +89,21 @@ class ExamViewSet(ModelViewSet):
|
|||
exam = Exam.objects.get(code=code, opentime__lt=now, closetime__gt=now)
|
||||
return Response({'exam':exam.pk})
|
||||
except:
|
||||
return Response({'error':'考试编号错误'})
|
||||
return Response({'error':'考试编号不存在'})
|
||||
return Response({'error':'操作失败'})
|
||||
|
||||
@action(methods=['post'], detail = True,perms_map=[{'get':'exam_init'}])
|
||||
@action(methods=['post'], detail = True,perms_map=[{'post':'exam_attend'}])
|
||||
def init(self, request, *args, **kwargs):
|
||||
"""
|
||||
生成考试卷
|
||||
"""
|
||||
obj = self.get_object()
|
||||
obj = Exam.objects.get(pk=kwargs['pk'])
|
||||
workscope = obj.workscope
|
||||
ret = {}
|
||||
if workscope.name in ['医学Ⅲ类', '非医学Ⅲ类']:
|
||||
ret['name'] = '正式考试' + datetime.now().strftime('%Y%m%d%H%M')
|
||||
ret['name'] = obj.name
|
||||
ret['type'] = '正式考试' # 正式考试
|
||||
ret['exam'] = obj.id
|
||||
ret['exam'] = ExamListSerializer(instance=obj).data
|
||||
ret['workscope'] = workscope.id
|
||||
ret['limit'] = 60
|
||||
ret['total_score'] = 120
|
||||
|
@ -130,6 +131,7 @@ class ExamViewSet(ModelViewSet):
|
|||
i['total_score'] = 4
|
||||
ret['questions'] = questions
|
||||
return Response(ret)
|
||||
return Response({'error':'生成试卷失败'})
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue