diff --git a/extension/shared/dossier-compiler.cjs b/extension/shared/dossier-compiler.cjs index 1ded244..39364f5 100644 --- a/extension/shared/dossier-compiler.cjs +++ b/extension/shared/dossier-compiler.cjs @@ -6,35 +6,40 @@ function compileSingleAuditToMarkdown(item) { const url = item.url || ''; const timestamp = (item.timestamp ? new Date(item.timestamp) : new Date()).toLocaleString(); - let md = `# idstack Instructional Design Audit: ${title}\n\n`; - md += `> **Audited Component:** ${pageType} \n`; - if (url) md += `> **Source URL:** [${url}](${url}) \n`; - md += `> **Date:** ${timestamp} \n`; - md += `> **Evaluator:** idstack Evidence-Based Course Design Engine (Manifest V3)\n\n`; - - md += `## Executive Summary\n\n`; - md += `- **Bloom's Demand:** ${result.summary?.bloomsLevel || 'N/A'}\n`; - md += `- **Constructive Alignment:** ${result.summary?.alignmentScore || 'N/A'}\n`; - md += `- **Key Takeaway:** ${result.summary?.keyTakeaway || 'No summary provided.'}\n\n`; + let mdParts = [ + `# idstack Instructional Design Audit: ${title}\n\n`, + `> **Audited Component:** ${pageType} \n` + ]; + if (url) mdParts.push(`> **Source URL:** [${url}](${url}) \n`); + mdParts.push( + `> **Date:** ${timestamp} \n`, + `> **Evaluator:** idstack Evidence-Based Course Design Engine (Manifest V3)\n\n`, + `## Executive Summary\n\n`, + `- **Bloom's Demand:** ${result.summary?.bloomsLevel || 'N/A'}\n`, + `- **Constructive Alignment:** ${result.summary?.alignmentScore || 'N/A'}\n`, + `- **Key Takeaway:** ${result.summary?.keyTakeaway || 'No summary provided.'}\n\n` + ); if (Array.isArray(result.findings) && result.findings.length > 0) { - md += `## Evidence-Based Findings & Recommendations\n\n`; - result.findings.forEach((f, idx) => { - md += `### ${idx + 1}. [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n\n`; - md += `- **Severity:** \`${(f.severity || 'info').toUpperCase()}\`\n`; - md += `- **Observation:** ${f.observation || ''}\n`; - md += `- **Empirical Evidence:** ${f.evidence || ''}\n`; - md += `- **Actionable Recommendation:** ${f.recommendation || ''}\n\n`; - }); + mdParts.push(`## Evidence-Based Findings & Recommendations\n\n`); + mdParts.push(result.findings.map((f, idx) => { + return `### ${idx + 1}. [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n\n` + + `- **Severity:** \`${(f.severity || 'info').toUpperCase()}\`\n` + + `- **Observation:** ${f.observation || ''}\n` + + `- **Empirical Evidence:** ${f.evidence || ''}\n` + + `- **Actionable Recommendation:** ${f.recommendation || ''}\n\n`; + }).join('')); } if (result.improvedDraft && result.improvedDraft.content) { - md += `## ${result.improvedDraft.title || 'Improved Draft & Alignment Matrix'}\n\n`; - md += `${result.improvedDraft.content}\n\n`; + mdParts.push( + `## ${result.improvedDraft.title || 'Improved Draft & Alignment Matrix'}\n\n`, + `${result.improvedDraft.content}\n\n` + ); } - md += `---\n*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`; - return md; + mdParts.push(`---\n*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`); + return mdParts.join(''); } function compileDossierToMarkdown(dossierItems, courseTitle = 'Canvas Course') { @@ -43,51 +48,63 @@ function compileDossierToMarkdown(dossierItems, courseTitle = 'Canvas Course') { } const timestamp = new Date().toLocaleString(); - let md = `# idstack Course Audit Dossier: ${courseTitle}\n\n`; - md += `> **Course:** ${courseTitle} \n`; - md += `> **Total Audited Materials:** ${dossierItems.length} components \n`; - md += `> **Compiled Date:** ${timestamp} \n`; - md += `> **Engine:** idstack Evidence-Based Instructional Design Co-Pilot\n\n`; - - md += `## Table of Audited Materials\n\n`; - md += `| # | Component Title | Type | Bloom's Demand | Alignment Score |\n`; - md += `| :--- | :--- | :--- | :--- | :--- |\n`; - dossierItems.forEach((item, idx) => { + + let mdParts = [ + `# idstack Course Audit Dossier: ${courseTitle}\n\n`, + `> **Course:** ${courseTitle} \n`, + `> **Total Audited Materials:** ${dossierItems.length} components \n`, + `> **Compiled Date:** ${timestamp} \n`, + `> **Engine:** idstack Evidence-Based Instructional Design Co-Pilot\n\n`, + `## Table of Audited Materials\n\n`, + `| # | Component Title | Type | Bloom's Demand | Alignment Score |\n`, + `| :--- | :--- | :--- | :--- | :--- |\n` + ]; + + mdParts.push(dossierItems.map((item, idx) => { const s = item.result?.summary || {}; - md += `| ${idx + 1} | ${item.title || 'Untitled'} | ${item.pageType || 'Page'} | ${s.bloomsLevel || 'N/A'} | ${s.alignmentScore || 'N/A'} |\n`; - }); - md += `\n---\n\n`; + return `| ${idx + 1} | ${item.title || 'Untitled'} | ${item.pageType || 'Page'} | ${s.bloomsLevel || 'N/A'} | ${s.alignmentScore || 'N/A'} |\n`; + }).join('')); - dossierItems.forEach((item, idx) => { - md += `## Section ${idx + 1}: ${item.title || 'Component'}\n\n`; - md += `> **Type:** ${item.pageType || 'Page'} | **Source:** ${item.url || 'N/A'}\n\n`; + mdParts.push(`\n---\n\n`); + + mdParts.push(dossierItems.map((item, idx) => { + let sectionParts = [ + `## Section ${idx + 1}: ${item.title || 'Component'}\n\n`, + `> **Type:** ${item.pageType || 'Page'} | **Source:** ${item.url || 'N/A'}\n\n` + ]; const r = item.result || {}; - md += `### Summary\n`; - md += `- **Cognitive Demand:** ${r.summary?.bloomsLevel || 'N/A'}\n`; - md += `- **Alignment Rating:** ${r.summary?.alignmentScore || 'N/A'}\n`; - md += `- **Takeaway:** ${r.summary?.keyTakeaway || 'N/A'}\n\n`; + sectionParts.push( + `### Summary\n`, + `- **Cognitive Demand:** ${r.summary?.bloomsLevel || 'N/A'}\n`, + `- **Alignment Rating:** ${r.summary?.alignmentScore || 'N/A'}\n`, + `- **Takeaway:** ${r.summary?.keyTakeaway || 'N/A'}\n\n` + ); if (Array.isArray(r.findings) && r.findings.length > 0) { - md += `### Findings & Evidence\n\n`; - r.findings.forEach((f, fIdx) => { - md += `#### ${idx + 1}.${fIdx + 1} [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n`; - md += `- **Observation:** ${f.observation || ''}\n`; - md += `- **Evidence:** ${f.evidence || ''}\n`; - md += `- **Recommendation:** ${f.recommendation || ''}\n\n`; - }); + sectionParts.push(`### Findings & Evidence\n\n`); + sectionParts.push(r.findings.map((f, fIdx) => { + return `#### ${idx + 1}.${fIdx + 1} [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n` + + `- **Observation:** ${f.observation || ''}\n` + + `- **Evidence:** ${f.evidence || ''}\n` + + `- **Recommendation:** ${f.recommendation || ''}\n\n`; + }).join('')); } if (r.improvedDraft && r.improvedDraft.content) { - md += `### ${r.improvedDraft.title || 'Revised Draft'}\n\n`; - md += `${r.improvedDraft.content}\n\n`; + sectionParts.push( + `### ${r.improvedDraft.title || 'Revised Draft'}\n\n`, + `${r.improvedDraft.content}\n\n` + ); } - md += `---\n\n`; - }); + sectionParts.push(`---\n\n`); + return sectionParts.join(''); + }).join('')); + + mdParts.push(`*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`); - md += `*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`; - return md; + return mdParts.join(''); } module.exports = { diff --git a/extension/shared/dossier-compiler.js b/extension/shared/dossier-compiler.js index eec4742..8b1280f 100644 --- a/extension/shared/dossier-compiler.js +++ b/extension/shared/dossier-compiler.js @@ -6,35 +6,40 @@ export function compileSingleAuditToMarkdown(item) { const url = item.url || ''; const timestamp = (item.timestamp ? new Date(item.timestamp) : new Date()).toLocaleString(); - let md = `# idstack Instructional Design Audit: ${title}\n\n`; - md += `> **Audited Component:** ${pageType} \n`; - if (url) md += `> **Source URL:** [${url}](${url}) \n`; - md += `> **Date:** ${timestamp} \n`; - md += `> **Evaluator:** idstack Evidence-Based Course Design Engine (Manifest V3)\n\n`; - - md += `## Executive Summary\n\n`; - md += `- **Bloom's Demand:** ${result.summary?.bloomsLevel || 'N/A'}\n`; - md += `- **Constructive Alignment:** ${result.summary?.alignmentScore || 'N/A'}\n`; - md += `- **Key Takeaway:** ${result.summary?.keyTakeaway || 'No summary provided.'}\n\n`; + let mdParts = [ + `# idstack Instructional Design Audit: ${title}\n\n`, + `> **Audited Component:** ${pageType} \n` + ]; + if (url) mdParts.push(`> **Source URL:** [${url}](${url}) \n`); + mdParts.push( + `> **Date:** ${timestamp} \n`, + `> **Evaluator:** idstack Evidence-Based Course Design Engine (Manifest V3)\n\n`, + `## Executive Summary\n\n`, + `- **Bloom's Demand:** ${result.summary?.bloomsLevel || 'N/A'}\n`, + `- **Constructive Alignment:** ${result.summary?.alignmentScore || 'N/A'}\n`, + `- **Key Takeaway:** ${result.summary?.keyTakeaway || 'No summary provided.'}\n\n` + ); if (Array.isArray(result.findings) && result.findings.length > 0) { - md += `## Evidence-Based Findings & Recommendations\n\n`; - result.findings.forEach((f, idx) => { - md += `### ${idx + 1}. [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n\n`; - md += `- **Severity:** \`${(f.severity || 'info').toUpperCase()}\`\n`; - md += `- **Observation:** ${f.observation || ''}\n`; - md += `- **Empirical Evidence:** ${f.evidence || ''}\n`; - md += `- **Actionable Recommendation:** ${f.recommendation || ''}\n\n`; - }); + mdParts.push(`## Evidence-Based Findings & Recommendations\n\n`); + mdParts.push(result.findings.map((f, idx) => { + return `### ${idx + 1}. [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n\n` + + `- **Severity:** \`${(f.severity || 'info').toUpperCase()}\`\n` + + `- **Observation:** ${f.observation || ''}\n` + + `- **Empirical Evidence:** ${f.evidence || ''}\n` + + `- **Actionable Recommendation:** ${f.recommendation || ''}\n\n`; + }).join('')); } if (result.improvedDraft && result.improvedDraft.content) { - md += `## ${result.improvedDraft.title || 'Improved Draft & Alignment Matrix'}\n\n`; - md += `${result.improvedDraft.content}\n\n`; + mdParts.push( + `## ${result.improvedDraft.title || 'Improved Draft & Alignment Matrix'}\n\n`, + `${result.improvedDraft.content}\n\n` + ); } - md += `---\n*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`; - return md; + mdParts.push(`---\n*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`); + return mdParts.join(''); } export function compileDossierToMarkdown(dossierItems, courseTitle = 'Canvas Course') { @@ -43,49 +48,61 @@ export function compileDossierToMarkdown(dossierItems, courseTitle = 'Canvas Cou } const timestamp = new Date().toLocaleString(); - let md = `# idstack Course Audit Dossier: ${courseTitle}\n\n`; - md += `> **Course:** ${courseTitle} \n`; - md += `> **Total Audited Materials:** ${dossierItems.length} components \n`; - md += `> **Compiled Date:** ${timestamp} \n`; - md += `> **Engine:** idstack Evidence-Based Instructional Design Co-Pilot\n\n`; - - md += `## Table of Audited Materials\n\n`; - md += `| # | Component Title | Type | Bloom's Demand | Alignment Score |\n`; - md += `| :--- | :--- | :--- | :--- | :--- |\n`; - dossierItems.forEach((item, idx) => { + + let mdParts = [ + `# idstack Course Audit Dossier: ${courseTitle}\n\n`, + `> **Course:** ${courseTitle} \n`, + `> **Total Audited Materials:** ${dossierItems.length} components \n`, + `> **Compiled Date:** ${timestamp} \n`, + `> **Engine:** idstack Evidence-Based Instructional Design Co-Pilot\n\n`, + `## Table of Audited Materials\n\n`, + `| # | Component Title | Type | Bloom's Demand | Alignment Score |\n`, + `| :--- | :--- | :--- | :--- | :--- |\n` + ]; + + mdParts.push(dossierItems.map((item, idx) => { const s = item.result?.summary || {}; - md += `| ${idx + 1} | ${item.title || 'Untitled'} | ${item.pageType || 'Page'} | ${s.bloomsLevel || 'N/A'} | ${s.alignmentScore || 'N/A'} |\n`; - }); - md += `\n---\n\n`; + return `| ${idx + 1} | ${item.title || 'Untitled'} | ${item.pageType || 'Page'} | ${s.bloomsLevel || 'N/A'} | ${s.alignmentScore || 'N/A'} |\n`; + }).join('')); - dossierItems.forEach((item, idx) => { - md += `## Section ${idx + 1}: ${item.title || 'Component'}\n\n`; - md += `> **Type:** ${item.pageType || 'Page'} | **Source:** ${item.url || 'N/A'}\n\n`; + mdParts.push(`\n---\n\n`); + + mdParts.push(dossierItems.map((item, idx) => { + let sectionParts = [ + `## Section ${idx + 1}: ${item.title || 'Component'}\n\n`, + `> **Type:** ${item.pageType || 'Page'} | **Source:** ${item.url || 'N/A'}\n\n` + ]; const r = item.result || {}; - md += `### Summary\n`; - md += `- **Cognitive Demand:** ${r.summary?.bloomsLevel || 'N/A'}\n`; - md += `- **Alignment Rating:** ${r.summary?.alignmentScore || 'N/A'}\n`; - md += `- **Takeaway:** ${r.summary?.keyTakeaway || 'N/A'}\n\n`; + sectionParts.push( + `### Summary\n`, + `- **Cognitive Demand:** ${r.summary?.bloomsLevel || 'N/A'}\n`, + `- **Alignment Rating:** ${r.summary?.alignmentScore || 'N/A'}\n`, + `- **Takeaway:** ${r.summary?.keyTakeaway || 'N/A'}\n\n` + ); if (Array.isArray(r.findings) && r.findings.length > 0) { - md += `### Findings & Evidence\n\n`; - r.findings.forEach((f, fIdx) => { - md += `#### ${idx + 1}.${fIdx + 1} [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n`; - md += `- **Observation:** ${f.observation || ''}\n`; - md += `- **Evidence:** ${f.evidence || ''}\n`; - md += `- **Recommendation:** ${f.recommendation || ''}\n\n`; - }); + sectionParts.push(`### Findings & Evidence\n\n`); + sectionParts.push(r.findings.map((f, fIdx) => { + return `#### ${idx + 1}.${fIdx + 1} [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n` + + `- **Observation:** ${f.observation || ''}\n` + + `- **Evidence:** ${f.evidence || ''}\n` + + `- **Recommendation:** ${f.recommendation || ''}\n\n`; + }).join('')); } if (r.improvedDraft && r.improvedDraft.content) { - md += `### ${r.improvedDraft.title || 'Revised Draft'}\n\n`; - md += `${r.improvedDraft.content}\n\n`; + sectionParts.push( + `### ${r.improvedDraft.title || 'Revised Draft'}\n\n`, + `${r.improvedDraft.content}\n\n` + ); } - md += `---\n\n`; - }); + sectionParts.push(`---\n\n`); + return sectionParts.join(''); + }).join('')); + + mdParts.push(`*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`); - md += `*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`; - return md; + return mdParts.join(''); }