Quantcast
Channel: General developer forum
Viewing all articles
Browse latest Browse all 37669

Filemanager help

$
0
0
by Jon Martin.  

Hello all!

I've been scouring the web and these forums for a little while now, but first time I've posted.

I'm completely new to Moodle, although I have plenty of experience working with PHP.  We're converting a custom blockfor Moodle 1.x (actually, Totara 1.x) to Moodle 2.  I've managed to work everything out and it's working pretty well barring uploading files.

So we have a simple form that uses the new filemanager form element.  The files are being uploaded perfectly fine to the draft area (as far as I can tell) and I can see the record being created in the _files db table.

Question 1: I seem to get two rows created for each upload.  The first contains the file specific info (filename, mimetype, filesize, etc) but the second doesn't.  The component, filearea and itemid always match.  Any ideas why I would get two records?  It *may* be because I also have an editor on my form and that's creating the record.  This isn't really my issue though.

Question 2: I cannot work out how to move the file from the draft area to a permanent area for this particular block.  I find the documentation rather confusing, but regardless I've worked through the glossary module to try and work out how it should be done.  At no point do I get a new record created in the files table.  

From what I can work out, all I actually need to do is run the following line to actually save the attachment, and I can see a change in the $rec variable before and after it's run, but nothing actually happens with the file.

Here's my pseudo code:

// run insert if no $rec->id

// else run update

file_postupdate_standard_filemanager($rec, 'attachment', $attachmentoptions, $context, 'block_external_learning', 'external_learning', $rec->id);

// run update again 

It's a long shot, but does anyone have any suggestion on what the problem could be, or even how to try and debug what's going on?

Thanks in advance!


Viewing all articles
Browse latest Browse all 37669

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>