Loading...
 

Tiki and PluginR


Recording different RDatas for different users

posts: 14 SPAIN

Hi all,

I'm trying to make that different users have its unique RData (using pretty trackers), but I don't know how to do that...

What I want to do is to use a unique identification (for example, from the "user Selector" field when registering for the first time) and save the RData with the user's name. But it doesn’t' work.

Using the PluginR, I've tried the following:

___

user_name="{$f_180}"
personal_dataset=paste("Dataset_",user_name,".RData", sep = "")
save.image(personal_dataset)
___

where the field 180 is the name of the user (from the tracker: New User Registration Form), but I get the following error:

"No field indicated"

It seems to be an error due to the type of tracker, since if I assign a field from other "standard" tracker, it works.

Anybody knows how to solve it?

Thanks!

posts: 1776 Catalan Countries

Hi Moises:

I'd rather improve this at pluginR level, so for most multiuser use cases, it works out of the box. Luckily, it's an easy improvement codewise.

I'll report again when done.

Cheers


posts: 14 SPAIN

Great! Thank you Xavi,

Moisés


posts: 1776 Catalan Countries

Done, Moises. Implemented in PluginR v0.85:

0.85 Multiuser Cache added: split apart cached files from different users for the same page or itemId


It should be available in mods.t.o in a day or two.

I hope this solves your issue.

Cheers


posts: 14 SPAIN

Hi again Xavi,

I've updated the PluginR to v0.85. However, I understand that this improvement allows us to record different Rdata files depending on each itemID (and so on different users).

But the fact is that, what I'm trying to do is to use different Rdatas for each user (regardless the itemID).

That is, what I want to do is that each user has its unique Rdata (always). That's the reason I would want to save different Rdata's depending on the name of each user. One way could be by using this command:

user_name="{$f_180}"
personal_dataset=paste("Dataset_",user_name,".RData", sep = "")
save.image(personal_dataset)

,where field 180 indicates the name of the user when registrating for the very first time (from the tracker: New User Registration Form). But it doesn't work... (I suppose it's because of the type of tracker)

Any idea to do that?

Cheers

Moisés


posts: 1776 Catalan Countries

Uff, you are right, I did the "multiuser cache" part, and skipped by mistake the "multiuser Rdata" part.

There I go to implement it...


posts: 1776 Catalan Countries

Done Moisés, in PluginR v0.86

Please, test it and tell me if this new version fixes this issue for you.

Thanks for beta-testing these improvements!


posts: 14 SPAIN

Thanks Xavi,

I see that with the new version (v0.86) when creating a new item, a new folder is created in the cache (ex. R__itemid_000428), and regardless the user who executes this item, different Rdata's are created in the same folder. That's ok and works perfectly.

The problem, in my case, is that I'd need to have different folders (or files) for each user, since each user has its each "own" items.

For example, imagine that "user1" executed pluginR with item001. Then a RData would be saved (user1.Rdata). Then, imagine that the same user1 executed pluginR with item002. Then I would like to keep using the same RData (user1.Rdata) in order to create a "historic results" for this user1.

That's the reason I would need to specify, using commands in R, the command "save as" the name of the current user.

Sorry for the mess!

Moisés


posts: 1776 Catalan Countries

Ok, Moisés, let's see, then, on the wiki page or smarty template part.

You can enable "wiki argument variables" (Admin home > Textarea > General Settings > Wiki syntax > Wiki argument variables".

Then you can use this special syntax :



that will be parsed as your username in a normal wiki page, and probably, in a smarty template.

Another (more complicated approach) would be to play with the tracker where the itemId belongs to. You could use tracker fields "items list" ( http://doc.tiki.org/Items+List+and+Item+Link+Tracker+Fields ), I guess, to display content from the users tracker into the tracker that hold the data/runs.
But this is more work, and probably not needed if the approach with wiki argument variables works already for your needs.

So, does it help?


posts: 1776 Catalan Countries
Another approach would be to make pluginR generate a second .RData per user, common for all the items of that user, in case that's what you need (if I understand it correctly)....

posts: 14 SPAIN

Almost solved...

The option of using a .RData per user would be what I need and the idea of using is great (since I need to call each .RData as the name of each user)! But another problem came... even activating argument variables, it seems not to work with smarty templates.

I've tried to use it in a "regular" wikipage, and it works without problem. That is:

{RR()} 
user_name=""
user_name
{RR}


But when using it with a smarty template I get this error message:

Syntax Error in template "tplwiki:Template_main" on line 43 "a=""" unknown tag "user"

posts: 1776 Catalan Countries

In tpl you can try with:

{$user}


Writing from the top of my head ...

posts: 14 SPAIN

You've hit the nail on the head! Now It works. Thanks Xavi!

The only thing is that it is necessary to write it in quotation marks. On the other hand, it only works within templates.

Hence, in short, if one wanted to save a unique RData for each user, it can be done as follows using the pluginR:

{RR()} 
user_name=""
user_name
personal_dataset=paste("Dataset_",user_name,".RData", sep = "")
save.image(personal_dataset)
{RR}


Or within a smarty template

user_name="{$user}"
personal_dataset=paste("Dataset_",user_name,".RData", sep = "")
save.image(personal_dataset)


Thank you for your help!



posts: 27 France

Following this thread, Xavi had made the Rdata files and caches always "per user", which pretty much disables caching for sites where multiple users should see the same thing.

I have now added an option cachestrategy which allows to choose per user or everybody sees the same for each plugin. Plus a no cache choice which might be useful when trying to write/edit/fix/test the R script.
'options' => array(
array('text' => tra("One cache per plugin"), 'value' => 'one'),
array('text' => tra("One cache per plugin per user"), 'value' => 'peruser'),
array('text' => tra("No caching: Ignore and replace existing cache, if any"), 'value' => 'nocache'),
),


posts: 1 United States
thanks xavi

Why Register?

Register at tiki.org and you'll be able to use the account at any *.tiki.org site, thanks to the InterTiki feature. A valid email address is required to receive site notifications and occasional newsletters. You can opt out of these items at any time.