-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
There was a problem hiding this 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 Report
@@ 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
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this 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.
_.forEach(element['elements'], childElement => { | ||
if (childElement.serial === serial) { | ||
parent = element; | ||
} else { | ||
checkFigureInElement(childElement, serial); | ||
} | ||
}); |
There was a problem hiding this comment.
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.
_.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) |
There was a problem hiding this comment.
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 >'); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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
Version
There are 0 BREAKING CHANGE, 0 feature, 23 fixes |
Related to: AUT-2673
Changes:
Companion extensions:
How to check:
On Assets
On Items
On Tests
Check a test on Delivery.