Skip to content

Commit

Permalink
Inject migration on grading-system components
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliansoelch committed Dec 19, 2024
1 parent ed44bc9 commit 42f4020
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { GradeType, GradingScale } from 'app/entities/grading-scale.model';
import { GradeStep } from 'app/entities/grade-step.model';
import { ActivatedRoute } from '@angular/router';
Expand Down Expand Up @@ -39,6 +39,12 @@ export enum GradeEditMode {

@Component({ template: '' })
export abstract class BaseGradingSystemComponent implements OnInit {
protected gradingSystemService = inject(GradingSystemService);
private route = inject(ActivatedRoute);
private translateService = inject(TranslateService);
private courseService = inject(CourseManagementService);
private examService = inject(ExamManagementService);

GradeType = GradeType;
ButtonSize = ButtonSize;
GradingScale = GradingScale;
Expand Down Expand Up @@ -67,14 +73,6 @@ export abstract class BaseGradingSystemComponent implements OnInit {
faExclamationTriangle = faExclamationTriangle;
faInfo = faInfo;

constructor(
protected gradingSystemService: GradingSystemService,
private route: ActivatedRoute,
private translateService: TranslateService,
private courseService: CourseManagementService,
private examService: ExamManagementService,
) {}

ngOnInit(): void {
this.route.parent?.params.subscribe((params) => {
this.isLoading = true;
Expand Down
18 changes: 7 additions & 11 deletions src/main/webapp/app/grading-system/bonus/bonus.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { BonusService } from 'app/grading-system/bonus/bonus.service';
import { GradingSystemService } from 'app/grading-system/grading-system.service';
import { GradingScale } from 'app/entities/grading-scale.model';
Expand All @@ -9,7 +9,6 @@ import { faExclamationTriangle, faPlus, faQuestionCircle, faSave, faTimes } from
import { GradeStep, GradeStepsDTO } from 'app/entities/grade-step.model';
import { ButtonSize } from 'app/shared/components/button.component';
import { Subject, forkJoin, of } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';
import { SearchTermPageableSearch, SortingOrder } from 'app/shared/table/pageable-table';
import { GradeEditMode } from 'app/grading-system/base-grading-system/base-grading-system.component';
import { AlertService } from 'app/core/util/alert.service';
Expand Down Expand Up @@ -37,6 +36,12 @@ export enum BonusStrategyDiscreteness {
imports: [ArtemisSharedModule, ArtemisSharedComponentModule, ArtemisModePickerModule, SafeHtmlPipe, GradeStepBoundsPipe],
})
export class BonusComponent implements OnInit {
private bonusService = inject(BonusService);
private gradingSystemService = inject(GradingSystemService);
private route = inject(ActivatedRoute);
private router = inject(Router);
private alertService = inject(AlertService);

readonly CALCULATION_PLUS = 1;
readonly CALCULATION_MINUS = -1;

Expand Down Expand Up @@ -105,15 +110,6 @@ export class BonusComponent implements OnInit {
sortedColumn: 'ID',
};

constructor(
private bonusService: BonusService,
private gradingSystemService: GradingSystemService,
private route: ActivatedRoute,
private router: Router,
private translateService: TranslateService,
private alertService: AlertService,
) {}

ngOnInit(): void {
this.isLoading = true;

Expand Down
10 changes: 4 additions & 6 deletions src/main/webapp/app/grading-system/bonus/bonus.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { GradeStep, GradeStepsDTO } from 'app/entities/grade-step.model';
Expand All @@ -11,12 +11,10 @@ export type EntityResponseType = HttpResponse<Bonus>;

@Injectable({ providedIn: 'root' })
export class BonusService {
public resourceUrl = 'api';
private http = inject(HttpClient);
private gradingSystemService = inject(GradingSystemService);

constructor(
private http: HttpClient,
private gradingSystemService: GradingSystemService,
) {}
public resourceUrl = 'api';

/**
* Deletes the bonus.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { GradingSystemService } from 'app/grading-system/grading-system.service';
import { GradeStep } from 'app/entities/grade-step.model';
import { ArtemisNavigationUtilService } from 'app/utils/navigation.utils';
import { faChevronLeft, faPrint } from '@fortawesome/free-solid-svg-icons';
Expand All @@ -19,19 +18,16 @@ import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
imports: [TranslateDirective, GradingKeyTableComponent, FaIconComponent, ArtemisTranslatePipe],
})
export class GradingKeyOverviewComponent implements OnInit {
private route = inject(ActivatedRoute);
private navigationUtilService = inject(ArtemisNavigationUtilService);
private themeService = inject(ThemeService);

readonly faChevronLeft = faChevronLeft;
readonly faPrint = faPrint;

plagiarismGrade: string;
noParticipationGrade: string;

constructor(
private route: ActivatedRoute,
private gradingSystemService: GradingSystemService,
private navigationUtilService: ArtemisNavigationUtilService,
private themeService: ThemeService,
) {}

isExam = false;

courseId?: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit, inject } from '@angular/core';
import { GradingSystemService } from 'app/grading-system/grading-system.service';
import { GradeStep, GradeStepsDTO } from 'app/entities/grade-step.model';
import { GradeType, GradingScale } from 'app/entities/grading-scale.model';
Expand All @@ -25,20 +25,18 @@ import { ArtemisSharedComponentModule } from 'app/shared/components/shared-compo
imports: [TranslateDirective, ArtemisTranslatePipe, GradeStepBoundsPipe, SafeHtmlPipe, ArtemisSharedComponentModule],
})
export class GradingKeyTableComponent implements OnInit {
private route = inject(ActivatedRoute);
private gradingSystemService = inject(GradingSystemService);
private bonusService = inject(BonusService);
private scoresStorageService = inject(ScoresStorageService);

readonly faChevronLeft = faChevronLeft;

readonly GradeEditMode = GradeEditMode;

@Input() studentGradeOrBonusPointsOrGradeBonus?: string;
@Input() forBonus?: boolean;

constructor(
private route: ActivatedRoute,
private gradingSystemService: GradingSystemService,
private bonusService: BonusService,
private scoresStorageService: ScoresStorageService,
) {}

plagiarismGrade: string;
noParticipationGrade: string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { faQuestionCircle } from '@fortawesome/free-regular-svg-icons';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateDirective } from 'app/shared/language/translate.directive';
Expand All @@ -11,9 +11,10 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
imports: [TranslateDirective, FaIconComponent],
})
export class GradingSystemInfoModalComponent {
private modalService = inject(NgbModal);

// Icons
farQuestionCircle = faQuestionCircle;
constructor(private modalService: NgbModal) {}

/**
* Open a large modal with the given content.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, inject } from '@angular/core';
import { ActivatedRoute, RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
import { DocumentationType } from 'app/shared/components/documentation-button/documentation-button.component';
import { GradeType } from 'app/entities/grading-scale.model';
Expand Down Expand Up @@ -33,6 +33,8 @@ import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
],
})
export class GradingSystemComponent implements OnInit {
private route = inject(ActivatedRoute);

readonly GradeType = GradeType;

courseId?: number;
Expand All @@ -45,8 +47,6 @@ export class GradingSystemComponent implements OnInit {
// Icons
readonly faExclamationTriangle = faExclamationTriangle;

constructor(private route: ActivatedRoute) {}

ngOnInit(): void {
this.route.params.subscribe((params) => {
this.courseId = Number(params['courseId']);
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/app/grading-system/grading-system.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, inject } from '@angular/core';
import { GradingScale } from 'app/entities/grading-scale.model';
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
Expand All @@ -13,9 +13,9 @@ export type EntityArrayResponseType = HttpResponse<GradingScale[]>;

@Injectable({ providedIn: 'root' })
export class GradingSystemService {
public resourceUrl = 'api/courses';
private http = inject(HttpClient);

constructor(private http: HttpClient) {}
public resourceUrl = 'api/courses';

/**
* Store a new grading scale for course on the server
Expand Down

0 comments on commit 42f4020

Please sign in to comment.