@@ -237,6 +237,68 @@ export async function registerSeedData(
237237 }
238238}
239239
240+ /**
241+ * Register BlanksCard (markdown fillIn) question type specifically
242+ */
243+ export async function registerBlanksCard (
244+ BlanksCard : any ,
245+ BlanksCardDataShapes : any [ ] ,
246+ courseConfig : CourseConfig ,
247+ courseDB : CourseDBInterface
248+ ) : Promise < { success : boolean ; errorMessage ?: string } > {
249+ try {
250+ console . log ( ' 📋 Registering BlanksCard data shapes and question type...' ) ;
251+
252+ let registeredCount = 0 ;
253+ const courseName = 'default' ; // BlanksCard comes from the default course
254+
255+ // Register BlanksCard data shapes
256+ for ( const dataShapeClass of BlanksCardDataShapes ) {
257+ const processedDataShape : ProcessedDataShape = {
258+ name : dataShapeClass . name ,
259+ course : courseName ,
260+ dataShape : dataShapeClass ,
261+ } ;
262+
263+ if ( registerDataShape ( processedDataShape , courseConfig ) ) {
264+ registeredCount ++ ;
265+ }
266+ }
267+
268+ // Register BlanksCard question type
269+ const processedQuestion : ProcessedQuestionData = {
270+ name : BlanksCard . name ,
271+ course : courseName ,
272+ questionClass : BlanksCard ,
273+ dataShapes : BlanksCardDataShapes ,
274+ views : BlanksCard . views || [ ] ,
275+ } ;
276+
277+ if ( registerQuestionType ( processedQuestion , courseConfig ) ) {
278+ registeredCount ++ ;
279+ }
280+
281+ // Update the course config in the database
282+ console . log ( ' 💾 Updating course configuration with BlanksCard...' ) ;
283+ const updateResult = await courseDB . updateCourseConfig ( courseConfig ) ;
284+
285+ if ( ! updateResult . ok ) {
286+ throw new Error ( `Failed to update course config: ${ JSON . stringify ( updateResult ) } ` ) ;
287+ }
288+
289+ // Register seed data if BlanksCard has any
290+ await registerSeedData ( processedQuestion , courseDB ) ;
291+
292+ console . log ( ` ✅ BlanksCard registration complete: ${ registeredCount } items registered` ) ;
293+
294+ return { success : true } ;
295+ } catch ( error ) {
296+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
297+ console . error ( ` ❌ BlanksCard registration failed: ${ errorMessage } ` ) ;
298+ return { success : false , errorMessage } ;
299+ }
300+ }
301+
240302/**
241303 * Main function to register all custom question types and data shapes
242304 */
0 commit comments