Moodle plugins directory: flowchart | Moodle.org
flowchart
Flowchart Moodle Filter
LMS Moodle filter to render/display flowcharts It uses flowchart.js by Adriano Raiano (http://adrai.github.io/flowchart.js, MIT license) that uses Raphaël js (http://raphaeljs.com, MIT license)
Using
common syntax is laTeX like:
\flowChart[<options>]{<content>}
example:
\flowChart[inline, yes-text:yup, line-width: 2]{st=>start: start in=>inputoutput: x,y op=>operation: z=x+y ou=>inputoutput: z en=>end: end st->in->op->ou->en}
Syntax
Syntax of content of the command see in flowchart.js project (http://adrai.github.io/flowchart.js/).
There could be any options in the command. Name them like options from example on the flowchart.js project page to make effect. Both :
and =
could be name-value separator.
There are four extra options:
- background-color : <html/css color>
- align : <html/css align>
- vertical-align : <html/css vertical-align> // will effect onli for inline flowchart
- display : <css display prperty>
Last three are not nessessery for manual operating. Background-color will affect div container. Displaying inline could be set up via singleinline
.
Installation
as zip
- download as zip (see https://bitbucket.org/belomir/moodle-filter_flowchart/downloads)
- install to moodle system via admin interface
manually
- clone this repo
- name the folder by filter name (flowchart)
- copy this folder into moodle's filter folder on server
How it works
It parses text to find all commands. Actually, standart php part of filter changes command to proper for js wrapper first. Then php part passes filter options from admin page. Plugs in to page nessessery js's. And runs main function from wrapper.
Wrapper finds all commands and parse them splitting options and content. Both are parses too. Places of commands appearing replaces with div container with proper settings. And then it calls flowchart.js function to add svg flowchart to given container with parsed text and locally override options.
Todo:
- more standart options to settings
Tomek
Warning Maturity information ($plugin->maturity) not found in version.php
Warning Release name ($plugin->release) not found in version.php
Warning Moodle requirements ($plugin->requires) not found in version.php
Second, I noticed that this is listed as being for Moodle 2.5. Has there been any testing on later versions of Moodle? Version 2.5 is no longer supported so it would be good if there were a version of the plugin available for a supported version of Moodle. Peace - Anthony
Warnings are fixed in 0.7 version (already merged in master).
I do belive plugin will work in all modern moodle versions, because js do the work, php part is almost dev wiki example.
But I'll try to set up moodle 2.8 to see how it works.
ps: if demo.moodle.net were allow install pugins it already would be tested 2.5 is what in ubuntu repo by default☺
Error: ReferenceError: initFlowcharts is not defined
in Moodle 2.8.
I'll try to figure out why is this happening, for some reason flowchart-wrapper.js is not included in the page.
$page->requires->js(new moodle_url('/filter/flowchart/js/flowchart-wrapper.js'), array(
'delayStartupUntil' => 'onload',
'showProcessingMessages' => 'false',
'messageStyle' => 'none'
));
Works well now!
Couple of minor things:
1. You're storing settings in mdl_config and not in mdl_config_plugins, see "Settings storage" point on https://docs.moodle.org/dev/Plugin_contribution_checklist .
2. flowchart-wrapper.js could be loaded and written using "Moodle JS way" - by using YUI loader and M namespace. I'm not sure how critical that is, I'll ask someone else to have a quick look at JS code.
3. Since you're including 3-rd party library, you could create thirdpartylibs.xml file.
I don't think any of the above is a deal breaker, your plugin looks good besides that!
Thanks Tomek for the review.
Marking this as needing more work yet so that Sergey has a chance to eventually fix the setting storage. Looking forward to approve this soon!
New version was tested with moodle 2.8
Previous versions are hided now (and will be deleted in future)
Thank you for your work and patience to novice.
Notation like this: $CFG->filter_flowchart/yes_text is parsed by PHP as
$CFG->filter_flowchart (division) yes_text
and hence causes warnings:
Notice: Undefined property: stdClass::$filter_flowchart in /var/www/html/vanilla/m283/filter/flowchart/filter.php on line 44
Notice: Use of undefined constant no_text - assumed 'no_text' in /var/www/html/vanilla/m283/filter/flowchart/filter.php on line 44
Warning: Division by zero in /var/www/html/vanilla/m283/filter/flowchart/filter.php on line 44
You can use this instead to fetch config values:
get_config('filter_flowchart', 'yes_text');
I had turn on error messages for moodle to see if something is wrong.
In last uploaded version it seems that it's OK.
At least I hav not any error messages and warnings.
Some more options are added to filter settings.
Thank you.
Sorry for the delay, I finally had a time to check your latest version. Looks good, my +1 to approve it.
I have came across the plugin for filter_flowchart and installed it on moodle V3.4.
Is it possible to give me a breakdown on how the function works/ trigger the option in the site.
Not sure how to activate this function and for use? I might be missing something.
I done the following:
- Site administration
- Plugins > select plugin and installed
- done
Is there an update with this plugin for Moodle 3.10?
Thank you in advance!