Forum Discussion
Any way to identify a large number of individuals using their user ID and variables?
Hi!
I have a piece of Javascript that brings the learner's User ID (which is a number) into Articulate and saves it as a variable 'UserID'. I have a list of 700 user IDs that need to see a different menu on taking my course.
Can anyone see a way to write a single trigger to identify these 700 accounts?
I can get it to identify them individually with 'If UserID is equal to 12345678, set variable Group1 to true', but I can't have a separate trigger for each user ID because there are too many. Is there a way to separate the numbers within the same trigger? Ie 'If UserID is equal to 12345678;12345679;112345671, set variable Group1 to true'?
Ideally I need to be able to paste the numbers from Excel or Word into a single field....
- Jürgen_Schoene_Community Member
here a small Javascript, which can do this
var groups = {
1: [
12345678, 12345679, 112345671,
],
2: [
12345699, 12345698, 112345667,
],
// ...
}
var player = GetPlayer();
var userID = parseInt( player.GetVar("UserID") );
var result = 0
for( var group in groups ){
if( groups[group].indexOf(userID) >= 0 ){
result = group;
break;
}
}
player.SetVar("Group", result )Group = -1 -> not yet searched
Group = 0 -> not found
Group > 0 -> group number
https://360.articulate.com/review/content/aaf27bda-178d-411f-81cd-6d4d96a41724/review
- RebeccaEvens-afCommunity Member
Fantastic, thanks!!!