Commit 17f37b1e by Jose Antonio

Merge remote-tracking branch 'origin/develop' into develop

parents 14fddbba 47f65b93
Showing with 332 additions and 240 deletions
...@@ -51,7 +51,6 @@ public abstract class Action { ...@@ -51,7 +51,6 @@ public abstract class Action {
Log.d("TIMESTAMP-----------> ", datetime.format(currentTime)); Log.d("TIMESTAMP-----------> ", datetime.format(currentTime));
if (PCBcontext.getPcbdb().getCurrentUser().has_supervisor()) { if (PCBcontext.getPcbdb().getCurrentUser().has_supervisor()) {
jsonObject.put(param_id_sup, PCBcontext.getPcbdb().getCurrentUser().get_id_sup()); jsonObject.put(param_id_sup, PCBcontext.getPcbdb().getCurrentUser().get_id_sup());
Log.i("TAG_PRUEBAS","ACTION_ID_SCENE: "+PCBcontext.getPcbdb().getCurrentUser().get_active_scene());
jsonObject.put(param_id_scene, PCBcontext.getPcbdb().getCurrentUser().get_active_scene()); jsonObject.put(param_id_scene, PCBcontext.getPcbdb().getCurrentUser().get_active_scene());
} }
//TODO Decidir qué almacenar con DEVICE //TODO Decidir qué almacenar con DEVICE
......
...@@ -176,7 +176,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -176,7 +176,7 @@ public class Device extends SQLiteOpenHelper {
Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null); Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null);
while (cursor.moveToNext() && user == null) while (cursor.moveToNext() && user == null)
if (cursor.getInt(0) == id_stu && cursor.getInt(9) == id_sup) if (cursor.getInt(0) == id_stu && cursor.getInt(10) == id_sup)
user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5), user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5),
cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11), cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11),
cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
...@@ -192,9 +192,9 @@ public class Device extends SQLiteOpenHelper { ...@@ -192,9 +192,9 @@ public class Device extends SQLiteOpenHelper {
* @return * @return
* @throws JSONException * @throws JSONException
*/ */
public Boolean isSupervisorOnLocal(int id_sup) throws JSONException{ public Boolean isSupervisorOnLocal(int id_sup,int id_stu) throws JSONException{
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(" SELECT * FROM supervisor WHERE id = " + id_sup, null); Cursor cursor = db.rawQuery(" SELECT * FROM users_detail WHERE id_stu = " + id_stu+ " AND id_sup ="+id_sup, null);
if(cursor.moveToFirst()) if(cursor.moveToFirst())
return true; return true;
cursor.close(); cursor.close();
...@@ -213,7 +213,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -213,7 +213,7 @@ public class Device extends SQLiteOpenHelper {
Hashtable<String, String> users = new Hashtable<>(3); 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); 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())
users.put(cursor.getString(0), cursor.getString(1)+", "+cursor.getString(2)+";"+cursor.getInt(3)); users.put(cursor.getString(0), cursor.getString(1) + ", " + cursor.getString(2) + ";" + cursor.getInt(3));
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;
......
...@@ -55,7 +55,6 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -55,7 +55,6 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @see PCBDBHelper#getCurrentUser() * @see PCBDBHelper#getCurrentUser()
*/ */
public void setCurrentUser(User user) { public void setCurrentUser(User user) {
Log.i(LOG_TAG,"user "+user.get_name_stu()+" "+" Scene:"+user.get_active_scene()+" attributes:"+user.get_json_attrs());
this.currentUser = user; this.currentUser = user;
PCBcontext.getDevice().setLastStuId(user.get_id_stu()); PCBcontext.getDevice().setLastStuId(user.get_id_stu());
if (user.is_supervisor()) PCBcontext.getDevice().setLastSupId(user.get_id_sup()); if (user.is_supervisor()) PCBcontext.getDevice().setLastSupId(user.get_id_sup());
...@@ -162,8 +161,8 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -162,8 +161,8 @@ public class PCBDBHelper extends SQLiteOpenHelper {
try { try {
String sql_scene="INSERT OR REPLACE INTO scene VALUES (" String sql_scene="INSERT OR REPLACE INTO scene VALUES ("
+params.getInt("id") +params.getInt("id")
+","+params.getInt("supervisor") +","+PCBcontext.getPcbdb().getCurrentUser().get_id_sup()
+","+params.get("student") +","+params.getInt("student")
+",'"+params.getString("name") +",'"+params.getString("name")
+"','"+params.getBoolean("active") +"','"+params.getBoolean("active")
+"','"+params.getBoolean("categories") +"','"+params.getBoolean("categories")
...@@ -172,7 +171,9 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -172,7 +171,9 @@ public class PCBDBHelper extends SQLiteOpenHelper {
getWritableDatabase().execSQL(sql_scene); getWritableDatabase().execSQL(sql_scene);
//Added //Added
//PCBcontext.getPcbdb().getCurrentUser().set_active_scene(params.getInt("id")); sql_scene = "UPDATE student SET id_scene = "+params.getInt("id")+" WHERE id = "+params.getInt("student");
getWritableDatabase().execSQL(sql_scene);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
Log.e(LOG_TAG,"Error setting active scene:"+e.getMessage()); Log.e(LOG_TAG,"Error setting active scene:"+e.getMessage());
...@@ -186,17 +187,11 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -186,17 +187,11 @@ public class PCBDBHelper extends SQLiteOpenHelper {
*/ */
public int getActiveSceneForStudent(int id_stu){ public int getActiveSceneForStudent(int id_stu){
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT id FROM scene WHERE id_stu = "+id_stu,null); Cursor cursor = db.rawQuery("SELECT id_scene FROM student WHERE id = "+id_stu,null);
cursor.moveToFirst(); cursor.moveToFirst();
int id; Log.i(LOG_TAG,"Scene: "+cursor.getInt(0)+"-- For student: "+id_stu);
if(cursor.getCount() > 0){
id=cursor.getInt(0);
Log.e(LOG_TAG," Active scene id:"+id);
return cursor.getInt(0); return cursor.getInt(0);
} }
return -1;
}
/** /**
* Return if a given scene has categories * Return if a given scene has categories
...@@ -209,7 +204,6 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -209,7 +204,6 @@ public class PCBDBHelper extends SQLiteOpenHelper {
Cursor cursor = db.query("scene",new String[]{"categories"},"id=?",new String[]{String.valueOf(id_scene)},null,null,null,null); Cursor cursor = db.query("scene",new String[]{"categories"},"id=?",new String[]{String.valueOf(id_scene)},null,null,null,null);
boolean has_categories; boolean has_categories;
cursor.moveToFirst(); cursor.moveToFirst();
int id;
if(cursor.getCount() > 0){ if(cursor.getCount() > 0){
has_categories=cursor.getString(0).equals("true"); has_categories=cursor.getString(0).equals("true");
} }
...@@ -223,8 +217,8 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -223,8 +217,8 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @see com.yottacode.pictogram.dao.Picto * @see com.yottacode.pictogram.dao.Picto
*/ */
public Vocabulary getStudentVocabulary(Vocabulary vocabulary ) throws JSONException { public Vocabulary getStudentVocabulary(Vocabulary vocabulary ) throws JSONException {
int id_stu = this.getCurrentUser().get_id_stu(); int id_stu = this.currentUser.get_id_stu();
int id_scene = this.getCurrentUser().get_active_scene(); int id_scene = this.currentUser.get_active_scene();
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
...@@ -256,11 +250,10 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -256,11 +250,10 @@ public class PCBDBHelper extends SQLiteOpenHelper {
values.put("id_stu", id_stu); values.put("id_stu", id_stu);
db.beginTransaction(); db.beginTransaction();
for (Picto picto : vocabulary) { for (Picto picto : vocabulary) {
Log.i(LOG_TAG,"inserting "+picto.get_id()+":"+picto.get_translation()+":"+picto.get_json_attrs()+"-id_sce: "+PCBcontext.getPcbdb().getCurrentUser().get_active_scene()); Log.d(LOG_TAG,"inserting "+picto.get_id()+":"+picto.get_translation()+":"+picto.get_json_attrs()+"-id_sce: "+PCBcontext.getPcbdb().getCurrentUser().get_active_scene());
values.put("id_picto", picto.get_id()); values.put("id_picto", picto.get_id());
values.put("id_scene", PCBcontext.getPcbdb().getCurrentUser().get_active_scene()); values.put("id_scene", this.currentUser.get_active_scene());
values.put("id_stupicto", picto.get_stupicto_id()); values.put("id_stupicto", picto.get_stupicto_id());
values.put("url", picto.get_url()); values.put("url", picto.get_url());
values.put("translation",picto.get_translation()); values.put("translation",picto.get_translation());
...@@ -286,7 +279,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -286,7 +279,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
values.put("id_stu", id_stu); values.put("id_stu", id_stu);
values.put("id_picto", picto.get_id()); values.put("id_picto", picto.get_id());
//TODO: Añadir aqui el id de escena activa para el estudiante //TODO: Añadir aqui el id de escena activa para el estudiante
values.put("id_scene",PCBcontext.getPcbdb().getCurrentUser().get_active_scene()); values.put("id_scene",this.currentUser.get_active_scene());
values.put("id_stupicto",picto.get_stupicto_id()); values.put("id_stupicto",picto.get_stupicto_id());
values.put("url", picto.get_url()); values.put("url", picto.get_url());
values.put("translation",picto.get_translation()); values.put("translation",picto.get_translation());
......
...@@ -251,22 +251,11 @@ public class User { ...@@ -251,22 +251,11 @@ public class User {
* @return The id of the active scene of this student * @return The id of the active scene of this student
*/ */
public int get_active_scene() { public int get_active_scene() {
/*try {
return this.attributes_stu.getInt(JSON_STUDENT_ATTTRS.ID_ACTIVE_SCENE);
} catch (JSONException e) {
e.printStackTrace();
}
return -1;*/
return this.id_scene_stu; return this.id_scene_stu;
} }
public void set_active_scene(int id) { public void set_active_scene(int id) {
//try {
this.id_scene_stu = id; this.id_scene_stu = id;
//this.attributes_stu.put(JSON_STUDENT_ATTTRS.ID_ACTIVE_SCENE,id);
/*} catch (JSONException e) {
e.printStackTrace();
}*/
} }
/** /**
* *
......
...@@ -60,7 +60,7 @@ public class ActionTalk implements Emitter.Listener { ...@@ -60,7 +60,7 @@ public class ActionTalk implements Emitter.Listener {
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;
} }
Log.i(LOG_TAG, "Received message '" + action + Log.d(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)
......
...@@ -34,6 +34,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -34,6 +34,7 @@ public class VocabularyTalk implements Emitter.Listener {
final String param_picto="picto"; final String param_picto="picto";
final String param_stu_picto="stu_picto"; final String param_stu_picto="stu_picto";
final String param_picto_id="id"; final String param_picto_id="id";
final String param_stupicto_scene="scene";
final String param_picto_cat="id_cat"; final String param_picto_cat="id_cat";
final String action_update="update"; final String action_update="update";
final String action_update_category="update_category"; final String action_update_category="update_category";
...@@ -41,6 +42,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -41,6 +42,7 @@ public class VocabularyTalk implements Emitter.Listener {
final String action_delete="delete"; final String action_delete="delete";
JSONObject msg = (JSONObject) args[0]; JSONObject msg = (JSONObject) args[0];
try { try {
Log.i(LOG_TAG, "raw Received message " +msg.toString()); Log.i(LOG_TAG, "raw Received message " +msg.toString());
...@@ -51,7 +53,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -51,7 +53,7 @@ public class VocabularyTalk implements Emitter.Listener {
JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto); JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto);
int picto_id = picto_stupicto.getInt(param_picto_id); int picto_id = picto_stupicto.getInt(param_picto_id);
int picto_cat = attrs_stu_picto!=null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0; int picto_cat = attrs_stu_picto!=null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0;
if(PCBcontext.getPcbdb().getCurrentUser().get_active_scene() == msg.getJSONObject("attributes").getInt("id_scene")) { if(PCBcontext.getPcbdb().getCurrentUser().get_active_scene() == stu_picto.getInt(param_stupicto_scene)) {
PCBcontext.getNetService().nextSynchro(new Date().getTime() + PCBcontext.getNetService().getSynchroTimingLength() * 2); //nos saltamos una sincronización para evitar que llegue antes que los websockets PCBcontext.getNetService().nextSynchro(new Date().getTime() + PCBcontext.getNetService().getSynchroTimingLength() * 2); //nos saltamos una sincronización para evitar que llegue antes que los websockets
for (iVocabularyListener listener : this.listeners) for (iVocabularyListener listener : this.listeners)
listener.change(action.equals(action_update) ? iVocabularyListener.action.update listener.change(action.equals(action_update) ? iVocabularyListener.action.update
......
...@@ -77,7 +77,6 @@ public final class PCBcontext { ...@@ -77,7 +77,6 @@ public final class PCBcontext {
@Override @Override
public void change(User updatedStudent) { public void change(User updatedStudent) {
Log.i(getClass().getCanonicalName(),"ID: "+updatedStudent.get_active_scene()+"--ID_UPDAT:"+PCBcontext.getPcbdb().getCurrentUser().get_active_scene());
PCBcontext.getDevice().insertUser(updatedStudent); PCBcontext.getDevice().insertUser(updatedStudent);
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories() if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories()
......
package com.yottacode.pictogram.tabletlibrary.gui.communicator; package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.app.Fragment; import android.app.Fragment;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public class Message_Fragment extends Fragment { public class Message_Fragment extends Fragment {
LinearLayout layout = null;
ArrayList<ImageView> pictos = null;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_message, null); View v = inflater.inflate(R.layout.fragment_message, null);
Button button = (Button) v.findViewById(R.id.aceptar);
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Log.i("TAG_PRUEBAS","Hace click");
// do something
getActivity().getFragmentManager().beginTransaction().remove(Message_Fragment.this).commit();
}
});
/*layout = (LinearLayout) v.findViewById(R.id.layoutImages);
pictos = new ArrayList<>();
for(int i = 0;i<layout.getChildCount();i++){
pictos.add((ImageView) layout.getChildAt(i));
}*/
// Inflate the layout for this fragment // Inflate the layout for this fragment
return v; return v;
} }
public boolean closedFragment(){ public void cargar_pictos(JSONArray arrayPictos){
this.onDestroy();
return true; for(int i = 0; i < arrayPictos.length(); i++) {
//ImageView imagen = (ImageView) layout.getChildAt(i);
JSONObject picto = null;
try {
picto = arrayPictos.getJSONObject(i).getJSONObject("attributes");
Log.i("TAG_PRUEBAS", "picto :" + i);
//pictos.get(i).setImageResource(R.drawable.anonymous_student);
//pictos.get(i).setImageURI(Uri.parse(picto.getString("uri")));
Log.i("TAG_PRUEBAS", "picto received:" + picto.getString("expression").toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
} }
} }
...@@ -3,6 +3,7 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator; ...@@ -3,6 +3,7 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Fragment;
import android.app.FragmentManager; import android.app.FragmentManager;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
import android.content.ClipData; import android.content.ClipData;
...@@ -38,6 +39,8 @@ import android.widget.CheckBox; ...@@ -38,6 +39,8 @@ import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.GridView; import android.widget.GridView;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.Toast; import android.widget.Toast;
...@@ -159,30 +162,55 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -159,30 +162,55 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
this.vocabulary = PCBcontext.getVocabulary(); this.vocabulary = PCBcontext.getVocabulary();
this.vocabulary.listen(PCBcontext.getRoom(), this, new ActionTalk.iActionListener() { this.vocabulary.listen(PCBcontext.getRoom(), this, new ActionTalk.iActionListener() {
@Override @Override
public void action(action action, int picto_cat, int picto_id, JSONObject msg) { public void action(action action, int picto_cat, int picto_id, JSONObject msg) {
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) {
/* TODO: Para la siguiente version, codigo para mostrar los mensajes privados
Log.i("TAG_PRUEBAS","show message received:"+msg.toString());
JSONObject msg_attrs = null;
JSONArray pictos = null;
String mensaje= "";
try { try {
//Log.i("TAG_PRUEBAS","show message received:"+msg.get("expression")); msg_attrs = msg.getJSONObject("attributes");
JSONObject msg_attrs = msg.getJSONObject("attributes"); pictos = msg_attrs.getJSONArray("pictos");
JSONArray pictos = msg_attrs.getJSONArray("pictos");
String user = pictos.getJSONObject(0).getJSONObject("attributes").getString("user_avatar");
if(user.equals(PCBcontext.getPcbdb().getCurrentUser().get_email_sup())){ //si el primer picto tiene ese sup asociado
mensaje += getResources().getString(R.string.message_from)+": "+PCBcontext.getPcbdb().getCurrentUser().get_name_stu()+", "+ PCBcontext.getPcbdb().getCurrentUser().get_surname_stu()+"\n";
mensaje += getResources().getString(R.string.says)+": ";
for(int i = 0; i < pictos.length(); i++) { for(int i = 0; i < pictos.length(); i++) {
JSONObject picto = pictos.getJSONObject(i).getJSONObject("attributes"); JSONObject picto = pictos.getJSONObject(i).getJSONObject("attributes");
Log.i("TAG_PRUEBAS","picto received:"+picto.get("expression").toString()); mensaje += (i != pictos.length()-1 ? picto.get("expression").toString()+" - " : picto.get("expression").toString());
}
Log.i(LOG_TAG,"Mensaje: "+msg.toString());
final AlertDialog.Builder builder = new AlertDialog.Builder(PictogramActivity.this);
builder.setMessage(mensaje)
.setPositiveButton("Vale", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
} }
});
// Create the AlertDialog object and return it
runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog alert = builder.create();
alert.show();
}
});
}
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Message_Fragment fragment = new Message_Fragment();
fragmentTransaction.add(R.id.fragment_container, fragment, "ALERTA");
fragmentTransaction.commit();
mainLayout.setEnabled(false); //Desactivar el fondo*/
} }
else if (PCBcontext.getPcbdb().getCurrentUser().is_mirror_on()) { else if (PCBcontext.getPcbdb().getCurrentUser().is_mirror_on()) {
......
...@@ -18,7 +18,6 @@ import com.yottacode.pictogram.dao.User; ...@@ -18,7 +18,6 @@ import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.ImgDownloader; import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity; import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity;
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.tools.GUITools; import com.yottacode.tools.GUITools;
...@@ -28,9 +27,7 @@ import org.json.JSONException; ...@@ -28,9 +27,7 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List;
import java.util.Vector; import java.util.Vector;
/** /**
...@@ -243,7 +240,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -243,7 +240,7 @@ public class StudentFragmentGrid extends Fragment{
try { try {
supervisor = supervisors.getJSONObject(i); supervisor = supervisors.getJSONObject(i);
idSupervisoresJSON.add(supervisor.getString("email")); idSupervisoresJSON.add(supervisor.getString("email"));
if(!PCBcontext.getDevice().isSupervisorOnLocal((int) supervisor.get("id"))) {//Para comprobar si ya existe en local if(!PCBcontext.getDevice().isSupervisorOnLocal((int) supervisor.get("id"),stu_id)) {//Para comprobar si ya existe en local
User currentUser = PCBcontext.getPcbdb().getCurrentUser(); User currentUser = PCBcontext.getPcbdb().getCurrentUser();
PCBcontext.getDevice().insertUser(new User(stu_id, currentUser.get_nickname_stu(), currentUser.get_pwd_stu() PCBcontext.getDevice().insertUser(new User(stu_id, currentUser.get_nickname_stu(), currentUser.get_pwd_stu()
, currentUser.get_name_stu(),currentUser.get_surname_stu(),currentUser.get_active_scene(), currentUser.get_url_img_stu() , currentUser.get_name_stu(),currentUser.get_surname_stu(),currentUser.get_active_scene(), currentUser.get_url_img_stu()
...@@ -322,7 +319,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -322,7 +319,7 @@ public class StudentFragmentGrid extends Fragment{
GUITools.show_alert(getActivity(), R.string.loginErrorTxt,getString(R.string.noStudentsError), new GUITools.iOKListener() { GUITools.show_alert(getActivity(), R.string.loginErrorTxt,getString(R.string.noStudentsError), new GUITools.iOKListener() {
@Override @Override
public void ok() { public void ok() {
PCBcontext.getNetService().restart_app(false); PCBcontext.getNetService().restart_app(true);
} }
}); });
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:layout_below="@+id/loginTopbarLayout" android:layout_below="@+id/loginTopbarLayout"
android:background="#eeeeee"
android:paddingTop="10dp"> android:paddingTop="10dp">
<fragment <fragment
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/serialmail" android:layout_below="@+id/serialmail"
android:layout_marginTop="25dp" android:layout_marginTop="25dp"
android:layout_toStartOf="@+id/imageView" android:layout_toStartOf="@+id/imageView1"
android:background="@drawable/edit_text_login_style" android:background="@drawable/edit_text_login_style"
android:fontFamily="monospace" android:fontFamily="monospace"
android:hint="@string/prompt_serial_pass" android:hint="@string/prompt_serial_pass"
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
</LinearLayout> </LinearLayout>
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/imageView1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="end" android:layout_gravity="end"
......
...@@ -8,17 +8,17 @@ ...@@ -8,17 +8,17 @@
tools:context="com.yottacode.pictogram.tabletlibrary.gui.login.SplashScreenActivity" > tools:context="com.yottacode.pictogram.tabletlibrary.gui.login.SplashScreenActivity" >
<ImageView <ImageView
android:id="@+id/imageView2"
android:layout_width="400px" android:layout_width="400px"
android:layout_height="120px" android:layout_height="120px"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="44dp"
android:contentDescription="@string/app_name" android:contentDescription="@string/app_name"
android:orientation="vertical" android:orientation="vertical"
android:src="@drawable/yottacode_logo"
android:scaleX="0.5" android:scaleX="0.5"
android:scaleY="0.5" android:scaleY="0.5"
android:id="@+id/imageView2" android:src="@drawable/yottacode_logo" />
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="44dp" />
<ImageView <ImageView
android:layout_width="200px" android:layout_width="200px"
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
android:contentDescription="@string/app_name" android:contentDescription="@string/app_name"
android:orientation="vertical" android:orientation="vertical"
android:src="@drawable/pictogram_logo" android:src="@drawable/pictogram_logo"
android:id="@+id/imageView" android:id="@+id/imageView1"
android:scaleX="1.5" android:scaleX="1.5"
android:scaleY="1.5" android:scaleY="1.5"
android:layout_centerVertical="true" android:layout_centerVertical="true"
......
...@@ -109,7 +109,10 @@ ...@@ -109,7 +109,10 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/textView_Supevisor" android:id="@+id/textView_Supevisor"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -124,20 +127,20 @@ ...@@ -124,20 +127,20 @@
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:textColor="@color/BlancoApp"
android:background="@color/VerdeApp" android:background="@color/VerdeApp"
android:text="___________" /> android:text="___________"
android:textColor="@color/BlancoApp" />
<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
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/textLegend" android:id="@+id/textLegend"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -153,7 +156,6 @@ ...@@ -153,7 +156,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/textLegend" android:layout_below="@+id/textLegend"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginBottom="15dp"
android:background="@drawable/editpicto_edittext_style" android:background="@drawable/editpicto_edittext_style"
android:ems="10" android:ems="10"
android:gravity="center" android:gravity="center"
...@@ -163,14 +165,13 @@ ...@@ -163,14 +165,13 @@
android:textColorLink="?android:attr/colorAccent" android:textColorLink="?android:attr/colorAccent"
android:textCursorDrawable="@null" android:textCursorDrawable="@null"
android:textSize="20sp" /> android:textSize="20sp" />
<View </LinearLayout>
android:layout_width="fill_parent"
android:layout_height="2dip" <LinearLayout
android:background="@color/VerdeApp" android:layout_width="match_parent"
android:paddingBottom="4dp" android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
/> android:orientation="vertical">
<TextView <TextView
android:id="@+id/textView_Audio" android:id="@+id/textView_Audio"
...@@ -300,6 +301,8 @@ ...@@ -300,6 +301,8 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
</LinearLayout>
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
......
...@@ -27,48 +27,49 @@ ...@@ -27,48 +27,49 @@
android:textStyle="bold" /> android:textStyle="bold" />
<LinearLayout <LinearLayout
android:id="@+id/layoutImages"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/imageView" android:id="@+id/imageView1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" /> android:layout_marginRight="5dp" />
<ImageView <ImageView
android:id="@+id/imageView5" android:id="@+id/imageView2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" /> android:layout_marginRight="5dp" />
<ImageView <ImageView
android:id="@+id/imageView4" android:id="@+id/imageView3"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" /> android:layout_marginRight="5dp" />
<ImageView <ImageView
android:id="@+id/imageView3" android:id="@+id/imageView4"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" /> android:layout_marginRight="5dp" />
<ImageView <ImageView
android:id="@+id/imageView2" android:id="@+id/imageView5"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" /> android:layout_marginRight="5dp" />
<ImageView <ImageView
android:id="@+id/imageView8" android:id="@+id/imageView6"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
...@@ -84,20 +85,20 @@ ...@@ -84,20 +85,20 @@
android:layout_weight="1" /> android:layout_weight="1" />
<ImageView <ImageView
android:id="@+id/imageView6" android:id="@+id/imageView8"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" android:layout_marginRight="5dp"
android:layout_weight="1" /> android:layout_weight="1" />
</LinearLayout> </LinearLayout>
<Button <Button
android:id="@+id/aceptar" android:id="@+id/aceptar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Button" android:text="Vale" />
android:onClick="closedFragment()"/>
</LinearLayout> </LinearLayout>
......
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
android:id="@+id/loginStudentGridView" android:id="@+id/loginStudentGridView"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="#eeeeee"
android:numColumns="5" android:numColumns="5"
android:stackFromBottom="false" /> android:stackFromBottom="false" />
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<ListView <ListView
android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@android:id/list" /> android:background="#eeeeee" />
</LinearLayout> </LinearLayout>
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<ListView <ListView
android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@android:id/list" /> android:background="#eeeeee" />
</LinearLayout> </LinearLayout>
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
<string name="titleCropperNew">New Picto</string> <string name="titleCropperNew">New Picto</string>
<string name="insertPasswordLogin">Insert Password</string> <string name="insertPasswordLogin">Insert Password</string>
<string name="version_label">Version:</string> <string name="version_label">Version:</string>
<string name="message_from">Message from</string>
<string name="says">Says</string>
</resources> </resources>
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
<string name="titleCropperNew">Nuevo Pictograma</string> <string name="titleCropperNew">Nuevo Pictograma</string>
<string name="insertPasswordLogin">Inserte Contraseña</string> <string name="insertPasswordLogin">Inserte Contraseña</string>
<string name="version_label">Versión:</string> <string name="version_label">Versión:</string>
<string name="message_from">Mensaje de</string>
<string name="says">Dice</string>
</resources> </resources>
...@@ -54,4 +54,6 @@ ...@@ -54,4 +54,6 @@
<!-- TODO: Remove or change this placeholder text --> <!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string> <string name="hello_blank_fragment">Hello blank fragment</string>
<string name="message_from">Mensaje de</string>
<string name="says">Dice</string>
</resources> </resources>
...@@ -13,8 +13,6 @@ CREATE PROCEDURE scene_adapt() ...@@ -13,8 +13,6 @@ 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;
...@@ -32,19 +30,9 @@ BEGIN ...@@ -32,19 +30,9 @@ BEGIN
LEAVE read_loop; LEAVE read_loop;
END IF; END IF;
SELECT CAST(attributes->"$.categories" as CHAR(10)) INTO _cat_status FROM student WHERE id = _id_stu;
IF (_cat_status LIKE '%on%') THEN
SET _cat_active = 1;
/*SELECT CONCAT('active: ', _cat_active);*/
ELSE
SET _cat_active = 0;
/*SELECT CONCAT('active: ', NOT _cat_active);*/
END IF;
/* FIRST SCENE, ACTIVE, WITH CATEGORIES*/ /* FIRST SCENE, ACTIVE, WITH CATEGORIES*/
INSERT INTO `scene` (name, categories, id_stu) INSERT INTO `scene` (name, categories, id_stu)
VALUES ('with_categories', _cat_active, _id_stu); VALUES ('Con categorías', 1, _id_stu);
SET LID = LAST_INSERT_ID(); SET LID = LAST_INSERT_ID();
...@@ -58,7 +46,7 @@ BEGIN ...@@ -58,7 +46,7 @@ BEGIN
/* SECOND SCENE, NOT ACTIVE, NO CATEGORIES*/ /* SECOND SCENE, NOT ACTIVE, NO CATEGORIES*/
INSERT INTO `scene` (name, categories, id_sup, id_stu) INSERT INTO `scene` (name, categories, id_sup, id_stu)
VALUES ('no_categories', NOT _cat_active, _id_sup, _id_stu); VALUES ('Sin categorías', 0, _id_sup, _id_stu);
SET LID = LAST_INSERT_ID(); SET LID = LAST_INSERT_ID();
......
...@@ -7,7 +7,7 @@ SET @TRIGGER_CHECKS = FALSE; ...@@ -7,7 +7,7 @@ SET @TRIGGER_CHECKS = FALSE;
-- Oficina -- Oficina
-- --
INSERT INTO `office` ( INSERT INTO `office` (
`name`, `name`,
`address`, `address`,
`country`, `country`,
...@@ -16,7 +16,7 @@ INSERT INTO `office` ( ...@@ -16,7 +16,7 @@ INSERT INTO `office` (
`phone1`, `phone1`,
`lang`, `lang`,
`postal_code` `postal_code`
) VALUES ( ) VALUES (
'Comunicación Aumentativa JAén (CAJA)', 'Comunicación Aumentativa JAén (CAJA)',
'Paraje Las Lagunillas, Ed A3, primera plata, 23071. Jaén', 'Paraje Las Lagunillas, Ed A3, primera plata, 23071. Jaén',
'ES', 'ES',
...@@ -25,13 +25,13 @@ INSERT INTO `office` ( ...@@ -25,13 +25,13 @@ INSERT INTO `office` (
'+34 953 21 28 88', '+34 953 21 28 88',
'es-es', 'es-es',
'23071' '23071'
); );
-- --
-- Supervisores -- Supervisores
-- --
INSERT INTO `supervisor` ( INSERT INTO `supervisor` (
`name`, `name`,
`surname`, `surname`,
`gender`, `gender`,
...@@ -41,9 +41,10 @@ INSERT INTO `supervisor` ( ...@@ -41,9 +41,10 @@ INSERT INTO `supervisor` (
`lang`, `lang`,
`password`, `password`,
`active`, `active`,
`postal_code`,
`id_off`, `id_off`,
`pic` `pic`
) VALUES ( ) VALUES (
'Fernando', 'Fernando',
'Martínez Santiago', 'Martínez Santiago',
'M', 'M',
...@@ -53,9 +54,10 @@ INSERT INTO `supervisor` ( ...@@ -53,9 +54,10 @@ INSERT INTO `supervisor` (
'es-es', 'es-es',
'$2a$10$Q4jHNlC58.ptfl/5wZeHfOIvpJslJHKOFNZO3bWs4it7TifQPQnEa', '$2a$10$Q4jHNlC58.ptfl/5wZeHfOIvpJslJHKOFNZO3bWs4it7TifQPQnEa',
true, true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'), (SELECT id from office where email='dofer@ujaen.es'),
'test_caja_dofer.jpg' 'test_caja_dofer.jpg'
), ( ), (
'Miguel Ángel', 'Miguel Ángel',
'García Cumbreras', 'García Cumbreras',
'M', 'M',
...@@ -65,9 +67,10 @@ INSERT INTO `supervisor` ( ...@@ -65,9 +67,10 @@ INSERT INTO `supervisor` (
'es-es', 'es-es',
'$2a$04$XQvWUwGTvjR47ChPwd3f6ukx8Zg.7o1N4Kf6P.zqhVtQxVNArOsXi', '$2a$04$XQvWUwGTvjR47ChPwd3f6ukx8Zg.7o1N4Kf6P.zqhVtQxVNArOsXi',
true, true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'), (SELECT id from office where email='dofer@ujaen.es'),
'test_caja_miguel.jpg' 'test_caja_miguel.jpg'
), ( ), (
'Arturo', 'Arturo',
'Montejo Ráez', 'Montejo Ráez',
'M', 'M',
...@@ -77,9 +80,10 @@ INSERT INTO `supervisor` ( ...@@ -77,9 +80,10 @@ INSERT INTO `supervisor` (
'es-es', 'es-es',
'$2a$04$yoBXAMSgCVGSIr2pnuIOw.J8UCm8f2XkATu5rqsMJiEmlxBHs5.cO', '$2a$04$yoBXAMSgCVGSIr2pnuIOw.J8UCm8f2XkATu5rqsMJiEmlxBHs5.cO',
true, true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'), (SELECT id from office where email='dofer@ujaen.es'),
'test_caja_arturo.jpg' 'test_caja_arturo.jpg'
), ( ), (
'Alfonso', 'Alfonso',
'Ureña López', 'Ureña López',
'M', 'M',
...@@ -89,9 +93,10 @@ INSERT INTO `supervisor` ( ...@@ -89,9 +93,10 @@ INSERT INTO `supervisor` (
'es-es', 'es-es',
'$2a$04$zVGHJFafoZa60wo1yBqF/Oi3RXV/qS2cq0/j/W3Dkf4P1ad0e7.iS', '$2a$04$zVGHJFafoZa60wo1yBqF/Oi3RXV/qS2cq0/j/W3Dkf4P1ad0e7.iS',
true, true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'), (SELECT id from office where email='dofer@ujaen.es'),
'test_caja_alfonso.jpg' 'test_caja_alfonso.jpg'
), ( ), (
'Jesús', 'Jesús',
'Navarro Moreno', 'Navarro Moreno',
'M', 'M',
...@@ -101,9 +106,10 @@ INSERT INTO `supervisor` ( ...@@ -101,9 +106,10 @@ INSERT INTO `supervisor` (
'es-es', 'es-es',
'$2a$04$8O3Jd5j9/nM/KC.b1a8qRevyUwWUx6XGU3Gm754Y/8PpLO2jv.i76', '$2a$04$8O3Jd5j9/nM/KC.b1a8qRevyUwWUx6XGU3Gm754Y/8PpLO2jv.i76',
true, true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'), (SELECT id from office where email='dofer@ujaen.es'),
'defaultAvatar.jpg' 'defaultAvatar.jpg'
); );
-- --
-- Tutores -- Tutores
...@@ -119,7 +125,8 @@ INSERT INTO `supervisor` ( ...@@ -119,7 +125,8 @@ INSERT INTO `supervisor` (
`phone`, `phone`,
`lang`, `lang`,
`password`, `password`,
`active` `active`,
`postal_code`
) VALUES ( ) VALUES (
'Don Fernando', 'Don Fernando',
'Padre Fernandito', 'Padre Fernandito',
...@@ -130,7 +137,8 @@ INSERT INTO `supervisor` ( ...@@ -130,7 +137,8 @@ INSERT INTO `supervisor` (
'+34 232 232 232', '+34 232 232 232',
'es-es', 'es-es',
'$2a$04$DMOX/cZ4h6cNJW9VlCou7O266q4YDYuS6p0QzP.gBHd08.QnFQWD.', '$2a$04$DMOX/cZ4h6cNJW9VlCou7O266q4YDYuS6p0QzP.gBHd08.QnFQWD.',
true true,
'23071'
), ( ), (
'Don Arturo', 'Don Arturo',
'Padre Arturito', 'Padre Arturito',
...@@ -141,7 +149,8 @@ INSERT INTO `supervisor` ( ...@@ -141,7 +149,8 @@ INSERT INTO `supervisor` (
NULL, NULL,
'es-es', 'es-es',
'$2a$04$V2ods9MMmOFvdLTaHJqk3ejKEYdf28gvfDhaBkOSLCFJOC02TweFK', '$2a$04$V2ods9MMmOFvdLTaHJqk3ejKEYdf28gvfDhaBkOSLCFJOC02TweFK',
true true,
'23071'
), ( ), (
'Don Miguel', 'Don Miguel',
'Padre Miguelito', 'Padre Miguelito',
...@@ -152,9 +161,10 @@ INSERT INTO `supervisor` ( ...@@ -152,9 +161,10 @@ INSERT INTO `supervisor` (
NULL, NULL,
'es-es', 'es-es',
'$2a$04$1UCak614LKz6WpDBtOblQeqFF41tOMy6ERMnP2OuGVZffe8Yi0mJq', '$2a$04$1UCak614LKz6WpDBtOblQeqFF41tOMy6ERMnP2OuGVZffe8Yi0mJq',
true true,
'23071'
), ( ), (
'Don Afonso', 'Don Alfonso',
'Padre Alfonsito', 'Padre Alfonsito',
'M', 'M',
'Avda. Andalucía 1. Jaén', 'Avda. Andalucía 1. Jaén',
...@@ -162,8 +172,9 @@ INSERT INTO `supervisor` ( ...@@ -162,8 +172,9 @@ INSERT INTO `supervisor` (
'donalfonso@gmail.com', 'donalfonso@gmail.com',
NULL, NULL,
'es-es', 'es-es',
'$2a$04$$2a$04$KktXwe06AJg3vMUEX1E1/esbP.g8f79mtcNGjCsrEDWktmegcML4q', '$2a$06$UtyBV4tLlT7xSqIt8LKPBucGvZ.Wgf7RgGE0fRcjEBDwjxjHlsP3K',
true true,
'23071'
), ( ), (
'Doña Alfonsa', 'Doña Alfonsa',
'Madre Alfonsita', 'Madre Alfonsita',
...@@ -174,7 +185,8 @@ INSERT INTO `supervisor` ( ...@@ -174,7 +185,8 @@ INSERT INTO `supervisor` (
NULL, NULL,
'es-es', 'es-es',
'$2a$04$ALDmQ1oRhRZKUEi1b0eK1ehQmSZiFkhzx48ZBwER0J4vakvlYc5VS', '$2a$04$ALDmQ1oRhRZKUEi1b0eK1ehQmSZiFkhzx48ZBwER0J4vakvlYc5VS',
true true,
'23071'
), ( ), (
'Don Jesús', 'Don Jesús',
'Padre Jesusito', 'Padre Jesusito',
...@@ -185,7 +197,8 @@ INSERT INTO `supervisor` ( ...@@ -185,7 +197,8 @@ INSERT INTO `supervisor` (
NULL, NULL,
'es-es', 'es-es',
'$2a$04$Psuu6IMPUj1sbzR.uxq3EOgX1/4dFNmccjkv76LhKp35JzpiCE.fm', '$2a$04$Psuu6IMPUj1sbzR.uxq3EOgX1/4dFNmccjkv76LhKp35JzpiCE.fm',
true true,
'23071'
); );
-- --
...@@ -383,42 +396,42 @@ UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name=' ...@@ -383,42 +396,42 @@ UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Jesús') WHERE student.name='Jesusito'; UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Jesús') WHERE student.name='Jesusito';
UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Jesús') WHERE student.name='Jesusita'; UPDATE student SET id_off=(SELECT id_off FROM supervisor WHERE supervisor.name='Jesús') WHERE student.name='Jesusita';
select a.name,b.attributes,text from student a, stu_picto b, picto c, picto_exp d where a.id=b.id_stu and b.id_pic=c.id and c.id=d.id_pic and a.id=23 and a.lang=d.lang; // select a.name,b.attributes,text from student a, stu_picto b, picto c, picto_exp d where a.id=b.id_stu and b.id_pic=c.id and c.id=d.id_pic and a.id=23 and a.lang=d.lang;
-- --
-- CAJA Core vocabulary -- CAJA Core vocabulary
-- --
--
INSERT INTO stu_picto(id_stu,id_pic,attributes) -- INSERT INTO stu_picto(id_stu,id_pic,scene,attributes)
SELECT S.id,P.id_pic, concat('{"id_cat":', if (id_cat_pic is null, 'null',id_cat_pic), -- SELECT S.id,P.id_pic, 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"',
',"highlight":false', -- ',"highlight":false',
',"color":', if (color is null, 'null',concat('"',color,'"')), -- ',"color":', if (color is null, 'null',concat('"',color,'"')),
'}') as attributes -- '}') as attributes
FROM student S, picto_core P -- FROM student S, picto_core P
WHERE S.id_off =(SELECT id from office where name='Comunicación Aumentativa JAén (CAJA)'); -- WHERE S.id_off =(SELECT id from office where name='Comunicación Aumentativa JAén (CAJA)');
-- --
-- Test method -- Test method
-- --
INSERT INTO meta_method(name) VALUES ( -- INSERT INTO meta_method(name) VALUES (
'Test MetaMethod' -- 'Test MetaMethod'
); -- );
INSERT INTO method(name, id_stu) VALUES ( -- INSERT INTO method(name, id_stu) VALUES (
'Test Method', -- 'Test Method',
(SELECT id FROM student WHERE username='aaa0002') -- (SELECT id FROM student WHERE username='aaa0002')
); -- );
INSERT INTO instruction(name, id_met) VALUES ( -- INSERT INTO instruction(name, id_met) VALUES (
'Test Instruction', -- 'Test Instruction',
(SELECT id FROM method WHERE name='Test Method') -- (SELECT id FROM method WHERE name='Test Method')
); -- );
INSERT INTO working_session (id_sup, id_ins) VALUES ( -- INSERT INTO working_session (id_sup, id_ins) VALUES (
(SELECT id FROM supervisor WHERE email='dofer@ujaen.es'), -- (SELECT id FROM supervisor WHERE email='dofer@ujaen.es'),
(SELECT id FROM instruction WHERE name='Test Instruction') -- (SELECT id FROM instruction WHERE name='Test Instruction')
); -- );
SET @TRIGGER_CHECKS = TRUE; SET @TRIGGER_CHECKS = TRUE;
SET foreign_key_checks=1; SET foreign_key_checks=1;
...@@ -107,6 +107,9 @@ BEGIN ...@@ -107,6 +107,9 @@ BEGIN
IF (idopentry IS NOT NULL) THEN IF (idopentry IS NOT NULL) THEN
DELETE FROM try DELETE FROM try
WHERE id = idopentry; WHERE id = idopentry;
DELETE FROM stu_opentry
WHERE id_ws = ws;
END IF; END IF;
END;; END;;
...@@ -261,9 +264,10 @@ thisTrigger: BEGIN ...@@ -261,9 +264,10 @@ thisTrigger: BEGIN
-- Show and resumesession actions creates new tries -- Show and resumesession actions creates new tries
CASE NEW.type CASE NEW.type
WHEN 'Show' THEN WHEN 'Show' THEN
IF (idopentry IS NOT NULL) THEN
INSERT INTO try(`id_ws`) INSERT INTO try(`id_ws`)
VALUES (idws); VALUES (idws);
END IF;
WHEN 'pausesession' THEN WHEN 'pausesession' THEN
...@@ -273,6 +277,11 @@ thisTrigger: BEGIN ...@@ -273,6 +277,11 @@ thisTrigger: BEGIN
result = 'DISCARDED' result = 'DISCARDED'
WHERE WHERE
id = idopentry; id = idopentry;
UPDATE stu_opentry
SET id_opentry=NULL
WHERE id_ws = idws;
END IF; END IF;
WHEN 'resumesession' THEN WHEN 'resumesession' THEN
...@@ -303,15 +312,19 @@ thisTrigger: BEGIN ...@@ -303,15 +312,19 @@ thisTrigger: BEGIN
IF ((new.end IS NOT NULL) AND (new.current IS NOT NULL)) THEN IF ((new.end IS NOT NULL) AND (new.current IS NOT NULL)) THEN
SET new.current=NULL; SET new.current=NULL;
-- DONE IN TRG_SESSION_CLOSED
-- Remove opentry record -- Remove opentry record
DELETE FROM stu_opentry -- DELETE FROM stu_opentry
WHERE id_ws = new.id; -- WHERE id_ws = new.id;
-- Remove tries with no actions -- Remove tries with no actions
DELETE FROM `try` -- DELETE FROM `try`
WHERE -- WHERE
end = NULL AND -- end IS NULL AND
id_ws = new.id; -- id_ws = new.id;
END IF; END IF;
END;; END;;
......
...@@ -2,28 +2,9 @@ ...@@ -2,28 +2,9 @@
Changes to be performed manually in servers to upgrade Changes to be performed manually in servers to upgrade
## AngularJS
(already done in dev & pre)
- angular-re-captcha has been replaced by angular-recaptcha, so bower has to be run
- reinstall ui-bootstrap
- replace angular-file-upload by ng-file-upload
`bower install`
## Database ## Database
- Delete active column from scene table (deleted from `already done in dev` sql `create scene table` statement)
`alter table scene drop active;`
- Add id_active_scene to student table
`ALTER TABLE student ADD COLUMN id_active_scene INT(11) DEFAULT NULL;`
`ALTER TABLE student ADD CONSTRAINT fk_active_scene FOREIGN KEY (`id_active_scene`) REFERENCES scene (`id`);`
- Reload enrolments trigger
`source /vagrant/roles/database/files/triggers-enrolments-integrity-constraints.sql;`
Already done in dev:
(already done in dev)
- update arasaac uri - update arasaac uri
`source update_arasaac_color_uri.sql` `source update_arasaac_color_uri.sql`
...@@ -44,6 +25,10 @@ Changes to be performed manually in servers to upgrade ...@@ -44,6 +25,10 @@ Changes to be performed manually in servers to upgrade
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="Scene table information. Every scene is related to some stu_pictos";` COMMENT="Scene table information. Every scene is related to some stu_pictos";`
- Add id_active_scene to student table
`ALTER TABLE student ADD COLUMN id_active_scene INT(11) DEFAULT NULL;`
`ALTER TABLE student ADD CONSTRAINT fk_active_scene FOREIGN KEY (`id_active_scene`) REFERENCES scene (`id`);`
- 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`) ON DELETE CASCADE;` `ALTER TABLE `stu_picto` ADD CONSTRAINT `stu_picto_scene_fk` FOREIGN KEY (`id_scene`) REFERENCES `scene` (`id`) ON DELETE CASCADE;`
...@@ -55,28 +40,4 @@ Changes to be performed manually in servers to upgrade ...@@ -55,28 +40,4 @@ Changes to be performed manually in servers to upgrade
- Reload enrolments trigger - Reload enrolments trigger
`source /vagrant/roles/database/files/triggers-enrolments-integrity-constraints.sql` `source /vagrant/roles/database/files/triggers-enrolments-integrity-constraints.sql`
(already done in dev & pre) - Reload triggers-sessions-integrity-constraints.sql
- add new column to license:
`alter table license add column creator varchar(40) DEFAULT NULL;`
- add arasaac to source table
`INSERT INTO `source` (`id`, `name`, `description`) VALUES (3, 'Arasaac', 'Arasaac pictograms collection');`
- alter table supervisor add arasaac license:
`ALTER TABLE supervisor ADD COLUMN arasaac_license BOOLEAN DEFAULT FALSE;`
- load arasaac.sql into MySQL
- load pictocat_tree_populate.sql
`source /vagrant/roles/database/files/pictocat_tree_populate.sql;`
- reload trigers-enrolments-integrity-constraints.sql
- alter table supervisor to add postal_code:
`alter table supervisor add column `postal_code` char(10) COLLATE utf8_unicode_ci NOT NULL;`
- alter table office to add postal_code:
`alter table office add column `postal_code` char(10) COLLATE utf8_unicode_ci NOT NULL;`
- remove max_students and current_students columns from offices:
`alter table office drop column max_students;`
`alter table office drop column current_students;`
- copy postal_code value from office to its supervisors
`update supervisor as sup inner join office as off on off.id = sup.id_off set sup.postal_code = off.postal_code;`
- alter table office
`alter table office modify logo_url varchar(240) default null;`
...@@ -161,7 +161,7 @@ module.exports = { ...@@ -161,7 +161,7 @@ module.exports = {
student.supervision = 0; // requester is admin of the office student.supervision = 0; // requester is admin of the office
else if (stu_sup && !req.token.office) else if (stu_sup && !req.token.office)
student.supervision = 1; // requester is tutor of the studend student.supervision = 1; // requester is tutor of the studend
else if (stu_sup && req.token.office && student.office == req.token.office.id) else if (stu_sup && req.token.office)
student.supervision = 2; // requester is supervisor of student student.supervision = 2; // requester is supervisor of student
else if (req.token.isStudent && req.token.id == student.id) else if (req.token.isStudent && req.token.id == student.id)
student.supervision = 3 // requester is the student himself student.supervision = 3 // requester is the student himself
...@@ -1438,7 +1438,7 @@ module.exports = { ...@@ -1438,7 +1438,7 @@ module.exports = {
Action.create({ Action.create({
type: action, type: action,
timestamp: attributes.timestamp, // it comes already in ISO format timestamp: new Date().toISOString(), // it comes already in ISO format
supervisor: sup, supervisor: sup,
student: attributes.id_stu, student: attributes.id_stu,
description: desc description: desc
......
...@@ -330,7 +330,7 @@ module.exports = { ...@@ -330,7 +330,7 @@ module.exports = {
email: params.email, email: params.email,
pic: sails.config.pictogram.paths.defaultAvatarFileName, pic: sails.config.pictogram.paths.defaultAvatarFileName,
address: params.address || '', address: params.address || '',
postalCode: params.postalCode || '', postal_code: params.postalCode || '',
country: params.country || '', country: params.country || '',
phone: params.phone || '', phone: params.phone || '',
lang: params.lang || 'es-es', lang: params.lang || 'es-es',
...@@ -338,6 +338,7 @@ module.exports = { ...@@ -338,6 +338,7 @@ module.exports = {
if (params.id_off) if (params.id_off)
supData.id_off = params.id_off; supData.id_off = params.id_off;
console.log(JSON.stringify(supData));
Supervisor.create(supData) Supervisor.create(supData)
.then(function (sup) { .then(function (sup) {
...@@ -369,11 +370,13 @@ module.exports = { ...@@ -369,11 +370,13 @@ module.exports = {
supervisor = sup; supervisor = sup;
sendConfirmationMail((err) => { sendConfirmationMail((err) => {
if (err) throw err; if (err) return res.serverError("Confirmation mail could not be sent: " + err);
return res.ok(); return res.ok();
}); });
}) })
.catch(err => {throw err}); .catch((err) => {
return res.serverError("Supervisor could not be created: " + err);
});
} else } else
return res.badRequest("Invalid role"); return res.badRequest("Invalid role");
}).catch(function (err) { }).catch(function (err) {
...@@ -474,12 +477,12 @@ module.exports = { ...@@ -474,12 +477,12 @@ module.exports = {
update: function (req, res) { update: function (req, res) {
Supervisor.findOne({ id: req.params.id }) Supervisor.findOne({ id: req.params.id })
.then(function (supervisor) { .then(function (supervisor) {
if (supervisor) { if (!supervisor)
if (req.body.password) { return res.notFound();
supervisor.password = req.body.password;
} else {
delete supervisor.password; delete supervisor.password;
} if (req.body.password && req.body.password.length > 0)
supervisor.password = req.body.password;
console.log(supervisor.password);
supervisor.name = req.body.name || supervisor.name; supervisor.name = req.body.name || supervisor.name;
supervisor.surname = req.body.surname || supervisor.surname; supervisor.surname = req.body.surname || supervisor.surname;
supervisor.gender = req.body.gender || supervisor.gender; supervisor.gender = req.body.gender || supervisor.gender;
...@@ -493,18 +496,12 @@ module.exports = { ...@@ -493,18 +496,12 @@ module.exports = {
supervisor.ttsEngine = req.body.ttsEngine || supervisor.ttsEngine; supervisor.ttsEngine = req.body.ttsEngine || supervisor.ttsEngine;
supervisor.office = req.body.office || supervisor.office; supervisor.office = req.body.office || supervisor.office;
supervisor.save(function (error) { supervisor.save(function (error) {
if (error) { if (error) throw error;
res.serverError(); return res.ok(supervisor);
} else {
res.ok(supervisor);
}
}); });
} else {
res.notFound();
}
}) })
.catch(function () { .catch(function (err) {
res.serverError(); return res.serverError(err);
}); });
}, },
...@@ -742,9 +739,13 @@ module.exports = { ...@@ -742,9 +739,13 @@ module.exports = {
delete: function (req, res) { delete: function (req, res) {
if (!req.params.id) if (!req.params.id)
return res.badRequest("Missing parameter"); return res.badRequest("Missing parameter");
StuSup.destroy({id_sup: req.params.id})
.then(() => {
Supervisor.destroy({id: req.params.id}) Supervisor.destroy({id: req.params.id})
.then(() => {res.ok()}) .then(() => {res.ok()})
.catch((err) => {res.serverError("Could not delete supervisor")}); .catch((err) => {console.log(err); res.serverError("Could not delete supervisor")});
})
.catch((err) => {console.log(err); res.serverError("Could not delete supervisor")});
} }
}; };
...@@ -44,7 +44,7 @@ module.exports = { ...@@ -44,7 +44,7 @@ module.exports = {
lang: { lang: {
required: true, required: true,
type: "string", type: "string",
size: 2 size: 5
}, },
contactPerson: { contactPerson: {
columnName: "contact_person", columnName: "contact_person",
...@@ -88,6 +88,7 @@ module.exports = { ...@@ -88,6 +88,7 @@ module.exports = {
collection: "Student", collection: "Student",
via: 'office' via: 'office'
}, },
toJSON: function() { toJSON: function() {
var office = this.toObject(); var office = this.toObject();
if (!office.logoUrl) if (!office.logoUrl)
......
...@@ -74,7 +74,7 @@ module.exports = { ...@@ -74,7 +74,7 @@ module.exports = {
lang: { lang: {
required: true, required: true,
type: "string", type: "string",
size: 2 size: 5
}, },
ttsEngine: { ttsEngine: {
columnName: 'tts_engine', columnName: 'tts_engine',
...@@ -143,7 +143,7 @@ module.exports = { ...@@ -143,7 +143,7 @@ module.exports = {
// //
beforeCreate: function (attrs, next) { beforeCreate: function (attrs, next) {
var async = require('async'); var async = require('async');
console.log("-->\n" + JSON.stringify(attrs));
async.series( async.series(
[ [
function (cb) { function (cb) {
...@@ -190,6 +190,9 @@ module.exports = { ...@@ -190,6 +190,9 @@ module.exports = {
Supervisor.findOne({ email: attrs.email }).then(function (supervisor) { Supervisor.findOne({ email: attrs.email }).then(function (supervisor) {
if (supervisor && supervisor.id !== attrs.id) { if (supervisor && supervisor.id !== attrs.id) {
cb(new Error('Email being used')); cb(new Error('Email being used'));
} else if (attrs.password && attrs.password.length > 0 && attrs.password == supervisor.password) {
delete attrs.password;
cb();
} else { } else {
cb(); cb();
} }
...@@ -203,6 +206,8 @@ module.exports = { ...@@ -203,6 +206,8 @@ module.exports = {
var bcrypt = require('bcrypt-nodejs'); var bcrypt = require('bcrypt-nodejs');
if (attrs.password && attrs.password.length > 0) { if (attrs.password && attrs.password.length > 0) {
attrs.password = bcrypt.hashSync(attrs.password, bcrypt.genSaltSync()); attrs.password = bcrypt.hashSync(attrs.password, bcrypt.genSaltSync());
} else {
delete attrs.password;
} }
cb(); cb();
} }
......
...@@ -53,7 +53,15 @@ process.chdir(__dirname); ...@@ -53,7 +53,15 @@ process.chdir(__dirname);
} }
} }
var sh;
try{
var SegfaultHandler = require('segfault-handler');
}catch(e){
console.log("No se ha podido cargar segfault-handler");
}
// Start server // Start server
sails.lift(rc('sails')); sails.lift(rc('sails'));
SegfaultHandler.registerHandler("crash.log"); // With no argument, SegfaultHandler will generate a generic log file name
})(); })();
...@@ -21,7 +21,7 @@ function SignInCtrl($scope, ...@@ -21,7 +21,7 @@ function SignInCtrl($scope,
name: '', name: '',
surname: '', surname: '',
address: '', address: '',
postal_code: '', postalCode: '',
country: '00', country: '00',
phone: '', phone: '',
gender: 'F', gender: 'F',
...@@ -41,7 +41,7 @@ function SignInCtrl($scope, ...@@ -41,7 +41,7 @@ function SignInCtrl($scope,
email: '', email: '',
logoUrl: '' logoUrl: ''
}, },
office_idx: -1 id_off: -1
}; };
}; };
...@@ -92,6 +92,11 @@ function SignInCtrl($scope, ...@@ -92,6 +92,11 @@ function SignInCtrl($scope,
return; return;
} }
if (($scope.formdata.role == 'therapist_office' || $scope.formdata.role == 'tutor_office') && $scope.formdata.id_off == -1) {
ngToast.danger({ content: $translate.instant('select_office') });
return;
}
if ($scope.formdata.role == 'therapist_nooffice' && $scope.formdata.office.country == '00') { if ($scope.formdata.role == 'therapist_nooffice' && $scope.formdata.office.country == '00') {
ngToast.danger({ content: $translate.instant('country_office_requested') }); ngToast.danger({ content: $translate.instant('country_office_requested') });
return; return;
...@@ -112,10 +117,8 @@ function SignInCtrl($scope, ...@@ -112,10 +117,8 @@ function SignInCtrl($scope,
$scope.showdialog = true; $scope.showdialog = true;
if ($scope.formdata.office_idx != -1) { if ($scope.formdata.id_off == -1)
$scope.formdata.id_off = $scope.offices[$scope.formdata.office_idx].id; delete $scope.formdata.id_off;
delete $scope.formdata.office_idx;
}
if ($scope.formdata.role === 'tutor_nooffice') { if ($scope.formdata.role === 'tutor_nooffice') {
$scope.formdata.office.name = 'no_office'; $scope.formdata.office.name = 'no_office';
......
...@@ -223,9 +223,9 @@ ...@@ -223,9 +223,9 @@
<div class="form-group" id="office_selection"> <div class="form-group" id="office_selection">
<legend translate>office_center</legend> <legend translate>office_center</legend>
<select class="form-control" ng-model="formdata.office_idx" ng-required="formdata.role == 'therapist_office' || formdata.role == 'tutor_office'"> <select class="form-control" ng-model="formdata.id_off" ng-required="formdata.role == 'therapist_office' || formdata.role == 'tutor_office'">
<option selected disabled hidden value="-1">{{ 'select_office' | translate }}</option> <option selected disabled hidden value="-1">{{ 'select_office' | translate }}</option>
<option ng-repeat="office in offices | orderBy: 'name' track by $index" ng-value="$index"> {{ office.name }} </option> <option ng-repeat="office in offices | orderBy: 'name' track by office.id" ng-value="office.id"> {{ office.name }} </option>
</select> </select>
</div> </div>
......
...@@ -697,6 +697,14 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -697,6 +697,14 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$scope.$apply(); $scope.$apply();
}); });
// unsubscribe sockets when leaving
$rootScope.$on('$stateChangeStart',
function(event, toState, toParams, fromState, fromParams) {
io.socket.off('scene');
io.socket.off('vocabulary');
}
);
// Load pictos // Load pictos
$scope.showActiveScene(); $scope.showActiveScene();
$scope.loadScenesList(); $scope.loadScenesList();
......
...@@ -235,9 +235,18 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -235,9 +235,18 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.wsessions[$scope.wsessions.length-1].tries.pop(); $scope.wsessions[$scope.wsessions.length-1].tries.pop();
$scope.ws.end = new Date(); $scope.ws.end = new Date();
$http $http
.post( .post(config.backend+'/action', {
config.backend+'/ws/' + $scope.ws.id + '/close', "type": "endsession",
"student": $scope.studentData.id,
"supervisor": $scope.user.id,
})
.success(function(data, status, headers, _config) {
// Adding resume action to the list of actions
$scope.actual_try.actions.push({ action: 'endsession'} );
$http.post(config.backend+'/ws/' + $scope.ws.id + '/close',
{ {
"id_stu": $scope.studentData.id "id_stu": $scope.studentData.id
} }
...@@ -252,6 +261,10 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -252,6 +261,10 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
}); });
})
.error(function(data, status, headers, config) {
});
// Cancel the mark of the device connected (with a new session will be connected again) // Cancel the mark of the device connected (with a new session will be connected again)
//$scope.active_device = null; //$scope.active_device = null;
}; };
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<div class="row"> <div class="row">
<div class="col-xs-2"><i class="fa fa-info-circle fa-lg" aria-hidden="true"></i></div> <div class="col-xs-2"><i class="fa fa-info-circle fa-lg" aria-hidden="true"></i></div>
<div class="col-xs-10"> <div class="col-xs-10">
<h4 class="alert-heading"> {{ 'license_expires' | translate }} <b>{{ studentData.expiration_date }}</b> </h4> {{ 'license_expires' | translate }} <b>{{ studentData.expiration_date }}</b>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -19,6 +19,10 @@ dashboardControllers.controller('TranslateController', function( ...@@ -19,6 +19,10 @@ dashboardControllers.controller('TranslateController', function(
var obj = JSON.parse($window.sessionStorage.user); var obj = JSON.parse($window.sessionStorage.user);
$translate.use(obj.lang); $translate.use(obj.lang);
} }
else if($window.sessionStorage.lang){
var lang = JSON.parse($window.sessionStorage.lang);
$translate.use(lang);
}
// Changes the language when user click on footer lang // Changes the language when user click on footer lang
$scope.changeLanguage = function (langKey) { $scope.changeLanguage = function (langKey) {
...@@ -48,6 +52,11 @@ dashboardControllers.controller('TranslateController', function( ...@@ -48,6 +52,11 @@ dashboardControllers.controller('TranslateController', function(
console.log("Error: Update supervisor language"); console.log("Error: Update supervisor language");
}); });
} }
else{
var lang = JSON.parse($window.sessionStorage.lang);
lang = langKey;
$window.sessionStorage.lang = JSON.stringify(lang);
}
// Reload captcha according to language (only once instance per page, so id is always 0) // Reload captcha according to language (only once instance per page, so id is always 0)
try { try {
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
"eslint-plugin-react": "^5.1.1", "eslint-plugin-react": "^5.1.1",
"mocha": "^2.4.5", "mocha": "^2.4.5",
"node-inspector": "^0.12.8", "node-inspector": "^0.12.8",
"segfault-handler": "^1.0.0",
"supertest": "^1.2.0" "supertest": "^1.2.0"
} }
} }
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