Can one create custom HTML blocks like a CMS with Moodle?

Can one create custom HTML blocks like a CMS with Moodle?

par Utilisateur supprimé,
Nombre de réponses : 10

Dear All,

As the subject says; we are getting a new CRM and thought it would be nice if when the student logs in, the CRM can be queried for a number of issues (outstanding fees, attendance issues and so on) and then have a block that alerts the student to the information. Also, if I need to make that connection using web services and the web service in question is not part of what Moodle offers, how would I write one that is attached (maybe added) to what Moodle offers?

Regards,

George

Moyenne des évaluations  -
En réponse à Utilisateur supprimé

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Mary Cooch,
Avatar Documentation writers Avatar Moodle HQ Avatar Particularly helpful Moodlers Avatar Testers Avatar Translators

Hello George

I've just messaged you to say I moved your post to the General Developer forum to see if you can get more technical help from there. Moodle does Web services although it's not something I understand myself.

En réponse à Mary Cooch

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Utilisateur supprimé,

Hi Mary,

Many thanks for the prompt reply. Setting aside the web services issue, is there a way that I can create a custom block to be shown where I choose on Moodle with my own text?

Regards,

George

En réponse à Utilisateur supprimé

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Mary Cooch,
Avatar Documentation writers Avatar Moodle HQ Avatar Particularly helpful Moodlers Avatar Testers Avatar Translators

Hi George - it's possible to add an HTML block and put your own text/image and other in it if that is what you mean -see HTML block

En réponse à Mary Cooch

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Utilisateur supprimé,

Hi Mary,

Many thanks for the prompt reply; is this functionality limited to HTML blocks or can one create PHP blocks as well? Is there any special syntax for them?

Regards,

George

En réponse à Utilisateur supprimé

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Richard Oelmann,
Avatar Core developers Avatar Particularly helpful Moodlers Avatar Plugin developers Avatar Testers

Use the HTML block as Mary suggests - that can be put in any block region and those depend on your theme.

Most themes that means in the side-bars, but there are themes around that allow block regions in multiple locations, although drag and drop into those regions does not work properly from 2.3 onwards (the block location can be altered in its settings though.)

En réponse à Richard Oelmann

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Utilisateur supprimé,

Hi Richard,

Many thanks, that is very useful information. Is this functionality limited to HTML blocks or can you do other languages as well (e.g. PHP)?

Regards,

George

En réponse à Utilisateur supprimé

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Oliver Stearn,

Hi George,

I would have thought this functionality is limited to HTML/JS.

If you want to include custom php, you will need to delve slightly deeper into moodle code.

This article/book/ we goes over the process of creating a super simple plugin. I recommend following this through to 'Line 11: Starting output' at least, here he mentions the process of loading and outputting blocks (which are plugins in moodle too).

I am no developer, but since this was unanswered I thought I would have a crack (I found this link very useful not too long ago). I dont know what you mean by CMS.. I would have thought you could have all your 'issues' within a single block and therefore bundle all your code within a plugin (checks for issues, displays those relevant or nothing at all).

If you want to organise blocks in a CMS, this would be a much bigger undertaking. I think (plz correct me if im wrong) you would have to fiddle with the code responsible for rendering blocks.

En réponse à Utilisateur supprimé

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Richard Oelmann,
Avatar Core developers Avatar Particularly helpful Moodlers Avatar Plugin developers Avatar Testers

If you want to create a block from scratch then you can create a block to do almost anything you want using html/php/javascript.

The html block, though, is a pre-existing block which simply allows you to add your own text through the editor, which seemed to be what you were asking Mary about.

If, going back to your original post, you need to query an external database and customise that text based on the results of the database query (or just use values returned from the query) then you will almost certainly need to create your own block rather than using the html block.

Richard

 

En réponse à Richard Oelmann

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Utilisateur supprimé,

Oliver, Richard,

Many thanks for the prompt replies. I am relatively new to Moodle coming from the CMS world so sometimes I confuse the terminology. What I want to do is query an external database source and based on the results perform some output. Based on what Richard is saying if my understanding is correct, this would amount to creating a new block (unless I am wrong again)?

Regards,

George

En réponse à Utilisateur supprimé

Re: Can one create custom HTML blocks like a CMS with Moodle?

par Richard Oelmann,
Avatar Core developers Avatar Particularly helpful Moodlers Avatar Plugin developers Avatar Testers

That's right George,

You will need a new block for this purpose as I don't think you would be able to add that into an html block.

I would start with looking at an existing simple block, then in the main .php file you would have the connection to your external database- if its available to be queried - the logic to create the information you want to display and then the actual display itself. That said, I've never created a block that connects to another external database myself sourire but Oliver's link looks very useful for the basic set up of the block.

As to webservices, I'm guessing that depends very much on the data management of the CRM and how you are able to extract the data from it.

Getting the data out of your CRM would appear to me to be the only potentially complex issue - depending on the CRM and its background database. The logic and display of the information through a Moodle block should be reasonably straightforward.