Sandbox parameters setting for external jar library files

Sandbox parameters setting for external jar library files

von JEONG CHOONG-KYO -
Anzahl Antworten: 2

Hello,


I'm using CodeRunner in a Moodle.

CodeRunner version: 5.2.2

Moodle version 4.4.1


I'd like to run students' java programs with external jar files.

I uploaded four external jar files in the "support files" and tried to set compile args and interpreter args to use those jar files in the "sandbox parameters" as follows:

{"compileargs": ["-cp", "junit-platform-commons_1.10.2.jar:junit-jupiter-api_5.10.2.jar:org.opentest4j_1.3.0.jar:org.apiguardian_1.1.2.v20211018-1956.jar"], 

"interpreterargs": ["-cp", ".:junit-platform-commons_1.10.2.jar:junit-jupiter-api_5.10.2.jar:org.opentest4j_1.3.0.jar:org.apiguardian_1.1.2.v20211018-1956.jar", "-Xss64m", "-Xmx4g"]}


However, when I tried to save the question, an error message is shown.

"Error writing to database"


I tried to set only compile args in the "sandbox parameters" as like,

{"compileargs": ["-cp", "junit-platform-commons_1.10.2.jar:junit-jupiter-api_5.10.2.jar:org.opentest4j_1.3.0.jar:org.apiguardian_1.1.2.v20211018-1956.jar"]}.

Ths time, the question was successfully saved and when I tried to run the program, it was compiled without any problem. Of course it failed to run without interpreter args.


Next I tried to set only interpreter args in the "sandbox parameters" as like,

{"interpreterargs": ["-cp", ".:junit-platform-commons_1.10.2.jar:junit-jupiter-api_5.10.2.jar:org.opentest4j_1.3.0.jar::org.apiguardian_1.1.2.v20211018-1956.jar", "-Xss64m", "-Xmx4g"]}

Ths time, the question was also successfully saved. Of course it failed to compile without compile args.


It looks like that only one parameter can be set in the "sandbox parameters".

Is there any mistake in my work? 

Please help me. Thanks!

Als Antwort auf JEONG CHOONG-KYO

Re: Sandbox parameters setting for external jar library files

von Richard Lobb -
I think the problem you've hit here is that the sandboxparams field of the question_coderunner_options database is a good (?) old char(255). So you've overrun that length. It sounds like we need to change that field size - the verbosity of Java strikes again!

In the meantime, you could either find a way to shorten the various filenames or switch to the approach used in the multilanguage question type where the control of the compile-and-run process is entirely within the python script. To see what I mean by that, create a new CodeRunner question of type multilanguage, click the Customise checkbox and read the template. Post back if you need more help.
Als Antwort auf Richard Lobb

Re: Sandbox parameters setting for external jar library files

von JEONG CHOONG-KYO -
Hi Richard,
I solved my problem by shortening file names as you suggested.
Thanks a lot!
Meanwhile, the multi-language question type approach sounds interesting.
I'd like to look at it after my immediate work.