UNPKG

@gmetrixr/rjson

Version:
43 lines (42 loc) 2.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const r_1 = require("../../../r"); /** * Flattens the Quiz property quiz_instructions * Older Structure: * /** * export interface QuizInstruction { * heading: { name: string, placeholder: string, value: string }, -----> heading * correct_score: { name: string, placeholder: string, value: number }, ------> quiz_correct_score * wrong_score: { name: string, placeholder: string, value: number }, ------> quiz_wrong_score * pass_mark: { name: string, placeholder: string, value: number } ------> quiz_passing_score * } * * [ElementProperty.quiz_starting_instructions]: {}, * [ElementProperty.quiz_passing_score]: {}, * [ElementProperty.quiz_correct_score]: {}, * [ElementProperty.quiz_wrong_score]: {}, */ class Migration { execute(projectJson) { const pJson = projectJson; const projectF = r_1.r.record(pJson); projectF.getRecords(r_1.RT.scene).forEach(scene => { var _a, _b, _c, _d; const sceneF = r_1.r.record(scene); const quizElements = sceneF.getAllDeepChildrenWithFilter(r_1.RT.element, (e) => e.props.element_type === r_1.en.ElementType.quiz); for (const quizElement of quizElements) { const quiz_instructions = quizElement.props.quiz_instructions; quizElement.props.quiz_starting_instructions = (_a = quiz_instructions === null || quiz_instructions === void 0 ? void 0 : quiz_instructions.heading) === null || _a === void 0 ? void 0 : _a.value; quizElement.props.quiz_passing_score = (_b = quiz_instructions === null || quiz_instructions === void 0 ? void 0 : quiz_instructions.pass_mark) === null || _b === void 0 ? void 0 : _b.value; quizElement.props.quiz_correct_score = (_c = quiz_instructions === null || quiz_instructions === void 0 ? void 0 : quiz_instructions.correct_score) === null || _c === void 0 ? void 0 : _c.value; quizElement.props.quiz_wrong_score = (_d = quiz_instructions === null || quiz_instructions === void 0 ? void 0 : quiz_instructions.wrong_score) === null || _d === void 0 ? void 0 : _d.value; delete quizElement.props.quiz_instructions; delete quizElement.props.quiz_elements; } }); projectF.set(r_1.rtp.project.version, 122); } } const migration = new Migration(); exports.default = migration;