upload_test

700 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
700
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

upload_test

  1. 1. Creating Moodle modules sam marshall
  2. 2. Contents <ul><li>Introduction to Moodle system </li></ul><ul><li>Introduction to modules </li></ul><ul><li>Versions and database tables </li></ul><ul><li>Capabilities </li></ul><ul><li>Language files and help files </li></ul><ul><li>Forms </li></ul><ul><li>view.php </li></ul>
  3. 3. Introduction to Moodle system <ul><li>PHP  </li></ul><ul><li>Database-driven </li></ul><ul><ul><li>Library of ‘simplifying’ database access functions </li></ul></ul><ul><ul><li>Every table has auto-increment id field </li></ul></ul><ul><li>Little persistent state </li></ul><ul><ul><li>Session data exists, not heavily used </li></ul></ul><ul><li>Mainly functions, not object-oriented </li></ul><ul><li>Independent PHP scripts </li></ul>
  4. 4. Introduction to modules <ul><li>‘ Activities’ </li></ul><ul><li>Appear on front page of course </li></ul><ul><li>Add using dropdown </li></ul><ul><li>Update settings </li></ul><ul><li>Link goes to module’s own PHP files </li></ul><ul><li>What’s in a module? </li></ul>
  5. 8. mod/ name <ul><li>db </li></ul><ul><ul><li>install.xml </li></ul></ul><ul><ul><li>access.php </li></ul></ul><ul><ul><li>update.php </li></ul></ul><ul><li>version.php </li></ul><ul><li>lang </li></ul><ul><ul><li>en_utf8 </li></ul></ul><ul><ul><ul><li>name .php </li></ul></ul></ul><ul><ul><ul><li>help </li></ul></ul></ul><ul><ul><ul><ul><li>mods.html </li></ul></ul></ul></ul><ul><li>lib.php </li></ul><ul><li>mod_form.php </li></ul><ul><li>styles.php </li></ul><ul><li>view.php </li></ul>
  6. 9. Database structure <ul><li>prefix_course_modules </li></ul><ul><ul><li>An instance of a module in a particular course </li></ul></ul><ul><li>prefix_ name </li></ul><ul><ul><li>Your table. Must have id, name, course </li></ul></ul><ul><ul><ul><li>And index on course </li></ul></ul></ul><ul><ul><li>$cm->instance == $ name ->id </li></ul></ul><ul><li>Variables </li></ul><ul><ul><li>$cm, $ name , $course </li></ul></ul>
  7. 10. Versions and database tables <ul><li>install.xml </li></ul><ul><ul><li>Used when installing for first time </li></ul></ul><ul><ul><li>Create with horrible editor ( not by hand!) </li></ul></ul><ul><li>update.php </li></ul><ul><ul><li>Used after code update on existing database </li></ul></ul><ul><ul><li>Code in PHP </li></ul></ul><ul><li>version.php </li></ul><ul><ul><li>Module version e.g. 2007031600 </li></ul></ul>
  8. 12. Capabilities <ul><li>Define capabilities for your module </li></ul><ul><ul><li>Array in access.php </li></ul></ul><ul><ul><ul><li>Specifies available capabilities and who has them by default </li></ul></ul></ul><ul><ul><li>mod/ name :edit, mod/ name :view,… </li></ul></ul><ul><li>Check capabilities </li></ul><ul><ul><li>Get context object for current module instance </li></ul></ul><ul><ul><li>has_capability(‘mod/ name :edit’,$context) </li></ul></ul>
  9. 13. Language files <ul><li>All strings taken out into language files </li></ul><ul><ul><li>Except system errors </li></ul></ul><ul><ul><ul><li>But not except user errors! </li></ul></ul></ul><ul><ul><li>Why? Now or future contribution to community </li></ul></ul><ul><li>Language file goes in lang/en_utf8/ name .php </li></ul><ul><ul><li>$string[‘frogscanjump’]=‘Frogs can jump’; </li></ul></ul><ul><ul><li>$string[‘howhigh’]=‘How high? $a metres!’; </li></ul></ul><ul><li>A couple standard strings (module name) </li></ul>
  10. 14. Help files <ul><li>In lang/en_utf8/help </li></ul><ul><li>Basic XHTML content </li></ul><ul><li>One standard file mods.html </li></ul><ul><li>Add other files </li></ul><ul><li>Link to them with standard help button </li></ul><ul><ul><li>For example, in forms </li></ul></ul>
  11. 15. Forms <ul><li>In case you’ve forgotten… </li></ul>
  12. 17. Forms <ul><li>mod_form.php </li></ul><ul><li>PHP QuickForm + Moodle extensions </li></ul><ul><ul><li>$mform->addElement('text', 'name', get_string('name')); </li></ul></ul><ul><li>Various types provided </li></ul><ul><li>Easy to add help buttons </li></ul><ul><li>Does formatting for you </li></ul><ul><ul><li>And accessibility (hopefully) </li></ul></ul>
  13. 18. view.php <ul><li>Your own PHP code </li></ul><ul><li>Can do anything </li></ul><ul><ul><li>Should use Moodle standard functions where appropriate </li></ul></ul><ul><ul><li>Header, footer, tabs, etc. </li></ul></ul><ul><li>Other PHP scripts too (as needed) </li></ul><ul><ul><li>view.php is just where the link goes </li></ul></ul>
  14. 20. Conclusion <ul><li>Standard platform features need to be used </li></ul><ul><ul><li>Maintaining </li></ul></ul><ul><ul><li>Administration (capabilities) </li></ul></ul><ul><ul><li>Community sharing </li></ul></ul><ul><li>Initial design is important </li></ul><ul><li>Skills needed </li></ul><ul><ul><li>Database </li></ul></ul><ul><ul><li>PHP </li></ul></ul><ul><ul><li>And… </li></ul></ul>
  15. 21. Bonus scare slide <ul><li>Security!!!!1!!1!!eleventy-one </li></ul><ul><ul><li>Public Web application </li></ul></ul><ul><ul><li>Easy to make mistakes </li></ul></ul><ul><ul><ul><li>Check permission on action as well as when showing link </li></ul></ul></ul><ul><ul><ul><li>Avoid SQL injection </li></ul></ul></ul><ul><ul><li>Be careful! </li></ul></ul>
  16. 22. To end on a positive note <ul><li> </li></ul>

×