<commit_before>var index = 0;
var formContainer = document.getElementById("formContainer");
var form = document.form1;

var prevButton = document.getElementById("prevButton");
var nextButton = document.getElementById("nextButton");
var scoreButton = document.getElementById("scoreButton");

var storedAnswers = [];

var allQuestions = [
  {
    question: "Who is Prime Minister of the United Kingdom?",
    choices: ["<NAME>", "<NAME>", "<NAME>", "<NAME>"],
    correctAnswer:0
  },
  {
    question: "Who is Prime Minister of the Netherlands?",
    choices: ["<NAME>", "<NAME>", "<NAME>", "<NAME>"],
    correctAnswer:1
  },
  {
    question: "In which city does the Dutch government reside?",
    choices: ["Rotterdam", "Amsterdam", "The Hague", "Utrecht"],
    correctAnswer:2
  }
];
var quizLength = allQuestions.length;

function showQuestion() {
  if(index == 0) {
    prevButton.style.display = "none";
  }
  if (index > 0) {
    prevButton.style.display = "inline";
  }
  if(index == quizLength) {
    scoreButton.style.display = "inline";
    nextButton.style.display = "none";
    form.innerHTML = "";
    return;
  }
  else {
    nextButton.style.display = "inline";
    scoreButton.style.display = "none";
  //  $("#nextButton").css("display", "inline");
  //  $("#score").css("display", "none");
  }

  var choices = allQuestions[index].choices;
  var storedAnswer = storedAnswers[index];
  var id;
  var quizItem = allQuestions[index];
  var q = document.createElement("h3");
  var text = document.createTextNode(quizItem.question);

  q.appendChild(text);
  form.appendChild(q);

  if (storedAnswer) {
    id = storedAnswer.id;
  }

  for (var i = 0; i < choices.length; i++) {
    var p = document.createElement("p");
    p.setAttribute("class", "answer");

    var input = document.createElement("input");
    input.setAttribute("id", i);
    input.setAttribute("type", "radio");
    input.setAttribute("name", "question");

    if (i == quizItem.correctAnswer) {
      input.setAttribute("value", "1");
    } else {
      input.setAttribute("value", "0");
    }

    if (i == id) {
      input.setAttribute("checked", "checked");
    }

    input.onclick = function(e) {
      var element = e.target;
      var answer = {
        id: element.id,
        value: element.value
      };
      storedAnswers.push(answer);
    }

    var label = document.createElement("label");
    var choice = document.createTextNode(choices[i]);
    label.appendChild(choice);

    p.appendChild(input);
    p.appendChild(label);
    form.appendChild(p);
  }
}
// http://jsfiddle.net/hvG7k/
function previousQuestion() {
  form.innerHTML = "";
  $("#form1").fadeOut(0, function() {
    index--;
    var show = showQuestion(index);
    $(this).attr('innerHTML', 'show').fadeIn(700);
  });
}

function nextQuestion() {
  if (storedAnswers[index] == null) {
    alert("Please choose an answer!");
    return;
  }
  else  {
    form.innerHTML = "";
    $("#form1").fadeOut(0, function() {
      index++;
      var show = showQuestion(index);
      $(this).attr('innerHTML', 'show').fadeIn(700);
    });
  }
}

function showScore() {
  prevButton.style.display = "none";
  scoreButton.style.display = "none";
  var totalScore = 0;
  for (var i = 0; i < storedAnswers.length; i++) {
    var score = parseInt(storedAnswers[i].value);
    totalScore += score;
  }

  var result = document.getElementById("result");
  var finalScore = document.getElementById("score");
  var leng = allQuestions.length
  if (score >= leng - 1) {
    result.innerHTML = "Great! Your score is " + totalScore + "!";
  }
  if (score <= 1) {
    result.innerHTML = "Not into politics are you? Your score is " + totalScore + "!";
  }
  else {
    result.innerHTML = "Well that's not too bad! Your score is " + totalScore + "!";
  }
  
  //finalScore.innerHTML = "Your score is " + totalScore;
}

prevButton.addEventListener("click", previousQuestion);
nextButton.addEventListener("click", nextQuestion);
scoreButton.addEventListener("click", showScore);

showQuestion();<commit_msg>error fixed in main.js<commit_after>var index = 0;
var formContainer = document.getElementById("formContainer");
var form = document.form1;

var prevButton = document.getElementById("prevButton");
var nextButton = document.getElementById("nextButton");
var scoreButton = document.getElementById("scoreButton");

var storedAnswers = [];

var allQuestions = [
  {
    question: "Who is Prime Minister of the United Kingdom?",
    choices: ["<NAME>", "<NAME>", "<NAME>", "<NAME>"],
    correctAnswer:0
  },
  {
    question: "Who is Prime Minister of the Netherlands?",
    choices: ["<NAME>", "<NAME>", "<NAME>", "<NAME>"],
    correctAnswer:1
  },
  {
    question: "In which city does the Dutch government reside?",
    choices: ["Rotterdam", "Amsterdam", "The Hague", "Utrecht"],
    correctAnswer:2
  }
];
var quizLength = allQuestions.length;

function showQuestion() {
  if(index == 0) {
    prevButton.style.display = "none";
  }
  if (index > 0) {
    prevButton.style.display = "inline";
  }
  if(index == quizLength) {
    scoreButton.style.display = "inline";
    nextButton.style.display = "none";
    form.innerHTML = "";
    return;
  }
  else {
    nextButton.style.display = "inline";
    scoreButton.style.display = "none";
  //  $("#nextButton").css("display", "inline");
  //  $("#score").css("display", "none");
  }

  var choices = allQuestions[index].choices;
  var storedAnswer = storedAnswers[index];
  var id;
  var quizItem = allQuestions[index];
  var q = document.createElement("h3");
  var text = document.createTextNode(quizItem.question);

  q.appendChild(text);
  form.appendChild(q);

  if (storedAnswer) {
    id = storedAnswer.id;
  }

  for (var i = 0; i < choices.length; i++) {
    var p = document.createElement("p");
    p.setAttribute("class", "answer");

    var input = document.createElement("input");
    input.setAttribute("id", i);
    input.setAttribute("type", "radio");
    input.setAttribute("name", "question");

    if (i == quizItem.correctAnswer) {
      input.setAttribute("value", "1");
    } else {
      input.setAttribute("value", "0");
    }

    if (i == id) {
      input.setAttribute("checked", "checked");
    }

    input.onclick = function(e) {
      var element = e.target;
      var answer = {
        id: element.id,
        value: element.value
      };
      storedAnswers.push(answer);
    }

    var label = document.createElement("label");
    var choice = document.createTextNode(choices[i]);
    label.appendChild(choice);

    p.appendChild(input);
    p.appendChild(label);
    form.appendChild(p);
  }
}
// http://jsfiddle.net/hvG7k/
function previousQuestion() {
  form.innerHTML = "";
  $("#form1").fadeOut(0, function() {
    index--;
    var show = showQuestion(index);
    $(this).attr('innerHTML', 'show').fadeIn(700);
  });
}

function nextQuestion() {
  if (storedAnswers[index] == null) {
    alert("Please choose an answer!");
    return;
  }
  else  {
    form.innerHTML = "";
    $("#form1").fadeOut(0, function() {
      index++;
      var show = showQuestion(index);
      $(this).attr('innerHTML', 'show').fadeIn(700);
    });
  }
}

function showScore() {
  prevButton.style.display = "none";
  scoreButton.style.display = "none";
  var totalScore = 0;
  for (var i = 0; i < storedAnswers.length; i++) {
    var score = parseInt(storedAnswers[i].value);
    totalScore += score;
  }

  var result = document.getElementById("result");
  var finalScore = document.getElementById("score");
  
  if (totalScore == allQuestions.length) {
    result.innerHTML = "Great! Your score is " + totalScore + "!";
  }
  else if (totalScore <= 1) {
    result.innerHTML = "Not into politics are you? Your score is " + totalScore + "!";
  }
  else {
    result.innerHTML = "Well that's not too bad! Your score is " + totalScore + "!";
  }

  //finalScore.innerHTML = "Your score is " + totalScore;
}

prevButton.addEventListener("click", previousQuestion);
nextButton.addEventListener("click", nextQuestion);
scoreButton.addEventListener("click", showScore);

showQuestion();
{'fraction_non_alphanumeric': 0.1679624830309762, 'fraction_numerical': 0.006293965198074787, 'mean_word_length': 3.4674751929437706, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '282244', 'n_tokens_mistral': 2583, 'n_tokens_neox': 2494, 'n_words': 569}