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

Integrated code lifecycle: Add editing of auxiliary repositories for instructors #9585

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,10 @@ default ProgrammingExercise findByIdWithTemplateAndSolutionParticipationLatestRe
programmingExerciseId);
ProgrammingExercise programmingExerciseWithSolution = getValueElseThrow(findWithSolutionParticipationLatestResultFeedbackTestCasesById(programmingExerciseId),
programmingExerciseId);
ProgrammingExercise programmingExerciseWithAuxiliaryRepositories = findByIdWithAuxiliaryRepositoriesElseThrow(programmingExerciseId);

programmingExerciseWithTemplate.setSolutionParticipation(programmingExerciseWithSolution.getSolutionParticipation());
programmingExerciseWithTemplate.setAuxiliaryRepositories(programmingExerciseWithAuxiliaryRepositories.getAuxiliaryRepositories());
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved

return programmingExerciseWithTemplate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
/>
<!-- repository select -->
<div ngbDropdown class="d-inline-block me-2">
<button class="btn btn-outline-primary" id="dropdownBasic1" ngbDropdownToggle>{{ selectedRepository }}</button>
<button class="btn btn-outline-primary" id="dropdownBasic1" ngbDropdownToggle>
{{ selectedRepository === REPOSITORY.AUXILIARY ? selectedAuxiliaryRepositoryName : selectedRepository }}
</button>
<div ngbDropdownMenu aria-labelledby="dropdownBasic1">
<button
[disabled]="!exercise || !exercise.templateParticipation || !exercise.templateParticipation.id || !exercise.templateParticipation.repositoryUri"
Expand Down Expand Up @@ -79,6 +81,20 @@
[style.background-color]="selectedRepository === REPOSITORY.TEST ? '#3e8acc' : 'transparent'"
jhiTranslate="artemisApp.editor.repoSelect.testRepo"
></button>
@for (auxiliaryRepository of exercise.auxiliaryRepositories; track exercise.auxiliaryRepositories; let i = $index) {
@if (auxiliaryRepository.id) {
<button
[disabled]="!exercise"
(click)="selectAuxiliaryRepository(auxiliaryRepository.id)"
ngbDropdownItem
[style.background-color]="
selectedRepository === REPOSITORY.AUXILIARY && selectedRepositoryId === auxiliaryRepository.id ? '#3e8acc' : 'transparent'
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
"
>
{{ auxiliaryRepository.name }}
</button>
}
}
</div>
</div>
<!-- action buttons -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { IrisSettings } from 'app/entities/iris/settings/iris-settings.model';
@Component({
selector: 'jhi-code-editor-instructor',
templateUrl: './code-editor-instructor-and-editor-container.component.html',
styleUrl: 'code-editor-instructor-and-editor-container.scss',
})
export class CodeEditorInstructorAndEditorContainerComponent extends CodeEditorInstructorBaseContainerComponent {
@ViewChild(UpdatingResultComponent, { static: false }) resultComp: UpdatingResultComponent;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.btn-outline-primary:not(.list-group-item).dropdown-toggle.show {
color: var(--default-btn-font);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export enum REPOSITORY {
TEMPLATE = 'TEMPLATE',
SOLUTION = 'SOLUTION',
TEST = 'TEST',
AUXILIARY = 'AUXILIARY',
}

/**
Expand Down Expand Up @@ -64,6 +65,8 @@ export abstract class CodeEditorInstructorBaseContainerComponent implements OnIn
// Stores which repository is selected atm.
// Needs to be set additionally to selectedParticipation as the test repository does not have a participation
selectedRepository: REPOSITORY;
selectedRepositoryId: number;
selectedAuxiliaryRepositoryName?: string;

// Fires when the selected domain changes.
// This can either be a participation (solution, template, assignment) or the test repository.
Expand Down Expand Up @@ -95,6 +98,7 @@ export abstract class CodeEditorInstructorBaseContainerComponent implements OnIn
this.paramSub = this.route!.params.subscribe((params) => {
const exerciseId = Number(params['exerciseId']);
const participationId = Number(params['participationId']);
const repositoryId = Number(params['repositoryId']);
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
this.loadingState = LOADING_STATE.INITIALIZING;
this.loadExercise(exerciseId)
.pipe(
Expand All @@ -107,6 +111,12 @@ export abstract class CodeEditorInstructorBaseContainerComponent implements OnIn
tap(() => {
if (this.router.url.endsWith('/test')) {
this.saveChangesAndSelectDomain([DomainType.TEST_REPOSITORY, this.exercise]);
} else if (this.router.url.indexOf('auxiliary') >= 0) {
const auxiliaryRepo = this.exercise.auxiliaryRepositories?.find((repo) => repo.id === repositoryId);
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
if (auxiliaryRepo) {
this.selectedAuxiliaryRepositoryName = auxiliaryRepo.name;
this.saveChangesAndSelectDomain([DomainType.AUXILIARY_REPOSITORY, auxiliaryRepo]);
}
} else {
const nextAvailableParticipation = this.getNextAvailableParticipation(participationId);
if (nextAvailableParticipation) {
Expand Down Expand Up @@ -190,7 +200,10 @@ export abstract class CodeEditorInstructorBaseContainerComponent implements OnIn
if (this.codeEditorContainer != undefined) {
this.codeEditorContainer.initializeProperties();
}
if (domainType === DomainType.PARTICIPATION) {
if (domainType === DomainType.AUXILIARY_REPOSITORY) {
this.selectedRepository = REPOSITORY.AUXILIARY;
this.selectedRepositoryId = domainValue.id;
} else if (domainType === DomainType.PARTICIPATION) {
this.setSelectedParticipation(domainValue.id);
} else {
this.selectedParticipation = this.exercise.templateParticipation!;
Expand Down Expand Up @@ -272,28 +285,42 @@ export abstract class CodeEditorInstructorBaseContainerComponent implements OnIn
* Select the template participation repository and navigate to it
*/
selectTemplateParticipation() {
this.router.navigate(['..', this.exercise.templateParticipation!.id], { relativeTo: this.route });
this.router.navigate([this.up(), this.exercise.templateParticipation!.id], { relativeTo: this.route });
}

/**
* Select the solution participation repository and navigate to it
*/
selectSolutionParticipation() {
this.router.navigate(['..', this.exercise.solutionParticipation!.id], { relativeTo: this.route });
this.router.navigate([this.up(), this.exercise.solutionParticipation!.id], { relativeTo: this.route });
}

/**
* Select the assignment participation repository and navigate to it
*/
selectAssignmentParticipation() {
this.router.navigate(['..', this.exercise.studentParticipations![0].id], { relativeTo: this.route });
this.router.navigate([this.up(), this.exercise.studentParticipations![0].id], { relativeTo: this.route });
}

/**
* Select the test repository and navigate to it
*/
selectTestRepository() {
this.router.navigate(['..', 'test'], { relativeTo: this.route });
this.router.navigate([this.up(), 'test'], { relativeTo: this.route });
}

/**
* Select the auxiliary repository and navigate to it
*/
selectAuxiliaryRepository(repositoryId: number) {
this.router.navigate([this.up(), 'auxiliary', repositoryId], { relativeTo: this.route });
}

/**
* Go two folders up if the current view is an auxiliary repository, and one otherwise
*/
up() {
return this.selectedRepository === REPOSITORY.AUXILIARY ? '../..' : '..';
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ const routes: Routes = [
},
canActivate: [UserRouteAccessService],
},
{
path: 'auxiliary/:repositoryId',
component: CodeEditorInstructorAndEditorContainerComponent,
data: {
authorities: [Authority.EDITOR, Authority.INSTRUCTOR, Authority.ADMIN],
pageTitle: 'artemisApp.editor.home.title',
flushRepositoryCacheAfter: 900000, // 15 min
participationCache: {},
repositoryCache: {},
},
canActivate: [UserRouteAccessService],
},
SimonEntholzer marked this conversation as resolved.
Show resolved Hide resolved
];

@NgModule({
Expand Down
Loading