Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Migrate client code for the grading system #10055

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/webapp/app/exam/manage/exam-management.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ import { DetailModule } from 'app/detail-overview-list/detail.module';
import { ArtemisDurationFromSecondsPipe } from 'app/shared/pipes/artemis-duration-from-seconds.pipe';
import { NoDataComponent } from 'app/shared/no-data-component';
import { GitDiffLineStatComponent } from 'app/exercises/programming/hestia/git-diff-report/git-diff-line-stat.component';
import { SafeHtmlPipe } from 'app/shared/pipes/safe-html.pipe';
import { GradeStepBoundsPipe } from 'app/shared/pipes/grade-step-bounds.pipe';

const ENTITY_STATES = [...examManagementState];

@NgModule({
// TODO: For better modularization we could define an exercise module with the corresponding exam routes
providers: [ArtemisDurationFromSecondsPipe],
providers: [ArtemisDurationFromSecondsPipe, SafeHtmlPipe, GradeStepBoundsPipe],
imports: [
RouterModule.forChild(ENTITY_STATES),
ArtemisTextExerciseModule,
Expand Down Expand Up @@ -109,6 +111,9 @@ const ENTITY_STATES = [...examManagementState];
DetailModule,
NoDataComponent,
GitDiffLineStatComponent,
SafeHtmlPipe,
GradeStepBoundsPipe,
BonusComponent,
],
declarations: [
ExamManagementComponent,
Expand Down Expand Up @@ -136,7 +141,6 @@ const ENTITY_STATES = [...examManagementState];
StudentExamDetailTableRowComponent,
ExamImportComponent,
ExamExerciseImportComponent,
BonusComponent,
ExamEditWorkingTimeComponent,
ExamEditWorkingTimeDialogComponent,
ExamLiveAnnouncementCreateModalComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { ProgrammingExerciseInstructionStepWizardComponent } from 'app/exercises
import { ProgrammingExerciseInstructionTaskStatusComponent } from 'app/exercises/programming/shared/instructions-render/task/programming-exercise-instruction-task-status.component';
import { ArtemisMarkdownModule } from 'app/shared/markdown.module';
import { ExamExerciseUpdateHighlighterModule } from 'app/exam/participate/exercises/exam-exercise-update-highlighter/exam-exercise-update-highlighter.module';
import { SafeHtmlPipe } from 'app/shared/pipes/safe-html.pipe';

@NgModule({
imports: [ArtemisSharedModule, ArtemisResultModule, ArtemisMarkdownModule, ExamExerciseUpdateHighlighterModule],
imports: [ArtemisSharedModule, ArtemisResultModule, ArtemisMarkdownModule, ExamExerciseUpdateHighlighterModule, SafeHtmlPipe],
declarations: [ProgrammingExerciseInstructionComponent, ProgrammingExerciseInstructionStepWizardComponent, ProgrammingExerciseInstructionTaskStatusComponent],
exports: [ProgrammingExerciseInstructionComponent],
})
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 { 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
25 changes: 14 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,10 +9,14 @@ 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';
import { ArtemisSharedModule } from 'app/shared/shared.module';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';
import { SafeHtmlPipe } from 'app/shared/pipes/safe-html.pipe';
import { GradeStepBoundsPipe } from 'app/shared/pipes/grade-step-bounds.pipe';
import { ArtemisModePickerModule } from 'app/exercises/shared/mode-picker/mode-picker.module';

export enum BonusStrategyOption {
GRADES,
Expand All @@ -28,8 +32,16 @@ export enum BonusStrategyDiscreteness {
selector: 'jhi-bonus',
templateUrl: './bonus.component.html',
styleUrls: ['./bonus.component.scss'],
standalone: true,
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 @@ -98,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,11 +1,19 @@
import { Component } from '@angular/core';
import { BaseGradingSystemComponent, CsvGradeStep } from 'app/grading-system/base-grading-system/base-grading-system.component';
import { parse } from 'papaparse';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';
import { FormsModule } from '@angular/forms';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { ArtemisSharedModule } from 'app/shared/shared.module';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-detailed-grading-system',
templateUrl: './detailed-grading-system.component.html',
styleUrls: ['./detailed-grading-system.component.scss'],
standalone: true,
imports: [TranslateDirective, ArtemisSharedComponentModule, FormsModule, FaIconComponent, ArtemisSharedModule, ArtemisTranslatePipe],
})
export class DetailedGradingSystemComponent extends BaseGradingSystemComponent {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
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';
import { ThemeService } from 'app/core/theme/theme.service';
import { loadGradingKeyUrlParams } from 'app/grading-system/grading-key-overview/grading-key-helper';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { GradingKeyTableComponent } from 'app/grading-system/grading-key-overview/grading-key/grading-key-table.component';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-grade-key-overview',
templateUrl: './grading-key-overview.component.html',
styleUrls: ['./grading-key-overview.scss'],
standalone: true,
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
Expand Up @@ -5,8 +5,7 @@ import { ArtemisSharedComponentModule } from 'app/shared/components/shared-compo
import { GradingKeyTableComponent } from 'app/grading-system/grading-key-overview/grading-key/grading-key-table.component';

@NgModule({
declarations: [GradingKeyOverviewComponent, GradingKeyTableComponent],
imports: [ArtemisSharedModule, ArtemisSharedComponentModule],
imports: [ArtemisSharedModule, ArtemisSharedComponentModule, GradingKeyOverviewComponent, GradingKeyTableComponent],
exports: [GradingKeyOverviewComponent, GradingKeyTableComponent],
})
export class GradingKeyOverviewModule {}
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 @@ -11,27 +11,32 @@ import { ScoresStorageService } from 'app/course/course-scores/scores-storage.se
import { ScoreType } from 'app/shared/constants/score-type.constants';
import { ActivatedRoute } from '@angular/router';
import { loadGradingKeyUrlParams } from 'app/grading-system/grading-key-overview/grading-key-helper';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
import { GradeStepBoundsPipe } from 'app/shared/pipes/grade-step-bounds.pipe';
import { SafeHtmlPipe } from 'app/shared/pipes/safe-html.pipe';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';

@Component({
selector: 'jhi-grade-key-table',
templateUrl: './grading-key-table.component.html',
styleUrls: ['../grading-key-overview.scss'],
standalone: true,
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(
maximiliansoelch marked this conversation as resolved.
Show resolved Hide resolved
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,15 +1,20 @@
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';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';

@Component({
selector: 'jhi-grading-system-info-modal',
templateUrl: './grading-system-info-modal.component.html',
standalone: true,
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,6 +1,10 @@
import { Component, Input, OnChanges } from '@angular/core';
import { ModePickerOption } from 'app/exercises/shared/mode-picker/mode-picker.component';
import { GradingScale } from 'app/entities/grading-scale.model';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';
import { ArtemisModePickerModule } from 'app/exercises/shared/mode-picker/mode-picker.module';
import { FormsModule } from '@angular/forms';

export enum PresentationType {
NONE = 'none',
Expand All @@ -22,6 +26,8 @@ export interface PresentationsConfig {
selector: 'jhi-grading-system-presentations',
templateUrl: './grading-system-presentations.component.html',
styleUrls: ['./grading-system-presentations.component.scss'],
standalone: true,
imports: [TranslateDirective, ArtemisSharedComponentModule, ArtemisModePickerModule, FormsModule],
})
export class GradingSystemPresentationsComponent implements OnChanges {
readonly NONE = PresentationType.NONE;
Expand Down
30 changes: 26 additions & 4 deletions src/main/webapp/app/grading-system/grading-system.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
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';
import { BaseGradingSystemComponent } from 'app/grading-system/base-grading-system/base-grading-system.component';
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';
import { TranslateDirective } from 'app/shared/language/translate.directive';
import { GradingSystemInfoModalComponent } from './grading-system-info-modal/grading-system-info-modal.component';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap';
import { FormsModule } from '@angular/forms';
import { GradingSystemPresentationsComponent } from './grading-system-presentations/grading-system-presentations.component';
import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';

@Component({
selector: 'jhi-grading-system',
templateUrl: './grading-system.component.html',
styleUrls: ['./grading-system.component.scss'],
standalone: true,
imports: [
ArtemisSharedComponentModule,
TranslateDirective,
GradingSystemInfoModalComponent,
FaIconComponent,
NgbTooltip,
FormsModule,
GradingSystemPresentationsComponent,
RouterLink,
RouterLinkActive,
RouterOutlet,
ArtemisTranslatePipe,
],
})
export class GradingSystemComponent implements OnInit {
private route = inject(ActivatedRoute);

readonly GradeType = GradeType;

courseId?: number;
Expand All @@ -23,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
13 changes: 11 additions & 2 deletions src/main/webapp/app/grading-system/grading-system.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@ import { ArtemisSharedComponentModule } from 'app/shared/components/shared-compo
import { GradingSystemPresentationsComponent } from 'app/grading-system/grading-system-presentations/grading-system-presentations.component';

@NgModule({
declarations: [GradingSystemComponent, DetailedGradingSystemComponent, IntervalGradingSystemComponent, GradingSystemInfoModalComponent, GradingSystemPresentationsComponent],
imports: [ArtemisSharedModule, RouterModule.forChild(gradingSystemState), ArtemisModePickerModule, ArtemisSharedComponentModule],
imports: [
ArtemisSharedModule,
RouterModule.forChild(gradingSystemState),
ArtemisModePickerModule,
ArtemisSharedComponentModule,
GradingSystemComponent,
DetailedGradingSystemComponent,
IntervalGradingSystemComponent,
GradingSystemInfoModalComponent,
GradingSystemPresentationsComponent,
],
exports: [GradingSystemComponent, GradingSystemInfoModalComponent],
})
export class GradingSystemModule {}
Loading
Loading