12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 'use strict';
- const assert = require('assert');
- const _ = require('lodash');
- const { ObjectId } = require('mongoose').Types;
- const { CrudService } = require('naf-framework-mongoose/lib/service');
- const { BusinessError, ErrorCode } = require('naf-core').Error;
- class UploadquestionService extends CrudService {
- constructor(ctx) {
- super(ctx, 'uploadquestion');
- this.model = this.ctx.model.Uploadquestion;
- this.smodel = this.ctx.model.Student;
- }
- // 完成度查询
- async completion(data) {
- const { type, typeid } = data;
- let allcount = '';
- let answercount = '';
- // 如果是期查询
- if (type === '0') {
- // 取得当前期学生总数
- allcount = await this.smodel.count({ termid: typeid });
- // 取得当前期学生答问卷数
- answercount = await this.model.count({ termid: typeid });
- } else if (type === '1') {
- // 取得当前期学生总数
- allcount = await this.smodel.count({ batchid: typeid });
- // 取得当前期学生答问卷数
- answercount = await this.model.count({ batchid: typeid });
- } else if (type === '2') {
- // 取得当前期学生总数
- allcount = await this.smodel.count({ classid: typeid });
- // 取得当前期学生答问卷数
- answercount = await this.model.count({ classid: typeid });
- }
- const newdata = { allcount, answercount };
- return newdata;
- }
- }
- module.exports = UploadquestionService;
|