js/qa-generator.js
/**
     * Generates alternative for a question
     * @method generateAlternatives
     * @param  {Object}             question
     */
Generates alternative for a question
@method generateAlternatives
@param  {Object}             question
Generates alternative for a question @method generateAlternatives @param { Object } question
function generateAlternatives(question, EquationType, useFractions, maxValue) {
      question.alternatives = [];
      var equation = undefined;
      while (question.alternatives.length !== 5) {
        equation = generateEquation(question.variable, EquationType, useFractions)
        var alternative = equation.toString();
        var solution = equation.solveFor(question.variable).toString();
        if (solution !== question.correct && question.alternatives.indexOf(solution) === -1) {
          question.alternatives.push(solution);
        }
      }
      question.alternatives.push(question.correct);
      question.alternatives = H5P.shuffleArray(question.alternatives);
    }
function generateAlternatives ( question , EquationType , useFractions , maxValue ) { question . alternatives = [ ] ; var equation = undefined ; while ( question . alternatives . length !== 5 ) { equation = generateEquation ( question . variable , EquationType , useFractions ) var alternative = equation . toString ( ) ; var solution = equation . solveFor ( question . variable ) . toString ( ) ; if ( solution !== question . correct && question . alternatives . indexOf ( solution ) === - 1 ) { question . alternatives . push ( solution ) ; } } question . alternatives . push ( question . correct ) ; question . alternatives = H5P . shuffleArray ( question . alternatives ) ; }
Generates alternative for a question
 @method generateAlternatives
 @param  {Object}             question
Generates alternative for a question @method generateAlternatives @param { Object } question
// Generate 5 wrong ones: // check if alternative is present already and is not the correct one // Add correct one // Shuffle alternatives: