This commit is contained in:
caoqianming 2020-04-21 18:32:24 +08:00
parent c6863eed94
commit 31224b0b12
6 changed files with 110 additions and 13 deletions

View File

@ -20,6 +20,7 @@ App({
if(res.code==200){
this.globalData.token = res.data.token
this.globalData.userinfo = res.data.userinfo
console.log(res.data.userinfo)
if(res.data.userinfo.username == null){
//匿名用户
wx.reLaunch({
@ -55,8 +56,8 @@ App({
userinfo: null, // 服务器传回的消费者信息
host: 'https://apitest.ctcshe.com',
mediahost: 'https://apitest.ctcshe.com',
// host: 'http://127.0.0.1:8000',
// mediahost: 'http://127.0.0.1:8000',
//host: 'http://127.0.0.1:8000',
//mediahost: 'http://127.0.0.1:8000',
token : '',
}
})

View File

@ -20,8 +20,7 @@ Page({
{ title: "如有疑问,请致电课程顾问师老师:18355135390" },]
},
imgH: function (e) {
let winWid = wx.getSystemInfoSync().windowWidth;
console.log(e) //获取当前屏幕的宽度
let winWid = wx.getSystemInfoSync().windowWidth; //获取当前屏幕的宽度
let imgh = e.detail.height;                //图片高度
let imgw = e.detail.width;
let swiperH = winWid * imgh / imgw + "px";
@ -116,15 +115,32 @@ Page({
}
},
goMoni: function () {
var that = this
const workscope = getApp().globalData.userinfo.workscope
if (workscope) {
this.genPaper(workscope)
} else {
wx.showToast({
title: '未开通权限\r\n请致电18355135390',
icon: 'none',
duration: 2000
})
that.genPaper(workscope)
}
else {
const remain_count = getApp().globalData.userinfo.remain_count
let confirmText, showCancel
if(remain_count>0){
wx.showModal({
title: '未开通权限!',
content: '您有' + remain_count + '次体验次数.',
confirmText: '体验一下',
success(res) {
if (res.confirm) {
that.genPaper2()
}
}
})
}else{
wx.showModal({
title: '未开通权限!',
content: '体验次数已用完',
showCancel: false,
})
}
}
},
goYati: function () {
@ -150,7 +166,7 @@ Page({
title: '正在生成试卷',
mask:true
})
api.request('/examtest/workscope/' + workId + '/monitest', 'GET').then(res => {
api.request('/examtest/workscope/' + workId + '/monitest/', 'GET').then(res => {
wx.hideLoading()
try {
wx.setStorageSync('examtest', res.data)
@ -161,4 +177,21 @@ Page({
})
},
genPaper2: function () {
wx.showLoading({
title: '正在生成试卷',
mask: true
})
api.request('/examtest/workscope/monitest2/', 'GET').then(res => {
wx.hideLoading()
try {
wx.setStorageSync('examtest', res.data)
getApp().globalData.userinfo.remain_count = res.data.remain_count
} catch (e) { }
wx.navigateTo({
url: '/pages/moni/note',
})
})
},
})

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.4 on 2020-04-21 08:23
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('crm', '0012_auto_20200402_2313'),
]
operations = [
migrations.AddField(
model_name='consumer',
name='remain_count',
field=models.IntegerField(default=1, verbose_name='可考次数'),
),
]

View File

@ -32,6 +32,7 @@ class Consumer(SoftCommonModel):
subjects = models.ManyToManyField(Questioncat, verbose_name='付费学科', through='PaySubject')
workscope = models.ForeignKey(WorkScope, verbose_name='工作类别', on_delete=models.SET_NULL, null=True, blank=True)
collects = models.ManyToManyField(Question, verbose_name='收藏试题')
remain_count = models.IntegerField('可考次数', default=1)
class Meta:

View File

@ -103,6 +103,50 @@ class WorkScopeViewSet(ModelViewSet):
ret['questions'] = questions
return Response(ret)
@action(methods=['get'], detail=False,url_path='monitest2', url_name='gen_monitest2', perms_map=[{'get':'gen_monitest'}])
def monitest2(self, request, pk=None):
'''
生成体验版自助模拟考试
'''
ret = {}
rule = TestRule.objects.first()
ret['name'] = '自助模考' + datetime.now().strftime('%Y%m%d%H%M')
ret['type'] = '自助模考' # 自助模拟考试
ret['limit'] = rule.limit
ret['total_score'] = rule.total_score
ret['pass_score'] = rule.pass_score
ret['danxuan_count'] = rule.danxuan_count
ret['danxuan_score'] = rule.danxuan_score
ret['duoxuan_count'] = rule.duoxuan_count
ret['duoxuan_score'] = rule.duoxuan_score
ret['panduan_count'] = rule.panduan_count
ret['panduan_score'] = rule.panduan_score
question_queryset = Question.objects.none()
queryset = Question.objects.filter(is_delete=0)
if ret['danxuan_count']:
danxuan = queryset.filter(type='单选').order_by('?')[:ret['danxuan_count']]
question_queryset = question_queryset | danxuan
if ret['duoxuan_count']:
duoxuan = queryset.filter(type='多选').order_by('?')[:ret['duoxuan_count']]
question_queryset = question_queryset | duoxuan
if ret['panduan_count']:
panduan = queryset.filter(type='判断').order_by('?')[:ret['panduan_count']]
question_queryset = question_queryset | panduan
questions = QuestionSerializer(instance=question_queryset.order_by('type'),many=True).data
for i in questions:
if i['type'] == '单选':
i['total_score'] = ret['danxuan_score']
elif i['type'] == '多选':
i['total_score'] = ret['duoxuan_score']
else:
i['total_score'] = ret['panduan_score']
ret['questions'] = questions
user = request.user
user.remain_count = user.remain_count -1
request.user.save()
ret['remain_count'] = user.remain_count
return Response(ret)
class BannerViewSet(ModelViewSet):
"""

View File

@ -226,7 +226,7 @@ class QuestionViewSet(ModelViewSet):
class ExerciseView(APIView):
def post(self, request):
questioncat = request.data['questioncat']
queryset = Question.objects.filter(is_delete=0,questioncat=questioncat).order_by('type')
queryset = Question.objects.filter(is_delete=0,questioncat=questioncat).order_by('type','name')
if 'ydtms' in request.data and request.data['ydtms']:
queryset = queryset.exclude(id__in = request.data['ydtms'])
count = queryset.count()