|
@@ -23,7 +23,8 @@ class AnswerService extends CrudService {
|
|
|
* @property {String} user_id 保安员id
|
|
|
*/
|
|
|
async getExamQuestion({ exam = false, ...info }) {
|
|
|
- const config = await this.configModel.findOne();
|
|
|
+ let config = await this.configModel.findOne();
|
|
|
+ if (config) config = JSON.parse(JSON.stringify(config));
|
|
|
const questionTypeList = await this.questTypeModel.find();
|
|
|
// 是否真的生成数据
|
|
|
let save = false;
|
|
@@ -85,21 +86,21 @@ class AnswerService extends CrudService {
|
|
|
let mscore = this.computedPercent(5, maxScore);
|
|
|
// 考试类型不能超过5%
|
|
|
let limit = 0;
|
|
|
- do {
|
|
|
- for (const p of exam_proportion) {
|
|
|
- const { score } = p;
|
|
|
- if (mscore - score < 0) {
|
|
|
- // 减完成负数了,不能减
|
|
|
- limit++;
|
|
|
- continue;
|
|
|
- } else {
|
|
|
- p.num++;
|
|
|
- mscore -= score;
|
|
|
- lessScore -= score;
|
|
|
- }
|
|
|
- }
|
|
|
- // limit到100次基本说明无限循环了,跳出来,有问题咱可以外面抛异常.别这里搞事消耗
|
|
|
- } while (mscore > 0 && limit < 100);
|
|
|
+ // do {
|
|
|
+ // for (const p of exam_proportion) {
|
|
|
+ // const { score } = p;
|
|
|
+ // if (mscore - score < 0) {
|
|
|
+ // // 减完成负数了,不能减
|
|
|
+ // limit++;
|
|
|
+ // continue;
|
|
|
+ // } else {
|
|
|
+ // p.num++;
|
|
|
+ // mscore -= score;
|
|
|
+ // lessScore -= score;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // limit到100次基本说明无限循环了,跳出来,有问题咱可以外面抛异常.别这里搞事消耗
|
|
|
+ // } while (mscore > 0 && limit < 100);
|
|
|
// 整理成plan,合并进去么
|
|
|
const exam_plan = exam_proportion.map(i => {
|
|
|
const { score, _id: type, num } = i;
|