Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
курc.docx
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
606.17 Кб
Скачать

If(checkNullUndefined(groupId))

{

this.GroupModel.deleteGroup(

{groupId},

() => this.render()

);

}

};

this.createGroup = () =>

{

var inputsBox = document.getElementById('createGroup').querySelectorAll('input, select'),

allSpecialityKeys = this.GroupModel.getAllSpecialityKeysArr(),

groupInfo = {},

groupObj = {};

groupInfo = this.groupBoxGetInputParams(inputsBox, allSpecialityKeys);

groupObj = groupInfo.data;

If(!groupInfo.CheckError)

{

this.GroupModel.createGroup(

groupObj,

() => this.render()

);

}

};

this.editGroup = () =>

{

var inputsBox = document.getElementById('editGroup').querySelectorAll('input, select'),

allSpecialityKeys = this.GroupModel.getAllSpecialityKeysArr(),

groupId = parseInt(document.getElementById('editGroup').getAttribute('data-groupid')),

groupInfo = {},

groupObj = {};

groupInfo = this.groupBoxGetInputParams(inputsBox, allSpecialityKeys);

groupObj = groupInfo.data;

If(!groupInfo.CheckError)

{

groupObj.groupId = groupId;

this.GroupModel.editGroup(

groupObj,

() => this.render()

);

}

};

this.exchangeGroupStudents = () =>

{

var exchangeGroupBox = document.getElementById('exchangeGroup'),

groupId = parseInt(exchangeGroupBox.getAttribute('data-groupid')),

newGroupId = parseInt(exchangeGroupBox.getElementsByTagName('select')[0].value);

If(checkNullUndefined(groupId) && checkNullUndefined(newGroupId))

{

this.GroupModel.exchangeGroupStudents(

{groupId, newGroupId},

() =>

{

this.StudentModel.replaceGroupStudents(groupId, newGroupId);

this.render();

}

);

}

};

this.emptyGroup = () =>

{

var groupId = parseInt(document.getElementById('emptyGroup').getAttribute('data-groupid'));

If(checkNullUndefined(groupId))

{

this.GroupModel.emptyGroup(

{groupId},

() =>

{

this.StudentModel.replaceGroupStudents(groupId, null);

this.render();

}

);

}

};

}

/assets/js/controllers/StudentController.js

function StudentController({GroupModel, StudentModel}, View)

{

this.View = View;

this.GroupModel = GroupModel;

this.StudentModel = StudentModel;

this.showAllStudents= () =>

{

var allStudents = this.StudentModel.getAllStudents(),

allGroups = this.GroupModel.getAllGroupsArr();

this.View.renderStudentTable(allStudents, allGroups);

};

this.showCreateStudentBox = () =>

{

var allGroupsArr = this.GroupModel.getAllGroupsArr();

this.View.renderCreateStudentBox(allGroupsArr);

};

this.showStudentInfo = (studentRow) =>

{

var studentId = parseInt(studentRow.getAttribute('data-studentid')),

student = {};