Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAK-51055 T&Q cc+ import issues with embedded image in CKEditor #13423

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

csev
Copy link
Contributor

@csev csev commented Mar 8, 2025

There are three steps to this change - they are separate commits below:

  1. Make it so that "Import from Site" fixes embedded images in the correct and incorrect feedback.
  2. Make it so that "Import from Site" handles embedded LTI links (shipping cart) in all RTE areas
  3. Make it so that "Lessons - Import from CC+" also works across all RTE areas and attachments

To do this, I extended the calling sequences for internal methods for updateEntityReferences() and migrateText() so they can handle the "Import from Site" or "merge()" use cases. The method signatures got a little long but I really wanted to avoid duplicating the complex code that goes through and finds all the RTE areas post copy or post merge. It seemed more reliable in the long run the have a few more parameters and if tests that a lot of intricate code duplicated.

@stetsche Since this touched your work on performance improvement on Samigo site copy - I think it needs a review from you.

Comments welcome.

@csev csev requested a review from stetsche March 8, 2025 16:10
@csev csev marked this pull request as draft March 8, 2025 16:10
@csev
Copy link
Contributor Author

csev commented Mar 9, 2025

@stetsche Since this touched your work on performance improvement on Samigo site copy - I think it needs a review from you.

@csev csev marked this pull request as ready for review March 9, 2025 16:45
@csev csev requested a review from bgarciaentornos March 10, 2025 07:27
Copy link
Contributor

@stetsche stetsche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@csev , thanks for the improvements! I left a few comments regarding some context and your changes. Do you think we should do another iteration of performance testing with the added code, or do you think it's really light additions?
CC: @bgarciaentornos

@@ -453,25 +472,26 @@ public void updateEntityReferences(String toContext, Map<String, String> transve
continue;
}

// TODO: why are these copyAttachments = false?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I can't answer the why definitely, what copyAttachments does, did not happen for instructions and descriptions, so that boolean exists to keep the previous behavior. My focus was on improving performance while maintaining functionality, I didn't want to add more process time, especially without fully understanding this why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel the same - it looks like copyAttachments makes another copy of embedded things like images attachments and only is used for the questions and answers and not the assessment-level text - so I will follow that pattern as well.

"feedback" + itemFeedback.getTypeId(), itemContentCache, entrySet, transversalMap, mcx, itemFeedback.getText());
log.debug("after migratedText: {}", migratedText);
itemFeedback.setText(migratedText);
itemFeedbacksChanged = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check for a change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Thanks.

return false;
}

private String migrateTextString(AssessmentService assessmentService, String toContext, String itemHash,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand this yet. It looks like you added some code to the part where the migration happens and then moved that into it's own method. But why does that also include the caching part? We would be double checking the caches?
If I understand the changes right, I think migrateTextString should just migrate without checking the cache and migrateText would call it after checking caches.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I will look into that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I will move all caching into migrateTextString(). The way I first did it avoided allocating one string that would be quickly deallocated. But making the code simpler and clearer and not duplicating logic is more important. Now migrateText() relies on migrateTextString() completely including all cache processing except for the check for differences, and using the setter and getter. I wanted the instruction text to be cached as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move caching to migrateTextString what purpose is left for migrateText? Why do we actually need two methods?
Either way, please ping me when you want me to look at it again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the use of migrateTextString again, it looks like the only difference is that you apply getter and setter manually. If you pass ItemFeedback::getText and ItemFeedback::setText to migrateText should do that for you, also returning the value for of itemFeedbacksChanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants