Skip to content

Commit

Permalink
Development: Migrate client code for the assessment dashboard (#10086)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliansoelch authored Jan 5, 2025
1 parent 60a21d7 commit 4ed301f
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Component, Input, OnChanges, OnDestroy, OnInit } from '@angular/core';
import { Component, Input, OnChanges, OnDestroy, OnInit, inject } from '@angular/core';
import { DueDateStat } from 'app/course/dashboards/due-date-stat.model';
import { LegendPosition } from '@swimlane/ngx-charts';
import { LegendPosition, PieChartModule } from '@swimlane/ngx-charts';
import { TranslateService } from '@ngx-translate/core';
import { GraphColors } from 'app/entities/statistics.model';
import { Subscription } from 'rxjs';
import { Course } from 'app/entities/course.model';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { ArtemisSidePanelModule } from 'app/shared/side-panel/side-panel.module';
import { RouterLink } from '@angular/router';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

export class AssessmentDashboardInformationEntry {
constructor(
Expand Down Expand Up @@ -33,8 +37,12 @@ export class AssessmentDashboardInformationEntry {
selector: 'jhi-assessment-dashboard-information',
templateUrl: './assessment-dashboard-information.component.html',
styleUrls: ['./assessment-dashboard-information.component.scss'],
standalone: true,
imports: [TranslateDirective, PieChartModule, ArtemisSidePanelModule, RouterLink, ArtemisTranslatePipe],
})
export class AssessmentDashboardInformationComponent implements OnInit, OnChanges, OnDestroy {
private translateService = inject(TranslateService);

@Input() isExamMode: boolean;
@Input() course: Course;
@Input() examId?: number;
Expand Down Expand Up @@ -71,8 +79,6 @@ export class AssessmentDashboardInformationComponent implements OnInit, OnChange

themeSubscription: Subscription;

constructor(private translateService: TranslateService) {}

ngOnInit(): void {
this.setup();
this.translateService.onLangChange.subscribe(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { CourseManagementService } from '../../manage/course-management.service';
import { AlertService } from 'app/core/util/alert.service';
import { User } from 'app/core/user/user.model';
Expand All @@ -17,19 +17,55 @@ import { Exam } from 'app/entities/exam/exam.model';
import { ExamManagementService } from 'app/exam/manage/exam-management.service';
import { ExerciseService } from 'app/exercises/shared/exercise/exercise.service';
import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model';
import { AssessmentDashboardInformationEntry } from './assessment-dashboard-information.component';
import { AssessmentDashboardInformationComponent, AssessmentDashboardInformationEntry } from './assessment-dashboard-information.component';
import { TutorIssue, TutorIssueComplaintsChecker, TutorIssueRatingChecker, TutorIssueScoreChecker } from 'app/course/dashboards/assessment-dashboard/tutor-issue';
import { TutorLeaderboardElement } from 'app/shared/dashboards/tutor-leaderboard/tutor-leaderboard.model';
import { faClipboard, faHeartBroken, faSort, faTable } from '@fortawesome/free-solid-svg-icons';
import { DocumentationType } from 'app/shared/components/documentation-button/documentation-button.component';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { ExamAssessmentButtonsComponent } from 'app/course/dashboards/assessment-dashboard/exam-assessment-buttons/exam-assessment-buttons.component';
import { FormsModule } from '@angular/forms';
import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module';
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
import { ArtemisTutorParticipationGraphModule } from 'app/shared/dashboards/tutor-participation-graph/tutor-participation-graph.module';
import { ArtemisExerciseAssessmentDashboardModule } from 'app/exercises/shared/dashboards/tutor/exercise-assessment-dashboard.module';
import { ArtemisTutorLeaderboardModule } from 'app/shared/dashboards/tutor-leaderboard/tutor-leaderboard.module';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-assessment-dashboard',
templateUrl: './assessment-dashboard.component.html',
styleUrls: ['./exam-assessment-buttons/exam-assessment-buttons.component.scss'],
providers: [CourseManagementService],
standalone: true,
imports: [
ArtemisSharedComponentModule,
RouterLink,
FaIconComponent,
TranslateDirective,
ExamAssessmentButtonsComponent,
AssessmentDashboardInformationComponent,
FormsModule,
ArtemisSharedCommonModule,
NgbTooltip,
ArtemisTutorParticipationGraphModule,
ArtemisExerciseAssessmentDashboardModule,
ArtemisTutorLeaderboardModule,
ArtemisTranslatePipe,
],
})
export class AssessmentDashboardComponent implements OnInit {
private courseService = inject(CourseManagementService);
private exerciseService = inject(ExerciseService);
private examManagementService = inject(ExamManagementService);
private alertService = inject(AlertService);
private accountService = inject(AccountService);
private route = inject(ActivatedRoute);
private guidedTourService = inject(GuidedTourService);
private sortService = inject(SortService);

readonly TeamFilterProp = TeamFilterProp;
readonly documentationType: DocumentationType = 'Assessment';

Expand Down Expand Up @@ -79,17 +115,6 @@ export class AssessmentDashboardComponent implements OnInit {
faClipboard = faClipboard;
faHeartBroken = faHeartBroken;

constructor(
private courseService: CourseManagementService,
private exerciseService: ExerciseService,
private examManagementService: ExamManagementService,
private alertService: AlertService,
private accountService: AccountService,
private route: ActivatedRoute,
private guidedTourService: GuidedTourService,
private sortService: SortService,
) {}

/**
* On init set the courseID, load all exercises and statistics for tutors and set the identity for the AccountService.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const ENTITY_STATES = [...assessmentDashboardRoute];
ArtemisExerciseAssessmentDashboardModule,
ArtemisSharedComponentModule,
PieChartModule,
AssessmentDashboardComponent,
AssessmentDashboardInformationComponent,
ExamAssessmentButtonsComponent,
],
declarations: [AssessmentDashboardComponent, AssessmentDashboardInformationComponent, ExamAssessmentButtonsComponent],
})
export class ArtemisAssessmentDashboardModule {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute, RouterLink } from '@angular/router';
import { StudentExamService } from 'app/exam/manage/student-exams/student-exam.service';
import { Subscription, forkJoin } from 'rxjs';
import { tap } from 'rxjs/operators';
Expand All @@ -15,12 +15,24 @@ import { AccountService } from 'app/core/auth/account.service';
import { onError } from 'app/shared/util/global.utils';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
import { faClipboard } from '@fortawesome/free-solid-svg-icons';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { TranslateDirective } from 'app/shared/language/translate.directive';

@Component({
selector: 'jhi-exam-assessment-buttons',
templateUrl: './exam-assessment-buttons.component.html',
standalone: true,
imports: [RouterLink, FaIconComponent, TranslateDirective],
})
export class ExamAssessmentButtonsComponent implements OnInit {
private route = inject(ActivatedRoute);
private examManagementService = inject(ExamManagementService);
private studentExamService = inject(StudentExamService);
private courseService = inject(CourseManagementService);
private alertService = inject(AlertService);
private accountService = inject(AccountService);
private artemisTranslatePipe = inject(ArtemisTranslatePipe);

courseId: number;
examId: number;
studentExams: StudentExam[];
Expand All @@ -38,16 +50,6 @@ export class ExamAssessmentButtonsComponent implements OnInit {
// icons
faClipboard = faClipboard;

constructor(
private route: ActivatedRoute,
private examManagementService: ExamManagementService,
private studentExamService: StudentExamService,
private courseService: CourseManagementService,
private alertService: AlertService,
private accountService: AccountService,
private artemisTranslatePipe: ArtemisTranslatePipe,
) {}

/**
* Initialize the courseId and examId
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('AssessmentDashboardInformationComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ArtemisTestModule, MockModule(PieChartModule)],
declarations: [AssessmentDashboardInformationComponent, MockPipe(ArtemisTranslatePipe), MockComponent(SidePanelComponent)],
declarations: [MockPipe(ArtemisTranslatePipe), MockComponent(SidePanelComponent)],
providers: [{ provide: TranslateService, useClass: MockTranslateService }],
}).compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ describe('AssessmentDashboardInformationComponent', () => {
return TestBed.configureTestingModule({
imports: [ArtemisTestModule, MockModule(RouterModule)],
declarations: [
AssessmentDashboardComponent,
MockComponent(TutorLeaderboardComponent),
MockComponent(TutorParticipationGraphComponent),
MockComponent(AssessmentDashboardInformationComponent),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('ExamAssessmentButtons', () => {

TestBed.configureTestingModule({
imports: [ArtemisTestModule],
declarations: [ExamAssessmentButtonsComponent, MockDirective(MockHasAnyAuthorityDirective), MockPipe(ArtemisTranslatePipe), MockRouterLinkDirective],
declarations: [MockDirective(MockHasAnyAuthorityDirective), MockPipe(ArtemisTranslatePipe), MockRouterLinkDirective],
providers,
})
.compileComponents()
Expand Down

0 comments on commit 4ed301f

Please sign in to comment.