1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import Api from "../../model/api";
- import Config from "../../model/config";
- Page({
- data: {
- exams: [],
- // score: '',
- },
- async onLoad(options) {
- let {id, stuId, courseId} = options;
- let params = {
- questionnaireId: id,
- studentId: stuId,
- }
- if (courseId && courseId !== 'null') {
- params.courseId = courseId;
- }
- let res = await Api.getQuestionResult(params, true);
- // let score = res.data.fraction || 0;
- // let testQuestionsList = res.data.testQuestionsList;
- // let exams = [
- // ...(testQuestionsList.singleChoice || []),
- // ...(testQuestionsList.multipleChoice || []),
- // ...(testQuestionsList.qaq || []),
- // ];
- let questions = res.data;
- questions.forEach(question => {
- question.isQAQ = question.allChoose.length === 0;
- if (question.otherAnswerType && !question.isQAQ) {
- //如果不是问答题,在选项里拼 其他 选项
- question.allChoose.push('其他')
- }
- question.allOptions = question.allChoose.map((item, idx) => {
- return {
- opt: Config.OPT_TIP[idx],
- answer: item
- }
- });
- if (question.isQAQ) {
- question.myAnswer = question.yourAnswer;
- } else {
- let answerStr = question.trueIndex.map(item => {
- return `${Config.OPT_TIP[item]}.${question.allChoose[item]}`
- }).join('、');
- if (question.otherAnswerType && question.yourAnswer) {
- //如果选择的选项中包含其他
- let otherOption = question.allOptions[question.allOptions.length - 1];
- answerStr += `、${otherOption.opt}.${otherOption.answer}(${question.yourAnswer})`
- }
- question.myAnswer = answerStr;
- }
- })
- this.setData({
- questions,
- // score
- })
- }
- });
|