Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { MatchStudentDefault } from '../match-student-default/match-student-default.component';
import { MatchStudentDefaultComponent } from '../match-student-default/match-student-default.component';
import { moveItem } from '../move-item';
import { MatchCdkDragDrop } from '../MatchCdkDragDrop';
import { Container } from '../container';
Expand All @@ -10,7 +10,7 @@ import { copy } from '../../../../common/object/object';
styleUrls: ['../match-student-default/match-student-default.component.scss'],
templateUrl: '../match-student-default/match-student-default.component.html'
})
export class MatchStudentChoiceReuse extends MatchStudentDefault {
export class MatchStudentChoiceReuse extends MatchStudentDefaultComponent {
protected drop(event: MatchCdkDragDrop<Container, Item>): void {
moveItem(event);
event.container.element.nativeElement.classList.remove('primary-bg');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<component-header [component]="component"></component-header>
<component-header [component]="component" />
<div class="match" fxLayout="row wrap" cdkDropListGroup>
<div
fxFlex="100"
Expand All @@ -12,9 +12,9 @@
>
<div class="bucket-title" fxLayout="row wrap" fxLayoutAlign="start center" fxLayoutGap="8px">
<h3 class="mat-subtitle-2" [innerHTML]="buckets[0].value"></h3>
<div *ngIf="componentContent.canCreateChoices">
@if (componentContent.canCreateChoices) {
<add-choice-button [isDisabled]="isDisabled" (onClick)="addChoice()" />
</div>
}
</div>
<ul
class="items"
Expand All @@ -24,65 +24,13 @@ <h3 class="mat-subtitle-2" [innerHTML]="buckets[0].value"></h3>
[cdkDropListData]="{ isSourceBucket: true, items: buckets[0].items }"
(cdkDropListDropped)="drop($event)"
>
<li
class="item"
[ngClass]="{ disabled: isDisabled }"
cdkDrag
[cdkDragDisabled]="isDisabled"
(cdkDragEntered)="dragEnter($event)"
(cdkDragExited)="dragExit($event)"
*ngFor="let item of buckets[0].items; let position = index"
[cdkDragData]="{ position: position, item: item }"
>
<match-choice-item
[buckets]="buckets"
[item]="item"
[hasCorrectAnswer]="hasCorrectAnswer"
[isDisabled]="isDisabled"
(onStudentDataChanged)="studentDataChanged()"
/>
</li>
</ul>
</div>
</div>
<div
fxLayout="column"
fxLayout.gt-xs="{{ componentContent.horizontal ? 'column' : 'row wrap' }}"
fxLayoutAlign="start stretch"
fxFlex="100"
fxFlex.gt-xs="{{ componentContent.horizontal ? 50 : 100 }}"
fxFlexOrder="{{ componentContent.choicesAfter ? 1 : 2 }}"
>
<div
*ngFor="let bucket of buckets.slice(1)"
fxLayout="column"
fxFlex="100"
fxFlex.gt-xs="{{ componentContent.horizontal ? 100 : 50 }}"
fxFlex.gt-md="{{ componentContent.horizontal ? 100 : 33.33 }}"
>
<div class="bucket target notice-bg-bg" fxLayout="column" fxLayoutAlign="stretch">
<div
class="bucket-title"
fxLayout="row wrap"
fxLayoutAlign="start center"
fxLayoutGap="8px"
>
<h3 class="mat-subtitle-2" [innerHTML]="bucket.value"></h3>
</div>
<ul
class="items"
cdkDropList
[cdkDropListData]="{ isSourceBucket: false, items: bucket.items }"
(cdkDropListDropped)="drop($event)"
>
@for (item of buckets[0].items; track item.id; let position = $index) {
<li
class="item"
[ngClass]="{ disabled: isDisabled }"
[ngClass]="{ item: true, disabled: isDisabled }"
cdkDrag
[cdkDragDisabled]="isDisabled"
(cdkDragEntered)="dragEnter($event)"
(cdkDragExited)="dragExit($event)"
*ngFor="let item of bucket.items; let position = index"
[cdkDragData]="{ position: position, item: item }"
>
<match-choice-item
Expand All @@ -93,10 +41,63 @@ <h3 class="mat-subtitle-2" [innerHTML]="bucket.value"></h3>
(onStudentDataChanged)="studentDataChanged()"
/>
</li>
</ul>
</div>
}
</ul>
</div>
</div>
<div
fxLayout="column"
fxLayout.gt-xs="{{ componentContent.horizontal ? 'column' : 'row wrap' }}"
fxLayoutAlign="start stretch"
fxFlex="100"
fxFlex.gt-xs="{{ componentContent.horizontal ? 50 : 100 }}"
fxFlexOrder="{{ componentContent.choicesAfter ? 1 : 2 }}"
>
@for (bucket of buckets.slice(1); track bucket.id) {
<div
fxLayout="column"
fxFlex="100"
fxFlex.gt-xs="{{ componentContent.horizontal ? 100 : 50 }}"
fxFlex.gt-md="{{ componentContent.horizontal ? 100 : 33.33 }}"
>
<div class="bucket target notice-bg-bg" fxLayout="column" fxLayoutAlign="stretch">
<div
class="bucket-title"
fxLayout="row wrap"
fxLayoutAlign="start center"
fxLayoutGap="8px"
>
<h3 class="mat-subtitle-2" [innerHTML]="bucket.value"></h3>
</div>
<ul
class="items"
cdkDropList
[cdkDropListData]="{ isSourceBucket: false, items: bucket.items }"
(cdkDropListDropped)="drop($event)"
>
@for (item of bucket.items; track item.id; let position = $index) {
<li
[ngClass]="{ item: true, disabled: isDisabled }"
cdkDrag
[cdkDragDisabled]="isDisabled"
(cdkDragEntered)="dragEnter($event)"
(cdkDragExited)="dragExit($event)"
[cdkDragData]="{ position: position, item: item }"
>
<match-choice-item
[buckets]="buckets"
[item]="item"
[hasCorrectAnswer]="hasCorrectAnswer"
[isDisabled]="isDisabled"
(onStudentDataChanged)="studentDataChanged()"
/>
</li>
}
</ul>
</div>
</div>
}
</div>
</div>
<match-feedback-section
[componentContent]="componentContent"
Expand All @@ -105,24 +106,24 @@ <h3 class="mat-subtitle-2" [innerHTML]="bucket.value"></h3>
[isLatestComponentStateSubmit]="isLatestComponentStateSubmit"
[submitCounter]="submitCounter"
/>
<component-save-submit-buttons
*ngIf="isSaveOrSubmitButtonVisible"
[componentState]="latestComponentState"
[isDirty]="isDirty"
[isDisabled]="isDisabled"
[isSaveButtonVisible]="isSaveButtonVisible"
[isSubmitButtonDisabled]="isSubmitButtonDisabled"
[isSubmitButtonVisible]="isSubmitButtonVisible"
[isSubmitDirty]="isSubmitDirty"
(saveButtonClicked)="saveButtonClicked($event)"
(submitButtonClicked)="submitButtonClicked($event)"
>
</component-save-submit-buttons>
<component-annotations
*ngIf="mode === 'student'"
[annotations]="latestAnnotations"
[maxScore]="componentContent.maxScore"
[nodeId]="nodeId"
[componentId]="componentId"
>
</component-annotations>
@if (isSaveOrSubmitButtonVisible) {
<component-save-submit-buttons
[componentState]="latestComponentState"
[isDirty]="isDirty"
[isDisabled]="isDisabled"
[isSaveButtonVisible]="isSaveButtonVisible"
[isSubmitButtonDisabled]="isSubmitButtonDisabled"
[isSubmitButtonVisible]="isSubmitButtonVisible"
[isSubmitDirty]="isSubmitDirty"
(saveButtonClicked)="saveButtonClicked($event)"
(submitButtonClicked)="submitButtonClicked($event)"
/>
}
@if (mode === 'student') {
<component-annotations
[annotations]="latestAnnotations"
[maxScore]="componentContent.maxScore"
[nodeId]="nodeId"
[componentId]="componentId"
/>
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// @ts-nocheck
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { StudentTeacherCommonServicesModule } from '../../../../../../app/student-teacher-common-services.module';
import { Component } from '../../../../common/Component';
import { copy } from '../../../../common/object/object';
import { ClickToSnipImageService } from '../../../../services/clickToSnipImageService';
import { ProjectService } from '../../../../services/projectService';
import { MatchStudentDefault } from './match-student-default.component';
import { MatchStudentDefaultComponent } from './match-student-default.component';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';

let component: MatchStudentDefault;
let fixture: ComponentFixture<MatchStudentDefault>;
let component: MatchStudentDefaultComponent;
let fixture: ComponentFixture<MatchStudentDefaultComponent>;
let bucket1: any;
let bucket2: any;
let bucket3: any;
Expand Down Expand Up @@ -49,12 +48,10 @@ let starterBucketLabel = 'Starter Choices';
describe('MatchStudentDefaultComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [MatchStudentDefault],
schemas: [NO_ERRORS_SCHEMA],
imports: [StudentTeacherCommonServicesModule],
imports: [MatchStudentDefaultComponent, StudentTeacherCommonServicesModule],
providers: [provideHttpClient(withInterceptorsFromDi())]
});
fixture = TestBed.createComponent(MatchStudentDefault);
fixture = TestBed.createComponent(MatchStudentDefaultComponent);
component = fixture.componentInstance;
choice1 = createChoice(choiceId1, choiceValue1);
choice2 = createChoice(choiceId2, choiceValue2);
Expand Down Expand Up @@ -94,6 +91,7 @@ describe('MatchStudentDefaultComponent', () => {
};
component.component = new Component(componentContent, nodeId);
spyOn(TestBed.inject(ProjectService), 'getComponent').and.returnValue(copy(componentContent));
spyOn(TestBed.inject(ProjectService), 'getThemeSettings').and.returnValue({});
spyOn(component, 'subscribeToSubscriptions').and.callFake(() => {});
spyOn(component, 'broadcastDoneRenderingComponent').and.callFake(() => {});
spyOn(component, 'isAddToNotebookEnabled').and.callFake(() => {
Expand Down Expand Up @@ -381,32 +379,27 @@ function getCorrectness() {
it('should get correctness from feedback object when it is true', () => {
const isCorrect = true;
const feedbackObject = createFeedback(choiceId1, '', isCorrect);
expect(component.getCorrectness(feedbackObject, true, 0)).toEqual(isCorrect);
expect(component.getCorrectness(feedbackObject, 0)).toEqual(isCorrect);
});

it('should get correctness from feedback object when it is false', () => {
const isCorrect = false;
const feedbackObject = createFeedback(choiceId1, '', isCorrect);
expect(component.getCorrectness(feedbackObject, true, 0)).toEqual(isCorrect);
expect(component.getCorrectness(feedbackObject, 0)).toEqual(isCorrect);
});

it(`should get correctness from feedback object when position matters and it is in the correct
position`, () => {
const isCorrect = true;
const feedbackObject = createFeedback(choiceId1, '', isCorrect, 1);
expect(component.getCorrectness(feedbackObject, true, 1)).toEqual(isCorrect);
expect(component.getCorrectness(feedbackObject, 1)).toEqual(isCorrect);
});

it(`should get correctness from feedback object when position matters and it is not in the
correct position`, () => {
const isCorrect = false;
const feedbackObject = createFeedback(choiceId1, '', isCorrect, 1);
expect(component.getCorrectness(feedbackObject, true, 2)).toEqual(isCorrect);
});

it('should get correctness from feedback object there is not correct answer', () => {
const feedbackObject = createFeedback(choiceId1, '', false, 1);
expect(component.getCorrectness(feedbackObject, false, 1)).toEqual(null);
expect(component.getCorrectness(feedbackObject, 2)).toEqual(isCorrect);
});
});
}
Expand Down
Loading
Loading