Supervisors management by offices ready

parent af191494
-- MySQL dump 10.13 Distrib 5.7.13, for Linux (x86_64)
--
-- Host: localhost Database: pictodb
-- ------------------------------------------------------
-- Server version 5.7.13
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `action`
--
DROP TABLE IF EXISTS `action`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `action` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
`timestamp` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL,
`id_try` int(11) DEFAULT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'serialization of properties of the picto at the time of the action',
`gps_lat` float DEFAULT NULL,
`gps_lon` float DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uq_stuact` (`id_stu`,`timestamp`),
UNIQUE KEY `id_stu` (`id_stu`,`timestamp`),
UNIQUE KEY `uq_supact` (`id_sup`,`timestamp`),
KEY `fk_sup_act` (`id_sup`),
KEY `fk_stu_act` (`id_stu`),
KEY `id_try` (`id_try`),
CONSTRAINT `fk_stu_act` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`),
CONSTRAINT `fk_sup_act` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
CONSTRAINT `fk_try_act` FOREIGN KEY (`id_try`) REFERENCES `try` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table registers and action performed by a user at a given time, all information of the action is in JSON format in the ''description'' column and the operation performed is one of the possible for the ''type'' column. NOTE: timestamps must support fractional seconds, so MySQL versions >= 5.6.4 are required.';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_NEW_EVENT_ONSESSION
BEFORE INSERT ON action
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idstu INT;
DECLARE idtry INT;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_BEFORE_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT id_opentry INTO idtry
FROM
stu_opentry
WHERE
id_stu = NEW.id_stu;
IF (idtry IS NOT NULL) THEN
SET NEW.id_try = idtry;
END IF;
IF (NEW.type = 'resumesession')
THEN
SET NEW.id_try=NULL;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_NEW_EVENT
AFTER INSERT ON action
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idopentry INT;
DECLARE idws INT;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT id_ws, id_opentry INTO idws, idopentry
FROM
stu_opentry
WHERE
id_stu = NEW.id_stu;
IF (NEW.id_try IS NOT NULL) THEN
UPDATE `try`
SET
end = NEW.timestamp
WHERE
id = idopentry;
END IF;
CASE NEW.type
WHEN 'Show' THEN
INSERT INTO try(`id_ws`)
VALUES (idws);
WHEN 'pausesession' THEN
IF (idopentry IS NOT NULL) THEN
UPDATE try
SET
result = 'DISCARDED'
WHERE
id = idopentry;
END IF;
WHEN 'resumesession' THEN
INSERT INTO try(`id_ws`)
VALUES (idws);
ELSE BEGIN END;
END CASE;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `catexp`
--
DROP TABLE IF EXISTS `catexp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catexp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_cat` int(11) NOT NULL,
`lang` char(5) DEFAULT NULL,
`exp` varchar(30) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `exp` (`exp`,`lang`)
) ENGINE=InnoDB AUTO_INCREMENT=27958 DEFAULT CHARSET=latin1 COMMENT='Stores the expressions available in several languages for a given category (id_cat)';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `instruction`
--
DROP TABLE IF EXISTS `instruction`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `instruction` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_met` int(11) NOT NULL,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`objective` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
`begin` timestamp(3) NULL DEFAULT NULL,
`end` timestamp(3) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_met_ins` (`id_met`),
KEY `ix_instruction_begin` (`begin`),
CONSTRAINT `fk_met_ins` FOREIGN KEY (`id_met`) REFERENCES `method` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='An instruction is a ''phase'' in a method for learning AAC';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `license`
--
DROP TABLE IF EXISTS `license`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `license` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_stu` int(11) DEFAULT NULL,
`number` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`creation_ts` datetime DEFAULT CURRENT_TIMESTAMP,
`activation_ts` datetime DEFAULT NULL,
`expiration_ts` datetime DEFAULT NULL,
`duration` int(11) DEFAULT '0',
`creator` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
`type` enum('trial','official') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'official',
PRIMARY KEY (`id`),
UNIQUE KEY `number` (`number`),
KEY `id_stu` (`id_stu`)
) ENGINE=InnoDB AUTO_INCREMENT=147 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Student license number';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `meta_instruction`
--
DROP TABLE IF EXISTS `meta_instruction`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `meta_instruction` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`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 AUTO_INCREMENT=36 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='One in a set of instructions predefined or stored by users. They are related to a metamethod (id_met)';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `meta_method`
--
DROP TABLE IF EXISTS `meta_method`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `meta_method` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`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,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`,`id_sup`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Methods predefined in the platform or stored by users for cloning';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `method`
--
DROP TABLE IF EXISTS `method`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `method` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`id_stu` int(11) NOT NULL,
`registration` date DEFAULT NULL,
`notes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_stu_met` (`id_stu`),
CONSTRAINT `fk_stu_met` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Information for a method. A method is composed by a set of instructions';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto`
--
DROP TABLE IF EXISTS `picto`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uri` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
`id_src` tinyint(4) NOT NULL,
`id_owner` int(11) DEFAULT NULL,
`id_cat` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ck_pic` (`id_owner`,`id_src`,`uri`),
KEY `fk_sou_pic` (`id_src`)
) ENGINE=InnoDB AUTO_INCREMENT=130774 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 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)';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto_acl`
--
DROP TABLE IF EXISTS `picto_acl`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto_acl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) NOT NULL DEFAULT '0',
`id_pic` int(11) NOT NULL DEFAULT '0',
`privilege` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
`timestamp` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
PRIMARY KEY (`id`),
KEY `k_pic_aclp` (`id_pic`),
KEY `k_sup_aclp` (`id_sup`),
CONSTRAINT `fk_pic_aclp` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`),
CONSTRAINT `fk_sup_aclp` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Stablish access rights to pictos';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto_core`
--
DROP TABLE IF EXISTS `picto_core`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto_core` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_pic` int(11) DEFAULT NULL COMMENT 'This is the id of the pictogram',
`id_cat_pic` int(11) DEFAULT NULL COMMENT 'This is the id of the pictogram that represents the category this entry belongs to',
`coord_x` tinyint(4) NOT NULL,
`coord_y` tinyint(4) NOT NULL,
`color` varchar(9) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id_pic` (`id_pic`),
KEY `id_cat_pic` (`id_cat_pic`),
CONSTRAINT `picto_core_ibfk_1` FOREIGN KEY (`id_cat_pic`) REFERENCES `picto` (`id`),
CONSTRAINT `picto_core_ibfk_2` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=233 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Default pictos and categories available for a newly created student with default coordinates';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto_exp`
--
DROP TABLE IF EXISTS `picto_exp`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto_exp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_pic` int(11) NOT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
`text` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `id_pic` (`id_pic`)
) ENGINE=InnoDB AUTO_INCREMENT=270859 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Expression (text label) for a picto (or a category) in different languages. This is used by the TTS engine';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `picto_tag`
--
DROP TABLE IF EXISTS `picto_tag`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `picto_tag` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) DEFAULT NULL COMMENT 'If NULL then is a default tag',
`id_pic` int(11) NOT NULL,
`tag` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`lang` char(5) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `id_pic` (`id_pic`),
KEY `id_sup` (`id_sup`),
CONSTRAINT `fk_con_pt` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`),
CONSTRAINT `picto_tag_ibfk_1` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
CONSTRAINT `picto_tag_ibfk_2` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=37052 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Labels assigned to pictos by default or by supervisors';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `pictocat`
--
DROP TABLE IF EXISTS `pictocat`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pictocat` (
`id` int(11) NOT NULL,
`id_supercat` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Identifies a category, which, itself, may belong to another category';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `pictocattree`
--
DROP TABLE IF EXISTS `pictocattree`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pictocattree` (
`id_cat` int(11) NOT NULL,
`id_ancestor` int(11) NOT NULL,
PRIMARY KEY (`id_cat`,`id_ancestor`),
KEY `id_ancestor` (`id_ancestor`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `scene`
--
DROP TABLE IF EXISTS `scene`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `scene` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`active` tinyint(1) NOT NULL DEFAULT '0',
`categories` tinyint(1) NOT NULL DEFAULT '0',
`id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `id_sup` (`id_sup`),
KEY `id_stu` (`id_stu`),
CONSTRAINT `scene_ibfk_1` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
CONSTRAINT `scene_ibfk_2` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=161 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Scene table information. Every scene is related to some stu_pictos';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `source`
--
DROP TABLE IF EXISTS `source`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `source` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Contains all possible sources of pictos';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `stu_opentry`
--
DROP TABLE IF EXISTS `stu_opentry`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `stu_opentry` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_stu` int(11) NOT NULL,
`id_sup` int(11) NOT NULL,
`id_ws` int(11) NOT NULL,
`id_opentry` int(11) DEFAULT NULL,
`total_tries` int(11) DEFAULT '0',
`begin` timestamp(3) NULL DEFAULT NULL,
`end` timestamp(3) NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_stu` (`id_stu`),
UNIQUE KEY `id_sup` (`id_sup`),
UNIQUE KEY `id_ws` (`id_ws`),
KEY `id_opentry` (`id_opentry`),
CONSTRAINT `stu_opentry_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`),
CONSTRAINT `stu_opentry_ibfk_2` FOREIGN KEY (`id_opentry`) REFERENCES `try` (`id`) ON DELETE SET NULL,
CONSTRAINT `stu_opentry_ibfk_3` FOREIGN KEY (`id_ws`) REFERENCES `working_session` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `stu_picto`
--
DROP TABLE IF EXISTS `stu_picto`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `stu_picto` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_stu` int(11) NOT NULL,
`id_pic` int(11) NOT NULL,
`attributes` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'JSON object describing the properties of the picto',
`id_scene` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_picto` (`id_pic`),
KEY `id_stu` (`id_stu`),
KEY `stu_picto_scene_fk` (`id_scene`),
CONSTRAINT `fk_picto` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`),
CONSTRAINT `stu_picto_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`),
CONSTRAINT `stu_picto_scene_fk` FOREIGN KEY (`id_scene`) REFERENCES `scene` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7010 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table relates a student with the pictos in her vocabulary';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `stu_sup`
--
DROP TABLE IF EXISTS `stu_sup`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `stu_sup` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_stu` int(11) NOT NULL,
`id_sup` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `fk_stu_sup_ss` (`id_stu`,`id_sup`),
KEY `fk_sup_ss` (`id_sup`),
KEY `id_stu` (`id_stu`),
CONSTRAINT `stu_sup_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`) ON DELETE CASCADE,
CONSTRAINT `stu_sup_ibfk_2` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table relates students and supervisors';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `student`
--
DROP TABLE IF EXISTS `student`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `student` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`name` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
`surname` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
`birthdate` date DEFAULT NULL,
`gender` char(1) COLLATE utf8_unicode_ci DEFAULT NULL,
`country` char(2) COLLATE utf8_unicode_ci DEFAULT NULL,
`pic` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'defaultAvatar.jpg',
`notes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`lang` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
`attributes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Attributes describing student along with his/her configuration',
`id_active_scene` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
KEY `fk_active_scene` (`id_active_scene`),
CONSTRAINT `fk_active_scene` FOREIGN KEY (`id_active_scene`) REFERENCES `scene` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Students information';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_NEW_STUDENT_UPDATE_ENROLMENTS
AFTER INSERT ON student
FOR EACH ROW
thisTrigger: BEGIN
DECLARE LID INT;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
INSERT INTO scene (id_stu,id_sup,name,categories) VALUES (NEW.id, null, 'with_categories', TRUE);
SET LID = LAST_INSERT_ID();
CALL scene_create_core(LID,new.id);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_DELETE_STUDENT_ENROLMENTS
AFTER DELETE ON student
FOR EACH ROW
thisTrigger: BEGIN
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_DELETE_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
IF old.id_off IS NULL THEN
UPDATE
office
SET
current_students=current_students-1
WHERE
office.id=old.id_off;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `sup_off`
--
DROP TABLE IF EXISTS `sup_off`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sup_off` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) NOT NULL,
`id_off` int(11) DEFAULT NULL,
KEY `fk_sup_off` (`id_sup`),
KEY `fk_off_sup` (`id_off`),
PRIMARY KEY(`id`),
UNIQUE KEY `idx_sup_off` (`id_sup`,`id_off`),
CONSTRAINT `fk_off_sup` FOREIGN KEY (`id_off`) REFERENCES `supervisor` (`id`),
CONSTRAINT `fk_sup_off` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `supervisor`
--
DROP TABLE IF EXISTS `supervisor`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `supervisor` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
`surname` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
`gender` char(1) COLLATE utf8_unicode_ci DEFAULT NULL,
`pic` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'defaultAvatar.jpg',
`address` varchar(180) COLLATE utf8_unicode_ci DEFAULT NULL,
`country` varchar(2) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`phone` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`lang` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,
`tts_engine` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`password` varchar(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Encrypted password using the BCrypt algorithm',
`active` tinyint(1) DEFAULT '0',
`postal_code` char(10) COLLATE utf8_unicode_ci DEFAULT NULL,
`arasaac_license` tinyint(1) DEFAULT '0',
`role` enum('tutor','therapist','office','admin') COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=84 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Supervisors information';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `try`
--
DROP TABLE IF EXISTS `try`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `try` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_ws` int(11) NOT NULL,
`begin` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`end` timestamp(3) NULL DEFAULT NULL,
`result` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id_ws` (`id_ws`),
KEY `ix_try_begin` (`begin`),
CONSTRAINT `try_ibfk_1` FOREIGN KEY (`id_ws`) REFERENCES `working_session` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table contains tries information (they belong to a working session)';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_NEW_TRY
AFTER INSERT ON try
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idstu INT;
DECLARE idsup INT;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT DISTINCT M.id_stu,W.id_sup INTO idstu, idsup
FROM
instruction I,
method M,
working_session W
WHERE
NEW.id_ws=W.id AND
W.id_ins=I.id AND
I.id_met=M.id;
INSERT INTO stu_opentry(id_stu,id_sup,id_ws,id_opentry, total_tries,begin)
VALUES (
idstu,
idsup,
NEW.id_ws,
NEW.id,
0,
NOW(3)
)
ON DUPLICATE KEY UPDATE id_stu=idstu, id_sup=idsup, id_ws=NEW.id_ws, id_opentry=NEW.id;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_TRY_EVALUATED
AFTER UPDATE ON try
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idws INT;
DECLARE ws_end DATE;
DECLARE ws_old_end DATE;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_UPDATE_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT end INTO ws_end
FROM
stu_opentry
WHERE
id_ws = NEW.id_ws;
IF ( (old.result IS NULL) and (new.result IS NOT NULL) and (new.end>ws_end)) THEN
UPDATE stu_opentry
SET
end = new.end,
total_tries = total_tries + 1
WHERE
id_ws = NEW.id_ws;
END IF;
SELECT end INTO ws_old_end
FROM
working_session
WHERE
id = NEW.id_ws;
IF (ws_old_end < NEW.end) THEN
UPDATE working_session
SET end = NEW.end
WHERE id = NEW.id_ws;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Temporary view structure for view `v_stu_last_instruction`
--
DROP TABLE IF EXISTS `v_stu_last_instruction`;
/*!50001 DROP VIEW IF EXISTS `v_stu_last_instruction`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `v_stu_last_instruction` AS SELECT
1 AS `id_ws`,
1 AS `ws_begin`,
1 AS `ws_end`,
1 AS `ws_description`,
1 AS `ins_name`,
1 AS `met_name`,
1 AS `id_stu`*/;
SET character_set_client = @saved_cs_client;
--
-- Temporary view structure for view `v_stu_last_ws_time`
--
DROP TABLE IF EXISTS `v_stu_last_ws_time`;
/*!50001 DROP VIEW IF EXISTS `v_stu_last_ws_time`*/;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `v_stu_last_ws_time` AS SELECT
1 AS `id_stu`,
1 AS `time`*/;
SET character_set_client = @saved_cs_client;
--
-- Table structure for table `working_session`
--
DROP TABLE IF EXISTS `working_session`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `working_session` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) NOT NULL,
`id_ins` int(11) NOT NULL,
`begin` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`end` timestamp(3) NULL DEFAULT NULL,
`current` tinyint(1) DEFAULT '1',
`description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_ws_supcur` (`id_sup`,`current`),
KEY `id_sup` (`id_sup`),
KEY `id_ins` (`id_ins`),
KEY `ix_ws_begin` (`begin`),
CONSTRAINT `fk_ins_ws` FOREIGN KEY (`id_ins`) REFERENCES `instruction` (`id`),
CONSTRAINT `working_session_ibfk_1` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='This table stores working session information. Every working session is related to one instruction and one supervisor (and the instruction is related to one method which is related to one student)';
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_SESSION_NEW
AFTER INSERT ON working_session
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idstu INT;
DECLARE ins_begin DATE;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT begin INTO ins_begin
FROM instruction
WHERE id = NEW.id_ins;
IF (ins_begin IS NULL) THEN
UPDATE instruction
SET
begin = NOW(3),
end = NOW(3)
WHERE
id = NEW.id_ins;
END IF;
UPDATE instruction
SET
status='started',
end = NOW(3)
WHERE
id = NEW.id_ins;
INSERT INTO try(`id_ws`)
VALUES (new.id);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_SESSION_CLOSING
BEFORE UPDATE ON working_session
FOR EACH ROW
thisTrigger: BEGIN
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_BEFORE_UPDATE_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
IF ((new.end IS NOT NULL) AND (new.current IS NOT NULL)) THEN
SET new.current=NULL;
DELETE FROM stu_opentry
WHERE id_ws = new.id;
DELETE FROM `try`
WHERE
end = NULL AND
id_ws = new.id;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER TRG_SESSION_CLOSED
AFTER UPDATE ON working_session
FOR EACH ROW
thisTrigger: BEGIN
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_UPDATE_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
IF (OLD.end < NEW.end) THEN
UPDATE instruction
SET
end = NEW.end
WHERE
id = NEW.id_ins;
END IF;
IF ((old.end IS NULL) and (new.end IS NOT NULL)) THEN
CALL deleteOpenTry(new.id);
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Final view structure for view `v_stu_last_instruction`
--
/*!50001 DROP VIEW IF EXISTS `v_stu_last_instruction`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_stu_last_instruction` AS select `WS`.`id` AS `id_ws`,`WS`.`begin` AS `ws_begin`,`WS`.`end` AS `ws_end`,`WS`.`description` AS `ws_description`,`I`.`name` AS `ins_name`,`M`.`name` AS `met_name`,`M`.`id_stu` AS `id_stu` from (((`working_session` `WS` join `instruction` `I`) join `method` `M`) join `v_stu_last_ws_time` `LAST_WS`) where ((`LAST_WS`.`time` = `WS`.`begin`) and (`LAST_WS`.`id_stu` = `M`.`id_stu`) and (`WS`.`id_ins` = `I`.`id`) and (`I`.`id_met` = `M`.`id`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
--
-- Final view structure for view `v_stu_last_ws_time`
--
/*!50001 DROP VIEW IF EXISTS `v_stu_last_ws_time`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
/*!50001 SET character_set_client = utf8 */;
/*!50001 SET character_set_results = utf8 */;
/*!50001 SET collation_connection = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `v_stu_last_ws_time` AS select `M`.`id_stu` AS `id_stu`,max(`WS`.`begin`) AS `time` from ((`working_session` `WS` join `instruction` `I`) join `method` `M`) where ((`WS`.`id_ins` = `I`.`id`) and (`I`.`id_met` = `M`.`id`)) group by `M`.`id_stu` */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2017-08-10 11:20:52
......@@ -17,12 +17,17 @@ ALTER TABLE student MODIFY lang VARCHAR(5) DEFAULT NULL;
ALTER TABLE license ADD type enum('trial', 'official') NOT NULL DEFAULT 'official';
CREATE TABLE IF NOT EXISTS sup_off (
id_sup int(11) NOT NULL,ALTER TABLE license ADD type enum('trial', 'official') NOT NULL DEFAULT 'official';
id_off int(11) DEFAULT NULL,
CONSTRAINT fk_sup_off FOREIGN KEY (id_sup) REFERENCES supervisor (id),
CONSTRAINT fk_off_sup FOREIGN KEY (id_off) REFERENCES supervisor (id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `sup_off` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) NOT NULL,
`id_off` int(11) DEFAULT NULL,
KEY `fk_sup_off` (`id_sup`),
KEY `fk_off_sup` (`id_off`),
PRIMARY KEY(`id`),
UNIQUE KEY `idx_sup_off` (`id_sup`,`id_off`),
CONSTRAINT `fk_off_sup` FOREIGN KEY (`id_off`) REFERENCES `supervisor` (`id`),
CONSTRAINT `fk_sup_off` FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
UPDATE supervisor
SET role = 'office'
......
......@@ -440,7 +440,131 @@ module.exports = {
});
},
/**
/**
* Get all supervisors in the database that are linked to the user as office.
* @param {request} req //
* {
id {ID} ID of the office (as a GET parameter)
}
* @param {response} res
* [
* {
* "id": 123,
* "name": "John"
* "surname": "Doe"
* "gender": "F/M"
* "password": "1234"
* "pic": "url/to/photo.jpg" (optional)
* "address": "Nice street" (optional)
* "country": "ES/UK/..." (optional)
* "email": "john@doe.com" (optional)
* "phone": "+123456789" (optional)
* "lang": "ES/EN/..." (optional)
* "tts_engine": "IVONA Text-to-Speech HQ" (optional)
* },
* ...
* ]
*/
supervisors: function (req, res) {
if (!req.params.id)
return res.badRequest("Supervisor ID missing");
var enriched_sups = [];
SupOff.find({office: req.params.id})
.populate('supervisor')
.then(function (supOffs) {
var sups = supOffs.map(so => so.supervisor);
async.eachSeries(sups, function (sup, next) {
if (!sup) return next();
Supervisor.commonStudents(sup.id, req.params.id, function (err, stus) {
if (err)
return next(err);
sup = sup.toJSON();
if (!stus || stus.length == 0)
sup.students = [];
else
sup.students = stus;
enriched_sups.push(sup);
next();
});
},
function (err) {
if (err) throw err;
else res.ok(enriched_sups);
});
})
.catch(function (err) {
res.serverError(err);
});
},
/**
* Links a new supervisor to the office
*
*/
link_supervisor: function (req, res) {
if (!req.params.id_off || !req.params.id_sup)
return res.badRequest();
if (req.params.id_off == req.params.id_sup)
return res.badRequest("Link to yourself is not allowed");
// Check that both ids are valid
Supervisor.findOne(req.params.id_sup)
.then((s) => {
if (!s)
throw new Error("Supervisor not found");
return Supervisor.findOne(req.params.id_off);
}).then((s) => {
if (!s)
throw new Error("Supervisor not found");
return SupOff.create({supervisor: req.params.id_sup, office: req.params.id_off});
})
.then((so) => {
if (!so)
throw new Error("Unable to perform linking");
res.ok();
})
.catch((err) => {
res.badRequest(err.message);
});
},
/**
* Unlinks a supervisor from an office
*
*/
unlink_supervisor: function (req, res) {
if (!req.params.id_off || !req.params.id_sup)
return res.badRequest();
// Check that both ids are valid
Supervisor.findOne(req.params.id_sup)
.then((s) => {
if (!s)
throw new Error("Supervisor not found");
return Supervisor.findOne(req.params.id_off);
})
.then((s) => {
if (!s)
throw new Error("Supervisor not found");
return SupOff.destroy({supervisor: req.params.id_sup, office: req.params.id_off});
})
.then((sos) => {
if (!sos)
throw new Error("No link exists");
res.ok();
})
.catch((err) => {
res.badRequest(err.message);
});
},
/**
* Get the list of students linked to this supervisor.
* The extra supervision attribute indicates the existing relationship between the supervisor and
* the student:
......@@ -486,6 +610,19 @@ module.exports = {
});
},
/*
Returns all the common students associated to both supervisors
*/
commonStudents: function (req, res) {
if (!req.params.id_sup || !req.params.id_off)
return res.badRequest();
Supervisor.commonStudents(req.params.id_sup, req.params.id_off, function (err, stus) {
if (err) throw err;
return res.ok(stus);
});
},
/**
* Get the pictos owned by this supervisor
* @param {request} req {}
......
/**
* office.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 = {
connection : 'localMysql',
tableName : 'office',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
autoIncrement: true,
primaryKey: true,
unique: true
},
name: {
required: true,
type: "string",
size: 80
},
logoUrl: {
columnName: 'logo_url',
type: "string",
size: 240
},
address: {
required: true,
type: "string",
size: 80
},
country: {
type: "string",
size: 5,
required: true
},
lang: {
required: true,
type: "string",
size: 5
},
contactPerson: {
columnName: "contact_person",
required: true,
type: "string",
size: 80
},
email: {
required: true,
type: "string",
size: 80,
unique: true
},
phone1: {
required: true,
type: "string",
size: 20
},
phone2: {
type: "string",
size: 20
},
admin: {
columnName: 'admin',
type: 'integer',
model: 'Supervisor'
},
postalCode: {
columnName: 'postal_code',
required: true,
type: "string",
size: 10
},
toJSON: function() {
var office = this.toObject();
if (!office.logoUrl)
office.logoUrl = '/app/img/logo_pictogram.png';
return office;
}
},
beforeCreate: function (attrs, next) {
if (!attrs.logoUrl)
attrs.logoUrl = '/app/img/logo_pictogram.png';
next();
}
};
/**
* StuSup.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
/**
* This model relates tutors and therapists with offices
*/
module.exports = {
tableName : 'sup_off',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
autoIncrement: true,
primaryKey: true,
unique: true
},
supervisor: { // FK de Supervisor. 1 a N
columnName: "id_sup",
required: true,
type: "integer",
model: "Supervisor"
},
office: { // FK de Supervisor. 1 a N
columnName: "id_off",
type: "integer",
model: "Supervisor"
}
}
}
......@@ -253,12 +253,7 @@ module.exports = {
s.current_instruction = s.lastInstruction[0] ? s.lastInstruction[0].ins_name : "no_instruction";
if (!s.license)
return next_cb();
//
// El alumno tiene licencia, es válida y no es de prueba
//
if (s.license.isValid || s.license.isOfficial)
l.push(s);
l.push(s);
next_cb();
});
},
......@@ -269,5 +264,52 @@ module.exports = {
.catch((err) => {
callback(err, l);
}); // end Supervisor.findOne
},
/***
* Return the list of students that are common to both supervisors
*/
commonStudents: function(id1, id2, callback) {
var l = [];
StuSup.find({ supervisor: id1 })
.then(function (stuSups) {
return [stuSups, StuSup.find({ supervisor: id2 })];
})
.spread((stuSups1, stuSups2) => {
if (!stuSups1 || !stuSups2)
throw new Error("No students");
// Common students
var stuSups = stuSups1.filter(a => stuSups2.findIndex(b => b.student == a.student) >= 0);
// Now, let's take full information about them
async.eachSeries(stuSups, function(stuSup, next_cb) {
// set current method and instruction if any
Student.findOne(stuSup.student)
.populate('lastInstruction')
.populate('license')
.then(function (s) {
if (!s)
return next_cb();
s = s.toJSON();
s.current_method = s.lastInstruction[0] ? s.lastInstruction[0].met_name : "no_method";
s.current_instruction = s.lastInstruction[0] ? s.lastInstruction[0].ins_name : "no_instruction";
if (!s.license)
return next_cb();
l.push(s);
next_cb();
});
},
function (err) {
return callback(err, l);
});
})
.catch((err) => {
return callback(err, l);
});
}
};
......@@ -205,12 +205,13 @@
"license_created": "License created",
"license_expired_official": "PRO license expired. To maintain access to therapeutical functionalities you can",
"license_expired_trial": "Trial license expired. To keep the account you should",
"license_expired_buy": "buy one",
"license_expired_buy": "buy one license",
"license_expired_renew": "renew it",
"license_expires_official": "PRO license expires on ",
"license_expires_trial": "Trial license expires on ",
"license_invalid": "Invalid license number",
"license_missing": "Account without PRO license",
"license_missing_official": "This PRO license expired. You have no access to therapeutical functionalities, but you can still manage pictograms and devices.",
"license_missing_trial": "Trial license expired. Buy an official one to keep using this account (go to Settings).",
"license_number": "License number",
"license_pro": "Pictogram PRO license",
"license_warning": "Only available for professional licenses (Pictogram Pro).",
......@@ -218,6 +219,8 @@
"licenses_left": "{{number}} licenses left",
"light_up": "Light up",
"link": "Link",
"link_supervisor": "Link supervisor",
"link_supervisor_desc": "When linking a therapist/parent/tutor, he/she will be notified of this action.",
"loading_pictos": "Loading pictos",
"login": "Log In",
"login_fail": "Invalid user or password",
......@@ -258,12 +261,15 @@
"no": "No",
"no_categories": "Without categories",
"nobegin": "No started",
"no_instruction": "No instruction defined",
"no_method": "No method defined",
"no_office": "No office",
"no_subscribed": "No connection to student account",
"no_instruction": "No instruction defined",
"no_students_for_user": "You are not associated to any students. Please ask your office to link your account to a Pictogram student.",
"no_space_in_category": "No space left in category",
"no_supervisors": "No supervisors linked. ",
"no_supervisors_desc": "Enter supervisor's email in the input field above to add one.",
"no_supervisor_linked": "Unable to link supervisor",
"normal": "Normal",
"note": "Note",
"notes": "Notes",
......@@ -414,12 +420,14 @@
"sup_not_deleted": "The supervisor couldn't be deleted by the student",
"sup_not_found": "There is no supervisor account in Pictogram with this email",
"supervisor_added": "Supervisor added",
"supervisor_already_linked": "The supervisor is already linked to your account",
"supervisor_deleted": "Supervisor deleted",
"supervisor_not_added": "Supervisor not added",
"supervisor_not_deleted": "Supervisor not deleted",
"supervisor_not_updated": "Supervisor not updated",
"supervisor_note": "If the parent aren't going to register in the platform, the administrator can use the notes field to store their information.",
"supervisor_updated": "Supervisor updated",
"supervisor_yourself": "This is you. No reason to link to yourself.",
"supervisors": "Supervisors",
"support": "User support",
"surname": "Surname",
......
......@@ -206,7 +206,7 @@
"license_created": "Licencia creada",
"license_expired_official": "La licencia PRO expiró. Para mantener acceso a funcionalidades terapéuticas puede",
"license_expired_trial": "La licencia de prueba expiró. Para mantener la cuenta debería",
"license_expired_buy": "adquirir una",
"license_expired_buy": "adquirir una licencia",
"license_expired_renew": "renovarla",
"license_expires_official": "La licencia PRO finaliza el ",
"license_expires_trial": "La licencia de prueba finaliza el ",
......@@ -214,10 +214,13 @@
"license_number": "Número de licencia",
"license_pro": "Licencia Pictogram PRO",
"license_warning": "Sólo disponible para licencias profesionales (Pictogram Pro).",
"license_missing": "Cuenta sin licencia PRO",
"license_missing_official": "La licencia PRO expiró. El acceso a las funcionalidades terapéuticas queda restringido, aunque puede seguir gestionando pictogramas y dispositivos.",
"license_missing_trial": "La licencia de prueba expiró. Adquiera una licencia oficial para mantener esta cuenta (puede hacerlo en Configuración).",
"licenses_created": "Licencias creadas",
"light_up": "Iluminar",
"link": "Vincular",
"link_supervisor": "Vincular supervisor",
"link_supervisor_desc": "Al vincular un terapeuta/padre/madre/tutor se enviará un correo de notificación al mismo.",
"loading_pictos": "Cargando pictos",
"login": "Iniciar sesión",
"login_fail": "Usuario o contraseña incorrectos",
......@@ -263,6 +266,9 @@
"no_students_for_user": "Su cuenta no está asociada a ningún estudiante. Por favor, contacte con su gabinete para enlazar su cuenta a un estudiante.",
"no_space_in_category": "No queda espacio en la categoría",
"no_subscribed": "Sin conexión a la cuenta del estudiante",
"no_supervisors": "No tiene tutores, padres o terapeutas asociados.",
"no_supervisors_desc": "Introduzca el correo electrónico del supervisor en el campo de arriba para añadirlo.",
"no_supervisor_linked": "No se pudo asociar al supervisor",
"nobegin": "Sin iniciar",
"normal": "Normal",
"note": "Nota",
......@@ -275,7 +281,7 @@
"num_sessions_per_month_in": "Número de sesiones por meses en",
"objetive": "Objetivo",
"October": "Octubre",
"office": "Gabinete",
"office": "Gabinete/centro",
"office_account_desc": "Gestione alumnos y equipos de intervención, además de todas las funcionalidades propias de un terapeuta.",
"office_center": "Gabinete/centro",
"office_added": "Gabinete añadido",
......@@ -414,12 +420,14 @@
"sup_not_deleted": "El supervisor no se ha podido desvincular del alumno.",
"sup_not_found": "No hay ningún usuario en Pictogram con ese correo electrónico.",
"supervisor_added": "Supervisor añadido",
"supervisor_already_linked": "El supervisor ya está vinculado",
"supervisor_deleted": "Supervisor eliminado",
"supervisor_not_added": "Supervisor no añadido",
"supervisor_not_deleted": "No se ha podido eliminar el supervisor",
"supervisor_not_updated": "El supervisor no se ha podido actualizar",
"supervisor_note": "Si los padres no se van a dar de alta en la plataforma nunca, el administrador puede anotar la información de contacto en el campo notas.",
"supervisor_updated": "Supervisor actualizado",
"supervisor_yourself": "Este es usted. No hay razón para añadir a uno mismo.",
"support": "Atención al cliente",
"supervisors": "Supervisores",
"surname": "Apellidos",
......

25.4 KB | W: | H:

25.2 KB | W: | H:

sails/src/assets/app/img/parents.png
sails/src/assets/app/img/parents.png
sails/src/assets/app/img/parents.png
sails/src/assets/app/img/parents.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -98,7 +98,7 @@
<div class="text-center">
<a ng-click="slide.rightTo('tutor'); formdata.role = 'tutor'">
<img src="img/parents.png" alt="{{'parents_tutor' | translate}}" title="{{'parents_tutor' | translate}}"
ng-class="{'small-img': hover_tutor}"
ng-class="{'img-200': hover_tutor}"
ng-mouseenter="hover_tutor = true"
ng-mouseleave="hover_tutor = false"/>
</a>
......@@ -109,7 +109,7 @@
<div class="text-center">
<a ng-click="slide.rightTo('therapist'); formdata.role = 'therapist'">
<img src="img/therapist.png" alt="{{'therapist' | translate}}" title="{{'therapist' | translate}}"
ng-class="{'small-img': hover_therapist}"
ng-class="{'img-200': hover_therapist}"
ng-mouseenter="hover_therapist = true"
ng-mouseleave="hover_therapist = false"/>
</a>
......@@ -120,7 +120,7 @@
<div class="text-center">
<a ng-click="slide.rightTo('office'); formdata.role = 'office'">
<img src="img/office.jpg" alt="{{'office_center' | translate}}" title="{{'office_center' | translate}}"
ng-class="{'small-img': hover_office}"
ng-class="{'img-200': hover_office}"
ng-mouseenter="hover_office = true"
ng-mouseleave="hover_office = false"/>
</a>
......
......@@ -50,17 +50,17 @@
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs tabs_student">
<!-- 0: admin, 1: tutor, 2: therapist -->
<li role="presentation" ng-class="{'active' : nav.tab == 'collections'}" ng-if="studentData.supervision != 0">
<!-- 0: admin, 1: tutor, 2: therapist -->
<li role="presentation" ng-class="{'active' : nav.tab == 'collections'}" ng-if="studentData.license.isValid && !studentData.license.isTrial">
<a href="/app/#/student/{{studentData.id}}/collections" ng-click="nav.tab = ''"><span class="glyphicon glyphicon-th" aria-hidden="true"></span> {{ 'collections' | translate }}</a>
</li>
<li role="presentation" ng-class="{'active' : nav.tab == 'instructions'}" ng-if="studentData.supervision == 2">
<li role="presentation" ng-class="{'active' : nav.tab == 'instructions'}" ng-if="studentData.license.isValid && !user.isTutor">
<a href="/app/#/student/{{studentData.id}}/instructions" ng-click="nav.tab = 'instructions'"><span class="glyphicon glyphicon-tasks" aria-hidden="true"></span> {{ 'instructions' | translate }}</a>
</li>
<li role="presentation" ng-class="{'active' : nav.tab == 'session'}" ng-if="studentData.supervision == 2">
<li role="presentation" ng-class="{'active' : nav.tab == 'session'}" ng-if="studentData.license.isValid && !user.isTutor">
<a href="/app/#/student/{{studentData.id}}/session" ng-click="nav.tab = 'session'"><span class="glyphicon glyphicon-transfer" aria-hidden="true"></span> {{ 'sessions' | translate }}</a>
</li>
<li role="presentation" ng-class="{'active' : nav.tab == 'reports'}" ng-if="studentData.supervision != 1">
<li role="presentation" ng-class="{'active' : nav.tab == 'reports'}" ng-if="studentData.license.isValid && !user.isTutor">
<a href="/app/#/student/{{studentData.id}}/reports" ng-click="nav.tab = 'reports'"><i class="fa fa-bar-chart" aria-hidden="true"></i> {{ 'reports' | translate }}</a>
</li>
<li role="presentation" ng-class="{'active' : nav.tab == 'setup'}">
......
......@@ -5,7 +5,7 @@
<button class="btn btn-default" btn-radio="'account'" ng-model="section">
<i class="fa fa-user" aria-hidden="true"></i> {{ 'account' | translate }}
</button>
<button class="btn btn-default" btn-radio="'device'" ng-model="section">
<button class="btn btn-default" btn-radio="'device'" ng-model="section" ng-if="studentData.license.isValid || studentData.license.isOfficial">
<i class="fa fa-tablet" aria-hidden="true"></i> {{ 'device' | translate }}
</button>
<button class="btn btn-default" btn-radio="'supervisors'" ng-model="section" ng-if="user.isOffice">
......@@ -76,7 +76,7 @@
<div class="row">
<div class="col-xs-2"><i class="fa fa-certificate fa-lg text-danger" aria-hidden="true"></i></div>
<div class="col-xs-10">
{{ 'license_expired_official' | translate }} <a href="http://pictogramweb.com/caracteristicas-de-pictogram/">{{ 'license_expired_renew' | translate }}</a>
{{ 'license_expired_official' | translate }} <a href="http://pictogramweb.com/caracteristicas-de-pictogram/">{{ 'license_expired_renew' | translate }}</a>.
</div>
</div>
</div>
......@@ -86,7 +86,7 @@
<div class="row">
<div class="col-xs-2"><i class="fa fa-flask fa-lg text-danger" aria-hidden="true"></i></div>
<div class="col-xs-10">
{{ 'license_expired_trial' | translate }} <a href="http://pictogramweb.com/caracteristicas-de-pictogram/">{{ 'license_expired_buy' | translate }}</a>
{{ 'license_expired_trial' | translate }} <a href="http://pictogramweb.com/caracteristicas-de-pictogram/">{{ 'license_expired_buy' | translate }}</a>.
</div>
</div>
</div>
......
......@@ -27,23 +27,6 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
$scope.minlength = CONSTANTS.password_minlength;
var formdata_empty = {
username: '',
password: '',
password_confirm: '',
name: $translate.instant('name'),
surname: $translate.instant('surname'),
birthdate: Date(),
country: 'ES',
gender: 'M',
lang: 'es-es',
notes: '',
current_method: 'no_method',
current_instruction: 'no_instruction',
license_number: null,
id_sup: $scope.user.id
};
// Hide new student form
$scope.hidestudentadd = true;
......@@ -83,7 +66,22 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
// Show student form
$scope.showForm = function () {
// Reset the form
$scope.formdata = formdata_empty;
$scope.formdata = {
username: '',
password: '',
password_confirm: '',
name: $translate.instant('name'),
surname: $translate.instant('surname'),
birthdate: Date(),
country: 'ES',
gender: 'M',
lang: 'es-es',
notes: '',
current_method: 'no_method',
current_instruction: 'no_instruction',
license_number: null,
id_sup: $scope.user.id
};
$scope.slide.state ='accounts';
$scope.slide.show = true;
......
......@@ -5,16 +5,105 @@
//--------------------------
dashboardControllers.controller('SupervisorsCtrl', function SupervisorsCtrl($scope, $window, $http, config, $translate, ngToast) {
$http
.get(config.backend+'/office/get/' + $scope.user.office.id + '/supervisors')
.success(function(data, status, headers, config) {
$scope.supervisors_list = data;
console.log($scope.supervisors_list);
})
.error(function(data, status, headers, config) {
$translate('error_downloading_supervisors').then(function (translation) {
ngToast.danger({ content: translation });
$scope.inputs = {
search_str: '',
email: ''
};
$scope.supToAdd = {};
function loadSupervisors() {
$http
.get(config.backend+'/sup/' + $scope.user.id + '/supervisors')
.success(function(data, status, headers, config) {
$scope.supervisors_list = data;
console.log($scope.supervisors_list);
})
.error(function(data, status, headers, config) {
ngToast.danger($translate.instant('error_downloading_supervisors'));
});
}
/**
* Get a supervisor by their email and updates the $scope.supToAdd element.
* The email used for search is fetched from $scope.email_sup.
*/
$scope.searchSup = function () {
if (!$scope.user.isOffice) {
console.log("Forbidden action. You're not an office!");
return;
}
if ($scope.inputs.email.length == 0)
return;
// Find tutor by email
$http.get(config.backend + '/sup/email/' + $scope.inputs.email)
.success(function (data) {
if (data) {
$scope.supToAdd = data;
$scope.showmessagesupfound = true;
} else {
ngToast.danger($translate.instant('sup_not_found'));
// Hide the success message (if it exists by other query)
$scope.showmessagesupfound = false;
}
})
.error(function () {
ngToast.danger($translate.instant('sup_not_found'));
});
};
/**
* Links a new supervisor
*/
$scope.confirmLink = function () {
if (!$scope.user.isOffice) {
console.log("Forbidden action. You're not an office!");
return;
}
$scope.showmessagesupfound = false;
$http
.post(config.backend+'/sup/' + $scope.supToAdd.id + '/off/' + $scope.user.id)
.success(function(data, status, headers, config) {
loadSupervisors();
ngToast.success($translate.instant('supervisor_added'));
})
.error(function(error) {
var message = typeof error == 'string' ? error : error.message;
if (message.search('already exists') > 0)
ngToast.danger($translate.instant('supervisor_already_linked'));
else if (message.search('yourself') > 0)
ngToast.danger($translate.instant('supervisor_yourself'));
else
ngToast.danger($translate.instant('no_supervisor_linked'));
});
};
/**
* Unlinks a supervisor
*/
$scope.unlinkSupervisor = function (id) {
if (!$scope.user.isOffice) {
console.log("Forbidden action. You're not an office!");
return;
}
$http
.delete(config.backend+'/sup/' + id + '/off/' + $scope.user.id)
.success(function(data, status, headers, config) {
loadSupervisors();
ngToast.success($translate.instant('supervisor_deleted'));
})
.error(function(data, status, headers, config) {
ngToast.danger($translate.instant('general_error'));
});
};
// MAIN
loadSupervisors();
});
......@@ -13,6 +13,29 @@
title="Pictogram" />
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li ng-class="{active: $location.url() == '/students'}">
<a href="/app/#/students">
<i class="fa fa-users" aria-hidden="true"></i> {{ 'students' | translate }}
</a>
</li>
<li ng-if="user.isOffice" ng-class="{active: $location.url() == '/supervisor/list'}">
<a class="pointer" role="menuitem" tabindex="0" href="/app/#/supervisor/list">
<i class="fa fa-users" aria-hidden="true"></i> {{ 'supervisors' | translate }}
</a>
</li>
<li ng-if="!user.isTutor" ng-class="{active: $location.url() == '/instructions'}">
<a href="/app/#/instructions">
<i class="glyphicon glyphicon-tasks" aria-hidden="true"></i> {{ 'instructions' | translate }}
</a>
</li>
<li>
<a ng-click="own_pictos()">
<i class="glyphicon glyphicon-picture" aria-hidden="true"></i> {{ 'own_pictos' | translate }}
</a>
</li>
</ul>
<div class="topbar__supervisor nav navbar-nav navbar-right">
<div class="dropdown">
<div class="topbar__supervisor__name">
......@@ -26,18 +49,18 @@
<img id="supervisor_profile" ng-src="{{user.pic}}" alt="Supervisor" title="Supervisor" />
</div>
<ul class="dropdown-menu" role="menu">
<li>
<!-- li>
<a class="pointer" role="menuitem" tabindex="0" href="/app/#/students">
<i class="fa fa-users" aria-hidden="true"></i>
{{ 'students' | translate }}
</a>
</li>
<li ng-if="user.isSupAdmin == true">
<li ng-if="user.isOffice">
<a class="pointer" role="menuitem" tabindex="0" href="/app/#/supervisor/list">
<i class="fa fa-users" aria-hidden="true"></i>
{{ 'supervisors' | translate }}
</a>
<li ng-if="user.isTutor == false">
<li ng-if="!user.isTutor">
<a class="pointer" role="menuitem" tabindex="0" href="/app/#/instructions">
<i class="glyphicon glyphicon-tasks" aria-hidden="true"></i>
{{ 'instructions' | translate }}
......@@ -48,7 +71,7 @@
<i class="glyphicon glyphicon-picture" aria-hidden="true"></i>
{{ 'own_pictos' | translate }}
</a>
</li>
</li -->
<li>
<a class="pointer" role="menuitem" tabindex="0" href="/app/#/setup">
<i class="glyphicon glyphicon-cog" aria-hidden="true"></i>
......@@ -65,4 +88,5 @@
</div>
</div>
</div>
</div>
</nav>
<!-- InstructionsCtrl controls here, see app.js -->
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title" translate>own_instructions</h3></div>
<div class="panel-heading"><h3 translate>own_instructions</h3></div>
<div class="panel-body">
......
<!-- SetupCtrl controls here, see app.js -->
<div>
<div class="page-header">
<h2 translate>setup</h2>
<h3 translate>setup</h3>
</div>
<div>
<!-- Logo Pictogram -->
......
......@@ -41,7 +41,8 @@
<td>
<i ng-show="student.license.isValid && !student.license.isTrial" class="fa fa-certificate fa-lg text-primary license-warning" aria-hidden="true" popover="{{ 'license_pro' | translate}}" popover-trigger="mouseenter"></i>
<i ng-show="student.license.isTrial && student.license.isValid" class="fa fa-flask fa-lg text-warning license-warning" aria-hidden="true" popover="{{ 'trial_license' | translate}}" popover-trigger="mouseenter"></i>
<i ng-show="!student.license.isValid" class="fa fa-exclamation-circle fa-lg text-danger license-warning" aria-hidden="true" popover="{{ 'license_missing' | translate}}" popover-trigger="mouseenter"></i>
<i ng-show="!student.license.isValid && student.license.isOfficial" class="fa fa-certificate fa-lg text-danger license-warning" aria-hidden="true" popover="{{ 'license_missing_official' | translate}}" popover-trigger="mouseenter"></i>
<i ng-show="!student.license.isValid && student.license.isTrial" class="fa fa-flask fa-lg text-danger license-warning" aria-hidden="true" popover="{{ 'license_missing_trial' | translate}}" popover-trigger="mouseenter"></i>
</td>
<td>
<h4>{{student.surname}}, {{student.name}}</h4>
......@@ -53,12 +54,12 @@
<a
class="btn btn-default btn-lg" role="button" href="/app/#/student/{{student.id}}/collections"
alt="{{ 'collections' | translate }}" popover="{{ 'collections' | translate }}" popover-trigger="mouseenter" ng-if="student.license.isValid">
alt="{{ 'collections' | translate }}" popover="{{ 'collections' | translate }}" popover-trigger="mouseenter" ng-if="student.license.isValid || student.license.isOfficial">
<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
</a>
<span
class="btn btn-default btn-lg" role="button"
alt="{{ 'collections' | translate }}" popover="{{ 'collections' | translate }}" popover-trigger="mouseenter" ng-if="!student.license.isValid">
alt="{{ 'collections' | translate }}" popover="{{ 'collections' | translate }}" popover-trigger="mouseenter" ng-if="!student.license.isValid && student.license.isTrial">
<span class="glyphicon glyphicon-th" aria-hidden="true" style="color: #bbb" ></span>
</span>
......
......@@ -20,31 +20,48 @@
<div class="col-md-4">
<legend translate>add_existing</legend>
<div class="text-center">
<a ng-click="slide.rightTo('existing')"><img src="img/child-existing.png" alt="{{'parents_tutor' | translate}}" title="{{'parents_tutor' | translate}}" /></a>
</div>
<div>
<p translate>add_existing_desc</p>
<a ng-click="slide.rightTo('existing')">
<img src="img/child-existing.png" alt="{{'parents_tutor' | translate}}" title="{{'parents_tutor' | translate}}"
ng-class="{'img-120': hover_existing}"
ng-mouseenter="hover_existing = true"
ng-mouseleave="hover_existing = false"/>
</a>
</div>
</div>
<div class="col-md-4">
<legend translate>add_new_official</legend>
<div class="text-center">
<a ng-click="slide.rightTo('new')"><img src="img/child-new.png" alt="{{'therapist' | translate}}" title="{{'therapist' | translate}}" /></a>
</div>
<div>
<p translate>add_new_official_desc</p>
<a ng-click="slide.rightTo('new')">
<img src="img/child-new.png" alt="{{'therapist' | translate}}" title="{{'therapist' | translate}}"
ng-class="{'img-120': hover_new}"
ng-mouseenter="hover_new = true"
ng-mouseleave="hover_new = false"/>
</a>
</div>
</div>
<div class="col-md-4">
<legend translate>new_test_account</legend>
<div class="text-center">
<a ng-click="slide.rightTo('test')"><img src="img/child-test.png" alt="{{'office_center' | translate}}" title="{{'office_center' | translate}}" /></a>
</div>
<div>
<p translate>new_test_account_desc</p>
<a ng-click="slide.rightTo('test')">
<img src="img/child-test.png" alt="{{'office_center' | translate}}" title="{{'office_center' | translate}}"
ng-class="{'img-120': hover_test}"
ng-mouseenter="hover_test = true"
ng-mouseleave="hover_test = false"/>
</a>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<p translate>add_existing_desc</p>
</div>
<div class="col-md-4">
<p translate>add_new_official_desc</p>
</div>
<div class="col-md-4">
<p translate>new_test_account_desc</p>
</div>
</div>
</div>
<!--
......
......@@ -4,37 +4,56 @@
<div class="panel-heading">
<div class="row">
<div class="col-xs-4">
<h5 translate>supervisors</h5>
<h3 translate>supervisors</h3>
</div>
<div class="col-xs-4">
<div class="col-xs-4 margin-top20">
<div class=" input-group">
<input type="text" ng-model="inputs.email" placeholder="{{ 'email' | translate }}" class="form-control">
<span class="input-group-btn"> <button ng-click="searchSup()" class="btn btn-success btn-sm" role="button"> {{ 'link_supervisor' | translate }}</button></span>
</div>
<!-- Alert and success messages for supervisor found -->
<div ng-show="{{ 'showmessagesupfound' }}" class="alert alert-info overlap-result">
<!-- Imagen de perfil del tutor -->
<img ng-src="{{supToAdd.pic}}" class="profile" alt="" title="" /> {{ supToAdd.name }} {{ supToAdd.surname }}
<a class="btn btn-default btn-sm pull-right" role="button" ng-click="confirmLink()" translate>add</a>
</div>
</div>
<div class="col-xs-4">
<div class="col-xs-4 margin-top20">
<div class=" input-group">
<input type="text" ng-model="search_sups" id="search_sups" placeholder="{{ 'filter' | translate }}" class="form-control" aria-describedby="basic-addon2">
<input type="text" ng-model="inputs.search_str" id="search_sups" placeholder="{{ 'filter' | translate }}" class="form-control" aria-describedby="basic-addon2">
<span class="input-group-addon"><span class="glyphicon glyphicon-search" id="basic-addon2" aria-hidden="true"></span></span>
</div>
</div>
</div>
</div>
</div>
<!-- Fin .panel-body -->
<div class="table-responsive">
<table class="table">
<table class="table" id="table_supervisors">
<thead class="thead-default">
<tr>
<th translate>supervisors</th>
<th translate>students</th>
<th class="col-xs-8" translate>supervisors</th>
<th class="col-xs-4" translate>students</th>
</tr>
</thead>
<tbody>
<tr class="active" ng-repeat="supervisor in supervisors_list | filter:search_sups | orderBy: 'name'">
<tr class="active" ng-repeat="supervisor in supervisors_list | filter:inputs.search_str | orderBy: 'name'">
<td>
<div>
<div class="row">
<div class="col-xs-2">
<div class="thumbnail">
<img ng-src="/upload/supervisorAvatar/{{supervisor.pic}}" alt="Supervisor" title="Supervisor" />
<img ng-src="{{supervisor.pic}}" alt="Supervisor" title="Supervisor" />
</div>
</div>
<div class="col-xs-10">
<div class="col-xs-1">
<a ng-click="unlinkSupervisor(supervisor.id)" class="delete_sup" title="{{ 'unlink' | translate }}">
<span class="glyphicon glyphicon-remove-circle text-danger" aria-hidden="true"></span>
</a>
</div>
<div class="col-xs-9">
<h4>{{supervisor.name}} {{supervisor.surname}}</h4>
<p><i class="fa fa-envelope" aria-hidden="true">&nbsp</i><a href="mailto:{{supervisor.email}}">{{supervisor.email}}</a></p>
<p><i class="fa fa-phone-square" aria-hidden="true"></i>&nbsp<a href="tel:{{supervisor.phone}}">{{supervisor.phone}}</a></p>
......@@ -52,6 +71,9 @@
</tr>
</tbody>
</table>
<div class="alert alert-warning" ng-if="supervisors_list.length == 0">
<strong translate>no_supervisors</strong> {{ 'no_supervisors_desc' | translate }}
</div>
</div>
</div>
......@@ -58,10 +58,18 @@
margin-top: 15px;
}
.margin-top20 {
margin-top: 20px;
}
.margin-top7 {
margin-top: 7px;
}
.margin-top10 {
margin-top: 10px;
}
.table .table-striped .striped {
background-color: lightgray !important;
}
......@@ -870,7 +878,8 @@ img.profile{
#user_tutors .list-group-item:hover .delete_tutor,
#user_sups .list-group-item:hover .delete_sup,
#table_students tr:hover .delete_stu{
#table_supervisors tr:hover .delete_sup,
#table_students tr:hover .delete_stu {
opacity: 1;
}
......@@ -1103,12 +1112,21 @@ input.editable.scene-name {
float: right;
}
.float-left {
float: left;
}
/* Cambiar tamaño imagen */
.small-img {
.img-200 {
margin-top: 25px;
width: 200px;
}
.img-120 {
margin-top: 25px;
width: 120px;
}
/* Estilos para ngSwitch */
.switch-panel-body {
position:relative;
......@@ -1162,3 +1180,9 @@ input.editable.scene-name {
.switch-panel {
overflow:hidden;
}
.overlap-result {
z-index:20;
position:absolute;
width:100%
}
......@@ -46,11 +46,11 @@ module.exports.policies = {
},
MetaMethodController: {
supVisible: ['tokenAuth'],
supOwned: ['tokenAuth'],
create: ['tokenAuth'],
update: ['tokenAuth'],
destroy: ['tokenAuth']
supVisible: ['tokenAuth'],
supOwned: ['tokenAuth'],
create: ['tokenAuth'],
update: ['tokenAuth'],
destroy: ['tokenAuth']
},
MethodController: {
......@@ -61,13 +61,6 @@ module.exports.policies = {
destroy: ['tokenAuth'],
},
OfficeController: {
getAll: true,
get: ['tokenAuth'],
getBasic: true,
supervisors: ['tokenAuth', 'isAdminOrOffice']
},
PictoController: {
upload: ['tokenAuth'],
add_tag: ['tokenAuth'],
......@@ -156,7 +149,10 @@ module.exports.policies = {
upload: ['tokenAuth'],
subscribe: ['tokenAuth'],
unsubscribe: ['tokenAuth'],
delete: ['tokenAuth', 'isAdmin']
delete: ['tokenAuth', 'isAdmin'],
supervisors: ['tokenAuth', 'isOffice'],
link_supervisor: ['tokenAuth', 'isOffice'],
unlink_supervisor: ['tokenAuth', 'isOffice']
},
TryController: {
......
......@@ -55,11 +55,6 @@ module.exports.routes = {
'PUT /method/template/:id': 'MetaMethodController.update',
'DELETE /method/template/:id': 'MetaMethodController.destroy',
'GET /office/get_all': 'OfficeController.getAll',
'GET /office/:code': 'OfficeController.getBasic',
'GET /office/get/:id': 'OfficeController.get',
'GET /office/get/:id/supervisors': 'OfficeController.supervisors',
'GET /picto/:lang/pic_categories/:id_cat': 'PictoController.categories',
'GET /picto/:lang/pic_fromcategory/:id_cat': 'PictoController.fromcategory',
'GET /picto/:lang/pic_fromSymbolStx/page/:page/limit/:limit': 'PictoController.fromSymbolStx',
......@@ -126,6 +121,9 @@ module.exports.routes = {
'GET /sup/all': 'SupervisorController.list',
'GET /sup/:id/students': 'SupervisorController.students',
'GET /sup/:id/supervisors': 'SupervisorController.supervisors',
'POST /sup/:id_sup/off/:id_off': 'SupervisorController.link_supervisor',
'DELETE /sup/:id_sup/off/:id_off': 'SupervisorController.unlink_supervisor',
'GET /sup/:id/pictos': 'SupervisorController.pictos',
'GET /sup/email/:email': 'SupervisorController.getByEmail',
......
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