vuk_niko
vuk_niko

Reputation: 21

Moodle plugin development - Is it possible to add html element to course/view.php?id=x from Activity module plugin I'm developing?

I am developing a plugin for comments and ratings of resources in moodle, so I figuered out that it is activity module type of plugin.

My goal is to enable students to rate resources and comment them but i can't find a way to display my star rating on a course/view.php?id=x page, where x is id of course. So basically, i want my plugin to add something like this:

enter image description here

I did research on https://docs.moodle.org/dev/NEWMODULE_Documentation, but there are no examples of plugins which add any html elements to the page mentioned above, and i couldnt find a way on my own of accessing course page view from activity module plugin. Is there a way i can achieve that?

My moodle version is 3.01

Upvotes: 1

Views: 1612

Answers (3)

AminFarajzadeh
AminFarajzadeh

Reputation: 408

you can do this in moodle/cource/view.php file :

<?php
.
.
echo $OUTPUT->header();
?>

<html elemets>

<?php
.
.
echo $OUTPUT->footer();

Upvotes: 0

vuk_niko
vuk_niko

Reputation: 21

After more detailed research, I found out that only way to achieve this is to change core of moodle. Precisely, in mod/resource/lib.php, there's function resource_cm_info_view(cm_info $cm), and $cm has function set_after_link(). So if that function is enabled, you can set afterlink. But that afterlink should lead to page on which are displayed comments and ratings for that particular resource. And that can be achieved throuh plugin.

Here are couple of pictures so You can see what i'm talking about:
mod/resource/lib.php
live moodle platform

Basically, if moodle community agrees to update moodle just a bit,and add something like

if (plugin exists) { enable afterlink function and pass it parameter for comment and rating link }

then it would be possible to create plugin that it is discussed. But that is up to them, and I am not sure if they would agree to such a thing.

So, short answer to my question is: No, it is not possible.

Upvotes: 1

nadavkav
nadavkav

Reputation: 466

Not a direct answer to your question but might help...

Upvotes: 0

Related Questions