Syntax highlighing in Moodle

The main idea is that we need syntax highlighting to quiz questions.

Here are the requirements:

  1. a plugin that is updated frequently, preferable by more than 1 person.
  2. support for syntax highlighting to as many languages as possible, not only in editing mode within the editor but in the view mode of questions, pages etc.
  3. it has to be free.
  4. it is better that it is accessible from the buttons of the editor so that it is easily accessible from students who want to create quiz content.
  5. it should support moodle 3.3+

Plugins that do not fill these requirements are:

  1. html+
  2. geshi
  3. Code Sample plugin

So here is a solution:

1 – Install the generico filter

Steps:

  1. Download the filter
  2. unzip to <moodleinstalldir>/filters
  3. navigate to moodle notifications and the system will guide you for installation, install.

2 – Activate the generico filter

Go to: Site Administration->plugins->filters->manage filters and activate the filter

3 – Configure the generico filter

Go to: Site Administration -> plugins -> filters -> Generico

From the bundles you can try the codeblock. But it didnt work for me.

I used prettify.txt from moodle forums. To install it simply drag and drop to the proper area (you will be prompted at the administrations screen, it should be a green area named “bundle”).

You can download prettify.txt from here.

To use the filter you can use the following tags:

{GENERICO:type="prettify",lang="php"}

 {GENERICO:type="prettify_end"}

4 – Install a plugin for your editor

For Atto you need: Generico Atto Icon with which a button will appear on the editor that can be used to autogenerate the generico tags.

 

 

References:

https://moodle.org/mod/forum/discuss.php?d=261896

https://moodle.org/mod/forum/discuss.php?d=339420

 

 

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s