CoCalc Blog

Embedding CoCalc in Your Application

Harald Schilly and Hal Snyder • • cocalc

Add scientific computing to any online training platform by embedding CoCalc.

Embedding CoCalc into an online learning platform or learning management system (LMS) adds:

For readers unfamiliar with the platform, the next two sections introduce two key features of CoCalc, notebooks and markdown.

Jupyter Notebooks

These interactive documents mix executable code cells with cells for Markdown text (see below).

A notebook contains headers and sections, text with explanations, and code with plots. Creating an assignment can be as simple as leaving selected code cells empty.

Multiple notebooks per topic are supported. Splitting a topic keeps the scope of a learning session manageable and reduces the confusion that can arise from large numbers of variables.

CoCalc users can choose from a growing list of tutorial notebooks and texts in the CoCalc library, which allows files to be copied directly into a CoCalc project.

Markdown

Markdown is a simple way of formatting text. It is easy to learn and converts readily into other online formats such as HTML. There are several descriptions online, including the one-page summary at CommonMark, which also includes a link to a brief tutorial.

Markdown is used in Jupyter notebooks and CoCalc worksheets for explanatory text, which can include mathematical expressions typeset in LaTeX. A typical notebook is an executable narrative consisting of alternating markdown and code cells.

CoCalc Pricing

CoCalc pricing is based on upgrade packages that include network access, disk space, memory, etc. You can apply upgrades to any project on which you are an owner or collaborator. Upgrades are available under two types of plan:

https://cocalc.com/policies/pricing.html

The API

The basic setup is to get an API key from your account page, and then issue calls to CoCalc. You can create accounts and projects, and coordinate everything using your own system and database. The CoCalc website has an API reference which documents each call and provides examples. The CoCalc team will work with customers to resolve any issues that arise.

Minerva Schools at KGI are using the CoCalc API to enable their students to work in Jupyter notebooks embedded inside an iframe on their website.

IFrame URLs

You may want to remove the upper menu bars when embedding a CoCalc file in your application. In that case, there is a special syntax for the URL to the file. The word “files” appears within the URL and “?session=&fullscreen” is appended to the URL.

Here’s an example:

https://cocalc.com/projects/cd3c25e4-5fbd-439b-9604-6011584af918/files/EMBED/batman-python.ipynb?session=&fullscreen

To prevent exiting fullscreen mode, append “=kiosk”.

https://cocalc.com/projects/cd3c25e4-5fbd-439b-9604-6011584af918/files/EMBED/batman-python.ipynb?session=&fullscreen=kiosk

Conclusion

If you already have an online learning platform and want to include the scientific computing features that CoCalc has to offer, you can use the pointers above to get started. To learn more, contact CoCalc support via email or visit the CoCalc help page online.