jcrodriguez-dis / moodle-mod_vpl

Virtual Programming Lab for Moodle (Module)
GNU General Public License v3.0
98 stars 85 forks source link

Webservice mod_vpl_open crashes if any submission is not text #137

Closed nikosdimitrakas closed 1 year ago

nikosdimitrakas commented 1 year ago

It appears that the webservice mod_vpl_open returns an empty string instead of an object (with zero or more files) if any of the submitted files is non-textual. I have tried a couple of cases: A student has two java-files = Works fine. I get the file names and file contents. A student has not submitted anything = Works fine. I get an object with no files. A student has submitted an icon-file (which renders fine in the GUI of VPL) = Does not work. I get an empty string. A student has submitted a java file and a jpg file (both render fine in the GUI) = Does not work. I get an empty string.

Possible solutions/expected behaviours:

  1. Return the file names and something like "Non-text file" as data. Not the best solution, but at least a correct response.
  2. Return file names and urls for download, just like the mod_assign_get_submissions does. Then a separate call would be required to actually retrieve the file. This could be done for all files, or for all non textual files. Then it could be that the response includes either data (for textual files) or fileurl (for non textual files). Never both.
  3. Block non textual files from being uploaded in the first place. Probably a bad idea though.
  4. Exclude non textual files from the response. It can be confusing, but at least the significant files would be in the response.
jcrodriguez-dis commented 1 year ago

The issue has been resolved in VPL 4.1.0 by accepting binary files using Base64 encoding. Each file's information now includes the file name, data name, and the encoding indicator. A value of 1 indicates that the data is encoded in Base64, while 0 indicates no encoding. See the WebService API documentation for more details.