Question Authors' Forum

Running C# in CodeRunner

 
Picture of Richard Lobb
Re: Running C# in CodeRunner
by Richard Lobb - Thursday, 7 December 2017, 11:27 PM
 

Hi Martin

OK, fair enough. I can appreciate that while getting a Jobe server up and running is straightforward enough, it is one more thing to maintain. And the fact that your Moodle server is on an outside rented server does mean that Jobe has to accessible from that server. That's the only machine it has to be accessible from, though. You should normally set the Linux firewall on the Jobe machine to prevent any other access, so it's really not vulnerable to attack in the way that the Moodle server or other web servers are.

I spent some more time testing the Ideone sandbox today, until I received this email:

Hi coderunner,

you have reached a limit of free submissions this month.

If you wish to submit new codes now,you can purchase a pool of submissions by visiting https://ideone.com/offer/users/.
Regards,
Ideone Team 

So as I rather suspected, Ideone is no longer a free service and I'm not prepared to buy a package of further submissions in order to do further testing.

You're welcome to the updated version of the PHP Ideone Sandbox code if you want it, but you'll have to fix any further bugs with it yourself. Do you have shell access to the Moodle server to edit the code?

Also, aside from the fact it's not a free service, you should be warned that Ideone is nowhere near as responsive as Jobe. Each run takes at least several seconds and so questions with non-combinator templates (e.g. programs that are run multiple times with different standard input) will take a rather unacceptably long time to grade. Lastly, you need to be aware that the Ideone sandbox has never, to my knowledge, been used in a production environment so there are bound to be "interesting" things happen in some situations. With all those caveats, are you still interested? :)

Richard



Picture of Martin Zwerschke
Re: Running C# in CodeRunner
by Martin Zwerschke - Friday, 8 December 2017, 10:29 PM
 

Hi Richard,

that's quite interesting but also disappointing news. I had not expected ideone to be limited that much.
Considering the mail you got from ideone, it really is no free service any more. And of course no one would
expect you to buy submission packets for that and I won't do either if -as I do expect- ideone is too expensive for our needs.

Perhaps our occasional use of CodeRunner would be below the unknown free limit. But who would rely on that
for doing a graded test with his students?

>You're welcome to the updated version of the PHP Ideone Sandbox code if you want it.

Of course I would like that nevertheless. Thanks in advance.

Yesterday I managed to pass a rextester-generated output to the (made readonly) student's answer box by ajax/jquery scripting inside a simple moodle shortanswer-quiz. That is quite near to my demands, though there is no syntax highlighting and no multiple test cases and so on.

But at least there is a chance for a fallback option, if I neither get our own jobe online nor ideone's limits get it sidelined.

I have not detected limits in rextester by the way so perhaps i could consider to replace ideone with rextester in your refreshed ideonesandbox phps.

I do not have shell access to moodle server yet and I do not know if my collegue, who manages moodle on the rented server has got something like this himself. I have got admin rights in moodle, but I am not  "root".

Is it possible to edit php-scripts of the plugin any other way? If not I would have to ask him.

I never maintained moodle before, so I do not really know what's going on under the surface, though generally I know php well enough to do modifications if I have got some access to the files. 

Martin

 





Picture of Richard Lobb
Re: Running C# in CodeRunner
by Richard Lobb - Friday, 15 December 2017, 9:52 PM
 

Hi Martin

The latest push to the Development branch of CodeRunner on github (https://github.com/trampgeek/moodle-qtype_coderunner) includes an updated ideonesandbox.php which I think should work with the language C# though I can't check because I've used up my free run ration. You can either copy that one file, to replace the existing one (which is in the classes folder) or, if you're feeling brave, pull the entire development branch. The latter option isn't recommended on a production server, though we're already running it on ours. If you use just the updated ideonsandbox.php with the question's language set to C# it won't be correctly syntax-coloured by the Ace editor, which instead uses the name 'cs' for C# (not recognised by Ideone). If you use the complete development branch, with a totally rewritten Ace interface, the syntax colouring should work with C#.

If you don't have sufficient access to your Moodle server to pull code in with git, then I'm afraid you'll have to wait for the changes to be merged back into Master and a new Moodle package released. That will probably happen around February next year.

Please be warned, though, that I've tagged use of the Ideone sandbox as "Deprecated". If there are any other users wanting the Ideone sandbox to stick around, now is the time for them to put up their hands!

Richard

Picture of Martin Zwerschke
Re: Running C# in CodeRunner
by Martin Zwerschke - Monday, 18 December 2017, 1:48 AM
 

Hi Richard,

although I am still interested in keeping the ideone-sandbox support alive or even adding a rextester-support, I started to
experiment with  jobe server as well.

As I noticed, the canterbury ouside jobe-server does not have Mono installed, so I could not test the C#-template instantly.

For getting into things, I installed my own jobe-server on an outdate private PC.

I finally got everything to run, and your C# template works.

But I noticed some problems and questions on my way :

  • Why exactly do you suggest to implement C# by a python3 script instead of adding it as an additional language to the jobe server?
    Wouldn't that make things easier?
  • Concerning the documentation of jobe, securing the jobe server as suggested is not possible using the given ufw-commands in my scenario:
    ufw default reject outgoing
    ufw allow out proto tcp to <some_useful_ip> port 80,443
    ufw allow in 22/tcp
    ufw allow in proto tcp to any port 80 from <your_client_ip>
    ufw enable
    Have I understood  correctly, that the ufw firewall to configure is the ufw on the jobe server? Or do you mean ufw on a separate firewall PC or a PC that is run as an internet router? Perhaps documentation could be clearer on this. I suggest a draft of the scenario for that the securing commands are valid.
    I guess <some_useful_ip> means the IP of our single (rented) moodle-server  and <your_client_ip> stands for the IP of my private jobe-server in my scenario. Perhaps that could be made clearer as well.

    My jobe server has got a private IP type 192.168.x.x as a reserved DHCP-lease given by the DSL-Router (a AVM-Fritz-Box in my case), which also serves as a NAT for the clients inside my LAN.
    The DSL-Router gets a dynamic IP from my DSL-provider. To be reachable from the Moodle-server I had to use a (free) DDNS-Service, that is updated regularly by the router and the DDNS service refreshs the DNS-subdomain for that.
    Inside the router's configuration I had to open an incoming port 80 to my jobe's 192.168.x.x-IP
    Yet the ufw commands do not support DNS names, but only fixed IPs.
    The Moodle server is a rented server and seems not to have a fixed IP as well, as I noticed this morning.
    The Server-IP shown inside the Moodle's Server-administration "php-info" has changed since yesterday.
    The moodle is reachable by it's DNS-name, not by a fixed IP-address.
    Thus I can not fill in the <some_useful_ip> field as well, nor in the ufw of my jobe server nor in the DSL-Router,
    that can not open a port for a special IP anyway, just open it for ouside access in general.

    Is it right, that opening in 22 tcp is only necessary, if the jobe server is not accessible physically with a mouse/keyboard and screen?


  • The C#-template seems not to include arguments for the mcs-compiler like the c-via-python-template does.
  • Special chars like 'ä' are not possible inside a C#-program - but that's a known bug already
  • Is there a way to inject keypresses as parts of the test cases? I tried to create a question using the C#'s Console.ReadKey()-command,
    but that could not work out, because the "stdin" only contains a string of chars, no key events.
  • You wrote:

      >For other question types, such as "write-a-C#-method", you will have to wrap the student submission in some extra code,

      > including that supplied in the >>{{TEST}} variable. If you need help with that, post back here.
      Could you please add a template for that? 
      How would a combinatator-question-template be done by the way?
      (I am not so sure to have understood the concept of that mechanism any way...
      Perhaps  a screenshot of a combinator-question in question author's and student's view would help.
      What exactly is the purpose of the cryptic SEPARATOR-string and why does it have to by customizeable?)