Question Authors' Forum

Object-oriented code-runner in Octave?

 
Picture of Angus Wallace
Re: Object-oriented code-runner in Octave?
by Angus Wallace - Thursday, 10 May 2018, 12:43 PM
 

Brilliant -- that's done it. Thanks Richard :-)

Regarding the old version of Octave, I don't think that was the explanation for the strange file paths, but I don't think those paths were the source of the problem. I queried this with IT support (who were extremely helpful and responsive, bless them!) and my understanding is that each student response is run in a chroot, which is why it looks like it's running in / even though it's not.

Versions of Octave <4.0 don't support the classdef method of class definitions. Now that we've upgraded to >4.0, it is working beautifully -- including the strings in classes with your latest suggestion.

Thanks again for all your help,

-Angus

Picture of Angus Wallace
Re: Object-oriented code-runner in Octave?
by Angus Wallace - Friday, 18 May 2018, 5:31 PM
 
Hi Richard,

One other (hopefully) quick question. Is it possible for me to have students submit two classes that have a separator between them, and change the template to something like:

clear all
format free;
student_answer = strsplit(sprintf('{{ STUDENT_ANSWER | e('matlab') }}',**^*--AWKseparator-DONT-TOUCH-AWKseparator--**^*);
fid = fopen("ClockDisplay.m", "w");
fputs(fid, student_answer{1});
fclose(fid);
fid = fopen("NumberDisplay.m", "w");
fputs(fid, student_answer{2});
fclose(fid);
rehash();
{{ TEST.testcode }};
{{ TEST.extra }};

Thanks, Angus
Picture of Richard Lobb
Re: Object-oriented code-runner in Octave?
by Richard Lobb - Friday, 18 May 2018, 9:56 PM
 

Hi Angus

That looks OK to me, apart from the missing quotes around the strsplit separator. Give it a go and let me know if it doesn't work.

BTW: you know you can tick the "Template debugging" checkbox and get to see exactly what program gets run, do you? In tricky situations you can then copy the program out into your IDE and debug it there rather than working within CodeRunner all the time.

Richard

Picture of Angus Wallace
Re: Object-oriented code-runner in Octave?
by Angus Wallace - Thursday, 24 May 2018, 1:17 PM
 

Great, thanks, yes I've got it to work.

A minor gotcha, I needed to start the separator with a comment -- not quite sure why, as I thought it was being interpreted before Octave saw it. Anyway, it seemed to be needed.

It's pretty neat, actually. The students see two classes that they need to complete/modify for a desired task. Octave sees them as though they are two saved classdef files. Seems to work well!

Cheers, Angus