123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import Api from "../../model/api";
- import Config from "../../model/config";
- import {questionTypes} from "../../model/enum";
- Page({
- data: {
- exams: [],
- score: '',
- },
- async onLoad(options) {
- const {id, stuId} = options;
- let res = await Api.getPaperResult(id, stuId, true);
- let score = res.data.fraction || 0;
- let testQuestionsList = res.data.testQuestionsList;
- let exams = [
- ...(testQuestionsList.singleChoice || []),
- ...(testQuestionsList.multipleChoice || []),
- ...(testQuestionsList.qaq || []),
- ];
- exams.forEach(item => {
- if (item.questionType == questionTypes.SINGLE || item.questionType == questionTypes.MULTIPLE) {
- let okAnswers = item.testAnswerList.filter(
- (item, index) => {
- item.opt = Config.OPT_TIP[index];
- return !item.isItCorrect
- }
- );
- let myAnswers = item.testAnswerList.filter(
- (item, index) => {
- item.opt = Config.OPT_TIP[index];
- return !item.status
- }
- );
- item.okAnswers = okAnswers;
- item.myAnswers = myAnswers;
- } else if (item.questionType == questionTypes.WRITE) {
- let myAnswer = item.testAnswerList[0].qaqAnswer;
- item.myAnswer = myAnswer;
- }
- })
- this.setData({
- exams,
- score
- })
- }
- });
|