Start a new topic

Javascript Questions

Where can I find documentation on using Javascript in Kotobee Author?  Especially things like detecting clicks on images (used as buttons) and other input methods.


Jason


1 person has this question

Well the only section that discusses Javascript is here: http://support.kotobee.com/support/solutions/articles/8000026740-adding-custom-interactivity


Since the ebook chapters are HTML based, they can take any javascript functions you like (as well as HTML and CSS). So it's a very wide scope for us to cover in our documentation. You can refer to w3schools.com for functions to detect image clicks, etc.


This help article may be useful for you as a starting step to use Javascript in Kotobee Author: 

https://www.kotobee.com/blog/create-dynamic-character-names-ebook/

hi


I have a similar issue with questions but more complicated I suppose

I want to ask: can I handle questions by ID? I mean what if I will have capture result of the test and display it on my own faction.



In this case Tymoteusz, you can build your own question component (it's simple javascript really). You're not obliged to use ours. Even if you use ours, you can attach a javascript event listener to the Submit button, and that was will be able to query through the questions to know the user's answer to each. Does it make sense?


hi


yes, it makes sense. I want to use your mechanism cause I have a lot of questions and those questions will be written by a person not familiar with java at all.

Can you explain how to "attach a javascript event listener to the Submit button" in your mechanism?

Sure. I've attached a sample for you. Basically, the function would look like this:


function forceSubmit(){
  var elems = document.getElementsByClassName("exam");
  if(elems.length){
    var btns = elems[0].getElementsByClassName("ki-mcq");
    if(btns.length)
      btns[0].click();
  }
  return false;
}


Good luck!


1 person likes this

hi


thanks for this example but can I find a description of automatic questions builder implemented in Kotabee to call it by my own functions?


The sample I have already attached shows you how to call your own functions, which will trigger the Kotobee question component to submit. Did you download and open the KPUB2?


1 person likes this

hi

yes but did names used in the script are permanent or just for this sample?

eg Class Name "exam" or Class Name "ki-mcq"

are there any other useful class names in question building module?

ki-mcq is permanenet (you will not need to change it). However, "exam" is dynamic, and it depends on the class name that you have given your question component. The screenshow below will clarify:



You do not need to do anything else but change "exam" to the class name of your specific question component.

Login or Signup to post a comment