Course Discussion Forum
with AI-Powered Teaching Assistant
AI Teaching Assistant
Hello! How can I help you with the course material today?
${answer}
`; submitAiQuestionBtn.disabled = false; }, 1500); // Simulate API call delay }; askAiBtn.addEventListener('click', openAIModal); closeAiModalBtn.addEventListener('click', closeAIModal); aiModalOverlay.addEventListener('click', (e) => { if (e.target === aiModalOverlay) closeAIModal(); }); submitAiQuestionBtn.addEventListener('click', handleAIQuestion); aiQuestionInput.addEventListener('keyup', (e) => { if (e.key === 'Enter') handleAIQuestion(); }); // --- Core Forum Render Functions (largely unchanged) --- const renderAllDiscussions = () => { discussionThreads.sort((a, b) => b.pinned - a.pinned); mainContent.innerHTML = `
${discussionThreads.map(thread => `
${thread.pinned ? `PINNED` : ''}
`).join('')}
`;
};
const renderNewPostForm = () => {
mainContent.innerHTML = `
${thread.title}
Posted by ${thread.author} • ${thread.timestamp} • ${thread.replies} replies
${isTeachingAssistant ? `
` : ''}
${thread.title}
Posted by ${thread.author} on ${thread.timestamp}
${thread.content}
Replies (${thread.replies})
${thread.replyList.map(reply => `
${isTeachingAssistant ? `
` : (thread.bestAnswer === reply.id ? `BEST ANSWER` : '')}
`).join('')}
${reply.content}
By ${reply.author} • ${reply.timestamp}
Add Your Reply
${isBest ? '
`;
}).join('');
const aiSectionHtml = lastAIInteraction ? `
BEST ANSWER
' : ''}${reply.content}
— ${reply.author}, ${reply.timestamp}
AI Assistant Interaction
Your Question: ${lastAIInteraction.question}
AI Answer: ${lastAIInteraction.answer}
${thread.pinned ? '
PINNED DISCUSSION
' : ''}${thread.title}
Posted by ${thread.author} • Report generated on ${date}
Original Post
${thread.content}
Replies
${repliesHtml || 'No replies yet.
'}