Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: DicoTrad block.

DicoTrad block: Difference between revisions

From MoodleDocs
Line 142: Line 142:
# Visibility of the block in the Moodle environment.  
# Visibility of the block in the Moodle environment.  


Only the points 3 and 4 are involved in adding a dictionary or any other search engine. We are going to see how to add the possibilty to query google. We will first display Google after the Etymology dictionary. In a second time we will add a new category named Search engine that include Google.
Only the points 3 and 4 are involved in adding a dictionary or any other search engine. We are going to see how to add the possibilty to query google. We will first display Google after the Etymology dictionary. In a second time we will add a new category named Search engine that include Google. <br>


We previously saw that the encoding of Google website was UTF and that the root of the link is:
We previously saw that the encoding of Google website was UTF and that the root of the link is: <br>
http://www.google.com/search?hl=en&lr=&q=


=== Displaying a dictionnary in DicoTrad ===
=== Displaying a dictionnary in DicoTrad ===

Revision as of 17:05, 23 January 2007

What's DicoTrad ?

DicoTrad is a moodle block with linguistic tools. It provides, by querying webservers, the following functionalities:

dicotraden0.jpg
  • Definition; Wordreference and Merriam-Webster dictionaries
  • Synonym
  • Antonym
  • Etymology
  • Wikipedia; search and consult
  • Translation; english - french, german, italian, spanish, portuguese, norsk, russian, svenska, chinese, japanese and vice versa.

Available versions

  • For Moodle 1.6, dicotraden16.zip : link
  • For Moodle 1.7 and above, dicotraden17.zip: link

There is also a french version avaiable here:

  • For Moodle 1.6, dicotradfr16.zip : link
  • For Moodle 1.7 and above, dicotradfr17.zip: link

Forum thread for this block here:


Archive content

  • Readme.txt
  • block_dicotraden.php (source code of the block)
  • tree.css (style sheet for the tree (menu))
  • treeview folder (images of the tree)
  • yui (a part of the yahoo user interface. Note that YUI comes with Moodle 1.7 so that dicotrad17.zip doesn't need this folder)

Configuration requirements

  • Moodle 1.6 or 1.7 and above
  • The block isn't visible in the tests.
  • I recommend to use at least a screen resolution of 1024x768
  • Works on Firefox 1.5 / Internet Explorer 7

Installation

1. Download dicotrad16.zip or dicotrad17.zip
dicotraden1.jpg

2. Unzip the file named dicotraden16.zip/dicotrad17.zip.
dicotraden2.jpg

3. Copy the folder dicotraden and its content to your blocks folder (moodle/blocks).
File:dicotraden3.jpg

4. Connect to your Moodle site with an administrator account.
5. Go to the Moodle administration's page (http://yourwebsite/moodle/admin). If everything is ok you'll get the following message:

"DicoTrad tables have been set up correctly"

6. Go to your site homepage or in the course you want to display the block. Turn editing on and click Add in the block "blocks" and select DicoTrad.
dicotraden4.jpg

7. You can customize the name of the block by clicking the hand under the title's block (turn editing on).
dicotraden5.jpg

8. dicotraden6.jpg
9. Now the block has a custom name.
dicotraden7.jpg

Now let's see how it works !

Using the block

It's pretty easy to use it;

  1. Enter a word in the field
    dicotradenuse.jpg
  2. Hit the arrow on the right of the field or hit enter, this will generate links.
  3. Click the link(s) you're interested in (i.e Merriam-Webster) and/or choose a language for translation.
  4. That's all ;)

Known problems

  • It's possible to collapse some menu elements by clicking on them (Dictionaries, Wikipedia, Translate). Notwithstanding, the menu is expanded at every reloading of the page and on every user submission. Because of it, I suggest you to collapse the whole block when you don't use it.
  • As you submit a word the page reload. For this I recommand you to put the block at the top of the page to avoid jumps from bottom to top.
  • It's not possible to have multiple version of DicoTrad on the same page. I.e you can't run the french and the english versions on the same page.

== How to add a dictionary ? == UNDER CONSTRUCTION At first sight, this work can appear long and tiresome. However with some practice you will be able to add, test or remove a dictionary in a few minutes! The addition or the removal of a dictionary requires the modification of the source code of the block. For that it is necessary to use an editor PHP such as for example PHP Designer.


Generally, this work can be broken up as follows:

  1. Retrieving information about the site to add.
    • URL structure.
    • Server encoding.
  2. Add some lines in the source code (block_dictotradfr.php).
  3. Display the new dictionnary in the block.
  4. Test under Moodle.

As example we will add a function of Google research to our block.


Retrieving information about the site to add

The GET and POST methods

To start you should known that certain sites will not function with this block. DicoTrad contains an HTML form that collect the user request through a field. There are two HTML methods to send data to a server:

  • The GET method write the data in the URL so they can be seen in the navigation bar of a browser. For example, if you search the word "bird" in google, the following URL will appear in your browser:
http://www.google.com/search?hl=en&q=bird&btnG=Google+Search
As you can see, "bird" and other information appear in the URL. Dicotrad is using the GET method..
  • With the POST method the data of the form are not written in the URL. It's a safer method used for example at the time of subscribing a new user to a website. Babelfish is a good online example of the POST method. Any translation will return the same URL in your browser: http://babelfish.altavista.com/tr

DicoTrad is using the GET method, as a result it's impossible to add sites working with the POST method.

Identifying the root of the link

Let's say we want to add a website uses the GET method, for example Google. Our first step is to identify the part of the URL that remains the same whatsoever the request is. We will name it "the root of the link". If we search the words Moodle and then LMS we got the following URL:

Moodle:
http://www.google.com/search?hl=en&q=moodle&btnG=Google+Search

LMS:
http://www.google.com/search?hl=en&q=LMS&btnG=Google+Search

We can see that both URL look very similar, only the word of the request change. The structure of the link is:
http://www.google.com/search?hl=en&q=YOUR_REQUEST&btnG=Google+Search

You can try to submit a new request by modifying the URL (without using the google field). For example put "apple" in the URL and hit enter:
http://www.google.com/search?hl=en&lr=&q=apple&btnG=Google+Search

Playing a little more with the URL show that it also works like this:
http://www.google.com/search?hl=en&lr=&q=apple

The structure of the link is :
http://www.google.com/search?hl=en&lr=&q=YOUR_REQUEST

The root of the link is: 
http://www.google.com/search?hl=en&lr=&q=

Server encoding

Another important step consists in knowing the server encoding. Moodle uses UTF-8 which is universal. I.e. it is able to encode the characters of many languages. For now many websites are encoded in other format that are, usually, identified by the browser. ISO 8859-1 is one of them. It's widespread and contains the Latin alphabet. It's used in the Americas, Western Europe, Oceania, and much of Africa.
The main function of DicoTrad is to create URLs that contain the user request. As this work is done in Moodle environment, the URL will be encoded in UTF-8. Everything is alright if the queried server is also in UTF-8. But when it's not the case (i.e ISO 8859-1), the queried server won't understand the request. We will see later how we can deal with such cases.
There is an easy way to know the encoding of a server. We will just enter an accentuated character and see how it appears in the browser navigation bar.

Let's search "é" in Google:
http://www.google.com/search?hl=en&q=%C3%A9&btnG=Google+Search
"é" is encoded by %C3%A9, this is UTF-8.

On ebay: http://search.ebay.com/search/search.dll?from=R40&satitle=%E9
"é" is encoded by %E9, this is ISO 8859-1.

Many other encodings exist. Unfortunately most of them won't work or will display some errors with DicoTrad. The only way to know if they will work is to try them !

Add a dictionnary in the source code of DicoTrad

To perform this step you need to edit the file block_dicotraden.php with an editor (like PHP editor). This file can be found in moodle/blocks/dicotraden/

The code of block_dicotraden.php has the following structure:

  1. Declaration of the block for Moodle.
  2. The form that include the field for the user request and a submit button.
  3. URL encoding of the dictionaries.
  4. Display of the dictionaries in the block.
  5. Visibility of the block in the Moodle environment.

Only the points 3 and 4 are involved in adding a dictionary or any other search engine. We are going to see how to add the possibilty to query google. We will first display Google after the Etymology dictionary. In a second time we will add a new category named Search engine that include Google.

We previously saw that the encoding of Google website was UTF and that the root of the link is:
http://www.google.com/search?hl=en&lr=&q=

Displaying a dictionnary in DicoTrad

How to add a category ?

Download examples

How to change the icons of the block ?

How to remove a dictionary ?

How to remove a category ?