Quantcast
Channel: General developer forum
Viewing all articles
Browse latest Browse all 37670

How to determine who added this module (activity or resource)

$
0
0
by Ahmad K.  

Hi moodlers!

Could you please give me your suggestion to what i have achieved:

In some custom course format which i was developing lately on moodle 2.3.x, I needed this to be determined:

In current course, who added this module (activity or resource)??

I did a little search here in the forums, and i did not manage to find an answer to my question (and if there is one which i missed, please forgive me).

So i decided to solve it by my own.

I started diging in the moodle db tables, starting from course_modules table with no luck.

Finally i did find a solution, and here it is:

$records = $DB->get_records_sql('SELECT * FROM {log} WHERE course LIKE ? AND module LIKE ? AND action LIKE ? AND url LIKE ?',
array( "$course->id", 'course', 'add mod', "%id=$mod->id" ));

Apparently i used the log table to determine what i needed.

My question is:

Is there a better way to answer my question in the begining (who added this mod?)??

(espicially that the rendering of the course has become SLOWER, because at every mod in the course, we have to execute the previous query on the HUGE log table )

I hope that my solution could help any one, and if there is a better solution please share it with us.

TIA


Viewing all articles
Browse latest Browse all 37670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>