Supporting each other

Community forums

Welcome, Guest
Username: Password: Remember me
This is the place for questions about learning design and pedagogy; how to use different page types for different purposes.
  • Page:
  • 1

TOPIC:

remember user selection 4 years 6 months ago #5939

  • viragom
  • viragom's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 29
  • Thank you received: 0
Hi all ,

I would like to make a LO in which the user can make a selection, i.e. female name / male name, 2 options on a page.
The users selects one
The name is remembered througout the rest of the LO (no backward navigation)

My problem: I can't find a way to let the LO remember the selection; (tried a variable for each, but i don't know which name the user selects, then i have to have all pages double....)

Thnx

Please Log in or Create an account to join the conversation.

remember user selection 4 years 6 months ago #5940

  • Fay
  • Fay's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • Posts: 231
  • Thank you received: 86
The next release will contain functionaility that allows users to set the value of variables themselves - so you could have a text field on the first page which will set the value of a variable used on subsequent pages. There's some documentation on this here: Variables documentation

You can achieve something similar at the moment but you will have to add some script yourself.

1. Create a variable which will hold the name info (in screenshots attached I've called it 'nameToUse' but it can be anything & I've set default value to be one of the names 'Bob')
2. On your first page create two links (one for each name) which point to the next page in the project (use the Xerte page link button)
3. View the source of the text field & add an id to the links - I've called them 'bob' & 'jane' (see screenshot)
4. Add the 'script' optional property & paste in this code for each button that you want to make change the default value of the variable. Note that '#jane' needs to match the id you gave the link in step 3:
$('#jane').click(function() {
  for (var i=0; i<x_variables.length; i++) {
  if (x_variables[i].name == 'nameToUse') {
    x_variables[i].value = 'Jane';
  }
}
})

5. Then add the variable to any subsequent pages with the markup [nameToUse] (see screenshot)

I hope this helps
Fay
Attachments:

Please Log in or Create an account to join the conversation.

remember user selection 4 years 6 months ago #5941

  • viragom
  • viragom's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 29
  • Thank you received: 0
Thnx Faye

But does this also work if Jane (or Bob) is a variable?

Please Log in or Create an account to join the conversation.

remember user selection 4 years 6 months ago #5942

  • Fay
  • Fay's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • Posts: 231
  • Thank you received: 86
With a bit of tweaking. So you could create 3 variables - one for female name, one for male name & one that's used to remember which one they choose on 1st page. Female / male names could for example be randomly choosen from a list.

Then on the page you want the user to make the selection you would have two links with id 'male' 'female' & can have this script:
var maleName,
    femaleName;

 for (var i=0; i<x_variables.length; i++) {
   if (x_variables[i].name == 'male') {
   maleName = x_variables[i].value;
   }
    if (x_variables[i].name == 'female') {
   femaleName = x_variables[i].value;
   }
 }

$('#female').click(function() {
  for (var i=0; i<x_variables.length; i++) {
  if (x_variables[i].name == 'nameToUse') {
    x_variables[i].value = femaleName;
  }
}
})

$('#male').click(function() {
  for (var i=0; i<x_variables.length; i++) {
  if (x_variables[i].name == 'nameToUse') {
    x_variables[i].value = maleName;
  }
}
})

You really need to understand some javascript if you want to go about doing this (not sure if you do) as you're likely to want to play around with exactly how you set it up yourself.

Please Log in or Create an account to join the conversation.

remember user selection 4 years 6 months ago #5943

  • viragom
  • viragom's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 29
  • Thank you received: 0
Thnx Fay

I do understand a little bit of JS...
and because the variable was used on the page already (in the clickable link for male and female), i could also use the GetElementById('male').textContent function in JS

I like your solution, so I'm gonna use that one.

Thnx

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ingdon
Time to create page: 0.068 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search