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

Saving for Widgets #2017

Open
pikurasa opened this issue Jan 7, 2020 · 14 comments
Open

Saving for Widgets #2017

pikurasa opened this issue Jan 7, 2020 · 14 comments
Labels

Comments

@pikurasa
Copy link
Collaborator

pikurasa commented Jan 7, 2020

Students expect that their work is saved in the widgets and are often disappointed when it is not.

Further, sometimes teacher and student find they need to refresh the browser, which causes work in the widget to be lost. (Notably, losing data seems to be inevitable when encountering issue 1936 as there is no access to save or play).

I see two solutions:

  • Save state of widget upon .html save
  • Prompt the user to "export/save their current widget data and save as .html" when user refreshes the browser.

The former (probably) requires more internal bookkeeping of data, but would guarantee they keep their work. The latter uses our current methods, but gives the user another reminder and chance before losing their data.

@walterbender
Copy link
Member

I think we can save widget state in the widget block much the way we save start block state in the start block:

[0,["start",{"collapsed":true,"xcor":0,"ycor":0,"heading":0,"color":80,"shade":40,"pensize":5,"grey":200,"name":"start"}],573,-1840,[null,1230,null]]

@bhngupta
Copy link

Hey, can I take up this issue?

@walterbender
Copy link
Member

Feel free to jump in. Might want to work on the phrase maker first.

@bhngupta
Copy link

Feel free to jump in. Might want to work on the phrase maker first.

Sure thing

@bhngupta
Copy link

bhngupta commented Jan 22, 2020

I think we can save widget state in the widget block much the way we save start block state in the start block:

[0,["start",{"collapsed":true,"xcor":0,"ycor":0,"heading":0,"color":80,"shade":40,"pensize":5,"grey":200,"name":"start"}],573,-1840,[null,1230,null]]

Hey @walterbender , in which files will I find widget state?

@walterbender
Copy link
Member

I don't think we need to do every widget. Probably just the phrase maker and rhythm maker.
The relevant code would be:

https://github.com/sugarlabs/musicblocks/blob/master/js/widgets/pitchtimematrix.js#L71

and

https://github.com/sugarlabs/musicblocks/blob/master/js/widgets/rhythmruler.js#L33

@Ishakikani9117
Copy link
Contributor

@walterbender , Can I work on this issue?Can you explain a little bit more about how to solve it?

@walterbender
Copy link
Member

Please read the discussion above. It pretty much summarizes the work that needs to be done.

@Ishakikani9117
Copy link
Contributor

@walterbender ,Hello , Would you please help me with this issue?Its a little bit tricky for me.

@Ishakikani9117
Copy link
Contributor

I think we can save widget state in the widget block much the way we save start block state in the start block:

[0,["start",{"collapsed":true,"xcor":0,"ycor":0,"heading":0,"color":80,"shade":40,"pensize":5,"grey":200,"name":"start"}],573,-1840,[null,1230,null]]

@walterbender where can i find the code for start block?I mean in which file?

@walterbender
Copy link
Member

Tip of the day: grep can be used to find things.

grep -R start

But I think you want to look for the saving and loading code for the start block, which is found in activity.js and blocks.js

@Ishakikani9117
Copy link
Contributor

Ishakikani9117 commented Feb 16, 2020

@walterbender ,Do you mean that the selected notes in the matrix should be black,even if the user refreshed page?

And if you're saying that if the user has not saved project yet and the action block disappears after he refreshes the page, then just play the block once by clicking on 'action'.So even if we refresh without saving, it won't disappear.

@Ishakikani9117
Copy link
Contributor

@walterbender , I have a question.If I want to work on this project,do I have to have a deep knowledge about music , like about different scales and keys?

@walterbender
Copy link
Member

@Ishakikani9117 I am not sure this is a good issue to work on as a first introduction of Music Blocks. But to answer your questions:

  • Music Blocks always tries to preserve your current state when you return to it (for example, refreshing your browser) without requiring an special action on the part of the user.
  • Most widgets preserve their state between closing and reopening them in a session, but lose state in a browser refresh -- the point made by @pikurasa when he created this issue. I have suggested that the same mechanism we use to save the position, heading, etc. of the mouse -- by adding a dictionary object to the block in the project's JSON output -- could be used for widgets. I've already pointed you to the relevant code in an earlier comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants