String substitution in Webpage or Weblink URL

String substitution in Webpage or Weblink URL

by Brandon Neill -
Number of replies: 7
I had a situation where I needed the url linked in a resource to be aware of the users ID. I was able to add a couple of lines of code so that I could put %%i in the URL, and it would substitute the users ID when they clicked on the resource. I suspect that others may find this useful as well.

The code was pretty simple, I just added:
$fullurl = str_replace("%%i", "$USER->id", "$resource->reference");

to the beginning of the case WEBPAGE section, and then changed $resource->reference to $fullurl. The str_replace can accept arrays, so it wouldn't be hard to add other substitutions.

Would others be interested in this feature?

Are there other data that might be needed in string substitition (username maybe)?

Any possible problems with using the %%i, %%u?
Average of ratings: -
In reply to Brandon Neill

Re: String substitution in Webpage or Weblink URL

by Tom Murdock -
When I grade papers and make comments (in MS WORD), I'd like a way to give the papers back in Moodle. Could I somehow upload them to a folder and then use a device like this to make it possible for the kids to retrieve them? I want to avoid having them pick up the papers of their classmates.
In reply to Tom Murdock

Re: String substitution in Webpage or Weblink URL

by Paula Edmiston -
Would you need to create a folder for each student as a way to control the data in the string to limit it to an individual?

What about just send an email to the student with the file attached? You could go to the listing of participants for the course and their email address is hyperlinked on the main listing everyone. The email message would also provide a place to enter comments (though it might be more efficient to insert the comments in the Word doc)

Perhaps you're thinking that when a person enrolls in a class the folder will be automatically be created? If so, then the list of participants could also include a link to that folder? You'd still need to upload each file individually, yes?

best,
paula
In reply to Paula Edmiston

Re: String substitution in Webpage or Weblink URL

by Joe Barnett -
Right. We would have to separately upload each file to each individual directory for each student, so, it seems that it would be basically the same as sending it as an email attachment. The difference is that the directories would complicate the system that much more. Just a thought.

I have taught up to five college online writing classes at one time, so I understand how time consuming it is to give back all of the papers one at a time. You get a rhythm to it after a while. smile

- Joe
In reply to Brandon Neill

Re: String substitution in Webpage or Weblink URL

by Gerhardt Katharina -

I  am very interested in this feature! But do you know how to do this for the new moodle version 1.4?

Thank you!!

In reply to Gerhardt Katharina

Re: String substitution in Webpage or Weblink URL

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
1.4 has this built in ... when adding a linked resource look under "parameters".
In reply to Martin Dougiamas

Re: String substitution in Webpage or Weblink URL

by Ralph Blakeslee -
Martin,

Could you please give me a little more guidence on how to use this feature. I would like to be able to pull a student's name out of the data base a place it in an html web page resource.

Thank you again for you assistance.

Ralph