SageCell

Filters ::: filter_sagecell
Maintained by Eugene Modlo, Sergey Semerikov
A Moodle filter plug-in to view results of Sage code using the SageMathCell server. It embeds any code as plain text. This filter will replace Sage code in [sage]...[/sage] block with the result of calculations in embedded sagecell.
Latest release:
33 sites
3 downloads
5 fans
Current versions available: 1

SageCell


A Moodle filter plug-in to view results of Sage code using the SageMathCell server.
It embeds any code as plain text.

NOTICE: this software is in no way endorsed by or affiliated with the official SageMath project or team.

This filter will replace Sage code in [sage]...[/sage] block  with the result of calculations in embedded sagecell.

Installation

To install (on Moodle 3.4):

  1. Un-compress the Zip/Gzip archive, and copy the folder renamed 'sagecell' to your moodle/filter/ directory.
  2. Log in to Moodle as admininstrator, go to Site Administration | Plugins | Filters | Manage Filters.
  3. Choose 'On' or 'Off but available' in the drop-down menu next to 'SageCell'.


Usage

The syntax to embed a Sage code:

    [sage]...[/sage]


Links


Notes

  • Tested in Moodle 3.4.1.
  • No database access, JavaScript only
  • Filter syntax is case-sensitive.


Notices

SageCell plugin, Copyright (c) 2015-2018 Eugene Modlo, Sergey Semerikov.
* License: <http://www.gnu.org/copyleft/gpl.html>; GNU GPL v3 or later.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2

Contributors

Eugene Modlo (Lead maintainer)
Sergey Semerikov
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Plugins bot
    Tue, Apr 28, 2015, 4:01 PM
  • David Mudrák
    Tue, Apr 28, 2015, 10:13 PM

    Hi Eugene. Thanks for sharing the filter with the community. While reviewing the implementation, I discovered some issues and reported them into your bug tracker. So far, the bug #1 and the security bug #5 are currently approval blockers but ideally all the issues should be addressed. I am going to mark this as needing more work for now.

  • David Mudrák
    Thu, May 7, 2015, 10:24 PM

    Hi. I am sorry, but the XSS fix is not good enough - I was able to easily bypass it by using [sagecell]&lt;/script&gt;&lt;script&gt;alert('You are doomed!');[/sagecell]. I don't know details of the SAGE syntax but I am wondering if you can check how the Moodle core function clean_text() is implemented and whether it could be used to clean up the user's input without negatively affecting the filter functionality. Marking as needing more work again.

  • David Mudrák
    Sat, Aug 13, 2016, 3:30 AM

    Thanks for the updated version. Please see your tracker for a reported recommendation to remove the empty settings.php file (leading to an empty settings page). Also note it might help to provide some examples of actual SageMathCell syntax in the description.

    Let me suggest to improve the implementation of the inputLocation selector. Any div with the class compute is currently processed on the page once the script is executed. It also seems quite ineffective when there are multiple cells created on the page.

    This can be approved now. You are cleared to land, welcome to the Plugins directory!

  • Ger Tielemans
    Wed, Aug 17, 2016, 1:51 PM
    When I try the demo with agoogle account I get:


    ( ! ) Warning: require_once(../../lib/pluginlib.php): failed to open stream: No such file or directory in /home/ccjourna/public_html/vtutor/auth/elcentra/google_response.php on line 26
    Call Stack
    # Time Memory Function Location
    1 0.0009 237216 {main}egg .../google_response.php:0
  • Ger Tielemans
    Thu, Feb 2, 2017, 12:55 AM
    Works now fine in 3.2
  • Ger Tielemans
    Fri, Jan 19, 2018, 7:42 PM
    David, is the XSS filter the problem here and can you solve it without losing security?

    We have lecturers who teach Math, Python, R and are jumping between Moodle en Jupyter Notebook to allow students use editors with code evaluate options. I found in Moodle the Sage filter which connects to a SageCell server.
    Sage had a Sage Notebook, but is now creating a version (8.1) on top of Jupyter Notebook: http://www.sagemath.org/

    If you wish to use the complete functionality of Jupyter (and the new JupyterLab) you stick to that,
    but why not have the option to connect to the server and borrow editor boxes you merge in a Moodle book, so you can combine the options from Moodle with such editors?

    The Sage plugin asks now for code between the sage tags like [sage]1+2[/sage] and shows only the result.

    If you change the plugin in your own moodle it can also offer Sage in editor mode [sage]...[/sage] and then you can type - in Moodle - code. If you then press evaluate it works.

    If you wish to create a "Jupyter-like" Moodle book you wish to offer students combinations of text with empty editors and editors already filled with code where students have to press the evaluate button like [sage]example code[/sage]

    BUT: when there are symbols in the code like < or > our Moodle/server combination FIRST replaces < with: & l t ;
    If you press " evaluate" you get an error, but if you manually put the code symbol back and then press it works fine...

    How to overrule this Moodle action? (store & l t ; in database and translate the code back before it opens in the editor?
  • Ger Tielemans
    Fri, Jan 26, 2018, 6:05 PM
    Another comment:
    If I add the following code in the online SageCell editor (Sagemath.org), I get correct answers.
    If I put it in the SageCell editor, I get 4 times [math error] instead of the big numbers. The plot is the same. My question: is SageCell connecting to a different server?
    #2017 AB2 (GC)
    f(t)=10+0.8*t*sin(t^3/100)
    g(t)=3+2.4*log(t^2+2*t)
    #2a)
    show(integrate(f(t),t,0,2).n())
    #2b)
    fp(t)=diff(f(t),t)
    show(fp(7).n())
    #2c)
    show((g(5)-f(5)).n())
    #2d)
    show((50-integrate(f(t),t,0,3)+integrate(g(t)-f(t),t,3,8)).n())
    #graphs
    plot([f(t),g(t)],0,8)
Please login to post comments