-
Notifications
You must be signed in to change notification settings - Fork 0
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
add optional figure reference baking injected exercises #432
Conversation
Codecov Report
@@ Coverage Diff @@
## main #432 +/- ##
=======================================
Coverage 99.96% 99.96%
=======================================
Files 179 181 +2
Lines 2712 2739 +27
=======================================
+ Hits 2711 2738 +27
Misses 1 1
|
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.
I think a better place for this change would be in the BakeInjectedExercises
class -- this is where the 'Refer to...' text is baked in the first place! I assume this change would only be for single-part exercises?
# | ||
# @return [Element] | ||
# | ||
def exercise_context |
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.
this should probably go on the InjectedExerciseElement
class -- if it doesn't exist, it seems like it should be created
@@ -41,11 +42,15 @@ def bake(question:, number:, only_number_solution:) | |||
end | |||
end | |||
|
|||
context = question.ancestor(:injected_exercise).exercise_context&.cut&.paste if figure_reference |
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.
@kswanson33 I have tried refactored the code with your requested changes but I've got stuck in this particular place and got such error:
In my recipe I'm using this loop, where it is not pointing to injected_exercises but
exercise_question``:
and I guess this is the reason why I can't select an ancestor for the exercise_question
of given type (`:injected_exercise`). Do you think there is a need to change the `BakeInjectedExerciseQuestion` to point `injected_exercises` instead of `exercise_question` I'm asking because it will need to be updated in some of the recipes? I can also use `context = question.parent.first("div[data-type='exercise-context']")&.cut&.paste if figure_reference` instead (it's working properly then). Or maybe you can see a different approach here, rewrite the loop in the recipe somehow? Let me know if you will have some suggestions. 🙂
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.
@kswanson33 could you also explain what did you mean by single-part exercises
?
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.
Hi @kswanson33 After Larissa's comment I have reworked the PR to only move the |
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.
looks really good! two little comments but other than that it's fantastic :)
CHANGELOG.md
Outdated
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
|
|||
* Add `BakeScreenreaderSpans` direction (minor) | |||
* Fix `BakeIndex` to group terms by character in polish books and transliterate it for others (minor) | |||
|
|||
* Add `figure_reference` option for `BakeNoteInjectedQuestion` to bake exercise-context figure reference (minor) |
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.
Don't forget to update the changelog to reflect the new change! I believe this change is major
as single-part injected exercises should always be changed.
end | ||
|
||
class V1 | ||
def bake(question:, number:, only_number_solution:) | ||
def bake(question:, number:, only_number_solution:, figure_reference:) |
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.
do we need an argument here? probably this should always be true
Issue: https://github.com/openstax/cnx-recipes/issues/4177