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
4ac513e9
authored
Nov 17, 2016
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
solved problems with student creation (picto core addition and list refresh)
parent
2a41c00b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
51 deletions
sails/roles/database/files/triggers-enrolments-integrity-constraints.sql
sails/src/api/controllers/StudentController.js
sails/src/api/models/Student.js
sails/src/assets/scripts/modules/supervisor/controllers/students.js
sails/src/assets/scripts/modules/supervisor/views/students.html
sails/roles/database/files/triggers-enrolments-integrity-constraints.sql
View file @
4ac513e9
...
@@ -53,6 +53,16 @@ thisTrigger: BEGIN
...
@@ -53,6 +53,16 @@ thisTrigger: BEGIN
current_students
=
current_students
+
1
current_students
=
current_students
+
1
WHERE
WHERE
office
.
id
=
new
.
id_off
;
office
.
id
=
new
.
id_off
;
INSERT
INTO
stu_picto
(
id_stu
,
id_pic
,
attributes
)
SELECT
new
.
id
,
id_pic
,
concat
(
'{"id_cat":'
,
if
(
id_cat_pic
is
null
,
'null'
,
id_cat_pic
),
',"coord_x":'
,
coord_x
,
',"coord_y":'
,
coord_y
,
',"status":"invisible"'
,
',"highlight":false'
,
',"color":'
,
if
(
color
is
null
,
'null'
,
concat
(
'"'
,
color
,
'"'
)),
'}'
)
as
attributes
FROM
picto_core
P
;
END
;;
END
;;
-- Integrity rule 3: office.current_enrolments and supervisor assigments updating.
-- Integrity rule 3: office.current_enrolments and supervisor assigments updating.
...
...
sails/src/api/controllers/StudentController.js
View file @
4ac513e9
...
@@ -158,7 +158,7 @@ module.exports = {
...
@@ -158,7 +158,7 @@ module.exports = {
Student
.
create
(
params
)
Student
.
create
(
params
)
.
then
(
function
(
created
)
{
.
then
(
function
(
created
)
{
sails
.
log
.
debug
(
'Student '
+
created
.
id
+
' created: '
+
JSON
.
stringify
(
created
));
sails
.
log
.
debug
(
'Student '
+
created
.
id
+
' created: '
+
JSON
.
stringify
(
created
));
return
res
.
ok
(
{
student
:
created
}
);
return
res
.
ok
(
created
);
})
})
.
error
(
function
(
err
)
{
.
error
(
function
(
err
)
{
if
(
err
.
message
.
search
(
"Maximum number of enrolments reached"
)
>
0
)
{
if
(
err
.
message
.
search
(
"Maximum number of enrolments reached"
)
>
0
)
{
...
@@ -169,8 +169,8 @@ module.exports = {
...
@@ -169,8 +169,8 @@ module.exports = {
return
res
.
serverError
(
err
.
message
);
return
res
.
serverError
(
err
.
message
);
}
}
else
{
else
{
sails
.
log
.
debug
(
err
);
sails
.
log
.
debug
(
err
.
message
);
return
res
.
serverError
(
err
);
return
res
.
serverError
(
err
.
message
);
}
}
});
});
},
},
...
...
sails/src/api/models/Student.js
View file @
4ac513e9
...
@@ -238,53 +238,6 @@ module.exports = {
...
@@ -238,53 +238,6 @@ module.exports = {
},
},
/**
/**
* Sets initial vocabulary of students to Picto Core
* @param {Object} attrs All student properties stored
* @param {Function} next Function to be executed when the check process
* has been completed (an error object will be passed
* to the function if necesary)
*/
afterCreate
:
function
(
attrs
,
next
)
{
// Assign the initial collection of pictos to the student
PictoCore
.
find
()
.
then
(
function
(
pictoCore
)
{
var
i
;
// Every picto from 'picto_core_cat' is going to be created
// in 'stu_picto'
for
(
var
i
=
0
;
i
<
pictoCore
.
length
;
i
++
)
{
StuPicto
.
create
({
student
:
created
.
id
,
picto
:
pictoCore
[
i
].
picto
,
attributes
:
{
id_cat
:
pictoCore
[
i
].
category
,
coord_x
:
pictoCore
[
i
].
coord_x
,
coord_y
:
pictoCore
[
i
].
coord_y
,
status
:
'invisible'
,
// Default, the pictos don't appear to the user
color
:
pictoCore
[
i
].
color
}
})
.
then
(
function
(
stuPictoError
,
added
)
{
if
(
added
)
{
sails
.
log
.
debug
(
'Picto '
+
added
.
picto
+
' added to student '
+
created
.
id
+
' with attributes: '
+
JSON
.
stringify
(
added
.
attributes
));
}
})
.
error
(
function
(
err
)
{
sails
.
log
.
debug
(
'StuPicto.create: '
+
err
);
throw
err
;
});
}
next
();
})
.
error
(
function
(
err
)
{
next
(
err
);
});
},
/**
* Checks the given properties before updating a new Student
* Checks the given properties before updating a new Student
* @param {Object} attrs All student properties to be stored
* @param {Object} attrs All student properties to be stored
* @param {Function} next Function to be executed when the check process
* @param {Function} next Function to be executed when the check process
...
...
sails/src/assets/scripts/modules/supervisor/controllers/students.js
View file @
4ac513e9
...
@@ -137,6 +137,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
...
@@ -137,6 +137,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
errorMessage
=
'invalid_fields'
;
errorMessage
=
'invalid_fields'
;
ngToast
.
danger
({
content
:
$translate
.
instant
(
errorMessage
)
});
ngToast
.
danger
({
content
:
$translate
.
instant
(
errorMessage
)
});
});
});
};
};
...
...
sails/src/assets/scripts/modules/supervisor/views/students.html
View file @
4ac513e9
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
"panel panel-default"
>
<div
class=
"panel panel-default"
>
<!-- Default panel contents -->
<!-- Default panel contents -->
<div
class=
"panel-heading"
><h3
class=
"panel-title"
translate
>
students
</h3>
<div
class=
"panel-heading"
><h3
class=
"panel-title"
translate
>
students
</h3>
<
span
ng-if=
"user.isAdmin"
>
({{user.office.currentStudents}}/{{user.office.maxStudents}} -
<span
translate=
"licenses_left"
translate-values=
"{number: num_licenses_left}"
></span>
)
</span
>
<
!-- span ng-if="user.isAdmin">({{user.office.currentStudents}}/{{user.office.maxStudents}} - <span translate="licenses_left" translate-values="{number: num_licenses_left}"></span>)</span --
>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<!-- Add Student Form -->
<!-- Add Student Form -->
...
...
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