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

  angular
    .module('exams.admin')
    .controller('ExamsAdminController', ExamsAdminController);

  ExamsAdminController.$inject = ['$scope', '$state', '$http', 'examResolve', '$window', 'Authentication', 'Notification', '$filter', 'Upload'];

  function ExamsAdminController($scope, $state, $http, exam, $window, Authentication, Notification, $filter, Upload) {
    var vm = this;

    vm.exam = exam;
    vm.examtitle = exam.title;
    vm.authentication = Authentication;
    vm.error = null;
    vm.form = {};
    vm.remove = remove;
    vm.save = save;

    // Auto-completion for tags-input
    vm.students = null;
    vm.rooms = null;
    vm.loadCourses = loadCourses;
    vm.loadExamSessions = loadExamSessions;
    vm.isFormReady = isFormReady;

    // Students management
    vm.addStudent = addStudent;
    vm.removeStudent = removeStudent;

    // Rooms management
    vm.getLetter = getLetter;
    vm.addRoom = addRoom;
    vm.removeRoom = removeRoom;

    // Copies management
    var nbCopies = vm.exam.copies.length;
    vm.uploading = Array.apply(null, new Array(nbCopies)).map(function(x, i) { return false; });
    vm.progressValue = Array.apply(null, new Array(nbCopies)).map(function(x, i) { return null; });
    vm.addCopy = addCopy;
    vm.removeCopy = removeCopy;
    vm.uploadCopy = uploadCopy;

    var examId = exam._id;

    // The course and exam session must be a list for the tags-input
    if (vm.exam.course) {
      vm.exam.course = [vm.exam.course];
    }
    if (vm.exam.examsession) {
      vm.exam.examsession = [vm.exam.examsession];
    }

    var tagsInputListsLoaded = [false, false];

    // Load the list of courses for the tags-input
    var coursesList = [];
    $http.get('/api/courses').success(function(data, status, headers, config) {
      coursesList = data;
      tagsInputListsLoaded[0] = true;
    });

    // Load the list of exam sessions for the tags-input
    var examsessionsList = [];
    $http.get('/api/examsessions').success(function(data, status, headers, config) {
      examsessionsList = data;
      tagsInputListsLoaded[1] = true;
    });

    // Load the list of students for the registrations
    $http.get('/api/students').success(function(data, status, headers, config) {
      vm.students = data;
    });

    // Load the list of rooms for the rooms
    $http.get('/api/rooms').success(function(data, status, headers, config) {
      vm.rooms = data;

      // Remove already selected rooms
      vm.exam.rooms.forEach(function (element) {
        var code = element.code;
        vm.rooms.splice(vm.rooms.findIndex(function (element) {
          return element.code === code;
        }), 1);
      });
    });

    // Convert date to Date object
    vm.exam.date = vm.exam.date ? new Date(vm.exam.date) : null;

    // Remove existing exam
    function remove() {
      if ($window.confirm('Are you sure you want to delete this exam?')) {
        vm.exam.$remove({ examId: exam._id }, onSuccess, onError);
      }
<commit_msg>Modules(exams): Remove already registered students from auto-completion<commit_after>(function () {
  'use strict';

  angular
    .module('exams.admin')
    .controller('ExamsAdminController', ExamsAdminController);

  ExamsAdminController.$inject = ['$scope', '$state', '$http', 'examResolve', '$window', 'Authentication', 'Notification', '$filter', 'Upload'];

  function ExamsAdminController($scope, $state, $http, exam, $window, Authentication, Notification, $filter, Upload) {
    var vm = this;

    vm.exam = exam;
    vm.examtitle = exam.title;
    vm.authentication = Authentication;
    vm.error = null;
    vm.form = {};
    vm.remove = remove;
    vm.save = save;

    // Auto-completion for tags-input
    vm.students = null;
    vm.rooms = null;
    vm.loadCourses = loadCourses;
    vm.loadExamSessions = loadExamSessions;
    vm.isFormReady = isFormReady;

    // Students management
    vm.addStudent = addStudent;
    vm.removeStudent = removeStudent;

    // Rooms management
    vm.getLetter = getLetter;
    vm.addRoom = addRoom;
    vm.removeRoom = removeRoom;

    // Copies management
    var nbCopies = vm.exam.copies.length;
    vm.uploading = Array.apply(null, new Array(nbCopies)).map(function(x, i) { return false; });
    vm.progressValue = Array.apply(null, new Array(nbCopies)).map(function(x, i) { return null; });
    vm.addCopy = addCopy;
    vm.removeCopy = removeCopy;
    vm.uploadCopy = uploadCopy;

    var examId = exam._id;

    // The course and exam session must be a list for the tags-input
    if (vm.exam.course) {
      vm.exam.course = [vm.exam.course];
    }
    if (vm.exam.examsession) {
      vm.exam.examsession = [vm.exam.examsession];
    }

    var tagsInputListsLoaded = [false, false];

    // Load the list of courses for the tags-input
    var coursesList = [];
    $http.get('/api/courses').success(function(data, status, headers, config) {
      coursesList = data;
      tagsInputListsLoaded[0] = true;
    });

    // Load the list of exam sessions for the tags-input
    var examsessionsList = [];
    $http.get('/api/examsessions').success(function(data, status, headers, config) {
      examsessionsList = data;
      tagsInputListsLoaded[1] = true;
    });

    // Load the list of students for the registrations
    $http.get('/api/students').success(function(data, status, headers, config) {
      vm.students = data;

      // Remove already selected students
      vm.exam.registrations.forEach(function (element) {
        var username = element.username;
        vm.students.splice(vm.students.findIndex(function (element) {
          return element.username === username;
        }), 1);
      });
    });

    // Load the list of rooms for the rooms
    $http.get('/api/rooms').success(function(data, status, headers, config) {
      vm.rooms = data;

      // Remove already selected rooms
      vm.exam.rooms.forEach(function (element) {
        var code = element.code;
        vm.rooms.splice(vm.rooms.findIndex(function (element) {
          return element.code === code;
        }), 1);
      });
    });

    // Convert date to Date object
    vm.exam.date = vm.exam.date ? new Date(vm.exam.date) : null;

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

{'fraction_non_alphanumeric': 0.1359615086139997, 'fraction_numerical': 0.0010864504112990843, 'mean_word_length': 2.826603325415677, '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': '2496593', 'n_tokens_mistral': 2030, 'n_tokens_neox': 1977, 'n_words': 485}