examResult.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import Api from "../../model/api";
  2. import Config from "../../model/config";
  3. import {questionTypes} from "../../model/enum";
  4. Page({
  5. data: {
  6. exams: [],
  7. score: '',
  8. },
  9. async onLoad(options) {
  10. const {id, stuId} = options;
  11. let res = await Api.getPaperResult(id, stuId, true);
  12. let score = res.data.fraction || 0;
  13. let testQuestionsList = res.data.testQuestionsList;
  14. let exams = [
  15. ...(testQuestionsList.singleChoice || []),
  16. ...(testQuestionsList.multipleChoice || []),
  17. ...(testQuestionsList.qaq || []),
  18. ];
  19. exams.forEach(item => {
  20. if (item.questionType == questionTypes.SINGLE || item.questionType == questionTypes.MULTIPLE) {
  21. let okAnswers = item.testAnswerList.filter(
  22. (item, index) => {
  23. item.opt = Config.OPT_TIP[index];
  24. return !item.isItCorrect
  25. }
  26. );
  27. let myAnswers = item.testAnswerList.filter(
  28. (item, index) => {
  29. item.opt = Config.OPT_TIP[index];
  30. return !item.status
  31. }
  32. );
  33. item.okAnswers = okAnswers;
  34. item.myAnswers = myAnswers;
  35. } else if (item.questionType == questionTypes.WRITE) {
  36. let myAnswer = item.testAnswerList[0].qaqAnswer;
  37. item.myAnswer = myAnswer;
  38. }
  39. })
  40. this.setData({
  41. exams,
  42. score
  43. })
  44. }
  45. });