<commit_before>function LevelViewCtrl(
  $stateParams, LevelService, LevelHintService
) {
  var vm = this;

  vm.level = {};

  vm.validate = validate;
  vm.buyHint = buyHint;

  init();

  /** Retrieve level info along side level instances */
  function init() {
    LevelService.getLevel($stateParams.id).then(function(level) {
      vm.level = level;

      LevelHintService.getHintsForLevel(vm.level).then(function(hints) {
        vm.level.hints = hints;
      });
    });

    LevelService.getLevelInstances({
      where: {
        level: $stateParams.id
      }
    }).then(function(instances) {
      vm.level.instances = instances;
    });


  }

  /** Validate level with passphrase and validation message */
  function validate(validation) {
    console.log(validation);
    vm.level.validated = true;
  }

  function buyHint(hint) {
    return LevelHintService.buyHintForLevel(hint, vm.level);
  }

}

angular
  .module('portal.levels')
  .controller('LevelViewCtrl', LevelViewCtrl);<commit_msg>Adding submitting validation in level view<commit_after>function LevelViewCtrl(
  $stateParams, LevelService, LevelHintService
) {
  var vm = this;

  vm.level = {};

  vm.validate = validate;
  vm.buyHint = buyHint;

  init();

  /** Retrieve level info along side level instances */
  function init() {
    LevelService.getLevel($stateParams.id).then(function(level) {
      vm.level = level;

      LevelHintService.getHintsForLevel(vm.level).then(function(hints) {
        vm.level.hints = hints;
      });
    });

    LevelService.getLevelInstances({
      where: {
        level: $stateParams.id
      }
    }).then(function(instances) {
      vm.level.instances = instances;
    });


  }

  /** Validate level with passphrase and validation message */
  function validate(validation) {
    LevelValidationService.validateOrganizationLevel(validation, vm.orgLevel)
      .then(function(data) {
        console.log('TODO: Notification that level is pending validation');
      });

    vm.level.validated = true; //switch to orgLevel
  }

  function buyHint(hint) {
    return LevelHintService.buyHintForLevel(hint, vm.level);
  }

}

angular
  .module('portal.levels')
  .controller('LevelViewCtrl', LevelViewCtrl);
{'fraction_non_alphanumeric': 0.12460779919318692, 'fraction_numerical': 0.0, 'mean_word_length': 3.1954887218045114, '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': '3486565', 'n_tokens_mistral': 694, 'n_tokens_neox': 665, 'n_words': 130}