Hi everyone,
In our course, we use a database activity for sending and sharing files. As we have a large amount of users (+3000), and their informatics knowledge is limited, we need to create a simple way for them to see their own itens (so they can read the comments left on in, or edit).
So, the question is: Is there a way to create a link to user's sent itens?
Thanks in advance!
You can use javascript to read the user name from the login info on the page and run search. Of course you may have users with the same name in which case the search result will show more than is actually required. So you can extract from the login info the Moodle user id rather than the user name and this should be unique (needless to say you need to have the ##user## in the list view for this to work).
Hi Itamar,
we tried this solution, but weren´t able to apply it successfully. Could you (or somebody else) be more specific about the code needed to perform this search?
Thanks!
we tried this solution, but weren´t able to apply it successfully. Could you (or somebody else) be more specific about the code needed to perform this search?
Thanks!
The login info in the database page is in the footer (at least in the standard themes; it may be different in specifically tailored themes in which case you can inspect the page source to find the DOM structure).
The user name should be retrievable by something like
var whoami=document.getElementById("footer").getElementsByTagName("a")[1].innerHTML;
If you want the user Moodle-id you need to retreive the href of the a tag and extract that id from it
/moodle/user/view.php?id=747&course=20666
Now with this info you can set the location.href to something like
http://moodle.yours.u/moodle/mod/data/view.php?d=13&perpage=100&search=John Doe&sort=0&order=ASC&advanced=0&filter=1&u_fn=&u_ln=
and that should reload the page and display only John Doe's records.
The user name should be retrievable by something like
var whoami=document.getElementById("footer").getElementsByTagName("a")[1].innerHTML;
If you want the user Moodle-id you need to retreive the href of the a tag and extract that id from it
/moodle/user/view.php?id=747&course=20666
Now with this info you can set the location.href to something like
http://moodle.yours.u/moodle/mod/data/view.php?d=13&perpage=100&search=John Doe&sort=0&order=ASC&advanced=0&filter=1&u_fn=&u_ln=
and that should reload the page and display only John Doe's records.