Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5ce08a09
authored
Nov 06, 2017
by
Sebastián Collado Montañez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
new_grid_system improvement
parent
9c9c171d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
14 deletions
sails/roles/database/files/new-grid-system-adapt.sql
sails/roles/database/files/new-grid-system-adapt.sql
View file @
5ce08a09
...
...
@@ -29,30 +29,31 @@ BEGIN
FETCH
cursor_stu_picto
INTO
_id_stu_picto
,
_id_stu
,
_attributes
;
-- Control para la finalizacion del bucle
IF
done
THEN
LEAVE
read_loop
;
END
IF
;
-- Carga las variables desde el JSON para free_category_coord e id_cat
SELECT
_attributes
->>
"$.free_category_coord_x"
INTO
_free_category_coord_x
;
SELECT
_attributes
->>
"$.free_category_coord_y"
INTO
_free_category_coord_y
;
SELECT
_attributes
->>
"$.id_cat"
INTO
_id_cat
;
-- Esto hay que hacerlo porque el null procediente del JSON para id_cat lo reconoce como un literal
...
IF
_
attributes
->>
"$.id_cat"
=
'null'
THEN
-- Esto hay que hacerlo porque el null procediente del JSON para id_cat lo reconoce como un literal
IF
_
id_cat
=
'null'
THEN
SET
_id_cat
=
NULL
;
ELSE
SELECT
_attributes
->>
"$.id_cat"
INTO
_id_cat
;
END
IF
;
-- Pictogramas que estan en escenas sin categorias
IF
(
_free_category_coord_x
IS
NOT
NULL
)
OR
(
_free_category_coord_y
IS
NOT
NULL
)
THEN
-- Pasa las coordenadas libres a coord_x y coord_y
-- Pasa las coordenadas libres a coord_x y coord_y
, ademas elimina variables antiguas
UPDATE
stu_picto
SET
`attributes`
=
JSON_REPLACE
(
`attributes`
,
'$.coord_x'
,
_free_category_coord_x
),
`attributes`
=
JSON_REPLACE
(
`attributes`
,
'$.coord_y'
,
_free_category_coord_y
),
`attributes`
=
JSON_RE
PLACE
(
`attributes`
,
'$.free_category_coord_x'
,
NULL
),
`attributes`
=
JSON_RE
PLACE
(
`attributes`
,
'$.free_category_coord_y'
,
NULL
)
`attributes`
=
JSON_RE
MOVE
(
`attributes`
,
'$.free_category_coord_x'
),
`attributes`
=
JSON_RE
MOVE
(
`attributes`
,
'$.free_category_coord_y'
)
WHERE
id
=
_id_stu_picto
;
-- Pictogramas que estan en escenas con categorias
...
...
@@ -70,13 +71,25 @@ BEGIN
-- Verifico si existe una escena con dicho nombre para el alumno actual
SELECT
COUNT
(
*
)
FROM
grid
WHERE
name
=
_grid_name
AND
id_stu
=
_id_stu
INTO
_grid_instances
;
-- Si el nombre de la escena existe mas de una vez, no sabemos a cual corresponde, lo notificamos
IF
(
_grid_instances
>
1
)
THEN
SELECT
concat
(
"El tablero ("
,
_grid_name
,
") existe ("
,
_grid_instances
,
") veces para el estudiante ("
,
_id_stu
,
")"
);
END
IF
;
-- La escena ya existe, asocio el pictograma a dicha escena
IF
(
_grid_instances
=
1
)
THEN
SELECT
id_grid
FROM
grid
WHERE
name
=
_grid_name
AND
id_stu
=
_id_stu
LIMIT
1
INTO
_grid_id
;
-- Actualiza el id_grid al que pertenece el picto
UPDATE
stu_picto
SET
id_grid
=
_grid_id
WHERE
id
=
_id_stu_picto
;
-- Se pone id_cat a NULL, puesto que dicho valor no lo volveremos a necesitar
UPDATE
stu_picto
SET
`attributes`
=
JSON_REMOVE
(
`attributes`
,
'$.id_cat'
)
WHERE
id
=
_id_stu_picto
;
END
IF
;
-- La escena no existe, la creo, la asocio con el picto padre y asocio el pictograma actual a dicha escena
...
...
@@ -87,7 +100,7 @@ BEGIN
-- Esta nueva escena es siempre hija de algun pictograma, lo busco para asociarlo a dicha escena
SELECT
id_pic
FROM
picto_exp
WHERE
`text`
=
_grid_name
INTO
_id_pic
;
SELECT
id
FROM
stu_picto
WHERE
id_pic
=
_id_pic
AND
id_stu
=
_id_stu
AND
id_child_grid
IS
NULL
INTO
_id_parent_picto
;
SELECT
id
FROM
stu_picto
WHERE
id_pic
=
_id_pic
AND
id_stu
=
_id_stu
AND
id_child_grid
IS
NULL
LIMIT
1
INTO
_id_parent_picto
;
-- Actualizo id_child_grid para el pictograma padre
UPDATE
stu_picto
...
...
@@ -98,13 +111,13 @@ BEGIN
UPDATE
stu_picto
SET
id_grid
=
LID
WHERE
id
=
_id_stu_picto
;
END
IF
;
-- Se pone id_cat a NULL, puesto que dicho valor no lo volveremos a necesitar
UPDATE
stu_picto
SET
`attributes`
=
JSON_REPLACE
(
`attributes`
,
'$.id_cat'
,
NULL
)
WHERE
id
=
_id_stu_picto
;
-- Se pone id_cat a NULL, puesto que dicho valor no lo volveremos a necesitar
UPDATE
stu_picto
SET
`attributes`
=
JSON_REMOVE
(
`attributes`
,
'$.id_cat'
,
NULL
)
WHERE
id
=
_id_stu_picto
;
END
IF
;
END
IF
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment