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

Instant visualization updates for artist #24196

Merged
merged 15 commits into from Aug 28, 2018
Merged

Instant visualization updates for artist #24196

merged 15 commits into from Aug 28, 2018

Conversation

balderdash
Copy link
Contributor

@balderdash balderdash commented Aug 9, 2018

Add a level option to immediately rerun code on block space changes.

auto-artist

@balderdash balderdash force-pushed the auto-artist branch 3 times, most recently from a9e0093 to 72514e6 Compare August 9, 2018 21:45
@balderdash
Copy link
Contributor Author

@balderdash
Copy link
Contributor Author

Also added a "limited" version of autorun that

  • Only redraws in response to block changes after a normal animated draw completes, but before you hit reset (so it doesn't just show up in the view space before you even hit run)
  • Doesn't allow you to move blocks around while it's active, only allowing you to edit field values.

I'm not a huge fan of this mode, but we want to find a way to give you the convenience of autorun when fiddling with lengths and values, but still try to make you think about actual program flow when arranging blocks.

Copy link
Contributor

@Hamms Hamms left a comment

Choose a reason for hiding this comment

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

Can you explain a bit what problem the immovable blocks stuff is trying to solve?

= boolean_check_box f, :auto_run
.field
= f.label :limited_auto_run, 'Automatically rerun on block changes, but only allow field edits'
= boolean_check_box f, :limited_auto_run
Copy link
Contributor

Choose a reason for hiding this comment

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

should this instead be two potential modes for the single auto_run field?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, done.

// Droplet doesn't automatically bubble up aceEditor changes
this.studioApp_.editor.aceEditor.on('change', changeHandler);
}
this.studioApp_.addChangeHandler(this.rerunSetupCode.bind(this));
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

if (!block.isMovable()) {
this.immovableBlocks.push(block);
} else {
block.setMovable(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this gonna mess up any blocks that are supposed to be immovable on initialization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't because I'm tracking the blocks that were initially immovable in this.immovableBlocks. However, it can cause problems if the project autosaves when you're in the immovable mode and you reload the page. I changed the implementation by adding lockMovement()/unlockMovement() methods to blockly in code-dot-org/blockly#145.

@@ -341,6 +349,20 @@ Artist.prototype.init = function (config) {
if (finishButton) {
dom.addClickTouchEvent(finishButton, this.checkAnswer.bind(this));
}

if (this.autoRun) {
Copy link
Contributor

@joshlory joshlory Aug 13, 2018

Choose a reason for hiding this comment

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

Should any of this live in https://github.com/code-dot-org/artist? If a 3rd party wanted to create a demo like the one in the PR description .gif, what additional code would that require?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That repo just has a visualizer, anyone who integrates it still has to provide their own code editor, and then decide when/how often to call display(). Just like I did in this PR, they would have to start calling display() on every code change in their code editor, in addition to/instead of their version of a run button click.

@joshlory
Copy link
Contributor

I'd love to see a test coverage plan if this isn't something we're going to release in Curriculum right away. Basically: how do we get notified if some other change breaks this?

Super awesome feature!

@joshlory
Copy link
Contributor

When you merge, can you remove it from the Dessert Menu and send mail? Thanks!

@balderdash
Copy link
Contributor Author

Can you explain a bit what problem the immovable blocks stuff is trying to solve?

Curriculum team wants students to be able to figure out how a program would run before running it, but autorun would make it too easy to avoid practicing that skill on artist levels. However, they still want students to be able to take advantage of autorun to fiddle with angles and lengths, since that's not really what we're trying to teach, and it can be really annoying to wait for the whole program to run multiple times just to get one of those numbers right.

@balderdash
Copy link
Contributor Author

Re: testing, I added better unit test coverage and a pretty basic eyes test.

@balderdash
Copy link
Contributor Author

@Hamms PTAL

Copy link
Contributor

@Hamms Hamms left a comment

Choose a reason for hiding this comment

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

Love the testing!

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.

None yet

3 participants