Skip to content

Commit

Permalink
Merge branch 'develop' into issue-1418-isLowestWorkgroupIdInPeerGroup…
Browse files Browse the repository at this point in the history
…-token
  • Loading branch information
hirokiterashima committed Sep 20, 2023
2 parents 977a85c + e9bba09 commit 25dd705
Show file tree
Hide file tree
Showing 70 changed files with 2,254 additions and 704 deletions.
8 changes: 5 additions & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { AnnouncementComponent } from './announcement/announcement.component';
import { AnnouncementDialogComponent } from './announcement/announcement.component';
import { TrackScrollDirective } from './track-scroll.directive';
import { RecaptchaV3Module, RECAPTCHA_V3_SITE_KEY, RECAPTCHA_BASE_URL } from 'ng-recaptcha';
import { ArchiveProjectService } from './services/archive-project.service';

export function initialize(
configService: ConfigService,
Expand Down Expand Up @@ -59,11 +60,12 @@ export function initialize(
MatDialogModule,
RecaptchaV3Module,
RouterModule.forRoot([], {
scrollPositionRestoration: 'enabled',
anchorScrolling: 'enabled'
})
scrollPositionRestoration: 'enabled',
anchorScrolling: 'enabled'
})
],
providers: [
ArchiveProjectService,
ConfigService,
StudentService,
TeacherService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,25 @@ <h5 fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="4px">
<mat-label *ngIf="rule.questions.length > 1" i18n
>Question #{{ questionIndex + 1 }}</mat-label
>
<textarea
matInput
[(ngModel)]="rule.questions[questionIndex]"
(ngModelChange)="inputChanged.next($event)"
cdkTextareaAutosize
>
</textarea>
<ng-container *ngIf="version === 2; then version2; else version1"></ng-container>
<ng-template #version2>
<textarea
matInput
[(ngModel)]="rule.questions[questionIndex].text"
(ngModelChange)="inputChanged.next($event)"
cdkTextareaAutosize
>
</textarea>
</ng-template>
<ng-template #version1>
<textarea
matInput
[(ngModel)]="rule.questions[questionIndex]"
(ngModelChange)="inputChanged.next($event)"
cdkTextareaAutosize
>
</textarea>
</ng-template>
<button
mat-icon-button
matSuffix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { QuestionBankRule } from '../../../assets/wise5/components/peerChat/peer
import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService';
import { StudentTeacherCommonServicesModule } from '../../student-teacher-common-services.module';
import { EditQuestionBankRulesComponent } from './edit-question-bank-rules.component';
import { Question } from '../../../assets/wise5/components/peerChat/peer-chat-question-bank/Question';

let component: EditQuestionBankRulesComponent;
let fixture: ComponentFixture<EditQuestionBankRulesComponent>;
let projectService: TeacherProjectService;
let nodeChangedSpy;
let nodeChangedSpy: jasmine.Spy;

describe('EditQuestionBankRulesComponent', () => {
beforeEach(async () => {
Expand Down Expand Up @@ -42,19 +43,42 @@ describe('EditQuestionBankRulesComponent', () => {

function addNewFeedbackToRule() {
describe('addNewFeedbackToRule()', () => {
it('should add new question to rule', () => {
const rule = new QuestionBankRule({ questions: ['Q1'] });
addNewFeedbackToRuleVersion1();
addNewFeedbackToRuleVersion2();
});
}

function addNewFeedbackToRuleVersion1() {
describe('using question bank content version 1', () => {
it('adds new question to rule', () => {
component.version = undefined;
const rule = new QuestionBankRule({ questions: [] });
component.addNewFeedbackToRule(rule);
expect(nodeChangedSpy).toHaveBeenCalled();
expect(rule.questions.length).toEqual(2);
expect(rule.questions[1]).toEqual('');
expect(rule.questions.length).toEqual(1);
expect(rule.questions[0]).toEqual('');
});
});
}

function addNewFeedbackToRuleVersion2() {
describe('using question bank content version 2', () => {
it('adds new question to rule', () => {
component.version = 2;
const rule = new QuestionBankRule({ questions: [] });
component.addNewFeedbackToRule(rule);
expect(nodeChangedSpy).toHaveBeenCalled();
expect(rule.questions.length).toEqual(1);
const question = rule.questions[0] as Question;
expect(question.hasOwnProperty('id')).toEqual(true);
expect(question.text).toEqual('');
});
});
}

function deleteFeedbackInRule() {
describe('deleteFeedbackInRule()', () => {
it('should delete specified feedback', () => {
it('deletes specified feedback', () => {
const rule = new QuestionBankRule({ questions: ['Q1', 'Q2'] });
spyOn(window, 'confirm').and.returnValue(true);
component.deleteFeedbackInRule(rule, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateRandomKey } from '../../../assets/wise5/common/string/string';
import { EditFeedbackRulesComponent } from '../../../assets/wise5/components/common/feedbackRule/edit-feedback-rules/edit-feedback-rules.component';
import { QuestionBankRule } from '../../../assets/wise5/components/peerChat/peer-chat-question-bank/QuestionBankRule';
import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService';
import { Question } from '../../../assets/wise5/components/peerChat/peer-chat-question-bank/Question';

@Component({
selector: 'edit-question-bank-rules',
Expand All @@ -20,7 +21,11 @@ export class EditQuestionBankRulesComponent extends EditFeedbackRulesComponent {
}

protected createNewFeedbackRule(): Partial<QuestionBankRule> {
return { id: generateRandomKey(), expression: '', questions: [''] };
if (this.version === 2) {
return { id: generateRandomKey(), expression: '', questions: [new Question()] };
} else {
return { id: generateRandomKey(), expression: '', questions: [''] };
}
}

deleteRule(ruleIndex: number): void {
Expand All @@ -31,7 +36,11 @@ export class EditQuestionBankRulesComponent extends EditFeedbackRulesComponent {
}

addNewFeedbackToRule(rule: Partial<QuestionBankRule>): void {
(rule.questions as string[]).push('');
if (this.version === 2) {
(rule.questions as any[]).push(new Question());
} else {
(rule.questions as string[]).push('');
}
this.projectService.nodeChanged();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,36 @@
</mat-checkbox>
</div>
<div *ngIf="componentContent.questionBank?.enabled">
<div class="custom-label">
<mat-form-field appearance="fill">
<mat-label i18n>Custom Label</mat-label>
<input
matInput
[(ngModel)]="componentContent.questionBank.label"
(ngModelChange)="inputChanged.next($event)"
placeholder="Question Bank"
i18n-placeholder
/>
</mat-form-field>
</div>
<div *ngIf="componentContent.questionBank.version === 2">
<mat-checkbox
[(ngModel)]="componentContent.questionBank.clickToUseEnabled"
(ngModelChange)="saveChanges()"
color="primary"
i18n
>
Student can select questions to use in Peer Chat
</mat-checkbox>
</div>
<div class="max-questions">
<mat-form-field appearance="fill">
<mat-label i18n>Max Number of Questions</mat-label>
<input
matInput
type="number"
[(ngModel)]="componentContent.questionBank.maxQuestionsToShow"
(ngModelChange)="saveChanges()"
(ngModelChange)="inputChanged.next($event)"
/>
</mat-form-field>
</div>
Expand All @@ -40,7 +62,10 @@
</edit-component-peer-grouping-tag>
</div>
<div class="feedback-rules">
<edit-question-bank-rules [feedbackRules]="componentContent.questionBank.rules">
<edit-question-bank-rules
[feedbackRules]="componentContent.questionBank.rules"
[version]="componentContent.questionBank.version"
>
</edit-question-bank-rules>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
margin-bottom: 16px;
}

.reference-component, .max-questions {
.custom-label, .reference-component, .max-questions {
margin-top: 16px;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,39 @@ import { Component, Input, OnInit } from '@angular/core';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { QuestionBank } from '../../../assets/wise5/components/peerChat/peer-chat-question-bank/QuestionBank';
import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService';
import { Subject, Subscription, debounceTime, distinctUntilChanged } from 'rxjs';

@Component({
selector: 'edit-question-bank',
templateUrl: './edit-question-bank.component.html',
styleUrls: ['./edit-question-bank.component.scss']
})
export class EditQuestionBankComponent implements OnInit {
allowedReferenceComponentTypes: string[] = ['MultipleChoice', 'OpenResponse'];
protected allowedReferenceComponentTypes: string[] = ['MultipleChoice', 'OpenResponse'];
@Input() componentContent: any;
protected inputChanged: Subject<string> = new Subject<string>();
private subscriptions: Subscription = new Subscription();

constructor(private projectService: TeacherProjectService) {}

ngOnInit(): void {}
ngOnInit(): void {
this.subscriptions.add(
this.inputChanged.pipe(debounceTime(1000), distinctUntilChanged()).subscribe(() => {
this.projectService.nodeChanged();
})
);
}

ngOnDestroy(): void {
this.subscriptions.unsubscribe();
}

toggleComponent(event: MatCheckboxChange): void {
if (this.componentContent.questionBank == null) {
this.componentContent.questionBank = new QuestionBank({
referenceComponent: {},
rules: []
rules: [],
version: 2
});
}
this.componentContent.questionBank.enabled = event.checked;
Expand Down
8 changes: 8 additions & 0 deletions src/app/common/harness-helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { MatMenuHarness } from '@angular/material/menu/testing';

export async function clickMenuButton(thisContext: any, menuButtonText: string): Promise<void> {
const getMenu = thisContext.locatorFor(MatMenuHarness);
const menu = await getMenu();
await menu.open();
return menu.clickItem({ text: menuButtonText });
}
4 changes: 4 additions & 0 deletions src/app/domain/archiveProjectResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export class ArchiveProjectResponse {
archived: boolean;
id: number;
}
24 changes: 13 additions & 11 deletions src/app/domain/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ import { Run } from './run';
import { User } from '../domain/user';

export class Project {
id: number;
name: string;
metadata: any;
dateCreated: string;
archived: boolean;
dateArchived: string;
lastEdited: string;
projectThumb: string;
thumbStyle: any;
dateCreated: string;
id: number;
isHighlighted: boolean;
lastEdited: string;
license: String;
metadata: any;
name: string;
owner: User;
sharedOwners: User[] = [];
run: Run;
parentId: number;
wiseVersion: number;
projectThumb: string;
run: Run;
sharedOwners: User[] = [];
tags: string[];
thumbStyle: any;
uri: String;
license: String;
wiseVersion: number;

static readonly VIEW_PERMISSION: number = 1;
static readonly EDIT_PERMISSION: number = 2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ConfigService } from '../../services/config.service';
import { Component } from '@angular/core';
import { RegisterUserCompleteComponent } from '../register-user-complete.component';

@Component({
selector: 'app-register-student-complete',
templateUrl: './register-student-complete.component.html',
styleUrls: ['./register-student-complete.component.scss']
})
export class RegisterStudentCompleteComponent implements OnInit {
username: string;
isUsingGoogleId: boolean;
googleLogInURL = `${this.configService.getContextPath()}/api/google-login`;

constructor(
private router: Router,
private route: ActivatedRoute,
private configService: ConfigService
) {}

ngOnInit() {
this.route.params.subscribe((params) => {
this.username = params['username'];
this.isUsingGoogleId = params['isUsingGoogleId'] == 'true';
});
}

login() {
this.router.navigate(['/login', { username: this.username }]);
}
}
export class RegisterStudentCompleteComponent extends RegisterUserCompleteComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { RegisterTeacherCompleteComponent } from './register-teacher-complete.component';
import { RouterTestingModule } from '@angular/router/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Observable } from 'rxjs';
import { Config } from '../../domain/config';
import { ConfigService } from '../../services/config.service';

export class MockConfigService {
Expand All @@ -16,14 +14,16 @@ describe('RegisterTeacherCompleteComponent', () => {
let component: RegisterTeacherCompleteComponent;
let fixture: ComponentFixture<RegisterTeacherCompleteComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [RegisterTeacherCompleteComponent],
imports: [RouterTestingModule],
providers: [{ provide: ConfigService, useClass: MockConfigService }],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
}));
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [RegisterTeacherCompleteComponent],
imports: [RouterTestingModule],
providers: [{ provide: ConfigService, useClass: MockConfigService }],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
})
);

beforeEach(() => {
fixture = TestBed.createComponent(RegisterTeacherCompleteComponent);
Expand Down
Loading

0 comments on commit 25dd705

Please sign in to comment.