clodhopper Posted June 17, 2009 Posted June 17, 2009 I'm looking at creating a moodle block to allow users to see there Papercut balance within moodle. I have the html code to do this with help from the Papercut guys but I'd like to be able to create a new block so that things like server setting's aren't hard coded into the php/html rather then just to use the html block built into moodle. Once I've got it working I'll be happy to share it as I know a few other people on here are Papercut users. Any pointers are gratefully received as the moodle doc's are a little daunting for a first time creator like me :-) 1
penfold_99 Posted June 17, 2009 Posted June 17, 2009 I'm looking at creating a moodle block to allow users to see there Papercut balance within moodle. I have the html code to do this with help from the Papercut guys but I'd like to be able to create a new block so that things like server setting's aren't hard coded into the php/html rather then just to use the html block built into moodle. Once I've got it working I'll be happy to share it as I know a few other people on here are Papercut users. Any pointers are gratefully received as the moodle doc's are a little daunting for a first time creator like me :-) This is something that i can knock together for you if your happy for me to have the copyright but release it under gpl?
clodhopper Posted June 17, 2009 Author Posted June 17, 2009 I'll happily give you the code as it's nothing special just something I pulled from the moodle forum's & a help from Chris @ Papercut. I'll drop him an email and ask if it's OK for me to let you have the code
penfold_99 Posted June 17, 2009 Posted June 17, 2009 I'll happily give you the code as it's nothing special just something I pulled from the moodle forum's & a help from Chris @ Papercut. I'll drop him an email and ask if it's OK for me to let you have the code Hi Just to let you know i have created a block that uses papercut's web widgets. i just need to make it more flexible then i will release it. 1
clodhopper Posted June 17, 2009 Author Posted June 17, 2009 And there was me working on it now :-( I've got it so that all the variables are defined at the top but my page only works in IE not firefox. The error in firefox is in this line $papercut_user = "{$USER->username}"; Here's my code, it's a bit of a hack together to create the javascript using php echo's but please be kind it's my first try at this sort of thing :-) Brian Web Widget Examples <?php require_once("config.php"); $papercut_server = "http://papercut.portsmouth-college.ac.uk:9191"; $java_src= "$papercut_server/content/widgets/widgets.js"; $papercut_user = "{$USER->username}"; ?> <?php echo " var pcUsername = '$papercut_user'; var pcServerURL = '$papercut_server'; pcGetUserDetails(); pcInitUserBalanceWidget('widgetBalance'); "; ?>
penfold_99 Posted June 17, 2009 Posted June 17, 2009 And there was me working on it now :-( I've got it so that all the variables are defined at the top but my page only works in IE not firefox. The error in firefox is in this line $papercut_user = "{$USER->username}"; Here's my code, it's a bit of a hack together to create the javascript using php echo's but please be kind it's my first try at this sort of thing :-) Brian Web Widget Examples <?php require_once("config.php"); $papercut_server = "http://papercut.portsmouth-college.ac.uk:9191"; $java_src= "$papercut_server/content/widgets/widgets.js"; $papercut_user = "{$USER->username}"; ?> <?php echo " var pcUsername = '$papercut_user'; var pcServerURL = '$papercut_server'; pcGetUserDetails(); pcInitUserBalanceWidget('widgetBalance'); "; ?> I'm a pragmatist, if it work then its good. Your script is nearly like for like with mine but mine is in a block. the only modification i need to do is allow the paper cut server url to be configured for the block management in moodle. is there any other blocks you might need?
clodhopper Posted June 17, 2009 Author Posted June 17, 2009 Oh that's good to know that I've not made a complete mess of it then :-) I think with what you've got then that's a really good workable solution. Have you tested it in both IE & Firefox ?? The other interesting thing I'll have to play with is that our Moodle server lives in the DMZ and papercut is internal so I'm going to have to have a play with the firewall to allow moodle through if the users are accessing from outside, or I just say "Tuff" only internally can you see you credits :-)
reggiep Posted June 17, 2009 Posted June 17, 2009 Just a round of applause for you two guys It's great to see what people out there are doing with moodle, and I'm so glas my school has decided to go with it. 1
clodhopper Posted June 17, 2009 Author Posted June 17, 2009 Thanks, I only thought about it this morning & in under 12 hours there's a working prototype, now that's the power of Open Source & collaboration :-) Hopefully once it's tested we'll be releasing it for other people to use, watch this space :-)
penfold_99 Posted June 17, 2009 Posted June 17, 2009 Oh that's good to know that I've not made a complete mess of it then :-) I think with what you've got then that's a really good workable solution. Have you tested it in both IE & Firefox ?? The other interesting thing I'll have to play with is that our Moodle server lives in the DMZ and papercut is internal so I'm going to have to have a play with the firewall to allow moodle through if the users are accessing from outside, or I just say "Tuff" only internally can you see you credits :-) i have tested with both IE and firefox, ie has issues with png files so there is a small border around the image that isn't there in firefox. Do people need to be able to see there print credits out side the school? it wont be hard to add in a if statement to check the clients ip to see it is in the same subnet as the server.
clodhopper Posted June 17, 2009 Author Posted June 17, 2009 Good that it works in both IE & Firefox as I'm trying to move everyone to Firefox :-) Thinking about it they don't need to see info from outside of College, they can only print in College so really only need it there so if it can check that they are inside on the a subnet like 192.168.x.x that would be good, or even a configurable variable :-)
penfold_99 Posted June 17, 2009 Posted June 17, 2009 Good that it works in both IE & Firefox as I'm trying to move everyone to Firefox :-) Thinking about it they don't need to see info from outside of College, they can only print in College so really only need it there so if it can check that they are inside on the a subnet like 192.168.x.x that would be good, or even a configurable variable :-) I will add in tomorrow and test it, if i dont get a chance is monday ok?
clodhopper Posted June 17, 2009 Author Posted June 17, 2009 No problem, I'm amazed how fast this has all come together I only started the thread at 13:50 & in under 8 hours there's a working solution, oh the power of open source & forums :-)
penfold_99 Posted June 17, 2009 Posted June 17, 2009 No problem, I'm amazed how fast this has all come together I only started the thread at 13:50 & in under 8 hours there's a working solution, oh the power of open source & forums :-) thats slow compared to some of the blocks i have written. from concept to working live it was less than 30 minutes. I created a zimbra single sign on block while doing a sims.net upgrade.
clodhopper Posted June 17, 2009 Author Posted June 17, 2009 OK that's just showing off & you didn't have a newbie like me slowing you down :-) Oh the good old days of SIMs I remember that when I started here, it's all UnitE now , same rubbish different name and all by the beloved Capita !!!
PaperCut Posted June 18, 2009 Posted June 18, 2009 Hi Guys, Great work! I notice there is the dreaded IE 6 PNG alpha channel problem - aka "the gray border". Time for IE8 or even better upgrade to Firefox :-) I'll post a bug on this and see if we can fix it in the default PaperCut AJAX widgets. In the meantime you can use a CCS behavior trick to fix. Add the following to your CCS: img { /* IE PNG transparency hack */ behavior: url(http://papercut-server.myorg.org/css/pngHack/pngHack.htc); } Update papercut-server.myorg.org to point to the real server. Regarding access from outside the Intranet - the print quota/balance and environmental impact AJAX widgets should be resilient to this. They work by "replacing" the contents of a DIV element with data loaded off the server. If the JavaScript is unable to contact the server, the element will not be replaced. If not rendering the widget causes page layout issues, you could add a placeholder image inside the DIV block as follows: images/balance_not_avaliable.png Another technique I've seen used on some sites is to use ProxyPass/ModProxy in Apache to proxy requests through to the internal server on a given URL path - specifically only the URLs used by the widgets. I am however reluctant to recommend this method. mod_proxy is very powerful but also very easy to stuff up. If miss configured you may end up exposing more than you planed, or even worse, I've seen one site accidentally turn their Apache server into a open proxy by accident! Good for Twitter uses in Iran but not good for the bandwidth bill :-) Once you have the Moddle block fully working, let me know as I'd love to post it on the PaperCut Knowledge Base. Moddle is becoming more and more popular in education and I'd love to spread the word. Cheers, Chris Developer at PaperCut
penfold_99 Posted June 18, 2009 Posted June 18, 2009 Hi Guys, Great work! I notice there is the dreaded IE 6 PNG alpha channel problem - aka "the gray border". Time for IE8 or even better upgrade to Firefox :-) I'll post a bug on this and see if we can fix it in the default PaperCut AJAX widgets. In the meantime you can use a CCS behavior trick to fix. Add the following to your CCS: img { /* IE PNG transparency hack */ behavior: url(http://papercut-server.myorg.org/css/pngHack/pngHack.htc); } Update papercut-server.myorg.org to point to the real server. Regarding access from outside the Intranet - the print quota/balance and environmental impact AJAX widgets should be resilient to this. They work by "replacing" the contents of a DIV element with data loaded off the server. If the JavaScript is unable to contact the server, the element will not be replaced. If not rendering the widget causes page layout issues, you could add a placeholder image inside the DIV block as follows: images/balance_not_avaliable.png Another technique I've seen used on some sites is to use ProxyPass/ModProxy in Apache to proxy requests through to the internal server on a given URL path - specifically only the URLs used by the widgets. I am however reluctant to recommend this method. mod_proxy is very powerful but also very easy to stuff up. If miss configured you may end up exposing more than you planed, or even worse, I've seen one site accidentally turn their Apache server into a open proxy by accident! Good for Twitter uses in Iran but not good for the bandwidth bill :-) Once you have the Moddle block fully working, let me know as I'd love to post it on the PaperCut Knowledge Base. Moddle is becoming more and more popular in education and I'd love to spread the word. Cheers, Chris Developer at PaperCut Hi Chris, Thanks for the additional fixes. Were just about to purchase papercut any chance of a discount in return for releasing this module?
PaperCut Posted June 18, 2009 Posted June 18, 2009 Hi Chris, Were just about to purchase papercut any chance of a discount in return for releasing this module? I'll have a chat to sales. I'm sure I can arrange something. Email me at chris a> papercut dot. com and I'll email through a discount code. Actually I probably could arrange a discount code for any EduGeek with a good thanked-to-post ratio Cheers, Chris Developer @ PaperCut
penfold_99 Posted June 18, 2009 Posted June 18, 2009 img { /* IE PNG transparency hack */ behavior: url(http://papercut-server.myorg.org/css/pngHack/pngHack.htc); } Hi Chris, Im currently unable to get the above code to work, if i include it it stops the widgets from being displayed.
PaperCut Posted June 19, 2009 Posted June 19, 2009 Hi Chris, Im currently unable to get the above code to work, if i include it it stops the widgets from being displayed. I raised this problem with Tom, our HTML guru. His first response was to suggest to upgrade away from IE6 as quick as possible He said another method is to use a JQuery plugin and try the following code: <br /> $(function() {<br /> $('body').supersleight();<br /> });<br /> You might want to download those scripts rather than hotlinking. Website describing plugin: http://allinthehead.com/retro/338/supersleight-jquery-plugin . The other option is to not use the stylec widgets but instead build your own layout using the AJAX data directly. There is an example of this in "Option B" in: ~papercut/server/examples/webwidgets/examples.html I've listed the layout issue in our bug database and it will get some attention fixed in a future release. Cheers, Chris Developer @ PaperCut
penfold_99 Posted June 19, 2009 Posted June 19, 2009 I raised this problem with Tom, our HTML guru. His first response was to suggest to upgrade away from IE6 as quick as possible We're trying to migrate all users over to firefox but some exam boards require the use of IE6. He said another method is to use a JQuery plugin and try the following code: <br /> $(function() {<br /> $('body').supersleight();<br /> });<br /> I have tried this but it require a transparent file called x.gif, i don't know what in needs to be. Could you ask you HTML guru? The other option is to not use the stylec widgets but instead build your own layout using the AJAX data directly. There is an example of this in "Option B" in: ~papercut/server/examples/webwidgets/examples.html I've listed the layout issue in our bug database and it will get some attention fixed in a future release. I tried example b first but could get it to update the fields properly so when for the widgets.
penfold_99 Posted June 19, 2009 Posted June 19, 2009 Hi Chris, Please ignore my previous message i have traced down the x.gif file. The problem i have now it i get a picture place holder over the pictures in the widget.
PaperCut Posted June 22, 2009 Posted June 22, 2009 Hi Chris, Please ignore my previous message i have traced down the x.gif file. The problem i have now it i get a picture place holder over the pictures in the widget. The "X" is caused by the jquery supersleight plugin not being able to load the 'x.gif' transparent shim. 1. Get a 1x1 px transparent gif shim, or download one from http://www.papercut.com/images/blank.gif 2a. Copy it to your web server root as 'x.gif' and put the following code in head of page displaying the widgets: src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"> src="http://allinthehead.com/code/sleight/supersleight.plugin.js"> <br /> $(function() {<br /> $('body').supersleight();<br /> });<br /> 2b. If you can't put the shim in your web server root as 'x.gif' you can reference one on the PaperCut server with the following code (modify your server name as appropriate): src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"> src="http://allinthehead.com/code/sleight/supersleight.plugin.js"> <br /> $(function() {<br /> $('body').supersleight( { shim:<br /> 'http://papercut-server:9191/css/pngHack/transparent.gif' } );<br /> });<br /> Cheers, Chris Developer @ PaperCut
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now