Skip to content

Commit

Permalink
courses: add participants export (fixes #7815) (#7817)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <dogi@users.noreply.github.com>
  • Loading branch information
jessewashburn and dogi authored Nov 21, 2024
1 parent 2f11105 commit c59e1a3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.15.61",
"version": "0.15.62",
"myplanet": {
"latest": "v0.21.4",
"min": "v0.20.4"
Expand Down
3 changes: 3 additions & 0 deletions src/app/courses/enroll-courses/courses-enroll.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<mat-toolbar class="primary-color font-size-1">
{{ course }}
<span class="toolbar-fill"></span>
<button mat-raised-button color="accent" (click)="exportCSV()">
Export
</button>
</mat-toolbar>

<ng-container *ngIf="!emptyData; else notFoundMessage">
Expand Down
22 changes: 21 additions & 1 deletion src/app/courses/enroll-courses/courses-enroll.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { TableState } from '../../users/users-table.component';
import { StateService } from '../../shared/state.service';
import { ManagerService } from '../../manager-dashboard/manager.service';
import { attachNamesToPlanets } from '../../manager-dashboard/reports/reports.utils';
import { CsvService } from '../../shared/csv.service';


@Component({
Expand Down Expand Up @@ -37,7 +38,8 @@ export class CoursesEnrollComponent {
private usersService: UsersService,
private coursesService: CoursesService,
private stateService: StateService,
private managerService: ManagerService
private managerService: ManagerService,
private csvService: CsvService
) {
this.coursesService.requestCourses();
this.usersService.requestUserData();
Expand Down Expand Up @@ -83,4 +85,22 @@ export class CoursesEnrollComponent {
this.emptyData = this.members.length === 0;
}

exportCSV() {
// Prepare CSV data
const csvData = this.members.map((user: any) => {
return {
username: user.doc.name,
dateStarted: user.activityDates.createdDate
? new Date(user.activityDates.createdDate).toLocaleDateString()
: 'N/A',
mostRecentActivity: user.activityDates.updatedDate
? new Date(user.activityDates.updatedDate).toLocaleDateString()
: 'N/A',
};
});
this.csvService.exportCSV({
data: csvData,
title: `Course Enrollment Data - ${this.course}`,
});
}
}

0 comments on commit c59e1a3

Please sign in to comment.