diff --git a/src/main/webapp/app/exam/manage/exercise-groups/exercise-groups.component.html b/src/main/webapp/app/exam/manage/exercise-groups/exercise-groups.component.html index 43cd6963ce39..670f75cab5a6 100644 --- a/src/main/webapp/app/exam/manage/exercise-groups/exercise-groups.component.html +++ b/src/main/webapp/app/exam/manage/exercise-groups/exercise-groups.component.html @@ -297,38 +297,38 @@
{{ exerciseGroup.title }}
@if (exerciseGroup.id && exerciseGroupToExerciseTypesDict.get(exerciseGroup.id)?.includes(exerciseType.PROGRAMMING)) { @if (exercise.type === exerciseType.PROGRAMMING) { - + } @if (exercise.type === exerciseType.PROGRAMMING) { - + } @if (exercise.type === exerciseType.PROGRAMMING) { - + } @if (exercise.type === exerciseType.PROGRAMMING) { - + } } @if (exerciseGroup.id && exerciseGroupToExerciseTypesDict.get(exerciseGroup.id!)?.includes(exerciseType.QUIZ)) { - + } @if (exerciseGroup.id && exerciseGroupToExerciseTypesDict.get(exerciseGroup.id!)?.includes(exerciseType.MODELING)) { - + } @if (exerciseGroup.id && exerciseGroupToExerciseTypesDict.get(exerciseGroup.id!)?.includes(exerciseType.FILE_UPLOAD)) { - + } @if ( diff --git a/src/main/webapp/app/exam/manage/exercise-groups/programming-exercise-cell/programming-exercise-group-cell.component.html b/src/main/webapp/app/exam/manage/exercise-groups/programming-exercise-cell/programming-exercise-group-cell.component.html index 5de7c8465f1a..d64ac1b586b5 100644 --- a/src/main/webapp/app/exam/manage/exercise-groups/programming-exercise-cell/programming-exercise-group-cell.component.html +++ b/src/main/webapp/app/exam/manage/exercise-groups/programming-exercise-cell/programming-exercise-group-cell.component.html @@ -1,54 +1,54 @@ -@if (programmingExercise) { - @if (displayShortName) { +@if (programmingExercise()) { + @if (displayShortName()) {
- {{ programmingExercise.shortName || '' }} + {{ programmingExercise().shortName || '' }}
} - @if (displayRepositoryUri) { + @if (displayRepositoryUri()) {
- @if (programmingExercise.templateParticipation?.repositoryUri) { + @if (programmingExercise().templateParticipation?.repositoryUri) { @if (!localVCEnabled) { - Template + Template } @else { Template } } - @if (programmingExercise.templateParticipation?.results?.length) { + @if (programmingExercise().templateParticipation?.results?.length) { }
- @if (programmingExercise.solutionParticipation?.repositoryUri) { + @if (programmingExercise().solutionParticipation?.repositoryUri) { @if (!localVCEnabled) { - Solution + Solution } @else { Solution } } - @if (programmingExercise.solutionParticipation?.results?.length) { + @if (programmingExercise().solutionParticipation?.results?.length) { }
- @if (programmingExercise.testRepositoryUri) { + @if (programmingExercise().testRepositoryUri) { @if (!localVCEnabled) { - Test + Test } @else { Test @@ -57,44 +57,44 @@
} - @if (displayTemplateUrls) { + @if (displayTemplateUrls()) {
- @if (programmingExercise.templateParticipation?.buildPlanId) { + @if (programmingExercise().templateParticipation?.buildPlanId) { @if (!localVCEnabled) { - Template + Template } @else { - {{ programmingExercise.templateParticipation!.buildPlanId }} + {{ programmingExercise().templateParticipation!.buildPlanId }} } }
- @if (programmingExercise.solutionParticipation?.buildPlanId) { + @if (programmingExercise().solutionParticipation?.buildPlanId) { @if (!localVCEnabled) { - Solution + Solution } @else { - {{ programmingExercise.solutionParticipation!.buildPlanId }} + {{ programmingExercise().solutionParticipation!.buildPlanId }} } }
} - @if (displayEditorModus) { + @if (displayEditorModus()) {
- +
- +
@if (onlineIdeEnabled) {
- +
}
diff --git a/src/main/webapp/app/exam/manage/exercise-groups/programming-exercise-cell/programming-exercise-group-cell.component.ts b/src/main/webapp/app/exam/manage/exercise-groups/programming-exercise-cell/programming-exercise-group-cell.component.ts index a171fc11d30e..1fc7cf40f34e 100644 --- a/src/main/webapp/app/exam/manage/exercise-groups/programming-exercise-cell/programming-exercise-group-cell.component.ts +++ b/src/main/webapp/app/exam/manage/exercise-groups/programming-exercise-cell/programming-exercise-group-cell.component.ts @@ -1,8 +1,7 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, OnInit, inject, input } from '@angular/core'; import { HttpResponse } from '@angular/common/http'; import { ProgrammingExercise } from 'app/entities/programming/programming-exercise.model'; import { ProgrammingExerciseParticipationType } from 'app/entities/programming/programming-exercise-participation.model'; -import { Exercise } from 'app/entities/exercise.model'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; import { createBuildPlanUrl } from 'app/exercises/programming/shared/utils/programming-exercise.utils'; import { ProgrammingExerciseInstructorRepositoryType, ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; @@ -17,53 +16,38 @@ import { PROFILE_LOCALVC, PROFILE_THEIA } from 'app/app.constants'; styles: [':host{display: contents}'], }) export class ProgrammingExerciseGroupCellComponent implements OnInit { - participationType = ProgrammingExerciseParticipationType; + private profileService = inject(ProfileService); + private programmingExerciseService = inject(ProgrammingExerciseService); + private alertService = inject(AlertService); - programmingExercise: ProgrammingExercise; + participationType = ProgrammingExerciseParticipationType; localVCEnabled = false; onlineIdeEnabled = false; - @Input() - displayShortName = false; - @Input() - displayRepositoryUri = false; - @Input() - displayTemplateUrls = false; - @Input() - displayEditorModus = false; - - @Input() - set exercise(exercise: Exercise) { - this.programmingExercise = exercise as ProgrammingExercise; - } + displayShortName = input(false); + displayRepositoryUri = input(false); + displayTemplateUrls = input(false); + displayEditorModus = input(false); + programmingExercise = input.required(); faDownload = faDownload; - constructor( - private profileService: ProfileService, - private programmingExerciseService: ProgrammingExerciseService, - private alertService: AlertService, - ) {} - ngOnInit(): void { this.profileService.getProfileInfo().subscribe((profileInfo) => { this.localVCEnabled = profileInfo.activeProfiles.includes(PROFILE_LOCALVC); this.onlineIdeEnabled = profileInfo.activeProfiles.includes(PROFILE_THEIA); - if (this.programmingExercise.projectKey) { - if (this.programmingExercise.solutionParticipation?.buildPlanId) { - this.programmingExercise.solutionParticipation!.buildPlanUrl = createBuildPlanUrl( - profileInfo.buildPlanURLTemplate, - this.programmingExercise.projectKey, - this.programmingExercise.solutionParticipation.buildPlanId, - ); + + const projectKey = this.programmingExercise()?.projectKey; + if (projectKey) { + const solutionParticipation = this.programmingExercise()?.solutionParticipation; + if (solutionParticipation?.buildPlanId) { + solutionParticipation.buildPlanUrl = createBuildPlanUrl(profileInfo.buildPlanURLTemplate, projectKey, solutionParticipation.buildPlanId); } - if (this.programmingExercise.templateParticipation?.buildPlanId) { - this.programmingExercise.templateParticipation!.buildPlanUrl = createBuildPlanUrl( - profileInfo.buildPlanURLTemplate, - this.programmingExercise.projectKey, - this.programmingExercise.templateParticipation.buildPlanId, - ); + + const templateParticipation = this.programmingExercise()?.templateParticipation; + if (templateParticipation?.buildPlanId) { + templateParticipation.buildPlanUrl = createBuildPlanUrl(profileInfo.buildPlanURLTemplate, projectKey, templateParticipation.buildPlanId); } } }); @@ -76,10 +60,11 @@ export class ProgrammingExerciseGroupCellComponent implements OnInit { * * @param repositoryType */ - downloadRepository(repositoryType: ProgrammingExerciseInstructorRepositoryType) { - if (this.programmingExercise.id) { + downloadRepository(repositoryType: ProgrammingExerciseInstructorRepositoryType): void { + const programmingExerciseId = this.programmingExercise()?.id; + if (programmingExerciseId) { // Repository type cannot be 'AUXILIARY' as auxiliary repositories are currently not supported for the local VCS. - this.programmingExerciseService.exportInstructorRepository(this.programmingExercise.id, repositoryType, undefined).subscribe((response: HttpResponse) => { + this.programmingExerciseService.exportInstructorRepository(programmingExerciseId, repositoryType, undefined).subscribe((response: HttpResponse) => { downloadZipFileFromResponse(response); this.alertService.success('artemisApp.programmingExercise.export.successMessageRepos'); });