Question Authors' Forum

Rust language

Re: Rust language

by Richard Lobb -
Number of replies: 0
Well, I had hoped a rust programmer would have jumped in here with an answer. But since no one has, I'll attempt an answer. Please realise I'm not a rust programmer and have just hacked something together as a proof of concept.

Firstly, you need to install rust on your jobe server. This was a bit harder than I expected as you have to install it globally for all users (Jobe jobs run as one of jobe00, jobe01, jobe02 etc, and those users have no home directory for security reasons).

The solution I used was one I found here: https://github.com/rust-lang/rustup/issues/1085. The only command I bothered to implement was /usr/local/bin/cargo.

That done, I created a prototype for a rust question using python3 to script a series of calls to cargo. There are probably better ways but like I said, I've never programmed in rust before and that was the way I found in the first tutorial I hit.

I attach the prototype (which is the pseudo-question that defines the new question type) and a couple of test questions. That's the ONLY two tests I've ever used. Caveat emptor. Import the three questions (they're Moodle XML format) and then run the hello world and fizzbuzz examples.

The question type is clumsy. Unless you ask 'write-a-program' questions, each test case has to define a main function to call whatever functions/classes the student answer defines. You could easily built more specific question types in which (say) the test code is plugged into a boiler-plate main function, but I leave that to you.

It's also rather inefficient in that there's a jobe run for each testcase. There are more efficient approaches but this is probably the easiest one to get you going. 

Let me know how you get on.

And if you write more sophisticated rust question types, please post them back here for other users.