Ensure edited animations are saved correctly in story, science, and poetry labs - #51393
Conversation
|
|
||
| private def uses_animation_bucket?(project_type) | ||
| %w(gamelab spritelab).include? project_type | ||
| %w(gamelab poetry science spritelab story).include? project_type |
There was a problem hiding this comment.
rather than hard-coding the subtypes here, can we pull from standalone_app_names in gamelab_jr.rb and poetry.rb? We will probably still need to hard-code gamelab here. But if we can pull from the source of truth we won't hit this again with a future subtype.
There was a problem hiding this comment.
I pushed a commit and unsure if this is what you were thinking. One unintended effect of this change is that 'Dance' projects are now part of the list that uses the animation bucket.
Lmk if you were actually thinking of a different approach. Thanks!
There was a problem hiding this comment.
Discussed in Slack. Part of convo in this thread. I will incorporate her feedback.
There was a problem hiding this comment.
I actually omitted 2 projects in my initial commit - poetry_hoc and time_capsule so this update ensures subtype list is complete as well. Thank you Molly!
| spritelab_subtypes = GamelabJr.standalone_app_names.map {|item| item[1]} | ||
| projects_that_use_animations.concat(poetry_subtypes) | ||
| projects_that_use_animations.concat(spritelab_subtypes) | ||
| return projects_that_use_animations.include?(project_type) |
There was a problem hiding this comment.
ruby nit: you can omit return here, as rails methods automatically return the last line of the method
This PR fixes a bug in saving edited animations in poetry, science, and story projects. Reported in this Slack thread, the curriculum writer was on a csc-bookcovers level which includes edited animations, and when she attempted to remix the project, she received the error 'Sorry we couldn't load animation...'
Video before update - 'story' level/project:
Screen.Recording.2023-02-14.at.2.41.33.PM.mov
This bug also occurs in science and poetry projects if they contain edited animation.
When an animation is modified by the user, the
sourceURLis assigned tonulland in this ticket, it was noted that perhaps this may be the reason why the remixed project is unable to find the image. However, in other labs such as 'spritelab' and 'gamelab', thesourceURLof an edited animation is assigned tonull, and these projects can be remixed without missing animation errors.In
P5.Lab.js, thesourceUrlof edited animations IS included in the list returned bygetExportableAnimationListand the URL of edited animations includes the channel id of the project and the animation key stored inmain.json.The reason that 'poetry', 'science', and 'story' projects that contain edited animations currently have errors is due to their omission in the
uses_animation_bucketfunction inprojects_controller.rb. In theremixfunction, theproject_typeis assigned fromparams[:key]. Thenuses_animation_bucketis called with this parameter.At first, I added the names of the subtypes to the list. However, @molly-moen suggested that I access
standalone_app_names(the list of subtypes) fromPoetryandGamelabJr. Thisstandalone_app_nameslist is actually an array of arrays. Each subarray's first element is assigned to the subtype name with uppercase characters and whitespace and the second element is assigned the subtype name with lowercase letters and underscores. The second element is the string we need for our listprojects_that_use_animations. This ensures that if additional subtypes are created, no update will be needed to this function. Also, I had omitted two subtypes initially -poetry_hocandtime_capsule. This is also a way to ensure the list is complete.After this update, these projects were able to be remixed without missing animation errors. Thanks to @molly-moen for helping me with this update!
After update - 'story', 'science', and 'poetry' projects:
after.update-animations.mp4
Links
jira ticket - Ensure edited animations are saved correctly
Testing story
I tested locally in 'story', 'poetry', 'science', 'spritelab', and 'gamelab' projects.
Deployment strategy
Follow-up work
sourceUrlof an edited animation is assignednull. As written in this ticket, 'we may want to clean up how we save animations, as we can get into a state due to poor network connection where an updated main.json gets saved but the animation does not, as the two are saved separately.' jirapoems_for_subtypemethod inpoetry.rbto a clearer name such aspoem_lists_for_standalone_appand updating references to the method. jiraPrivacy
Security
Caching
PR Checklist: