diff --git a/src/libs/convert/educationLevelShort.js b/src/libs/convert/educationLevelShort.js new file mode 100644 index 0000000000000000000000000000000000000000..3d543ee98690179952ab97b3b9a9ad6056741a3f --- /dev/null +++ b/src/libs/convert/educationLevelShort.js @@ -0,0 +1,20 @@ +module.exports = function educationLevelShort(id) { + switch (id) { + case 1: + return 'Creche'; + case 2: + return 'Pré-Escola'; + case 3: + return 'Ensino Fundamental - anos iniciais'; + case 4: + return 'Ensino Fundamental - anos finais'; + case 5: + return 'Ensino Médio'; + case 6: + return 'EJA'; + case 7: + return 'EE exclusiva'; + default: + return 'Não classificado'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index be74c3c2bbe0823c93e859c4979a4165bedf7de2..9304758c47e84a553e37f6c0f9d644addb785208 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -10,6 +10,7 @@ const agreement = require(`${libs}/convert/agreement`); const booleanVariable = require(`${libs}/convert/booleanVariable`); const educationLevel = require(`${libs}/convert/educationLevel`); const educationLevelMod = require(`${libs}/convert/educationLevelMod`); +const educationLevelShort = require(`${libs}/convert/educationLevelShort`); const educationType = require(`${libs}/convert/educationType`); const ids = { @@ -18,6 +19,7 @@ const ids = { school_year_id: schoolYear, education_level_id: educationLevel, education_level_mod_id: educationLevelMod, + education_level_short_id: educationLevelShort, adm_dependency_id: admDependency, adm_dependency_detailed_id: admDependency, location_id: location, diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index 7238959e28ea3789a877cb73960f6d6d485fb12b..eabd957844c7be03439ec498c4312d8bee8f1e47 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -88,6 +88,20 @@ classApp.get('/education_level_mod', (req, res, next) => { next(); }, query, response('education_level_mod')); +classApp.get('/education_level_short', (req, res, next) => { + req.result = [ + {id: null, name: 'Não Classificado'}, + {id: 1, name: 'Creche'}, + {id: 2, name: 'Pré-Escola'}, + {id: 3, name: 'Ensino Fundamental - anos iniciais'}, + {id: 4, name: 'Ensino Fundamental - anos finais'}, + {id: 5, name: 'Ensino Médio'}, + {id: 6, name: 'EJA'}, + {id: 7, name: 'EE exclusiva'} + ]; + next(); +}, response('education_level_short')); + rqfCount.addField({ name: 'filter', field: false, @@ -203,6 +217,16 @@ rqfCount.addField({ type: 'integer', field: 'etapas_mod_ensino_segmento_id' } +}).addValue({ + name: 'education_level_short', + table: 'turma', + tableField: 'etapa_resumida', + resultField: 'education_level_short_id', + where: { + relation: '=', + type: 'integer', + field: 'etapa_resumida' + } }).addValue({ name: 'adm_dependency_detailed', table: 'turma', diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 6f1329d4afd02440e699964865adb14ff1f3351c..b6117dc4ca851bcc0e10cdfd19f96e94f2dc9857 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -71,6 +71,20 @@ enrollmentApp.get('/education_level_mod', (req, res, next) => { next(); }, query, response('education_level_mod')); +enrollmentApp.get('/education_level_short', (req, res, next) => { + req.result = [ + {id: null, name: 'Não Classificado'}, + {id: 1, name: 'Creche'}, + {id: 2, name: 'Pré-Escola'}, + {id: 3, name: 'Ensino Fundamental - anos iniciais'}, + {id: 4, name: 'Ensino Fundamental - anos finais'}, + {id: 5, name: 'Ensino Médio'}, + {id: 6, name: 'EJA'}, + {id: 7, name: 'EE exclusiva'} + ]; + next(); +}, response('education_level_short')); + // Returns all adm dependencies enrollmentApp.get('/adm_dependency', (req, res, next) => { req.sql.from('dependencia_adm') @@ -121,7 +135,6 @@ enrollmentApp.get('/integral_time', (req, res, next) => { next(); }, response('integral_time')); - rqf.addField({ name: 'filter', field: false, @@ -180,6 +193,16 @@ rqf.addField({ type: 'integer', field: 'etapas_mod_ensino_segmento_id' } +}).addValue({ + name: 'education_level_short', + table: 'matricula', + tableField: 'etapa_resumida', + resultField: 'education_level_short_id', + where: { + relation: '=', + type: 'integer', + field: 'etapa_resumida' + } }).addValue({ name: 'region', table: 'regiao', diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index 470801ceb768279dd354e9d2c89a359c1b148fde..c99441600bf1677f8adce9d1fe2167b1d9de9fdc 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -48,6 +48,20 @@ teacherApp.get('/education_level_mod', (req, res, next) => { next(); }, query, response('education_level_mod')); +teacherApp.get('/education_level_short', (req, res, next) => { + req.result = [ + {id: null, name: 'Não Classificado'}, + {id: 1, name: 'Creche'}, + {id: 2, name: 'Pré-Escola'}, + {id: 3, name: 'Ensino Fundamental - anos iniciais'}, + {id: 4, name: 'Ensino Fundamental - anos finais'}, + {id: 5, name: 'Ensino Médio'}, + {id: 6, name: 'EJA'}, + {id: 7, name: 'EE exclusiva'} + ]; + next(); +}, response('education_level_short')); + teacherApp.get('/location', (req, res, next) => { req.sql.from('localizacao') .field('id') @@ -133,6 +147,16 @@ rqf.addField({ type: 'integer', field: 'etapas_mod_ensino_segmento_id' } +}).addValue({ + name: 'education_level_short', + table: 'docente', + tableField: 'etapa_resumida', + resultField: 'education_level_short_id', + where: { + relation: '=', + type: 'integer', + field: 'etapa_resumida' + } }).addValue({ name: 'education_type', table: 'docente', diff --git a/src/test/class.js b/src/test/class.js index 7c20fc91ad949f65b0dcc1916ffd100a2bcbda4f..c7619d604e9b053e882c7e5a917082c303383e3b 100644 --- a/src/test/class.js +++ b/src/test/class.js @@ -66,6 +66,20 @@ describe('request class', () => { }); }); + it('should list the education level short', (done) => { + chai.request(server) + .get('/api/v1/class/education_level_short') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('id'); + res.body.result[0].should.have.property('name'); + done(); + }); + }); + it('should list the administrative dependencies', (done) => { chai.request(server) .get('/api/v1/class/adm_dependency_detailed') @@ -198,4 +212,18 @@ describe('request class', () => { done(); }); }); + + it('should list enrollment with dimension education_level_short', (done) => { + chai.request(server) + .get('/api/v1/class?dims=education_level_short') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('education_level_short_name'); + res.body.result[0].should.not.have.property('education_level_short_id'); + done(); + }); + }); }); diff --git a/src/test/enrollment.js b/src/test/enrollment.js index efa5c160a5607f2e9b14136e14b6795d3ac2b232..f48334d74325091bad08b602d5c1088db11297e2 100644 --- a/src/test/enrollment.js +++ b/src/test/enrollment.js @@ -108,6 +108,20 @@ describe('request enrollments', () => { }); }); + it('should list the education level short', (done) => { + chai.request(server) + .get('/api/v1/enrollment/education_level_short') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('id'); + res.body.result[0].should.have.property('name'); + done(); + }); + }); + it('should list the administrative dependencies', (done) => { chai.request(server) .get('/api/v1/enrollment/adm_dependency') @@ -234,23 +248,6 @@ describe('request enrollments', () => { }); }); - it('should list enrollments with valid dimensions', (done) => { - chai.request(server) - .get('/api/v1/enrollment?dims=region,state,adm_dependency,location,gender,period,school_year,location,ethnic_group') - .end((err, res) => { - res.should.have.status(200); - res.should.be.json; - res.body.should.have.property('result'); - res.body.result.should.be.a('array'); - res.body.result[0].should.have.property('region_name'); - res.body.result[0].should.have.property('state_name'); - res.body.result[0].should.have.property('adm_dependency_name'); - res.body.result[0].should.have.property('location_name'); - res.body.result[0].should.have.property('total'); - done(); - }); - }); - it('should list enrollments with invalid dimensions', (done) => { chai.request(server) .get('/api/v1/enrollment?dims=foo,bar') @@ -367,6 +364,20 @@ describe('request enrollments', () => { }); }); + it('should list enrollment with dimension education_level_short', (done) => { + chai.request(server) + .get('/api/v1/enrollment?dims=education_level_short') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('education_level_short_name'); + res.body.result[0].should.not.have.property('education_level_short_id'); + done(); + }); + }); + it('should list enrollment with dimension adm_dependency', (done) => { chai.request(server) .get('/api/v1/enrollment?dims=adm_dependency') diff --git a/src/test/teacher.js b/src/test/teacher.js index 7022188f9b546e7bea85dc49cbddb8ebe9d3a1e2..a9624eca227c052cba818a5dad246989137f2f76 100644 --- a/src/test/teacher.js +++ b/src/test/teacher.js @@ -80,6 +80,20 @@ describe('request teachers', () => { }); }); + it('should list the education level short', (done) => { + chai.request(server) + .get('/api/v1/teacher/education_level_short') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('id'); + res.body.result[0].should.have.property('name'); + done(); + }); + }); + it('should list the education type', (done) => { chai.request(server) .get('/api/v1/teacher/education_type') @@ -283,6 +297,20 @@ describe('request teachers', () => { }); }); + it('should list enrollment with dimension education_level_short', (done) => { + chai.request(server) + .get('/api/v1/teacher?dims=education_level_short') + .end((err, res) => { + res.should.have.status(200); + res.should.be.json; + res.body.should.have.property('result'); + res.body.result.should.be.a('array'); + res.body.result[0].should.have.property('education_level_short_name'); + res.body.result[0].should.not.have.property('education_level_short_id'); + done(); + }); + }); + it('should list teacher count with dimension education type', (done) => { chai.request(server) .get('/api/v1/teacher?dims=education_type')