Skip to content

Player examples

Two ways to feed <astl-player>, both running in this page. Every attribute, property, method and event: Player reference.

The exercise of examples/static-html, compiled in this page and graded with localChecker, as astrolabe.js does it. The log lists the player's events as they happen: answer something, press "Check", go to page 2.

An elephant is gray, and a trout is a .

Which animals are mammals? Otter Trout Mole

Half of one is .

How many legs does a spider have? Six Eight Ten

Events, newest first

    Here the page plays only the compiled view, as it would with a server. The checker stands in for the grading endpoint: under PRACTICE_POLICY the player shows "Check"; under TEST_POLICY it shows "Hand in", the checker refuses checks, and the result reveals the score only.

    Policy

    The same calls, written out:

    // On the server: compile once, keep the key.
    const result = await engine.compile(source, { salt: 'exercise-42' });
    // In the browser, with a real server:
    // <astl-player src="/v/<viewHash>.html" integrity="<viewHash>" endpoint="/api/attempts/123">
    // Here, with a checker that grades in the page instead:
    await player.load({ view: result.view, policy: TEST_POLICY, checker: localChecker(engine, result.key, TEST_POLICY) });