diff --git a/extension/shared/dossier-compiler.cjs b/extension/shared/dossier-compiler.cjs index 1ded244..9c42d30 100644 --- a/extension/shared/dossier-compiler.cjs +++ b/extension/shared/dossier-compiler.cjs @@ -6,35 +6,38 @@ 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`; + const md = []; + md.push(`# idstack Instructional Design Audit: ${title}\n\n`); + md.push(`> **Audited Component:** ${pageType} \n`); + if (url) md.push(`> **Source URL:** [${url}](${url}) \n`); + md.push(`> **Date:** ${timestamp} \n`); + md.push(`> **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`; + md.push(`## Executive Summary\n\n`); + md.push(`- **Bloom's Demand:** ${result.summary?.bloomsLevel || 'N/A'}\n`); + md.push(`- **Constructive Alignment:** ${result.summary?.alignmentScore || 'N/A'}\n`); + md.push(`- **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`; - }); + md.push(`## Evidence-Based Findings & Recommendations\n\n`); + md.push(result.findings.map((f, idx) => { + const fLines = []; + fLines.push(`### ${idx + 1}. [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n\n`); + fLines.push(`- **Severity:** \`${(f.severity || 'info').toUpperCase()}\`\n`); + fLines.push(`- **Observation:** ${f.observation || ''}\n`); + fLines.push(`- **Empirical Evidence:** ${f.evidence || ''}\n`); + fLines.push(`- **Actionable Recommendation:** ${f.recommendation || ''}\n\n`); + return fLines.join(''); + }).join('')); } if (result.improvedDraft && result.improvedDraft.content) { - md += `## ${result.improvedDraft.title || 'Improved Draft & Alignment Matrix'}\n\n`; - md += `${result.improvedDraft.content}\n\n`; + md.push(`## ${result.improvedDraft.title || 'Improved Draft & Alignment Matrix'}\n\n`); + md.push(`${result.improvedDraft.content}\n\n`); } - md += `---\n*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`; - return md; + md.push(`---\n*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`); + return md.join(''); } function compileDossierToMarkdown(dossierItems, courseTitle = 'Canvas Course') { @@ -43,51 +46,56 @@ 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`; + const md = []; + md.push(`# idstack Course Audit Dossier: ${courseTitle}\n\n`); + md.push(`> **Course:** ${courseTitle} \n`); + md.push(`> **Total Audited Materials:** ${dossierItems.length} components \n`); + md.push(`> **Compiled Date:** ${timestamp} \n`); + md.push(`> **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) => { + md.push(`## Table of Audited Materials\n\n`); + md.push(`| # | Component Title | Type | Bloom's Demand | Alignment Score |\n`); + md.push(`| :--- | :--- | :--- | :--- | :--- |\n`); + md.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('')); + md.push(`\n---\n\n`); - 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`; + md.push(dossierItems.map((item, idx) => { + const section = []; + section.push(`## Section ${idx + 1}: ${item.title || 'Component'}\n\n`); + section.push(`> **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`; + section.push(`### Summary\n`); + section.push(`- **Cognitive Demand:** ${r.summary?.bloomsLevel || 'N/A'}\n`); + section.push(`- **Alignment Rating:** ${r.summary?.alignmentScore || 'N/A'}\n`); + section.push(`- **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`; - }); + section.push(`### Findings & Evidence\n\n`); + section.push(r.findings.map((f, fIdx) => { + const fLines = []; + fLines.push(`#### ${idx + 1}.${fIdx + 1} [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n`); + fLines.push(`- **Observation:** ${f.observation || ''}\n`); + fLines.push(`- **Evidence:** ${f.evidence || ''}\n`); + fLines.push(`- **Recommendation:** ${f.recommendation || ''}\n\n`); + return fLines.join(''); + }).join('')); } if (r.improvedDraft && r.improvedDraft.content) { - md += `### ${r.improvedDraft.title || 'Revised Draft'}\n\n`; - md += `${r.improvedDraft.content}\n\n`; + section.push(`### ${r.improvedDraft.title || 'Revised Draft'}\n\n`); + section.push(`${r.improvedDraft.content}\n\n`); } - md += `---\n\n`; - }); + section.push(`---\n\n`); + return section.join(''); + }).join('')); - md += `*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`; - return md; + md.push(`*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`); + return md.join(''); } module.exports = { diff --git a/extension/shared/dossier-compiler.js b/extension/shared/dossier-compiler.js index eec4742..398ee4c 100644 --- a/extension/shared/dossier-compiler.js +++ b/extension/shared/dossier-compiler.js @@ -6,35 +6,38 @@ 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`; + const md = []; + md.push(`# idstack Instructional Design Audit: ${title}\n\n`); + md.push(`> **Audited Component:** ${pageType} \n`); + if (url) md.push(`> **Source URL:** [${url}](${url}) \n`); + md.push(`> **Date:** ${timestamp} \n`); + md.push(`> **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`; + md.push(`## Executive Summary\n\n`); + md.push(`- **Bloom's Demand:** ${result.summary?.bloomsLevel || 'N/A'}\n`); + md.push(`- **Constructive Alignment:** ${result.summary?.alignmentScore || 'N/A'}\n`); + md.push(`- **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`; - }); + md.push(`## Evidence-Based Findings & Recommendations\n\n`); + md.push(result.findings.map((f, idx) => { + const fLines = []; + fLines.push(`### ${idx + 1}. [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n\n`); + fLines.push(`- **Severity:** \`${(f.severity || 'info').toUpperCase()}\`\n`); + fLines.push(`- **Observation:** ${f.observation || ''}\n`); + fLines.push(`- **Empirical Evidence:** ${f.evidence || ''}\n`); + fLines.push(`- **Actionable Recommendation:** ${f.recommendation || ''}\n\n`); + return fLines.join(''); + }).join('')); } if (result.improvedDraft && result.improvedDraft.content) { - md += `## ${result.improvedDraft.title || 'Improved Draft & Alignment Matrix'}\n\n`; - md += `${result.improvedDraft.content}\n\n`; + md.push(`## ${result.improvedDraft.title || 'Improved Draft & Alignment Matrix'}\n\n`); + md.push(`${result.improvedDraft.content}\n\n`); } - md += `---\n*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`; - return md; + md.push(`---\n*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`); + return md.join(''); } export function compileDossierToMarkdown(dossierItems, courseTitle = 'Canvas Course') { @@ -43,49 +46,54 @@ 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`; + const md = []; + md.push(`# idstack Course Audit Dossier: ${courseTitle}\n\n`); + md.push(`> **Course:** ${courseTitle} \n`); + md.push(`> **Total Audited Materials:** ${dossierItems.length} components \n`); + md.push(`> **Compiled Date:** ${timestamp} \n`); + md.push(`> **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) => { + md.push(`## Table of Audited Materials\n\n`); + md.push(`| # | Component Title | Type | Bloom's Demand | Alignment Score |\n`); + md.push(`| :--- | :--- | :--- | :--- | :--- |\n`); + md.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('')); + md.push(`\n---\n\n`); - 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`; + md.push(dossierItems.map((item, idx) => { + const section = []; + section.push(`## Section ${idx + 1}: ${item.title || 'Component'}\n\n`); + section.push(`> **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`; + section.push(`### Summary\n`); + section.push(`- **Cognitive Demand:** ${r.summary?.bloomsLevel || 'N/A'}\n`); + section.push(`- **Alignment Rating:** ${r.summary?.alignmentScore || 'N/A'}\n`); + section.push(`- **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`; - }); + section.push(`### Findings & Evidence\n\n`); + section.push(r.findings.map((f, fIdx) => { + const fLines = []; + fLines.push(`#### ${idx + 1}.${fIdx + 1} [${f.tier || 'T1'}] ${f.citation || 'Citation'}\n`); + fLines.push(`- **Observation:** ${f.observation || ''}\n`); + fLines.push(`- **Evidence:** ${f.evidence || ''}\n`); + fLines.push(`- **Recommendation:** ${f.recommendation || ''}\n\n`); + return fLines.join(''); + }).join('')); } if (r.improvedDraft && r.improvedDraft.content) { - md += `### ${r.improvedDraft.title || 'Revised Draft'}\n\n`; - md += `${r.improvedDraft.content}\n\n`; + section.push(`### ${r.improvedDraft.title || 'Revised Draft'}\n\n`); + section.push(`${r.improvedDraft.content}\n\n`); } - md += `---\n\n`; - }); + section.push(`---\n\n`); + return section.join(''); + }).join('')); - md += `*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`; - return md; + md.push(`*Generated by [idstack](https://github.com/savvides/idstack) — Evidence-Based Course Design.*`); + return md.join(''); }