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

fix/AUT-2673/inline-figure-img #2279

Merged
merged 31 commits into from
Nov 28, 2022
Merged

Conversation

marpesia
Copy link
Contributor

@marpesia marpesia commented Nov 16, 2022

Related to: AUT-2673

Changes:

Companion extensions:

How to check:

On Assets

  • Create an Asset with a text block. Add in the middle of the text an image. Play with the inline panel controls of the image to check if it is positioned correctly.
  • Check Preview.

On Items

  • Create an Item with a text block. Add in the middle of the text an image. Play with the inline panel controls of the image to check if it is positioned correctly.
  • Add the previously created Asset with the Figure image on the inline position to check the position of the Asset image inside the Item.
  • Check Preview

On Tests

  • Check Terre Preview
  • Delivery Terre

Check a test on Delivery.

@marpesia marpesia changed the base branch from master to develop November 16, 2022 09:09
@marpesia marpesia requested a review from bziondik November 16, 2022 10:04
Copy link
Contributor

@jsconan jsconan left a comment

Choose a reason for hiding this comment

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

Code check only.
It looks good.

@codecov-commenter
Copy link

codecov-commenter commented Nov 18, 2022

Codecov Report

Merging #2279 (ac7cf05) into develop (cf1ef53) will increase coverage by 0.30%.
The diff coverage is n/a.

@@              Coverage Diff              @@
##             develop    #2279      +/-   ##
=============================================
+ Coverage      15.88%   16.18%   +0.30%     
- Complexity      4194     4204      +10     
=============================================
  Files            387      388       +1     
  Lines          11700    11397     -303     
=============================================
- Hits            1858     1845      -13     
+ Misses          9842     9552     -290     
Impacted Files Coverage Δ
model/qti/asset/handler/LocalAssetHandler.php 72.22% <0.00%> (-9.03%) ⬇️
...lement/validator/PortableElementModelValidator.php 87.50% <0.00%> (-5.84%) ⬇️
model/qti/container/Container.php 40.90% <0.00%> (-0.63%) ⬇️
model/qti/Element.php 51.10% <0.00%> (-0.18%) ⬇️
...iAssetCompiler/XIncludeAdditionalAssetInjector.php 97.56% <0.00%> (-0.06%) ⬇️
model/qti/response/TemplatesDriven.php 2.15% <0.00%> (-0.05%) ⬇️
model/import/Report/ReportBuilder.php 98.70% <0.00%> (-0.02%) ⬇️
model/Config.php 0.00% <0.00%> (ø)
model/qti/Math.php 0.00% <0.00%> (ø)
model/ItemModel.php 0.00% <0.00%> (ø)
... and 146 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@marpesia marpesia marked this pull request as ready for review November 21, 2022 12:02
Copy link
Contributor

@jsconan jsconan left a comment

Choose a reason for hiding this comment

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

Code check only.
Looks okayish, but I saw a design flaw in a search algorithm. Look at my comment below.

Comment on lines 30 to 36
_.forEach(element['elements'], childElement => {
if (childElement.serial === serial) {
parent = element;
} else {
checkFigureInElement(childElement, serial);
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: the recursion looks useless as the returned value is not captured. You need to rewrite it using a local function.

suggestion: If you don't need to visit all nodes, you could optimize the algorithm by preventing a full visit of the tree as soon as you find the parent.

Suggested change
_.forEach(element['elements'], childElement => {
if (childElement.serial === serial) {
parent = element;
} else {
checkFigureInElement(childElement, serial);
}
});
const searchRecurse = parentElement => {
if (!parentElement) {
return null;
}
if (parentElement.serial === serial) {
return parentElement;
}
let found = null;
_.some(parentElement['elements'], childElement => {
if (childElement.serial === serial) {
found = childElement;
} else if (parentElement['elements']) {
found = searchRecurse(childElement);
}
if (found) {
return true;
}
});
return found;
}
const parent = searchRecurse(element)

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 for the suggestion :)

@@ -26,6 +26,12 @@ define(['tpl!taoQtiItem/qtiXmlRenderer/tpl/element'], function (tpl) {
data.tag = `${ns.name}:figure`;
}

if (!figure.attr('showFigure')) {
data.tag = 'img';
const cleanImg = data.body.split('<qh5:figcaption >');
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Is it expected to have this space inside the tag? If it is an artifact of the browser, it might not be safe as it might not always be there.

Copy link
Contributor

@bziondik bziondik left a comment

Choose a reason for hiding this comment

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

  • New code is covered by tests (if applicable)
  • Tests are running successfully (old and new ones) on my local machine (if applicable)
  • New code is respecting code style rules
  • New code is respecting best practices
  • New code is not subject to concurrency issues (if applicable)
  • Feature is working correctly on playground (if applicable)
  • Acceptance criteria are respected
  • Pull request title and description are meaningful

Copy link
Contributor

@Silvia-loza Silvia-loza left a comment

Choose a reason for hiding this comment

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

Still experiencing issue with duplicate image in authoring for both item and media manager.
image

Copy link
Contributor

@Silvia-loza Silvia-loza left a comment

Choose a reason for hiding this comment

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

Amazing job! 🎉🎉🎉

  • New code is covered by tests (if applicable)
  • Tests are running successfully (old and new ones) on my local machine (if applicable)
  • New code is respecting code style rules
  • New code is respecting best practices
  • Pull request's target is not master
  • Feature is working correctly on kitchen env (if applicable)
  • Acceptance criteria are respected
  • Pull request title and description are meaningful

@github-actions
Copy link

Version

Target Version 29.17.1
Last version 29.17.0

There are 0 BREAKING CHANGE, 0 feature, 23 fixes

@bziondik bziondik merged commit 1c4f38e into develop Nov 28, 2022
@bziondik bziondik deleted the fix/AUT-2673/inline-figure-img branch November 28, 2022 12:47
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.

5 participants