30 lines
892 B
TypeScript
30 lines
892 B
TypeScript
import { AnyTypedQuizQuestion } from "@/model/questionTypes";
|
|
|
|
export function extractImageLinksFromQuestion(question: AnyTypedQuizQuestion | null | undefined): string[] {
|
|
if (!question) return [];
|
|
|
|
const links: string[] = [];
|
|
|
|
if (question.type === "images") {
|
|
question.content.variants.forEach((variant) => {
|
|
if (variant.extendedText.startsWith("https://")) links.push(variant.extendedText);
|
|
});
|
|
}
|
|
|
|
if (question.type === "varimg") {
|
|
question.content.variants.forEach((variant) => {
|
|
if (variant.extendedText.startsWith("https://")) links.push(variant.extendedText);
|
|
});
|
|
}
|
|
|
|
if (question.type === "page") {
|
|
if (question.content.back?.startsWith("https://")) links.push(question.content.back);
|
|
}
|
|
|
|
if (question.type === "result") {
|
|
if (question.content.back?.startsWith("https://")) links.push(question.content.back);
|
|
}
|
|
|
|
return links;
|
|
}
|