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
cde7a3cb
authored
Mar 15, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://scm.ujaen.es/softuno/pictogram
parents
7737f075
889b9572
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
131 additions
and
112 deletions
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
android/Pictogram/app/src/main/res/values-es/strings.xml
android/Pictogram/app/src/main/res/values/strings.xml
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
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
View file @
cde7a3cb
...
...
@@ -108,7 +108,6 @@ public class SerialActivity extends Activity implements iRestapiListener {
password
=
""
;
}
// Escribo los últimos valores indicados
mSerialViewMail
.
setText
(
username
);
//mSerialViewPass.setText(password);
...
...
@@ -124,78 +123,74 @@ public class SerialActivity extends Activity implements iRestapiListener {
Log
.
d
(
LOG_TAG
,
"PCBcontext iniciado"
);
//if (PCBcontext.getDevice().getLastStuId() != 0) {
if
(!
username
.
equals
(
""
)
&&
!
password
.
equals
(
""
)){
// Tengo usuario, sigo con este usuario
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
if
(
username
.
contains
(
"@"
)){
// Es un supervisor
String
operation
=
"sup/login"
;
Hashtable
<
String
,
String
>
postDataParams
=
new
Hashtable
<
String
,
String
>();
postDataParams
.
put
(
"email"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
if
(!
username
.
equals
(
""
)
&&
!
password
.
equals
(
""
)){
// Tengo usuario, sigo con este usuario
if
(
RestapiWrapper
.
ping
(
context
.
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
,
this
))
{
// Tengo conexión a internet. Compruebo ONLINE
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
if
(
username
.
contains
(
"@"
)){
// Es un supervisor
String
operation
=
"sup/login"
;
Hashtable
<
String
,
String
>
postDataParams
=
new
Hashtable
<
String
,
String
>();
postDataParams
.
put
(
"email"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
/*
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("desc", _MODEL);
postDataParams.put("serial", serial);
*/
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
else
{
// Es un estudiante
Log
.
d
(
LOG_TAG
,
"Entro con usuario y password"
);
String
operation
=
"stu/login"
;
Hashtable
<
String
,
String
>
postDataParams
=
new
Hashtable
<
String
,
String
>();
postDataParams
.
put
(
"username"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
else
{
// Es un estudiante
Log
.
d
(
LOG_TAG
,
"Entro con usuario y password"
);
String
operation
=
"stu/login"
;
Hashtable
<
String
,
String
>
postDataParams
=
new
Hashtable
<
String
,
String
>();
postDataParams
.
put
(
"username"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
/*
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("desc", _MODEL);
postDataParams.put("serial", serial);
*/
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
}
else
{
// Compruebo si tengo acceso a internet
//modificación FERNANDO
if
(!
RestapiWrapper
.
ping
(
context
.
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
,
this
))
{
// No puedo comprobar si el serial es válido. Muestro un alertdialog de error, y cierro la aplicación
AlertDialog
alertDialog
=
new
AlertDialog
.
Builder
(
SerialActivity
.
this
).
create
();
alertDialog
.
setTitle
(
"Mensaje del sistema"
);
alertDialog
.
setMessage
(
"No hay conexión a Internet. Inténtelo más tarde"
);
//alertDialog.setIcon(R.drawable.tick);
/*
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "Saliendo de la aplicación", Toast.LENGTH_SHORT).show();
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
}
else
{
// NO Tengo conexión a internet. Compruebo OFFLINE
if
(
username
.
contains
(
"@"
))
{
// Es un supervisor
}
else
{
// Es un estudiante
}
// ....
}
});
*/
alertDialog
.
show
();
// ¿QUÉ HACEMOS CON LA APP?
}
else
{
Button
mEntrarButton
=
(
Button
)
findViewById
(
R
.
id
.
entrar_button
);
mEntrarButton
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
username
=
mSerialViewMail
.
getText
().
toString
();
String
password
=
mSerialViewPass
.
getText
().
toString
();
SharedPreferences
settings
=
getSharedPreferences
(
PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
editor
.
putString
(
"username"
,
username
);
editor
.
putString
(
"password"
,
password
);
editor
.
commit
();
// DE PRUEBA
// Alumno
//username = "faf0001";
//password = "faf0001";
// Supervisor
//username = "dofer@ujaen.es";
//password = "dofer";
}
else
{
// No tengo aún usuario. Espero a que lo indique
Button
mEntrarButton
=
(
Button
)
findViewById
(
R
.
id
.
entrar_button
);
mEntrarButton
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
username
=
mSerialViewMail
.
getText
().
toString
();
String
password
=
mSerialViewPass
.
getText
().
toString
();
SharedPreferences
settings
=
getSharedPreferences
(
PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
editor
.
putString
(
"username"
,
username
);
editor
.
putString
(
"password"
,
password
);
editor
.
commit
();
// DE PRUEBA
// Alumno
username
=
"faf0001"
;
password
=
"faf0001"
;
// Supervisor
//username = "dofer@ujaen.es";
//password = "dofer";
// IMPORTANTE. FERNANDO: ¿Para qué el último argumento del listener?
if
(
RestapiWrapper
.
ping
(
context
.
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
,
null
))
{
// Tengo conexión a internet. Compruebo ONLINE
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
if
(
username
.
contains
(
"@"
)){
// Es un supervisor
...
...
@@ -204,11 +199,6 @@ public class SerialActivity extends Activity implements iRestapiListener {
postDataParams
.
put
(
"email"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
/*
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("desc", _MODEL);
postDataParams.put("serial", serial);
*/
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
else
{
// Es un estudiante
...
...
@@ -217,16 +207,21 @@ public class SerialActivity extends Activity implements iRestapiListener {
postDataParams
.
put
(
"username"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
/*
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("desc", _MODEL);
postDataParams.put("serial", serial);
*/
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
}
else
{
// NO Tengo conexión a internet. Compruebo OFFLINE
if
(
username
.
contains
(
"@"
))
{
// Es un supervisor
// Necesito una función local que dado el username y pass me devuelva el listado de usuarios o el usuario, si es correcto
// ....
}
else
{
// Es un estudiante
}
// ....
}
}
);
}
}
}
);
}
}
...
...
@@ -250,7 +245,7 @@ public class SerialActivity extends Activity implements iRestapiListener {
Log
.
d
(
LOG_TAG
,
"JSON en result:"
+
result
.
toString
());
if
(
result
.
toString
().
contains
(
"error"
)){
progressDialog
.
dismiss
();
if
(
progressDialog
!=
null
)
progressDialog
.
dismiss
();
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
SerialActivity
.
this
);
...
...
@@ -308,7 +303,8 @@ public class SerialActivity extends Activity implements iRestapiListener {
PCBcontext
.
set_user
(
student
,
jsonToken
,
new
iImgDownloaderListener
()
{
@Override
public
void
loadComplete
()
{
progressDialog
.
dismiss
();
if
(
progressDialog
!=
null
)
progressDialog
.
dismiss
();
Intent
pictogramActivity
=
new
Intent
(
SerialActivity
.
this
,
PictogramActivity
.
class
);
startActivity
(
pictogramActivity
);
}
...
...
@@ -341,7 +337,7 @@ public class SerialActivity extends Activity implements iRestapiListener {
int
su_id_int
=
su_id
.
intValue
();
//close the progress dialog
if
(!
username
.
contains
(
"@"
)){
if
(!
username
.
contains
(
"@"
)
&&
progressDialog
!=
null
){
progressDialog
.
dismiss
();
}
...
...
@@ -379,10 +375,10 @@ public class SerialActivity extends Activity implements iRestapiListener {
Log
.
e
(
this
.
getClass
().
getName
(),
" Server restapi error: "
+
e
.
getLocalizedMessage
());
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
SerialActivity
.
this
);
builder
.
setMessage
(
getString
(
R
.
string
.
serverError
)+
":"
+
e
.
getLocalizedMessage
())
.
setCancelable
(
false
)
.
setPositiveButton
(
"Entendido"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
builder
.
setMessage
(
getString
(
R
.
string
.
serverError
)
+
":"
+
e
.
getLocalizedMessage
())
.
setCancelable
(
false
)
.
setPositiveButton
(
"Entendido"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
//do things
}
});
...
...
android/Pictogram/app/src/main/res/values-es/strings.xml
View file @
cde7a3cb
...
...
@@ -46,9 +46,9 @@
<!--Semantic grammar -->
<string
name=
"loadingGrammar"
>
Por favor espere, cargando gramática semántica
</string>
<string
name=
"naturalgrammar"
>
SUpO_ES
</string>
<string
name=
"pictogrammar"
>
SUpO_PICTOES
</string>
<string
name=
"grammar"
>
SUpO_ES
</string>
<string
name=
"nogrammar"
>
Advertencia: Lenguaje no soportado
</string>
<string
name=
"pictogrammar"
>
SUpO_PICTOES
</string>
<item
type=
"integer"
name=
"maxInTape"
>
8
</item>
...
...
android/Pictogram/app/src/main/res/values/strings.xml
View file @
cde7a3cb
...
...
@@ -45,8 +45,10 @@
<!--Semantic grammar -->
<string
name=
"loadingGrammar"
>
Please wait, loading semmantic grammar
</string>
<string
name=
"naturalgrammar"
>
SUpO_EN
</string>
<string
name=
"grammar"
>
SUpO_EN
</string>
<string
name=
"nogrammar"
>
Warning: unknown language
</string>
<string
name=
"pictogrammar"
>
SUpO_PICTOEN
</string>
<!--Upload local img -->
<string
name=
"enterImgLabel"
>
Introduzca etiqueta de la imagen
</string>
...
...
sails/src/api/controllers/StudentController.js
View file @
cde7a3cb
...
...
@@ -538,6 +538,7 @@ module.exports = {
//
delete_picto
:
function
(
req
,
res
)
{
var
params
=
req
.
allParams
();
console
.
log
(
JSON
.
stringify
(
params
));
StuPicto
.
destroy
({
id
:
params
.
id_stuPicto
}).
exec
(
function
(
err
,
destroyed
)
{
if
(
err
)
{
...
...
@@ -545,11 +546,11 @@ module.exports = {
return
res
.
json
(
500
,
{
error
:
'Not removed picto for student'
});
}
if
(
destroyed
)
{
console
.
log
(
"Removed picto
for the student"
);
console
.
log
(
"Removed picto
"
+
destroyed
[
0
].
id_pic
+
"for the student "
);
return
res
.
json
({
"id"
:
destroyed
[
0
].
id
,
"attributes"
:
JSON
.
parse
(
destroyed
[
0
].
attributes
),
"picto"
:
destroyed
[
0
].
id_pic
id
:
destroyed
[
0
].
id
,
attributes
:
JSON
.
parse
(
destroyed
[
0
].
attributes
),
picto
:
{
id
:
destroyed
[
0
].
id_pic
}
});
}
});
...
...
@@ -560,7 +561,7 @@ module.exports = {
//
update_picto
:
function
(
req
,
res
)
{
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
));
query
=
params
.
id_stuPicto
?
{
id
:
params
.
id_stuPicto
}
...
...
@@ -572,7 +573,12 @@ module.exports = {
}
if
(
updated
)
{
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 = {
if
(
req
.
isSocket
)
{
sails
.
log
.
debug
(
"Inside /stu/subscribe - isSocket"
);
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
({
msg
:
"Subscribed to student "
+
roomName
});
...
...
@@ -691,8 +702,8 @@ module.exports = {
sails
.
sockets
.
leave
(
req
.
socket
,
rooms
[
i
]);
sails
.
log
.
debug
(
"Unsusbscribe from room "
+
rooms
[
i
]);
}
res
.
json
({
res
.
json
({
msg
:
"Unsubscribed from all rooms"
});
}
...
...
sails/src/assets/app/i18n/en-gb.json
View file @
cde7a3cb
...
...
@@ -143,6 +143,7 @@
"normal"
:
"Normal"
,
"notes"
:
"Notes"
,
"November"
:
"November"
,
"num_peers"
:
"Peers"
,
"num_sessions_per_day_in"
:
"Sessions per day in"
,
"num_sessions_per_month_in"
:
"Sessions per months in"
,
"objetive"
:
"Objetive"
,
...
...
sails/src/assets/app/i18n/es-es.json
View file @
cde7a3cb
...
...
@@ -143,6 +143,7 @@
"normal"
:
"Normal"
,
"notes"
:
"Notas"
,
"November"
:
"Noviembre"
,
"num_peers"
:
"Conectados"
,
"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"
,
"objetive"
:
"Objetivo"
,
...
...
sails/src/assets/app/modules/student/controllers/addpicto.js
View file @
cde7a3cb
...
...
@@ -136,7 +136,7 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
};
$scope
.
alert
=
{
type
:
'danger'
,
msg
:
'Category is full of pictos.'
,
show
:
false
};
//
// Close alert message
//
...
...
@@ -352,6 +352,7 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
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 @
cde7a3cb
...
...
@@ -23,7 +23,8 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
id
:
''
,
name
:
''
},
stuSup
:
[]
stuSup
:
[],
num_peers
:
1
};
// For the user form data in setup section
...
...
@@ -34,6 +35,30 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
// from the abstract parent (it has no url)
$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
...
...
@@ -244,24 +269,6 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
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
io.socket.on('action', function(data) {
...
...
sails/src/assets/app/modules/student/views/header.html
View file @
cde7a3cb
...
...
@@ -23,6 +23,7 @@
<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_instruction | translate}}
</div>
<div
style=
"margin-left: 5px; color: green"
class=
"text-left"
>
{{ 'num_peers' | translate}} : {{studentData.num_peers}}
</div>
</div>
</div>
<div
class=
"row"
>
...
...
@@ -49,4 +50,4 @@
</div>
</div>
</nav>
<!-- Fin cabecera alumno -->
\ No newline at end of file
<!-- Fin cabecera alumno -->
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