<br>Hi Martin,<br>I am sold with the blocks concept ;)<br><br>Though:<br><br>I have finally wrapped things with the XML-RPC stuff for assignment-clone (which is print) module<br>My idea was "do anything new only after having a backup". But there's still the authentication stuff<br>
that's at question. How do i tell moodle this is from an user X and how do I tell moodle that this will <br>go into a particular course module ( I see no way to beat this without having a selection UI in the <br>client). <br>
I have attached the module. There's a test.php script you can run to check how the xmlr-rpc code <br>works.<br>And I am very well ready to do a switch to a block, provided I have this<br>all setup, so I don't mess my GSoC schedule.<br>
;)<br>
<br>Thanks,<br>Vamsi<br><div class="gmail_quote">On Fri, Jul 17, 2009 at 1:56 PM, Martin Langhoff <span dir="ltr"><<a href="mailto:martin.langhoff@gmail.com" target="_blank">martin.langhoff@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Vamsi,<br>
<br>
Good hint from Tim -- Using a block is a much better approach :-) --<br>
blocks are also "for something else" but we can make it happen if we<br>
are careful about a couple of things...<br>
<br>
So it's good to make a new block. I assume you can look at the block<br>
guide a bit, and draft a simple initial block -- do ask for help if<br>
you get stuck in that.<br>
<br>
I trust you to design how it works :-)<br>
<br>
There are acouple of "special" things I think you want to be careful<br>
with, because we are not making a conventional block.<br>
<br>
These are tricky points. I read my own email 3 times to make sure it<br>
made sense :-)<br>
<br>
I am also copying Mihai Suncan - he is working on a different project<br>
that (I suspect) has to solve a similar problem (in #2 below).<br>
<br>
1 - Blocks can be displayed in any 'course page'. In our case, it will<br>
usualyl be displayed in the "Homepage" (which is a course page,<br>
actually, the course page of a special course that is called the<br>
'sitecourse', identified by the SITEID constant). If it is displayed<br>
in a conventional course page (non-'sitecourse') it should probably<br>
show the same data.<br>
<br>
So the _context_ (in terms of access control API) in which it is<br>
displayed does not matter much -- it is a matter of convenience to the<br>
user. So you want to mostly _ignore_ the context that the Blocks API<br>
gives you, and make a lookup for the context of the "system context".<br>
You want to ask whether the user has printing / print-queue-management<br>
rights in the system context, instead of in the course context.<br>
<br>
2 - You will need to transfer the data from the Journal to Moodle,<br>
store it somewhere, one of the key things is "in which security<br>
context / in which course". The other one is "how to handle the<br>
transfer".<br>
<br>
2.1 - For the security context / "which course" question, my<br>
recommendation is to use the 'sitecourse' in Moodle 1.9.x -- this is<br>
not entirely correct, but I think we can make it work. We need to look<br>
up exactly how we can store those files in a way that is private for<br>
each user (so they are not browsable by anyone on the 'files' UI).<br>
<br>
For 2.0 (and for 1.9.x if the above doesn't work) we need to catch up<br>
with Petr to see how "user" files are handled in the new Files API.<br>
If/when we go this way, we will want to use the 'CONTEXT_USER'<br>
context. If things are not ready in the API, it will be awkward.<br>
<br>
2.2 - The transfer! Moodle's existing API won't give you much here,<br>
neither in 1.9.x or in 2.0, but there are good tools to do what we<br>
want.<br>
<br>
2.2.1 You _will need to make a specific entry point to transfer the<br>
files to_, a URL inside the block directory. We don't want to hardcode<br>
that in the Journal side, so let's hardcode a canonical URL in the<br>
Journal ( <a href="http://schoolserver/printqueue" target="_blank">http://schoolserver/printqueue</a> ) and we'll use a redirect or<br>
an alias to point it to the right file in your Moodle block.<br>
<br>
2.2.2 The files to print can be large -- very large. HTTP is not very<br>
good transferring very large files, and Apache+PHP on the server side<br>
only make it worse (in memory use in particular). I am being polite<br>
here -- it sucks. It's unworkable.<br>
<br>
One thing we can do is to use WebDAV which is HTTP but it has all the<br>
smarts needed to transfer large files in many little chunks.<br>
<br>
One the Journal side, you need to identify a good python lib that can<br>
talk WebDAV. Does not need to be fancy but you _will_ want something<br>
that has a big "turn on debugging" option so you can see what's<br>
happening :-)<br>
<br>
On the Moodle side, we can use the PHP WebDAV libs to make a "magic"<br>
webdav folder that acts as a "blind dropbox"... a directory that looks<br>
always empty, but that you can transfer files to (and returns an OK<br>
code when the transfer succeeds).<br>
<br>
I wrote a "Moodle WebDAV" patch about 2 years ago that can be a good<br>
source of inspiration. My patch does a ton more, so you only need...<br>
5% of it.<br>
<br>
hth,<br>
<font color="#888888"><br>
<br>
<br>
martin<br>
</font><div><div></div><div><br>
<br>
On Tue, Jul 14, 2009 at 5:18 PM, Vamsi Krishna<br>
Davuluri<<a href="mailto:vdavuluri@acm.org" target="_blank">vdavuluri@acm.org</a>> wrote:<br>
><br>
> I finished writing a course module, but anyway. I<br>
> I talked to Tim Hunt from Moodle.<br>
> And we had a very lengthy discussion to port this into a Block.<br>
> A block would have the advantage of being used anywhere from<br>
> moodle, and also enable us to have global notifications.<br>
> This seems much appropriate.<br>
><br>
> 12:21:45 PM) Vamsi Krishna D: <a href="http://pastebin.be/19720" target="_blank">http://pastebin.be/19720</a><br>
> (12:26:55 PM) Tim Hunt: Great!<br>
> (12:27:48 PM) Tim Hunt: So one question, is how does the teacher get to the<br>
> 'Print submissions page'. Presumably that is a link, but where is the best<br>
> place for it in Moodle.<br>
> (12:27:56 PM) Tim Hunt: ?<br>
> (12:29:04 PM) Vamsi Krishna D: he would have to enter the activity in my<br>
> vision. But I suspect having it in his global notifications would be best<br>
> (12:29:33 PM) Tim Hunt: Yes. I think using a block lets you put the global<br>
> notification on any page.<br>
> (12:30:45 PM) Tim Hunt: My feeling is that this whole system should be<br>
> loosely coupled to Moodle, and an assignment must be strongly coupled to a<br>
> course.<br>
> (12:31:00 PM) Vamsi Krishna D: Okay, can i reuse any of my code :p<br>
> (12:31:34 PM) Tim Hunt: Sure. I think the code that does the actual work is<br>
> the same, it is just a question of where you put it.<br>
> (12:31:46 PM) Tim Hunt: The code for integrating to Moodle would be<br>
> different.<br>
> (12:32:45 PM) Tim Hunt: The good thing about blocks is that there is quite<br>
> good documentation for how to make one:<br>
> <a href="http://dev.moodle.org/course/view.php?id=2" target="_blank">http://dev.moodle.org/course/view.php?id=2</a> and<br>
> <a href="http://docs.moodle.org/en/Development:Blocks" target="_blank">http://docs.moodle.org/en/Development:Blocks</a><br>
> (12:34:12 PM) Tim Hunt: I suggest that the block just gives a summary like<br>
> '3 print jobs awaiting approval' with a link to a separate<br>
> blocks/printingmanager/approve.php script that does most of the work.<br>
> (12:34:49 PM) Vamsi Krishna D: so that would be like my submissions.php?<br>
> (12:34:59 PM) Tim Hunt: And for students the block can have a link,<br>
> something like 'Upload your print jobs here that takes them to a<br>
> blocks/printingmanager/submit.php<br>
> (12:35:22 PM) ***Tim Hunt goes to look at submissions.php<br>
> (12:35:53 PM) Vamsi Krishna D: which calls a function submissions.php in<br>
> lib.php :p<br>
> (12:36:00 PM) Vamsi Krishna D: submissions()<br>
> (12:36:01 PM) Vamsi Krishna D: *<br>
> (12:36:22 PM) Tim Hunt: Well, submissions.php has lots of code specific to<br>
> being an assignment in a course. Most of that could be deleted if this is a<br>
> separate script linked to from a block ;-)<br>
> (12:36:52 PM) Vamsi Krishna D: Ah!<br>
> (12:37:12 PM) Tim Hunt: Yes, it looks like you could move the code from<br>
> submissions() to blocks/printingmanager/approve.php - or whatever you want<br>
> to call it.<br>
> (12:37:56 PM) Vamsi Krishna D: excellent!<br>
> (12:38:33 PM) Vamsi Krishna D: Martin was also suggesting something better<br>
> than Course modules<br>
> (12:38:45 PM) Tim Hunt: What did Martin suggest?<br>
> (12:39:24 PM) Vamsi Krishna D: In my opinion, your code should not be a<br>
> moodle module. We need to<br>
> organize a skype / sip / irc chat to discuss where it would 'fit' in<br>
> Moodle. There are other APIs in Moodle that may be a better place.<br>
><br>
> Or perhaps it doesn't fit any API and we need to craft a patch.<br>
> (12:40:03 PM) Tim Hunt: Ah I think I have not said anything that Martin<br>
> woudl disagree with ;-)<br>
> (12:40:17 PM) Vamsi Krishna D: Great!<br>
> (12:40:32 PM) Tim Hunt: The only other option I can think of is to put your<br>
> code in the /local folder, which is designed for miscellaneous hacks.<br>
> (12:40:40 PM) Tim Hunt: However, I think a block is better.<br>
> (12:41:05 PM) Tim Hunt: But might be worth emailing Martin a summary of what<br>
> we talked about, to make sure he agrees with what I have said.<br>
> (12:41:09 PM) Vamsi Krishna D: let me mail Martin and my mentor about this<br>
> concept<br>
><br>
> On Tue, Jul 14, 2009 at 5:57 AM, Martin Langhoff <<a href="mailto:martin.langhoff@gmail.com" target="_blank">martin.langhoff@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Thu, Jul 9, 2009 at 1:15 PM, Vamsi Krishna<br>
>> Davuluri<<a href="mailto:vamsi.davuluri@gmail.com" target="_blank">vamsi.davuluri@gmail.com</a>> wrote:<br>
>> > Thanks to a kick start from Andres, I'm working royally with<br>
>> > moodle.<br>
>><br>
>> Excellent. Sorry about taking so long.<br>
>><br>
>> > so anyway, despite reading the reference site on the function:<br>
>> > I couldn't figure out how it works.<br>
>> ><br>
>> > has_capability('mod/print:submit', $this->context)<br>
>> > how exactly does this function work?<br>
>><br>
>> Let me see if I can shed some light...<br>
>><br>
>> - A module is _always_ used as part of a course. Modules implement<br>
>> the behaviour of a 'module instance', (think of it in OOP terms). So<br>
>> for example mod/forum code handles "a forum in a course", which is a<br>
>> "modinstance" (module instance) in moodle internals lingo.<br>
>><br>
>> - Each modinstance has a "security context" - sec contexts are<br>
>> nested, like this: Site -> Category -> Course -> Modinstance.<br>
>><br>
>> - The $context object you have there refers to the context of the<br>
>> specific modinstance you are dealing with (again, in OOP-ish terms,<br>
>> though moodle's modules aren't strictly OOP).<br>
>><br>
>> With that background laid out, the code<br>
>><br>
>> has_capability('mod/print:submit', $this->context)<br>
>><br>
>> will return true or false answering the following question:<br>
>><br>
>> does the currently logged in user have the<br>
>> capability/authorization to do "mod/print:submit"<br>
>> in the context of this module instance?<br>
>><br>
>> Now, this won't make much sense in your case because printing is not<br>
>> about stuff "in a course".<br>
>><br>
>> In my opinion, your code should not be a moodle module. We need to<br>
>> organize a skype / sip / irc chat to discuss where it would 'fit' in<br>
>> Moodle. There are other APIs in Moodle that may be a better place.<br>
>><br>
>> Or perhaps it doesn't fit any API and we need to craft a patch.<br>
>><br>
>> cheers,<br>
>><br>
>><br>
>><br>
>> m--<br>
>> <a href="mailto:martin.langhoff@gmail.com" target="_blank">martin.langhoff@gmail.com</a><br>
>> <a href="mailto:martin@laptop.org" target="_blank">martin@laptop.org</a> -- School Server Architect<br>
>> - ask interesting questions<br>
>> - don't get distracted with shiny stuff - working code first<br>
>> - <a href="http://wiki.laptop.org/go/User:Martinlanghoff" target="_blank">http://wiki.laptop.org/go/User:Martinlanghoff</a><br>
><br>
><br>
<br>
<br>
<br>
</div></div>--<br>
<div><div></div><div> <a href="mailto:martin.langhoff@gmail.com" target="_blank">martin.langhoff@gmail.com</a><br>
<a href="mailto:martin@laptop.org" target="_blank">martin@laptop.org</a> -- School Server Architect<br>
- ask interesting questions<br>
- don't get distracted with shiny stuff - working code first<br>
- <a href="http://wiki.laptop.org/go/User:Martinlanghoff" target="_blank">http://wiki.laptop.org/go/User:Martinlanghoff</a><br>
</div></div></blockquote></div><br><input type="hidden"><input type="hidden"><div></div>