Commit 1df7ae61 by Arturo Montejo Ráez

Merge branch 'issue711' into develop

parents 8fb0cea2 b1d26eef
......@@ -11,8 +11,8 @@ Los ficheros SQL que importará este rol son los siguientes:
los datos almacenados por symbolstx.
- [pictodb-schema][3] contiene el esquema de la base de datos.
- [pictodb-data][4] contiene la información básica que la aplicación necesita para funcionar. Añade información a las tablas `meta_method`, `meta_instruction`, `source`, `picto_core` y `picto_exp`.
- [symbolstx-categories][5] añade las categorías de symbolstx en las tablas `pictocat` y `catexp`.
- [symbolstix-metadata][6] añade traducciones para symbolstx y los pictos (tablas `picto_exp`, `picto_tag` y `picto`).
- [pitcodb-core][11] y [pictodb-corexp][12] contienen la información del subconjunto de symbolstix que conforma el vocabulario básico de un estudiante recién creado
- [symbolstx][11] añade la colección de Symbolstix
- [triggers-enrolments-integrity-constraints][7] añade disparadores para el control de
integridad de inscripciones.
- [triggers-sessions-integrity-constraints][8] añade disparadores para el control de integridad
......@@ -20,6 +20,11 @@ Los ficheros SQL que importará este rol son los siguientes:
- [test-caja][9] contiene datos para el test de CAJA.
- [test-autismojaen][10] añade los datos para el test de autismojaen.
Obsoleto:
- [symbolstx-categories][5] añade las categorías de symbolstx en las tablas `pictocat` y `catexp`
- [symbolstix-metadata][6] añade traducciones para symbolstx y los pictos (tablas `picto_exp`, `picto_tag` y `picto`).
[1]: /softuno/pictogram/blob/develop/sails/roles/database/files/init.sql
[2]: /softuno/pictogram/blob/develop/sails/roles/database/files/init-ignoresymbolstix.sql
[3]: /softuno/pictogram/blob/develop/sails/roles/database/files/pictodb-schema.sql
......@@ -30,3 +35,5 @@ Los ficheros SQL que importará este rol son los siguientes:
[8]: /softuno/pictogram/blob/develop/sails/roles/database/files/triggers-sessions-integrity-constraints.sql
[9]: /softuno/pictogram/blob/develop/sails/roles/database/files/test-autismojaen.sql
[10]: /softuno/pictogram/blob/develop/sails/roles/database/files/test-caja.sql
[11]: /softuno/pictogram/blob/develop/sails/roles/database/files/pictodb-core.sql
[12]: /softuno/pictogram/blob/develop/sails/roles/database/files/pictodb-coreexp.sql
......@@ -9,7 +9,7 @@ INSERT INTO `picto_core` (`id`, `id_pic`, `id_cat_pic`, `coord_x`, `coord_y`,`co
(2, 4391, NULL, 1, 0, NULL), -- no
(4, 2237, NULL, 2, 0, NULL), -- i want
(229, 2224, NULL, 3, 0, NULL), -- i have
(131, 8148,NULL, 0, 1, '#FE9A2E'), -- Places and rooms
(131, 8148, NULL, 0, 1, '#FE9A2E'), -- Places and rooms
(134, 7989, 8148, 0, 0, NULL), -- Places.Hospital
(135, 8155, 8148, 0, 1, NULL), -- Places.Playground
(136, 8354, 8148, 0, 2, NULL), -- Places.Zoo
......@@ -229,6 +229,3 @@ INSERT INTO `picto_core` (`id`, `id_pic`, `id_cat_pic`, `coord_x`, `coord_y`,`co
(5, 266, 1379, 3, 5, NULL), -- Adverbs and interjections.help
(7, 2179, 1379, 3, 6, NULL), -- Adverbs and interjections.hello
(124, 2169,1379, 3, 7, NULL); -- Adverbs and interjections.bye
......@@ -21,19 +21,33 @@ INSERT INTO `supervisor` (`id`, `name`, `surname`, `gender`, `pic`, `address`, `
--
-- Meta-method
--
INSERT INTO `meta_method` (`id`, `name`, `description`, `id_sup`) VALUES
(1, 'Comunicación Aumentativa y Adaptativa', NULL, NULL);
INSERT INTO `meta_method` (`id`, `name`, `description`, `id_sup`, `lang`) VALUES
(1, 'Comunicación Aumentativa y Alternativa', NULL, NULL, 'es-es'),
(2, 'Augmentative and Alternative Communication', NULL, NULL, 'en-us'),
(3, 'Augmentative and Alternative Communication', NULL, NULL, 'en-gb');
--
-- Meta-instruction
--
INSERT INTO `meta_instruction` (`id` ,`name` ,`objective` ,`id_met`) VALUES
(NULL , 'Fase 1 - El Intercambio físico', 'En cuanto vea un objeto altamente preferido, el estudiante tomará la imagen del objeto, se acercará hacia el terapeuta y dejará la imagen (fotografía) en la mano del terapeuta.', '1'),
(NULL , 'Fase 2 - Desarrollando la espontaneidad', 'El estudiante irá a su tablero de comunicación, tomará una fotografía, irá a un adulto y la dejará en su mano.', '1'),
(NULL , 'Fase 3 - Discriminación de fotografías', 'El estudiante solicitará los objetos deseados yendo al tablero de comunicación, seleccionando la fotografía apropiada y volviendo de nuevo hasta el interlocutor a darle la fotografía.', '1'),
(NULL , 'Fase 4 - Estructura de la oración', 'El estudiante solicita artículos presentes y no presentes usando una frase de varias palabras yendo al libro.El estudiante toma una fotografía/símbolo de "Yo quiero" y la coloca en una línea de frase (tira de Velcro). Luego, el estudiante toma una imagen de lo que desea, la coloca en la línea de frase, quita toda la tira de Velcro, y la lleva a su interlocutor.', '1'),
(NULL , 'Fase 5 - Respondiendo a "¿Qué quieres?"', 'El estudiante puede de manera espontánea solicitar una variedad de objetos y puede responder a la pregunta, "Que quieres?"', '1'),
(NULL , 'Fase 6 - Respuesta y comentario espontáneo', 'El estudiante responde apropiadamente a "Qué quieres?", "Qué ves?", "Qué tienes?" y a otras preguntas similares cuando éstas son hechas de manera aleatoria.', '1');
INSERT INTO `meta_instruction` (`id` ,`name` ,`objective` ,`id_met`, `lang`) VALUES
(NULL , 'Fase 1 - El Intercambio físico', 'En cuanto vea un objeto altamente preferido, el estudiante tomará la imagen del objeto, se acercará hacia el terapeuta y dejará la imagen (fotografía) en la mano del terapeuta.', '1', 'es-es'),
(NULL , 'Fase 2 - Desarrollando la espontaneidad', 'El estudiante irá a su tablero de comunicación, tomará una fotografía, irá a un adulto y la dejará en su mano.', '1', 'es-es'),
(NULL , 'Fase 3 - Discriminación de fotografías', 'El estudiante solicitará los objetos deseados yendo al tablero de comunicación, seleccionando la fotografía apropiada y volviendo de nuevo hasta el interlocutor a darle la fotografía.', '1', 'es-es'),
(NULL , 'Fase 4 - Estructura de la oración', 'El estudiante solicita artículos presentes y no presentes usando una frase de varias palabras yendo al libro.El estudiante toma una fotografía/símbolo de "Yo quiero" y la coloca en una línea de frase (tira de Velcro). Luego, el estudiante toma una imagen de lo que desea, la coloca en la línea de frase, y la lleva a su interlocutor.', '1', 'es-es'),
(NULL , 'Fase 5 - Respondiendo a "¿Qué quieres?"', 'El estudiante puede de manera espontánea solicitar una variedad de objetos y puede responder a la pregunta, "Que quieres?"', '1', 'es-es'),
(NULL , 'Fase 6 - Respuesta y comentario espontáneo', 'El estudiante responde apropiadamente a "Qué quieres?", "Qué ves?", "Qué tienes?" y a otras preguntas similares cuando éstas son hechas de manera aleatoria.', '1', 'es-es'),
(NULL , 'Phase 1 - How to Communicate', 'Students learn to exchange single pictures for items or activities they really want. ', '2', 'en-us'),
(NULL , 'Phase 2 - Distance and Persistence', 'Still using single pictures, students learn to generalize this new skill by using it in different places, with different people and across distances. They are also taught to be more persistent communicators.', '2', 'en-us'),
(NULL , 'Phase 3 - Picture Discrimination', 'Students learn to select from two or more pictures to ask for their favorite things. These are placed in the phrase strip of the device where pictures are stored and easily removed for communication.', '2', 'en-us'),
(NULL , 'Phase 4 - Sentence Structure', 'Students learn to construct simple sentences on a detachable sentence strip using an "I want" picture followed by a picture of the item being requested.', '2', 'en-us'),
(NULL , 'Phase 5 - Answering Questions', 'Students learn to use Pictogram to answer the question, "What do you want?".', '2', 'en-us'),
(NULL , 'Phase 6 - Commenting', 'Now students are taught to comment in response to questions such as, "What do you see?", "What do you hear?" and "What is it?". They learn to make up sentences starting with "I see", "I hear", "I feel", "It is a", etc.', '2', 'en-us'),
(NULL , 'Phase 1 - How to Communicate', 'Students learn to exchange single pictures for items or activities they really want. ', '3', 'en-gb'),
(NULL , 'Phase 2 - Distance and Persistence', 'Still using single pictures, students learn to generalize this new skill by using it in different places, with different people and across distances. They are also taught to be more persistent communicators.', '3', 'en-gb'),
(NULL , 'Phase 3 - Picture Discrimination', 'Students learn to select from two or more pictures to ask for their favorite things. These are placed in the phrase strip of the device where pictures are stored and easily removed for communication.', '3', 'en-gb'),
(NULL , 'Phase 4 - Sentence Structure', 'Students learn to construct simple sentences on a detachable sentence strip using an "I want" picture followed by a picture of the item being requested.', '3', 'en-gb'),
(NULL , 'Phase 5 - Answering Questions', 'Students learn to use Pictogram to answer the question, "What do you want?".', '3', 'en-gb'),
(NULL , 'Phase 6 - Commenting', 'Now students are taught to comment in response to questions such as, "What do you see?", "What do you hear?" and "What is it?". They learn to make up sentences starting with "I see", "I hear", "I feel", "It is a", etc.', '3', 'en-gb');
--
-- Volcado de datos para la tabla `source`
......
......@@ -94,6 +94,7 @@ CREATE TABLE IF NOT EXISTS `meta_instruction` (
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`objective` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`id_met` tinyint(4) NOT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="One in a set of instructions predefined or stored by users. They are related to a metamethod (id_met)";
......@@ -105,9 +106,10 @@ COMMENT="One in a set of instructions predefined or stored by users. They are re
CREATE TABLE IF NOT EXISTS `meta_method` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`name` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`id_sup` INT( 11 ) DEFAULT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
UNIQUE(name,id_sup),
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
......@@ -158,6 +160,7 @@ CREATE TABLE IF NOT EXISTS `picto` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=104142
COMMENT="Main information about a pictogram, either coming from a source like Symbolstix or added by a supervisor. It can belongs to a category (id_cat)";
--
-- Estructura de tabla para la tabla `picto_acl`
-- NOT IN USE (candidate for removal)
......
This diff could not be displayed because it is too large.
......@@ -34,7 +34,7 @@ thisTrigger: BEGIN
END IF;
END;;
-- Integrity rule 2: office.current_enrolments updating
-- Integrity rule 2: office.current_enrolments updating (adding core)
DROP TRIGGER IF EXISTS TRG_NEW_STUDENT_UPDATE_ENROLMENTS;
CREATE TRIGGER TRG_NEW_STUDENT_UPDATE_ENROLMENTS
AFTER INSERT ON student
......
......@@ -16,16 +16,13 @@
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/pictodb-schema.sql"
- name: Imports symbolstx categories and metadata
- name: Imports symbolstix pictos
mysql_db:
login_user: "{{ database_user }}"
login_password: "{{ database_user_passwd }}"
name: "{{ database_name }}"
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/symbolstx-{{ item }}.sql"
with_items:
- metadata
- categories
target: "{{ server_path }}/{{ database_files_relative_path }}/symbolstix.sql"
- name: Imports application essential data
mysql_db:
......
......@@ -33,7 +33,7 @@ module.exports = {
res.ok(metaMethods);
})
.catch(function (err) {
res.serverError(err);
res.serverError(err.message);
});
},
......
......@@ -304,7 +304,7 @@ module.exports = {
Picto.create({
uri: pictoFileName,
source: 1, // @TODO check for other sources
source: 2, // 1 -> SymbolStix, 2 -> custom
owner: supervisor.id
})
.then(picto => {
......
......@@ -965,23 +965,16 @@ module.exports = {
//
update_legend: function (req, res) {
var params = req.allParams();
var query='update stu_picto'+
' set attributes=json_set(attributes, \'$.legend\',\''+params.legend_value+'\')'+
' where id_stu='+params.id_stu;
console.log('Updating legend for student ' + params.id_stu +" collection to "+
params.legend_value+": "+query);
StuPicto.query(query, function(err, result) {
if (err)
throw new Error ("error on update");
else {
console.log('Updated attributes for picto student:' + params.id_stu);
Student.update_legend(params.id_stu, params.legend_value, function (err) {
if (err) {
sails.log.debug(JSON.stringify(err));
return res.serverError("Error on legend update: ");
}
return res.ok({
id: params.id_stu,
legend_value: params.legend_value, // picto attributes for student
});
}
});
})
},
/**
......
/**
* catexp.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName : 'catexp',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
primaryKey: true,
unique: true
},
id_cat: {
type: "integer",
required: true,
model: 'PictoCat'
},
lang: {
required: true,
type: "string",
size: 5
},
exp: {
required: false,
type: "string",
size: 30
}
}
};
\ No newline at end of file
......@@ -12,7 +12,7 @@ module.exports = {
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
......@@ -25,6 +25,11 @@ module.exports = {
type: "string",
size: 40
},
lang: {
required: true,
type: "string",
size: 5
},
description: {
type: "string",
size: 1024
......@@ -35,10 +40,10 @@ module.exports = {
required: false,
model: "Supervisor"
},
// Relación con MetaInstruction. [1 MetaMethod to N MetaInstruction]
// Relación con MetaInstruction. [1 MetaMethod to N MetaInstruction]
metainstructions: {
collection: "MetaInstruction",
via: "id_met"
}
}
};
\ No newline at end of file
};
/**
* pictocat.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName : 'pictocat',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
primaryKey: true,
unique: true
},
id_supercat: {
type: "integer",
required: false
},
exps: {
collection: "CatExp",
via: 'id_cat'
}
}
};
\ No newline at end of file
......@@ -520,5 +520,27 @@ module.exports = {
})
.catch((err) => {cb(err)});
});
},
/*
* Updates legend in student pictos
* legend is not updated for categories
*/
update_legend: function(id_stu, legend_value, cb) {
var query='UPDATE stu_picto' +
' SET attributes = json_set(attributes, \'$.legend\',\''+legend_value+'\')' +
' WHERE id_stu=' + id_stu + ' AND ' +
' (json_extract(attributes, \'$.id_cat\') LIKE \'null\' AND ' +
' json_extract(attributes, \'$.coord_y\') = 0 OR ' +
' json_extract(attributes, \'$.id_cat\') NOT LIKE \'null\' AND ' +
' json_extract(attributes, \'$.coord_y\') > 0); '
;
StuPicto.query(query, function(err, result) {
if (err)
cb(err);
else
cb();
});
}
};
......@@ -14,6 +14,25 @@
module.exports = function serverError (data, options) {
//
// This function avoids converting to JSON circular structures
//
function avoidCircular (object) {
var cache = [];
for (var property in object) {
if (object.hasOwnProperty(property)) {
if (typeof object[property] === 'object' && object[property] !== null) {
if (cache.indexOf(value) !== -1) {
delete object[property];
}
// Store value in our collection
cache.push(value);
}
}
}
return object;
}
// Get access to `req`, `res`, & `sails`
var req = this.req;
var res = this.res;
......@@ -30,7 +49,7 @@ module.exports = function serverError (data, options) {
// If the user-agent wants JSON, always respond with JSON
if (req.wantsJSON) {
return res.jsonx(data);
return res.jsonx(avoidCircular(data));
}
// If second argument is a string, we take that to mean it refers to a view.
......@@ -60,7 +79,7 @@ module.exports = function serverError (data, options) {
else {
sails.log.warn('res.serverError() :: When attempting to render error page view, an error occured (sending JSON instead). Details: ', err);
}
return res.jsonx(data);
return res.jsonx(avoidCircular(data));
}
return res.send(html);
......
......@@ -6,7 +6,7 @@
"license": "Private",
"private": true,
"dependencies": {
"angular": "1.3.x",
"angular": "1.2.x",
"angular-mocks": "1.3.x",
"jquery": "~2.1.1",
"bootstrap": "~3.1.1",
......
......@@ -57,7 +57,10 @@
<div class="form-group" ng-if="show_change_form">
<label>Captcha*</label>
<div re-captcha ng-model="captcha_chgpass"></div>
<div re-captcha
ng-model="captcha_chgpass"
size="compact"
lang="es"></div>
</div>
<p class="text-center">
......
......@@ -138,6 +138,45 @@ dashboardControllers.controller('AddPictoCtrl', function (
};
/**
* It replaces the image associated to a picto (making a
* POST request to /picto/upload) but keeping the rest of attributes.
* @param {Array of Objects} $files Array of pictos to be uploaded the file
* itself (as binary data) will be sent.
*/
$scope.changePictoImg = function ($files, id_pic) {
$files.forEach(function (file) {
if (file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif') {
$upload.upload({
url: '/picto/update',
method: 'UPDATE',
fields: { owner: supervisor.id, id_pic: id_pic},
file: file
}).success(function (picto) {
$translate('picto_upload_success').then(function (translation) {
ngToast.success(translation);
});
picto.expressions = [];
$scope.pictos.push(picto);
$scope.open_exp(picto);
}).error(function (err) {
if (err.code == "E_EXCEEDS_UPLOAD_LIMIT")
$translate('picto_upload_limit').then(function (translation) {
ngToast.danger(translation);
});
else
$translate('picto_upload_error').then(function (translation) {
ngToast.danger(translation);
});
});
} else {
$translate('invalid_file_type').then(function (translation) {
ngToast.danger(translation);
});
}
});
};
/**
* When a image file is selected it tries to upload it as custom picto (making a
* POST request to /picto/upload).
* @param {Array of Objects} $files Array of pictos to be uploaded the file
......
......@@ -24,12 +24,15 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.get(config.backend+'/method/template/' + $scope.user.id)
.success(function(data, status, headers, config) {
for (var i = 0; i < data.length; i++) {
data[i].disabled = data[i].lang != $translate.use();
}
// Add to list
$scope.methods_available = data;
console.log("Meta Methods charged:");
console.log(JSON.stringify($scope.methods_available));
// Option to add new methods
$scope.methods_available.push({ id: 0, name: $translate.instant('new_method') });
$scope.methods_available.push({ id: 0, name: $translate.instant('new_method'), disabled: false });
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
......
......@@ -4,7 +4,14 @@
<div class="panel-body">
<!-- Select to add new method -->
<div class="form-group">
<select class="form-control" name="method_select" id="method_select" ng-model="method_selected" ng-options="ma.name for ma in methods_available">
<select class="form-control" name="method_select" id="method_select" ng-model="method_selected">
<option ng-repeat="ma in methods_available track by $index"
value="{{ $index }}"
label="{{ ma.name }}"
ng-if="ma.lang == user.lang">
{{ ma.name }}
</option>
<option value="" translate>select_method</option>
</select>
......@@ -22,18 +29,19 @@
<!-- Method instructions -->
<div class="method_details" ng-repeat="m in methods">
<input type="text" class="editable title" ng-model="m.name " ng-blur="update_method(m)"/>
<div class="options">
<a ng-click="save_as_template(m)" popover="{{ 'save_as_template' | translate}}" popover-trigger="mouseenter"><span class="text_medium color_black glyphicon glyphicon-floppy-disk" aria-hidden="true"></span></a>
<a ng-click="delete_method(m)" popover="{{ 'delete' | translate}}" popover-trigger="mouseenter"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a>
</div>
<textarea class="editable" ng-model="m.description " placeholder="{{'description' | translate}}" ng-blur="update_method(m)"></textarea>
<!-- Tabla método -->
<table class="table_instructions table">
<tr>
......@@ -66,12 +74,12 @@
</div>
</td>
<td class="editable_status">
<span class="pointer text_medium glyphicon" ng-class="{
'color_green': i.status == 'finished',
'glyphicon-check': i.status == 'finished',
'color_blue': i.status == 'started',
'glyphicon-edit': i.status == 'started',
'glyphicon-minus': i.status == null
<span class="pointer text_medium glyphicon" ng-class="{
'color_green': i.status == 'finished',
'glyphicon-check': i.status == 'finished',
'color_blue': i.status == 'started',
'glyphicon-edit': i.status == 'started',
'glyphicon-minus': i.status == null
}" aria-hidden="true" popover="{{(i.status || 'nobegin') | translate}}" popover-trigger="mouseenter" ng-click="change_status(i)"></span>
</td>
<td><a confirmed-click="delete_instruction(i);" ng-confirm-click="{{ 'confirmation' | translate}}" class="delete_instruction"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a></td>
......@@ -91,4 +99,4 @@
</div>
<!-- END .panel-body -->
</div>
<!-- END .panel -->
\ No newline at end of file
<!-- END .panel -->
......@@ -6,5 +6,6 @@
dashboardControllers.controller('TranslateController', function($translate, $scope) {
$scope.changeLanguage = function (langKey) {
$translate.use(langKey);
$scope.user.lang = langKey;
};
});
\ No newline at end of file
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment