55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import type { DebugPublishMeta } from '../../utils/debugPublish';
|
|
import { inferGradeFromAge } from '../../utils/debugPublish';
|
|
import { CLOCK_READING_WORKSHEET_DEFINITIONS } from '../../config/worksheets/clockReading';
|
|
import {
|
|
CLOCK_TIME_MODE_OPTIONS,
|
|
type ClockReadingTimeMode,
|
|
} from './generators/clock-generator';
|
|
|
|
export { CLOCK_READING_WORKSHEET_DEFINITIONS };
|
|
|
|
export type { ClockReadingTimeMode };
|
|
|
|
type ClockReadingWorksheetRow =
|
|
(typeof CLOCK_READING_WORKSHEET_DEFINITIONS)[number];
|
|
|
|
const CLOCK_READING_WORKSHEET_BY_ID = Object.fromEntries(
|
|
CLOCK_READING_WORKSHEET_DEFINITIONS.map((m) => [m.id, m]),
|
|
) as Record<string, ClockReadingWorksheetRow>;
|
|
|
|
export const CLOCK_READING_MODE_OPTIONS = CLOCK_READING_WORKSHEET_DEFINITIONS;
|
|
|
|
export { CLOCK_TIME_MODE_OPTIONS };
|
|
|
|
export function getModeInfo(id: string) {
|
|
const m = CLOCK_READING_WORKSHEET_BY_ID[id];
|
|
return m ? { title: m.title, desc: m.subtitle } : undefined;
|
|
}
|
|
|
|
export function isValidMode(id: string): boolean {
|
|
return id in CLOCK_READING_WORKSHEET_BY_ID;
|
|
}
|
|
|
|
export function getPublishMetaByMode(id: string): DebugPublishMeta | null {
|
|
const m = CLOCK_READING_WORKSHEET_BY_ID[id];
|
|
if (!m) return null;
|
|
return {
|
|
id: m.id,
|
|
title: m.title,
|
|
subtitle: m.subtitle,
|
|
category: 'math',
|
|
subcategory: 'clock-reading',
|
|
path: `/mathPages/clockReading/clockReading?id=${m.id}`,
|
|
ageMin: m.ageMin,
|
|
ageMax: m.ageMax,
|
|
grade: inferGradeFromAge(m.ageMin, m.ageMax),
|
|
difficulty: m.difficulty,
|
|
previewImg: '',
|
|
tags: [...m.tags],
|
|
isNew: false,
|
|
isHot: false,
|
|
sortOrder: m.sortOrder,
|
|
status: 'draft',
|
|
};
|
|
}
|