numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
200 stars 117 forks source link

Resource paths failure #3

Closed graemechester closed 13 years ago

graemechester commented 13 years ago

I had problems compiling the example.exam file, it didn't flag any errors but it didn't display the image in my browser. On investigating, I found it hadn't copied the image to the output/resources directory. I can make it work by changing the resource declaration path to:-

    resources: [exams/example_files/Love_math_1.jpg]

and calling it by .

A couple of things here; the resource directory appears to be relative to the path specified in the -p option on the command line, rather than the current directory of example.exam as specified in the manual. Also, when I try to specify the directory rather than the file as:-

    resources: [exams/example_files]

then the compiler crashes:-

F:\numbas\exams>f:\numbas\bin\numbas.py -p f:\numbas -o f:\numbas\output example.exam Traceback (most recent call last): File "F:\numbas\bin\numbas.py", line 207, in makeExam(options) File "F:\numbas\bin\numbas.py", line 123, in makeExam compileToDir(options) File "F:\numbas\bin\numbas.py", line 73, in compileToDir shutil.copyfile(src,dst) File "F:\Python32\lib\shutil.py", line 98, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 13] Permission denied: 'f:\numbas\exams/example_files'

I stepped through with pdb, and this seems to be caused by trying to copy the directory as if it were a file. I think that os.path.isdir() is failing to identify the type because of an inconsistency in the path names when building the directory list. I also had some problems with the graph example which wouldn't work until I manually copied the scripts to the extensions folder, but I haven't looked into that in detail. I've tried it on two machines, Win2k and Vista with the same result - I haven't tried Linux.

anthonyyoud commented 13 years ago

Compiling the default example.exam works correctly if you do so from the numbas directory, i.e.

H:\numbas>bin\numbas.py exams\example.exam

and make sure the resources exam property is the name of a directory, not a file.

I can reproduce the behaviour you see though, and it needs fixing. We'll get back to you, but hopefully the above will be enough to keep you going for the time being.

graemechester commented 13 years ago

Yes, that sounds like a good workaround. I have been enumerating resource files individually, which is OK since I am working on small trials so far.

christianp commented 13 years ago

I've just pushed a new version which should fix this issue. Please tell me if it works for you.

graemechester commented 13 years ago

Yes, directories for resources and extensions are now copied OK. Thanks!