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
9a22eecc
authored
Sep 28, 2016
by
Sebastián Collado
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Working on issue #588
parent
dc05f9d3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
17 deletions
sails/src/api/models/Student.js
sails/src/api/models/Student.js
View file @
9a22eecc
...
...
@@ -452,23 +452,70 @@ module.exports = {
var
l_met
=
[];
Method
.
find
({
id_stu
:
id_stu
}).
exec
(
function
(
err
,
methods
)
{
Method
.
find
({
id_stu
:
id_stu
})
.
populate
(
'instructions'
)
.
then
((
methods
)
=>
{
if
(
!
methods
||
methods
.
length
==
0
)
return
callback
([]);
// Recorremos methods
async
.
eachSeries
(
methods
,
function
(
method
,
next_met
)
{
if
(
!
method
.
instructions
||
method
.
instructions
.
length
==
0
)
next_met
();
var
l_ws
=
[];
// Recorremos instructions
async
.
eachSeries
(
method
.
instructions
,
function
(
instruction
,
next_inst
)
{
Instruction
.
findOne
({
id
:
instruction
})
.
populate
(
'workingSessions'
)
.
then
((
instruction
)
=>
{
if
(
!
instruction
)
return
next_inst
();
if
(
!
instruction
.
workingSessions
||
instruction
.
workingSessions
.
length
==
0
)
return
next_inst
();
// Recorremos workingSessions
var
l_try
=
[];
async
.
eachSeries
(
instruction
.
workingSessions
,
function
(
ws
,
next_ws
)
{
WorkingSession
.
findOne
({
id
:
ws
.
id
})
.
populate
(
tries
)
.
then
((
found_ws
)
=>
{
if
(
!
found_ws
||
!
found_ws
.
tries
||
found_ws
.
tries_length
==
0
)
return
next_ws
();
// POR FIN!!! Tenemos un método, una instrucción, una working session y sus tries
l_try
=
found_ws
.
tries
;
})
},
function
(
err
)
{
if
(
err
)
return
next_ws
();
next_inst
();
});
})
.
catch
(
err
=>
{
if
(
err
||
!
methods
||
methods
.
length
==
0
)
return
callback
(
err
,
[]);
});
})
.
catch
((
err
)
=>
{
next_inst
();
});
},
function
(
err
)
{
}
);
// eachSeries
async
.
eachSeries
(
// 1st array of items
methods
,
// 2nd function to operate over one item
function
(
method
,
next
)
{
// Original: Devolver el objeto con el método completo / instructions / workinSessions / Tries
// y controlar en Angular
//Instruction.find({ id_met: method.id }).populate('tries').exec(function(err, instructions) {
Instruction
.
find
({
id_met
:
method
.
id
}).
populate
(
'workingSessions'
).
exec
(
function
(
err
,
instructions
)
{
if
(
err
||
!
instructions
||
instructions
.
length
==
0
)
console
.
log
(
"error finding instructions"
);
.
populate
(
'workingSessions'
)
.
then
((
instructions
)
{
if
(
instructions
&&
instructions
.
length
==
0
)
// Push method
l_met
.
push
({
...
...
@@ -481,7 +528,7 @@ module.exports = {
"instructions"
:
instructions
,
});
nex
t
();
next_me
t
();
});
},
...
...
@@ -494,8 +541,13 @@ module.exports = {
// with the list
}
);
});
})
.
catch
((
err
)
=>
{
if
(
err
)
return
callback
(
err
,
[]);
});
},
// Removes logically a student
...
...
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