function ask_init_question(anwser) {
  var q_container = document.getElementById('question');
  q_container.innerHTML = 'Pre-Q: Do you see a ' + pre_question_arr[pre_q_index] + '?';
  display_img('q_img', 'image/question/' + pre_question_arr[pre_q_index] + '.jpg');
  //When anw is fals, change it to null in array
  if (anwser == 0) {
    pre_question_arr[pre_q_index - 1] = null;
  }
  pre_q_index++;
  //When all init questions are asked
  if (pre_q_index == 4) {
    var q_groupe_num = 0;
    for (q_group of pre_question_arr) {
      if (q_group != null) {
        q_groupe_num++;
      }
    }

    // When too little features are observed
    if (q_groupe_num < 2) {
      pre_q_index = 0;
      pre_question_arr = ['flower', 'fruit', 'leaf'];

      // Display alert
      swal({
        title: 'Try again',
        text:
          'To obtain an accurate result, \
          please make sure the plant has at two of the following features: flower, fruit, and leaf.',
        icon: 'warning',
        button: 'Ok'
      });

      //Ask the pre qustions again
      ask_init_question(-1);
    } else {
      q_container.innerHTML =
        'Now loading...<br>It might take a while to get your first question (less than a minute).';
      document.getElementById('yes_button').style.display = 'none';
      document.getElementById('no_button').style.display = 'none';
      display_img('q_img', 'image/icon/loading.gif');
      //When at leat on group of attributes is missing, remove them from table
      if (q_groupe_num == 2) {
        skip_col_arr = get_skip_cols(pre_question_arr);
      }

      // Interactive decisson tree startss
      setTimeout(function() {
        //Start with the top hirachy (order)
        find_best_questions(3);
      }, 1000);

      document.getElementById('yes_button').setAttribute('onclick', "ask_question('1')");
      document.getElementById('no_button').setAttribute('onclick', "ask_question('0')");
    }
  }
}
// Ask user preliminary questions to get the attributes that will be used

Ask user preliminary questions to get the attributes that will be used
Ask user preliminary questions to get the attributes that will be used
function ask_init_question(anwser) {
  var q_container = document.getElementById('question');
  q_container.innerHTML = 'Pre-Q: Do you see a ' + pre_question_arr[pre_q_index] + '?';
  display_img('q_img', 'image/question/' + pre_question_arr[pre_q_index] + '.jpg');
  if (anwser == 0) {
    pre_question_arr[pre_q_index - 1] = null;
  }
  pre_q_index++;
  if (pre_q_index == 4) {
    var q_groupe_num = 0;
    for (q_group of pre_question_arr) {
      if (q_group != null) {
        q_groupe_num++;
      }
    }
    if (q_groupe_num < 2) {
      pre_q_index = 0;
      pre_question_arr = ['flower', 'fruit', 'leaf'];
      swal({
        title: 'Try again',
        text:
          'To obtain an accurate result, \
          please make sure the plant has at two of the following features: flower, fruit, and leaf.',
        icon: 'warning',
        button: 'Ok'
      });
      ask_init_question(-1);
    } else {
      q_container.innerHTML =
        'Now loading...<br>It might take a while to get your first question (less than a minute).';
      document.getElementById('yes_button').style.display = 'none';
      document.getElementById('no_button').style.display = 'none';
      display_img('q_img', 'image/icon/loading.gif');
      if (q_groupe_num == 2) {
        skip_col_arr = get_skip_cols(pre_question_arr);
      }
      setTimeout(function() {
        find_best_questions(3);
      }, 1000);
      document.getElementById('yes_button').setAttribute('onclick', "ask_question('1')");
      document.getElementById('no_button').setAttribute('onclick', "ask_question('0')");
    }
  }
}
function ask_init_question ( anwser ) { var q_container = document . getElementById ( 'question' ) ; q_container . innerHTML = 'Pre-Q: Do you see a ' + pre_question_arr [ pre_q_index ] + '?' ; display_img ( 'q_img' , 'image/question/' + pre_question_arr [ pre_q_index ] + '.jpg' ) ; if ( anwser == 0 ) { pre_question_arr [ pre_q_index - 1 ] = null ; } pre_q_index ++ ; if ( pre_q_index == 4 ) { var q_groupe_num = 0 ; for ( q_group of pre_question_arr ) { if ( q_group != null ) { q_groupe_num ++ ; } } if ( q_groupe_num < 2 ) { pre_q_index = 0 ; pre_question_arr = [ 'flower' , 'fruit' , 'leaf' ] ; swal ( { title : 'Try again' , text : 'To obtain an accurate result, \
          please make sure the plant has at two of the following features: flower, fruit, and leaf.' , icon : 'warning' , button : 'Ok' } ) ; ask_init_question ( - 1 ) ; } else { q_container . innerHTML = 'Now loading...<br>It might take a while to get your first question (less than a minute).' ; document . getElementById ( 'yes_button' ) . style . display = 'none' ; document . getElementById ( 'no_button' ) . style . display = 'none' ; display_img ( 'q_img' , 'image/icon/loading.gif' ) ; if ( q_groupe_num == 2 ) { skip_col_arr = get_skip_cols ( pre_question_arr ) ; } setTimeout ( function ( ) { find_best_questions ( 3 ) ; } , 1000 ) ; document . getElementById ( 'yes_button' ) . setAttribute ( 'onclick' , "ask_question('1')" ) ; document . getElementById ( 'no_button' ) . setAttribute ( 'onclick' , "ask_question('0')" ) ; } } }
Ask user preliminary questions to get the attributes that will be used
Ask user preliminary questions to get the attributes that will be used
//When anw is fals, change it to null in array
 //When all init questions are asked
 // When too little features are observed
 // Display alert
 //Ask the pre qustions again
 //When at leat on group of attributes is missing, remove them from table
 // Interactive decisson tree startss
 //Start with the top hirachy (order)
