Javascript to write to custom profile field?

Javascript to write to custom profile field?

by Kimber Warden -
Number of replies: 3

I am using the jquery plug-in Joyride to create a tour of our Moodle site and have it working correctly. Now I want to control WHEN students see it. Currently it begins every time a student views the Dashboard, and I want it to only begin the first time a student views the Dashboard. I know I could use a cookie to control whether or not it plays, but I want Moodle to remember whether or not the student has already seen it, even when he switches to another device.

I'm thinking perhaps I could create a custom profile field which Moodle could write to when the tutorial has been completed. Ideally, I would like Moodle to record "viewed" for each step of the tutorial, so that if a student only clicked through the first half of the tutorial, the 2nd half would still begin the next time the student views the Dashboard. 

What do I need to do in my javascript to make Moodle write something to a custom user profile field? For example, the profile field could be called "Tutorial Steps Watched" and Moodle would write "Step 1" after the student has clicked in the 1st Step, and "Step 2" after the student has clicked in the 2nd step, etc.


Average of ratings: -
In reply to Kimber Warden

Re: Javascript to write to custom profile field?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
In reply to Marcus Green

Re: Javascript to write to custom profile field?

by Kimber Warden -

I'm so glad someone is working on a tour plug-in! I hope it's released soon. I don't know if it will track item by item though.

For my own education, how would I accomplish what I'm attempting?

In reply to Kimber Warden

Re: Javascript to write to custom profile field?

by Ben Kelada -

you want to set_user_preference , using ajax

Average of ratings: Useful (1)