diff --git a/routes/create/controllers/h5pPreviewController.js b/routes/create/controllers/h5pPreviewController.js
index a2dac84..b412bc7 100644
--- a/routes/create/controllers/h5pPreviewController.js
+++ b/routes/create/controllers/h5pPreviewController.js
@@ -165,37 +165,13 @@ body { margin:0; padding:40px; font-family:-apple-system,BlinkMacSystemFont,"Seg
preloadedDependencies
};
- // Create a temp directory for this preview, copy needed library files
- const previewId = uuidv4();
- const extractDir = path.join(UPLOAD_BASE, previewId);
- await fs.mkdir(extractDir, { recursive: true });
-
- // Symlink ALL library dirs from h5p-libs into the temp directory.
- // This is instant (vs mergeDir copying thousands of files) and ensures
- // resolveDependencies finds transitive deps without triggering mergeDir.
- try {
- const libEntries = await fs.readdir(H5P_LIBS_DIR, { withFileTypes: true });
- for (const entry of libEntries) {
- if (entry.isDirectory()) {
- const src = path.join(H5P_LIBS_DIR, entry.name);
- const dest = path.join(extractDir, entry.name);
- try {
- await fs.symlink(src, dest, 'dir');
- } catch {
- // Already exists or other issue, skip
- }
- }
- }
- } catch {
- // h5p-libs dir not accessible
- }
+ // Resolve CSS/JS dependencies in correct load order.
+ // Read directly from h5p-libs (no temp dir or symlinks needed).
+ const { cssFiles, jsFiles } = await resolveLibraryDependencies(syntheticH5pJson);
- // Resolve CSS/JS dependencies in correct load order
- const { cssFiles, jsFiles } = await resolveDependencies(syntheticH5pJson, extractDir);
-
- const basePath = `/h5p-preview-files/${previewId}`;
- const cssTags = cssFiles.map(f => ` `).join('\n');
- const jsTags = jsFiles.map(f => ` `).join('\n');
+ const libBasePath = '/h5p-libs';
+ const cssTags = cssFiles.map(f => ` `).join('\n');
+ const jsTags = jsFiles.map(f => ` `).join('\n');
// Build per-question HTML blocks and H5P.newRunnable() calls
const questionBlocks = [];
@@ -221,7 +197,7 @@ body { margin:0; padding:40px; font-family:-apple-system,BlinkMacSystemFont,"Seg
var library = ${JSON.stringify(h5pContent)};
var $container = jQuery('#${containerId}');
$container.addClass('h5p-content');
- H5P.newRunnable(library, 'preview-${previewId}-${idx}', $container, false, {
+ H5P.newRunnable(library, 'preview-${quizId}-${idx}', $container, false, {
metadata: library.metadata || {}
});
})();`);
@@ -314,9 +290,6 @@ ${runnableCalls.join('\n')}