Skip to content

Weekly summaries for professors#466

Open
MithishR wants to merge 15 commits intomainfrom
mithish/309-weekly-summaries
Open

Weekly summaries for professors#466
MithishR wants to merge 15 commits intomainfrom
mithish/309-weekly-summaries

Conversation

@MithishR
Copy link
Collaborator

@MithishR MithishR commented Jan 24, 2026

Description

This PR implements automated weekly email summaries sent to professors every week with detailed usage statistics for all their HelpMe courses. Each professor receives a single consolidated email covering all courses they teach.

Features Included:

  • Chatbot Activity: Total questions, unique students, daily breakdown.
  • Async Questions: Total, AI-resolved, staff-answered, pending questions, and average response time
  • Most Active Days: Visual breakdown of queue activity by day of week
  • Peak Hours: Identification of busiest times
  • New Students: List of students who joined in the past week.
  • Top Active Students: Top 5 students by questions asked
  • Staff Performance: Questions helped per staff member with average help times
  • Recommendations: Automated suggestions based on activity patterns (e.g., high wait times, low engagement)
  • Archive Suggestions: Alerts for courses with no activity in 4 weeks

Closes: #309

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This requires a run of yarn install
  • This change requires an addition/change to the production .env variables. These changes are below:
  • This change requires developers to add new .env variables. The file and variables needed are below:
  • This change requires a database query to update old data on production. This query is below:

How Has This Been Tested?

  • Tested the cron job by running it EVERY_MINUTE to check if it works and check the content.
  • Tested email generation with sample course data
  • Tested cases with courses no activity, single type of activity, professors with multiple courses.
  • Confirmed new student identification and display.

Testing instructions:

  • Change the cron job to run EVERY_MINUTE to see if it works.
  • Check the sent email logs for email generation and verify the email content.
  • Add a test seed data for a new student to test a new student joining the course.
  • Simulate asking questions using the seed student accounts and getting them answered using the seed TA accounts, the data will be fetched and shown in the email accordingly.

Checklist:

  • I have performed a code review of my own code (under the "Files Changed" tab on github) to ensure nothing is committed that shouldn't be (e.g. leftover console.logs, leftover unused logic, or anything else that was accidentally committed)
  • I have commented my code where needed
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing tests pass locally with my changes
  • Any work that this PR is dependent on has been merged into the main branch
  • Any UI changes have been checked to work on desktop, tablet, and mobile

Sample screenshots:
image
image

@MithishR MithishR self-assigned this Jan 24, 2026
@MithishR MithishR marked this pull request as ready for review February 14, 2026 21:54
Copy link
Collaborator

@AdamFipke AdamFipke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start! I haven't yet ran the code just yet. Some initial feedback in comments

<hr style="border: 1px solid #ecf0f1; margin: 30px 0;">
<p style="color: #95a5a6; font-size: 12px; text-align: center;">
Weekly summary from HelpMe.<br>
Manage your email preferences in settings.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a link to the page here. Also, did you test that you can actually disable the emails under course preferences?

if (queueStats.totalQuestions > 0 && queueStats.totalQuestions < 5) {
recommendations.push({
type: 'info',
message: 'Queue usage is low. Consider reminding students about office hours availability.',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most queues are not office hours and there isn't really a good way to tell. I would probably just remove this suggestion

<ul style="line-height: 1.8; color: #34495e;">
<li><strong>${chatbotStats.totalQuestions}</strong> questions asked by <strong>${chatbotStats.uniqueStudents}</strong> unique student${chatbotStats.uniqueStudents !== 1 ? 's' : ''}</li>
<li>Average: <strong>${chatbotStats.avgQuestionsPerStudent.toFixed(1)}</strong> questions per student</li>
<li>Most active day: <strong>${chatbotStats.mostActiveDay}</strong></li>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most active day won't be needed if there's a chart that already showcases that

<li><strong>${asyncStats.total}</strong> total questions</li>
<li><strong style="color: #27ae60;">${asyncStats.aiResolved}</strong> resolved by AI</li>
<li><strong style="color: #3498db;">${asyncStats.humanAnswered}</strong> answered by staff</li>
<li><strong style="color: #e74c3c;">${asyncStats.stillNeedHelp}</strong> still need help</li>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the async questions that still need help include those from previous weeks? Since it should.

Even better, if there are any async questions that are older than 1 week, it should probably highlight those. Saying something like:

<a href="/course/34/async_centre">Anytime Questions</a> older than 1 week that still need help  
- "Need help on Lab 3 question 2..." - 10 days ago
- "I don't understand abstraction I n...." - 68 days ago

And I would probably make it bold and red. You could also include it in the Recommendations section, but that might just result in a lot of duplicate text (which is bad, 'cause people don't read)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this goes for async questions that still need help that are younger than 1 week; I would display a list of the async questions with their abstract with how many days ago it was posted. Or maybe even just have 1 consolidated list of all async questions that still need help, their abstracts, and how many days ago it was posted.

if (asyncStats.stillNeedHelp > 0) {
recommendations.push({
type: 'warning',
message: `${asyncStats.stillNeedHelp} async question${asyncStats.stillNeedHelp !== 1 ? 's' : ''} still need${asyncStats.stillNeedHelp === 1 ? 's' : ''} attention from staff.`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would just remove this one. It's a good idea but another part of the email already mentions how many anytime questions still need help.

constructor(private mailService: MailService) {}

// Run every week
@Cron(CronExpression.EVERY_WEEK)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is every week; what day does it start on? I've given it some more thought, and probably sending it out on Sunday morning might be better (in the original issue I said Monday), though in truth it probably doesn't matter all that much

// Run every week
@Cron(CronExpression.EVERY_WEEK)
async sendWeeklySummaries() {
console.log('Starting weekly summary email job...');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • "I have performed a code review of my own code (under the "Files Changed" tab on github) to ensure nothing is committed that shouldn't be (e.g. leftover console.logs, leftover unused logic, or anything else that was accidentally committed)"
Image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oopsies my bad :(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha it's all good i'm just buggin ya

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha it's all good i'm just buggin ya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weekly Summaries for Professors

2 participants