Skip to content

Commit d3b8bb8

Browse files
Merge pull request #637 from SELab-2/567-frontend---question-components-tests-and-integrations
[Frontend] - Question components tests and integrations
2 parents 401e70d + 16f16b2 commit d3b8bb8

26 files changed

+1228
-366
lines changed

backend/extra/seedDatabase.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function seedDatabase(): Promise<void> {
8080
const teacherInput: Teacher = new Teacher(
8181
email,
8282
firstName,
83-
lastName,
83+
'T. '+lastName,
8484
passwordHash,
8585
schoolName,
8686
)
@@ -113,7 +113,7 @@ export async function seedDatabase(): Promise<void> {
113113
const studentInput: Student = new Student(
114114
email,
115115
firstName,
116-
lastName,
116+
'S. '+lastName,
117117
passwordHash,
118118
schoolName,
119119
)
@@ -231,12 +231,11 @@ export async function seedDatabase(): Promise<void> {
231231
const visibilityOptions = [
232232
VisibilityType.PRIVATE,
233233
VisibilityType.GROUP,
234-
VisibilityType.PUBLIC
235234
];
236235

237236
for (const { id: assignmentId, classId } of assignments) {
238-
const students = await userRep.getByClassId(classId);
239-
const teachers = await userRep.getByClassId(classId);
237+
const students = await userRep.getStudentsByClassId(classId);
238+
const teachers = await userRep.getTeachersByClassId(classId);
240239
const teacherIds = teachers.map(t => t.id);
241240

242241
// Select 5–6 students for threads
@@ -258,7 +257,6 @@ export async function seedDatabase(): Promise<void> {
258257

259258
const visibility = faker.helpers.arrayElement(visibilityOptions);
260259

261-
262260
const thread = new QuestionThread(
263261
student.id!,
264262
assignmentId,
@@ -288,27 +286,6 @@ export async function seedDatabase(): Promise<void> {
288286
await messageRep.create(teacherMessage);
289287
}
290288
}
291-
292-
// Bonus: Add 2 public/global threads for this assignment
293-
for (let k = 0; k < 2; k++) {
294-
const globalThread = new QuestionThread(
295-
faker.helpers.arrayElement(students).id!,
296-
assignmentId,
297-
`step-${faker.number.int({ min: 1, max: 5 })}`,
298-
false,
299-
VisibilityType.PUBLIC,
300-
[]
301-
);
302-
const savedThread = await threadRep.create(globalThread) as { id: string };
303-
304-
const msg = new Message(
305-
faker.helpers.arrayElement(teacherIds)!,
306-
new Date(),
307-
savedThread.id!,
308-
faker.lorem.sentence()
309-
);
310-
await messageRep.create(msg);
311-
}
312289
}
313290
} catch (err) {
314291
console.error('Error during DB seeding:', err);

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

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,36 @@
99
[progress]="progress" [step]="furthestStep" (selectedNodeChanged)="onSelectedNodeChanged($event)"
1010
(emitGraph)="retrieveGraph($event)">
1111
</app-learning-path>
12-
@if(!alreadySubmitted && isStudent){
13-
@if (taskFetched ){
14-
<app-create-submission [assignmentId]="assignmentId" [taskObject]="taskObject" [type]="taskType" [taskId]="taskId!"
15-
[learningObjectId]="currentLearningObjectId" (submissionCreated)="onSubmissionCreated()"></app-create-submission>
16-
}
17-
@if (noTask ){
18-
<app-create-submission [assignmentId]="assignmentId" [taskObject]="taskObject"
19-
[learningObjectId]="currentLearningObjectId" (submissionCreated)="onSubmissionCreated()"></app-create-submission>
20-
}
21-
}@else if(isStudent) {
22-
@if(submissionType === 'accepted') {
23-
<h2 i18n>Your submission is marked Correct!</h2>
24-
}
25-
@else if(submissionType === 'rejected'){
26-
<h2 i18n>Your submission has been marked as Incorrect!</h2>
27-
}
28-
@else {
29-
<h2 i18n>Already submitted!</h2>
30-
}
31-
} @else if(!isStudent && !initializeTasks && submissionStatsReady) {
32-
<app-assignment-stats class="stats" [submissions]="submissionsForStep" [task]="task!"
33-
(patched)="reloadStats()"></app-assignment-stats>
34-
}
12+
<div class="inline">
13+
@if(!alreadySubmitted && isStudent){
14+
@if (taskFetched ){
15+
<app-create-submission [assignmentId]="assignmentId" [taskObject]="taskObject" [type]="taskType" [taskId]="taskId!"
16+
[learningObjectId]="currentLearningObjectId" (submissionCreated)="onSubmissionCreated()"></app-create-submission>
17+
}
18+
@if (noTask ){
19+
<app-create-submission [assignmentId]="assignmentId" [taskObject]="taskObject"
20+
[learningObjectId]="currentLearningObjectId" (submissionCreated)="onSubmissionCreated()"></app-create-submission>
21+
}
22+
}@else if(isStudent) {
23+
@if(submissionType === 'accepted') {
24+
<h2 i18n>Your submission is marked Correct!</h2>
25+
}
26+
@else if(submissionType === 'rejected'){
27+
<h2 i18n>Your submission has been marked as Incorrect!</h2>
28+
}
29+
@else {
30+
<h2 i18n>Already submitted!</h2>
31+
}
32+
} @else if(!isStudent && !initializeTasks && submissionStatsReady) {
33+
<app-assignment-stats class="stats" [submissions]="submissionsForStep" [task]="task!"
34+
(patched)="reloadStats()"></app-assignment-stats>
35+
}
36+
37+
@if (isStudent){
38+
<app-chat-popup [assignmentId]="assignmentId" [currentLearningObjectId]="currentLearningObjectId">
39+
</app-chat-popup>
40+
}
41+
</div>
3542

3643
<div class="arrows">
3744
<button mat-icon-button color="warn" [disabled]="step === 0" (click)="navigateBack()" i18n-matTooltip
@@ -53,7 +60,6 @@ <h2 i18n>Already submitted!</h2>
5360
<mat-card-title>{{step + 1}}/{{maxStep}}</mat-card-title>
5461

5562
</mat-card>
56-
5763
</div>
5864

5965
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,11 @@
5555

5656
.stats {
5757
width: 80%;
58+
}
59+
60+
.inline {
61+
display: flex;
62+
flex-direction: row;
63+
width: 100%;
64+
justify-content: center;
5865
}

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,27 @@ import { SubmissionService } from '../../services/submission.service';
2828
import { UserService } from '../../services/user.service';
2929
import { forkJoin, of, switchMap } from 'rxjs';
3030
import { Submission } from '../../interfaces/submissions';
31+
import { ChatPopupComponent } from '../chat-popup/chat-popup.component';
3132
import { MatIcon, MatIconModule } from '@angular/material/icon';
3233
import { MatButtonModule } from '@angular/material/button';
3334
import { MatTooltipModule } from '@angular/material/tooltip';
3435

3536
@Component({
3637
selector: 'app-assignment',
37-
imports: [LearningPathComponent, MatSelectModule, MatIcon, MatIconModule, MatTooltipModule, MatButtonModule, MatFormFieldModule, MatOptionModule, CreateSubmissionComponent, MatProgressBar, MatCardModule, LoadingComponent, CreateTaskComponent, AssignmentStatsComponent],
38+
imports: [
39+
LearningPathComponent,
40+
MatSelectModule,
41+
MatIcon, MatIconModule, MatTooltipModule, MatButtonModule,
42+
MatFormFieldModule,
43+
MatOptionModule,
44+
CreateSubmissionComponent,
45+
MatProgressBar,
46+
MatCardModule,
47+
LoadingComponent,
48+
CreateTaskComponent,
49+
AssignmentStatsComponent,
50+
ChatPopupComponent,
51+
],
3852
templateUrl: './assignment.component.html',
3953
styleUrl: './assignment.component.less'
4054
})
@@ -177,11 +191,12 @@ export class AssignmentComponent implements OnInit {
177191
progressObservable.subscribe(
178192
(res) => {
179193
this.progress = res;
180-
this.step = this.progress.step;
194+
this.step = this.progress.step - 1;
181195
this.furthestStep = this.progress.step; // furthest step is always returned by progress
182196
this.alreadySubmitted = this.step < this.furthestStep
183197
this.maxStep = this.progress.maxStep;
184198
this.loading = false;
199+
console.log(this.step, this.furthestStep, this.maxStep)
185200
}
186201
)
187202
}

frontend/src/app/components/authenticated-menu/authenticated-menu.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
<button mat-menu-item routerLink="/student/dashboard" i18n="@@authenticatedDashboardStudent">Dashboard</button>
55
<button mat-menu-item routerLink="/student/classes" i18n="@@authenticatedClassesStudent">Classes</button>
66
<button mat-menu-item routerLink="/student/assignments" i18n="@@authenticatedAssignmentsStudent">Assignments</button>
7+
<button mat-menu-item routerLink="/student/chat/0" i18n="@@authenticatedChatsStudent">Chats</button>
78
} @else {
89
<button mat-menu-item routerLink="/teacher/dashboard" i18n="@@authenticatedDashboardTeacher">Dashboard</button>
910
<button mat-menu-item routerLink="/teacher/classes" i18n="@@authenticatedClassesTeacher">Classes</button>
1011
<button mat-menu-item routerLink="/teacher/assignments" i18n="@@authenticatedAssignmentsTeacher">Assignments</button>
12+
<button mat-menu-item routerLink="/teacher/chat/0" i18n="@@authenticatedChatsTeacher">Chats</button>
1113
}
1214

1315
<button mat-menu-item routerLink="/explore" i18n="@@authenticatedExplore">Explore</button>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<button mat-fab class="chat-fab" color="primary" (click)="open()">
2+
<mat-icon>chat</mat-icon>
3+
</button>
4+
5+
<ng-template #chatDialog>
6+
<div class="chat-dialog">
7+
<div class="chat-header">
8+
<mat-toolbar color="primary" class="chat-custom-toolbar">
9+
<span>Chat</span>
10+
<span class="spacer"></span>
11+
<button mat-icon-button (click)="navigateToFullChat()" matTooltip="Open full chat">
12+
<mat-icon style="color: black;">open_in_new</mat-icon>
13+
</button>
14+
<button mat-icon-button (click)="close()">
15+
<mat-icon style="color: black;">close</mat-icon>
16+
</button>
17+
</mat-toolbar>
18+
</div>
19+
<app-chat
20+
[questionThreadId]="currentThreadId"
21+
[showHeader]="false"
22+
[assignmentId]="assignmentId"
23+
[learningObjectId]="currentLearningObjectId">
24+
</app-chat>
25+
</div>
26+
</ng-template>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.chat-fab {
2+
margin-left: 3rem;
3+
}
4+
5+
.chat-dialog-container {
6+
.mat-mdc-dialog-container {
7+
height: 100% !important;
8+
display: flex;
9+
flex-direction: column;
10+
padding: 0;
11+
overflow: hidden;
12+
13+
.mdc-dialog__surface {
14+
height: 100%;
15+
display: flex;
16+
flex-direction: column;
17+
}
18+
}
19+
}
20+
21+
.chat-dialog {
22+
display: flex;
23+
flex-direction: column;
24+
height: 100%;
25+
overflow: hidden;
26+
27+
app-chat {
28+
flex: 1;
29+
overflow-y: auto;
30+
}
31+
}
32+
33+
.chat-custom-toolbar {
34+
position: sticky;
35+
top: 0;
36+
z-index: 2;
37+
height: 64px;
38+
flex-shrink: 0;
39+
display: flex;
40+
justify-content: space-between;
41+
align-items: center;
42+
43+
.spacer {
44+
flex: 1;
45+
}
46+
47+
.mat-icon-button {
48+
background: transparent !important;
49+
border: none !important;
50+
51+
&:hover {
52+
background: rgba(255, 255, 255, 0.1) !important;
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)