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
6f9f9cb3
authored
Feb 16, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Plain Diff
refactorización de sesiones lista
parents
c8dff581
92eba8c1
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
378 additions
and
470 deletions
android/Pictogram/commonlibrary/build.gradle
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/RestapiWrapper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Device.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/websockets/VocabularyTalk.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoItemViewGenerator.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoMenu.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/camera.png
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/edit_picture.png
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/gallery.png
android/Pictogram/tabletlibrary/src/main/res/layout/edit_picto_layout.xml
sails/roles/database/files/pictocat.sql
sails/roles/database/files/pictocat_tree_populate.sql
sails/roles/database/tasks/main.yml
sails/src/CHANGES.md
sails/src/api/controllers/PictoController.js
sails/src/api/controllers/StudentController.js
sails/src/api/models/PictoCatTree.js
sails/src/assets/scripts/modules/student/controllers/addpicto.js
sails/src/assets/scripts/modules/student/controllers/collections.js
sails/src/assets/scripts/modules/student/controllers/session.js
sails/src/assets/scripts/modules/student/views/addpicto.html
sails/src/assets/scripts/modules/student/views/session.html
android/Pictogram/commonlibrary/build.gradle
View file @
6f9f9cb3
...
...
@@ -10,7 +10,7 @@ android {
versionCode
1
versionName
"1.0"
resValue
"string"
,
"db_name"
,
"PCB.db"
resValue
"integer"
,
"db_version"
,
"
3
"
resValue
"integer"
,
"db_version"
,
"
4
"
resValue
"string"
,
"app_version"
,
"0.1"
resValue
"string"
,
"core_vocabulary"
,
"core_vocabulary"
resValue
"string"
,
"apk"
,
"to_be_set_in_subproject"
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/net/RestapiWrapper.java
View file @
6f9f9cb3
...
...
@@ -215,7 +215,7 @@ public class RestapiWrapper {
}
}
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"POST-->"
+
surl
+
" "
+
request_method
+
" j"
+
json_params
+
" param"
+
sparams
);
//Send request
DataOutputStream
wr
=
new
DataOutputStream
(
urlConnection
.
getOutputStream
());
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Device.java
View file @
6f9f9cb3
...
...
@@ -54,7 +54,7 @@ public class Device extends SQLiteOpenHelper {
*/
public
Device
(
Context
context
,
CursorFactory
factory
,
int
version
)
{
super
(
context
,
DeviceHelper
.
getDBName
(
context
),
factory
,
DeviceHelper
.
getDBVersion
(
context
)
);
super
(
context
,
DeviceHelper
.
getDBName
(
context
),
factory
,
version
);
if
(
DeviceHelper
.
force_create
(
context
))
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Forcing create new Database "
+
DeviceHelper
.
getDBName
(
context
)+
" v."
+
DeviceHelper
.
getDBVersion
(
context
));
context
.
deleteDatabase
(
DeviceHelper
.
getDBName
(
context
));
...
...
@@ -354,11 +354,10 @@ public class Device extends SQLiteOpenHelper {
Cursor
cursor
=
db
.
query
(
"picto"
,
new
String
[]{
"(SELECT MIN(id) FROM picto) AS MIN"
},
null
,
null
,
null
,
null
,
null
,
"1"
);
cursor
.
moveToFirst
();
next_key
=
cursor
.
getInt
(
cursor
.
getColumnIndex
(
"MIN"
))-
1
;
if
(
next_key
>=
0
)
next_key
=-
1
;
cursor
.
close
();
db
.
close
();
return
next_key
;
return
next_key
>=
0
?
-
1
:
next_key
;
}
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/PCBDBHelper.java
View file @
6f9f9cb3
...
...
@@ -155,7 +155,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
cursor
.
moveToFirst
();
if
(
cursor
.
getCount
()>
0
)
do
{
Picto
picto
=
new
Picto
(
cursor
.
getInt
(
1
),
cursor
.
getString
(
2
),
cursor
.
getString
(
3
),
cursor
.
getString
(
4
));
vocabulary
.
loa
dPicto
(
picto
);
vocabulary
.
ad
dPicto
(
picto
);
}
while
(
cursor
.
moveToNext
());
cursor
.
close
();
db
.
close
();
...
...
@@ -204,7 +204,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @param picto added to the Student collection
* @see com.yottacode.pictogram.dao.Picto
*/
public
void
add
Picto
(
Picto
picto
)
{
public
void
save
Picto
(
Picto
picto
)
{
int
id_stu
=
this
.
getCurrentUser
().
get_id_stu
();
SQLiteDatabase
db
=
this
.
getWritableDatabase
();
ContentValues
values
=
new
ContentValues
(
6
);
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/Picto.java
View file @
6f9f9cb3
...
...
@@ -2,8 +2,6 @@ package com.yottacode.pictogram.dao;
import
android.graphics.Color
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
android.util.Log
;
import
com.yottacode.pictogram.action.VocabularyAction
;
...
...
@@ -14,8 +12,6 @@ import com.yottacode.pictogram.tools.PCBcontext;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.Serializable
;
/**
* A object which represents a pictogram
...
...
@@ -25,7 +21,22 @@ import java.io.Serializable;
*/
public
class
Picto
extends
Img
{
private
static
final
String
LOG_TAG
=
Img
.
class
.
getName
();
public
static
final
int
STUPICTO_NULL
=
-
1
;
public
int
get_stupicto_id
()
{
int
stupicto_id
;
try
{
stupicto_id
=
this
.
attributes
.
getInt
(
JSON_ATTTRS
.
STUPICTO_ID
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
stupicto_id
=
STUPICTO_NULL
;
}
return
stupicto_id
;
}
public
final
static
class
JSON_ATTTRS
{
public
static
String
STUPICTO_ID
=
"id"
;
public
static
String
CATEGORY
=
"id_cat"
;
public
static
String
COLUMN
=
"coord_x"
;
public
static
String
ROW
=
"coord_y"
;
...
...
@@ -75,11 +86,11 @@ public class Picto extends Img {
try
{
this
.
attributes
=
new
JSONObject
(
p
.
attributes
.
toString
());
}
catch
(
JSONException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
}
translation
=
new
String
(
p
.
get_translation
());
}
public
Picto
(
int
id
,
String
url
,
String
translation
,
int
cat
,
int
row
,
int
column
,
int
freeRow
,
int
freeColumn
)
throws
JSONException
{
public
Picto
(
int
id
,
String
url
,
String
translation
,
int
cat
,
int
row
,
int
column
,
int
freeRow
,
int
freeColumn
,
int
stupicto_id
)
throws
JSONException
{
this
(
id
,
url
,
translation
,
new
JSONObject
()
.
put
(
JSON_ATTTRS
.
CATEGORY
,
cat
)
.
put
(
JSON_ATTTRS
.
COLUMN
,
column
)
...
...
@@ -87,7 +98,8 @@ public class Picto extends Img {
.
put
(
JSON_ATTTRS
.
FREE_ROW
,
freeRow
)
.
put
(
JSON_ATTTRS
.
FREE_COLUMN
,
freeColumn
)
.
put
(
JSON_ATTTRS
.
STATUS
,
JSON_ATTTR_STATUS_VALUES
.
ENABLED
)
.
put
(
JSON_ATTTRS
.
LEGEND
,
JSON_ATTTR_LEGEND_VALUES
.
NONE
));
.
put
(
JSON_ATTTRS
.
LEGEND
,
JSON_ATTTR_LEGEND_VALUES
.
NONE
)
.
put
(
JSON_ATTTRS
.
STUPICTO_ID
,
stupicto_id
));
}
public
Picto
(
int
id
,
String
url
,
String
translation
,
String
attributes
)
throws
JSONException
{
this
(
id
,
url
,
translation
,
new
JSONObject
(
attributes
));
...
...
@@ -102,7 +114,7 @@ public class Picto extends Img {
if
(
this
.
attributes
.
get
(
JSON_ATTTRS
.
CATEGORY
)==
null
)
this
.
attributes
.
put
(
JSON_ATTTRS
.
CATEGORY
,
Picto
.
NO_CATEGORY
);
}
catch
(
JSONException
e
)
{
Log
.
e
(
this
.
getClass
().
getName
()
,
e
.
toString
());
Log
.
e
(
LOG_TAG
,
e
.
toString
());
}
}
...
...
@@ -282,6 +294,7 @@ public class Picto extends Img {
legend
=
this
.
attributes
.
getString
(
JSON_ATTTRS
.
LEGEND
);
}
catch
(
JSONException
e
)
{
legend
=
JSON_ATTTR_LEGEND_VALUES
.
NONE
;
// By default
Log
.
e
(
LOG_TAG
,
" Error getting legend:"
+
e
.
getMessage
());
}
return
legend
.
equalsIgnoreCase
(
"null"
)
?
JSON_ATTTR_LEGEND_VALUES
.
NONE
:
legend
;
}
...
...
@@ -363,36 +376,14 @@ public class Picto extends Img {
return
"("
+
get_id
()
+
") - ["
+
get_row
()
+
","
+
get_column
()+
"]"
+
get_translation
()
+
"(Cat: "
+
get_category
()
+
") - "
+
get_url
()
+
" --- "
+
get_json_attrs
();
}
/**
* modify locally the status of the picto
* @return true if current status is enabled. False in other case.
*/
/*public boolean alter_status() {
String status=is_enabled() ? JSON_ATTTR_STATUS_VALUES.DISABLED
: is_disabled() ? JSON_ATTTR_STATUS_VALUES.INVISIBLE
: JSON_ATTTR_STATUS_VALUES.ENABLED;
Log.i(this.getClass().getCanonicalName(),"Picto id. "+get_id()+" status enabled/disabled modified to "+is_enabled());
try {
this.attributes.put(JSON_ATTTRS.STATUS, status);
set_local_status(true);
if (!is_local()) {
new PictoUploader(this).uploadState();
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS, this));
}
} catch (JSONException e) {
e.printStackTrace();
Log.e(this.getClass().getCanonicalName(),e.getMessage());
}
return is_enabled();
}
*/
/**
* modify locally the status of the picto
* @param status the status that u press on the menu
* @return true if current status is enabled. False in other case.
*/
public
boolean
alter_status
(
String
status
)
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
"Picto id. "
+
get_id
()+
" status enabled/disabled modified to "
+
is_enabled
());
Log
.
i
(
LOG_TAG
,
"Picto id. "
+
get_id
()+
" status enabled/disabled modified to "
+
is_enabled
());
try
{
this
.
attributes
.
put
(
JSON_ATTTRS
.
STATUS
,
status
);
set_local_status
(
true
);
...
...
@@ -402,7 +393,7 @@ public class Picto extends Img {
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
}
return
is_enabled
();
}
...
...
@@ -425,7 +416,7 @@ public class Picto extends Img {
PCBcontext
.
getPcbdb
().
modifyPicto
(
this
.
get_id
(),
this
.
get_json_attrs
());
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
e
.
getMessage
());
Log
.
e
(
LOG_TAG
,
e
.
getMessage
());
}
else
{
...
...
@@ -433,4 +424,5 @@ public class Picto extends Img {
PCBcontext
.
getPcbdb
().
modifyPicto
(
this
.
get_id
(),
this
.
get_json_attrs
());
}
}
}
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/grammar/Vocabulary.java
View file @
6f9f9cb3
...
...
@@ -90,6 +90,7 @@ public class Vocabulary implements Iterable<Picto> {
try
{
String
uri
=
args
.
getJSONObject
(
"picto"
).
getString
(
"uri"
);
JSONObject
attrs_picto
=
args
.
getJSONObject
(
"attributes"
);
attrs_picto
.
put
(
Picto
.
JSON_ATTTRS
.
STUPICTO_ID
,
args
.
getInt
(
"id"
));
String
text
=
attrs_picto
.
getString
(
"expression"
);
addPicto
(
new
Picto
(
picto_id
,
uri
,
text
,
attrs_picto
),
ImgDownloader
.
tsource
.
remote
);
...
...
@@ -135,7 +136,7 @@ public class Vocabulary implements Iterable<Picto> {
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Picto status modified while offline. Picto translation: '"
+
picto
.
get_translation
()
+
"', id:"
+
picto
.
get_id
()
+
" Local status?"
+
picto
.
local_status
());
}
if
(
picto
.
is_local
())
//id<0 iif it is a local id
if
(
picto
.
is_local
())
try
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Picto added while offline. Picto translation: '"
+
picto
.
get_translation
()
+
"', id:"
+
picto
.
get_id
()
+
" Local status?"
+
picto
.
local_status
());
...
...
@@ -172,17 +173,18 @@ public class Vocabulary implements Iterable<Picto> {
final
String
juri
=
"uri"
;
final
String
jattributes
=
"attributes"
;
final
String
jexpression
=
"expression"
;
final
String
jexpression_text
=
"text"
;
Picto
[]
pictos
=
new
Picto
[
result
.
length
()];
JSONObject
picto
=
null
,
attributes
=
null
;
JSONObject
picto
,
attributes
;
String
expression
;
JSONObject
oj
picto
=
null
;
JSONObject
stu
picto
=
null
;
try
{
for
(
int
i
=
0
;
i
<
result
.
length
();
i
++)
{
ojpicto
=
result
.
getJSONObject
(
i
);
picto
=
ojpicto
.
getJSONObject
(
jpicto
);
attributes
=
ojpicto
.
getJSONObject
(
jattributes
);
stupicto
=
result
.
getJSONObject
(
i
);
picto
=
stupicto
.
getJSONObject
(
jpicto
);
attributes
=
stupicto
.
getJSONObject
(
jattributes
);
attributes
.
put
(
Picto
.
JSON_ATTTRS
.
STUPICTO_ID
,
stupicto
.
get
(
jid
));
expression
=
attributes
.
getString
(
jexpression
);
pictos
[
i
]
=
new
Picto
(
picto
.
getInt
(
jid
),
picto
.
getString
(
juri
),
...
...
@@ -197,7 +199,7 @@ public class Vocabulary implements Iterable<Picto> {
StackTraceElement
traces
[]
=
e
.
getStackTrace
();
for
(
StackTraceElement
s:
traces
)
Log
.
e
(
s
.
getClassName
()+
"."
+
s
.
getFileName
()+
"."
+
s
.
getLineNumber
(),
s
.
toString
());
Log
.
e
(
this
.
getClass
().
getName
(),
" Picto JSON error from server: "
+
oj
picto
.
toString
());
Log
.
e
(
this
.
getClass
().
getName
(),
" Picto JSON error from server: "
+
stu
picto
.
toString
());
this
.
error
(
new
RestapiWrapper
.
HTTPException
(
"JSON Error:"
+
e
.
getMessage
(),-
1
));
}
}
...
...
@@ -264,9 +266,9 @@ public class Vocabulary implements Iterable<Picto> {
ImgDownloader
downloader
=
new
ImgDownloader
(
PCBcontext
.
getContext
(),
imgListener
,
source
);
downloader
.
executeOnExecutor
(
AsyncTask
.
THREAD_POOL_EXECUTOR
,
imgs
);
loa
dPicto
(
pic
);
ad
dPicto
(
pic
);
PCBcontext
.
getPcbdb
().
add
Picto
(
pic
);
PCBcontext
.
getPcbdb
().
save
Picto
(
pic
);
}
public
void
setImgDownloaderListener
(
ImgDownloader
.
iImgDownloaderListener
listener
)
{
...
...
@@ -289,6 +291,15 @@ public class Vocabulary implements Iterable<Picto> {
return
index
;
}
private
Picto
find_picto
(
int
pic_cat
,
int
row
,
int
column
)
{
LinkedList
<
Picto
>
pictos_cat
=
this
.
pictos
.
get
(
pic_cat
);
Picto
picto
=
null
;
for
(
int
i
=
0
;
i
<
pictos_cat
.
size
()
&&
picto
==
null
;
i
++)
if
(
pictos_cat
.
get
(
i
).
get_column
()==
column
&&
pictos_cat
.
get
(
i
).
get_row
()==
row
)
picto
=
pictos_cat
.
get
(
i
);
return
picto
;
}
public
Picto
get_picto
(
int
pic_cat
,
int
pic_id
)
{
Picto
picto
=
null
;
LinkedList
<
Picto
>
pictos_cat
=
this
.
pictos
.
get
(
pic_cat
);
...
...
@@ -335,8 +346,7 @@ public class Vocabulary implements Iterable<Picto> {
* @param picto
* @seealso com.yottacode.pictogram.dao.PCBDBHelper.getStudentVocabulary
*/
public
void
loadPicto
(
Picto
picto
)
{
Log
.
i
(
LOG_TAG
,
"load picto "
+
picto
.
get_translation
());
public
void
addPicto
(
Picto
picto
)
{
LinkedList
<
Picto
>
pictos_cat
;
if
(
this
.
pictos
.
containsKey
(
picto
.
get_category
()))
pictos_cat
=
pictos
.
get
(
picto
.
get_category
());
...
...
@@ -389,10 +399,19 @@ Log.i(LOG_TAG, "load picto "+picto.get_translation());
* It saves locally a new picto obtained from the PCB
*/
public
Picto
saveLocalPicto
(
String
url
,
String
exp
,
int
cat
,
int
coord_x
,
int
coord_y
,
int
free_category_coord_x
,
int
free_category_coord_y
,
final
iLocalPicto
listener
)
{
int
id
=
PCBcontext
.
getDevice
().
getNextLocalPictoID
();
Picto
prev_picto
=
find_picto
(
cat
,
coord_x
,
coord_y
);
//¿estamos reemplazanddo un picto que ya existe?
if
(
prev_picto
!=
null
)
{
//El picto ya existe
removePicto
(
prev_picto
.
get_category
(),
prev_picto
.
get_id
());
//borramos el picto local actual
Log
.
i
(
LOG_TAG
,
"Picto "
+
exp
+
" already exists. Previous local picto "
+
prev_picto
.
get_id
()+
" is deleted."
);
}
int
id
=
PCBcontext
.
getDevice
().
getNextLocalPictoID
();
final
Picto
picto
[]=
new
Picto
[
1
];
try
{
picto
[
0
]
=
new
Picto
(
id
,
url
,
exp
,
cat
,
coord_x
,
coord_y
,
free_category_coord_x
,
free_category_coord_y
);
picto
[
0
]
=
new
Picto
(
id
,
url
,
exp
,
cat
,
coord_x
,
coord_y
,
free_category_coord_x
,
free_category_coord_y
,
prev_picto
!=
null
?
prev_picto
.
get_stupicto_id
()
:
Picto
.
STUPICTO_NULL
);
addPicto
(
picto
[
0
],
ImgDownloader
.
tsource
.
local
,
new
ImgDownloader
.
iImgDownloaderListener
()
{
@Override
public
void
loadComplete
()
{
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/PictoUploader.java
View file @
6f9f9cb3
...
...
@@ -30,6 +30,7 @@ import java.util.concurrent.ExecutionException;
* Created by Fernando on 02/03/2016.
*/
public
class
PictoUploader
{
private
static
final
String
LOG_TAG
=
PictoUploader
.
class
.
getName
();
Picto
picto
=
null
;
public
PictoUploader
(
Picto
picto
)
{
...
...
@@ -38,7 +39,7 @@ public class PictoUploader {
private
boolean
uploadImg
(
Img
img
)
throws
UnsupportedEncodingException
{
boolean
success
;
Bitmap
bmp
=
null
;
Bitmap
bmp
;
Response
<
JsonObject
>
response
=
null
;
if
(!
img
.
get_filetype
().
equalsIgnoreCase
(
"png"
))
throw
new
UnsupportedEncodingException
(
"Extension "
+
img
.
get_filetype
()+
" is not supported. Only png files"
);
...
...
@@ -49,7 +50,7 @@ public class PictoUploader {
bmp
=
img
.
get_bitmap
(
PCBcontext
.
getContext
());
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
"Uploading Picto img "
+
img
.
file_name
()
+
" from "
+
img
.
get_type
()
+
"- Size:"
+
bmp
.
getWidth
()
+
" "
+
bmp
.
getHeight
());
Log
.
i
(
LOG_TAG
,
"Uploading Picto img "
+
img
.
file_name
()
+
" from "
+
img
.
get_type
()
+
"- Size:"
+
bmp
.
getWidth
()
+
" "
+
bmp
.
getHeight
());
File
file
=
img
.
file
(
PCBcontext
.
getContext
());
...
...
@@ -67,7 +68,7 @@ public class PictoUploader {
if
(
response
!=
null
&&
response
.
getHeaders
().
code
()
==
200
)
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
"Uploaded image result: "
+
response
.
getHeaders
()
+
":"
+
response
.
getResult
());
Log
.
i
(
LOG_TAG
,
"Uploaded image result: "
+
response
.
getHeaders
()
+
":"
+
response
.
getResult
());
int
img_id
=
response
.
getResult
().
get
(
"id"
).
getAsInt
();
String
img_uri
=
response
.
getResult
().
get
(
"uri"
).
getAsString
();
img
.
set_url
(
img_uri
);
...
...
@@ -75,16 +76,16 @@ public class PictoUploader {
success
=
true
;
}
else
{
success
=
false
;
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
"Uploaded image failed "
);
Log
.
i
(
LOG_TAG
,
"Uploaded image failed "
);
if
(
response
!=
null
)
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
"Uploaded image failed, headers: "
+
response
.
getHeaders
());
Log
.
i
(
LOG_TAG
,
"Uploaded image failed, headers: "
+
response
.
getHeaders
());
}
}
catch
(
InterruptedException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
"Image upload error: "
+
e
.
getMessage
()+
"Code: "
+
Log
.
e
(
LOG_TAG
,
"Image upload error: "
+
e
.
getMessage
()+
"Code: "
+
(
response
==
null
?
-
1
:
response
.
getHeaders
().
code
()));
success
=
false
;
}
catch
(
ExecutionException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
"Image upload error: "
+
e
.
getMessage
()+
Log
.
e
(
LOG_TAG
,
"Image upload error: "
+
e
.
getMessage
()+
(
response
==
null
?
-
1
:
response
.
getHeaders
().
code
()));
success
=
false
;
}
catch
(
IOException
e
)
{
...
...
@@ -118,7 +119,7 @@ public class PictoUploader {
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
" Error: "
+
e
.
getLocalizedMessage
());
Log
.
e
(
LOG_TAG
,
" Error: "
+
e
.
getLocalizedMessage
());
}
PCBcontext
.
getRestapiWrapper
().
ask
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_restapi_operation_stu
()
+
"/picto/"
+
id_picto
,
params
,
"post"
,
true
,
new
RestapiWrapper
.
iRestapiListener
()
{
@Override
...
...
@@ -132,13 +133,13 @@ public class PictoUploader {
@Override
public
void
result
(
JSONObject
result
)
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
" Attributes uploaded: "
+
result
.
toString
());
Log
.
i
(
LOG_TAG
,
" Attributes uploaded: "
+
result
.
toString
());
listener
.
success
(
true
,
result
.
toString
());
}
@Override
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
" Error uploading attributes: "
+
e
.
getLocalizedMessage
());
Log
.
e
(
LOG_TAG
,
" Error uploading attributes: "
+
e
.
getLocalizedMessage
());
listener
.
success
(
false
,
e
.
getLocalizedMessage
());
}
...
...
@@ -154,7 +155,7 @@ public class PictoUploader {
params
.
put
(
"picto"
,
Integer
.
toString
(
id_picto
));
params
.
put
(
"lang"
,
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_lang_stu
());
params
.
put
(
"text"
,
picto
.
get_translation
());
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
"Uploading translation: "
+
picto
.
get_translation
());
Log
.
i
(
LOG_TAG
,
"Uploading translation: "
+
picto
.
get_translation
());
PCBcontext
.
getRestapiWrapper
().
ask
(
"picto/exp"
,
params
,
"post"
,
new
RestapiWrapper
.
iRestapiListener
()
{
@Override
...
...
@@ -167,13 +168,51 @@ public class PictoUploader {
@Override
public
void
result
(
JSONObject
result
)
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
"Uploaded translation result: "
+
result
.
toString
());
Log
.
i
(
LOG_TAG
,
"Uploaded translation result: "
+
result
.
toString
());
listener
.
success
(
true
,
result
.
toString
());
uploadAttributes
(
picto
.
get_id
(),
listener
);
}
@Override
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
(),
"Error uploading translation: "
+
e
.
getLocalizedMessage
()+
" Picto:"
+
params
.
get
(
"picto"
)+
" Lang:"
+
params
.
get
(
"lang"
)+
" Text:"
+
params
.
get
(
"text"
));
Log
.
e
(
LOG_TAG
,
"Error uploading translation: "
+
e
.
getLocalizedMessage
()+
" Picto:"
+
params
.
get
(
"picto"
)+
" Lang:"
+
params
.
get
(
"lang"
)+
" Text:"
+
params
.
get
(
"text"
));
listener
.
success
(
false
,
e
.
getMessage
());
}
});
}
/**
* if the a picto was modified from the PCB, the original one is modified and a new one is included
*/
private
void
deletePicto
(
final
int
id_stupicto
,
final
iPictoUploaderListener
listener
)
{
final
String
picto_str
=
"/picto"
;
String
operation
=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_restapi_operation_stu
()+
picto_str
+
"/"
+
id_stupicto
;
Log
.
i
(
LOG_TAG
,
"Delete picto request: "
+
operation
);
PCBcontext
.
getRestapiWrapper
().
ask
(
operation
,
null
,
"delete"
,
new
RestapiWrapper
.
iRestapiListener
()
{
@Override
public
void
preExecute
()
{
}
@Override
public
void
result
(
JSONArray
result
)
{
}
@Override
public
void
result
(
JSONObject
result
)
{
String
str
=
"Picto "
+
id_stupicto
+
" deleted"
;
Log
.
i
(
LOG_TAG
,
str
);
listener
.
success
(
true
,
str
);
uploadTranslation
(
picto
.
get_id
(),
listener
);
}
@Override
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
Log
.
e
(
LOG_TAG
,
"Error deleting picto: "
+
e
.
getLocalizedMessage
()+
" Picto:"
+
id_stupicto
);
listener
.
success
(
false
,
e
.
getMessage
());
}
});
...
...
@@ -181,38 +220,29 @@ public class PictoUploader {
/**
*Try to Upload local picto. It requires:
* i)
to upload the image,
* ii) to upload the
attributes
* i)
if the picto exists, to delete the remote previous one
* ii) to upload the
image,
* iii) to upload the expression
* iv) to upload the attributes
*
**/
public
void
upload
()
throws
IOException
{
final
int
local_i
mg_i
d
=
this
.
picto
.
get_id
();
final
int
local_id
=
this
.
picto
.
get_id
();
final
int
stupicto_id
=
this
.
picto
.
get_stupicto_id
();
final
boolean
imgUpload_success
=
uploadImg
(
this
.
picto
);
int
elements_to_be_uploaded
=
2
;
if
(
stupicto_id
!=
Picto
.
STUPICTO_NULL
)
elements_to_be_uploaded
++;
Log
.
i
(
LOG_TAG
,
"Local Picto to be uploaded:"
+
this
.
picto
.
get_translation
()+
"(localID:"
+
local_id
+
", new remoteID:"
+
this
.
picto
.
get_id
()+
(
stupicto_id
!=
Picto
.
STUPICTO_NULL
?
", stupicto to be deleted:"
+
stupicto_id
+
")"
:
" .New picto"
));
iPictoUploaderListener
listener
=
new
PictoUploaderListener
(
local_id
,
elements_to_be_uploaded
);
iPictoUploaderListener
listener
=
new
iPictoUploaderListener
()
{
int
elements_uploaded
=
0
;
@Override
public
void
success
(
boolean
success
,
String
msg
)
{
if
(
success
)
elements_uploaded
++;
else
{
int
errmsg
=
msg
.
contains
(
"Error: Picto already in student's vocabulary"
)
?
R
.
string
.
upload_duplicated
:
R
.
string
.
upload_error
;
GUITools
.
show_alert
(
PCBcontext
.
getActivityContext
(),
errmsg
,
PictoUploader
.
this
.
picto
.
get_translation
());
}
if
(
elements_uploaded
==
2
)
{
PCBcontext
.
getPcbdb
().
deletePicto
(
local_img_id
);
PictoUploader
.
this
.
picto
.
delete_bitmap
(
PCBcontext
.
getContext
());
PCBcontext
.
getRoom
().
emit
(
new
VocabularyAction
(
VocabularyAction
.
ADD
,
PictoUploader
.
this
.
picto
));
GUITools
.
show_alert
(
PCBcontext
.
getContext
(),
R
.
string
.
upload_ok
,
PictoUploader
.
this
.
picto
.
get_translation
());
}
}
};
if
(
imgUpload_success
)
{
uploadAttributes
(
picto
.
get_id
(),
listener
);
if
(
stupicto_id
!=
Picto
.
STUPICTO_NULL
)
{
Log
.
i
(
LOG_TAG
,
"Remote Picto to be deleted:"
+
this
.
picto
.
get_translation
()+
"("
+
stupicto_id
+
")"
);
deletePicto
(
stupicto_id
,
listener
);
}
else
uploadTranslation
(
picto
.
get_id
(),
listener
);
}
else
{
...
...
@@ -232,7 +262,7 @@ public class PictoUploader {
params
.
put
(
"id_stu"
,
Integer
.
toString
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_id_stu
()));
params
.
put
(
"id_pic"
,
Integer
.
toString
(
this
.
picto
.
get_id
()));
Log
.
i
(
this
.
getClass
().
getCanonicalName
()
,
"Picto Uploading "
+
params
.
toString
());
Log
.
i
(
LOG_TAG
,
"Picto Uploading "
+
params
.
toString
());
PCBcontext
.
getRestapiWrapper
().
ask
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_restapi_operation_stu
()
+
"/picto"
,
params
,
"put"
,
new
RestapiWrapper
.
iRestapiListener
()
{
...
...
@@ -247,14 +277,14 @@ public class PictoUploader {
@Override
public
void
result
(
JSONObject
result
)
{
Log
.
i
(
PictoUploader
.
this
.
getClass
().
getCanonicalName
()
,
"Upload ok Picto "
+
PictoUploader
.
this
.
picto
.
get_id
());
Log
.
i
(
PictoUploader
.
LOG_TAG
,
"Upload ok Picto "
+
PictoUploader
.
this
.
picto
.
get_id
());
picto
.
set_local_status
(
false
);
PCBcontext
.
getRoom
().
emit
(
new
VocabularyAction
(
VocabularyAction
.
ALTERATTRS
,
PictoUploader
.
this
.
picto
));
}
@Override
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
Log
.
e
(
this
.
getClass
().
getCanonicalName
()
,
"Picto Error: "
+
e
.
getLocalizedMessage
());
Log
.
e
(
LOG_TAG
,
"Picto Error: "
+
e
.
getLocalizedMessage
());
}
}
);
...
...
@@ -267,4 +297,33 @@ public class PictoUploader {
public
static
interface
iPictoUploaderListener
{
void
success
(
boolean
success
,
String
s
);
}
public
class
PictoUploaderListener
implements
iPictoUploaderListener
{
int
elements_uploaded
=
0
;
int
elements_to_be_uploaded
;
int
local_img_id
;
PictoUploaderListener
(
int
local_img_id
,
int
elements
)
{
this
.
elements_to_be_uploaded
=
elements
;
this
.
local_img_id
=
local_img_id
;
}
@Override
public
void
success
(
boolean
success
,
String
msg
)
{
if
(
success
)
elements_uploaded
++;
else
{
int
errmsg
=
msg
.
contains
(
"Error: Picto already in student's vocabulary"
)
?
R
.
string
.
upload_duplicated
:
R
.
string
.
upload_error
;
GUITools
.
show_alert
(
PCBcontext
.
getActivityContext
(),
errmsg
,
PictoUploader
.
this
.
picto
.
get_translation
());
}
if
(
elements_uploaded
==
elements_to_be_uploaded
)
{
PCBcontext
.
getPcbdb
().
deletePicto
(
local_img_id
);
PictoUploader
.
this
.
picto
.
delete_bitmap
(
PCBcontext
.
getContext
());
PCBcontext
.
getVocabulary
().
addPicto
(
picto
);
PCBcontext
.
getRoom
().
emit
(
new
VocabularyAction
(
VocabularyAction
.
ADD
,
PictoUploader
.
this
.
picto
));
GUITools
.
show_alert
(
PCBcontext
.
getContext
(),
R
.
string
.
upload_ok
,
PictoUploader
.
this
.
picto
.
get_translation
());
}
}
};
}
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/websockets/VocabularyTalk.java
View file @
6f9f9cb3
...
...
@@ -45,6 +45,7 @@ public class VocabularyTalk implements Emitter.Listener {
Log
.
i
(
LOG_TAG
,
"raw Received message "
+
msg
.
toString
());
String
action
=
msg
.
getString
(
param_action
).
toLowerCase
();
JSONObject
stu_picto
=
msg
.
getJSONObject
(
param_attributes
).
getJSONObject
(
param_stu_picto
);
int
stupicto_id
=
stu_picto
.
getInt
(
param_picto_id
);
JSONObject
attrs_stu_picto
=
stu_picto
.
optJSONObject
(
param_attributes
);
JSONObject
picto_stupicto
=
stu_picto
.
optJSONObject
(
param_picto
);
int
picto_id
=
picto_stupicto
.
getInt
(
param_picto_id
);
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
View file @
6f9f9cb3
...
...
@@ -8,6 +8,7 @@ import com.yottacode.net.SSLDummyContext;
import
com.yottacode.pictogram.R
;
import
com.yottacode.pictogram.action.ActionLog
;
import
com.yottacode.pictogram.dao.Device
;
import
com.yottacode.pictogram.dao.DeviceHelper
;
import
com.yottacode.pictogram.dao.PCBDBHelper
;
import
com.yottacode.pictogram.dao.User
;
import
com.yottacode.pictogram.grammar.Vocabulary
;
...
...
@@ -38,7 +39,7 @@ public final class PCBcontext {
if
(!
init
)
{
init
=
true
;
context
=
c
;
device
=
new
Device
(
c
,
null
,
2
);
device
=
new
Device
(
c
,
null
,
DeviceHelper
.
getDBVersion
(
context
)
);
activityContext
=
null
;
SSLDummyContext
.
init
(
context
.
getResources
().
getBoolean
(
R
.
bool
.
ssl_connect
));
service
=
new
NetService
(
context
.
getResources
().
getInteger
(
R
.
integer
.
netservice_timing
),
listener
);
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoItemViewGenerator.java
View file @
6f9f9cb3
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Paint
;
import
android.view.Gravity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -64,79 +60,6 @@ public class PictoItemViewGenerator {
}
/**
* @param context
* @param bitmap Bitmap to add the legend and rescale
* @param picto
* @return the bitmap scaled and with the legend or without changes
*/
private
static
Bitmap
set_legend
(
Context
context
,
Bitmap
bitmap
,
Picto
picto
)
{
{
Paint
paint
=
new
Paint
(
Paint
.
ANTI_ALIAS_FLAG
);
int
width
=
bitmap
.
getWidth
();
//Ancho original
int
height
=
bitmap
.
getHeight
();
//Alto original
//String texto = format_legend(picto,MAX_LINE_LENGTH);
/*if(picto.get_legend().equals("normal")) { //Normal legend
android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
if (bitmapConfig == null) {
bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
}
bitmap = bitmap.copy(bitmapConfig, true);
Canvas canvas = new Canvas(bitmap);
Bitmap bm = Bitmap.createScaledBitmap(bitmap, width / 2, height / 2, false);
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); //Poner en blanco el bitmap original para dibujar encima
canvas.drawBitmap(bm, 25, 0, paint);
TextView textView = new TextView(context);
textView.layout(0, 50, 100, 100);
textView.setPadding(0, 0, 0, 0);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 13);
textView.setTextColor(Color.BLACK);
textView.setBackgroundColor(Color.WHITE);
textView.setWidth(100);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setMaxLines(4);
textView.setText(texto);
textView.setDrawingCacheEnabled(true);
canvas.drawBitmap(textView.getDrawingCache(), 0, 50, null);
}else{*/
//Only legend
android
.
graphics
.
Bitmap
.
Config
bitmapConfig
=
bitmap
.
getConfig
();
if
(
bitmapConfig
==
null
)
{
bitmapConfig
=
android
.
graphics
.
Bitmap
.
Config
.
ARGB_8888
;
}
bitmap
=
bitmap
.
copy
(
bitmapConfig
,
true
);
Canvas
canvas
=
new
Canvas
(
bitmap
);
paint
.
setColor
(
Color
.
WHITE
);
canvas
.
drawRect
(
0
,
0
,
100
,
100
,
paint
);
TextView
textView
=
new
TextView
(
context
);
textView
.
layout
(
0
,
0
,
100
,
100
);
textView
.
setPadding
(
0
,
0
,
0
,
0
);
textView
.
setTextSize
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_picto_size_big
()
?
13
:
11
);
textView
.
setTextColor
(
Color
.
rgb
(
0
,
0
,
0
));
textView
.
setWidth
(
100
);
textView
.
setGravity
(
Gravity
.
CENTER
);
textView
.
setMaxLines
(
3
);
//textView.setText(texto);
textView
.
setDrawingCacheEnabled
(
true
);
canvas
.
drawBitmap
(
textView
.
getDrawingCache
(),
0
,
25
,
null
);
}
//}
return
bitmap
;
}
public
static
View
getPictoView
(
Picto
picto
,
View
convertView
,
ViewGroup
parent
)
{
return
getPictoView
(
picto
,
convertView
,
parent
,
false
);
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictoMenu.java
View file @
6f9f9cb3
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
gui
.
communicator
;
import
android.app.Activity
;
import
android.app.AlertDialog
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.provider.MediaStore
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.ArrayAdapter
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
...
...
@@ -53,7 +45,7 @@ public class PictoMenu {
* @param col
* @param expression
*/
public
void
createMenuForNewPicto
(
final
int
row
,
final
int
col
,
final
int
cat
,
final
String
expression
,
boolean
is_picto_big
)
{
public
void
createMenuForNewPicto
(
final
int
row
,
final
int
col
,
final
int
cat
,
final
String
expression
)
{
ll
=
new
RelativeLayout
(
PCBcontext
.
getContext
());
RelativeLayout
.
LayoutParams
params
=
new
RelativeLayout
.
LayoutParams
(
RelativeLayout
.
LayoutParams
.
MATCH_PARENT
,
...
...
@@ -66,58 +58,20 @@ public class PictoMenu {
int
centerX
=
activity
.
getResources
().
getDisplayMetrics
().
widthPixels
/
2
;
int
centerY
=
activity
.
getResources
().
getDisplayMetrics
().
heightPixels
/
2
;
if
(!
is_picto_big
){
centerY
+=
100
;
detail
.
setMaxWidth
(
90
);
}
else
{
centerY
+=
135
;
detail
.
setMaxWidth
(
115
);
}
PieMenu
=
new
RadialMenuWidget
(
PCBcontext
.
getContext
());
PieMenu
.
setAnimationSpeed
(
0L
);
PieMenu
.
setCenterLocation
(
centerX
-
(
PieMenu
.
getcRadius
()*
2
)
-
50
,
centerY
-
(
PieMenu
.
getcRadius
()*
2
));
PieMenu
.
setCenterLocation
(
centerX
,
centerY
+
(
PieMenu
.
getcRadius
()*
2
));
PieMenu
.
setIconSize
(
20
,
35
);
//Tamaño del icono
Picto
picto
=
null
;
PieMenu
.
setCenterCircle
(
new
Close
());
PieMenu
.
addMenuEntry
(
new
newPickFromCamera
(
row
,
col
,
cat
,
expression
));
PieMenu
.
addMenuEntry
(
new
newPickFromGallery
(
row
,
col
,
cat
,
expression
));
ll
.
addView
(
PieMenu
);
detail
.
setImageResource
(
R
.
color
.
black
);
detail
.
setMaxWidth
(
96
);
detail
.
setMaxHeight
(
96
);
detail
.
setX
(
centerX
+
10
);
detail
.
setY
(
centerY
-
96
);
ll
.
addView
(
detail
);
/*final String[] items = new String[]{activity.getString(R.string.dialogCamera), activity.getString(R.string.dialogGallery)};
ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, android.R.layout.select_dialog_item, items);
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(activity.getString(R.string.dialogTitle));
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
addPicto(row,col,cat,expression,item);
}
});
builder.setNegativeButton(activity.getString(R.string.dialogCancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// if this button is clicked, just close
// the dialog box and do nothing
dialog.cancel();
}
});
final AlertDialog dialog = builder.create();
dialog.show();*/
}
...
...
@@ -146,66 +100,6 @@ public class PictoMenu {
}
/**
* Función para la selección de una foto del carrete
*
* @param requestCode
* @param resultCode
* @param data
*/
/*public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
String selectedImagePath;
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
int row = activity.getIntent().getIntExtra(Picto.JSON_ATTTRS.ROW, -1);
int col = activity.getIntent().getIntExtra(Picto.JSON_ATTTRS.COLUMN, -1);
int freeRow = activity.getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_ROW, -1);
int freeColumn = activity.getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
Log.i(activity.getClass().getCanonicalName(), "0 Picto x y " + " " + row + " " + col);
activity.getIntent().removeExtra(Picto.JSON_ATTTRS.ROW);
activity.getIntent().removeExtra(Picto.JSON_ATTTRS.COLUMN);
activity.getIntent().removeExtra(Picto.JSON_ATTTRS.FREE_ROW);
activity.getIntent().removeExtra(Picto.JSON_ATTTRS.FREE_COLUMN);
//chooseTextAndSavePicto(selectedImagePath, row, col, freeRow, freeColumn);
}
}
}*/
/**
* Función para la selección de una foto del carrete
*
* @param uri
* @return
*/
static
public
String
getPath
(
Uri
uri
)
{
if
(
uri
==
null
)
{
return
null
;
}
// this will only work for images selected from gallery
String
[]
projection
=
{
MediaStore
.
Images
.
Media
.
DATA
};
Cursor
cursor
=
PCBcontext
.
getContext
().
getContentResolver
().
query
(
uri
,
projection
,
null
,
null
,
null
);
if
(
cursor
!=
null
)
{
int
column_index
=
cursor
.
getColumnIndexOrThrow
(
MediaStore
.
Images
.
Media
.
DATA
);
cursor
.
moveToFirst
();
return
cursor
.
getString
(
column_index
);
}
return
uri
.
getPath
();
}
/**Function for build a radial menu
*
* @param is_picto_big
...
...
@@ -243,7 +137,7 @@ public class PictoMenu {
PieMenu
.
addMenuEntry
(
new
UnlockPictoMenu
(
picto
));
PieMenu
.
addMenuEntry
(
new
DisablePictoMenu
(
picto
));
PieMenu
.
addMenuEntry
(
new
SetInvisibleMenu
(
picto
));
PieMenu
.
addMenuEntry
(
new
EditMenu
(
picto
));
if
(!
picto
.
is_category
())
PieMenu
.
addMenuEntry
(
new
EditMenu
(
picto
));
ll
.
addView
(
PieMenu
);
...
...
@@ -286,7 +180,7 @@ public class PictoMenu {
}
public
String
getName
()
{
return
"disable"
;
}
public
String
getLabel
()
{
return
null
;
}
public
int
getIcon
()
{
return
android
.
R
.
drawable
.
ic_delete
;
}
public
int
getIcon
()
{
return
R
.
drawable
.
disabled_picto
;
}
public
List
<
RadialMenuWidget
.
RadialMenuEntry
>
getChildren
()
{
return
null
;
}
public
void
menuActiviated
()
{
...
...
@@ -351,7 +245,7 @@ public class PictoMenu {
}
public
String
getName
()
{
return
"edit"
;
}
public
String
getLabel
()
{
return
null
;
}
public
int
getIcon
()
{
return
android
.
R
.
drawable
.
ic_menu_edit
;
}
public
int
getIcon
()
{
return
R
.
drawable
.
edit_picture
;
}
private
List
<
RadialMenuWidget
.
RadialMenuEntry
>
children
;
public
List
<
RadialMenuWidget
.
RadialMenuEntry
>
getChildren
()
{
return
children
;
}
public
void
menuActiviated
()
...
...
@@ -373,7 +267,7 @@ public class PictoMenu {
}
public
String
getName
()
{
return
"editText"
;
}
public
String
getLabel
()
{
return
null
;
}
public
int
getIcon
()
{
return
android
.
R
.
drawable
.
ic_menu_
camera
;
}
public
int
getIcon
()
{
return
R
.
drawable
.
camera
;
}
public
List
<
RadialMenuWidget
.
RadialMenuEntry
>
getChildren
()
{
return
null
;
}
public
void
menuActiviated
()
{
...
...
@@ -393,7 +287,7 @@ public class PictoMenu {
}
public
String
getName
()
{
return
"editImage"
;
}
public
String
getLabel
()
{
return
null
;
}
public
int
getIcon
()
{
return
android
.
R
.
drawable
.
ic_menu_
gallery
;
}
public
int
getIcon
()
{
return
R
.
drawable
.
gallery
;
}
public
List
<
RadialMenuWidget
.
RadialMenuEntry
>
getChildren
()
{
return
null
;
}
public
void
menuActiviated
()
{
...
...
@@ -416,7 +310,7 @@ public class PictoMenu {
}
public
String
getName
()
{
return
""
;
}
public
String
getLabel
()
{
return
null
;
}
public
int
getIcon
()
{
return
android
.
R
.
drawable
.
ic_menu_
camera
;
}
public
int
getIcon
()
{
return
R
.
drawable
.
camera
;
}
public
List
<
RadialMenuWidget
.
RadialMenuEntry
>
getChildren
()
{
return
null
;
}
public
void
menuActiviated
()
{
...
...
@@ -440,7 +334,7 @@ public class PictoMenu {
}
public
String
getName
()
{
return
""
;
}
public
String
getLabel
()
{
return
null
;
}
public
int
getIcon
()
{
return
android
.
R
.
drawable
.
ic_menu_
gallery
;
}
public
int
getIcon
()
{
return
R
.
drawable
.
gallery
;
}
public
List
<
RadialMenuWidget
.
RadialMenuEntry
>
getChildren
()
{
return
null
;
}
public
void
menuActiviated
()
{
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
View file @
6f9f9cb3
...
...
@@ -841,7 +841,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
if
(
p
==
null
)
{
// No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device si no es categoria
if
(
getCurrentCategory
()
!=
null
||
!
PCBcontext
.
getPcbdb
().
getCurrentUser
().
has_categories
())
{
new
PictoMenu
(
PictogramActivity
.
this
).
createMenuForNewPicto
(
position
%
maxColumns
,
(
int
)
(
position
/
maxColumns
),
currentCategory
.
get_id
(),
null
,
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_picto_size_big
()
);
new
PictoMenu
(
PictogramActivity
.
this
).
createMenuForNewPicto
(
position
%
maxColumns
,
(
int
)
(
position
/
maxColumns
),
currentCategory
.
get_id
(),
null
);
}
else
Toast
.
makeText
(
PictogramActivity
.
this
,
PictogramActivity
.
this
.
getResources
().
getString
(
R
.
string
.
notNewCats
),
Toast
.
LENGTH_SHORT
).
show
();
...
...
@@ -1093,7 +1093,6 @@ protected void showOnlyTape(boolean onlyTape) {
*/
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
Log
.
e
(
LOG_TAG
,
"CTSA prec (onACR)"
+
requestCode
+
" "
+
resultCode
);
int
cat
=
getIntent
().
getIntExtra
(
"cat"
,
-
1
);
...
...
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/camera.png
0 → 100644
View file @
6f9f9cb3
1.14 KB
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/edit_picture.png
View file @
6f9f9cb3
851 Bytes
|
W:
|
H:
1.21 KB
|
W:
|
H:
2-up
Swipe
Onion skin
android/Pictogram/tabletlibrary/src/main/res/drawable-hdpi/gallery.png
0 → 100644
View file @
6f9f9cb3
1.02 KB
android/Pictogram/tabletlibrary/src/main/res/layout/edit_picto_layout.xml
View file @
6f9f9cb3
...
...
@@ -139,4 +139,3 @@
</LinearLayout>
</LinearLayout>
sails/roles/database/files/pictocat.sql
View file @
6f9f9cb3
...
...
@@ -49,3 +49,8 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */
;
-- Dump completed on 2017-01-17 9:48:07
--
-- Creacion y volcado de datos para la tabla `pictocattree`
--
source
/
vagrant
/
roles
/
database
/
files
/
pictocat_tree_populate
.
sql
sails/roles/database/files/pictocat_tree_populate.sql
0 → 100644
View file @
6f9f9cb3
DROP
TABLE
IF
EXISTS
`pictocattree`
;
CREATE
TABLE
pictocattree
(
id_cat
INT
,
id_ancestor
INT
,
CONSTRAINT
pk_primary_key
PRIMARY
KEY
(
id_cat
,
id_ancestor
),
INDEX
(
id_ancestor
)
);
DELIMITER
$$
DROP
PROCEDURE
IF
EXISTS
picto_cat_tree
$$
CREATE
PROCEDURE
picto_cat_tree
()
BEGIN
DECLARE
done
,
populated
INT
DEFAULT
FALSE
;
DECLARE
_id
,
_id_supercat
,
x
,
_id_cat
,
_id_ancestor
INT
;
DECLARE
pictocat
CURSOR
FOR
SELECT
id
,
id_supercat
FROM
pictodb
.
pictocat
;
DECLARE
pictocattree
CURSOR
FOR
SELECT
id_cat
,
id_ancestor
FROM
pictodb
.
pictocattree
where
id_cat
=
x
;
DECLARE
CONTINUE
HANDLER
FOR
NOT
FOUND
SET
done
=
TRUE
;
OPEN
pictocat
;
DELETE
FROM
pictocattree
;
read_loop
:
LOOP
FETCH
pictocat
INTO
_id
,
_id_supercat
;
IF
done
THEN
LEAVE
read_loop
;
END
IF
;
INSERT
INTO
pictocattree
(
id_cat
,
id_ancestor
)
VALUES
(
_id
,
_id_supercat
);
IF
_id_supercat
!=
0
THEN
SET
populated
=
0
;
populate_loop
:
LOOP
SET
x
=
_id_supercat
;
OPEN
pictocattree
;
FETCH
pictocattree
INTO
_id_cat
,
_id_ancestor
;
INSERT
INTO
pictocattree
(
id_cat
,
id_ancestor
)
VALUES
(
_id
,
_id_ancestor
);
IF
_id_ancestor
=
0
THEN
LEAVE
populate_loop
;
END
IF
;
END
LOOP
;
CLOSE
pictocattree
;
END
IF
;
END
LOOP
;
CLOSE
pictocat
;
END
$$
DELIMITER
;
CALL
picto_cat_tree
();
sails/roles/database/tasks/main.yml
View file @
6f9f9cb3
...
...
@@ -24,6 +24,14 @@
state
:
import
target
:
"
{{
server_path
}}/{{
database_files_relative_path
}}/symbolstix.sql"
-
name
:
Imports symbolstix categories
mysql_db
:
login_user
:
"
{{
database_user
}}"
login_password
:
"
{{
database_user_passwd
}}"
name
:
"
{{
database_name
}}"
state
:
import
target
:
"
{{
server_path
}}/{{
database_files_relative_path
}}/pictocat.sql"
-
name
:
Imports application essential data
mysql_db
:
login_user
:
"
{{
database_user
}}"
...
...
sails/src/CHANGES.md
View file @
6f9f9cb3
...
...
@@ -13,6 +13,9 @@ Changes to be performed manually in servers to upgrade
## Database
-
load pictocat_tree_populate.sql
`source /vagrant/roles/database/files/pictocat_tree_populate.sql;`
(already done in dev)
-
reload trigers-enrolments-integrity-constraints.sql
...
...
sails/src/api/controllers/PictoController.js
View file @
6f9f9cb3
...
...
@@ -148,18 +148,18 @@ module.exports = {
var
fs
=
require
(
'fs'
);
// return empty for category 0 (that represents category pictos and all custom pictos)
if
(
req
.
params
.
id_cat
==
0
)
return
res
.
ok
(
l
);
//
if (req.params.id_cat == 0)
//
return res.ok(l);
Supervisor
.
findOne
({
id
:
req
.
params
.
id
}).
then
(
function
(
supervisor
)
{
if
(
supervisor
)
{
PictoCat
.
find
({
select
:
[
'id
'
],
id_supercat
:
req
.
params
.
id_cat
})
PictoCat
Tree
.
find
({
select
:
[
'id
_cat'
],
id_ancestor
:
req
.
params
.
id_cat
})
.
then
(
function
(
categories
)
{
var
filtered
=
[
req
.
params
.
id_cat
];
for
(
var
i
=
0
;
i
<
categories
.
length
;
i
++
){
filtered
.
push
(
categories
[
i
].
id
);
var
filtered
=
[
req
.
params
.
id_cat
];
// Category itself
for
(
var
i
=
0
;
i
<
categories
.
length
;
i
++
){
//All subcategories
filtered
.
push
(
categories
[
i
].
id
_cat
);
}
Picto
.
find
({
category
:
filtered
})
.
paginate
({
page
:
req
.
params
.
page
,
limit
:
req
.
params
.
limit
})
...
...
@@ -193,67 +193,11 @@ module.exports = {
.
catch
(
function
(
err
)
{
throw
err
;
});
//get all categories under id_cat
// var promise = new Promise(function(resolve, reject){
// var cats = [];
// var catsFiltered = [];
// cats = getCategories(req.params.id_cat);
// while(cats.length > 1){
// var cat = cats.pop().id;
// catsFiltered.push(cat);
// cats = cats.concat(getCategories(cat));
// }
// console.log(catsFiltered);
// resolve(catsFiltered);
// });
//promise.then(function(catsFiltered){
// Picto.find({ category: catsFiltered })
// .paginate({ page: req.params.page, limit: req.params.limit})
// .populate('expressions', { lang: supervisor.lang })
// .then(function (pictos) {
// async.eachSeries(pictos, function(picto, next_cb) {
//
// // check picto has expressions associated in student language
// if (picto.expressions.length == 0 || picto.expressions[0].text.length == 0)
// return next_cb();
//
// // check picto image is available
// picto.imageFileExists((found) => {
// if (found) {
// l.push(picto);
// next_cb();
// }
// else
// next_cb();
// });
// },
// function (err) { // loop has end
// if (err) throw err;
// sails.log.debug(pictos.length + " pictos sent for category " + req.params.id_cat + " in language " + supervisor.lang);
// return res.ok(l);
// }); // end async.eachSeries
// })
// .catch(() => res.badRequest());
//});
}
else
{
return
res
.
badRequest
();
}
})
.
catch
(()
=>
res
.
serverError
());
// function getCategories(id_cat){
// PictoCat
// .find({select: ['id'], id_supercat: id_cat })
// .then(function (categories) {
// console.log(categories);
// return categories;
// })
// .catch(function (err) {
// throw err;
// });
// }
},
/**
...
...
@@ -287,12 +231,12 @@ module.exports = {
if
(
req
.
params
.
id_cat
==
0
){
//Search in all categories
getPictos
(
0
,
supervisor
.
lang
,
supervisor
.
id
);
}
else
{
//Get selected category and subcategories
PictoCat
.
find
({
select
:
[
'id
'
],
id_supercat
:
req
.
params
.
id_cat
})
PictoCat
Tree
.
find
({
select
:
[
'id
_cat'
],
id_ancestor
:
req
.
params
.
id_cat
})
.
then
(
function
(
categories
)
{
var
filtered
=
[
Number
(
req
.
params
.
id_cat
)];
//Get returned ID
for
(
var
i
=
0
;
i
<
categories
.
length
;
i
++
){
filtered
.
push
(
categories
[
i
].
id
);
var
filtered
=
[
req
.
params
.
id_cat
];
//Category itself
for
(
var
i
=
0
;
i
<
categories
.
length
;
i
++
){
//All subcategories
filtered
.
push
(
categories
[
i
].
id
_cat
);
}
getPictos
(
filtered
,
supervisor
.
lang
,
supervisor
.
id
);
})
...
...
sails/src/api/controllers/StudentController.js
View file @
6f9f9cb3
...
...
@@ -827,22 +827,35 @@ module.exports = {
/**
* Add an existing picto to the student's collection
* @param {request} req (with
studentId and pictoId as url parameter
)
* @param {request} req (with
id_stu and id_picto as url parameters
)
* {
* id_stu,
* id_picto,
* attributes: { @see StuPicto.getValidAttributes() }
* }
* @param {response} res
* {
* id: stuPictoId (association betweet student and picto)
* student: studentId (speficied as url parameter)
* picto: { @see Picto model}
* attributes: { @see StuPicto.getValidAttributes() }
*
* @param {response} res {
* id: <stu_picto ID>,
* student: <student ID>,
* attributes: {
* id_cat: categoryId or null,
* coord_x: 1 .. 5 or null,
* coord_y: 1 .. 10 or null,
* free_category_coord_x: 0 .. 4 or null,
* free_category_coord_y: 0 .. 9 or null,
* status: '[invisible]/enabled/disabled',
* highlight: true/[false],
* legend: true/[false],
* legend_size: '[small]/large',
* expression: 'custom expression',
* color: any valid HEX color or [null]
* }
* }
*/
add_picto
:
function
(
req
,
res
)
{
var
params
=
req
.
allParams
();
StuPicto
.
find
({
id_pic
:
params
.
id_picto
})
StuPicto
.
find
({
id_pic
:
params
.
id_picto
,
id_stu
:
params
.
id_stu
})
.
then
((
entries
)
=>
{
if
(
entries
&&
entries
.
length
>
0
)
{
var
err
=
new
Error
(
"Picto already in student's vocabulary"
);
...
...
sails/src/api/models/PictoCatTree.js
0 → 100644
View file @
6f9f9cb3
/**
* pictocat.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module
.
exports
=
{
tableName
:
'pictocattree'
,
migrate
:
'safe'
,
schema
:
true
,
autoPK
:
false
,
autoCreatedAt
:
false
,
autoUpdatedAt
:
false
,
attributes
:
{
id_cat
:
{
type
:
"integer"
,
primaryKey
:
true
,
unique
:
true
},
id_ancestor
:
{
type
:
"integer"
,
primaryKey
:
true
,
required
:
false
}
}
};
sails/src/assets/scripts/modules/student/controllers/addpicto.js
View file @
6f9f9cb3
...
...
@@ -39,28 +39,6 @@ dashboardControllers.controller('AddPictoCtrl', function (
exp
:
'Inicio'
,
glyphicon
:
'glyphicon glyphicon-home'
});
// Request of general pictos categories (symbolstx)
$http
.
get
(
config
.
backend
+
'/sup/'
+
supervisor
.
id
+
'/pic_categories/0'
)
.
success
(
function
(
data
)
{
$scope
.
symbolstxCats
=
data
;
})
.
error
(
function
()
{
$translate
(
'error_loading_pictos'
).
then
(
function
(
translation
)
{
ngToast
.
danger
({
content
:
translation
});
});
});
// Request page 1 pictos (symbolstx)
$http
.
get
(
config
.
backend
+
'/sup/'
+
supervisor
.
id
+
'/pic_fromSymbolStx/page/1/limit/'
+
$scope
.
limit
)
.
success
(
function
(
data
)
{
$scope
.
pictos
=
data
;
})
.
error
(
function
()
{
$translate
(
'error_loading_pictos'
).
then
(
function
(
translation
)
{
ngToast
.
danger
({
content
:
translation
});
});
});
}
//
...
...
@@ -80,8 +58,9 @@ dashboardControllers.controller('AddPictoCtrl', function (
}
$http
.
get
(
request
)
.
success
(
function
(
data
)
{
if
(
data
)
if
(
data
&&
$scope
.
source
==
'symbolstx'
){
$scope
.
pictos
=
data
;
}
$scope
.
loadingCatPictos
=
false
;
setTimeout
(
function
()
{
$scope
.
$apply
();
});
})
...
...
@@ -122,9 +101,12 @@ dashboardControllers.controller('AddPictoCtrl', function (
$http
.
get
(
config
.
backend
+
'/sup/'
+
supervisor
.
id
+
'/pic_categories/'
+
categoryId
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
if
(
data
)
if
(
data
&&
$scope
.
source
==
'symbolstx'
){
$scope
.
symbolstxCats
=
data
;
else
$scope
.
symbolstxCats
=
[];
}
else
{
$scope
.
symbolstxCats
=
[];
}
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
});
...
...
@@ -173,7 +155,7 @@ dashboardControllers.controller('AddPictoCtrl', function (
};
$scope
.
addOwnPicto
=
function
()
{
console
.
log
(
$scope
.
picFile
);
$scope
.
progress
=
0
;
var
modalInstance
=
$modal
.
open
({
animation
:
true
,
...
...
@@ -186,7 +168,7 @@ dashboardControllers.controller('AddPictoCtrl', function (
progress
:
()
=>
{
return
$scope
.
progress
;}
}
});
modalInstance
.
result
.
then
(
function
()
{});
modalInstance
.
result
.
then
(
function
()
{
$scope
.
picFile
=
null
;
});
};
/**
...
...
@@ -212,7 +194,7 @@ dashboardControllers.controller('AddPictoCtrl', function (
picto
.
expressions
=
[];
$scope
.
open_exp
(
picto
,
()
=>
{
$scope
.
pictos
.
push
(
picto
);
load_own_pictos
();
$scope
.
load_own_pictos
();
cb
();
});
});
...
...
@@ -295,8 +277,8 @@ dashboardControllers.controller('AddPictoCtrl', function (
//Triggered when scrolling to bottom
$scope
.
scroll
=
function
(){
if
(
$scope
.
onlyOwn
)
return
;
if
(
$scope
.
onlyOwn
||
$scope
.
source
==
'ownpictos'
)
return
;
//When ownpictos is active, load whole own pictos at once
$scope
.
loadingCatPictos
=
true
;
$scope
.
page
+=
1
;
...
...
@@ -379,7 +361,13 @@ dashboardControllers.controller('AddPictoCtrl', function (
}
};
if
(
onlyOwn
)
//Initial load category and pictos
if
(
onlyOwn
){
$scope
.
load_own_pictos
();
}
else
{
$scope
.
load_category
(
0
);
$scope
.
load_pictos
(
0
);
}
});
sails/src/assets/scripts/modules/student/controllers/collections.js
View file @
6f9f9cb3
...
...
@@ -369,6 +369,9 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
// Returned data from the modal window
modalInstance
.
result
.
then
(
function
(
pictoId
)
{
if
(
!
pictoId
)
return
;
// Send the picto to the server
$http
.
post
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/picto/'
+
pictoId
,
{
attributes
:
{
...
...
sails/src/assets/scripts/modules/student/controllers/session.js
View file @
6f9f9cb3
...
...
@@ -27,7 +27,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope
.
paused
=
false
;
//
Read the last working session to show the last tries when session tab is opened
//
Array with working sessions for selected instruction
$scope
.
wsessions
=
[];
// Array with student methods (with instructions)
...
...
@@ -63,9 +63,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
wsessions
=
data
;
$scope
.
currentPage
=
1
;
$scope
.
numPerPage
=
5
;
$scope
.
totalPages
=
Math
.
ceil
(
$scope
.
wsessions
.
length
/
$scope
.
numPerPage
);
$scope
.
ws_recover
=
$scope
.
wsessions
[
0
]
!=
null
&&
$scope
.
wsessions
[
0
].
end
==
null
;
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
...
...
@@ -94,24 +91,10 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
wsessions
=
data
;
// Refresh navigation vars
$scope
.
currentPage
=
1
;
$scope
.
numPerPage
=
5
;
$scope
.
totalPages
=
Math
.
ceil
(
$scope
.
wsessions
.
length
/
$scope
.
numPerPage
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{});
};
// Tries pagination - previous tries
$scope
.
before
=
function
(){
if
(
$scope
.
currentPage
>
1
)
$scope
.
currentPage
--
;
};
// Tries pagination - next tries
$scope
.
after
=
function
(){
var
total_pages
=
Math
.
ceil
(
$scope
.
wsessions
.
length
/
$scope
.
numPerPage
);
if
(
$scope
.
currentPage
<
total_pages
)
$scope
.
currentPage
++
;
};
//
// Evaluate a try (result update request)
...
...
@@ -366,8 +349,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
*/
$scope
.
is_currentOpenTry
=
function
(
t
)
{
if
(
t
.
end
==
null
&&
$scope
.
ws
.
id
==
t
.
workingSession
)
{
$scope
.
actual_try
.
id
=
t
.
id
;
if
(
t
.
end
==
null
&&
$scope
.
ws
.
id
==
t
.
workingSession
)
{
$scope
.
actual_try
.
id
=
t
.
id
;
return
true
;
}
return
false
;
...
...
sails/src/assets/scripts/modules/student/views/addpicto.html
View file @
6f9f9cb3
<div>
<div
class=
"modal-header"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
ng-click=
"close()"
>
<span
aria-hidden=
"true"
>
×
</span><span
class=
"sr-only"
translate
>
close
</span>
</button>
<h4
class=
"modal-title"
id=
"myModalLabel"
translate
ng-show=
"!onlyOwn"
>
add_picto
</h4>
<h4
class=
"modal-title"
id=
"myModalLabel"
translate
ng-show=
"onlyOwn"
>
own_pictos
</h4>
...
...
@@ -18,10 +19,12 @@
<span
class=
"glyphicon glyphicon-picture"
></span>
{{ 'own_pictos' | translate }}
</button>
</div>
</div>
</div>
<!-- /modal-header -->
<div
class=
"modal-body"
>
<!-- Bread and categories -->
<div
id=
"bread_and_categories"
ng-show=
"source == 'symbolstx' && !onlyOwn"
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<div
class=
"pull-left"
ng-repeat=
"b in breadcrumbs"
>
...
...
@@ -44,34 +47,41 @@
<alert
ng-show=
"alert.show"
ng-model=
"alert"
type=
"{{alert.type}}"
close=
"closeAlert()"
>
{{alert.msg | translate}}
</alert>
</div>
<!-- Collections row -->
<div
class=
"row"
>
<!-- Collections -->
<div
id=
"collections"
class=
"col-md-12 category-collection"
ng-class=
"{ 'category-collection-loading': loadingCatPictos }"
data-loading=
"{{ 'loading_pictos' | translate }}"
>
<!-- Filter form -->
<form
ng-submit=
"search()"
ng-show=
"!onlyOwn"
>
<div
class=
"input-group"
id=
"search_pictos_box"
>
<input
type=
"text"
class=
"form-control"
placeholder=
"{{ 'filter' | translate }}"
id=
"srch_term_picto"
name=
"srch_term_picto"
ng-model=
"srch_term_picto"
>
<span
class=
"input-group-btn"
>
<button
type=
"submit"
class=
"btn btn-primary
"
>
<i
class=
"fa fa-search"
aria-hidden=
"true"
></i>
{{ 'search' | translate }}
<button
type=
"submit"
class=
"btn btn-default
"
>
<i
class=
"fa fa-search"
aria-hidden=
"true"
></i>
</button>
</span>
</div>
</form>
<!-- Add new image -->
<div
ng-show=
"source == 'ownpictos'"
class=
"input-group"
>
<button
class=
"btn btn-success"
ngf-select
ng-model=
"picFile"
accept=
"image/*"
ngf-change=
"addOwnPicto()"
>
<span
class=
"glyphicon glyphicon-folder-open"
></span>
{{ 'new_img' | translate }}
</button>
</div>
<!-- Galería de pictos -->
<div
id=
"clearfix-infiniteScroll-parent"
infinite-scroll=
"scroll()"
infinite-scroll-container=
"'#collections'"
>
<div
class=
"picto_peq pull-left"
ng-repeat=
"p in pictos"
>
<!-- Picto galery -->
<div
id=
"clearfix-infiniteScroll-parent"
infinite-scroll=
"scroll()"
infinite-scroll-container=
"'#collections'"
>
<div
class=
"picto_peq pull-left"
ng-repeat=
"p in pictos"
>
<img
ng-src=
"{{p.uri}}"
popover=
"{{p.expressions[0].text}}"
popover-trigger=
"mouseenter"
/>
<div
class=
"picto_options"
>
<!-- Options to remove picto (Only for own pictos) -->
<div
class=
"picto_options"
>
<a
ng-click=
"remove_own_picto(p.id)"
class=
"picto_remove"
title=
"{{ 'delete' | translate}}"
ng-show=
"source == 'ownpictos'"
>
<span
class=
"color_red glyphicon glyphicon-remove-circle"
aria-hidden=
"true"
></span>
</a>
...
...
@@ -81,19 +91,18 @@
title=
"{{ 'add_picto' | translate}}"
>
<span
class=
"color_green glyphicon glyphicon-plus-sign"
aria-hidden=
"true"
></span>
</a>
</div
>
</div
>
</div>
<!-- /picto-options --
>
</div>
<!-- /each picto --
>
<div
class=
"clearfix"
></div>
</div>
<!-- /picto galery -->
</div>
<!-- /collections -->
</div>
<!-- /row -->
</div>
<!-- /modal-body -->
</div>
<!-- /collections row -->
</div>
<!-- /modal-body -->
<div
class=
"modal-footer"
>
<button
class=
"btn btn-primary"
ng-click=
"cancel()"
>
{{ 'close' | translate }}
</button>
</div>
</div>
<!-- /modal-footer -->
</div>
sails/src/assets/scripts/modules/student/views/session.html
View file @
6f9f9cb3
...
...
@@ -6,19 +6,15 @@
<button
class=
"btn btn-default"
btn-radio=
"'new'"
ng-model=
"section"
>
<span
class=
"glyphicon glyphicon-record"
></span>
{{ 'new_session' | translate }}
</button>
<button
class=
"btn btn-default"
btn-radio=
"'previous'"
ng-model=
"section"
>
<button
class=
"btn btn-default"
btn-radio=
"'previous'"
ng-model=
"section"
ng-click=
"load_tries()"
>
<span
class=
"glyphicon glyphicon-transfer"
></span>
{{ 'previous_sessions' | translate }}
</button>
</div>
<div
class=
"alert alert-danger"
role=
"alert"
ng-show=
"studentData.num_peers<2"
>
<span
class=
"glyphicon glyphicon-exclamation-sign"
aria-hidden=
"true"
></span>
<span
class=
"sr-only"
>
Error:
</span>
{{ 'warning_no_tablet_online' | translate }}
</div>
</div>
<div
class=
"row"
>
<!-- select instruction -->
<div
class=
"col-md-6"
>
<form
role=
"form"
action=
"#"
ng-hide=
"ws_recover "
>
...
...
@@ -35,7 +31,8 @@
<div
class=
"col-md-6"
>
<div
class=
"session-controls form-horizontal"
ng-show=
"selected.item != -1"
>
<!-- show number of sessions and dropdown button -->
<!-- show/hide sessions button -->
<div
class=
"form-group"
ng-show=
"section == 'previous'"
>
<span
class=
"control-label"
>
{{ wsessions.length }} {{ 'sessions' | translate }}
</span>
<button
ng-click=
"showSessions = !showSessions"
class=
"btn btn-default btn-sm"
ng-disabled=
"wsessions.length == 0"
>
...
...
@@ -50,7 +47,12 @@
<!-- / number of sessions and dropdown button -->
<!-- controls for session recording-->
<div
class=
"form-group"
ng-show=
"selected.item != -1 && studentData.num_peers>1 && section == 'new'"
>
<div
ng-show=
"studentData.num_peers<2 && section == 'new'"
class=
"form-group"
>
<span
class=
"glyphicon glyphicon-exclamation-sign text-warning"
aria-hidden=
"true"
></span>
<span
class=
"label label-warning"
>
{{ 'warning_no_tablet_online' | translate }}
</span>
</div>
<div
class=
"input-group"
ng-show=
"selected.item != -1 && studentData.num_peers>1 && section == 'new'"
>
<div
class=
"btn-group pull-right"
>
<button
type=
"button"
class=
"btn btn-default btn-sm"
...
...
@@ -96,7 +98,6 @@
<!-- first row with instruction select and controls -->
<div
id=
"tries"
>
<!-- alert on non closed session -->
<div
class=
"alert alert-danger"
role=
"alert"
ng-show=
"ws_recover"
>
<span
class=
"glyphicon glyphicon-exclamation-sign"
aria-hidden=
"true"
></span>
...
...
@@ -185,20 +186,24 @@
</div>
<!-- / running try -->
<div
class=
"tries_nav"
ng-show=
"!showLastTry && wsessions.length > 0"
>
POR AQUI VOY
<a
ng-click=
"before()"
class=
"btn btn-sm"
role=
"button"
id=
""
ng-disabled=
"currentPage == 1"
ng-hide=
"wsessions.length == 0"
>
<span
class=
"glyphicon glyphicon-chevron-up"
aria-hidden=
"true"
popover=
"{{ 'next_sessions' | translate}}"
popover-trigger=
"mouseenter"
></span>
</a>
</div>
<!-- sessions list -->
<div
class=
"list-group"
ng-show=
"showSessions || showLastTry && wsessions.length > 0"
>
<div
class=
"list-group-item"
ng-repeat=
"s in wsessions | orderBy: '-begin' | limitTo: numPerPage:(currentPage-1)*numPerPage"
>
<div
class=
"list-group pre-scrollable"
ng-show=
"showSessions && section == 'previous' || showLastTry && wsessions.length > 0 && ws_recover || tryRunning"
>
<div
ng-repeat=
"s in wsessions | orderBy: '-begin'"
>
<!-- div class="list-group-item" ng-repeat="s in wsessions | orderBy: '-begin' | limitTo: numPerPage:(currentPage-1)*numPerPage" -->
<div
class=
"list-group-item"
ng-show=
"section == 'previous' || ws.id==s.id"
>
<div
ng-show=
"showLastTry && wsessions.length > 0"
>
<h4><strong>
{{ 'last_session' | translate }}
</strong>
: {{ studentData.current_method }}, {{ studentData.current_instruction }}
</h4>
</div>
<!-- session time -->
<p
style=
"text-align: left ; margin-bottom: 5px"
class=
"list-group-item-text bg-info"
>
<span
translate
>
session
</span>
<b>
{{ 'tpl_day' | translate:{'day':s.begin} }}
</b>
{{ 'tpl_hours_frame' | translate:{'begin':s.begin, 'end':s.end} }}
</p>
<!-- show/hide tries button -->
<div
class=
"form-group pull-right"
>
<span
class=
"control-label"
>
{{ s.tries.length }} {{ 'tries' | translate }}
</span>
<button
ng-click=
"showTries = !showTries"
class=
"btn btn-default btn-sm"
>
...
...
@@ -211,18 +216,9 @@
</button>
</div>
<!-- span ng-show="!showLastTry" class="list-group-item-heading color_green">{{$index+1}} </span -->
<p
style=
"text-align: left ; margin-bottom: 5px"
class=
"list-group-item-text color_green"
>
<span
translate
>
session
</span>
<b>
{{ 'tpl_day' | translate:{'day':s.begin} }}
</b>
{{ 'tpl_hours_frame' | translate:{'begin':s.begin, 'end':s.end} }}
</p>
<!-- session notes -->
<textarea
type=
"editable title"
rows=
"2"
id=
"ins_desc_ws"
placeholder=
" {{ 'session_notes' | translate }}"
ng-model=
"s.description"
ng-model-options=
"{ updateOn: 'blur' }"
ng-change=
"update_ws(s)"
cols=
"80"
></textarea>
<a
class=
"session_details"
ng-click=
"showTries = !showTries"
>
<span
ng-if=
"!showTries"
class=
"glyphicon glyphicon-collapse-down color_green"
aria-hidden=
"true"
></span>
<span
ng-if=
"showTries"
class=
"glyphicon glyphicon-collapse-up color_green"
aria-hidden=
"true"
></span>
</a>
<!-- tries list -->
<div
class=
"sessionTries"
ng-show=
"showTries || ws.id == s.id"
>
...
...
@@ -326,8 +322,8 @@
</div>
</div>
<a
class=
"try_details"
ng-click=
"showTryNotes = !showTryNotes"
>
<span
ng-if=
"!showActions"
class=
"glyphicon glyphicon-collapse-down
"
aria-hidden=
"true"
></span>
<span
ng-if=
"showActions"
class=
"glyphicon glyphicon-collapse-up
"
aria-hidden=
"true"
></span>
<span
ng-if=
"!showTryNotes"
class=
"glyphicon glyphicon-collapse-down ng-scope
"
aria-hidden=
"true"
></span>
<span
ng-if=
"showTryNotes"
class=
"glyphicon glyphicon-collapse-up ng-scope
"
aria-hidden=
"true"
></span>
</a>
<div
class=
"tryNotes pull-left"
ng-show=
"showTryNotes"
>
<textarea
type=
"editable title"
rows=
"2"
id=
"ins_desc_try"
placeholder=
" {{ 'notes' | translate }}"
ng-model=
"t.description"
ng-model-options=
"{ updateOn: 'blur' }"
ng-change=
"update_try(t)"
cols=
"80"
></textarea>
...
...
@@ -340,10 +336,6 @@
</div>
<!-- / tries list -->
</div>
<div
class=
"tries_nav"
ng-show=
"!showLastTry "
>
<a
ng-click=
"after()"
class=
"btn btn-sm"
role=
"button"
id=
""
ng-disabled=
"currentPage == totalPages || totalPages == 0"
ng-hide=
"wsessions.length == 0"
>
<span
class=
"glyphicon glyphicon-chevron-down"
aria-hidden=
"true"
popover=
"{{ 'previous_sessions' | translate}}"
popover-trigger=
"mouseenter"
></span>
</a>
</div>
</div>
<!-- / sessions list -->
...
...
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