Documentation

Scoring

Each custom module can be treated as an activity. To be an activity, the addon has to implement three methods:

  • getScore
  • getErrorCount
  • getMaxScore

First, let's add this question to the addon's view:

Color of the grass is  
<select class="sample-question-select">  
  <option value="red">red</option>  
  <option value="green">green</option>  
  <option value="blue">blue</option>  
  </select>

Scoring methods can look as follows:

presenter.getMaxScore = function () {  
    return 1;  
};  

presenter.getScore = function () {  
    var greenOption = presenter.$view.find('.sample-question-select option[value=green]'),  
      isGreenOptionSelected = greenOption.attr('selected');  

    return isGreenOptionSelected ? 1 : 0;  
};  

presenter.getErrorCount = function () {  
    return presenter.getMaxScore() - presenter.getScore();  
};