Skip to main content
garyc56322630
Known Participant
May 5, 2017
Question

How to create a question button with custom score

  • May 5, 2017
  • 0 replies
  • 360 views

Hi,

 

Lately I have been trying to create custom quizzes to deliver customer features.

I had a huge inspiration from another post by Steven Warwick by the use of intensive javascript. 

I have succeeded to calculate a custom score on a slide based on some inputs (selected / Not selected).

I trigger then an hidden question button and use the combination of undocumented functions : 

var quizObject= cp.getQuestionObject(QuestionButton);

cp.SubmitInteractions(QuestionButton,  cp.QuestionStatusEnum.CORRECT, 0) for score > 0

OR 

cp.SubmitInteractions(QuestionButton,  cp.QuestionStatusEnum.WRONG, 0) for score = 0

 

It works fine but I can get any partial score working using : cp.SubmitInteractions(QuestionButton,  cp.QuestionStatusEnum.PARTIAL_CORRECT, 0)

I know this is not documented but has anyboby already played with the QuizObject question to manage interactions and partial score?

 

Code EXAMPLE :

theAnswers = { 

 "Question_1" : "Selected",

 "Question_2" : "Normal",

 "Question_13" : "Selected",

 "Question_14" : "Normal"

 }

 

Poids = { 

 "Question_1" : 10,

 "Question_2" : 10,

"Question_13" : 10,

 "Question_14" : 10

 }

var QuestionButton = "ShapeQuestion";

/*******************************************************/

var score = 0;

for ( Shape in theAnswers) 

{

  rightAnswer = theAnswers[Shape];

  theState = cp.getCurrentStateNameForSlideItem(Shape);

  console.log('---- question Info -----');

  console.log('Status ='+theState);

 

  if (theState == rightAnswer)

  { 

    console.log('Status ='+theState);

    console.log('Good Answer : add '+Poids[Shape]);

    score = score + Poids[Shape];

    console.log('Score ='+score);

  }

 else

 {

    console.log('Wrong Answer');

 }

}

 

var quizObject= cp.getQuestionObject(QuestionButton);

 

if (score == 0) {

quizObject.score = 0;

cp.SubmitInteractions(QuestionButton,  cp.QuestionStatusEnum.WRONG, 0);

}

else

{

quizObject.score = score;

cp.SubmitInteractions(QuestionButton,  cp.QuestionStatusEnum.PARTIAL_CORRECT, 0);

}

console.log('Score Final ='+score);

cpCmndNextSlide = 1;

 

Any thoughts?

    This topic has been closed for replies.