Skip to content

Commit

Permalink
fix issue with commenting on exemplar docs
Browse files Browse the repository at this point in the history
  • Loading branch information
scytacki committed Sep 18, 2024
1 parent a76b815 commit b248042
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ describe('SortWorkView Tests', () => {
cy.visit(queryParams2);
cy.waitForLoad();
cy.openTopTab('sort-work');
cy.get('.section-header-label').should("contain", "Group 5");
cy.get('.section-header-arrow').click({multiple: true}); // Open the sections
cy.wait(1000);
studentProblemDocs.forEach(doc => {
Expand Down Expand Up @@ -307,11 +308,6 @@ describe('SortWorkView Tests', () => {
cy.log("check that exemplar document is displayed in new tag");
chatPanel.getChatCloseButton().click();
cy.openTopTab('sort-work');
// at the moment this is required to refresh the sort
sortWork.getShowForMenu().click();
sortWork.getShowForInvestigationOption().click();
sortWork.getShowForMenu().click();
sortWork.getShowForProblemOption().click();

cy.get('.section-header-arrow').click({multiple: true}); // Open the sections
sortWork.checkDocumentInGroup("Diverging Designs", exemplarDocs[0]);
Expand Down
10 changes: 9 additions & 1 deletion src/models/stores/sorted-documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,18 @@ export class SortedDocuments {
typecheck(DocumentMetadataModel, data);
const exemplarMetadata = this.exemplarMetadataDocs.get(data.key);
if (exemplarMetadata) {
// If this metadata doc in Firestore is an exemplar in the same unit then the exemplar
// metadata will be found. This will happen when a teacher comments on a exemplar.
// So in this case we need to merge the strategies from the exemplar with the strategies from
// the teacher's comments.
const authoredStrategies = exemplarMetadata.strategies || [];
const userStrategies = data.strategies || [];
data.strategies = union(authoredStrategies, userStrategies);
data.tools = exemplarMetadata.tools;
// We also update the tools incase the author has changed the exemplar content after
// the teacher commented on the document.
// We need a copy of the tools so the same array isn't attached to two MST trees at
// the same time.
data.tools = [...exemplarMetadata.tools];
}
});
return mstSnapshot;
Expand Down

0 comments on commit b248042

Please sign in to comment.