<commit_before>(function () {
  'use strict';

  angular
    .module('examsessions.admin')
    .controller('ExamSessionsAdminController', ExamSessionsAdminController);

  ExamSessionsAdminController.$inject = ['$scope', '$state', 'examsessionResolve', '$window', 'Authentication', 'Notification'];

  function ExamSessionsAdminController($scope, $state, examsession, $window, Authentication, Notification) {
    var vm = this;

    vm.examsession = examsession;
    vm.examsessionname = examsession.name;
    vm.authentication = Authentication;
    vm.error = null;
    vm.form = {};
    vm.remove = remove;
    vm.save = save;

    // Convert start and end dates to Date objects
    vm.examsession.start = vm.examsession.start ? new Date(vm.examsession.start) : null;
    vm.examsession.end = vm.examsession.end ? new Date(vm.examsession.end) : null;

    // Remove existing exam session
    function remove() {
      if ($window.confirm('Are you sure you want to delete this exam session?')) {
        vm.examsession.$remove(onSuccess, onError);
      }

      function onSuccess(examsession) {
        $state.go('admin.manage.examsessions.list');
        Notification.success({ message: '<i class="glyphicon glyphicon-exclamation-sign"></i> Exam session deleted successfully!' });
      }

      function onError(errorResponse) {
        var error = errorResponse.data;
        Notification.error({ message: '<i class="glyphicon glyphicon-exclamation-sign"></i> ' + error.message });
      }
    }

    // Save exam session
    function save(isValid) {
      if (!isValid) {
        $scope.$broadcast('show-errors-check-validity', 'vm.form.examsessionForm');
        return false;
      }

      // Create a new exam session, or update the current instance
      vm.examsession.createOrUpdate()
        .then(successCallback)
        .catch(errorCallback);

      function successCallback(res) {
        // Clear form fields
        vm.examsession.name = '';
        vm.examsession.description = '';
        vm.examsession.start = null;
        vm.examsession.end = null;

        $state.go('admin.manage.examsessions.view', {
          examsessionId: res._id
        });
      }

      function errorCallback(res) {
        vm.error = res.data.message;
      }
    }
  }
}());
<commit_msg>Modules(examsessions): Add notification message upon successful deletion<commit_after>(function () {
  'use strict';

  angular
    .module('examsessions.admin')
    .controller('ExamSessionsAdminController', ExamSessionsAdminController);

  ExamSessionsAdminController.$inject = ['$scope', '$state', 'examsessionResolve', '$window', 'Authentication', 'Notification'];

  function ExamSessionsAdminController($scope, $state, examsession, $window, Authentication, Notification) {
    var vm = this;

    vm.examsession = examsession;
    vm.examsessionname = examsession.name;
    vm.authentication = Authentication;
    vm.error = null;
    vm.form = {};
    vm.remove = remove;
    vm.save = save;

    // Convert start and end dates to Date objects
    vm.examsession.start = vm.examsession.start ? new Date(vm.examsession.start) : null;
    vm.examsession.end = vm.examsession.end ? new Date(vm.examsession.end) : null;

    // Remove existing exam session
    function remove() {
      if ($window.confirm('Are you sure you want to delete this exam session?')) {
        vm.examsession.$remove(onSuccess, onError);
      }

      function onSuccess(examsession) {
        $state.go('admin.manage.examsessions.list');
        Notification.success({ message: '<i class="glyphicon glyphicon-exclamation-sign"></i> ' + $filter('translate')('EXAMSESSION.SUCCESSFUL_DELETE') });
      }

      function onError(errorResponse) {
        var error = errorResponse.data;
        Notification.error({ message: '<i class="glyphicon glyphicon-exclamation-sign"></i> ' + error.message });
      }
    }

    // Save exam session
    function save(isValid) {
      if (!isValid) {
        $scope.$broadcast('show-errors-check-validity', 'vm.form.examsessionForm');
        return false;
      }

      // Create a new exam session, or update the current instance
      vm.examsession.createOrUpdate()
        .then(successCallback)
        .catch(errorCallback);

      function successCallback(res) {
        // Clear form fields
        vm.examsession.name = '';
        vm.examsession.description = '';
        vm.examsession.start = null;
        vm.examsession.end = null;

        $state.go('admin.manage.examsessions.view', {
          examsessionId: res._id
        });
      }

      function errorCallback(res) {
        vm.error = res.data.message;
      }
    }
  }
}());

{'fraction_non_alphanumeric': 0.12963359760017143, 'fraction_numerical': 0.0, 'mean_word_length': 2.861042183622829, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5220418', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1342, 'n_words': 281}