ソースを参照

增加查询条件问卷id

liuyu 5 年 前
コミット
7263156c0f
1 ファイル変更7 行追加7 行削除
  1. 7 7
      app/service/uploadquestion.js

+ 7 - 7
app/service/uploadquestion.js

@@ -18,7 +18,7 @@ class UploadquestionService extends CrudService {
 
   // 完成度查询
   async completion(data) {
-    const { type, typeid, trainplanid } = data;
+    const { type, typeid, trainplanid, questionnaireid } = data;
     assert(type && typeid, '缺少部分信息项');
     const datas = [];
     let answertotal = '';
@@ -32,7 +32,7 @@ class UploadquestionService extends CrudService {
         // 取得当前期学生总数
         const allcount = await this.smodel.count({ batchid: batch.id });
         // 取得当前期学生答问卷数
-        const answercount = await this.model.count({ batchid: batch.id });
+        const answercount = await this.model.count({ batchid: batch.id, questionnaireid });
         let completion = (answercount / allcount * 100).toFixed(2);
         completion = completion + '%';
         const newdata = { id: batch.id, name: batch.name, allcount, answercount, completion };
@@ -41,14 +41,14 @@ class UploadquestionService extends CrudService {
       // 取得当前期学生总数
       alltotal = await this.smodel.count({ termid: typeid });
       // 取得当前期学生答问卷数
-      answertotal = await this.model.count({ termid: typeid });
+      answertotal = await this.model.count({ termid: typeid, questionnaireid });
     } else if (type === '1') {
       const classs = await this.cmodel.find({ batchid: typeid });
       for (const elm of classs) {
         // 取得当前期学生总数
         const allcount = await this.smodel.count({ classid: elm.id });
         // 取得当前期学生答问卷数
-        const answercount = await this.model.count({ classid: elm.id });
+        const answercount = await this.model.count({ classid: elm.id, questionnaireid });
         let completion = (answercount / allcount * 100).toFixed(2);
         completion = completion + '%';
         const newdata = { id: elm.id, name: elm.name, allcount, answercount, completion };
@@ -57,13 +57,13 @@ class UploadquestionService extends CrudService {
       // 取得当前期学生总数
       alltotal = await this.smodel.count({ batchid: typeid });
       // 取得当前期学生答问卷数
-      answertotal = await this.model.count({ batchid: typeid });
+      answertotal = await this.model.count({ batchid: typeid, questionnaireid });
     } else if (type === '2') {
       // 取得当前期学生总数
       const stus = await this.smodel.find({ classid: typeid });
       for (const elm of stus) {
         // 取得当前期学生答问卷数
-        const answer = await this.model.find({ studentid: elm.id });
+        const answer = await this.model.find({ studentid: elm.id, questionnaireid });
         let completion = '';
         if (answer) {
           completion = '100%';
@@ -76,7 +76,7 @@ class UploadquestionService extends CrudService {
       // 取得当前期学生总数
       alltotal = await this.smodel.count({ classid: typeid });
       // 取得当前期学生答问卷数
-      answertotal = await this.model.count({ classid: typeid });
+      answertotal = await this.model.count({ classid: typeid, questionnaireid });
 
     }
     let completiontotal = (answertotal / alltotal * 100).toFixed(2);