uploadtask.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 答案详情
  5. const answerInfo = new Schema({
  6. questionid: { type: String, required: false, maxLength: 200 }, // 问题id
  7. topic: { type: String, required: false, maxLength: 200 }, // 问题
  8. answer: { type: String, required: false, maxLength: 200 }, // 答案
  9. questionscore: { type: String, required: false, maxLength: 200 }, // 分数
  10. });
  11. // 学生上传作业表
  12. const UploadtaskSchema = {
  13. termid: { type: String, required: true, maxLength: 200 }, // 期id
  14. batchid: { type: String, required: true, maxLength: 200 }, // 批次id
  15. classid: { type: String, required: true, maxLength: 200 }, // 班级id
  16. lessonid: { type: String, required: true, maxLength: 200 }, // 课程信息id
  17. lessonname: { type: String, required: false, maxLength: 200 }, // 课程信息名称
  18. studentid: { type: String, required: true, maxLength: 200 }, // 学生id
  19. picurl: { type: Array, required: false, maxLength: 200 }, // 上传图片地址
  20. taskid: { type: String, required: false, maxLength: 200 }, // 作业id
  21. score: { type: String, required: false, maxLength: 2000 }, // 分数
  22. answers: { type: [ answerInfo ], select: true }, // 回答详情
  23. };
  24. const schema = new Schema(UploadtaskSchema, { toJSON: { virtuals: true } });
  25. schema.index({ id: 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Uploadtask', schema, 'uploadtask');
  30. };