+ Post New Thread
Page 1 of 3 123 LastLast
Results 1 to 15 of 32
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 ...
  1. #1
    clodhopper's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    93
    Thank Post
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    18

    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 :-)

  2. #2
    penfold_99's Avatar
    Join Date
    Feb 2008
    Location
    East Sussex
    Posts
    965
    Thank Post
    58
    Thanked 163 Times in 115 Posts
    Rep Power
    67
    Quote Originally Posted by clodhopper View Post
    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?

  3. #3
    clodhopper's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    93
    Thank Post
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    18
    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

  4. #4
    penfold_99's Avatar
    Join Date
    Feb 2008
    Location
    East Sussex
    Posts
    965
    Thank Post
    58
    Thanked 163 Times in 115 Posts
    Rep Power
    67
    Quote Originally Posted by clodhopper View Post
    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.

  5. Thanks to penfold_99 from:

    papercut (18th June 2009)

  6. #5
    clodhopper's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    93
    Thank Post
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    18
    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>

  7. #6
    penfold_99's Avatar
    Join Date
    Feb 2008
    Location
    East Sussex
    Posts
    965
    Thank Post
    58
    Thanked 163 Times in 115 Posts
    Rep Power
    67
    Quote Originally Posted by clodhopper View Post
    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?

  8. #7
    clodhopper's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    93
    Thank Post
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    18
    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 :-)

  9. #8
    reggiep's Avatar
    Join Date
    Apr 2008
    Location
    In the vast area of space and time
    Posts
    1,550
    Thank Post
    518
    Thanked 56 Times in 50 Posts
    Rep Power
    30
    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.

  10. #9
    clodhopper's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    93
    Thank Post
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    18
    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 :-)

  11. #10
    penfold_99's Avatar
    Join Date
    Feb 2008
    Location
    East Sussex
    Posts
    965
    Thank Post
    58
    Thanked 163 Times in 115 Posts
    Rep Power
    67
    Quote Originally Posted by clodhopper View Post
    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.

  12. #11
    clodhopper's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    93
    Thank Post
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    18
    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 :-)

  13. #12
    penfold_99's Avatar
    Join Date
    Feb 2008
    Location
    East Sussex
    Posts
    965
    Thank Post
    58
    Thanked 163 Times in 115 Posts
    Rep Power
    67
    Quote Originally Posted by clodhopper View Post
    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?

  14. #13
    clodhopper's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    93
    Thank Post
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    18

    Smile

    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 :-)

  15. #14
    penfold_99's Avatar
    Join Date
    Feb 2008
    Location
    East Sussex
    Posts
    965
    Thank Post
    58
    Thanked 163 Times in 115 Posts
    Rep Power
    67
    Quote Originally Posted by clodhopper View Post
    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.

  16. #15
    clodhopper's Avatar
    Join Date
    May 2007
    Location
    Portsmouth
    Posts
    93
    Thank Post
    0
    Thanked 11 Times in 11 Posts
    Rep Power
    18
    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:
+ Post New Thread
Page 1 of 3 123 LastLast

Similar Threads

  1. Moodle - Stop Editing Teachers Changing Blocks On Front Page
    By FN-GM in forum Virtual Learning Platforms
    Replies: 11
    Last Post: 6th November 2013, 07:20 AM
  2. How flexible is moodle for creating themes?
    By HodgeHi in forum EduGeek Moodle
    Replies: 2
    Last Post: 23rd February 2009, 06:44 PM
  3. Bad Blocks + Locating
    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
  •