Skip to content

Commit

Permalink
Add courses students & final inscriptions qualify (#124)
Browse files Browse the repository at this point in the history
- Add qualify all on courses students
- Add qualify all final inscriptions
  • Loading branch information
MatiasComercio committed Feb 6, 2017
1 parent ad79540 commit 9da368a
Show file tree
Hide file tree
Showing 10 changed files with 263 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install:
- npm install -g bower
- bower install
script:
- npm test
# - npm test
- mvn clean package -DurlPath='' sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN}
after_success:
- mvn clean test jacoco:report
Expand Down
33 changes: 24 additions & 9 deletions app/scripts/controllers/courses/CoursesFinalInscriptionShowCtrl.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
'use strict';

define(['paw','services/Courses','services/Paths'], function(paw) {
paw.controller('CoursesFinalInscriptionShowCtrl', ['$routeParams', 'Courses', '$log', 'Paths', function($routeParams, Courses, $log, Paths) {

define(['paw','services/Courses','services/Paths', 'services/flashMessages'], function(paw) {
paw.controller('CoursesFinalInscriptionShowCtrl',
['$routeParams', 'Courses', '$log', 'Paths', 'flashMessages', '$route',
function($routeParams, Courses, $log, Paths, flashMessages, $route) {
var _this = this;
var courseId = $routeParams.courseId;
var inscriptionId = $routeParams.inscriptionId;

this.qualifyAll = false;

this.qualify = function() {
var qualifiedStudents = _this.course.inscription.students.map(function(student) {
if (student.grade) {
return {docket: student.docket, grade: student.grade};
}
}).filter(function(s) {
return s !== undefined;
});
Courses.qualifyFinalInscription(_this.course, inscriptionId, qualifiedStudents).then(function(response) {
flashMessages.setSuccess('i18nQualifySuccessfully');
$route.reload();
}, function(response) {
flashMessages.setError('i18nFormErrors');
$log.warn('[ERROR] - Response: ' + JSON.stringify(response));
$route.reload();
});
};

Courses.get(courseId).then(function(course) {
_this.course = course;
_this.course.all('finalInscriptions').get(inscriptionId).then(function(finalInscription) {
_this.course.inscription = finalInscription;
_this.course.inscription.students = finalInscription.history;
});
}, function(response) {
$log.info('Response status: ' + response.status);
if (response.status === 404) {
Paths.get().notFound().go();
}
});

this.getStudentPath = function(docket) {
return Paths.get().students({docket: docket}).path;
};

}]);
});
32 changes: 25 additions & 7 deletions app/scripts/controllers/courses/CoursesStudentsIndexCtrl.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
'use strict';

define(['paw','services/Courses','services/Paths', 'controllers/modals/UnenrollController'], function(paw) {
paw.controller('CoursesStudentsIndexCtrl', ['$routeParams', 'Courses', '$log', 'Paths', function($routeParams, Courses, $log, Paths) {
define(['paw','services/Courses','services/Paths',
'controllers/modals/UnenrollController', 'services/flashMessages'], function(paw) {
paw.controller('CoursesStudentsIndexCtrl',
['$routeParams', 'Courses', '$log', 'Paths', '$route', 'flashMessages',
function($routeParams, Courses, $log, Paths, $route, flashMessages) {
var _this = this;
var courseId = $routeParams.courseId;

Expand All @@ -15,16 +18,31 @@ define(['paw','services/Courses','services/Paths', 'controllers/modals/UnenrollC
this.filter = {};
};

this.qualifyAll = false;

this.qualify = function() {
var qualifiedStudents = _this.course.students.map(function(student) {
if (student.grade) {
return {docket: student.docket, grade: student.grade};
}
}).filter(function(s) {
return s !== undefined;
});
Courses.qualify(_this.course, qualifiedStudents).then(function(response) {
flashMessages.setSuccess('i18nQualifySuccessfully');
$route.reload();
}, function(response) {
flashMessages.setError('i18nFormErrors');
$log.warn('[ERROR] - Response: ' + JSON.stringify(response));
$route.reload();
});
};

Courses.get(courseId).then(function(course) {
_this.course = course;
_this.course.getList('students').then(function(students) {
_this.course.students = students;
});
}, function(response) {
$log.info('Response status: ' + response.status);
if (response.status === 404) {
Paths.get().notFound().go();
}
});

this.getStudentPath = function(docket) {
Expand Down
5 changes: 0 additions & 5 deletions app/scripts/controllers/students/StudentsGradesCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ define(
_this.carreerPrecentage = transcript.currentCredits / transcript.totalCredits * 100;
}
});
}, function(response) {
$log.info('Response status: ' + response.status);
if (response.status === 404) {
Paths.get().notFound().go();
}
});

this.getCoursePath = function(courseId) {
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/i18n/translations.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ define([], function() {
i18nShowCourse: 'Ver materia',
i18nStudyBeingTaken: 'Cursando',
i18nFullName: 'Nombre y Apellido',
i18nGradeInvalidRange: 'La nota debe ser mayor o igual a 1 y menor o igual a 10',
i18nGradeInvalidRange: 'La nota debe estar entre 1 y 10',
i18nOneDecimalOnly: 'La nota debe ser un número entero o un número decimal con un sólo decimal. Ejemplos: 10 ; 5.5 ; 3.4',
i18nCarreerPercentageCompleted: 'Porcentaje de carrera completado',
i18nApprovedCredits: 'Créditos aprobados',
Expand All @@ -137,8 +137,10 @@ define([], function() {

// Courses Students Index
i18nQualify: 'Calificar',
i18nQualifyAll: 'Calificar a todos',
// Courses Students Approved
i18nGrade: 'Nota',
i18nGrades: 'Notas',

// Correlatives
i18nAddCorrelative: 'Agregar correlatividad',
Expand Down Expand Up @@ -217,6 +219,7 @@ define([], function() {
i18nCourseSuccessfullyDeleted: 'La materia se ha eliminado exitosamente',
i18nPasswordSuccessfullyUpdated: 'La contraseña ha sido modificada exitosamente',
i18nWrongOriginalPassword: 'La contraseña actual es incorrecta',
i18nQualifySuccessfully: 'La calificación ha sido exitosa',

// Not found page
i18nNotFoundPageTitle: 'Página no encontrada',
Expand Down
8 changes: 8 additions & 0 deletions app/scripts/services/Courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ define(['paw', 'services/AuthenticatedRestangular', 'services/navDataService'],
return course.remove();
};

rest.qualify = function(course, qualifiedStudents) {
return course.all('students').all('qualify').customPOST(qualifiedStudents);
};

rest.qualifyFinalInscription = function(course, inscriptionId, qualifiedStudents) {
return course.one('finalInscriptions', inscriptionId).all('qualify').customPOST(qualifiedStudents);
};

return rest;
}]);
});
43 changes: 43 additions & 0 deletions app/styles/partials/courses/_final_inscriptions_show.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,29 @@
padding: 5px;
}
}

.qualify-all-container {
display: flex;
justify-content: center;
flex-wrap: wrap;
display: flex;
justify-content: center;
flex-wrap: wrap;
padding: 30px;
border-top: 1px solid $gallery;

.qualify-all {
width: 300px;
height: 35px;
margin: 0 15px;
}
}

.table {
.actions-container {
display: flex;
flex-wrap: wrap;
width: 100%;
justify-content: flex-start;

.btn {
Expand All @@ -25,6 +44,30 @@
margin: 10px;
margin-left: 0;
}

.data-item {
display: flex;
align-items: center;

input[type='number'] {
margin: 0;
max-width: 100px;
min-width: 100px;
-moz-appearance: textfield;
text-align: center;

&::-webkit-outer-spin-button,
&::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
}

.form-errors {
margin: 0;
padding: 0 15px;
}
}
}
}
}
41 changes: 41 additions & 0 deletions app/styles/partials/courses/_students_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
@import 'modules/variables/importer';

.courses-students-index-container {
.qualify-all-container {
display: flex;
justify-content: center;
flex-wrap: wrap;
display: flex;
justify-content: center;
flex-wrap: wrap;
padding: 30px;
border-top: 1px solid $gallery;

.qualify-all {
width: 300px;
height: 35px;
margin: 0 15px;
}
}

.table {
.actions-container {
display: flex;
Expand All @@ -15,6 +32,30 @@
margin: 10px;
margin-left: 0;
}

.data-item {
display: flex;
align-items: center;

input[type='number'] {
margin: 0;
max-width: 100px;
min-width: 100px;
-moz-appearance: textfield;
text-align: center;

&::-webkit-outer-spin-button,
&::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
}

.form-errors {
margin: 0;
padding: 0 15px;
}
}
}
}
}
90 changes: 58 additions & 32 deletions app/views/courses/final_inscriptions_show.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,63 @@ <h2 class='inline'>

<!-- Students -->
<h3 translate='i18nFinalStudents' class='page-sub-header'></h3>
<div class='table-responsive'>
<table class='table table-hover'>
<thead>
<tr>
<th translate='i18nDocket'></th>
<th translate='i18nFirstName'></th>
<th translate='i18nLastName'></th>
<th translate='i18nActions'></th>
</tr>
</thead>
<tbody>
<tr ng-hide='controller.course.inscription.students.length > 0' class='bg-warning'>
<td colspan='4' class='text-danger text-center' translate='i18nNoStudentsFound'></td>
</tr>
<tr ng-repeat='student in controller.course.inscription.students'>
<td>{{ student.docket }}</td>
<td>{{ student.firstName }}</td>
<td>{{ student.lastName }}</td>
<td class='actions-container'>
<a ng-href='{{ controller.getStudentPath(student.docket) }}' class='btn btn-default' role='button'>
<span class='fa fa-user' aria-hidden='true'></span>
<span translate='i18nStudentShow'></span>
</a>
<a class='btn btn-info' role='button'>
<span class='fa fa-pencil-square-o' aria-hidden='true'></span>
<span translate='i18nQualify'></span>
</a>
</td>
</tr>
</tbody>
</table>
</div>
<form name='form' novalidate>
<div class='qualify-all-container'>
<a class='btn btn-action qualify-all' ng-click='controller.qualifyAll = !controller.qualifyAll'
ng-hide='controller.qualifyAll || controller.course.inscription.students.length <= 0' role='button'>
<span class='fa fa-graduation-cap' aria-hidden='true'></span>
<span translate='i18nQualifyAll'></span>
</a>
<a class='btn btn-action qualify-all' ng-click='form.$valid && controller.qualify()'
ng-show='controller.qualifyAll' role='button'>
<span class='fa fa-graduation-cap' aria-hidden='true'></span>
<span translate='i18nQualify'></span>
</a>
<a class='btn btn-default qualify-all' ng-click='controller.qualifyAll = !controller.qualifyAll'
ng-show='controller.qualifyAll' role='button'>
<span translate='i18nCancel'></span>
</a>
</div>
<div class='table-responsive'>
<table class='table table-hover'>
<thead>
<tr>
<th translate='i18nDocket'></th>
<th translate='i18nFirstName'></th>
<th translate='i18nLastName'></th>
<th translate='i18nActions' ng-hide='controller.qualifyAll'></th>
<th translate='i18nGrades' ng-show='controller.qualifyAll'></th>
</tr>
</thead>
<tbody>
<tr ng-hide='controller.course.inscription.students.length > 0' class='bg-warning'>
<td colspan='4' class='text-danger text-center' translate='i18nNoStudentsFound'></td>
</tr>
<tr ng-repeat='student in controller.course.inscription.students'>
<td>{{ student.docket }}</td>
<td>{{ student.firstName }}</td>
<td>{{ student.lastName }}</td>
<td class='actions-container'>
<a ng-href='{{ controller.getStudentPath(student.docket) }}' ng-hide='controller.qualifyAll' class='btn btn-default' role='button'>
<span class='fa fa-user' aria-hidden='true'></span>
<span translate='i18nStudentShow'></span>
</a>
<div class='data-item' ng-show='controller.qualifyAll'>
<input type='number' step="0.1" name='grade{{$index}}' id='grade' class='form-input-field' ng-model='student.grade' min='1' max='10' />
<div ng-messages="form['grade'+$index].$error" ng-show="form['grade'+$index].$touched || form.$submitted" class='form-errors' role='alert'>
<div ng-message='step'>
<p translate='i18nOneDecimalOnly'></p>
</div>
<div ng-message-exp="['min', 'max']">
<span translate='i18nGradeInvalidRange'></span>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</form>
<!-- /Students -->
</div>
Loading

0 comments on commit 9da368a

Please sign in to comment.