Search This Blog

Saturday, January 7, 2012

How to add new field to database activity - Part 1

There are many changes that I'd like to make to the Moodle 2.1 database activity - I would mostly LOVE to embed images and video directly through the html editor.....like you can do on every other page. For some reason, this is disabled on the database activity. Oh well.

For now I've come up with a temporary solution: add a new field that allows you to upload a media file and it will be embedded in your page. First thing we are going to do is create the new field structure:

  1. On your moodle server, go to /mod/data/field/
  2. Copy the "file" folder and rename this (I chose to rename the folder as "media")
  3. Open up the "field.class.php" file - go to the first line of class definition (line 25). 
    1. Change this:    data_field_file
    2. To this:           data_field_media   (<-- or whatever you named your new folder)
  4. Inside the same file, the very next line (line 26), change this:
    1. Change this:      var $type = 'file';
    2. To this:             var $type = 'media';   (<-- your chosen name)
  5. On your moodle server, go to /mod/data/lang/en/data.php
  6. Here is where we define the name of our new field, so ALL of moodle can find it. If you like to keep things in alphabetical order, go to line 202 and add this:
    1. $string['media'] = 'Media';           (<-- again, replace "media" with whatever name you chose)
  7. In the same file, around line 220, add this:
    1. $string['namemedia'] = 'Media field';           (<-- replace this with your name)

Hopefully your new field should be added to the database acitvity now.
To test if it works:   go to your database activity, to the "Fields" tab, and navigate to the drop-down box where you can choose a new field.  If all goes well, you should see your new field appear in the list!

1 comment:

  1. Slots of Vegas Casino - DrmCD
    Play at Casino Vegas! 여수 출장안마 Featuring 전라북도 출장마사지 slot machines, table games, 포항 출장마사지 and live casino 1xbet 먹튀 action, our Las Vegas casino is the ultimate destination for 정읍 출장마사지 all kinds of

    ReplyDelete