INGInious / problems-blockly

INGInious plugin for adding Blockly problems
GNU Affero General Public License v3.0
2 stars 4 forks source link

Conflict of ID between blocs in workspace and toolbox #28

Open cyrilledebongnie opened 2 years ago

cyrilledebongnie commented 2 years ago

When creating a variable with the same name present both in the workspace and the toolbox, a bug will appear when you try to solve the task. The blocs (getter - setter - variable) from the toolbox cannot be dragged onto the workspace, as there is a conflict of ID.

Error message : Uncaught Error: Variable "test" is already in use and its id is "Gb:rfS?s2I9-yzU+:m4C" which conflicts with the passed in id, "wm||];n1QbzdRrI@1wT|".

However you can resume using those blocs from the toolbox if you first manually change the getter/setter/var to any variable then again to your variable, it seems to reset the ID of the variable in the toolbox to the ID of the variable in the workspace.

A quickfix is to use the online factory from google ( https://blockly-demo.appspot.com/static/demos/blockfactory/index.html ) and after setting up your workspace from it, export the XML. Using this XML on the INGInious platform seems to do the trick. It's worth noticing that doing so, since it uses hardcoded ID's, prevents any other modification from the graphical interface.

A suggestion to fix this would be to change the path of the factory files currently in use, to the more recent ones present on the INGInious github.

Kind regards

ogoletti commented 2 years ago

You mean when creating a variable with the workspace editor of a blockly task on inginious.

Also, if I remember what you told me, for the proposed quickfix to work, you need to create the workspace first and the toolbox is generated by the facotry or something like that?

For the fix, my understanding is the actual factory used in inginious' task editor use old blockly js (here:https://github.com/UCL-INGI/INGInious-problems-blockly/blob/c8e30a5013260d2f649cdcf73d1b5573c8bd3004/inginious-problems-blockly/templates/editbox_blockly_templates.html#L101) the js files are 4 years old and have been copied here https://github.com/UCL-INGI/INGInious-problems-blockly/tree/master/inginious-problems-blockly/static/blocklyfactory but we should use the ones in the blockly submodule (in demos/blockfactory). Not sure whether thoses files were modified though.

cyrilledebongnie commented 2 years ago

You mean when creating a variable with the workspace editor of a blockly task on inginious.

Yes I forgot to specify that indeed.

Also, if I remember what you told me, for the proposed quickfix to work, you need to create the workspace first and the toolbox is generated by the facotry or something like that?

Yes, the workspace factory proposes that you store the generated blocs of the workspace into categories in the toolbox, if you do not accept the toolbox is not created along (also the google factory glitches a bit)

For the fix, my understanding is the actual factory used in inginious' task editor use old blockly js (here:

https://github.com/UCL-INGI/INGInious-problems-blockly/blob/c8e30a5013260d2f649cdcf73d1b5573c8bd3004/inginious-problems-blockly/templates/editbox_blockly_templates.html#L101

) the js files are 4 years old and have been copied here https://github.com/UCL-INGI/INGInious-problems-blockly/tree/master/inginious-problems-blockly/static/blocklyfactory but we should use the ones in the blockly submodule (in demos/blockfactory). Not sure whether thoses files were modified though.

Thanks for the clarification, my message was unclear here as well

anthonygego commented 2 years ago

For the fix, my understanding is the actual factory used in inginious' task editor use old blockly js (here:

https://github.com/UCL-INGI/INGInious-problems-blockly/blob/c8e30a5013260d2f649cdcf73d1b5573c8bd3004/inginious-problems-blockly/templates/editbox_blockly_templates.html#L101

) the js files are 4 years old and have been copied here https://github.com/UCL-INGI/INGInious-problems-blockly/tree/master/inginious-problems-blockly/static/blocklyfactory but we should use the ones in the blockly submodule (in demos/blockfactory). Not sure whether thoses files were modified though.

There is high chance they were not modified, even if I remember having imported them from the old repo without any further check. This made me realize there is no copyright mention in those files (happily the license at least is OK). That would be worth updating them.

@Drumor I see the blocky submodule has been updated 2 years ago but files copy never updated in the /static folder... there were also changes in the local wrapper js at the same time (see 3495a6b7f436e9370e6eeb4a6cd02abbe78a23f9), this is a bit confusing...