How to pass a variable into report from a custom link

How to pass a variable into report from a custom link

by Casey Tyler -
Number of replies: 4

Hello All,

I have a sql query that I used that pulls all classes taken by a student  along with the grades. This is essentially a transcript. I have a parameter set up for the user id that pulls up that students transcript. It works very well. However, you have to go to the students profile page, get the id, browse to the report then enter in the id to get to it. What I would like to do is either:

  1. add a block to the users profile page where the ID could be grabbed from there  (like it does for courses when a custom report is added to a course).
  2. Add a custom link to a custom profile page that I can pass a users ID to the report when clicked.


Has any body done this or have any ideas on how I can do this.


Thank you

Casey

Average of ratings: -
In reply to Casey Tyler

Re: How to pass a variable into report from a custom link

by Nadav Kavalerchik -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

Here is an example of calling a second report from a main report

https://docs.moodle.org/31/en/ad-hoc_contributed_reports#List_course_resources_accumulative_file_size_and_count

Though, you could use the second report's ID and not its ALIAS, as in the above example. much simpler. 

In reply to Nadav Kavalerchik

Re: How to pass a variable into report from a custom link

by Casey Tyler -

Hi Nadav,

Thank you so much. I really appreciate it.

I do have one more question if you could help me with.

When using a filter, is there any way to counter the LIKE comparison. For instance, if I am looking for a specific User ID, is there any way to convert the LIKE operator to "=".

Thanks again for your help Nadav!

PS:  I did search the forums and had seen this question asked but I could not find one with an Answer.

In reply to Casey Tyler

Re: How to pass a variable into report from a custom link

by Nadav Kavalerchik -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators

If you are searching for userid = 123 and use the "searchtext" filter this way

#%%FILTER_SEARCHTEXT:user.id:~%%

It is actually converted to " AND user.id LIKE '%123%' "

And if you are using it this way:

#%%FILTER_SEARCHTEXT:user.id:=%%

It is actually converted to " AND user.id = '123' "


There are other logical condition you can use too, see:

https://github.com/nadavkav/moodle-block_configurablereports/blob/M27/components/filters/searchtext/plugin.class.php#L43

Average of ratings: Useful (2)
In reply to Nadav Kavalerchik

Re: How to pass a variable into report from a custom link

by Casey Tyler -

That is exactly what I was looking for. Thanks you so much. You just saved me a ton of time.


Thank you, thank you, thank you!

Casey