Skip to content

Commit

Permalink
fix(Authoring Tool): Component preview save and submit buttons (#1565)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan authored Dec 19, 2023
1 parent 27b0508 commit 5fcedca
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/assets/wise5/components/component-student.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export abstract class ComponentStudent {
this.createComponentState(action).then((componentState: any) => {
this.StudentDataService.setDummyIdIntoLocalId(componentState);
this.StudentDataService.setDummyServerSaveTimeIntoLocalServerSaveTime(componentState);
this.handleStudentWorkSavedToServer({ studentWork: componentState });
this.handleStudentWorkSavedToServer(componentState);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,9 @@ export class ConceptMapStudent extends ComponentStudent {
if (this.hasAutoGrading()) {
this.performAutoGrading();
}
this.isSubmit = true;
this.emitComponentSubmitTriggered();
this.performSubmit(submitTriggeredBy);
} else {
this.isSubmit = false;
this.setIsSubmit(false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@
</div>
</div>
<mat-divider class="comment-divider"></mat-divider>
<div class="new-reply" fxLayout="row" *ngIf="mode === 'student' && !isDisabled">
<div
class="new-reply"
fxLayout="row"
*ngIf="(mode === 'student' || mode === 'preview') && !isDisabled"
>
<textarea
class="new-reply-input"
[(ngModel)]="response.replyText"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,18 @@ export class DiscussionStudent extends ComponentStudent {
nodeId: this.nodeId,
componentId: this.componentId
});
if (this.isPreviewMode()) {
this.saveForAuthoringPreviewMode('submit');
}
}

handleStudentWorkSavedToServerAdditionalProcessing(componentState: any): void {
this.clearComponentValues();
if (this.isClassmateResponsesGated() && !this.retrievedClassmateResponses) {
if (
!this.isPreviewMode() &&
this.isClassmateResponsesGated() &&
!this.retrievedClassmateResponses
) {
this.getClassmateResponses();
} else {
this.addClassResponse(componentState);
Expand Down Expand Up @@ -360,6 +367,7 @@ export class DiscussionStudent extends ComponentStudent {
componentState.componentType = 'Discussion';
componentState.nodeId = this.nodeId;
componentState.componentId = this.componentId;
componentState.isSubmit = this.isSubmit;
if (
(this.ConfigService.isPreview() && !this.componentStateIdReplyingTo) ||
this.mode === 'authoring'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { AnnotationService } from '../../../services/annotationService';
import { ConfigService } from '../../../services/configService';
import { NodeService } from '../../../services/nodeService';
import { NotebookService } from '../../../services/notebookService';
import { ProjectService } from '../../../services/projectService';
import { StudentAssetService } from '../../../services/studentAssetService';
import { StudentDataService } from '../../../services/studentDataService';
import { ComponentStudent } from '../../component-student.component';
Expand All @@ -15,6 +14,7 @@ import { MultipleChoiceComponent } from '../MultipleChoiceComponent';
import { MultipleChoiceService } from '../multipleChoiceService';
import { MultipleChoiceContent } from '../MultipleChoiceContent';
import { hasConnectedComponent } from '../../../common/ComponentContent';
import { copy } from '../../../common/object/object';

@Component({
selector: 'multiple-choice-student',
Expand All @@ -40,7 +40,6 @@ export class MultipleChoiceStudent extends ComponentStudent {
private multipleChoiceService: MultipleChoiceService,
protected nodeService: NodeService,
protected notebookService: NotebookService,
private projectService: ProjectService,
protected studentAssetService: StudentAssetService,
protected studentDataService: StudentDataService
) {
Expand All @@ -58,16 +57,13 @@ export class MultipleChoiceStudent extends ComponentStudent {

ngOnInit(): void {
super.ngOnInit();
this.originalComponentContent = copy(this.component.content);
this.studentChoices = this.component.isRadio() ? '' : [];
this.isCorrect = null;
this.choices = this.component.getChoices();
this.componentHasCorrectAnswer = this.hasCorrectChoices();
this.showFeedback = this.component.content.showFeedback;
this.choiceType = this.component.getChoiceType();
this.originalComponentContent = this.projectService.getComponent(
this.component.nodeId,
this.component.id
) as MultipleChoiceContent;

if (hasConnectedComponent(this.componentContent, 'showWork')) {
this.handleConnectedComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ describe('TableStudentComponent', () => {
getYAxisForDataExplorerSeries();
getYFromDataPoint();
handleConnectedComponents();
handleStudentWorkSavedToServer();
initializeDataExplorer();
isAllDataExplorerSeriesSpecified();
isDataExplorerOneYAxis();
Expand Down Expand Up @@ -612,23 +611,6 @@ function handleConnectedComponents() {
});
}

function handleStudentWorkSavedToServer() {
describe('handleStudentWorkSavedToServer', () => {
it('should handle student work saved to server', () => {
const componentState = {
componentId: componentId,
nodeId: nodeId,
studentData: {
tableData: testTableData
}
};
component.isDirty = true;
component.handleStudentWorkSavedToServer(componentState);
expect(component.isDirty).toEqual(false);
});
});
}

function isAllDataExplorerSeriesSpecified() {
describe('isAllDataExplorerSeriesSpecified', () => {
it('should check if all data explorer series are specified when it is', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,6 @@ export class TableStudent extends ComponentStudent {
}
}

handleStudentWorkSavedToServer(componentState: any): void {
if (this.isForThisComponent(componentState)) {
this.isDirty = false;
this.emitComponentDirty(false);
this.latestComponentState = componentState;
}
}

/**
* Get a copy of the table data
* @param tableData the table data to copy
Expand Down

0 comments on commit 5fcedca

Please sign in to comment.