Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 6x 644x 1437x 939x 706x | import { useBackend } from "main/utils/useBackend";
// Words whose branding does not follow plain title case.
const SPECIAL_CASE_WORDS = {
edudora: "EduDora",
catme: "CATME",
};
export function titleCaseFromOption(option) {
return option
.toLowerCase()
.split("_")
.map(
(word) =>
SPECIAL_CASE_WORDS[word] ??
word.charAt(0).toUpperCase() + word.slice(1),
)
.join(" ");
}
export function courseOptionsQueryKey(courseId) {
return `/api/course/options/?courseId=${courseId}`;
}
/**
* Fetch the map of course options (e.g. { TRANSLATE_SECTIONS: true, ... })
* for a course. All callers share the same query key, so toggling an option
* anywhere (e.g. on the Settings tab) refreshes every consumer.
*
* @param courseId id of the course
* @param options extra react-query options (e.g. { enabled: false })
*/
export function useCourseOptions(courseId, options = {}) {
return useBackend(
[courseOptionsQueryKey(courseId)],
{
// Stryker disable next-line StringLiteral : GET and "" are equivalent
method: "GET",
url: "/api/course/options",
params: { courseId },
},
{},
false,
options,
);
}
|