RFH: tricky problems with portfolio API

RFH: tricky problems with portfolio API

by Penny Leach -
Number of replies: 5
Dear General Developer Forum!

During the development of the new Portfolio API, I have come up across a couple tricky problems I would love some input from the wider community to solve:

1. Resource module: Where to add the 'export to portfolio' entry point for uploadey-type resources? The 'Compose a text page' and 'Compose a HTML page' resource types are both easy and already done, but the uploadey ones are hard - I can't figure out where to add the 'export' button (which can either be a button with a dropmenu or just a single small icon) since the file is just force downloaded.

2. Database module: Where to put the export button for single-entry export? The obvious place is with the edit and delete icons, but they're part of the template.

3. Generating an early-sha1 hash of the content to be exported. This one requires a bit more explanation:

The export goes through a series of stages:
- ask the user questions (defined by both the portfolio plugin in use and the location in moodle exporting the content [referred to from now on as the 'caller']) - at this stage often the user is asked whether they wish to wait for the transfer or send it to the queue for cron processing, depending on the projected length of transfer
- set the result of the config data in both the portfolio plugin and the caller
- ask the caller for a sha1 of the data to be exported
- present the user with a confirmation form, including any details of previous transfers of the exact same data to the exact same portfolio instance. Note that this cannot be generated until after the config form as it is dependent on the users's answers.
- queue (or send immediately) the transfer.

So far so good, but the part I am having problem with is this:

The actual data to be sent (for example, an entire glossary module instance, with all aliases and category data) resides still in the database until the point that the actual transfer happens (which might be at cron), and is later than the point where the caller is asked for the sha1. It's fine to generate a sha1 of say, one forum post, or even an entire typed in text or html resource. But a more complicated data structure, say an entire glossary, or entire database module instance, is more costly to calculate.

This really can just be a lookahead-type sha1 of the content, a best guess (as it is only used to tell the user they've exported the same content before) - but I'm really still stuck as to the best way to generate this. Suggestions I've had so far but have dismissed as not rich enough are: the last record of the content to be exported (doesn't track changes), and something involving timemodified which I'm not sure I can trust.

I can't move the sha1 generation to the transfer point, because that might be away from the user interaction (eg cron).

Suggestions welcome!

P


Edit: I should clarify a few things

1. The sha1 generation is completely up to the caller to generate. The portfolio code itself doesn't presume to make any guesses about what the content is or what its sha1 might be
2. There are simple cases (eg forum post, text/html resource) that I'm having less problem with. It's really only when the export spans multiple rows from multiple tables.
Average of ratings: -
In reply to Penny Leach

Re: RFH: tricky problems with portfolio API

by Penny Leach -
Talking to myself:

More info for 1 & 2 in: http://tracker.moodle.org/browse/MDL-15758

More info for 3 in: http://tracker.moodle.org/browse/MDL-15934
In reply to Penny Leach

Re: RFH: tricky problems with portfolio API

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Update: 3 seems to have been resolved in the bug, and I just commented in the bug on 2.

(This parallel strands of communication thing does not seem to be working very well.)
In reply to Tim Hunt

Re: RFH: tricky problems with portfolio API

by Penny Leach -
I agree sad bugs, developer forum & hq chat... cause problems.

thanks for your comments, TIm.
In reply to Penny Leach

Re: RFH: tricky problems with portfolio API

by Penny Leach -
All solved except for the resource module thing. Any moodlers more familiar with the resource module than me (surely, most of you!) - input appreciated!
In reply to Penny Leach

Re: RFH: tricky problems with portfolio API

by Mark Nielsen -
Hi Penny,

Main problem is that the resource module can just redirect the user directly to the file and out of your control for display.

Besides that, I was just thinking of putting a button up in the header, like where the Update this resource button is located. This would hopefully work for when the file is displayed inline or in a frame.

Cheers,
Mark