Good Morning,
We have been using Coderunner for the last year quite successfully with the built in languages. We recently decided we wanted to add the ability the run F# questions as well. Following the documentation, I am able to get the jobe server to respond to the request from the Moodle server, but depending on how we structure the call, we either get a compilation error or a time exceeded error. the example we are using to test is a simple printfn "Hello World"
For reason, I don't believe the code is executing past Line 19 ( print("**Compilation failed. testing Aborted **")).
I based the creation of the question type on an older forum post describing how to compile C# using mono. (for various reasons DotNet is to be used over mono).
I would greatly appreciate it if people could provide some insight into my problem. Please find below a copy of the question we have created as well as images of the error messages.
===============================================================
import subprocess, sys, os
# Write the student code to a file prog.cs
student_answer = """{{ STUDENT_ANSWER | e('py') }}"""
with open("test.fsx", "w") as src:
print(student_answer, file=src)
e=os.environ.copy()
e["DOTNET_CLI_HOME"] = os.getcwd()
e["DOTNET_CLI_TELEMETRY_OPTOUT"] = "true"
# Compile
print("testing- Pre Call.")
return_code = subprocess.call(['dotnet','fsi','test.fsx'], env = e, shell=True) ## returns an compilation error see comp error
# return_code = subprocess.call("dotnet fsi test.fsx", env = e, shell=True) ## returns a Time Out Error.
print(return_code)
if return_code != 0:
print("** Compilation failed. Testing aborted **", file=sys.stderr)
# If compile succeeded, run the code. Since this is a per-test template,
# stdin is already set up for the stdin text specified in the test case,
# so we can run the compiled program directly.
if return_code == 0:
try:
output = subprocess.check_output("dotnet fsi test.fsx", universal_newlines=True)
print(output)
except subprocess.CalledProcessError as e:
if e.returncode > 0:
# Ignore non-zero positive return codes
if e.output:
print(e.output)
else:
# But negative return codes are signals - abort
if e.output:
print(e.output, file=sys.stderr)
if e.returncode < 0:
print("Task failed with signal", -e.returncode, file=sys.stderr)
print("** Further testing aborted **", file=sys.stderr)