General developer forum

Moodle plugin development

 
Picture of Milad Akhavaan
Moodle plugin development
 

Hi all,

i have a question with regard to Moodle plugins.
I have added the newmodule template to my Moodle, and i have renamed everything. (i have downloaded from the link below). (Newmodule is the template plugin of moodle)
i have a Javascript package for my Wordcloud, that converts a text to wordcloud. the word cloud works local in my pc.
now i aim to integrate my javascript code to the new module plugin.  i mean, when i add the module activity to my course, i want to use my wordcloud to make the texts for me as a wordcloud.
 it would be of great help if you answer my question.


 
Average of ratings: -
Picture of Richard Jones
Re: Moodle plugin development
Particularly helpful MoodlersPlugin developersTesters

Hi Milad  

Integrating JavaScript in Moodle is done typically using the AMD module described here: https://docs.moodle.org/dev/Javascript_Modules.

An activity module may not be your best solution if you are wanting to process text in Moodle - you don't say where the text originates.  

I wonder if the existing tag cloud block would be a good model for your project?  

I'm sure there are people here who can help if you state more clearly the question(s) that you have (not trying to be funny but you didn't actually ask a question wink )



 
Average of ratings: Useful (1)
Picture of Milad Akhavaan
Re: Moodle plugin development
 

Hi,

Thank you for your answer.

My question is following.

I have javascript code that creates a Wordcloud from the text. this code functions locally in my PC. now i want to ask how can i use it in my moodle project as a plugin, or sth else that gets a text as an input (some Tags) and gives me a wordCloud as an output. 

Following is javascript code link:

https://github.com/jasondavies/d3-cloud

 a solution that i found was a newmodule template plugin. Following link:

https://github.com/moodlehq/moodle-mod_newmodule

If anybody can suggest me sth that works better, it would be perfect.

 
Average of ratings: -
Picture of Mark Sharp
Re: Moodle plugin development
Core developersParticularly helpful MoodlersPlugin developers

I have a filter plugin the utilises a 3rd party javascript.

As Richard mentioned you integrate javascript using AMD.

Have a look at my code at https://github.com/sharpchi/moodle-filter_syntaxhighlighter for an example.

Put your js in the AMD folders. Create and add your js refs to thirdpartylibs.xml

In your view.php (or whereever you want the cloud to appear, perhaps the renderer) you'll need to put in a call to requires->js_call_amd('yourplugin', 'initfunction');

In my plugin, it's in the filter.php file. 

Have a look here for more details: https://docs.moodle.org/dev/Javascript_Modules


 
Average of ratings: Useful (2)
Picture of Richard Jones
Re: Moodle plugin development
Particularly helpful MoodlersPlugin developersTesters

I also have a template for filters that might be useful if you take that route:

https://github.com/richardjonesnz/moodle_filter_simplemodal

It uses very primitive AMD code but at least you can see how it is set up within Moodle.



 
Average of ratings: Useful (1)
Picture of Nilesh Pathade
Re: Moodle plugin development
 

Hi Milad,

You can use your JavaScript by adding plugin index.php page and  try with YUI js.  

 
Average of ratings: Useful (1)