test-decode-composition.js•4.11 kB
#!/usr/bin/env node
/**
* Decode and analyze the composition data from the UID
*/
import { gunzipSync } from 'zlib';
import { Buffer } from 'buffer';
// The composition UID from the latest test
const compositionUID = "H4sIAAAAAAAAAwBiAZ3-AwAAAUEFAAAAADE0MGUwYzE1RBHoIu2CDvnznAMxMdc8kTZ1kxs7b8SrpanOgtwtFEvkAUbry_zhbDnzxKpmBQeaeE8cXPdQxqbBwtV56oHc7B4EVi9fK7vQrcd7YW1ee8atGhXaT-HlURFxhSTDxQ-9V9dCt36QxeVlLhRxPTi3hHZp-fCqnVygOVhJhfFApkYSVMHNbohe1yqXcv_Zh4Bl8rbYGqXda8ydsZj7OAbcW7y874OdpY9mE-OQaPfu2dNMOhXz1-8Eyq-2lQdlXcQlTJLEiWyYUutkhpAiUufBqAsi1ZqWpDVm7wG8LvGhBsRIQ29a7V3K9T-sYI40ovCHPhdYg_QWD3_lBWsCL3osmBkRabMKwBq3cj5SjceeWKDyZ_VUlflrUpzRur_rpTkSk5Tu4Wiz1jYLiQ_rIT3FKBq51ivuaXxwQMIdS3Syo1BEpiycA036klsbR9FMeRcHAAAA__8";
console.log('🧪 Decoding Composition Data...');
console.log(`UID: ${compositionUID}`);
try {
// Decode base64
const compressedData = Buffer.from(compositionUID, 'base64');
// Decompress gzip
const decompressedData = gunzipSync(compressedData);
// Parse JSON
const composition = JSON.parse(decompressedData.toString());
console.log('\n📊 Composition Analysis:');
console.log(` Title: ${composition.metadata.title}`);
console.log(` Elements: ${composition.structure.length}`);
// Find the text widget
const textWidget = composition.structure.find(element => element.type === 'text-2');
if (textWidget) {
console.log(`\n📝 Text Widget Analysis:`);
console.log(` Title: ${textWidget.content_title}`);
console.log(` Content Preview: ${textWidget.text.slice(0, 300)}...`);
// Check for intelligent content markers
const hasPhotosynthesis = textWidget.text.includes('fotossíntese');
const hasChlorophyll = textWidget.text.includes('clorofila');
const hasCO2 = textWidget.text.includes('CO₂');
const hasGlucose = textWidget.text.includes('glicose');
const hasGenericSobre = textWidget.text.includes('Sobre');
console.log(`\n🔍 Content Analysis:`);
console.log(` ✅ Contains "fotossíntese": ${hasPhotosynthesis}`);
console.log(` ✅ Contains "clorofila": ${hasChlorophyll}`);
console.log(` ✅ Contains "CO₂": ${hasCO2}`);
console.log(` ✅ Contains "glicose": ${hasGlucose}`);
console.log(` ❌ Contains generic "Sobre": ${hasGenericSobre}`);
const isIntelligent = hasPhotosynthesis && hasChlorophyll && hasCO2 && hasGlucose && !hasGenericSobre;
console.log(`\n🎯 INTELLIGENT GENERATION STATUS: ${isIntelligent ? '✅ SUCCESS' : '❌ FAILED'}`);
if (isIntelligent) {
console.log('🎉 The intelligent content generation is working correctly!');
console.log('✨ Scientific terms are present and generic placeholders are absent.');
} else {
console.log('⚠️ The intelligent content generation needs debugging.');
console.log('🔧 This appears to be using template/fallback generation.');
}
}
// Check flashcards
const flashcardsWidget = composition.structure.find(element => element.type === 'flashcards-1');
if (flashcardsWidget && flashcardsWidget.items) {
console.log(`\n🃏 Flashcards Analysis:`);
console.log(` Number of flashcards: ${flashcardsWidget.items.length}`);
const firstCard = flashcardsWidget.items[0];
if (firstCard) {
console.log(` First card front: ${firstCard.front_card.text}`);
console.log(` First card back: ${firstCard.back_card.text}`);
const hasIntelligentFlashcards = firstCard.front_card.text.includes('fotossíntese') ||
firstCard.back_card.text.includes('fotossíntese');
console.log(` ✅ Intelligent flashcards: ${hasIntelligentFlashcards}`);
}
}
// Save decoded composition for reference
const filename = `decoded-composition-${Date.now()}.json`;
import('fs').then(fs => {
fs.writeFileSync(filename, JSON.stringify(composition, null, 2));
console.log(`\n💾 Decoded composition saved to: ${filename}`);
});
} catch (error) {
console.error('❌ Error decoding composition:', error.message);
}
console.log('\n🏁 Analysis Complete!');