CodeRunner for Haskell

CodeRunner for Haskell

von Leila Shafti -
Anzahl Antworten: 4

Hi,

I wonder if it is possible to use CodeRunner for marking Haskell excersises? Currenly we have CodeRunner Plugin for our Moodle, but there is no option to choose Haskell for the language.

I wonder if it would be possible to have any kind of support for Haskell as well.

Thanks

Leila

Als Antwort auf Leila Shafti

Re: CodeRunner for Haskell

von Richard Lobb -
Hi Leila

You can use pretty much any language you like once it's installed on the Jobe server. See the documentation on Supporting or implementing new languages

So in your case you'd need to get your sysadmin to install ghc on the Jobe server (command: sudo apt install ghc).

You should then be able to follow through the step-by-step guide in the above-linked documentation section, replacing 'C' with 'Haskell' throughout and using the following template code in lieu of that given for C.

""" The template for a simple write-a-program Haskell question type."""
import subprocess

# Write the student code to a file
student_answer = """{{ STUDENT_ANSWER | e('py') }}"""
with open("Main.hs", "w") as src:
    print(student_answer, file=src)

# Run it.
subprocess.run(["runhaskell", "Main.hs"], text=True)
 When that's done, you should find you have a new question type haskell_via_python (or whatever else you chose to call it). I attach an export of the prototype, though I recommend you work through the construction of it yourself if you can. I also attach a trivial demo which behaves as follows:

Screenshot of Haskell program example.

Import caveats:
  1. I'm not a Haskell programmer so there may be all sorts of restrictions/limitations/error situations that I'm unaware of.
  2. This is just a write-a-program question type. More complex question types, such as write-a-function, are of course possible but require a bit more understanding of CodeRunner and prototypes.
  3. Since both Python and Haskell run within the same allocated virtual memory, you will likely run out of memory with larger programs. It depends on what sort of questions you're setting. You may wish to  set a high MemLimit value within the prototype (hidden under Advanced Customisation).
  4. You do need to be understand question prototypes and manage them carefully. There are quite a few gotchas. See the documentation.

If this prototype proves useful, please post back and I'll include it in the unsupported question types folder in the repo. If it doesn't prove useful, or your have issues with it, please let us know, too.


Als Antwort auf Richard Lobb

Re: CodeRunner for Haskell

von Leila Shafti -
Thanks Richard. I have asked our admin to install the ghc. Once it is done, I will try your solution and will let you know.
Als Antwort auf Richard Lobb

Re: CodeRunner for Haskell

von Leila Shafti -
I’ve been told that by our admins that due to the current CodeRunner backend setup, the Jobeserver isn’t easily configurable. Installing ghc appears to be more complex than simply running the suggested installation command. They are currently investigating how to resolve this issue.
Als Antwort auf Leila Shafti

Re: CodeRunner for Haskell

von Richard Lobb -
I'm not sure why it would be difficult. Perhaps your institution contracts Moodle server configuration and maintenance to a third-party supplier? You could tell your admins they're welcome to post to this forum if it's a technical issue we might be able to help with.

Questions or prototypes can be individually configured to use a different Jobe server from the default by passing its URI/IP to the Sandbox Parameters field under Advanced Customisation. For example: {"jobeserver": "mycustomjobe.xyz"}. This might give you a temporary workaround - just set up Jobe on a handy server somewhere and install ghc using the command I gave you.

Setting up a Jobe server isn't as hard as it sounds; there's a Docker image for it (https://github.com/trampgeek/jobeinabox). However, there could be networking or firewall issues preventing your Moodle server from accessing external servers, so this isn't guaranteed to work.