@caspingus/lt
Version:
A utility library of helpers and extensions useful when working with Learnosity APIs.
51 lines (50 loc) • 2.15 kB
JavaScript
import { r as e, t } from "../../extensionsFactory-hk5ijx1G.js";
//#region src/assessment/extensions/accessibility/ux/mcqLabelPrefix/index.js
var n = {
chosenMask: "upperAlpha",
logPrefix: "LRN MCQ Label Prefix:",
prefixMask: {
lowerAlpha: 97,
upperAlpha: 65,
numeric: 49
},
explicitPrefixes: [],
suffix: "."
};
function r(e) {
let { mask: r, suffix: a, prefixes: o } = e || {};
n.prefixMask.hasOwnProperty(r) && (n.chosenMask = r), a && typeof a == "string" && (n.suffix = a), o && Array.isArray(o) && (n.explicitPrefixes = o), t.eventBus.on("item:load", () => {
i(t.questions());
}, "mcqLabelPrefix");
}
function i(e) {
let r = n.prefixMask[n.chosenMask], i = n.suffix;
try {
for (let a of e) if (a.type === "mcq" && a?.ui_style?.type !== "block" && a?.ui_style?.type !== "horizontal-input-bottom") {
let e = a.response_id, o = document.getElementById(e).querySelectorAll(".lrn-mcq-option");
if (o) {
let e = 0;
for (let t of o) {
let a = t.querySelector(".lrn-possible-answer").children;
if (!t.querySelector(".lrn-prefix-label")) {
let t;
t = Array.isArray(n.explicitPrefixes) && n.explicitPrefixes.length && typeof n.explicitPrefixes[e] == "string" ? n.explicitPrefixes[e] : String.fromCharCode(r + e);
for (let e = 0; e < a.length; e++) {
let n = document.createElement("span");
n.classList.add("lrn-prefix-label"), n.append(`${t}${i}`), a[e].prepend(n);
}
e++;
}
}
} else t.utils.logger.warn(n.logPrefix, "Options element not found");
}
} catch (e) {
t.utils.logger.error(e);
}
}
function a() {
return "\n /* Learnosity MCQ label prefix styles */\n .lrn-prefix-label {\n padding-right: 15px;\n font-weight: 500;\n }\n @media (max-width: 750px) {\n .lrn-prefix-label {\n padding-right: 10px;\n }\n }\n @media (max-width: 650px) {\n .lrn-prefix-label {\n padding-right: 5px;\n }\n }\n ";
}
var o = e("mcqLabelPrefix", r, { getStyles: a });
//#endregion
export { o as mcqLabelPrefix };