How to make a Snap! block listener in javascript?

yeah that's why I got a bit confused Iframe is like putting another webpage inside a webpage right?

The autograders I know about have code both in the Snap! iframe (i.e., Snap! code) and code in the outer page (JS code). I'm guessing you're worried about students cheating if they have access to the Snap! part of the connection? If so, the problem isn't insecurity of the Snap! code; it's giving grades.

I see so how does Snap*!* code interact with external JS code?

Good question, but I don't really know the answer. See if I can find out...

Alright thank you so much for helping thus far!

I made "proof of concept" of modified Snap! https://replit.com/@DarDoro/SnapEmbed#snap.html
The "check" button builds the "spec" of the sprite[0]=>script[0] for simple script (no loops, if's, rings). You can test the entire spec or just count the lines.

function scriptSpec( script){
     if(!script?.blockSpec) return "";
     return script.blockSpec+";\n"+scriptSpec( script?.children.find( elem => elem?.blockSpec));
}

function checkIt(){
   alert( scriptSpec( world.children[0].sprites.contents[0].scripts.children?.[0])); 
}

As for Snap! to JS, there is an official api.js. And JSFunction in Snap! itself to call JS code.

SnapEmbed

Warning: you get access to server backend (login, projects) only if you convince Snap! dev's to whitelist your host

I have been exploring autograding in NetsBlox (and will have a workshop at Snap!Con if you are interested!). Currently, we have been creating autograders using NetsBlox (and for NetsBlox) which can then be loaded via query string parameters. When the autograder is loaded, the user can switch between different assignments, view the tests, and submit them (if the integration is specified when creating the autograder - only coursera is supported at the moment).

An example can be found here and the documentation can be found here. When the tab is opened with the autograder, there will be a new button by the code stepping button on the top right portion of the IDE. This button can then be used to start and grade assignments, etc.

So far, we have been focusing mostly on testing custom blocks (often as Parsons problems) but would like to be able to support richer forms of assessment in the future. Test cases specify a custom block and either a set of inputs and expected output or a function that will evaluate the given block (defined via blocks). The example uses a custom block to help create the former; an example of the latter can be found below.

myRole script pic (1)

The above example is testing a block which is a generator producing counting numbers (using HoFs). The test is checking that two different invocations of the generator do not share memory but produce two independent sequences of counting numbers. (This type of test case is not yet supported on editor.netsblox.org but will be soon.)