I just tried my template and hit a problem, too. It seems that Octave caches classdefs, so that once you've loaded a classdef it stays loaded, even across multiple launches of Octave. [Yuck!]
The solution is to do a clear all at the start of the script. The following template is now working for me:
clear all;
student_answer = sprintf("{{ STUDENT_ANSWER | e('matlab') }}");
fid = fopen("Car.m", "w");
fputs(fid, student_answer);
fclose(fid);
rehash();
{{ TEST.testcode }}
The test code is
mycar = Car('Ford', 23000);
fprintf('A %s with %d km on the clock\n', mycar.brand, mycar.mileage);
and the expected answer is
classdef Car
properties
brand, mileage
end
methods
function self = Car(brand, mileage)
self.brand = brand;
self.mileage = mileage;
end
end
end
Here's a screenshot
However, one thing about your output that worries me is the pathnames like /optcar.m and /optprog.octave. These imply that you're writing files to the root of the file system. If so, this is seriously wrong. It shouldn't even be possible for the web server to write to the root directory - jobe would need to be seriously misconfigured to allow that. The only directory that a jobe task should be writing to is the current working directory, which is a temporary directory set up just for one run and which can't be seen by any other jobs running at the same time. [The task can write to /tmp also, but I don't recommend that.]
Can you clarify what is going on here, please?
Richard