<commit_before>'use strict';

/* @ngInject */
function QuizEasyCtrl($scope, $routeParams, ResourceFactory, $location) {
  $scope.resourceId = $routeParams.resourceId;
  ResourceFactory.getResource($routeParams.resourceId).then(function (resource) {
    $scope.resource = resource;
    $scope.quizzes = [{
      'number': '1',
      'question': 'foo question',
      'answers': [
        'Answer 1', 'Answer 2', 'Answer 3'
      ],
      'answer': ''
    }, {
      'number': '2',
      'question': 'foo question',
      'answers': [
        'Answer 1', 'Answer 2', 'Answer 3'
      ],
      'answer': ''
    }];
  });
  $scope.pendingAnswers = function () {
    var pending = true;
    $scope.quizzes.forEach(function (quiz) {
      pending = pending && quiz.answer.length;
    });
    return !pending;
  };
  $scope.submit = function () {
    console.log('foo');
    $location.url('resource-win/' + $scope.resourceId);
  };
}

angular.module('hackyRacesApp')
  .controller('QuizEasyCtrl', QuizEasyCtrl);<commit_msg>Easy quiz will go to the fail page if you get questions wrong. Easy quiz gets the easy question from Firebase<commit_after>'use strict';

/* @ngInject */
function QuizEasyCtrl($scope, $routeParams, ResourceFactory, $location) {
  $scope.resourceId = $routeParams.resourceId;
  ResourceFactory.getResource($routeParams.resourceId).then(function (resource) {
    $scope.resource = resource;
    $scope.quizzes = [
		resource.questions.easy
	,
	{
      'question': 'foo question',
      'answers': [
        'Answer 1', 'Answer 2', 'Answer 3'
      ],
      'answer': ''
    }, {
      'question': 'foo question',
      'answers': [
        'Answer 1', 'Answer 2', 'Answer 3'
      ],
      'answer': ''
    }];
  });
  $scope.pendingAnswers = function () {
    var pending = true;
    $scope.quizzes.forEach(function (quiz) {
      pending = pending && quiz.answer.length;
    });
    return !pending;
  };
  $scope.submit = function () {
	var allAnswersCorrect = true;
    $scope.quizzes.forEach(function (quiz) {
		var thisAnswerCorrect = (quiz.correctAnswer === 1) || (quiz.answer === "Answer 1");
		allAnswersCorrect = allAnswersCorrect && thisAnswerCorrect;
	});
	if (allAnswersCorrect) {
		console.log("win!");
		$location.url('resource-win/' + $scope.resourceId);
	} else {
		console.log("loes");
		$location.url('resource-fail/' + $scope.resourceId);
	}
  };
}

angular.module('hackyRacesApp')
  .controller('QuizEasyCtrl', QuizEasyCtrl);
{'fraction_non_alphanumeric': 0.16951219512195123, 'fraction_numerical': 0.0065040650406504065, 'mean_word_length': 3.2285223367697595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4809366', 'n_tokens_mistral': 858, 'n_tokens_neox': 793, 'n_words': 159}