Error
There was an error loading the page.
Metadata
-
England schools
-
England university
-
Scotland schools
Taxonomy: mathcentre
Taxonomy: Kind of activity
Taxonomy: Context
History
Christian Lawson-Perfect 1 year, 10 months ago
Published this.George Stagg commented 3 years, 1 month ago
SVG output now works. I've compiled the svglite package for webR and set things up so it can be loaded into the filesystem.
I tried to make it work nicely by adding a r_load_package(pkg_name) function that takes a package name and loads it, ready to be used with R's library() function, and add it to the pre_submit note so that it loads the package before the student's code runs. However, there's an issue where unless the webR runner is already loaded and ready to go the image doesn't appear until the second time the part is submitted.
When it happens the output svg doesn't exist in the virtual filesystem at all, so I think there's an issue with my promises that are supposed to resolve only once the WASM libraries are finished compiling. I've worked around it for now by loading the package in the question preamble.
George Stagg 3 years, 1 month ago
Saved a checkpoint:
Tweaked for newest version of the runner and SVG file output.
George Stagg commented 3 years, 1 month ago
That's awesome, thanks! Pyodide gives access to the same Emscripten filesystem API that I'm using for webR here, via pyodide.FS. So, later if we like this method we should be able to extend it to do the same thing there.
Christian Lawson-Perfect commented 3 years, 1 month ago
I've written a generic r_load_files function to load a list of files out of the webR environment. For pdfs it returns a blob URL; for everything else it returns the contents of the file as a string. This is a promise, so you can use it as a pre-submit task; it fills in the entry 'r_files' in the pre_submit note.
I made the feedback() marking function take HTML, so you can display the plot in the feedback without any magic.
The blob URLs won't work in suspend data. We need a reliable way of serializing file binary contents to strings. base64 encoding is the only thing i can think of at the moment.
The load_files function should be built in to the extension, and work for whatever language runner.
George Stagg 3 years, 1 month ago
Created this.Name | Status | Author | Last Modified | |
---|---|---|---|---|
Make a plot | draft | George Stagg | 13/09/2024 11:05 | |
Make a plot with matplotlib | draft | Christian Lawson-Perfect | 10/05/2023 13:31 | |
Make a plot with matplotlib | Ready to use | Christian Lawson-Perfect | 23/11/2023 11:37 | |
Make a plot | Ready to use | Christian Lawson-Perfect | 24/07/2024 10:28 | |
Plotting a parametric surface with Python | draft | Toby Wood | 03/04/2024 14:59 |
There are 21 other versions that do you not have access to.
Name | Type | Generated Value |
---|
write_file_example | string |
txt <- "Hello World"
writeLine
|
Generated value: string
This variable doesn't seem to be used anywhere.
Use this tab to check that this question works as expected.
Part | Test | Passed? |
---|---|---|
Code | ||
Hasn't run yet | ||
Information only |
This question is used in the following exam: