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

Invalid parameter for chapter in playground links #5

Closed
ning-y opened this issue Jun 26, 2018 · 2 comments
Closed

Invalid parameter for chapter in playground links #5

ning-y opened this issue Jun 26, 2018 · 2 comments

Comments

@ning-y
Copy link
Member

ning-y commented Jun 26, 2018

There is a change in specification for shared playground links, in the new version of source-academy at cadet-frontend.

Shared playground links must take the form,

{host}/playground#chap={chap}&ext={ext}&prgrm={lzStr}

Where

  • {host} is the host of source-academy, e.g. http://stg-cadet-frontend.s3-website-ap-southeast-1.amazonaws.com for the staging server, or https://http://sourceacademy.nus.edu.sg for deployment. Required.
  • {chap} is an integer representing the source chapter version. e.g. 1 for Source §1, 2 for Source §2, ... Optional, defaults to the latest chapter if missing or invalid.
  • {ext} is a string representing the name of the external library to be used. The list of permitted external library names are here. For example, one can specify CURVES to allow usage of the curves library in the playground upon loading the program, ... Optional, defaults to "NONE" if missing or invalid.
  • {prgrm} is a string representing the hashed program in the editor. Alternatively, the key for this parameter can also be lz, i.e. &lz={lzStr}, for back-compatibility. Required.

The order of the parameters after the hash (#) does not matter.

Examples of Valid URLs

http://stg-cadet-frontend.s3-website-ap-southeast-1.amazonaws.com/playground#chap=2&prgrm=EQQ2G4g
http://stg-cadet-frontend.s3-website-ap-southeast-1.amazonaws.com/playground#chap=2&lz=EQQ2G4g

http://stg-cadet-frontend.s3-website-ap-southeast-1.amazonaws.com/playground#chap=1&prgrm=EQQ2G4g
http://stg-cadet-frontend.s3-website-ap-southeast-1.amazonaws.com/playground#chap=2&prgrm=EQQ2G4g
http://stg-cadet-frontend.s3-website-ap-southeast-1.amazonaws.com/playground#prgrm=EQQ2G4g

http://stg-cadet-frontend.s3-website-ap-southeast-1.amazonaws.com/playground#chap=2&ext=TWO_DIM_RUNES&prgrm=EQQ2G4g
http://stg-cadet-frontend.s3-website-ap-southeast-1.amazonaws.com/playground#ext=THREE_DIM_RUNES&prgrm=EQQ2G4g

Suggestions

We use the lz-string javascript library to hash the programs into the prgrm/lz parameter value. It is probably possible to dynamically generate and parse an example program in the textbook into this hashed string, then interpolate it as a valid URL, saving a bunch of manual work (if this is not already implemented).

@martin-henz
Copy link
Member

Oh, I see. Thanks. Will ask Piao Piao to take a look.

@remo5000
Copy link

@martin-henz Hi Professor, We have added support for external libraries in the links. As such, lib has been renamed to chap due to conflict in naming, and ext is used to specify the external library. I've updated the issue above accordingly.

@remo5000 remo5000 changed the title Invalid parameter for lib in playground links Invalid parameter for chapter in playground links Jul 27, 2018
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

No branches or pull requests

3 participants