Skip to content

Commit

Permalink
General: Hide group name customization by default (ls1intum#8432)
Browse files Browse the repository at this point in the history
  • Loading branch information
pzdr7 authored Apr 26, 2024
1 parent 9ffe787 commit 0fcfd55
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 38 deletions.
32 changes: 15 additions & 17 deletions src/main/webapp/app/course/manage/course-update.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,21 @@ <h5>
</select>
</div>
<div *jhiHasAnyAuthority="'ROLE_ADMIN'">
@if (!course.id) {
<div class="form-check">
<input
type="checkbox"
[checked]="customizeGroupNames"
(change)="changeCustomizeGroupNames()"
class="form-check-input"
name="customizeGroupNamesEnabled"
id="field_customizeGroupNamesEnabled"
formControlName="customizeGroupNames"
/>
<label class="form-control-label" jhiTranslate="artemisApp.course.customizeGroupNames.title" for="field_customizeGroupNamesEnabled"
>Customize Group Names</label
>
<fa-icon [icon]="faQuestionCircle" class="text-secondary" ngbTooltip="{{ 'artemisApp.course.customizeGroupNames.description' | artemisTranslate }}" />
</div>
}
<div class="form-check">
<input
type="checkbox"
[checked]="customizeGroupNames"
(change)="changeCustomizeGroupNames()"
class="form-check-input"
name="customizeGroupNamesEnabled"
id="field_customizeGroupNamesEnabled"
formControlName="customizeGroupNames"
/>
<label class="form-control-label" jhiTranslate="artemisApp.course.customizeGroupNames.title" for="field_customizeGroupNamesEnabled"
>Customize Group Names</label
>
<fa-icon [icon]="faExclamationTriangle" class="text-secondary" ngbTooltip="{{ 'artemisApp.course.customizeGroupNames.description' | artemisTranslate }}" />
</div>
@if (customizeGroupNames) {
<div>
<div class="form-group">
Expand Down
53 changes: 34 additions & 19 deletions src/main/webapp/app/course/manage/course-update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { onError } from 'app/shared/util/global.utils';
import { getSemesters } from 'app/utils/semester-utils';
import { ImageCropperModalComponent } from 'app/course/manage/image-cropper-modal.component';

const DEFAULT_CUSTOM_GROUP_NAME = 'artemis-dev';

@Component({
selector: 'jhi-course-update',
templateUrl: './course-update.component.html',
Expand Down Expand Up @@ -72,6 +74,7 @@ export class CourseUpdateComponent implements OnInit {
messagingEnabled = true;
ltiEnabled = false;
isAthenaEnabled = false;
tutorialGroupsFeatureActivated = false;

readonly semesters = getSemesters();

Expand All @@ -80,7 +83,6 @@ export class CourseUpdateComponent implements OnInit {
// Currently set to 65535 as this is the limit of TEXT
readonly COMPLAINT_RESPONSE_TEXT_LIMIT = 65535;
readonly COMPLAINT_TEXT_LIMIT = 65535;
tutorialGroupsFeatureActivated = false;

constructor(
private eventManager: EventManager,
Expand Down Expand Up @@ -132,24 +134,20 @@ export class CourseUpdateComponent implements OnInit {

this.profileService.getProfileInfo().subscribe((profileInfo) => {
if (profileInfo) {
if (profileInfo.inProduction) {
// in production mode, the groups should not be customized by default when creating a course
// when editing a course, only admins can customize groups automatically
this.customizeGroupNames = !!this.course.id;
} else {
// developers typically want to customize the groups, therefore this is prefilled
if (!profileInfo.inProduction) {
// developers may want to customize the groups
this.customizeGroupNames = true;
if (!this.course.studentGroupName) {
this.course.studentGroupName = 'artemis-dev';
this.course.studentGroupName = DEFAULT_CUSTOM_GROUP_NAME;
}
if (!this.course.teachingAssistantGroupName) {
this.course.teachingAssistantGroupName = 'artemis-dev';
this.course.teachingAssistantGroupName = DEFAULT_CUSTOM_GROUP_NAME;
}
if (!this.course.editorGroupName) {
this.course.editorGroupName = 'artemis-dev';
this.course.editorGroupName = DEFAULT_CUSTOM_GROUP_NAME;
}
if (!this.course.instructorGroupName) {
this.course.instructorGroupName = 'artemis-dev';
this.course.instructorGroupName = DEFAULT_CUSTOM_GROUP_NAME;
}
}
this.ltiEnabled = profileInfo.activeProfiles.includes(PROFILE_LTI);
Expand Down Expand Up @@ -475,19 +473,36 @@ export class CourseUpdateComponent implements OnInit {
changeCustomizeGroupNames() {
if (!this.customizeGroupNames) {
this.customizeGroupNames = true;
this.courseForm.controls['studentGroupName'].setValue('artemis-dev');
this.courseForm.controls['teachingAssistantGroupName'].setValue('artemis-dev');
this.courseForm.controls['editorGroupName'].setValue('artemis-dev');
this.courseForm.controls['instructorGroupName'].setValue('artemis-dev');
this.setGroupNameValuesInCourseForm(
this.course.studentGroupName ?? DEFAULT_CUSTOM_GROUP_NAME,
this.course.teachingAssistantGroupName ?? DEFAULT_CUSTOM_GROUP_NAME,
this.course.editorGroupName ?? DEFAULT_CUSTOM_GROUP_NAME,
this.course.instructorGroupName ?? DEFAULT_CUSTOM_GROUP_NAME,
);
} else {
this.customizeGroupNames = false;
this.courseForm.controls['studentGroupName'].setValue(undefined);
this.courseForm.controls['teachingAssistantGroupName'].setValue(undefined);
this.courseForm.controls['editorGroupName'].setValue(undefined);
this.courseForm.controls['instructorGroupName'].setValue(undefined);
if (!this.course.id) {
// Creating: clear the values so groups are no longer customized
this.setGroupNameValuesInCourseForm(undefined, undefined, undefined, undefined);
} else {
// Editing: restore the old values -> no change.
this.setGroupNameValuesInCourseForm(
this.course.studentGroupName,
this.course.teachingAssistantGroupName,
this.course.editorGroupName,
this.course.instructorGroupName,
);
}
}
}

private setGroupNameValuesInCourseForm(studentGroupName?: string, teachingAssistantGroupName?: string, editorGroupName?: string, instructorGroupName?: string) {
this.courseForm.controls['studentGroupName'].setValue(studentGroupName);
this.courseForm.controls['teachingAssistantGroupName'].setValue(teachingAssistantGroupName);
this.courseForm.controls['editorGroupName'].setValue(editorGroupName);
this.courseForm.controls['instructorGroupName'].setValue(instructorGroupName);
}

/**
* Enable or disable test course
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/i18n/de/course.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"customizeGroupNames": {
"title": "Passe Gruppennamen an",
"description": "Stelle sicher, dass die Gruppen in der externen Verwaltung von Nutzer:innen existieren, wenn du diese Option aktivierst. Die Gruppen werden dann nicht automatisch erzeugt."
"description": "Das Anpassen der Gruppennamen sollte nicht nötig sein und kann dazu führen, dass Nutzer:innen den Zugang zum Kurs verlieren. Stelle sicher, dass du einen guten Grund für das Anpassen der Gruppennamen hast."
},
"studentGroupName": "Gruppe der Studierenden",
"teachingAssistantGroupName": "Gruppe der Tutor:innen",
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/i18n/en/course.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"customizeGroupNames": {
"title": "Customize group names",
"description": "Make sure that the groups exist in the external user management if you enable this option. The groups are not created automatically then."
"description": "Customizing the group names should not be necessary and may cause users to lose access to this course. Make sure you have a good reason for customizing the group names."
},
"studentGroupName": "Students",
"teachingAssistantGroupName": "Tutors",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ describe('Course Management Update Component', () => {

describe('changeCustomizeGroupNames', () => {
it('should initialize values if enabled and reset if disabled', () => {
comp.course = new Course();
comp.courseForm = new FormGroup({
studentGroupName: new FormControl('noname'),
teachingAssistantGroupName: new FormControl('noname'),
Expand Down

0 comments on commit 0fcfd55

Please sign in to comment.