Developers' Forum

Octave Statistics not loading

Octave Statistics not loading

by Christoph Roehrs -
Number of replies: 2

Hi,

I have a problem with Octave Statistics on my Jobe Coderunner Server. Moodle receives always an error because octave statistics is not loading correctly. 

***Error***
warning: the 'anova' function belongs to the statistics package from Octave Forge
which you have installed but not loaded.  To load the package, run 'pkg
load statistics' from the Octave prompt.

Please read <https://www.octave.org/missing.html>; to learn how you can
contribute missing functionality.
error: 'anova' undefined near line 4 column 32
error: called from
    __tester__.octave at line 4 column 2

Octave is installed and configured correctly and I also talked with them about this problem. They told me, they think that the problem is how moodle/coderunner is calling octave. 

see .. https://savannah.gnu.org/bugs/?56986 

Thanks for your help!

Best regards,

Christoph 


In reply to Christoph Roehrs

Re: Octave Statistics not loading

by Richard Lobb -

Jobe starts Octave with a command of the form

octave --version --norc --no-window-system --silent -H prog.m

The --norc will prevent autoloading of packages. I don't remember all the details, but I don't think you can remove that option as the task is running as user Jobe, who for security reasons has no home directory.

I installed the statistics package on my development server and was able to submit an Octave answer that began

pkg load statistics

So can you not just clone the octave_function question prototype (or whatever prototype you're using) and edit it so it begins

pkg load statistics
{{ STUDENT_ANSWER }}

?

You could call your new question type octave_stats or some such. 

That has the slight disadvantage that error line numbers seen by the students will be out by one but students soon learn not to trust error line numbers anyway.


In reply to Richard Lobb

Re: Octave Statistics not loading

by Rea Sutter -

Hi Richard,

I'm working with Christoph to solve that statistics problem.

Your hint about removing --norc was one part of the solution, and an important one. Let me detail here how I got statistics to load automatically in CodeRunner, just in case someone else is looking for this:

  • in the file octave_task.php (in /var/www/html/jobe/applications/libraries/), remove both instances of --norc. It is used in lines 19 and 27.
  • in /etc/octave.conf add the line
    pkg ("load", "statistics"); just before atexit ("__finish__"); (this is the file that is linked from .octaverc)
  • Now statistics loads, but the following warning is shown (which is why answers evaluate as wrong): function /usr/share/octave/packages/statistics-1.4.0/distributions/binopdf.m shadows a core library function
    to get rid of this warning, I renamed the file binopdf.m at the given path to binopdf1.m
I will do some more research to find out whether it makes any difference which of the functions is disabled - the one in core or the one in the statistics package. But it's finally working now! :-)

Are you sure, Richard, that removing the --norc is safe?

Anyway, thank you for your help!