Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
Randomisation of instructions

I am a complete beginner in javascript so really need help! I have made a set of questions called advisorRating (parts shown below) and I want the preamble to say 'rate advisor A' and 'rate advisor B' on separate pages in random order.

i.e. on one page rate advisor A -> submit -> next page asks to rate advisor B and vice versa.

I also want the presentation order to be equally distributed (i.e. 50% time A and then B, vice versa)

To do this, I've tried the code below but its not working. For awhile it only showed advisor B twice and now its only showing advisor A twice.

  type: jsPsychSurveyLikert,
  questions: [
    {prompt: "How knowledgeable is this advisor?", 
    name: 'Knowledgeable', 
    labels: advisorLikertScale,
},
if (Math.random() < 0.5)
{
    advisorRating.preamble = "Please rate Advisor A on the following questions";
    timeline.push(advisorRating);
    advisorRating.preamble = "Please rate Advisor B on the following questions";
    timeline.push(advisorRating);
}
else
{
    advisorRating.preamble = "Please rate Advisor B on the following questions";
    timeline.push(advisorRating);
    advisorRating.preamble = "Please rate Advisor A on the following questions";
    timeline.push(advisorRating);
}

I've tried different things:

defining advisor preamble differently: advisorRating["preamble"]

defining advisorA and advisorB first and then pushing:

var advisorB = advisorRating
advisorA.preamble = "Please rate Advisor A on the following questions";
advisorB.preamble = "Please rate Advisor B on the following questions";
if (Math.random() < 0.5)
{
    timeline.push(advisorRatingA, advisorRatingB);
}
else
{
    timeline.push(advisorRatingB, advisorRatingA);
}

I would like to know why this isn't working. However, more importantly, I would like to know how I can achieve my initial goal: randomly presenting the instructions on different pages.

Thank you for your help :)x

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda