Commit 0ca9f1b5 by Arturo Montejo Ráez

Merge branch 'develop' of http://gitlab.ujaen.es/yotta/pictogram into develop

parents ac5c7624 5a8d9b6d
Showing with 1006 additions and 217 deletions
...@@ -31,6 +31,8 @@ sails/src/config/ssl/**/*.crt ...@@ -31,6 +31,8 @@ sails/src/config/ssl/**/*.crt
sails/src/config/ssl/**/*.csr sails/src/config/ssl/**/*.csr
sails/src/config/ssl/**/*.pem sails/src/config/ssl/**/*.pem
sails/src/config/local.js sails/src/config/local.js
sails/src/config/local.js
sails/src/assets/scripts/config.js
sails/src/node_modules sails/src/node_modules
sails/src/certbot.log sails/src/certbot.log
sails/.vagrant sails/.vagrant
......
...@@ -21,6 +21,7 @@ import java.io.IOException; ...@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
...@@ -178,14 +179,34 @@ public class Device extends SQLiteOpenHelper { ...@@ -178,14 +179,34 @@ public class Device extends SQLiteOpenHelper {
return user; return user;
} }
public Vector<User> recoverSupervisors(Integer id_stu) throws JSONException{ /**
* Para saber si un supervisor esta en la bbdd local
* @param id_sup
* @return
* @throws JSONException
*/
public Boolean isSupervisorOnLocal(int id_sup) throws JSONException{
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Vector<User> users = new Vector<>(); Cursor cursor = db.rawQuery(" SELECT * FROM supervisor WHERE id = " + id_sup, null);
Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null); if(cursor.moveToFirst())
return true;
cursor.close();
return false;
}
/**
* Recupera los supervisores de un determinado alumno
* @author Germán Callejas
* @param id_stu
* @return
* @throws JSONException
*/
public Hashtable<String, String> recoverSupervisors(Integer id_stu) throws JSONException{
SQLiteDatabase db = this.getReadableDatabase();
Hashtable<String, String> users = new Hashtable<>(3);
Cursor cursor = db.rawQuery(" SELECT email_sup, name_sup, surname_sup,id_sup FROM users_detail WHERE id_stu = "+id_stu ,null);
while (cursor.moveToNext()) while (cursor.moveToNext())
if (cursor.getInt(0) == id_stu) users.put(cursor.getString(0), cursor.getString(1)+", "+cursor.getString(2)+";"+cursor.getInt(3));
users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8),
cursor.getInt(9), cursor.getString(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(18)));
cursor.close(); cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return users; return users;
...@@ -297,7 +318,20 @@ public class Device extends SQLiteOpenHelper { ...@@ -297,7 +318,20 @@ public class Device extends SQLiteOpenHelper {
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
} }
/**
* Elimina los supervisores asociados a un niño que no tengan password, es decir, los que no hayan estado logueados en el tablet con
* anterioridad
* @author Germán Callejas
* @param stu_id
* @param sup_id
*/
public void deleteSupervisor(int stu_id,int sup_id){
SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction();
db.execSQL("DELETE FROM users_detail WHERE id_stu = "+stu_id + " AND id_sup = "+sup_id+" AND pwd_sup LIKE '_' " );
db.setTransactionSuccessful();
db.endTransaction();
}
/** /**
* delete the list of images (students, supervisors, pictograms) which are no longer used * delete the list of images (students, supervisors, pictograms) which are no longer used
......
...@@ -78,7 +78,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -78,7 +78,7 @@ public class Vocabulary implements Iterable<Picto> {
modifyAttsPicto(picto_cat, picto_id, args.getJSONObject("attributes")); modifyAttsPicto(picto_cat, picto_id, args.getJSONObject("attributes"));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
Log.e(LOG_TAG,e.getMessage()); Log.e(LOG_TAG,"Error updating picto:"+e.getMessage());
} }
break; break;
} }
...@@ -457,7 +457,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -457,7 +457,7 @@ public class Vocabulary implements Iterable<Picto> {
}); });
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Log.e(Vocabulary.class.getCanonicalName(), e.getMessage()); Log.e(Vocabulary.class.getCanonicalName(), "Error saving picto:"+e.getMessage());
} }
} }
......
...@@ -9,7 +9,6 @@ import com.koushikdutta.ion.Response; ...@@ -9,7 +9,6 @@ import com.koushikdutta.ion.Response;
import com.yottacode.net.RestapiWrapper; import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.R; import com.yottacode.pictogram.R;
import com.yottacode.pictogram.action.VocabularyAction; import com.yottacode.pictogram.action.VocabularyAction;
import com.yottacode.pictogram.dao.Device;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
...@@ -24,7 +23,6 @@ import java.io.IOException; ...@@ -24,7 +23,6 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
/** /**
...@@ -104,10 +102,10 @@ public class PictoUploader { ...@@ -104,10 +102,10 @@ public class PictoUploader {
boolean success; boolean success;
Response<JsonObject> response=null; Response<JsonObject> response=null;
String [] path = audioFile.getPath().split("\\.");
String extension = path[1];
if (extension != "mp3") String extension = audioFile.getName().substring(audioFile.getName().lastIndexOf('.')+1);
if (!extension.equalsIgnoreCase("mp3"))
throw new UnsupportedEncodingException("Extension "+extension+" is not supported. Only mp3 files"); throw new UnsupportedEncodingException("Extension "+extension+" is not supported. Only mp3 files");
Ion ion = Ion.getDefault(PCBcontext.getContext()); Ion ion = Ion.getDefault(PCBcontext.getContext());
...@@ -116,7 +114,7 @@ public class PictoUploader { ...@@ -116,7 +114,7 @@ public class PictoUploader {
response=ion.with(PCBcontext.getContext()) response=ion.with(PCBcontext.getContext())
.load("POST", PCBcontext.getContext().getResources().getString(R.string.server) + "/picto/upload_sound/"+picto.get_stupicto_id()) .load("POST", PCBcontext.getContext().getResources().getString(R.string.server) + "/picto/upload_sound/"+picto.get_stupicto_id())
.setMultipartParameter("filename", "id_del _sonido") .setMultipartParameter("filename", audioFile.getName())
.setMultipartParameter("extension", "mp3") .setMultipartParameter("extension", "mp3")
.setMultipartParameter("owner", Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_id_sup())) .setMultipartParameter("owner", Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_id_sup()))
.setMultipartParameter("folder", "pictoSound") .setMultipartParameter("folder", "pictoSound")
...@@ -140,7 +138,7 @@ public class PictoUploader { ...@@ -140,7 +138,7 @@ public class PictoUploader {
success=false; success=false;
Log.i(LOG_TAG, "Uploaded Sound failed "); Log.i(LOG_TAG, "Uploaded Sound failed ");
if (response != null) if (response != null)
Log.i(LOG_TAG, "Uploaded Sound failed, headers: " + response.getHeaders()); Log.i(LOG_TAG, "Uploaded Sound failed, headers: " + response.getHeaders().message()+"("+response.getHeaders().code()+")");
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e(LOG_TAG, "Sound upload error: " + e.getMessage()+ "Code: "+ Log.e(LOG_TAG, "Sound upload error: " + e.getMessage()+ "Code: "+
...@@ -167,6 +165,7 @@ public class PictoUploader { ...@@ -167,6 +165,7 @@ public class PictoUploader {
Hashtable<String, String> params = new Hashtable<String, String>(4); Hashtable<String, String> params = new Hashtable<String, String>(4);
try { try {
JSONObject json_attrs =new JSONObject().put("status",picto.get_status()); JSONObject json_attrs =new JSONObject().put("status",picto.get_status());
json_attrs.put("user_avatar",picto.get_user_avatar());
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) if (PCBcontext.getPcbdb().getCurrentUser().has_categories())
json_attrs.put(Picto.JSON_ATTTRS.CATEGORY, picto.get_category()) json_attrs.put(Picto.JSON_ATTTRS.CATEGORY, picto.get_category())
.put(Picto.JSON_ATTTRS.COLUMN, picto.get_column()) .put(Picto.JSON_ATTTRS.COLUMN, picto.get_column())
...@@ -301,14 +300,15 @@ public class PictoUploader { ...@@ -301,14 +300,15 @@ public class PictoUploader {
if (imgUpload_success){ if (imgUpload_success){
if(this.picto.getUriSound() != "" && this.picto.getUriSound() != null ){ //Si el picto tiene audio en local if(this.picto.getUriSound() != "" && this.picto.getUriSound() != null ){ //Si el picto tiene audio en local
Log.i("TAG_PRUEBAS","Hay uri: "+this.picto.getUriSound()+" -Procede a subir archivo"); Log.i(LOG_TAG,"Uploading sound "+this.picto.getUriSound());
File file = new File(picto.getUriSound()); //Obtengo el fichero de audio local File file = new File(picto.getUriSound()); //Obtengo el fichero de audio local
boolean soundUpload_success = uploadSound(file); //Llamo a la subida boolean soundUpload_success = uploadSound(file); //Llamo a la subida
if(soundUpload_success) { if(soundUpload_success) {
Log.i("TAG_PRUEBAS","Se sube sonido hay EXITO"); Log.i(LOG_TAG,"Sound uploaded");
}else { }else {
GUITools.show_alert(PCBcontext.getActivityContext(),Integer.parseInt(R.string.upload_error+"Audio"), PictoUploader.this.picto.get_translation()); Log.e(LOG_TAG, "Uploading sound error");
GUITools.show_alert(PCBcontext.getActivityContext(),R.string.upload_error, PictoUploader.this.picto.get_translation());
} }
} }
if (stupicto_id!=Picto.STUPICTO_NULL) { if (stupicto_id!=Picto.STUPICTO_NULL) {
...@@ -318,7 +318,7 @@ public class PictoUploader { ...@@ -318,7 +318,7 @@ public class PictoUploader {
uploadTranslation(picto.get_id(), listener); uploadTranslation(picto.get_id(), listener);
} }
}else{ }else{
GUITools.show_alert(PCBcontext.getActivityContext(), Integer.parseInt(R.string.upload_error+"Imagen"), PictoUploader.this.picto.get_translation()); GUITools.show_alert(PCBcontext.getActivityContext(), R.string.upload_error, PictoUploader.this.picto.get_translation());
} }
} }
......
...@@ -52,7 +52,6 @@ public class ActionTalk implements Emitter.Listener { ...@@ -52,7 +52,6 @@ public class ActionTalk implements Emitter.Listener {
if (action.equals(action_add) || action.equals(action_select) || action.equals(action_show) || action.equals(action_delete)) { if (action.equals(action_add) || action.equals(action_select) || action.equals(action_show) || action.equals(action_delete)) {
int picto_id; int picto_id;
int picto_cat; int picto_cat;
boolean mirroing=PCBcontext.getPcbdb().getCurrentUser().is_mirror_on();
if (action.equals(action_show)) { if (action.equals(action_show)) {
picto_id=picto_cat=-1; picto_id=picto_cat=-1;
} else { } else {
...@@ -61,12 +60,10 @@ public class ActionTalk implements Emitter.Listener { ...@@ -61,12 +60,10 @@ public class ActionTalk implements Emitter.Listener {
JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto); JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto);
picto_id = picto_stupicto.getInt(param_picto_id); picto_id = picto_stupicto.getInt(param_picto_id);
picto_cat = attrs_stu_picto != null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0; picto_cat = attrs_stu_picto != null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0;
mirroing|=attrs_stu_picto.has(Picto.JSON_ATTTRS.MIRROR);
} }
if ( mirroing) { Log.i(LOG_TAG, "Received message '" + action +
Log.i(LOG_TAG, "Received message '" + action +
"' for picto " + picto_id + " (cat " + picto_cat); "' for picto " + picto_id + " (cat " + picto_cat);
for (iActionListener listener : this.listeners) for (iActionListener listener : this.listeners)
listener.action(action.equals(action_add) listener.action(action.equals(action_add)
? iActionListener.action.add ? iActionListener.action.add
: action.equals(action_select) : action.equals(action_select)
...@@ -75,7 +72,7 @@ public class ActionTalk implements Emitter.Listener { ...@@ -75,7 +72,7 @@ public class ActionTalk implements Emitter.Listener {
? iActionListener.action.delete ? iActionListener.action.delete
: iActionListener.action.show : iActionListener.action.show
, picto_cat, picto_id); , picto_cat, picto_id);
}
} }
} catch (JSONException e) { } catch (JSONException e) {
......
...@@ -90,14 +90,18 @@ public final class PCBcontext { ...@@ -90,14 +90,18 @@ public final class PCBcontext {
} }
public static void unset_user() { public static void unset_user() {
Log.i(PCBcontext.class.getCanonicalName(), "User unset. Student " + getPcbdb().getCurrentUser().get_name_stu()); Log.e(PCBcontext.class.getCanonicalName(), "User unset. Student " + getPcbdb().getCurrentUser().get_name_stu());
if (room!=null) room.exit(); if (room!=null) room.exit();
pcbdb = null; pcbdb = null;
room = null; room = null;
vocabulary = null; vocabulary = null;
getNetService().notifyStatus(); getNetService().notifyStatus();
} }
@Override
protected void finalize() {
Log.e("PCBcontext", "FINALIZE Pictogram Activity");
}
/** /**
* *
* @return true if a given user has been logged into the system (the login window was successfully filled) * @return true if a given user has been logged into the system (the login window was successfully filled)
......
package com.yottacode.tools; package com.yottacode.tools;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BlurMaskFilter; import android.graphics.BlurMaskFilter;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
...@@ -8,12 +9,22 @@ import android.graphics.Matrix; ...@@ -8,12 +9,22 @@ import android.graphics.Matrix;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.os.Environment;
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
/** /**
* Created by Fernando on 15/03/2016. * Created by Fernando on 15/03/2016.
*/ */
public class BitmapTools { public class BitmapTools {
Bitmap bitmap; private static String LOG_TAG=BitmapTools.class.getName();
Bitmap bitmap;
public BitmapTools(Bitmap bitmap) { this.bitmap=bitmap;} public BitmapTools(Bitmap bitmap) { this.bitmap=bitmap;}
public Bitmap get() {return this.bitmap;} public Bitmap get() {return this.bitmap;}
...@@ -167,4 +178,36 @@ public class BitmapTools { ...@@ -167,4 +178,36 @@ public class BitmapTools {
canvas.drawBitmap(new BitmapTools(drawable.getBitmap()).resize(w,h).get(), canvas.drawBitmap(new BitmapTools(drawable.getBitmap()).resize(w,h).get(),
(int)((this.bitmap.getWidth()-w)/2),(int)((this.bitmap.getHeight()-h)/2),null); (int)((this.bitmap.getWidth()-w)/2),(int)((this.bitmap.getHeight()-h)/2),null);
} }
public static void save_temporal(Bitmap bitmap) {
File f3=new File(Environment.getExternalStorageDirectory()+"/inpaint/");
if(!f3.exists())
f3.mkdirs();
OutputStream outStream = null;
File file = new File(Environment.getExternalStorageDirectory() + "/inpaint/"+"seconds"+".png");
try {
outStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static Bitmap load_temporal() {
InputStream inStream;
inStream = null;
File file = new File(Environment.getExternalStorageDirectory() + "/inpaint/"+"seconds"+".png");
try {
inStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.e(BitmapTools.LOG_TAG,e.getMessage());
}
Bitmap originalBitmap = BitmapFactory.decodeStream(inStream);
file.delete();
return originalBitmap ;
}
} }
...@@ -62,4 +62,7 @@ ...@@ -62,4 +62,7 @@
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="landscape" /> android:screenOrientation="landscape" />
</application> </application>
</manifest> </manifest>
...@@ -2,8 +2,6 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator; ...@@ -2,8 +2,6 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Point;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
...@@ -11,14 +9,10 @@ import android.widget.RelativeLayout; ...@@ -11,14 +9,10 @@ import android.widget.RelativeLayout;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity; import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity;
import com.yottacode.pictogram.tabletlibrary.gui.login.MainActivity;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools; import com.yottacode.tools.BitmapTools;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import static android.graphics.Color.argb; import static android.graphics.Color.argb;
...@@ -122,10 +116,11 @@ public class PictoMenu { ...@@ -122,10 +116,11 @@ public class PictoMenu {
intent.putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col); intent.putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col);
} }
ByteArrayOutputStream stream = new ByteArrayOutputStream(); /*ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
intent.putExtra(IMAGE_PICTO, byteArray); intent.putExtra(IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(bitmap);
intent.putExtra(IS_EDIT,true); intent.putExtra(IS_EDIT,true);
activity.startActivityForResult(intent,EditPictoActivity.EDIT_PICTO_REQUEST); activity.startActivityForResult(intent,EditPictoActivity.EDIT_PICTO_REQUEST);
......
...@@ -56,12 +56,12 @@ import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet; ...@@ -56,12 +56,12 @@ import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.tts.TTSHelper; import com.yottacode.pictogram.tts.TTSHelper;
import com.yottacode.tools.BitmapTools;
import com.yottacode.tools.GUITools; import com.yottacode.tools.GUITools;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
...@@ -160,7 +160,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -160,7 +160,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
Log.i(this.getClass().getCanonicalName(), action + " from " + picto_cat + "," + picto_id + " catched"); Log.i(this.getClass().getCanonicalName(), action + " from " + picto_cat + "," + picto_id + " catched");
if (action==ActionTalk.iActionListener.action.show) { if (action==ActionTalk.iActionListener.action.show) {
} }
else { else if (PCBcontext.getPcbdb().getCurrentUser().is_mirror_on()) {
Picto picto = vocabulary.get_picto(picto_cat, picto_id); Picto picto = vocabulary.get_picto(picto_cat, picto_id);
PictogramActivity.this.execHighligthFeeback(picto, true); PictogramActivity.this.execHighligthFeeback(picto, true);
} }
...@@ -393,6 +393,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -393,6 +393,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
@Override @Override
protected void onPause() { protected void onPause() {
Log.e(this.LOG_TAG,"ONPAUSE");
super.onPause(); super.onPause();
this.pictoCategoryGridAdapter.allPictosInGrid(); this.pictoCategoryGridAdapter.allPictosInGrid();
this.pictoMainGridAdapter.allPictosInGrid(); this.pictoMainGridAdapter.allPictosInGrid();
...@@ -408,6 +409,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -408,6 +409,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
@Override @Override
protected void onDestroy() { protected void onDestroy() {
Log.e(LOG_TAG, "destroy Pictogram Activity");
super.onDestroy(); super.onDestroy();
if (tts != null) { if (tts != null) {
tts.destroy(); tts.destroy();
...@@ -1215,11 +1217,11 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1215,11 +1217,11 @@ protected void showOnlyTape(boolean onlyTape) {
Intent intent = new Intent(this, EditPictoActivity.class); Intent intent = new Intent(this, EditPictoActivity.class);
ByteArrayOutputStream stream = new ByteArrayOutputStream(); /* ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.PNG, 100, stream); image.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray); intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(image);
startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST); startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST);
} }
......
...@@ -6,7 +6,6 @@ import android.content.Intent; ...@@ -6,7 +6,6 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point; import android.graphics.Point;
import android.media.MediaActionSound; import android.media.MediaActionSound;
import android.media.MediaPlayer; import android.media.MediaPlayer;
...@@ -27,41 +26,38 @@ import android.view.KeyEvent; ...@@ -27,41 +26,38 @@ import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.grammar.Vocabulary;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular; import com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictoMenu; import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictoMenu;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.BitmapTools;
import com.yottacode.tools.GUITools; import com.yottacode.tools.GUITools;
import org.json.JSONException; import org.json.JSONException;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.Hashtable;
import java.util.Random; import java.util.Random;
import java.util.Vector;
import pl.droidsonroids.gif.GifTextView; import pl.droidsonroids.gif.GifTextView;
import static java.lang.Thread.sleep; import static java.lang.Thread.sleep;
/** /**
...@@ -70,6 +66,7 @@ import static java.lang.Thread.sleep; ...@@ -70,6 +66,7 @@ import static java.lang.Thread.sleep;
public class EditPictoActivity extends Activity { public class EditPictoActivity extends Activity {
private static final CharSequence NO_SUP_TEXT = "____________";
Picto p; Picto p;
private boolean editar; private boolean editar;
Random nRandom = new Random(); Random nRandom = new Random();
...@@ -101,8 +98,8 @@ public class EditPictoActivity extends Activity { ...@@ -101,8 +98,8 @@ public class EditPictoActivity extends Activity {
EditText legend; EditText legend;
//For Associated Supervisors///////////////////////////////////////////////////////// //For Associated Supervisors/////////////////////////////////////////////////////////
Button desplegableSupervisores; Button supAsociado;
TextView supAsociado;
private ListView mDrawerList; private ListView mDrawerList;
private ArrayAdapter<String> mAdapter; private ArrayAdapter<String> mAdapter;
...@@ -227,10 +224,9 @@ public class EditPictoActivity extends Activity { ...@@ -227,10 +224,9 @@ public class EditPictoActivity extends Activity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
setContentView(R.layout.edit_picto_layout); setContentView(R.layout.edit_picto_layout);
Log.i(DEBUG_MESSAGE,"EDITAR ABIERTO");
//Persmisos para grabar audio //Persmisos para grabar audio
ActivityCompat.requestPermissions(this, permissions, REQUEST_RECORD_AUDIO_PERMISSION); ActivityCompat.requestPermissions(this, permissions, REQUEST_RECORD_AUDIO_PERMISSION);
...@@ -239,33 +235,18 @@ public class EditPictoActivity extends Activity { ...@@ -239,33 +235,18 @@ public class EditPictoActivity extends Activity {
mDrawerList = (ListView)findViewById(R.id.navList); mDrawerList = (ListView)findViewById(R.id.navList);
/**Obtener la lista de supervisores y aplicarle formato*/ /**Obtener la lista de supervisores y aplicarle formato*/
Log.i(DEBUG_MESSAGE,"Usuario: "+ PCBcontext.getPcbdb().getCurrentUser().get_name_stu());
ArrayList<String> supervisoresAdapter = new ArrayList<>(); ArrayList<String> supervisoresAdapter = new ArrayList<>();
Vector<User> supervisores = null; Hashtable<String, String> supervisores = null;
try { try {
supervisores = PCBcontext.getDevice().recoverSupervisors(PCBcontext.getPcbdb().getCurrentUser().get_id_stu()); supervisores = PCBcontext.getDevice().recoverSupervisors(PCBcontext.getPcbdb().getCurrentUser().get_id_stu());
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (supervisores != null){ if (supervisores != null){
for(User supervisor: supervisores){ for(String email_sup: supervisores.keySet())
supervisoresAdapter.add(supervisor.get_name_sup()+", "+supervisor.get_surname_sup()+ "\n" +supervisor.get_email_sup() ); supervisoresAdapter.add(supervisores.get(email_sup).split(";")[0]+"\n"+email_sup);
}
} }
supervisoresAdapter.add(NO_SUP_TEXT+"\n"+NO_SUP_TEXT);
//String supervisors = PCBcontext.getPcbdb().getCurrentUser().get_Supervisors();
//Log.i(DEBUG_MESSAGE,"Supervisores: "+ supervisors);
//ArrayList<String> supervisores = new ArrayList<>();
/*if(supervisors != null) {
String[] separated = supervisors.split(";");
for (String supervisor : separated) {
String[] detalles = supervisor.split(",");
supervisores.add(detalles[0] + "\n" + detalles[1]);
}
}else
Log.i(DEBUG_MESSAGE,"No tiene supervisores...");*/
mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, supervisoresAdapter); mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, supervisoresAdapter);
mDrawerList.setAdapter(mAdapter); mDrawerList.setAdapter(mAdapter);
...@@ -328,8 +309,7 @@ public class EditPictoActivity extends Activity { ...@@ -328,8 +309,7 @@ public class EditPictoActivity extends Activity {
okButton = (Button) findViewById(R.id.okButton); okButton = (Button) findViewById(R.id.okButton);
cancelButton = (Button) findViewById(R.id.cancelButton); cancelButton = (Button) findViewById(R.id.cancelButton);
desplegableSupervisores = (Button) findViewById(R.id.botonDesplegable); supAsociado = (Button) findViewById(R.id.botonSupAsociado);//(TextView) findViewById(R.id.sup_actual);
supAsociado = (TextView) findViewById(R.id.sup_actual);
botonGrabar = (BotonCircular) findViewById(R.id.botonGrabar); botonGrabar = (BotonCircular) findViewById(R.id.botonGrabar);
botonReproducir = (BotonCircular) findViewById(R.id.reproducir); botonReproducir = (BotonCircular) findViewById(R.id.reproducir);
...@@ -366,16 +346,16 @@ public class EditPictoActivity extends Activity { ...@@ -366,16 +346,16 @@ public class EditPictoActivity extends Activity {
if(editar){ if(editar){
p = PCBcontext.getVocabulary().get_picto(getIntent().getExtras().getInt(Picto.JSON_ATTTRS.CATEGORY),getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE)); p = PCBcontext.getVocabulary().get_picto(getIntent().getExtras().getInt(Picto.JSON_ATTTRS.CATEGORY),getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE));
legend.setText(p.get_translation()); legend.setText(p.get_translation());
supAsociado.setText(p.get_user_avatar()); supAsociado.setText(p.get_user_avatar()==null ? NO_SUP_TEXT : p.get_user_avatar());
} }
legend.setHorizontallyScrolling(false); legend.setHorizontallyScrolling(false);
legend.setMaxLines(1); legend.setMaxLines(1);
legend.setSingleLine(true); legend.setSingleLine(true);
//Obtener imagen del intent //Obtener imagen del intent
byte[] byteArray = getIntent().getByteArrayExtra(PictoMenu.IMAGE_PICTO); /*byte[] byteArray = getIntent().getByteArrayExtra(PictoMenu.IMAGE_PICTO);*/
final Bitmap imagePicto = scale_image(BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length));
final Bitmap imagePicto = scale_image(BitmapTools.load_temporal());
cropImageView.setAspectRatio(editar ? imagePicto.getWidth() : 4,editar ? imagePicto.getHeight() : 3); //Si es editar un picto la ventana de recorte mantiene el tamaño de la imagen, sino 4:3 cropImageView.setAspectRatio(editar ? imagePicto.getWidth() : 4,editar ? imagePicto.getHeight() : 3); //Si es editar un picto la ventana de recorte mantiene el tamaño de la imagen, sino 4:3
cropImageView.setImageBitmap(imagePicto); cropImageView.setImageBitmap(imagePicto);
cropImageView.setMaxWidth(imagePicto.getWidth()); cropImageView.setMaxWidth(imagePicto.getWidth());
...@@ -393,7 +373,7 @@ public class EditPictoActivity extends Activity { ...@@ -393,7 +373,7 @@ public class EditPictoActivity extends Activity {
//} //}
pathNumber = nRandom.nextInt(); pathNumber = nRandom.nextInt();
desplegableSupervisores.setOnClickListener(new View.OnClickListener() { supAsociado.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT))
...@@ -428,7 +408,7 @@ public class EditPictoActivity extends Activity { ...@@ -428,7 +408,7 @@ public class EditPictoActivity extends Activity {
String filepath = null; String filepath = null;
String audioPath = null; String audioPath = null;
try { try {
id_pic = getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE); id_pic = getIntent().getExtras()!=null ? getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE) : 0;
filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_pic + ".png" filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_pic + ".png"
...@@ -478,7 +458,7 @@ public class EditPictoActivity extends Activity { ...@@ -478,7 +458,7 @@ public class EditPictoActivity extends Activity {
intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,audioPath); //Mandar el path del audio intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,audioPath); //Mandar el path del audio
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString()); //Mandar expresion nueva intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString()); //Mandar expresion nueva
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1)); intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText()); intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText().equals(NO_SUP_TEXT)?null:supAsociado.getText());
//p.setUriSound(audioPath); //p.setUriSound(audioPath);
...@@ -706,10 +686,11 @@ public class EditPictoActivity extends Activity { ...@@ -706,10 +686,11 @@ public class EditPictoActivity extends Activity {
Bitmap rescaled = scale_image(imagen); Bitmap rescaled = scale_image(imagen);
cropImageView.setImageBitmap(rescaled); cropImageView.setImageBitmap(rescaled);
ByteArrayOutputStream stream = new ByteArrayOutputStream(); /*ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream); rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray); getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(rescaled);
} }
break; break;
...@@ -726,10 +707,11 @@ public class EditPictoActivity extends Activity { ...@@ -726,10 +707,11 @@ public class EditPictoActivity extends Activity {
Bitmap rescaled = scale_image(bitmap); Bitmap rescaled = scale_image(bitmap);
cropImageView.setImageBitmap(rescaled); cropImageView.setImageBitmap(rescaled);
ByteArrayOutputStream stream = new ByteArrayOutputStream(); /* ByteArrayOutputStream stream = new ByteArrayOutputStream();
rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream); rescaled.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray); getIntent().putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(rescaled);
} }
break; break;
} }
......
...@@ -16,6 +16,7 @@ import android.widget.Button; ...@@ -16,6 +16,7 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast;
import com.yottacode.pictogram.dao.User; import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.dao.UserLogin; import com.yottacode.pictogram.dao.UserLogin;
...@@ -83,13 +84,22 @@ public class SerialActivity extends Activity { ...@@ -83,13 +84,22 @@ public class SerialActivity extends Activity {
listaSup.setOnItemClickListener(new AdapterView.OnItemClickListener() { listaSup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); if (supUsers.elementAt(position).get_pwd_sup().equals("_")) {
SharedPreferences.Editor editor = settings.edit(); mSerialViewMail.setText(supUsers.elementAt(position).get_email_sup());
editor.putString("username", supUsers.elementAt(position).get_email_sup()); mSerialViewPass.setText("");
editor.putString("password", supUsers.elementAt(position).get_pwd_sup()); mSerialViewPass.requestFocus();
editor.commit(); Toast toast = Toast.makeText(PCBcontext.getContext(), R.string.insertPasswordLogin, Toast.LENGTH_SHORT);
new UserLogin().login(supUsers.elementAt(position).get_email_sup(), toast.show();
supUsers.elementAt(position).get_pwd_sup(),SerialActivity.this, PictogramActivity.class, LoginActivity.class);
} else {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("username", supUsers.elementAt(position).get_email_sup());
editor.putString("password", supUsers.elementAt(position).get_pwd_sup());
editor.commit();
new UserLogin().login(supUsers.elementAt(position).get_email_sup(),
supUsers.elementAt(position).get_pwd_sup(), SerialActivity.this, PictogramActivity.class, LoginActivity.class);
}
} }
}); });
} }
......
...@@ -29,6 +29,7 @@ import org.json.JSONObject; ...@@ -29,6 +29,7 @@ import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
...@@ -203,6 +204,11 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -203,6 +204,11 @@ public class StudentFragmentGrid extends Fragment{
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs); downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs);
} }
/**
* Recupera los supervisores de un alumno
* @author Germán Callejas
* @param stu_id
*/
private void download_supervisors(final int stu_id) { private void download_supervisors(final int stu_id) {
String token = getActivity().getIntent().getExtras().getString("token"); String token = getActivity().getIntent().getExtras().getString("token");
...@@ -226,19 +232,39 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -226,19 +232,39 @@ public class StudentFragmentGrid extends Fragment{
@Override @Override
public void result(JSONArray supervisors) { public void result(JSONArray supervisors) {
//String supervisorsFormat = ""; Vector<String> idSupervisoresJSON = new Vector<>();
for (int i=0;i<supervisors.length();i++) { for (int i=0;i<supervisors.length();i++) {
JSONObject supervisor; JSONObject supervisor = null;
try { try {
supervisor = supervisors.getJSONObject(i); supervisor = supervisors.getJSONObject(i);
//PCBcontext.getDevice().insertUser(new User(stu_id,null,null,null,null,null,null,null,null,(int) supervisor.get("id"),supervisor.get("email").toString(),null,supervisor.get("name").toString(), idSupervisoresJSON.add(supervisor.getString("email"));
// supervisor.get("surname").toString(), supervisor.get("pic").toString(),supervisor.get("gender").toString(),supervisor.get("lang").toString(),supervisor.get("ttsEngine").toString(),supervisor.get("office").toString())); if(!PCBcontext.getDevice().isSupervisorOnLocal((int) supervisor.get("id"))) {//Para comprobar si ya existe en local
//supervisorsFormat += supervisor.get("name") +" " + supervisor.get("surname") + "," + supervisor.get("email") + ";"; PCBcontext.getDevice().insertUser(new User(stu_id, PCBcontext.getPcbdb().getCurrentUser().get_nickname_stu(), PCBcontext.getPcbdb().getCurrentUser().get_pwd_stu()
, PCBcontext.getPcbdb().getCurrentUser().get_name_stu(), PCBcontext.getPcbdb().getCurrentUser().get_surname_stu(), PCBcontext.getPcbdb().getCurrentUser().get_url_img_stu()
, PCBcontext.getPcbdb().getCurrentUser().get_gender_stu(), PCBcontext.getPcbdb().getCurrentUser().get_lang_stu(), PCBcontext.getPcbdb().getCurrentUser().get_json_attrs(),
(int) supervisor.get("id"), supervisor.get("email").toString(), "_", supervisor.get("name").toString(), supervisor.get("surname").toString(), supervisor.get("pic").toString(),
supervisor.get("gender").toString(), supervisor.get("lang").toString(), supervisor.get("ttsEngine").toString(), supervisor.get("office").toString()));
}
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
//PCBcontext.getPcbdb().getCurrentUser().set_Supervisors(supervisorsFormat);
/**Eliminar los que habia y que ya no vienen en el JSON */
try {
Hashtable<String,String> supervisorsLocal = PCBcontext.getDevice().recoverSupervisors(stu_id);
if(supervisorsLocal != null && !supervisorsLocal.isEmpty()){
for(String email_sup: supervisorsLocal.keySet()){
if(!idSupervisoresJSON.contains(email_sup)){
//Coge la segunda parte ya que el formato del dato es Nombre, Apellidos;id_sup
PCBcontext.getDevice().deleteSupervisor(stu_id,Integer.parseInt(supervisorsLocal.get(email_sup).split(";")[1]));
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
} }
@Override @Override
......
...@@ -45,7 +45,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction ...@@ -45,7 +45,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
float firstTouchX=-1; float firstTouchX=-1;
ListInstructionsFragment listInstructionsFragment= new ListInstructionsFragment(); ListInstructionsFragment listInstructionsFragment= new ListInstructionsFragment();
boolean previous_mirrormode=PCBcontext.getPcbdb().getCurrentUser().is_mirror_on();
private void addLogMsg(final String msg) { private void addLogMsg(final String msg) {
...@@ -301,9 +301,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction ...@@ -301,9 +301,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
final Button failBtn =((Button)findViewById(R.id.btn_fail)); final Button failBtn =((Button)findViewById(R.id.btn_fail));
final Button supBtn =((Button)findViewById(R.id.btn_supervised)); final Button supBtn =((Button)findViewById(R.id.btn_supervised));
final Button modBtn =((Button)findViewById(R.id.btn_model)); final Button modBtn =((Button)findViewById(R.id.btn_model));
previous_mirrormode=PCBcontext.getPcbdb().getCurrentUser().is_mirror_on();
if (!PCBcontext.getPcbdb().getCurrentUser().is_mirror_on())
PCBcontext.getPcbdb().getCurrentUser().alter_mirror_mode();
SessionFragment sessionFragment = (SessionFragment) getSupportFragmentManager().findFragmentByTag(SessionActivity.FRAGMENT_SESSION); SessionFragment sessionFragment = (SessionFragment) getSupportFragmentManager().findFragmentByTag(SessionActivity.FRAGMENT_SESSION);
if (sessionFragment==null) sessionFragment=new SessionFragment(); if (sessionFragment==null) sessionFragment=new SessionFragment();
getSupportFragmentManager() getSupportFragmentManager()
...@@ -330,10 +328,6 @@ public class SessionActivity extends FragmentActivity implements ListInstruction ...@@ -330,10 +328,6 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
final Button supBtn =((Button)findViewById(R.id.btn_supervised)); final Button supBtn =((Button)findViewById(R.id.btn_supervised));
final Button modBtn =((Button)findViewById(R.id.btn_model)); final Button modBtn =((Button)findViewById(R.id.btn_model));
if (previous_mirrormode!=PCBcontext.getPcbdb().getCurrentUser().is_mirror_on())
PCBcontext.getPcbdb().getCurrentUser().alter_mirror_mode();
getSupportFragmentManager() getSupportFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.sessions_fragment_container, listInstructionsFragment, SessionActivity.FRAGMENT_METHOD) .replace(R.id.sessions_fragment_container, listInstructionsFragment, SessionActivity.FRAGMENT_METHOD)
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:textColor="@color/BlancoApp"
android:background="@color/VerdeApp" android:background="@color/VerdeApp"
android:paddingBottom="8dp" android:paddingBottom="8dp"
android:paddingTop="@dimen/content_padding_half" android:paddingTop="@dimen/content_padding_half"
android:text="@string/titleCropperNew" android:text="@string/titleCropperNew"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/BlancoApp"
android:textSize="24sp" /> android:textSize="24sp" />
<LinearLayout <LinearLayout
...@@ -109,34 +109,34 @@ ...@@ -109,34 +109,34 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/textAssociated" android:id="@+id/textView_Supevisor"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_marginTop="15dp"
android:text="Asociar a:" android:text="Supervisor:"
android:textColor="@color/gray" android:textColor="@color/gray"
android:textSize="20sp" /> android:textSize="20sp" />
<Button <Button
android:id="@+id/botonDesplegable" android:id="@+id/botonSupAsociado"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="Ver" /> android:textColor="@color/BlancoApp"
android:background="@color/VerdeApp"
android:text="___________" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:background="@color/VerdeApp"
/>
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/sup_actual"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="18sp" />
<TextView <TextView
android:id="@+id/textLegend" android:id="@+id/textLegend"
...@@ -163,13 +163,21 @@ ...@@ -163,13 +163,21 @@
android:textColorLink="?android:attr/colorAccent" android:textColorLink="?android:attr/colorAccent"
android:textCursorDrawable="@null" android:textCursorDrawable="@null"
android:textSize="20sp" /> android:textSize="20sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="@color/VerdeApp"
android:paddingBottom="4dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
/>
<TextView <TextView
android:id="@+id/textView_Audio" android:id="@+id/textView_Audio"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:text="Audio" android:text="Audio:"
android:textColor="@color/gray" android:textColor="@color/gray"
android:textSize="20sp" /> android:textSize="20sp" />
...@@ -291,9 +299,13 @@ ...@@ -291,9 +299,13 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:background="@color/VerdeApp" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
...@@ -335,6 +347,8 @@ ...@@ -335,6 +347,8 @@
android:layout_width="250dp" android:layout_width="250dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="right|end" android:layout_gravity="right|end"
android:background="#ffeeeeee"/> android:background="@color/VerdeApp"
android:headerDividersEnabled="false"
android:textColor="@color/BlancoApp" />
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
<string name="uploadingImage">Subiendo imagen al servidor</string> <string name="uploadingImage">Subiendo imagen al servidor</string>
<string name="titleCropperEdit">Edit Picto</string> <string name="titleCropperEdit">Edit Picto</string>
<string name="titleCropperNew">New Picto</string> <string name="titleCropperNew">New Picto</string>
<string name="insertPasswordLogin">Insert Password</string>
</resources> </resources>
<resources> <resources>
<string name="app_name">com.yottacode.pictogram.Tablet</string> <string name="app_name">com.yottacode.pictogram.Tablet</string>
<string name="alumnos">Estrudiantes</string> <string name="alumnos">Alumnos</string>
<string name="supervisores">Supervisores</string> <string name="supervisores">Supervisores</string>
<item name="maxInTape" type="integer">8</item> <item name="maxInTape" type="integer">8</item>
<item name="maxInTape_big" type="integer">6</item> <item name="maxInTape_big" type="integer">6</item>
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
<string name="cancel">Cancelar</string> <string name="cancel">Cancelar</string>
<string name="titleCropperEdit">Editar Pictograma</string> <string name="titleCropperEdit">Editar Pictograma</string>
<string name="titleCropperNew">Nuevo Pictograma</string> <string name="titleCropperNew">Nuevo Pictograma</string>
<string name="insertPasswordLogin">Inserte Contraseña</string>
</resources> </resources>
...@@ -49,4 +49,5 @@ ...@@ -49,4 +49,5 @@
<string name="cancel">Cancel</string> <string name="cancel">Cancel</string>
<string name="drawer_open">Open Menu</string> <string name="drawer_open">Open Menu</string>
<string name="drawer_close">Close Menu</string> <string name="drawer_close">Close Menu</string>
<string name="insertPasswordLogin">Inserte Contraseña</string>
</resources> </resources>
...@@ -62,13 +62,6 @@ ...@@ -62,13 +62,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
...@@ -76,6 +69,13 @@ ...@@ -76,6 +69,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
...@@ -121,5 +121,17 @@ ...@@ -121,5 +121,17 @@
<orderEntry type="library" exported="" name="ion-2.1.9" level="project" /> <orderEntry type="library" exported="" name="ion-2.1.9" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" />
<orderEntry type="module" module-name="commonlibrary" exported="" /> <orderEntry type="module" module-name="commonlibrary" exported="" />
<orderEntry type="library" exported="" name="android-android-24" level="project" />
<orderEntry type="library" exported="" name="okhttp-ws-2.3.0" level="project" />
<orderEntry type="library" exported="" name="socket.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.3.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="library" exported="" name="okio-1.3.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" />
<orderEntry type="library" exported="" name="engine.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="json-20090211" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
...@@ -441,9 +441,9 @@ COMMENT="This table stores working session information. Every working session is ...@@ -441,9 +441,9 @@ COMMENT="This table stores working session information. Every working session is
CREATE TABLE IF NOT EXISTS `scene` ( CREATE TABLE IF NOT EXISTS `scene` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`active` boolean NULL DEFAULT 0, `active` boolean NOT NULL DEFAULT 0,
`categories` boolean NULL DEFAULT 0, `categories` boolean NOT NULL DEFAULT 0,
`id_sup` int(11) NOT NULL, `id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL, `id_stu` int(11) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`), FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
...@@ -540,7 +540,7 @@ ALTER TABLE `picto_tag` ...@@ -540,7 +540,7 @@ ALTER TABLE `picto_tag`
ALTER TABLE `stu_picto` ALTER TABLE `stu_picto`
ADD CONSTRAINT `fk_picto` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`), ADD CONSTRAINT `fk_picto` FOREIGN KEY (`id_pic`) REFERENCES `picto` (`id`),
ADD CONSTRAINT `stu_picto_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`), ADD CONSTRAINT `stu_picto_ibfk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`),
ADD CONSTRAINT `stu_picto_scene_fk` FOREIGN KEY (`id_scene`) REFERENCES `scene` (`id`); ADD CONSTRAINT `stu_picto_scene_fk` FOREIGN KEY (`id_scene`) REFERENCES `scene` (`id`) ON DELETE CASCADE;
-- --
-- Filtros para la tabla `stu_sup` -- Filtros para la tabla `stu_sup`
......
/* /*
SET FOREIGN_KEY_CHECKS = 0;
ALTER TABLE stu_picto DROP FOREIGN KEY stu_picto_scene_fk; ALTER TABLE stu_picto DROP FOREIGN KEY stu_picto_scene_fk;
ALTER TABLE stu_picto DROP COLUMN id_scene;
ALTER TABLE stu_picto DROP id_scene; ALTER TABLE stu_picto DROP id_scene;
DROP TABLE scene; DROP TABLE scene;
SET FOREIGN_KEY_CHECKS = 1;
*/ */
DELIMITER $$ DELIMITER $$
...@@ -13,6 +14,8 @@ CREATE PROCEDURE scene_adapt() ...@@ -13,6 +14,8 @@ CREATE PROCEDURE scene_adapt()
BEGIN BEGIN
DECLARE _id_stu INT; DECLARE _id_stu INT;
DECLARE _id_sup INT; DECLARE _id_sup INT;
DECLARE _cat_status CHAR(10);
DECLARE _cat_active BOOLEAN;
DECLARE done INT DEFAULT FALSE; DECLARE done INT DEFAULT FALSE;
DECLARE LID INT; DECLARE LID INT;
...@@ -30,11 +33,19 @@ BEGIN ...@@ -30,11 +33,19 @@ BEGIN
LEAVE read_loop; LEAVE read_loop;
END IF; END IF;
SELECT `id_sup` INTO _id_sup FROM `stu_sup` WHERE `id_stu` = _id_stu LIMIT 1; SELECT CAST(attributes->"$.categories" as CHAR(10)) INTO _cat_status FROM student WHERE id = _id_stu;
/* FIRST SCENE, ACTIVE, WITH CATEGORIES */ IF (_cat_status LIKE '%on%') THEN
INSERT INTO `scene` (name, active, categories, id_sup, id_stu) SET _cat_active = 1;
VALUES ('with_categories', 1, 1, _id_sup, _id_stu); /*SELECT CONCAT('active: ', _cat_active);*/
ELSE
SET _cat_active = 0;
/*SELECT CONCAT('active: ', NOT _cat_active);*/
END IF;
/* FIRST SCENE, ACTIVE, WITH CATEGORIES*/
INSERT INTO `scene` (name, active, categories, id_stu)
VALUES ('with_categories', _cat_active, 1, _id_stu);
SET LID = LAST_INSERT_ID(); SET LID = LAST_INSERT_ID();
...@@ -44,9 +55,9 @@ BEGIN ...@@ -44,9 +55,9 @@ BEGIN
AND attributes->"$.free_category_coord_x" IS NULL AND attributes->"$.free_category_coord_x" IS NULL
AND attributes->"$.free_category_coord_y" IS NULL; AND attributes->"$.free_category_coord_y" IS NULL;
/* SECOND SCENE, NOT ACTIVE, NO CATEGORIES */ /* SECOND SCENE, NOT ACTIVE, NO CATEGORIES*/
INSERT INTO `scene` (name, active, categories, id_sup, id_stu) INSERT INTO `scene` (name, active, categories, id_sup, id_stu)
VALUES ('no_categories', 0, 0, _id_sup, _id_stu); VALUES ('no_categories', NOT _cat_active, 0, _id_sup, _id_stu);
SET LID = LAST_INSERT_ID(); SET LID = LAST_INSERT_ID();
......
...@@ -190,7 +190,7 @@ INSERT IGNORE INTO `student` ( ...@@ -190,7 +190,7 @@ INSERT IGNORE INTO `student` (
NULL, NULL,
'es-es', 'es-es',
(SELECT id from office WHERE email='belen.perez@autismojaen.es'), (SELECT id from office WHERE email='belen.perez@autismojaen.es'),
'{"stu-att":[{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}]}' '{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}'
), ( ), (
'alumno2', 'alumno2',
'$2a$10$RUv25u.C/waYE4xxbfTWTe/IBNQfIFFP5dKPTJsqYznbkS3QCvqq2', '$2a$10$RUv25u.C/waYE4xxbfTWTe/IBNQfIFFP5dKPTJsqYznbkS3QCvqq2',
...@@ -203,7 +203,7 @@ INSERT IGNORE INTO `student` ( ...@@ -203,7 +203,7 @@ INSERT IGNORE INTO `student` (
NULL, NULL,
'es-es', 'es-es',
(SELECT id from office WHERE email='belen.perez@autismojaen.es'), (SELECT id from office WHERE email='belen.perez@autismojaen.es'),
'{"stu-att":[{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}]}' '{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}'
), ( ), (
'alumno3', 'alumno3',
'$2a$10$Ei9E2Pz8sJ4aojbMPsdfZ.xz.LrWG4op1koC4LwCxHr.A0MgeP4m6', '$2a$10$Ei9E2Pz8sJ4aojbMPsdfZ.xz.LrWG4op1koC4LwCxHr.A0MgeP4m6',
...@@ -216,7 +216,7 @@ INSERT IGNORE INTO `student` ( ...@@ -216,7 +216,7 @@ INSERT IGNORE INTO `student` (
NULL, NULL,
'es-es', 'es-es',
(SELECT id from office WHERE email='belen.perez@autismojaen.es'), (SELECT id from office WHERE email='belen.perez@autismojaen.es'),
'{"stu-att":[{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}]}' '{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}'
-- 'manuel', -- 'manuel',
-- '$2a$06$SaAswfsdqGpSo/bE.Cks8.CJnpqHGjixdRLGGpdOHWVFJR2w0fTaS', -- '$2a$06$SaAswfsdqGpSo/bE.Cks8.CJnpqHGjixdRLGGpdOHWVFJR2w0fTaS',
...@@ -229,7 +229,7 @@ INSERT IGNORE INTO `student` ( ...@@ -229,7 +229,7 @@ INSERT IGNORE INTO `student` (
-- NULL, -- NULL,
-- 'es-es', -- 'es-es',
-- (SELECT id from office WHERE email='belen.perez@autismojaen.es'), -- (SELECT id from office WHERE email='belen.perez@autismojaen.es'),
-- '{"stu-att":[{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}]}' -- '{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}'
-- ), ( -- ), (
-- 'jose', -- 'jose',
-- '$2a$06$WtRXXLwFrEdDzB7r0r54RuY5A9wX3aysUIM8AHAGPpfVxhbNISBIa', -- '$2a$06$WtRXXLwFrEdDzB7r0r54RuY5A9wX3aysUIM8AHAGPpfVxhbNISBIa',
...@@ -242,7 +242,7 @@ INSERT IGNORE INTO `student` ( ...@@ -242,7 +242,7 @@ INSERT IGNORE INTO `student` (
-- NULL, -- NULL,
-- 'es-es', -- 'es-es',
-- (SELECT id from office WHERE email='belen.perez@autismojaen.es'), -- (SELECT id from office WHERE email='belen.perez@autismojaen.es'),
-- '{"stu-att":[{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}]}' -- '{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}'
-- ), ( -- ), (
-- 'carmen', -- 'carmen',
-- '$2a$06$2c4zNE1Bkc24AXiXATbn8OfgkM/r9DJzUfnJ8qHrDUxBkMQd8rUIG', -- '$2a$06$2c4zNE1Bkc24AXiXATbn8OfgkM/r9DJzUfnJ8qHrDUxBkMQd8rUIG',
...@@ -255,7 +255,7 @@ INSERT IGNORE INTO `student` ( ...@@ -255,7 +255,7 @@ INSERT IGNORE INTO `student` (
-- NULL, -- NULL,
-- 'es-es', -- 'es-es',
-- (SELECT id from office WHERE email='belen.perez@autismojaen.es'), -- (SELECT id from office WHERE email='belen.perez@autismojaen.es'),
-- '{"stu-att":[{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}]}' -- '{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}'
); );
-- --
......
...@@ -223,7 +223,7 @@ INSERT INTO `student` ( ...@@ -223,7 +223,7 @@ INSERT INTO `student` (
'test_caja_juan.jpg', 'test_caja_juan.jpg',
NULL, NULL,
'es-es', 'es-es',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "es" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "es" }'
), ( ), (
'faf0002', 'faf0002',
'$2a$10$FOJ2fmJaHyI5sWe1tQojFuhoPpqHSTVPwvHPTpWEftFPI28VdyYNq', '$2a$10$FOJ2fmJaHyI5sWe1tQojFuhoPpqHSTVPwvHPTpWEftFPI28VdyYNq',
...@@ -235,7 +235,7 @@ INSERT INTO `student` ( ...@@ -235,7 +235,7 @@ INSERT INTO `student` (
'test_caja_kate.jpg', 'test_caja_kate.jpg',
NULL, NULL,
'en-gb', 'en-gb',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }'
), ( ), (
'mam0001', 'mam0001',
'$2a$10$zygC/WviDviyZQsMsNqK8.tSUI4Qr/dLlLrw0i5kR1bbN4SeU5ACq', '$2a$10$zygC/WviDviyZQsMsNqK8.tSUI4Qr/dLlLrw0i5kR1bbN4SeU5ACq',
...@@ -247,7 +247,7 @@ INSERT INTO `student` ( ...@@ -247,7 +247,7 @@ INSERT INTO `student` (
'test_caja_carlos.jpg', 'test_caja_carlos.jpg',
NULL, NULL,
'es-es', 'es-es',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "es" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "es" }'
), ( ), (
'mam0002', 'mam0002',
'$2a$10$xbyNUhf9rqhdXDBrvUSiOuJIzUVOyyz9ToQMCByFThiiiPwO0PWgK', '$2a$10$xbyNUhf9rqhdXDBrvUSiOuJIzUVOyyz9ToQMCByFThiiiPwO0PWgK',
...@@ -259,7 +259,7 @@ INSERT INTO `student` ( ...@@ -259,7 +259,7 @@ INSERT INTO `student` (
'test_caja_rocio.jpg', 'test_caja_rocio.jpg',
NULL, NULL,
'es-es', 'es-es',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }'
), ( ), (
'aaa0001', 'aaa0001',
'$2a$10$koWKIn42UNSi1N67akxjpOuJNwpXJ/vOe6biD2xkjrUz6dr3g.Wa.', '$2a$10$koWKIn42UNSi1N67akxjpOuJNwpXJ/vOe6biD2xkjrUz6dr3g.Wa.',
...@@ -271,7 +271,7 @@ INSERT INTO `student` ( ...@@ -271,7 +271,7 @@ INSERT INTO `student` (
'test_caja_samuel.jpg', 'test_caja_samuel.jpg',
NULL, NULL,
'es-es', 'es-es',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "es" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "es" }'
), ( ), (
'aaa0002', 'aaa0002',
'$2a$10$ffAjZjWN0UKja0JO7ko6qup4x2phbY3VpC66TmpMnGdWUutBFeWY2', '$2a$10$ffAjZjWN0UKja0JO7ko6qup4x2phbY3VpC66TmpMnGdWUutBFeWY2',
...@@ -283,7 +283,7 @@ INSERT INTO `student` ( ...@@ -283,7 +283,7 @@ INSERT INTO `student` (
'test_caja_adela.jpg', 'test_caja_adela.jpg',
NULL, NULL,
'es-es', 'es-es',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }'
), ( ), (
'aaa0003', 'aaa0003',
'$2a$10$glc5A6vyPve5.4407Vdkau5CHF3GOpA0Uo6rxMDdIopIWTJK0nBse', '$2a$10$glc5A6vyPve5.4407Vdkau5CHF3GOpA0Uo6rxMDdIopIWTJK0nBse',
...@@ -295,7 +295,7 @@ INSERT INTO `student` ( ...@@ -295,7 +295,7 @@ INSERT INTO `student` (
'test_caja_adela.jpg', 'test_caja_adela.jpg',
NULL, NULL,
'es-es', 'es-es',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }'
), ( ), (
'aaa0004', 'aaa0004',
'$2a$10$tezK07jq5ZMdQbCboubEBeHiXWJisZPAbgN301n5kRLXkq8xOlb4O', '$2a$10$tezK07jq5ZMdQbCboubEBeHiXWJisZPAbgN301n5kRLXkq8xOlb4O',
...@@ -307,7 +307,7 @@ INSERT INTO `student` ( ...@@ -307,7 +307,7 @@ INSERT INTO `student` (
'test_caja_juan.jpg', 'test_caja_juan.jpg',
NULL, NULL,
'es-es', 'es-es',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }'
), ( ), (
'jaj0001', 'jaj0001',
'$2a$10$UQYGXOOE8mxxOjvgo8cjwOpsv5jCtRXpMTLpbD3TzMBiUIv3hXlnO', '$2a$10$UQYGXOOE8mxxOjvgo8cjwOpsv5jCtRXpMTLpbD3TzMBiUIv3hXlnO',
...@@ -319,7 +319,7 @@ INSERT INTO `student` ( ...@@ -319,7 +319,7 @@ INSERT INTO `student` (
'test_caja_adela.jpg', 'test_caja_adela.jpg',
NULL, NULL,
'es-es', 'es-es',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }'
), ( ), (
'jaj0002', 'jaj0002',
'$2a$10$tVy3Wfu35l4B6bFpnjJCE.ckjncq6YCKMGW4B9abesbiFVeyGu2Dy', '$2a$10$tVy3Wfu35l4B6bFpnjJCE.ckjncq6YCKMGW4B9abesbiFVeyGu2Dy',
...@@ -331,7 +331,7 @@ INSERT INTO `student` ( ...@@ -331,7 +331,7 @@ INSERT INTO `student` (
'test_caja_samuel.jpg', 'test_caja_samuel.jpg',
NULL, NULL,
'es-es', 'es-es',
'{"stu-att" : [{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }]}' '{ "categories" : "on", "input feedback" : [ "vibration", "tts" ], "input selection" : "click", "pictogram size" : "medium", "tts engine" : "IVONA Text-to-Speech HQ", "tts voice": "en" }'
); );
-- --
......
...@@ -74,7 +74,7 @@ INSERT IGNORE INTO `student` ( ...@@ -74,7 +74,7 @@ INSERT IGNORE INTO `student` (
NULL, NULL,
'es-es', 'es-es',
(SELECT id from office WHERE email='centrodestrezas@gmail.com'), (SELECT id from office WHERE email='centrodestrezas@gmail.com'),
'{"stu-att":[{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}]}' '{"categories":"on","input feedback":["vibration","tts"],"input selection":"click","pictogram size":"medium"}'
); );
INSERT IGNORE INTO `stu_picto` ( INSERT IGNORE INTO `stu_picto` (
......
...@@ -41,6 +41,7 @@ CREATE TRIGGER TRG_NEW_STUDENT_UPDATE_ENROLMENTS ...@@ -41,6 +41,7 @@ CREATE TRIGGER TRG_NEW_STUDENT_UPDATE_ENROLMENTS
AFTER INSERT ON student AFTER INSERT ON student
FOR EACH ROW FOR EACH ROW
thisTrigger: BEGIN thisTrigger: BEGIN
DECLARE LID INT;
IF ((@TRIGGER_CHECKS = FALSE) IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE)) OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost') AND (USER() = 'root@localhost')
...@@ -48,9 +49,22 @@ thisTrigger: BEGIN ...@@ -48,9 +49,22 @@ thisTrigger: BEGIN
LEAVE thisTrigger; LEAVE thisTrigger;
END IF; END IF;
-- Load core collection for student -- Load core collection for student
INSERT INTO stu_picto(id_stu,id_pic,attributes) INSERT INTO scene (id_stu,id_sup,name,active,categories) VALUES (new.id, null, 'with_categories', TRUE, TRUE);
SELECT new.id,id_pic, concat('{"id_cat":', if (id_cat_pic is null, 'null', id_cat_pic), SET LID = LAST_INSERT_ID();
CALL scene_create_core(LID,new.id);
END;;
-- Procedure to add core when new scene is created
DROP PROCEDURE IF EXISTS scene_create_core ;
CREATE PROCEDURE scene_create_core(IN id_scene INTEGER, IN id_stu INTEGER)
BEGIN
-- Load core collection for student
INSERT INTO stu_picto(id_stu,id_pic,id_scene,attributes)
SELECT id_stu,id_pic,id_scene, concat('{"id_cat":', if (id_cat_pic is null, 'null', id_cat_pic),
',"coord_x":',coord_x, ',"coord_x":',coord_x,
',"coord_y":',coord_y, ',"coord_y":',coord_y,
',"status":"invisible"', ',"status":"invisible"',
...@@ -84,3 +98,5 @@ thisTrigger: BEGIN ...@@ -84,3 +98,5 @@ thisTrigger: BEGIN
END IF; END IF;
END IF; END IF;
END;; END;;
DELIMITER ;
...@@ -32,6 +32,14 @@ ...@@ -32,6 +32,14 @@
state: import state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/arasaac.sql" target: "{{ server_path }}/{{ database_files_relative_path }}/arasaac.sql"
- name: Imports arasaac pictos
mysql_db:
login_user: "{{ database_user }}"
login_password: "{{ database_user_passwd }}"
name: "{{ database_name }}"
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/arasaac_byn.sql"
- name: Imports application essential data - name: Imports application essential data
mysql_db: mysql_db:
...@@ -50,6 +58,14 @@ ...@@ -50,6 +58,14 @@
target: "{{ server_path }}/{{ database_files_relative_path }}/test-{{ item }}.sql" target: "{{ server_path }}/{{ database_files_relative_path }}/test-{{ item }}.sql"
with_items: "{{ database_tests }}" with_items: "{{ database_tests }}"
- name: Create scenes for existing stu_picto
mysql_db:
login_user: "{{ database_user }}"
login_password: "{{ database_user_passwd }}"
name: "{{ database_name }}"
state: import
target: "{{ server_path }}/{{ database_files_relative_path }}/scene_adapt.sql"
- name: Creates triggers - name: Creates triggers
mysql_db: mysql_db:
login_user: "{{ database_user }}" login_user: "{{ database_user }}"
......
...@@ -23,9 +23,9 @@ Changes to be performed manually in servers to upgrade ...@@ -23,9 +23,9 @@ Changes to be performed manually in servers to upgrade
`CREATE TABLE IF NOT EXISTS `scene` ( `CREATE TABLE IF NOT EXISTS `scene` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`active` boolean NULL DEFAULT 0, `active` boolean NOT NULL DEFAULT 0,
`categories` boolean NULL DEFAULT 0, `categories` boolean NOT NULL DEFAULT 0,
`id_sup` int(11) NOT NULL, `id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL, `id_stu` int(11) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`), FOREIGN KEY (`id_sup`) REFERENCES `supervisor` (`id`),
...@@ -35,12 +35,15 @@ Changes to be performed manually in servers to upgrade ...@@ -35,12 +35,15 @@ Changes to be performed manually in servers to upgrade
- alter table stu_picto to add new reference to scene - alter table stu_picto to add new reference to scene
`ALTER TABLE `stu_picto` ADD id_scene int(11) NOT NULL;` `ALTER TABLE `stu_picto` ADD id_scene int(11) NOT NULL;`
`ALTER TABLE `stu_picto` ADD CONSTRAINT `stu_picto_scene_fk` FOREIGN KEY (`id_scene`) REFERENCES `scene` (`id`);` `ALTER TABLE `stu_picto` ADD CONSTRAINT `stu_picto_scene_fk` FOREIGN KEY (`id_scene`) REFERENCES `scene` (`id`) ON DELETE CASCADE;`
(si hay problema al añadir la foreign key, hacer SET FOREIGN_KEY_CHECKS = 0; antes de añadirla y SET FOREIGN_KEY_CHECKS = 1; después) (si hay problema al añadir la foreign key, hacer SET FOREIGN_KEY_CHECKS = 0; antes de añadirla y SET FOREIGN_KEY_CHECKS = 1; después)
- load default scenes procedure - load default scenes procedure
`source /vagrant/roles/database/files/scene_adapt.sql` `source /vagrant/roles/database/files/scene_adapt.sql`
- Reload enrolments trigger
`source /vagrant/roles/database/files/triggers-enrolments-integrity-constraints.sql;`
(already done in dev & pre) (already done in dev & pre)
- add new column to license: - add new column to license:
......
/* global Student, PictoCore, VStuLastInstruction, StuPicto, StuSup, sailsTokenAuth, sails,
Picto */
/**
/* StudentController
*
* @description :: Server-side logic for managing students
* @help :: See http://links.sailsjs.org/docs/controllers
*/
module.exports = {
//
// Adds a new scene into the database
//
create: function (req, res) {
var params = req.params.all();
Scene.create({
name: params.name,
active: false,
categories: params.categories,
supervisor: params.id_sup,
student: params.id_stu
}).then(scene=>{
if(scene.categories){
Model.query('CALL scene_create_core('+scene.id+','+scene.student+') ', function(err, result) {
if (err) {
return res.serverError("Could not call stored procedure create scene picto core "+err);
} else {
return res.ok(scene);
}
});
}
return res.ok(scene);
}).catch(function (err){
return res.serverError("Error creating scene: " + err);
});
},
//
// Update a scene data
//
update: function (req, res) {
var params= req.allParams();
if (typeof req.params.id == 'undefined' || !req.params.id)
return res.badRequest("scene id not defined");
//If active field is true, check if other scene is active before
if(params.active){
Scene.findOne({active:true, student:params.id_stu})
.then(function(scene){
if(scene.id != req.params.id){
//Is not same scene so it might be deactivated
scene.active = false;
scene.save(function(err){
if(err){
return res.serverError("Could not deactivate previos active_scene");
}
});
}
}).catch(function(err){
return res.serverError("Could not find active_scene");
});
}
Scene.findOne({ id: params.id }).then(function (scene) {
if (!scene) {
res.badRequest();
throw new Error('Scene not found');
}
delete scene.categories;//To avoid update these fields
delete scene.supervisor;
delete scene.student;
scene.name = params.name || scene.name;
if (typeof params.active == 'undefined' || !params.active)
scene.active = scene.active;
else
scene.active = params.active;
scene.save(function (error) {
if (error) {
return res.serverError("Could not save scene "+ error);
}
var cat = false;
if(scene.active){
cat=true;
}
Student.findOne({id:scene.student})
.then(student => {
student.attributes.categories=cat;
delete student.password;
student.save(function(error){
if(error){
return res.serverError("Error saving student data");
}
else{
return res.ok(scene);
}
})
});
});
})
.catch(function (err) {
res.serverError("Could not find scene "+err);
});
},
/**
* Delete a scene by its ID
* @param {request} req {} (with sceneId as url parameter)
* @param {response} res {}
*/
destroy: function (req, res) {
if (typeof req.params.id == 'undefined' || !req.params.id)
return res.badRequest("scene id not defined");
Scene.destroy({ id: req.params.id }).exec(function (error) {
if (error)
return res.badRequest();
else
return res.ok();
});
},
/**
* Return a scene with all StuPicto
* @param {request} req {} (with sceneId as url parameter)
* @param {response} res {}
*/
getScene: function(req, res){
if (typeof req.params.id == 'undefined' || !req.params.id)
return res.badRequest("scene id not defined");
Scene.findOne({id: req.params.id})
.populate('stuPictos').then(function(scene){
if(!scene){
return res.badRequest();
}
else{
Scene.pictos(scene.id, function(err, pictos){
if (err){
return res.serverError("Error obtaining pictos: "+ err);
}
scene.pictos=pictos;
return res.ok(scene);
});
}
}).catch(function (err){
return res.serverError("Error finding scene "+err);
});
},
/**
* Copies a scene with its stu_pictos
* @param {request} req {} (id of source scene)
*/
duplicate: function(req,res){
Scene.findOne({id:req.params.id})
.populate('stuPictos').then(function(scene){
Scene.create({
name: scene.name,
active: false,
categories: scene.categories,
supervisor: scene.supervisor,
student: scene.student
}).then(newScene=>{
scene.stuPictos.forEach(function (stuPicto, cb) {
StuPicto.create({
student: stuPicto.student,
picto: stuPicto.picto,
scene: newScene.id,
attributes: stuPicto.attributes
}).catch(function (err){
console.log("Error creating stu_picto "+err.details);
sails.log.error(err.details);
});
});
return res.ok(newScene);
}).catch(function (err){
return res.serverError("Error creating scene: " + err);
});
});
},
//
// Logs a scene action and broadcast to anyone subscribed to this student
scene: function (req, res) {
var action = req.param('action');
var scene = req.param('scene');
var roomName = 'studentRoom' + scene.student;
if (req.isSocket) {
sails.log.debug("Inside scene - isSocket");
// Send to all sockets subscribed to this room except the own socket that sends the message
// Parameters: room, action, data to send, socket to avoid sending (the socket that send this)
sails.sockets.broadcast(roomName, 'scene', {
"action": action,
"scene": scene
}, req.socket);
res.json({
msg: "Action " + action + " in scene " + scene.id + " from student " + scene.student
});
}
},
};
...@@ -818,6 +818,51 @@ module.exports = { ...@@ -818,6 +818,51 @@ module.exports = {
}); });
}, },
/**
* Return the active scene of a student with all StuPicto
* @param {request} req {} (with studentId as url parameter)
* @param {response} res {}
*/
getActiveScene: function(req, res){
if (typeof req.params.id_stu == 'undefined' || !req.params.id_stu)
return res.badRequest("id_stu not defined");
Scene.findOne({student: req.params.id_stu, active: true})
.populate('stuPictos')
.then(function(scene){
if(!scene)
return res.badRequest("Scene not found");
else
Scene.pictos(scene.id, function(err, pictos){
if (err){
return res.serverError("Error obtaining pictos: "+ err);
}
scene.pictos=pictos;
return res.ok(scene);
});
}).catch(function (err){
return res.serverError("Error finding scene "+err);
});
},
/**
* Return all scenes of a student
* @param {request} req {} (with studentId as url parameter)
* @param {response} res {}
*/
getScenes: function(req, res){
if (typeof req.params.id_stu == 'undefined' || !req.params.id_stu)
return res.badRequest("id_stu not defined");
Scene.find({student: req.params.id_stu})
.then(function(scenes){
if(!scenes)
return res.badRequest("No scenes found");
else
return res.ok(scenes);
}).catch(function (err){
return res.serverError("Error finding scene "+err);
});
},
// //
// Returns all working sessions for the given student // Returns all working sessions for the given student
// //
...@@ -847,8 +892,9 @@ module.exports = { ...@@ -847,8 +892,9 @@ module.exports = {
/** /**
* Add an existing picto to the student's collection * Add an existing picto to the student's collection
* @param {request} req (with id_stu and id_picto as url parameters) * @param {request} req (with id_scene,id_stu and id_picto as url parameters)
* { * {
* id_scene,
* id_stu, * id_stu,
* id_picto, * id_picto,
* attributes: { @see StuPicto.getValidAttributes() } * attributes: { @see StuPicto.getValidAttributes() }
...@@ -883,7 +929,7 @@ module.exports = { ...@@ -883,7 +929,7 @@ module.exports = {
add_picto: function (req, res) { add_picto: function (req, res) {
var params = req.allParams(); var params = req.allParams();
StuPicto.find({id_pic: params.id_picto, id_stu: params.id_stu}) StuPicto.find({id_pic: params.id_picto, id_stu: params.id_stu, id_scene:params.id_scene})
.then((entries) => { .then((entries) => {
if (entries && entries.length > 0) { if (entries && entries.length > 0) {
var err = new Error("Picto already in student's vocabulary"); var err = new Error("Picto already in student's vocabulary");
...@@ -916,6 +962,7 @@ module.exports = { ...@@ -916,6 +962,7 @@ module.exports = {
StuPicto.create({ StuPicto.create({
student: student.id, student: student.id,
picto: picto.id, picto: picto.id,
scene: params.id_scene,
attributes: params.attributes attributes: params.attributes
}) })
, ,
......
...@@ -134,7 +134,7 @@ module.exports = function eventsHook(sails) { ...@@ -134,7 +134,7 @@ module.exports = function eventsHook(sails) {
}, },
/** /**
* Vocabulary is updated * Vocabulary is updated (active scene)
* @param {action} type of the action * @param {action} type of the action
* @param {attributes} attributes of the action (id_stu, stu_picto) * @param {attributes} attributes of the action (id_stu, stu_picto)
* @return {Object} {name, data} * @return {Object} {name, data}
...@@ -147,6 +147,22 @@ module.exports = function eventsHook(sails) { ...@@ -147,6 +147,22 @@ module.exports = function eventsHook(sails) {
attributes: attributes attributes: attributes
} }
}; };
},
/**
* Scene is updated
* @param {action} type of the action
* @param {attributes} attributes of the action (id_stu, stu_picto)
* @return {Object} {name, data}
*/
scene: function (action, scene) {
return {
name: 'scene',
data: {
scene: scene,
action: action
}
};
} }
}; };
}; };
/**
* scene.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 : 'scene',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
autoIncrement: true,
primaryKey: true,
unique: true
},
name: {
required: true,
type: "string",
size: 100
},
active: {
type: "boolean"
},
categories: {
type: "boolean"
},
supervisor: { //FK de supervisor 1 a N
columnName: "id_sup",
required: false,
type: "integer",
model: "supervisor"
},
student: { // FK de student 1 a N
columnName: "id_stu",
required: true,
type: "integer",
model: "student"
},
// Relacion con Stu_picto
stuPictos:{
collection: "stupicto",
via: "scene"
}
},
//
// Class method for getting the list of pictos associated to a given
// scene
pictos: function(id_scene, callback) {
var l = [];
var fs = require('fs');
Scene.findOne(id_scene)
.then((scene) => {
if (!scene)
throw new Error("No scene found");
var stuPictos = StuPicto.find({scene: id_scene})
.populate('picto')
.then((stuPictos) => {
if (!stuPictos || stuPictos.length == 0)
return [];
return stuPictos;
})
.catch((err) => {
throw err;
});
var student = Student.findOne(scene.student).then(student=>{
if (!student)
return [];
return student;
}).catch( (err) => {
throw err;
});
return [scene, stuPictos, student];
})
.spread((scene, stuPictos, student) => {
async.eachSeries(stuPictos, function(stuPicto, next_cb) {
// Populate expressions to get it with the picto
Picto.findOne(stuPicto.picto.id)
.populate('expressions', {lang: student.lang})
.populate('tags', {lang: student.lang})
.then((picto) => {
// 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(function(found) {
if (found) {
// Now we have everything, so we add the picto to the list
stuPicto.attributes.expression = stuPicto.attributes.expression ? stuPicto.attributes.expression : picto.expressions[0].text;
var stuPictoToAdd = {
"id": stuPicto.id,
"picto": stuPicto.picto,
"attributes": stuPicto.attributes,
"tags": picto.tags ? picto.tags : []
};
l.push(stuPictoToAdd);
next_cb();
} else {
next_cb();
}
});
})
.catch((err) => {
next_cb(err);
});
},
function (err) { // loop has end
callback(err, l);
}); // end async.eachSeries
})
.catch((err) => {
callback(err, l);
}); // end Scene.findOne
}
};
...@@ -32,6 +32,11 @@ module.exports = { ...@@ -32,6 +32,11 @@ module.exports = {
type: 'integer', type: 'integer',
model: 'Picto' model: 'Picto'
}, },
scene: { //FK de Scene 1 a N
columnName: "id_scene",
type: "integer",
model: "Scene"
},
/** /**
* This "extra" property allow us to adapt the server to the student needs * This "extra" property allow us to adapt the server to the student needs
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
"birthdate": "Birthdate", "birthdate": "Birthdate",
"black_and_white": "B&W", "black_and_white": "B&W",
"cancel": "Cancel", "cancel": "Cancel",
"cant_delete_active_scene": "Active scene could not be deleted, deactive it first",
"cannot_delete_method": "Method could not be deleted, maybe due to existing recorded sessions.", "cannot_delete_method": "Method could not be deleted, maybe due to existing recorded sessions.",
"cannot_delete_instruction": "Instruction could not be deleted, maybe due to existing recorded sessions.", "cannot_delete_instruction": "Instruction could not be deleted, maybe due to existing recorded sessions.",
"case_requested": "Please, specify your user case", "case_requested": "Please, specify your user case",
...@@ -132,6 +133,8 @@ ...@@ -132,6 +133,8 @@
"error_on_upload": "Error on image upload. The maximum allowed size for images is 1 MB.", "error_on_upload": "Error on image upload. The maximum allowed size for images is 1 MB.",
"error_on_update": "Error on update", "error_on_update": "Error on update",
"error_loading_pictos": "Error loading pictos information", "error_loading_pictos": "Error loading pictos information",
"error_loading_scene": "Error loading scene data",
"error_loading_scenes": "Error loading scenes data",
"error_general": "An error has been produced", "error_general": "An error has been produced",
"error_rate": "Error rate", "error_rate": "Error rate",
"expand_navigation": "Expand navigation", "expand_navigation": "Expand navigation",
...@@ -298,6 +301,7 @@ ...@@ -298,6 +301,7 @@
"read_picto": "Read picto", "read_picto": "Read picto",
"register": "Sign in", "register": "Sign in",
"reloading_pictos": "Reloading pictograms", "reloading_pictos": "Reloading pictograms",
"reload_scene": "Reloading scene",
"remember": "Remember me", "remember": "Remember me",
"reports": "Reports", "reports": "Reports",
"request_change_password": "Request change password", "request_change_password": "Request change password",
...@@ -305,6 +309,11 @@ ...@@ -305,6 +309,11 @@
"room_changed": "A partner is offline. Session paused.", "room_changed": "A partner is offline. Session paused.",
"save": "Save", "save": "Save",
"save_as_template": "Save as template", "save_as_template": "Save as template",
"scene_added": "Scene data has been saved",
"scene_already_deleted": "Scene was already deleted",
"scene_deleted": "Scene has been deleted",
"scene_duplicated": "Scene has been copied",
"scene_updated": "Scene data updated",
"search": "Search", "search": "Search",
"search_sup_email": "Search supervisor by email", "search_sup_email": "Search supervisor by email",
"search_tutor_email": "Search tutor by email", "search_tutor_email": "Search tutor by email",
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
"birthdate": "Fecha de nacimiento", "birthdate": "Fecha de nacimiento",
"black_and_white": "ByN", "black_and_white": "ByN",
"cancel": "Cancelar", "cancel": "Cancelar",
"cant_delete_active_scene": "No se puede eliminar la escena activa, desactívela antes.",
"cannot_delete_method": "No se pudo eliminar el método, tal vez porque existen sesiones asociadas.", "cannot_delete_method": "No se pudo eliminar el método, tal vez porque existen sesiones asociadas.",
"cannot_delete_instruction": "No se pudo eliminar la instrucción, tal vez porque existen sesiones asociadas.", "cannot_delete_instruction": "No se pudo eliminar la instrucción, tal vez porque existen sesiones asociadas.",
"case_requested": "Por favor, especifique el tipo de usuario.", "case_requested": "Por favor, especifique el tipo de usuario.",
...@@ -135,6 +136,8 @@ ...@@ -135,6 +136,8 @@
"error_on_update": "Error al actualizar", "error_on_update": "Error al actualizar",
"error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.", "error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.",
"error_loading_pictos": "Error cargando información de los pictos", "error_loading_pictos": "Error cargando información de los pictos",
"error_loading_scene": "Error cargando información de la escena",
"error_loading_scenes": "Error cargando información de las escenas",
"error_general": "Se ha producido un error", "error_general": "Se ha producido un error",
"error_rate": "Tasa de error", "error_rate": "Tasa de error",
"February": "Febrero", "February": "Febrero",
...@@ -297,6 +300,7 @@ ...@@ -297,6 +300,7 @@
"record": "Grabar", "record": "Grabar",
"register": "Regístrate", "register": "Regístrate",
"register_button": "Registrar", "register_button": "Registrar",
"reload_scene": "Recargando escena",
"reloading_pictos": "Recargando pictogramas", "reloading_pictos": "Recargando pictogramas",
"remember": "No cerrar sesión", "remember": "No cerrar sesión",
"reports": "Informes", "reports": "Informes",
...@@ -305,6 +309,11 @@ ...@@ -305,6 +309,11 @@
"room_changed":"Un participante abandonó la sesión. Sesión en pausa.", "room_changed":"Un participante abandonó la sesión. Sesión en pausa.",
"save": "Guardar", "save": "Guardar",
"save_as_template": "Guardar como plantilla", "save_as_template": "Guardar como plantilla",
"scene_already_deleted": "La escena ya se había eliminado",
"scene_added": "Escena creada correctamente",
"scene_deleted": "Escena eliminada",
"scene_duplicated": "Escena duplicada",
"scene_updated": "Datos de la escena actualizados",
"search": "Buscar", "search": "Buscar",
"search_sup_email": "Buscar supervisor por email", "search_sup_email": "Buscar supervisor por email",
"search_tutor_email": "Buscar tutor por email", "search_tutor_email": "Buscar tutor por email",
......
...@@ -372,7 +372,11 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -372,7 +372,11 @@ dashboardControllers.controller('AddPictoCtrl', function (
}else if($scope.source == "arasaac"){ }else if($scope.source == "arasaac"){
//Request page X from all pictos (symbolstx) //Request page X from all pictos (symbolstx)
request = config.backend + '/picto/' + student.lang + request = config.backend + '/picto/' + student.lang +
'/pic_fromArasaac/page/'+$scope.page+'/limit/'+$scope.limit; '/pic_fromArasaac/page/'+$scope.page+'/limit/'+$scope.limit+'/source/3';
}else if($scope.source == "arasaac_byn"){
//Request page X from all pictos (symbolstx)
request = config.backend + '/picto/' + student.lang +
'/pic_fromArasaac/page/'+$scope.page+'/limit/'+$scope.limit+'/source/4';
} }
$http.get(request) $http.get(request)
...@@ -405,6 +409,8 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -405,6 +409,8 @@ dashboardControllers.controller('AddPictoCtrl', function (
$scope.open_category_from_bc(0); $scope.open_category_from_bc(0);
}else if($scope.source == "arasaac"){ }else if($scope.source == "arasaac"){
$scope.load_arasaac_pictos(); $scope.load_arasaac_pictos();
}else if($scope.source == "arasaac_byn"){
$scope.load_arasaac_byn_pictos();
} }
}else{ }else{
var request = ""; var request = "";
...@@ -425,6 +431,8 @@ dashboardControllers.controller('AddPictoCtrl', function ( ...@@ -425,6 +431,8 @@ dashboardControllers.controller('AddPictoCtrl', function (
source = 2; source = 2;
}else if($scope.source == "arasaac"){ }else if($scope.source == "arasaac"){
source = 3; source = 3;
}else if($scope.source == "arasaac_byn"){
source = 4;
} }
request = config.backend + '/picto/' + student.lang + '/' + supervisor.id + request = config.backend + '/picto/' + student.lang + '/' + supervisor.id +
'/pic_fromSearch/'+$scope.srch_term_picto+'/category/'+category+ '/pic_fromSearch/'+$scope.srch_term_picto+'/category/'+category+
......
...@@ -166,18 +166,6 @@ ...@@ -166,18 +166,6 @@
<div class="col-md-3"> <div class="col-md-3">
<fieldset> <fieldset>
<div class="form-group"> <div class="form-group">
<label translate>categories</label>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox"
id="studentSetupUseCategories"
ng-model="studentData.attributes.categories"
ng-change="update_attributes()">
</span>
<span class="form-control" for="studentSetupUseCategories">{{ 'use_categories' | translate }}</span>
</div>
</div>
<div class="form-group">
<label translate>picto_size</label> <label translate>picto_size</label>
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"> <span class="input-group-addon">
......
...@@ -1057,3 +1057,12 @@ form .progress { ...@@ -1057,3 +1057,12 @@ form .progress {
display: none; display: none;
} }
} }
/* Estilos para las escenas */
input.editable.scene-name {
min-width: inherit;
width: 100%;
font-size: 16px;
font-weight: 600;
}
...@@ -80,6 +80,16 @@ module.exports.policies = { ...@@ -80,6 +80,16 @@ module.exports.policies = {
fromSearch: ['tokenAuth'] fromSearch: ['tokenAuth']
}, },
SceneController:{
create: ['tokenAuth', 'isSupervisorOfStudent'],
update: ['tokenAuth', 'isSupervisorOfStudent'],
destroy: ['tokenAuth', 'isSupervisorOfStudent'],
duplicate: ['tokenAuth', 'isSupervisorOfStudent'],
getScene: ['tokenAuth'],
getStudentScenes: ['tokenAuth'],
scene: true
},
ServerController: { ServerController: {
ping: true, ping: true,
ping_session: ['tokenAuth'] ping_session: ['tokenAuth']
...@@ -115,7 +125,9 @@ module.exports.policies = { ...@@ -115,7 +125,9 @@ module.exports.policies = {
actions_batch: ['tokenAuth'], actions_batch: ['tokenAuth'],
delete: ['tokenAuth', 'isSupAdmin'], delete: ['tokenAuth', 'isSupAdmin'],
unlink_supervisor: ['tokenAuth', 'isSupAdmin'], unlink_supervisor: ['tokenAuth', 'isSupAdmin'],
delete_picto: ['tokenAuth', 'isSupervisorOfStudent'] delete_picto: ['tokenAuth', 'isSupervisorOfStudent'],
getActiveScene: ['tokenAuth'],
getScenes: ['tokenAuth']
}, },
LicenseController: { LicenseController: {
......
...@@ -73,6 +73,15 @@ module.exports.routes = { ...@@ -73,6 +73,15 @@ module.exports.routes = {
'DELETE /picto/:id': 'PictoController.destroy', 'DELETE /picto/:id': 'PictoController.destroy',
'DELETE /picto/:id_sup/tag/:id_tag': 'PictoController.del_tag', 'DELETE /picto/:id_sup/tag/:id_tag': 'PictoController.del_tag',
/// Websocket request for propagating actions add, delete, modify...
'POST /scene': 'SceneController.scene',
'GET /scene/:id': 'SceneController.getScene',
'GET /scene/:id/stu/:id_stu/copy': 'SceneController.duplicate',
'POST /scene/:id/stu/:id_stu': 'SceneController.create',
'PUT /scene/:id/stu/:id_stu': 'SceneController.update',
'DELETE /scene/:id/stu/:id_stu': 'SceneController.destroy',
'GET /server/ping': 'ServerController.ping', 'GET /server/ping': 'ServerController.ping',
'GET /server/ping_session': 'ServerController.ping_session', 'GET /server/ping_session': 'ServerController.ping_session',
...@@ -82,6 +91,8 @@ module.exports.routes = { ...@@ -82,6 +91,8 @@ module.exports.routes = {
'GET /stu/:id_stu/tutors': 'StudentController.tutors', 'GET /stu/:id_stu/tutors': 'StudentController.tutors',
'POST /stu/:id_stu/sup/:id_sup': 'StudentController.link_supervisor', 'POST /stu/:id_stu/sup/:id_sup': 'StudentController.link_supervisor',
'GET /stu/:id_stu/pictos': 'StudentController.pictos', 'GET /stu/:id_stu/pictos': 'StudentController.pictos',
'GET /stu/:id_stu/activeScene': 'StudentController.getActiveScene',
'GET /stu/:id_stu/scenes': 'StudentController.getScenes',
'GET /stu/:id_stu/methods': 'StudentController.methods', 'GET /stu/:id_stu/methods': 'StudentController.methods',
'GET /stu/:id_stu/lasttries': 'StudentController.lasttries', 'GET /stu/:id_stu/lasttries': 'StudentController.lasttries',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment