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
f7a63b48
authored
Sep 20, 2016
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issue #583 fixed
parent
ac58b697
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
78 additions
and
46 deletions
sails/src/api/controllers/StudentController.js
sails/src/api/controllers/SupervisorController.js
sails/src/api/models/Student.js
sails/src/api/models/VStuLastInstruction.js
sails/src/assets/scripts/modules/student/views/header.html
sails/src/assets/scripts/modules/supervisor/controllers/students.js
sails/src/assets/scripts/modules/supervisor/views/students.html
sails/src/config/csrf.js
sails/src/api/controllers/StudentController.js
View file @
f7a63b48
...
...
@@ -100,25 +100,27 @@ module.exports = {
* }
*/
getInfo
:
function
(
req
,
res
)
{
Student
.
findOne
({
id
:
req
.
params
.
id_stu
})
Student
.
findOne
({
id
:
req
.
params
.
id_stu
})
.
populate
(
'lastInstruction'
)
.
then
(
function
(
student
)
{
if
(
!
student
)
throw
new
Error
(
"student not found"
);
student
.
current_method
=
null
;
student
.
current_instruction
=
null
;
student
.
current_method
=
student
.
lastInstruction
[
0
]
?
student
.
lastInstruction
[
0
].
met_name
:
"no_method"
;
student
.
current_instruction
=
student
.
lastInstruction
[
0
]
?
student
.
lastInstruction
[
0
].
ins_name
:
"no_instruction"
;
// recover last instruction to complete student info
var
stu_last_inst
=
VStuLastInstruction
.
findOne
({
student
:
student
.
id
})
.
then
(
function
(
stu_last_inst
)
{
return
stu_last_inst
;
});
})
.
error
(
err
=>
{
throw
err
});
// determine supervision level of the requester on the student
var
stu_sup
=
StuSup
.
findOne
({
id_stu
:
student
.
id
,
id_sup
:
req
.
token
.
id
})
.
then
(
function
(
stu_sup
)
{
return
stu_sup
});
return
stu_sup
;
})
.
error
(
err
=>
{
throw
err
});
return
[
student
,
stu_last_inst
,
stu_sup
];
})
...
...
sails/src/api/controllers/SupervisorController.js
View file @
f7a63b48
...
...
@@ -392,39 +392,63 @@ module.exports = {
* ]
*/
students
:
function
(
req
,
res
)
{
Supervisor
.
findOne
({
id
:
req
.
params
.
id
}).
then
(
function
(
supervisor
)
{
if
(
supervisor
)
{
StuSup
.
find
({
supervisor
:
supervisor
.
id
}).
populate
(
'student'
).
then
(
function
(
stuSups
)
{
var
students
=
stuSups
.
map
(
function
(
stuSup
)
{
Supervisor
.
findOne
({
id
:
req
.
params
.
id
})
.
then
(
function
(
supervisor
)
{
if
(
!
supervisor
)
throw
new
Error
(
"Not a valid supervisor"
)
// Get all stu_sup relations
StuSup
.
find
({
supervisor
:
supervisor
.
id
})
.
populate
(
'student'
)
.
then
(
function
(
stuSups
)
{
var
students
=
[];
async
.
each
(
stuSups
,
function
(
stuSup
,
cb
)
{
var
student
=
stuSup
.
student
;
student
.
supervision
=
req
.
token
.
office
?
2
:
1
;
return
student
;
});
if
(
req
.
token
.
isSupAdmin
&&
req
.
token
.
office
&&
req
.
token
.
office
.
id
)
{
Student
.
find
({
office
:
req
.
token
.
office
.
id
}).
then
(
function
(
officeStudents
)
{
students
=
students
.
concat
(
officeStudents
);
students
=
students
.
map
((
student
)
=>
{
student
.
supervision
=
student
.
supervision
||
0
;
return
student
;
});
res
.
ok
(
lodash
.
uniq
(
students
,
false
,
'id'
));
VStuLastInstruction
.
findOne
({
student
:
student
.
id
})
.
then
(
function
(
stu_last_inst
)
{
student
.
current_method
=
stu_last_inst
?
stu_last_inst
.
met_name
:
"no_method"
;
student
.
current_instruction
=
stu_last_inst
?
stu_last_inst
.
ins_name
:
"no_instruction"
;
students
.
push
(
student
);
cb
();
})
.
catch
(
function
()
{
res
.
serverError
();
.
error
(
err
=>
{
students
.
push
(
student
);
cb
();
});
}
else
{
res
.
ok
(
students
);
}
})
.
catch
(
function
()
{
res
.
serverError
();
});
}
else
{
res
.
badRequest
();
}
},
function
(
err
)
{}
);
return
students
;
})
.
then
(
function
(
students
)
{
// Get all students from the office if user is administrator
if
(
req
.
token
.
isSupAdmin
&&
req
.
token
.
office
&&
req
.
token
.
office
.
id
)
{
Student
.
find
({
office
:
req
.
token
.
office
.
id
}).
populate
(
'lastInstruction'
)
.
then
(
function
(
officeStudents
)
{
officeStudents
=
officeStudents
.
map
((
student
)
=>
{
student
.
supervision
=
student
.
supervision
||
0
;
student
.
current_method
=
student
.
lastInstruction
[
0
]
?
student
.
lastInstruction
[
0
].
met_name
:
"no_method"
;
student
.
current_instruction
=
student
.
lastInstruction
[
0
]
?
student
.
lastInstruction
[
0
].
ins_name
:
"no_instruction"
;
return
student
;
});
students
=
students
.
concat
(
officeStudents
);
res
.
ok
(
lodash
.
uniq
(
students
,
false
,
'id'
));
})
.
catch
(
function
(
err
)
{
res
.
serverError
(
"Error "
+
err
);
});
}
else
res
.
ok
(
students
);
})
.
catch
(
err
=>
{
throw
err
});
})
.
catch
(
function
()
{
res
.
serverError
();
.
catch
(
function
(
err
)
{
res
.
serverError
(
"Error "
+
err
);
});
},
...
...
sails/src/api/models/Student.js
View file @
f7a63b48
...
...
@@ -75,17 +75,22 @@ module.exports = {
},
// Relación con StuSup
stuSup
:
{
collection
:
'
StuS
up'
,
collection
:
'
stus
up'
,
via
:
'student'
},
// Relación con Method. [1 Student to N Method]
methods
:
{
collection
:
'
M
ethod'
,
collection
:
'
m
ethod'
,
via
:
'student'
},
// Relación con StuPicto. [1 Student to N StuPicto]
stuPicto
:
{
collection
:
'StuPicto'
,
collection
:
'stupicto'
,
via
:
'student'
},
// Relación con VStuLastInstruction [1 Student to 1 StuPicto]
lastInstruction
:
{
collection
:
'vstulastinstruction'
,
via
:
'student'
},
...
...
@@ -166,7 +171,7 @@ module.exports = {
legend_size
:
'normal'
,
size
:
'normal'
,
picto_background
:
'#0000ff'
,
tape_background
:
'#00ffff'
tape_background
:
'#00ffff'
,
};
sails
.
log
.
verbose
(
'Requested attributes for Student'
,
attributes
);
...
...
sails/src/api/models/VStuLastInstruction.js
View file @
f7a63b48
...
...
@@ -14,7 +14,7 @@ module.exports = {
autoPK
:
false
,
autoCreatedAt
:
false
,
autoUpdatedAt
:
false
,
attributes
:
{
workingSession
:
{
columnName
:
'id_ws'
,
...
...
@@ -36,7 +36,7 @@ module.exports = {
ins_name
:
{
// instruction name
columnName
:
'ins_name'
,
type
:
"string"
,
},
},
met_name
:
{
// method name
columnName
:
"met_name"
,
type
:
"string"
,
...
...
@@ -46,7 +46,7 @@ module.exports = {
required
:
true
,
primaryKey
:
true
,
unique
:
true
,
type
:
"integer"
,
model
:
"Student"
}
}
};
\ No newline at end of file
};
sails/src/assets/scripts/modules/student/views/header.html
View file @
f7a63b48
...
...
@@ -22,7 +22,7 @@
<div
class=
"col-md-10"
>
<div
style=
"margin-left: 5px"
><h4>
{{studentData.name}} {{studentData.surname}}
</h4></div>
<div
style=
"margin-left: 5px"
class=
"text-left"
>
<span>
{{studentData.current_instruction | translate}}
</span>
<span>
{{studentData.current_instruction | translate}}
</span>
<br/>
<span
class=
"text-muted"
>
({{studentData.current_method | translate}})
</span>
</div>
</div>
...
...
sails/src/assets/scripts/modules/supervisor/controllers/students.js
View file @
f7a63b48
...
...
@@ -40,6 +40,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
console
.
log
(
"currentStudents: "
+
$scope
.
user
.
office
.
currentStudents
);
console
.
log
(
"maxStudents: "
+
$scope
.
user
.
office
.
maxStudents
);
// Compute number of licenses left
if
(
$scope
.
user
.
office
.
currentStudents
>=
$scope
.
user
.
office
.
maxStudents
)
{
$scope
.
num_licenses_left
=
0
;
}
else
{
...
...
@@ -51,6 +52,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
$scope
.
user
.
office
=
{
name
:
''
};
}
// Hide new student form
$scope
.
hidestudentadd
=
true
;
// Get list of supervisor's students
...
...
sails/src/assets/scripts/modules/supervisor/views/students.html
View file @
f7a63b48
...
...
@@ -36,7 +36,7 @@
<h4>
{{student.name}} {{student.surname}}
</h4>
</td>
<td>
<p>
{{student.current_method}}
<br
/>
{{student.current_instruction}}
</p>
<p>
<span>
{{student.current_method | translate}}
</span>
<br
/>
<span
class=
"text-muted"
>
{{student.current_instruction | translate}}
</span>
</p>
</td>
<td>
<!-- BUTTONS -->
...
...
sails/src/config/csrf.js
View file @
f7a63b48
...
...
@@ -48,7 +48,7 @@
* *
****************************************************************************/
//
module.exports.csrf = fals
e;
//
module.exports.csrf = tru
e;
/****************************************************************************
* *
...
...
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