diff --git a/safesite/daoru.py b/safesite/daoru.py index b0ce039e..898337bb 100644 --- a/safesite/daoru.py +++ b/safesite/daoru.py @@ -2,7 +2,7 @@ from docxtpl import DocxTemplate, InlineImage from docx.shared import Mm, Inches, Pt from openpyxl import Workbook, load_workbook from openpyxl.drawing.image import Image -from .models import User,Trouble,Dickey,Partment,Dicclass,Train,Drill,TroubleAccess,Group,Yjyc,Equipment,Area,RiskAct,Risk +from .models import User,Trouble,Dickey,Partment,Dicclass,Train,Drill,TroubleAccess,Group,Yjyc,Equipment,Area,RiskAct,Risk,Question,Questioncat from datetime import datetime,date import base64 from django.conf import settings @@ -53,6 +53,48 @@ def makeqr_area(data): img.save(filepath) return filepath +def drquestions(companyid,path): + wb = load_workbook(path) + sheet = wb.worksheets[0] + i = 4 + while sheet['c'+str(i)].value!=None: + type = sheet['a'+str(i)].value.replace(' ', '') + cate = sheet['b'+str(i)].value.replace(' ', '') + title = sheet['c'+str(i)].value + answerA = sheet['d'+str(i)].value + answerB = sheet['e'+str(i)].value + answerC = sheet['f'+str(i)].value + answerD = sheet['g'+str(i)].value + answerE = sheet['h'+str(i)].value + answerF = sheet['i'+str(i)].value + right = sheet['j'+str(i)].value.replace(' ', '') + resolution = sheet['k'+str(i)].value + level = sheet['l'+str(i)].value + objs = Questioncat.objects.filter(usecomp__partid=1,name=cate) + if objs.exists(): + cateobj = objs[0] + else: + objs = Questioncat.objects.filter(usecomp__partid=companyid,name=cate) + if objs.exists(): + cateobj = objs[0] + else: + cateobj = Questioncat.objects.create(usecomp__partid=companyid,name=cate) + if type == '单选': + obj = Question() + obj.type = 1 + obj.cate = cateobj + obj.title = title + obj.answerA = answerA + obj.answerB = answerB + obj.answerC = answerC + obj.answerD = answerD + obj.answerE = answerE + obj.answerF = answerF + pass + + + + def drequipments(companyid,path): wb = load_workbook(path) sheet = wb.worksheets[0] diff --git a/safesite/models.py b/safesite/models.py index ca51d125..bf09e322 100644 --- a/safesite/models.py +++ b/safesite/models.py @@ -598,7 +598,7 @@ class ExamTestDetail(models.Model):#考试详情表 endtime = models.DateTimeField(null=True,blank=True) took = models.IntegerField(default=0) #耗时 rights = models.IntegerField(default=1) #正确数 - ison = models.IntegerField(default=0) #未参加/已参加/不计算 + ison = models.IntegerField(default=0) #未参加0/已参加1/ passcode = models.IntegerField(default=0) #是否通过 testdetail = JSONField(null=True,blank=True) score = models.FloatField(default=0)#得分 diff --git a/safesite/static/safesite/muban/tm.xlsx b/safesite/static/safesite/muban/tm.xlsx index 842959e5..1011ee74 100644 Binary files a/safesite/static/safesite/muban/tm.xlsx and b/safesite/static/safesite/muban/tm.xlsx differ diff --git a/safesite/templates/question.html b/safesite/templates/question.html index de9a0a2b..60ca4455 100644 --- a/safesite/templates/question.html +++ b/safesite/templates/question.html @@ -29,7 +29,7 @@
请按模板录入后导入
录入完成后点击下方按钮上传文件
diff --git a/safesite/templates/report.html b/safesite/templates/report.html index df231901..4cc1017e 100644 --- a/safesite/templates/report.html +++ b/safesite/templates/report.html @@ -345,6 +345,7 @@ //data['map7v'] = myChart7.getDataURL({ pixelRatio: 2, }); data['nowyjz'] = nowyjz; //console.log(JSON.stringify(data));5 + console.log(data) $.ajax({ type: "POST", async: false, //异步请求(同步请求将会锁住浏览器,用户其他操作必须等待请求完成才可以执行)