Virtual Learning Platforms Thread, Creating moodle blocks in Technical; I'm looking at creating a moodle block to allow users to see there Papercut balance within moodle. I have the ...
-
17th June 2009, 01:51 PM #1 Creating moodle blocks
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 :-)
-
-
IDG Tech News
-
17th June 2009, 02:09 PM #2 
Originally Posted by
clodhopper
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?
-
-
17th June 2009, 03:43 PM #3 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
-
-
17th June 2009, 08:14 PM #4 
Originally Posted by
clodhopper
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.
papercutblock.JPG
i just need to make it more flexible then i will release it.
-
Thanks to penfold_99 from:
papercut (18th June 2009)
-
17th June 2009, 08:23 PM #5 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Web Widget Examples</title>
</head>
<body>
<?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}";
?>
<div id="widgetBalance" style="margin-bottom: 3em;">
<!-- User Balance widget will be rendered here -->
</div>
<?php
echo "
<script type=\"text/javascript\" src=\"$java_src\"></script>
<script type=\"text/javascript\">
var pcUsername = '$papercut_user';
var pcServerURL = '$papercut_server';
pcGetUserDetails();
</script>
<script type=\"text/javascript\">
pcInitUserBalanceWidget('widgetBalance');
</script>
";
?>
</body>
</html>
-
-
17th June 2009, 09:03 PM #6 
Originally Posted by
clodhopper
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Web Widget Examples</title>
</head>
<body>
<?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}";
?>
<div id="widgetBalance" style="margin-bottom: 3em;">
<!-- User Balance widget will be rendered here -->
</div>
<?php
echo "
<script type=\"text/javascript\" src=\"$java_src\"></script>
<script type=\"text/javascript\">
var pcUsername = '$papercut_user';
var pcServerURL = '$papercut_server';
pcGetUserDetails();
</script>
<script type=\"text/javascript\">
pcInitUserBalanceWidget('widgetBalance');
</script>
";
?>
</body>
</html>
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?
-
-
17th June 2009, 09:08 PM #7 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 :-)
-
-
17th June 2009, 09:15 PM #8 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.
-
-
17th June 2009, 09:18 PM #9 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 :-)
-
-
17th June 2009, 09:27 PM #10 
Originally Posted by
clodhopper
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.
-
-
17th June 2009, 09:30 PM #11 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 :-)
-
-
17th June 2009, 09:36 PM #12 
Originally Posted by
clodhopper
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?
-
-
17th June 2009, 09:38 PM #13
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 :-)
-
-
17th June 2009, 09:45 PM #14 
Originally Posted by
clodhopper
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.
-
-
17th June 2009, 09:47 PM #15 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 !!!
-
SHARE:
Similar Threads
-
By HodgeHi in forum EduGeek Moodle
Replies: 2
Last Post: 23rd February 2009, 07:44 PM
-
By FN-GM in forum Virtual Learning Platforms
Replies: 7
Last Post: 15th November 2008, 10:11 PM
-
By Dos_Box in forum Hardware
Replies: 7
Last Post: 29th August 2008, 08:32 AM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules