Skip to content

Commit 401e70d

Browse files
Merge pull request #633 from SELab-2/616-divide-group-fix
[Frontend] - Not all students need to be assigned to an assignment
2 parents 16d7097 + 1b8da82 commit 401e70d

16 files changed

+146
-143
lines changed
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
main {
2-
height: 100%;
3-
width: 100%;
4-
overflow-y: auto;
2+
height: 100%;
3+
width: 100%;
4+
overflow-y: auto;
55
}
66

77
::ng-deep .secondary-mat-card[class] {
88
background-color: #ffffff;
99
color: black;
10-
}
11-
12-
::ng-deep .secondary-mat-card[class]:hover {
13-
background-color: black;
14-
cursor: pointer;
1510
}

frontend/src/app/components/assignment/assignment.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export class AssignmentComponent implements OnInit {
112112
this.submissionStatsReady = false;
113113
this.currentLearningObjectId = node.value.metadata.hruid!;
114114
this.step = node.value.metadata.step!;
115-
console.log(this.step, this.furthestStep);
116115
this.alreadySubmitted = this.step < this.furthestStep;
117116
this.fetchTaskAndSubmissions();
118117
}

frontend/src/app/components/class-pending-requests/class-pending-requests.component.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ export class ClassPendingRequestsComponent implements OnInit {
2727
public joinRequests: JoinRequestWithUser[] = [];
2828

2929
// Messages for the snackbar
30-
private readonly acceptedMessage: string = $localize `:@@accepted:Accepted!`;
31-
private readonly rejectedMessage: string = $localize `:@@rejected:Rejected!`;
30+
private readonly acceptedMessage: string = $localize`:@@accepted:Accepted!`;
31+
private readonly rejectedMessage: string = $localize`:@@rejected:Rejected!`;
3232

3333
// Snackbar
3434
private readonly snackBar = inject(MatSnackBar);
3535

3636
public constructor(
3737
private joinRequestService: JoinRequestService
38-
) {}
38+
) { }
3939

4040
/**
4141
* Requests the join requests for this class
@@ -44,7 +44,7 @@ export class ClassPendingRequestsComponent implements OnInit {
4444
public ngOnInit(): void {
4545
const classId: string | null = this._class?.id || null;
4646

47-
if(classId) {
47+
if (classId) {
4848
// Get all join requests
4949
const joinRequests$ = this.joinRequestService.getJoinRequestsForClass(classId);
5050

@@ -53,7 +53,6 @@ export class ClassPendingRequestsComponent implements OnInit {
5353
// Fill users of those join requests
5454
const joinRequestWithUser$ = this.joinRequestService.fillUsers(response);
5555
joinRequestWithUser$.subscribe(joinRequests => {
56-
console.log(joinRequests);
5756
this.joinRequests = joinRequests;
5857
});
5958
});
@@ -68,7 +67,7 @@ export class ClassPendingRequestsComponent implements OnInit {
6867
const accepted$ = this.joinRequestService.acceptRequest(requestId);
6968

7069
accepted$.subscribe((response) => {
71-
if(response) this.openSnackBar(this.acceptedMessage);
70+
if (response) this.openSnackBar(this.acceptedMessage);
7271
window.location.reload();
7372
});
7473
}
@@ -80,15 +79,15 @@ export class ClassPendingRequestsComponent implements OnInit {
8079
public rejectRequest(requestId: string): void {
8180
const rejected$ = this.joinRequestService.rejectRequest(requestId);
8281

83-
rejected$.subscribe((response) => {
84-
if(response) this.openSnackBar(this.rejectedMessage);
85-
window.location.reload();
86-
});
82+
rejected$.subscribe((response) => {
83+
if (response) this.openSnackBar(this.rejectedMessage);
84+
window.location.reload();
85+
});
8786
}
8887

89-
private openSnackBar(message: string, action: string="Ok") {
88+
private openSnackBar(message: string, action: string = "Ok") {
9089
this.snackBar.open(message, action, {
91-
duration: 2500
90+
duration: 2500
9291
});
9392
}
9493

frontend/src/app/components/create-assignment/create-assignment.component.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,27 @@
2424

2525
<mat-form-field>
2626
<mat-label i18n>Class</mat-label>
27-
<mat-select formControlName="classId">
27+
<mat-select formControlName="classId" (selectionChange)="checkNonEmpty($event.value)">
2828
@for (class of classes; track class.id) {
2929
<mat-option [value]="class.id">
3030
{{ class.name }}
3131
</mat-option>
3232
}
3333
</mat-select>
34+
@if(!enableCreate){
35+
<mat-hint i18n style="color: red">
36+
You need students in your class!
37+
</mat-hint>
38+
}
39+
3440
</mat-form-field>
3541

3642
<mat-form-field>
3743
<mat-label i18n>Extra instructions</mat-label>
3844
<textarea matInput formControlName="extraInstructions" placeholder="Extra instructions"></textarea>
3945
</mat-form-field>
4046

41-
<button mat-raised-button type="submit" [disabled]="createForm.invalid" i18n>
47+
<button mat-raised-button type="submit" [disabled]="!enableCreate || createForm.invalid" i18n>
4248
Create
4349
</button>
4450
</form>
@@ -52,7 +58,7 @@
5258
}
5359

5460
@if(initializeTasks) {
55-
<mat-card class="row">
61+
<mat-card class="row secondary-mat-card">
5662
<mat-card class="inline">
5763
<div>
5864
<mat-card-title i18n>Create Tasks for your Assignment!</mat-card-title>

frontend/src/app/components/create-assignment/create-assignment.component.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { ActivatedRoute, Router } from '@angular/router';
1919
import { AssignmentComponent } from '../assignment/assignment.component';
2020
import { MatIconModule } from '@angular/material/icon';
2121
import { TaskService } from '../../services/task.service';
22+
import { MatSnackBar } from '@angular/material/snack-bar';
2223

2324
@Component({
2425
selector: 'app-create-assignment',
@@ -37,7 +38,7 @@ import { TaskService } from '../../services/task.service';
3738
MatInputModule,
3839
MatDateRangeInput,
3940
MatNativeDateModule,
40-
MatButtonModule
41+
MatButtonModule,
4142
],
4243
templateUrl: './create-assignment.component.html',
4344
styleUrl: './create-assignment.component.less',
@@ -48,6 +49,7 @@ export class CreateAssignmentComponent implements OnInit {
4849
@Output() showGroups: EventEmitter<void> = new EventEmitter<void>
4950

5051
private readonly route = inject(ActivatedRoute);
52+
private readonly snackBar = inject(MatSnackBar);
5153

5254
public learningPathId: string = "";
5355
public language: string = "nl";
@@ -62,6 +64,8 @@ export class CreateAssignmentComponent implements OnInit {
6264
public assignmentId: string = '';
6365
public classMembers: User[] = [];
6466

67+
public enableCreate: boolean = true;
68+
6569
constructor(
6670
private formBuilder: FormBuilder,
6771
private classesService: ClassesService,
@@ -84,6 +88,12 @@ export class CreateAssignmentComponent implements OnInit {
8488

8589
}
8690

91+
checkNonEmpty(classId: string) {
92+
this.classesService.usersInClass(classId).subscribe(
93+
value => this.enableCreate = value.students.length > 0
94+
)
95+
}
96+
8797
create(): void {
8898
const newAssignment: NewAssignment | null = this.extractFormValues();
8999
if (newAssignment) {
@@ -100,6 +110,7 @@ export class CreateAssignmentComponent implements OnInit {
100110
}
101111
}
102112

113+
103114
private getClasses(): void {
104115
this.classesService.classesOfUser().subscribe((response: Class[]) => {
105116
this.classes = response;
@@ -166,10 +177,10 @@ export class CreateAssignmentComponent implements OnInit {
166177
// Initialize all empty tasks with an 'other'-type task without details
167178
this.taskService.fillRestWithEmptyTasks(this.assignmentId).subscribe({
168179
next: () => {
169-
console.log($localize`Assignment Created!`);
180+
this.snackBar.open($localize`Assignment Created!`);
170181
},
171-
error: (err) => {
172-
console.error(err);
182+
error: () => {
183+
this.snackBar.open($localize`Something went wrong!`);
173184
}
174185
});
175186

@@ -178,4 +189,5 @@ export class CreateAssignmentComponent implements OnInit {
178189
// we can redirect to assignments page
179190
this.router.navigate(['/teacher/assignments']);
180191
}
192+
181193
}

frontend/src/app/components/create-group/create-group.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ <h1 i18n="@@createGroupsHeader">Create groups</h1>
55
<p i18n="@@createGroupsDescription">
66
Here you can divide the members of your class into groups.
77
Drag a member into an existing group or onto the new group.
8+
If you do not wish to assign a student to this assignment, you can keep them into the "Members" section.
89
</p>
910

1011
<span style="display: flex; align-items: center;">
1112
<h2 i18n="@@createGroupMembers">Members</h2>
1213
<button mat-raised-button (click)="partitionMembers()" id="assign-all-button" style="margin-left: 75px;">
13-
<p>Assign all</p>
14+
<p i18n="@@assignAllGroupMembers">Assign all</p>
1415
</button>
1516
</span>
1617

frontend/src/app/components/create-group/create-group.component.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
align-items: center;
55
justify-content: center;
66

7+
78
gap: 20px;
89
}
910

frontend/src/app/components/create-group/create-group.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ export class CreateGroupComponent {
110110
* Make a call to the API to create the made groups.
111111
*/
112112
public createGroups(): void {
113-
if (this.members.length > 0) {
114-
this.openSnackBar($localize`There are still members not assigned to a group.`);
115-
} else {
116-
const nonEmptyGroups = this.groups.filter(group => group.length > 0);
113+
const nonEmptyGroups = this.groups.filter(group => group.length > 0);
117114

115+
if (nonEmptyGroups.length === 0) {
116+
this.openSnackBar($localize`You need to assign students!.`);
117+
} else {
118118
this.groupService.createGroups(nonEmptyGroups, this.assignmentId!)
119119
.subscribe((response) => {
120120
if (response) {
@@ -123,8 +123,10 @@ export class CreateGroupComponent {
123123
} else {
124124
this.openSnackBar($localize`Failed to create groups.`);
125125
}
126-
})
126+
});
127127
}
128+
129+
128130
}
129131

130132
/**

frontend/src/app/components/learning-path/learning-path.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ export class LearningPathComponent implements OnInit {
148148
const resultNode = this.trajectoryGraph!.nodes[i];
149149
if (resultNode) {
150150
this.selectedNode = resultNode;
151-
console.log("in learning path", this.step)
152151
this.selectedNodeChanged.emit(resultNode);
153152
} else {
154153
// First node, navigate back to assignments

frontend/src/app/components/manage-codes/manage-codes.component.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ export class ManageCodesComponent implements OnInit {
3434
public constructor(
3535
private activeRoute: ActivatedRoute,
3636
private classCodeService: ClassCodeService
37-
) {}
37+
) { }
3838

3939
public ngOnInit(): void {
4040
const id: string | null = this.activeRoute.snapshot.paramMap.get('id');
4141

42-
console.log(id);
42+
if (id) this._classId = id;
4343

44-
if(id) this._classId = id;
45-
46-
if(this._classId) {
44+
if (this._classId) {
4745
this.classCodeService.getClassCodes(this._classId)
4846
.subscribe((codes: Code[]) => {
4947
this._codes = codes;
@@ -64,7 +62,7 @@ export class ManageCodesComponent implements OnInit {
6462
public expireClassCode(code: Code): void {
6563
this.classCodeService.expireClassCode(code)
6664
.subscribe(response => {
67-
if(!response) {
65+
if (!response) {
6866
this.openSnackBar($localize`Could not expire code`);
6967
}
7068
else {
@@ -77,7 +75,7 @@ export class ManageCodesComponent implements OnInit {
7775
public deleteClassCode(code: Code): void {
7876
this.classCodeService.deleteClassCode(code)
7977
.subscribe(response => {
80-
if(!response) {
78+
if (!response) {
8179
this.openSnackBar($localize`Could not delete code`);
8280
}
8381
else {
@@ -88,15 +86,15 @@ export class ManageCodesComponent implements OnInit {
8886
}
8987

9088
public createClassCode(): void {
91-
if(this._classId) this.classCodeService.createClassCode(this._classId)
92-
.subscribe(response => {
93-
if(!response) {
94-
this.openSnackBar($localize`Could not create code`);
95-
}
96-
else {
97-
this.openSnackBar($localize`Code created successfully`);
98-
location.reload();
99-
};
89+
if (this._classId) this.classCodeService.createClassCode(this._classId)
90+
.subscribe(response => {
91+
if (!response) {
92+
this.openSnackBar($localize`Could not create code`);
93+
}
94+
else {
95+
this.openSnackBar($localize`Code created successfully`);
96+
location.reload();
97+
};
10098
});
10199
}
102100

@@ -112,9 +110,9 @@ export class ManageCodesComponent implements OnInit {
112110
this._codes = codes;
113111
}
114112

115-
private openSnackBar(message: string, action: string="Ok") {
113+
private openSnackBar(message: string, action: string = "Ok") {
116114
this.snackBar.open(message, action, {
117-
duration: 2500
115+
duration: 2500
118116
});
119117
}
120118

0 commit comments

Comments
 (0)