Add the xls student load, student list and removal by course
This commit is contained in:
@@ -15,17 +15,7 @@
|
|||||||
|
|
||||||
sections.query(
|
sections.query(
|
||||||
function (successResult){
|
function (successResult){
|
||||||
vm.matricula = successResult;
|
vm.section = successResult;
|
||||||
angular.forEach(vm.matricula, function (value){
|
|
||||||
matriculaArray.push({
|
|
||||||
section:value.section,
|
|
||||||
code:value.code,
|
|
||||||
course:value.course,
|
|
||||||
semester:value.semester,
|
|
||||||
student: value.student
|
|
||||||
});
|
|
||||||
});
|
|
||||||
vm.listaMatricula = matriculaArray;
|
|
||||||
},
|
},
|
||||||
function (){
|
function (){
|
||||||
console.log("Error al obtener los datos.");
|
console.log("Error al obtener los datos.");
|
||||||
@@ -65,9 +55,9 @@
|
|||||||
$rootScope.otroBotonOk = true;
|
$rootScope.otroBotonOk = true;
|
||||||
$rootScope.botonCancelar = false;
|
$rootScope.botonCancelar = false;
|
||||||
$rootScope.urlLo = 'listarMatricula';
|
$rootScope.urlLo = 'listarMatricula';
|
||||||
var name = vm.matricula[index].section;
|
var name = vm.section[index].name;
|
||||||
|
|
||||||
sections.delete({ id: vm.matricula[index]._id },
|
sections.delete({ id: vm.section[index]._id },
|
||||||
function () {
|
function () {
|
||||||
$rootScope.rsplice = true;
|
$rootScope.rsplice = true;
|
||||||
$rootScope.mensaje = "Sección " + name + " eliminada";
|
$rootScope.mensaje = "Sección " + name + " eliminada";
|
||||||
@@ -79,7 +69,7 @@
|
|||||||
|
|
||||||
vm.eliminarMatriculaSplice = function (index, rsplice) {
|
vm.eliminarMatriculaSplice = function (index, rsplice) {
|
||||||
if(rsplice){
|
if(rsplice){
|
||||||
vm.listaMatricula.splice(index, 1);
|
vm.section.splice(index, 1);
|
||||||
$rootScope.rsplice = false;
|
$rootScope.rsplice = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -88,11 +78,12 @@
|
|||||||
|
|
||||||
|
|
||||||
vm.modificarMatricula = function (index) {
|
vm.modificarMatricula = function (index) {
|
||||||
matriculaSeleccionada.Nombre = vm.matricula[index].Nombre;
|
matriculaSeleccionada._id = vm.section[index]._id;
|
||||||
matriculaSeleccionada.Codigo = vm.matricula[index].Codigo;
|
matriculaSeleccionada.name = vm.section[index].name;
|
||||||
matriculaSeleccionada.Materia = vm.matricula[index].Materia;
|
matriculaSeleccionada.code = vm.section[index].code;
|
||||||
matriculaSeleccionada.Semestre = vm.matricula[index].Semestre;
|
matriculaSeleccionada.course = vm.section[index].course;
|
||||||
matriculaSeleccionada.Estudiantes= vm.matricula[index].Estudiantes;
|
matriculaSeleccionada.semester = vm.section[index].semester;
|
||||||
|
matriculaSeleccionada.students = vm.section[index].students;
|
||||||
$location.url('actualizarMatricula');
|
$location.url('actualizarMatricula');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -121,7 +112,9 @@
|
|||||||
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
vm.submitted = false;
|
vm.submitted = false;
|
||||||
|
vm.semester, vm.section, vm.materias;
|
||||||
$rootScope.mensaje = "";
|
$rootScope.mensaje = "";
|
||||||
|
vm.students = [];
|
||||||
|
|
||||||
courses.query(
|
courses.query(
|
||||||
function (successResult) {
|
function (successResult) {
|
||||||
@@ -134,13 +127,12 @@
|
|||||||
vm.submit = function () {
|
vm.submit = function () {
|
||||||
|
|
||||||
if (vm.data_input_form.$valid){
|
if (vm.data_input_form.$valid){
|
||||||
vm.section = {
|
vm.package = {
|
||||||
|
"name": vm.name,
|
||||||
"section": vm.matricula.Nombre,
|
"code": vm.valorMateria.code,
|
||||||
"code": vm.valorMateria.Codigo,
|
"course": vm.valorMateria.name,
|
||||||
"course": vm.valorMateria.Nombre,
|
"semester": vm.semester,
|
||||||
"semester": vm.matricula.Semestre,
|
"students": vm.students
|
||||||
"students": vm.matricula.Estudiantes,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.modalInstance = $modal.open({
|
$scope.modalInstance = $modal.open({
|
||||||
@@ -155,16 +147,16 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sections.save(vm.section,
|
sections.save(vm.package,
|
||||||
function(){
|
function(){
|
||||||
$rootScope.botonOk = true;
|
$rootScope.botonOk = true;
|
||||||
$rootScope.urlLo = 'listarMatricula';
|
$rootScope.urlLo = 'listarMatricula';
|
||||||
$rootScope.mensaje = "Sección " + vm.matricula.Nombre + " creada";
|
$rootScope.mensaje = "Sección " + vm.name + " creada";
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
$rootScope.botonOk = true;
|
$rootScope.botonOk = true;
|
||||||
$rootScope.urlLo = 'listarMatricula';
|
$rootScope.urlLo = 'listarMatricula';
|
||||||
$rootScope.mensaje = "Error creando la seccion " + vm.matricula.Nombre;
|
$rootScope.mensaje = "Error creando la seccion " + vm.name;
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
vm.submitted = true;
|
vm.submitted = true;
|
||||||
@@ -173,37 +165,44 @@
|
|||||||
|
|
||||||
var xlf = document.getElementById('xlf');
|
var xlf = document.getElementById('xlf');
|
||||||
function handleFile(e) {
|
function handleFile(e) {
|
||||||
console.log("DO SOME STUFF");
|
|
||||||
/*rABS = document.getElementsByName("userabs")[0].checked;
|
|
||||||
use_worker = document.getElementsByName("useworker")[0].checked;
|
|
||||||
var files = e.target.files;
|
var files = e.target.files;
|
||||||
var f = files[0];
|
var i,f,z;
|
||||||
{
|
var student = {};
|
||||||
|
for (i = 0, f = files[i]; i != files.length; ++i) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
var name = f.name;
|
var name = f.name;
|
||||||
reader.onload = function(e) {
|
reader.onload = function(e) {
|
||||||
if(typeof console !== 'undefined') console.log("onload", new Date(), rABS, use_worker);
|
|
||||||
var data = e.target.result;
|
var data = e.target.result;
|
||||||
if(use_worker) {
|
var workbook = XLSX.read(data, {type: 'binary'});
|
||||||
xw(data, process_wb);
|
var sheet = workbook.SheetNames[0];
|
||||||
} else {
|
var worksheet = workbook.Sheets[sheet];
|
||||||
var wb;
|
|
||||||
if(rABS) {
|
|
||||||
wb = X.read(data, {type: 'binary'});
|
|
||||||
} else {
|
|
||||||
var arr = fixdata(data);
|
|
||||||
wb = X.read(btoa(arr), {type: 'base64'});
|
|
||||||
}
|
|
||||||
process_wb(wb);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if(rABS) reader.readAsBinaryString(f);
|
|
||||||
else reader.readAsArrayBuffer(f);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
vm.cargarEstudiantes = function () {
|
|
||||||
|
|
||||||
|
/* Find desired cell containing semester and section */
|
||||||
|
vm.semester = worksheet['B5'].v;
|
||||||
|
vm.name = worksheet['B9'].v;
|
||||||
|
$scope.$apply();
|
||||||
|
|
||||||
|
for (z in worksheet) {
|
||||||
|
/* all keys that do not begin with "!" correspond to cell addresses */
|
||||||
|
if (z[0] === '!') continue;
|
||||||
|
if ((z[0] >'B') && (z[1] > 0) && (z[2] > 1)) {
|
||||||
|
/* Cells that start in the C column represent the sttudent id in the worksheet, the same applies to name and lastname being in D and E columns*/
|
||||||
|
if (z[0] =='C') student.id = worksheet[z].v;
|
||||||
|
if (z[0] =='D') student.name = worksheet[z].v;
|
||||||
|
if (z[0] =='E') {
|
||||||
|
student.lastname = worksheet[z].v;
|
||||||
|
/*Since we are only going to use these 3 attributes from the students then we push only this data to the students array*/
|
||||||
|
vm.students.push(student);
|
||||||
|
student = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
reader.readAsBinaryString(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(xlf.addEventListener) xlf.addEventListener('change', handleFile, false);
|
||||||
|
|
||||||
$scope.ok = function (urlLo) {
|
$scope.ok = function (urlLo) {
|
||||||
$location.url(urlLo);
|
$location.url(urlLo);
|
||||||
@@ -224,27 +223,12 @@
|
|||||||
function actualizarMatriculaCtrl($scope, $rootScope, $location, sections, $modal, matriculaSeleccionada){
|
function actualizarMatriculaCtrl($scope, $rootScope, $location, sections, $modal, matriculaSeleccionada){
|
||||||
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
vm.lista = true;
|
vm.section = matriculaSeleccionada;
|
||||||
$rootScope.loading = true;
|
vm.students = matriculaSeleccionada.students;
|
||||||
$rootScope.table = false;
|
|
||||||
vm.matricula = matriculaSeleccionada;
|
|
||||||
vm.listaEstudiantes = vm.matricula.Estudiantes;
|
|
||||||
|
|
||||||
|
|
||||||
vm.actualizarMatricula = function() {
|
vm.actualizarMatricula = function() {
|
||||||
sections.update(section,
|
|
||||||
function(){
|
|
||||||
$rootScope.botonOk = true;
|
|
||||||
$rootScope.botonCancelar = false;
|
|
||||||
$rootScope.urlLo = 'listarMatricula';
|
|
||||||
$rootScope.mensaje = "Sección actualizada";
|
|
||||||
},
|
|
||||||
function(){
|
|
||||||
$rootScope.botonOk = true;
|
|
||||||
$rootScope.botonCancelar = false;
|
|
||||||
$rootScope.urlLo = 'listarMatricula';
|
|
||||||
$rootScope.mensaje = "Error al actualizar la Sección ";
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.retirarEstudianteModal = function (index) {
|
vm.retirarEstudianteModal = function (index) {
|
||||||
@@ -256,7 +240,7 @@
|
|||||||
|
|
||||||
$rootScope.rsplice = false;
|
$rootScope.rsplice = false;
|
||||||
$rootScope.eliminarLoading = false;
|
$rootScope.eliminarLoading = false;
|
||||||
$rootScope.mensaje = "¿Desea retirar este estudiante de la Sección?";
|
$rootScope.mensaje = "¿Desea retirar al estudiante "+ vm.students[index].lastname +", "+ vm.students[index].name + "?";
|
||||||
|
|
||||||
$scope.modalInstance = $modal.open({
|
$scope.modalInstance = $modal.open({
|
||||||
animation: $rootScope.animationsEnabled,
|
animation: $rootScope.animationsEnabled,
|
||||||
@@ -272,24 +256,36 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
vm.retirarEstudiante = function (index) {
|
vm.retirarEstudiante = function (index) {
|
||||||
$rootScope.botonOk = false;
|
$rootScope.rsplice = true;
|
||||||
$rootScope.otroBotonOk = true;
|
|
||||||
$rootScope.botonCancelar = false;
|
|
||||||
$rootScope.urlLo = 'actualizarMatricula';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.retirarEstudianteSplice = function(index, rsplice) {
|
vm.retirarEstudianteSplice = function(index, rsplice) {
|
||||||
if (rsplice) {
|
if (rsplice) {
|
||||||
vm.listaEstudiantes.splice(index, 1);
|
vm.students.splice(index, 1);
|
||||||
$rootScope.rsplice = false;
|
$rootScope.rsplice = false;
|
||||||
|
|
||||||
var section = {
|
vm.section = {
|
||||||
'section': vm.matricula.Nombre,
|
"_id": vm.section._id,
|
||||||
'code': vm.matricula.Codigo,
|
"name": vm.section.name,
|
||||||
'course': vm.matricula.Seccion,
|
"code": vm.section.code,
|
||||||
'semester': vm.matricula.Semestre,
|
"course": vm.section.name,
|
||||||
'students': vm.listaEstudiantes
|
"semester": vm.section.semester,
|
||||||
|
"students": vm.students
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sections.update(vm.section,
|
||||||
|
function (){
|
||||||
|
$rootScope.botonOk = false;
|
||||||
|
$rootScope.otroBotonOk = true;
|
||||||
|
$rootScope.botonCancelar = false;
|
||||||
|
$rootScope.mensaje = "Sección "+ vm.section.name +" actualizada";
|
||||||
|
},
|
||||||
|
function (){
|
||||||
|
$rootScope.botonOk = false;
|
||||||
|
$rootScope.otroBotonOk = true;
|
||||||
|
$rootScope.botonCancelar = false;
|
||||||
|
$rootScope.mensaje = "Error al actualizar la Sección "+ vm.section.name;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -299,8 +295,7 @@
|
|||||||
$rootScope.opened = true;
|
$rootScope.opened = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.ok = function (urlLo) {
|
$scope.ok = function () {
|
||||||
$location.url(urlLo);
|
|
||||||
$scope.modalInstance.dismiss('cancel');
|
$scope.modalInstance.dismiss('cancel');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -20,13 +20,13 @@
|
|||||||
<label for="codigo">Codigo de la Materia</label>
|
<label for="codigo">Codigo de la Materia</label>
|
||||||
<input type="text" class="form-control"
|
<input type="text" class="form-control"
|
||||||
name="codigo" readonly="readonly"
|
name="codigo" readonly="readonly"
|
||||||
ng-model="vm.valorMateria.code"/>
|
ng-model="vm.valorMateria.code" required/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4 column">
|
<div class="col-md-4 column">
|
||||||
<label for="semestre">Semestre</label>
|
<label for="semestre">Semestre</label>
|
||||||
<input type="text" class="form-control"
|
<input type="text" class="form-control"
|
||||||
name="semestre"
|
name="semestre" readonly="readonly"
|
||||||
ng-model="vm.matricula.Semestre" required/>
|
ng-model="vm.semester" required/>
|
||||||
<div class="error" ng-show="vm.submitted &&
|
<div class="error" ng-show="vm.submitted &&
|
||||||
vm.data_input_form.semestre.$invalid">
|
vm.data_input_form.semestre.$invalid">
|
||||||
<small class="error"
|
<small class="error"
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
<div class="col-md-4 column">
|
<div class="col-md-4 column">
|
||||||
<label for="seccion">Sección</label>
|
<label for="seccion">Sección</label>
|
||||||
<input type="text" class="form-control"
|
<input type="text" class="form-control"
|
||||||
name="seccion" ng-model="vm.matricula.Nombre"
|
name="seccion" readonly="readonly" ng-model="vm.name"
|
||||||
required/>
|
required/>
|
||||||
<div class="error" ng-show="vm.submitted &&
|
<div class="error" ng-show="vm.submitted &&
|
||||||
vm.data_input_form.seccion.$invalid">
|
vm.data_input_form.seccion.$invalid">
|
||||||
|
@@ -5,11 +5,11 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="20%">
|
<th width="20%">
|
||||||
<a href="" ng-click="sortType = 'section';
|
<a href="" ng-click="sortType = 'name';
|
||||||
sortReverse = !sortReverse">
|
sortReverse = !sortReverse">
|
||||||
Sección
|
Sección
|
||||||
<span ng-show="sortType == 'section' && !sortReverse" class="fa fa-caret-down"></span>
|
<span ng-show="sortType == 'name' && !sortReverse" class="fa fa-caret-down"></span>
|
||||||
<span ng-show="sortType == 'section' && sortReverse" class="fa fa-caret-up"></span>
|
<span ng-show="sortType == 'name' && sortReverse" class="fa fa-caret-up"></span>
|
||||||
</a>
|
</a>
|
||||||
</th>
|
</th>
|
||||||
<th width="20%">
|
<th width="20%">
|
||||||
@@ -44,11 +44,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="matricula in vm.listaMatricula | orderBy:sortType:sortReverse | filter:searchUser">
|
<tr ng-repeat = "section in vm.section | orderBy:sortType:sortReverse | filter:searchUser">
|
||||||
<td style="vertical-align:middle">{{ matricula.section }}</td>
|
<td style="vertical-align:middle">{{ section.name }}</td>
|
||||||
<td style="vertical-align:middle">{{ matricula.course }}</td>
|
<td style="vertical-align:middle">{{ section.course }}</td>
|
||||||
<td style="vertical-align:middle">{{ matricula.code }}</td>
|
<td style="vertical-align:middle">{{ section.code }}</td>
|
||||||
<td style="vertical-align:middle">{{ matricula.semester }}</td>
|
<td style="vertical-align:middle">{{ section.semester }}</td>
|
||||||
<td style="text-align: center">
|
<td style="text-align: center">
|
||||||
<span title="Click aqui para Modificar la Matricula"
|
<span title="Click aqui para Modificar la Matricula"
|
||||||
class="glyphicon glyphicon-edit" aria-hidden="true"
|
class="glyphicon glyphicon-edit" aria-hidden="true"
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
<button class="btn btn-primary" ng-show="botonOk" type="button"
|
<button class="btn btn-primary" ng-show="botonOk" type="button"
|
||||||
ng-click="vm.retirarEstudiante(index)">OK</button>
|
ng-click="vm.retirarEstudiante(index)">OK</button>
|
||||||
<button class="btn btn-primary" ng-show="otroBotonOk" type="button"
|
<button class="btn btn-primary" ng-show="otroBotonOk" type="button"
|
||||||
ng-click="ok(urlLo)">Aceptar</button>
|
ng-click="ok()">Aceptar</button>
|
||||||
<button class="btn btn-warning" ng-show="botonCancelar" type="button"
|
<button class="btn btn-warning" ng-show="botonCancelar" type="button"
|
||||||
ng-click="cancel()">Cancelar</button>
|
ng-click="cancel()">Cancelar</button>
|
||||||
</div>
|
</div>
|
@@ -1,29 +1,29 @@
|
|||||||
<div class="row clearfix">
|
<div class="row clearfix">
|
||||||
<h4>Estudiantes Inscritos en {{ vm.matricula.Nombre }} - Seccion {{ vm.matricula.Seccion }} - Semestre {{ vm.matricula.Semestre }}</h4>
|
<h4>Estudiantes Inscritos en {{ vm.section.course }} - Seccion {{ vm.section.name }} - Semestre {{ vm.section.semester }}</h4>
|
||||||
<br>
|
<br>
|
||||||
<div>
|
<div>
|
||||||
<table class="table table-bordered table-striped">
|
<table class="table table-bordered table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th width="20%">
|
<th width="20%">
|
||||||
<a href="" ng-click="sortType = 'Cedula'; sortReverse = !sortReverse">
|
<a href="" ng-click="sortType = 'id'; sortReverse = !sortReverse">
|
||||||
Cedula
|
Cedula
|
||||||
<span ng-show="sortType == 'Cedula' && !sortReverse" class="fa fa-caret-down"></span>
|
<span ng-show="sortType == 'id' && !sortReverse" class="fa fa-caret-down"></span>
|
||||||
<span ng-show="sortType == 'Cedula' && sortReverse" class="fa fa-caret-up"></span>
|
<span ng-show="sortType == 'id' && sortReverse" class="fa fa-caret-up"></span>
|
||||||
</a>
|
</a>
|
||||||
</th>
|
</th>
|
||||||
<th width="20%">
|
<th width="20%">
|
||||||
<a href="" ng-click="sortType = 'Nombre'; sortReverse = !sortReverse">
|
<a href="" ng-click="sortType = 'name'; sortReverse = !sortReverse">
|
||||||
Nombre
|
Nombre
|
||||||
<span ng-show="sortType == 'Nombre' && !sortReverse" class="fa fa-caret-down"></span>
|
<span ng-show="sortType == 'name' && !sortReverse" class="fa fa-caret-down"></span>
|
||||||
<span ng-show="sortType == 'Nombre' && sortReverse" class="fa fa-caret-up"></span>
|
<span ng-show="sortType == 'name' && sortReverse" class="fa fa-caret-up"></span>
|
||||||
</a>
|
</a>
|
||||||
</th>
|
</th>
|
||||||
<th width="20%">
|
<th width="20%">
|
||||||
<a href="" ng-click="sortType = 'Apellido'; sortReverse = !sortReverse">
|
<a href="" ng-click="sortType = 'lastname'; sortReverse = !sortReverse">
|
||||||
Apellido
|
Apellido
|
||||||
<span ng-show="sortType == 'Apellido' && !sortReverse" class="fa fa-caret-down"></span>
|
<span ng-show="sortType == 'lastname' && !sortReverse" class="fa fa-caret-down"></span>
|
||||||
<span ng-show="sortType == 'Apellido' && sortReverse" class="fa fa-caret-up"></span>
|
<span ng-show="sortType == 'lastname' && sortReverse" class="fa fa-caret-up"></span>
|
||||||
</a>
|
</a>
|
||||||
</th>
|
</th>
|
||||||
<th width="20%" style="text-align: center">
|
<th width="20%" style="text-align: center">
|
||||||
@@ -32,10 +32,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="estudiante in vm.listaEstudiantes | orderBy:sortType:sortReverse | filter:searchUser">
|
<tr ng-repeat="student in vm.students | orderBy:sortType:sortReverse | filter:searchUser">
|
||||||
<td style="vertical-align:middle">{{ estudiante.Cedula }}</td>
|
<td style="vertical-align:middle">{{ student.id }}</td>
|
||||||
<td style="vertical-align:middle">{{ estudiante.Nombre }}</td>
|
<td style="vertical-align:middle">{{ student.name }}</td>
|
||||||
<td style="vertical-align:middle">{{ estudiante.Apellido }}</td>
|
<td style="vertical-align:middle">{{ student.lastname }}</td>
|
||||||
<td style="text-align: center">
|
<td style="text-align: center">
|
||||||
<span title="Click aqui para Eliminar un Estudiante"
|
<span title="Click aqui para Eliminar un Estudiante"
|
||||||
class="glyphicon glyphicon-remove" aria-hidden="true"
|
class="glyphicon glyphicon-remove" aria-hidden="true"
|
||||||
|
Reference in New Issue
Block a user