Lectora Tips #2: Replacing Feedback Commas

How many times have you ran into the issue of unreadable multiple choice feedback returned in Lectora because of the default commas and no spaces? Indeed, CSV is great for computers, but humans are not computers. WELL…not until 2045, anyway. The LHT Group gets this question all the time because it is the Lectora default.

When you show the user the answers from a multiple choice question the feedback looks like this:
feedback 1,feedback 2,feedback 3

We really want something more readable for the end user, like this:
feedback 1 – feedback 2 – feedback 3

Use these 3 STEPS to replace commas in your Lectora eLearning courses:

STEP 1: Click Add an External HTML Object on the page that displays your question feedback. Here we are revising the displayed answers for Question 12, so we’ll call ours “Remove Commas Q12.” For Object Type choose “Bottom of file scripting.”

 

 

 

 

 

 

 

STEP 2: Insert the code under Custom HTML:

<script language=”JavaScript”>
function formatAnswer() {
var nameArray = new Array();
var str = VarQuestion_0012.getValue();
str = str.replace(“,”, ” – “);
text39673.actionChangeContents(str,’alignleft’,’1′);
}
var t=setTimeout(formatAnswer,2000);
</script>
However, this question has multiple commas separating answers. So, replace this code: str = str.replace(“,”, ” – “); With this code: str = str.replace(/,/g, ” – “);
  • STEP 3: You will need to change VarQuestion_0012 AND text39673 to match your question and text variables. You can find them in the properties sections of the text field.

That’s it! Simple, right? Now you should be able to replace the commas in the Lectora feedback for your eLearning courses.

 

Leave a Reply