Skip to content

Commit 56ce5ce

Browse files
Aaron-Detrehirokiterashimabreity
authored
feat(Survey Unit): Anonymous user can work on unit (#2191)
Co-authored-by: Hiroki Terashima <[email protected]> Co-authored-by: Jonathan Lim-Breitbart <[email protected]>
1 parent e3a850c commit 56ce5ce

File tree

55 files changed

+1644
-769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1644
-769
lines changed

src/app/app-routing.module.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { FormsModule } from '@angular/forms';
12
import { HTTP_INTERCEPTORS, HttpRequest, HttpHandler, HttpInterceptor } from '@angular/common/http';
23
import { Injectable, NgModule } from '@angular/core';
3-
import { RouterModule, Routes } from '@angular/router';
4-
import { FormsModule } from '@angular/forms';
5-
import { PublicLibraryComponent } from './modules/library/public-library/public-library.component';
64
import { PersonalLibraryComponent } from './modules/library/personal-library/personal-library.component';
5+
import { PublicLibraryComponent } from './modules/library/public-library/public-library.component';
6+
import { RouterModule, Routes } from '@angular/router';
77

88
const routes: Routes = [
99
{ path: '', loadChildren: () => import('./home/home.module').then((m) => m.HomeModule) },
@@ -56,6 +56,10 @@ const routes: Routes = [
5656
{
5757
path: 'teacher',
5858
loadChildren: () => import('./teacher/teacher.module').then((m) => m.TeacherModule)
59+
},
60+
{
61+
path: 'survey',
62+
loadChildren: () => import('./student/survey/survey.module').then((m) => m.SurveyModule)
5963
}
6064
];
6165

src/app/app.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ export class AppComponent {
190190
!this.router.url.includes('/login') &&
191191
!this.router.url.includes('/join') &&
192192
!this.router.url.includes('/contact') &&
193-
!this.router.url.includes('/forgot')
193+
!this.router.url.includes('/forgot') &&
194+
!this.router.url.includes('/survey')
194195
);
195196
}
196197

src/app/app.module.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import { NgModule, inject, provideAppInitializer } from '@angular/core';
1+
import { AnnouncementComponent } from './announcement/announcement.component';
2+
import { AnnouncementDialogComponent } from './announcement/announcement.component';
3+
import { AppComponent } from './app.component';
4+
import { AppRoutingModule } from './app-routing.module';
5+
import { ArchiveProjectService } from './services/archive-project.service';
6+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
27
import { BrowserModule } from '@angular/platform-browser';
8+
import { ConfigService } from './services/config.service';
9+
import { FooterComponent } from './modules/footer/footer.component';
310
import { FormsModule } from '@angular/forms';
4-
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
11+
import { HeaderComponent } from './modules/header/header.component';
12+
import { HomeModule } from './home/home.module';
513
import { HttpErrorInterceptor } from './http-error.interceptor';
6-
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7-
import { RouterModule } from '@angular/router';
14+
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
815
import { MatDialogModule } from '@angular/material/dialog';
916
import { MatSidenavModule } from '@angular/material/sidenav';
1017
import { MatSnackBarModule } from '@angular/material/snack-bar';
1118
import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar';
12-
import { AppComponent } from './app.component';
13-
import { AppRoutingModule } from './app-routing.module';
14-
import { ConfigService } from './services/config.service';
15-
import { HomeModule } from './home/home.module';
19+
import { MobileMenuComponent } from './modules/mobile-menu/mobile-menu.component';
20+
import { NgModule, inject, provideAppInitializer } from '@angular/core';
21+
import { RecaptchaV3Module, RECAPTCHA_V3_SITE_KEY, RECAPTCHA_BASE_URL } from 'ng-recaptcha-2';
22+
import { RouterModule } from '@angular/router';
1623
import { StudentService } from './student/student.service';
17-
import { UserService } from './services/user.service';
1824
import { TeacherService } from './teacher/teacher.service';
19-
import { MobileMenuComponent } from './modules/mobile-menu/mobile-menu.component';
20-
import { AnnouncementComponent } from './announcement/announcement.component';
21-
import { AnnouncementDialogComponent } from './announcement/announcement.component';
2225
import { TrackScrollDirective } from './track-scroll.directive';
23-
import { RecaptchaV3Module, RECAPTCHA_V3_SITE_KEY, RECAPTCHA_BASE_URL } from 'ng-recaptcha-2';
24-
import { ArchiveProjectService } from './services/archive-project.service';
25-
import { FooterComponent } from './modules/footer/footer.component';
26-
import { HeaderComponent } from './modules/header/header.component';
26+
import { UserService } from './services/user.service';
2727

2828
export function initialize(
2929
configService: ConfigService,
@@ -47,17 +47,17 @@ export function initialize(
4747
bootstrap: [AppComponent],
4848
imports: [
4949
AnnouncementComponent,
50-
BrowserModule,
51-
BrowserAnimationsModule,
52-
FormsModule,
5350
AppRoutingModule,
51+
BrowserAnimationsModule,
52+
BrowserModule,
5453
FooterComponent,
54+
FormsModule,
5555
HeaderComponent,
5656
HomeModule,
57-
MobileMenuComponent,
57+
MatDialogModule,
5858
MatSidenavModule,
5959
MatSnackBarModule,
60-
MatDialogModule,
60+
MobileMenuComponent,
6161
RecaptchaV3Module,
6262
RouterModule.forRoot([], {
6363
scrollPositionRestoration: 'enabled',
@@ -73,9 +73,9 @@ export function initialize(
7373
TeacherService,
7474
UserService,
7575
provideAppInitializer(() => {
76-
const initializerFn = (initialize)(inject(ConfigService), inject(UserService));
77-
return initializerFn();
78-
}),
76+
const initializerFn = initialize(inject(ConfigService), inject(UserService));
77+
return initializerFn();
78+
}),
7979
{
8080
provide: MAT_SNACK_BAR_DEFAULT_OPTIONS,
8181
useValue: {

src/app/domain/run.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class Run {
1515
owner: User;
1616
sharedOwners: User[] = [];
1717
project: Project;
18+
private isSurvey: boolean;
1819

1920
static readonly VIEW_STUDENT_WORK_PERMISSION: number = 1;
2021
static readonly GRADE_AND_MANAGE_PERMISSION: number = 2;
@@ -39,32 +40,32 @@ export class Run {
3940
}
4041
}
4142

42-
public canViewStudentWork(userId) {
43+
public canViewStudentWork(userId): boolean {
4344
return (
4445
this.isOwner(userId) ||
4546
this.isSharedOwnerWithPermission(userId, Run.VIEW_STUDENT_WORK_PERMISSION)
4647
);
4748
}
4849

49-
public canGradeAndManage(userId) {
50+
public canGradeAndManage(userId): boolean {
5051
return (
5152
this.isOwner(userId) ||
5253
this.isSharedOwnerWithPermission(userId, Run.GRADE_AND_MANAGE_PERMISSION)
5354
);
5455
}
5556

56-
public canViewStudentNames(userId) {
57+
public canViewStudentNames(userId): boolean {
5758
return (
5859
this.isOwner(userId) ||
5960
this.isSharedOwnerWithPermission(userId, Run.VIEW_STUDENT_NAMES_PERMISSION)
6061
);
6162
}
6263

63-
isOwner(userId) {
64+
isOwner(userId): boolean {
6465
return this.owner.id == userId;
6566
}
6667

67-
isSharedOwnerWithPermission(userId, permissionId) {
68+
isSharedOwnerWithPermission(userId, permissionId): boolean {
6869
for (const sharedOwner of this.sharedOwners) {
6970
if (sharedOwner.id == userId) {
7071
return this.userHasPermission(sharedOwner, permissionId);
@@ -73,7 +74,7 @@ export class Run {
7374
return false;
7475
}
7576

76-
userHasPermission(user: User, permission: number) {
77+
userHasPermission(user: User, permission: number): boolean {
7778
return user.permissions.includes(permission);
7879
}
7980

@@ -92,6 +93,10 @@ export class Run {
9293
private hasEndTime(): boolean {
9394
return this.endTime != null;
9495
}
96+
97+
isSurveyRun(): boolean {
98+
return this.isSurvey;
99+
}
95100
}
96101

97102
export function sortByRunStartTimeDesc(a: Run, b: Run): number {

src/app/modules/header/header-account-menu/header-account-menu.component.html

Lines changed: 75 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -6,80 +6,82 @@
66
</button>
77
<mat-menu #accountMenu="matMenu" xPosition="before">
88
<div class="header-account-menu">
9-
<div class="user-info flex flex-row items-center space-x-2">
10-
<mat-icon
11-
*ngIf="roles.includes('student'); else teacherAvatar"
12-
i18n-aria-label
13-
aria-label="Account avatar"
14-
>account_circle</mat-icon
9+
@if (!roles.includes('surveyStudent')) {
10+
<div class="user-info flex flex-row items-center space-x-2">
11+
<mat-icon
12+
*ngIf="roles.includes('student'); else teacherAvatar"
13+
i18n-aria-label
14+
aria-label="Account avatar"
15+
>account_circle</mat-icon
16+
>
17+
<ng-template #teacherAvatar>
18+
<mat-icon i18n-aria-label aria-label="Account avatar">account_box</mat-icon>
19+
</ng-template>
20+
<span>{{ firstName }} {{ lastName }}</span>
21+
</div>
22+
<div *ngIf="isPreviousAdmin" class="user-switch">
23+
<a (click)="switchToOriginalUser()" i18n>Switch back to original user</a>
24+
</div>
25+
<mat-divider></mat-divider>
26+
<a
27+
*ngIf="roles.includes('student')"
28+
routerLinkActive="active"
29+
[routerLinkActiveOptions]="{ exact: true }"
30+
mat-menu-item
31+
routerLink="/student"
1532
>
16-
<ng-template #teacherAvatar>
17-
<mat-icon i18n-aria-label aria-label="Account avatar">account_box</mat-icon>
18-
</ng-template>
19-
<span>{{ firstName }} {{ lastName }}</span>
20-
</div>
21-
<div *ngIf="isPreviousAdmin" class="user-switch">
22-
<a (click)="switchToOriginalUser()" i18n>Switch back to original user</a>
23-
</div>
24-
<mat-divider></mat-divider>
25-
<a
26-
*ngIf="roles.includes('student')"
27-
routerLinkActive="active"
28-
[routerLinkActiveOptions]="{ exact: true }"
29-
mat-menu-item
30-
routerLink="/student"
31-
>
32-
<mat-icon>home</mat-icon>
33-
<span i18n>Student Home</span>
34-
</a>
35-
<a
36-
*ngIf="roles.includes('teacher')"
37-
mat-menu-item
38-
routerLink="/teacher"
39-
routerLinkActive="active"
40-
[routerLinkActiveOptions]="{ exact: true }"
41-
>
42-
<mat-icon>home</mat-icon>
43-
<span i18n>Teacher Home</span>
44-
</a>
45-
<a
46-
*ngIf="roles.includes('student')"
47-
mat-menu-item
48-
routerLink="/student/profile/edit"
49-
routerLinkActive="active"
50-
[routerLinkActiveOptions]="{ exact: true }"
51-
>
52-
<mat-icon>edit</mat-icon>
53-
<span i18n>Edit Profile</span>
54-
</a>
55-
<a
56-
*ngIf="roles.includes('teacher')"
57-
mat-menu-item
58-
routerLink="/teacher/profile/edit"
59-
routerLinkActive="active"
60-
[routerLinkActiveOptions]="{ exact: true }"
61-
>
62-
<mat-icon>edit</mat-icon>
63-
<span i18n>Edit Profile</span>
64-
</a>
65-
<a *ngIf="roles.includes('researcher')" mat-menu-item (click)="switchToAdmin()">
66-
<mat-icon>settings</mat-icon>
67-
<span i18n>Researcher Tools</span>
68-
</a>
69-
<a *ngIf="roles.includes('admin')" mat-menu-item (click)="switchToAdmin()">
70-
<mat-icon>settings</mat-icon>
71-
<span i18n>Admin Tools</span>
72-
</a>
73-
<a
74-
mat-menu-item
75-
routerLink="/help"
76-
routerLinkActive="active"
77-
[routerLinkActiveOptions]="{ exact: true }"
78-
>
79-
<mat-icon>help</mat-icon>
80-
<span i18n>Help</span>
81-
</a>
82-
<mat-divider></mat-divider>
33+
<mat-icon>home</mat-icon>
34+
<span i18n>Student Home</span>
35+
</a>
36+
<a
37+
*ngIf="roles.includes('teacher')"
38+
mat-menu-item
39+
routerLink="/teacher"
40+
routerLinkActive="active"
41+
[routerLinkActiveOptions]="{ exact: true }"
42+
>
43+
<mat-icon>home</mat-icon>
44+
<span i18n>Teacher Home</span>
45+
</a>
46+
<a
47+
*ngIf="roles.includes('student')"
48+
mat-menu-item
49+
routerLink="/student/profile/edit"
50+
routerLinkActive="active"
51+
[routerLinkActiveOptions]="{ exact: true }"
52+
>
53+
<mat-icon>edit</mat-icon>
54+
<span i18n>Edit Profile</span>
55+
</a>
56+
<a
57+
*ngIf="roles.includes('teacher')"
58+
mat-menu-item
59+
routerLink="/teacher/profile/edit"
60+
routerLinkActive="active"
61+
[routerLinkActiveOptions]="{ exact: true }"
62+
>
63+
<mat-icon>edit</mat-icon>
64+
<span i18n>Edit Profile</span>
65+
</a>
66+
<a *ngIf="roles.includes('researcher')" mat-menu-item (click)="switchToAdmin()">
67+
<mat-icon>settings</mat-icon>
68+
<span i18n>Researcher Tools</span>
69+
</a>
70+
<a *ngIf="roles.includes('admin')" mat-menu-item (click)="switchToAdmin()">
71+
<mat-icon>settings</mat-icon>
72+
<span i18n>Admin Tools</span>
73+
</a>
74+
<a
75+
mat-menu-item
76+
routerLink="/help"
77+
routerLinkActive="active"
78+
[routerLinkActiveOptions]="{ exact: true }"
79+
>
80+
<mat-icon>help</mat-icon>
81+
<span i18n>Help</span>
82+
</a>
83+
<mat-divider></mat-divider>
84+
}
8385
<a mat-menu-item (click)="logOut()">
8486
<mat-icon color="warn">exit_to_app</mat-icon>
8587
<span class="warn" i18n>Sign Out</span>

0 commit comments

Comments
 (0)