Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Javascript compare variables in captivate

New Here ,
Nov 28, 2017 Nov 28, 2017

Hi, 

I seem to be having a problem with comparing vars. I have two in captivate, one is called LMSpass and is set to 80 and the other grabs the score from my moodle LMS and populates LMSscore.  Then on the quiz results page I compare one with the other and it doesn't work. I want the learner to go to the next page if they pass which is a certificate. Can anyone offer some help, it looks like it should work ok

 

This is the code on my test results page- both variables are populated.

window.cpAPIInterface.setVariableValue("LMSscore", SCORM_CallLMSGetValue("cmi.core.score.raw"));

if (LMSscore>=LMSpass) {

    window.cpAPIInterface.next();

} else {

    {alert("Hi you have failed the test. Please retake. If you need technical help please contact ....");

}

160
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 28, 2017 Nov 28, 2017
LATEST

Your code doesn't really make any sense since you are setting a value (LMSscore) with the value of cmi.core.score.raw. If cmi.core.score raw is set, then the values would always be the same. If you know that you need 80 to pass, then all you need to do is:

var getScore = Number(SCORM_CallLMSGetValue("cmi.core.score.raw"));//ensure the result is a number

if(getScore>=80)

{

     window.cpAPIInterface.next();

}

else

{

     alert("Hi you have failed the test. Please retake. If you need technical help please contact ....");

}

By the way, you have a curly brace before the alert in your code which would break it anyway.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources