Skip to content

Commit

Permalink
157041 - new api for get total enrollment count
Browse files Browse the repository at this point in the history
  • Loading branch information
yashveertrigyn committed Jul 19, 2024
1 parent c88c0d3 commit 76cb36e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@
</span>

<span *ngIf="currentBatch.participantCount !== null" class="course-participants course-participants-label">
<span class="font-weight-bold">{{currentBatch.participantCount}}</span>
<!-- <span class="font-weight-bold">{{currentBatch.participantCount}}</span> -->
<span *ngIf="!showParticipantLoader" class="font-weight-bold">{{showParticipantCount}}</span>
<img width="24" *ngIf="showParticipantLoader" src="../../../../../assets/images/loader.gif">
</span>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as _ from 'lodash-es';
import { UserService, FormService } from '@sunbird/core';
import {
ResourceService, ToasterService, ServerResponse, PaginationService, ConfigService,
NavigationHelperService, IPagination, OnDemandReportsComponent
NavigationHelperService, IPagination, OnDemandReportsComponent,UtilService
} from '@sunbird/shared';
import { CourseProgressService, UsageService } from './../../services';
import { ICourseProgressData, IBatchListData, IForumContext } from './../../interfaces';
Expand Down Expand Up @@ -191,6 +191,9 @@ export class CourseProgressComponent implements OnInit, OnDestroy, AfterViewInit
reportTypes = [];
userRoles;
selectedTab = 2;
appBaseUrl: string;
showParticipantCount = 0;
showParticipantLoader = false;
/**
* Constructor to create injected service(s) object
* @param {UserService} user Reference of UserService
Expand All @@ -210,7 +213,7 @@ export class CourseProgressComponent implements OnInit, OnDestroy, AfterViewInit
config: ConfigService,
public onDemandReportService: OnDemandReportService,
public formService: FormService,
public navigationhelperService: NavigationHelperService, private usageService: UsageService,
public navigationhelperService: NavigationHelperService, private usageService: UsageService,private utilService: UtilService
) {
this.user = user;
this.route = route;
Expand Down Expand Up @@ -292,6 +295,7 @@ export class CourseProgressComponent implements OnInit, OnDestroy, AfterViewInit
this.currentBatch = _.get(batch, 'value');;
// this.currentBatch.lastUpdatedOn = dayjs(this.currentBatch.lastUpdatedOn).format('DD-MMM-YYYY hh:mm a');
this.batchId = _.get(batch, 'value.id');
this.participantCount(this.batchId);
this.setCounts(this.currentBatch);
this.populateCourseDashboardData(_.get(batch, 'value'));
if (this.selectedTab === 1) {
Expand Down Expand Up @@ -582,6 +586,7 @@ export class CourseProgressComponent implements OnInit, OnDestroy, AfterViewInit
* course id and timeperiod
*/
ngOnInit() {
this.appBaseUrl = this.utilService.getAppBaseUrl();
// ---- Mock data Start-----
const apiData = {
userConsent: 'No',
Expand Down Expand Up @@ -730,4 +735,36 @@ export class CourseProgressComponent implements OnInit, OnDestroy, AfterViewInit
this.loadOndemandReports(2);
}
}

participantCount(batchId){
// URL of the file
this.showParticipantCount = 0;
this.showParticipantLoader = true;
const fileUrl = this.appBaseUrl+'/data/reports/total_batchWise_enrolment_count/coursewise_total_enroll_count.json';
// Fetch the file
fetch(fileUrl)
.then(response => {
// Check if the response is OK
if (!response.ok) {
throw new Error('Network response was not ok');
}
// Read the response as JSON
return response.json();
})
.then(data => {
// Do something with the JSON data
let count = data.find(t=>(t.batchId == batchId ))?.count;
if(count){
this.showParticipantCount = count;
}
this.showParticipantLoader = false;
})
.catch(error => {
// Handle errors
this.showParticipantLoader = false;
console.error('There was a problem with the fetch operation:', error);
});

}

}

0 comments on commit 76cb36e

Please sign in to comment.