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
25c0f999
authored
Mar 14, 2016
by
Fernando Martínez Santiago
Committed by
Arturo Montejo Ráez
Mar 14, 2016
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Several bugs regarding JSON structure for vocabulary delete and update operations
parent
21fc48ba
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
30 deletions
sails/src/api/controllers/StudentController.js
sails/src/assets/app/i18n/en-gb.json
sails/src/assets/app/i18n/es-es.json
sails/src/assets/app/modules/student/controllers/addpicto.js
sails/src/assets/app/modules/student/controllers/student.js
sails/src/assets/app/modules/student/views/header.html
sails/src/api/controllers/StudentController.js
View file @
25c0f999
...
@@ -538,6 +538,7 @@ module.exports = {
...
@@ -538,6 +538,7 @@ module.exports = {
//
//
delete_picto
:
function
(
req
,
res
)
{
delete_picto
:
function
(
req
,
res
)
{
var
params
=
req
.
allParams
();
var
params
=
req
.
allParams
();
console
.
log
(
JSON
.
stringify
(
params
));
console
.
log
(
JSON
.
stringify
(
params
));
StuPicto
.
destroy
({
id
:
params
.
id_stuPicto
}).
exec
(
function
(
err
,
destroyed
)
{
StuPicto
.
destroy
({
id
:
params
.
id_stuPicto
}).
exec
(
function
(
err
,
destroyed
)
{
if
(
err
)
{
if
(
err
)
{
...
@@ -545,11 +546,11 @@ module.exports = {
...
@@ -545,11 +546,11 @@ module.exports = {
return
res
.
json
(
500
,
{
error
:
'Not removed picto for student'
});
return
res
.
json
(
500
,
{
error
:
'Not removed picto for student'
});
}
}
if
(
destroyed
)
{
if
(
destroyed
)
{
console
.
log
(
"Removed picto
for the student"
);
console
.
log
(
"Removed picto
"
+
destroyed
[
0
].
id_pic
+
"for the student "
);
return
res
.
json
({
return
res
.
json
({
"id"
:
destroyed
[
0
].
id
,
id
:
destroyed
[
0
].
id
,
"attributes"
:
JSON
.
parse
(
destroyed
[
0
].
attributes
),
attributes
:
JSON
.
parse
(
destroyed
[
0
].
attributes
),
"picto"
:
destroyed
[
0
].
id_pic
picto
:
{
id
:
destroyed
[
0
].
id_pic
}
});
});
}
}
});
});
...
@@ -560,7 +561,7 @@ module.exports = {
...
@@ -560,7 +561,7 @@ module.exports = {
//
//
update_picto
:
function
(
req
,
res
)
{
update_picto
:
function
(
req
,
res
)
{
var
params
=
req
.
allParams
();
var
params
=
req
.
allParams
();
console
.
log
(
"Updating attributes for picto student "
+
params
);
console
.
log
(
"Updating attributes for picto student "
+
JSON
.
stringify
(
params
)
);
console
.
log
(
JSON
.
stringify
(
params
));
console
.
log
(
JSON
.
stringify
(
params
));
query
=
params
.
id_stuPicto
?
{
id
:
params
.
id_stuPicto
}
query
=
params
.
id_stuPicto
?
{
id
:
params
.
id_stuPicto
}
...
@@ -572,7 +573,12 @@ module.exports = {
...
@@ -572,7 +573,12 @@ module.exports = {
}
}
if
(
updated
)
{
if
(
updated
)
{
console
.
log
(
"Updated attributes for picto student:"
+
JSON
.
stringify
(
updated
[
0
]));
console
.
log
(
"Updated attributes for picto student:"
+
JSON
.
stringify
(
updated
[
0
]));
return
res
.
json
(
updated
[
0
]);
// return res.json(updated[0]);
return
res
.
json
({
id
:
updated
[
0
].
id
,
attributes
:
updated
[
0
].
attributes
,
picto
:
{
id
:
updated
[
0
].
picto
}
});
}
}
});
});
},
},
...
@@ -665,6 +671,11 @@ module.exports = {
...
@@ -665,6 +671,11 @@ module.exports = {
if
(
req
.
isSocket
)
{
if
(
req
.
isSocket
)
{
sails
.
log
.
debug
(
"Inside /stu/subscribe - isSocket"
);
sails
.
log
.
debug
(
"Inside /stu/subscribe - isSocket"
);
sails
.
sockets
.
join
(
req
.
socket
,
roomName
);
sails
.
sockets
.
join
(
req
.
socket
,
roomName
);
sails
.
io
.
sockets
.
in
(
roomName
).
clients
(
function
(
err
,
ids
)
{
sails
.
log
.
debug
(
"number of clients in room: "
+
ids
.
length
);
if
(
!
err
)
sails
.
io
.
to
(
roomName
).
emit
(
'update_peers'
,
{
count
:
ids
.
length
});
});
res
.
json
({
res
.
json
({
msg
:
"Subscribed to student "
+
roomName
msg
:
"Subscribed to student "
+
roomName
});
});
...
@@ -691,8 +702,8 @@ module.exports = {
...
@@ -691,8 +702,8 @@ module.exports = {
sails
.
sockets
.
leave
(
req
.
socket
,
rooms
[
i
]);
sails
.
sockets
.
leave
(
req
.
socket
,
rooms
[
i
]);
sails
.
log
.
debug
(
"Unsusbscribe from room "
+
rooms
[
i
]);
sails
.
log
.
debug
(
"Unsusbscribe from room "
+
rooms
[
i
]);
}
}
res
.
json
({
res
.
json
({
msg
:
"Unsubscribed from all rooms"
msg
:
"Unsubscribed from all rooms"
});
});
}
}
...
...
sails/src/assets/app/i18n/en-gb.json
View file @
25c0f999
...
@@ -143,6 +143,7 @@
...
@@ -143,6 +143,7 @@
"normal"
:
"Normal"
,
"normal"
:
"Normal"
,
"notes"
:
"Notes"
,
"notes"
:
"Notes"
,
"November"
:
"November"
,
"November"
:
"November"
,
"num_peers"
:
"Peers"
,
"num_sessions_per_day_in"
:
"Sessions per day in"
,
"num_sessions_per_day_in"
:
"Sessions per day in"
,
"num_sessions_per_month_in"
:
"Sessions per months in"
,
"num_sessions_per_month_in"
:
"Sessions per months in"
,
"objetive"
:
"Objetive"
,
"objetive"
:
"Objetive"
,
...
...
sails/src/assets/app/i18n/es-es.json
View file @
25c0f999
...
@@ -143,6 +143,7 @@
...
@@ -143,6 +143,7 @@
"normal"
:
"Normal"
,
"normal"
:
"Normal"
,
"notes"
:
"Notas"
,
"notes"
:
"Notas"
,
"November"
:
"Noviembre"
,
"November"
:
"Noviembre"
,
"num_peers"
:
"Conectados"
,
"num_sessions_per_day_in"
:
"Número de sesiones por día en"
,
"num_sessions_per_day_in"
:
"Número de sesiones por día en"
,
"num_sessions_per_month_in"
:
"Número de sesiones por meses en"
,
"num_sessions_per_month_in"
:
"Número de sesiones por meses en"
,
"objetive"
:
"Objetivo"
,
"objetive"
:
"Objetivo"
,
...
...
sails/src/assets/app/modules/student/controllers/addpicto.js
View file @
25c0f999
...
@@ -136,7 +136,7 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
...
@@ -136,7 +136,7 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
};
};
$scope
.
alert
=
{
type
:
'danger'
,
msg
:
'Category is full of pictos.'
,
show
:
false
};
$scope
.
alert
=
{
type
:
'danger'
,
msg
:
'Category is full of pictos.'
,
show
:
false
};
//
//
// Close alert message
// Close alert message
//
//
...
@@ -352,6 +352,7 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
...
@@ -352,6 +352,7 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
})
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
console
.
log
(
"Error from API: "
+
data
.
error
);
alert
(
'Pictogram is already part of this vocabulary'
);
});
});
}
}
...
...
sails/src/assets/app/modules/student/controllers/student.js
View file @
25c0f999
...
@@ -23,7 +23,8 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
...
@@ -23,7 +23,8 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
id
:
''
,
id
:
''
,
name
:
''
name
:
''
},
},
stuSup
:
[]
stuSup
:
[],
num_peers
:
1
};
};
// For the user form data in setup section
// For the user form data in setup section
...
@@ -34,6 +35,30 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
...
@@ -34,6 +35,30 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
// from the abstract parent (it has no url)
// from the abstract parent (it has no url)
$scope
.
studentData
.
id
=
$state
.
$current
.
locals
.
globals
.
$stateParams
.
idStudent
;
$scope
.
studentData
.
id
=
$state
.
$current
.
locals
.
globals
.
$stateParams
.
idStudent
;
//
// WebSockets communication
//
io
.
socket
.
on
(
'update_peers'
,
function
(
data
)
{
console
.
log
(
data
.
count
+
' peers connected'
);
$scope
.
studentData
.
num_peers
=
data
.
count
;
});
io
.
socket
.
on
(
'reconnect'
,
function
()
{
// Subscribe to student's socket room
console
.
log
(
"reconnecting to socket"
);
io
.
socket
.
post
(
'/stu/subscribe'
,
{
action
:
'subscribe'
,
attributes
:{
id_stu
:
$scope
.
studentData
.
id
},
token
:
$window
.
sessionStorage
.
token
},
function
(
res
)
{
console
.
log
(
"Connected to student: "
+
res
.
msg
);
});
});
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
//
//
// Load student account information
// Load student account information
...
@@ -244,24 +269,6 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
...
@@ -244,24 +269,6 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
console
.
log
(
"Error from API: "
+
data
.
error
);
console
.
log
(
"Error from API: "
+
data
.
error
);
});
});
//
// WebSockets communication
//
io
.
socket
.
on
(
'reconnect'
,
function
()
{
// Subscribe to student's socket room
console
.
log
(
"reconnecting to socket"
);
io
.
socket
.
post
(
'/stu/subscribe'
,
{
action
:
'subscribe'
,
attributes
:{
id_stu
:
$scope
.
studentData
.
id
},
token
:
$window
.
sessionStorage
.
token
},
function
(
res
)
{
console
.
log
(
"Connected to student: "
+
res
.
msg
);
});
});
/*
/*
// Events handling
// Events handling
io.socket.on('action', function(data) {
io.socket.on('action', function(data) {
...
...
sails/src/assets/app/modules/student/views/header.html
View file @
25c0f999
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
<div
style=
"margin-left: 5px"
><h4>
{{studentData.name}} {{studentData.surname}}
</h4></div>
<div
style=
"margin-left: 5px"
><h4>
{{studentData.name}} {{studentData.surname}}
</h4></div>
<div
style=
"margin-left: 5px"
class=
"text-left"
>
{{studentData.current_method | translate}}
</div>
<div
style=
"margin-left: 5px"
class=
"text-left"
>
{{studentData.current_method | translate}}
</div>
<div
style=
"margin-left: 5px"
class=
"text-left"
>
{{studentData.current_instruction | translate}}
</div>
<div
style=
"margin-left: 5px"
class=
"text-left"
>
{{studentData.current_instruction | translate}}
</div>
<div
style=
"margin-left: 5px; color: green"
class=
"text-left"
>
{{ 'num_peers' | translate}} : {{studentData.num_peers}}
</div>
</div>
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"row"
>
...
@@ -49,4 +50,4 @@
...
@@ -49,4 +50,4 @@
</div>
</div>
</div>
</div>
</nav>
</nav>
<!-- Fin cabecera alumno -->
<!-- Fin cabecera alumno -->
\ No newline at end of file
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