Skip to content

Ensure edited animations are saved correctly in story, science, and poetry labs - #51393

Merged
fisher-alice merged 5 commits into
stagingfrom
alice/fix-save-animations
Apr 19, 2023
Merged

Ensure edited animations are saved correctly in story, science, and poetry labs#51393
fisher-alice merged 5 commits into
stagingfrom
alice/fix-save-animations

Conversation

@fisher-alice

@fisher-alice fisher-alice commented Apr 18, 2023

Copy link
Copy Markdown
Contributor

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 sourceURL is assigned to null and 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', the sourceURL of an edited animation is assigned to null, and these projects can be remixed without missing animation errors.

In P5.Lab.js, the sourceUrl of edited animations IS included in the list returned by getExportableAnimationList and the URL of edited animations includes the channel id of the project and the animation key stored in main.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_bucket function in projects_controller.rb. In the remix function, the project_type is assigned from params[:key]. Then uses_animation_bucket is 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) from Poetry and GamelabJr. This standalone_app_names list 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 list projects_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_hoc and time_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

  1. It still seems somewhat strange that the sourceUrl of an edited animation is assigned null. 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.' jira
  2. A small item would be renaming the poems_for_subtype method in poetry.rb to a clearer name such as poem_lists_for_standalone_app and updating references to the method. jira

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@fisher-alice
fisher-alice marked this pull request as ready for review April 18, 2023 21:34
@fisher-alice
fisher-alice requested review from a team and molly-moen April 18, 2023 21:34

private def uses_animation_bucket?(project_type)
%w(gamelab spritelab).include? project_type
%w(gamelab poetry science spritelab story).include? project_type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Discussed in Slack. Part of convo in this thread. I will incorporate her feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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!

@fisher-alice
fisher-alice requested review from a team and molly-moen April 19, 2023 18:26

@molly-moen molly-moen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ruby nit: you can omit return here, as rails methods automatically return the last line of the method

@fisher-alice
fisher-alice merged commit 9b081e1 into staging Apr 19, 2023
@fisher-alice
fisher-alice deleted the alice/fix-save-animations branch April 19, 2023 20:54
@fisher-alice fisher-alice mentioned this pull request May 18, 2023
8 tasks
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.

2 participants