Commit 17f37b1e by Jose Antonio

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

parents 14fddbba 47f65b93
Showing with 438 additions and 349 deletions
......@@ -51,7 +51,6 @@ public abstract class Action {
Log.d("TIMESTAMP-----------> ", datetime.format(currentTime));
if (PCBcontext.getPcbdb().getCurrentUser().has_supervisor()) {
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());
}
//TODO Decidir qué almacenar con DEVICE
......
......@@ -176,7 +176,7 @@ public class Device extends SQLiteOpenHelper {
Cursor cursor = db.query("users_detail", null, null, null, null, null, null, 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),
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),
......@@ -192,9 +192,9 @@ public class Device extends SQLiteOpenHelper {
* @return
* @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();
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())
return true;
cursor.close();
......@@ -213,7 +213,7 @@ public class Device extends SQLiteOpenHelper {
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())
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();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return users;
......
......@@ -55,7 +55,6 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @see PCBDBHelper#getCurrentUser()
*/
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;
PCBcontext.getDevice().setLastStuId(user.get_id_stu());
if (user.is_supervisor()) PCBcontext.getDevice().setLastSupId(user.get_id_sup());
......@@ -162,8 +161,8 @@ public class PCBDBHelper extends SQLiteOpenHelper {
try {
String sql_scene="INSERT OR REPLACE INTO scene VALUES ("
+params.getInt("id")
+","+params.getInt("supervisor")
+","+params.get("student")
+","+PCBcontext.getPcbdb().getCurrentUser().get_id_sup()
+","+params.getInt("student")
+",'"+params.getString("name")
+"','"+params.getBoolean("active")
+"','"+params.getBoolean("categories")
......@@ -172,7 +171,9 @@ public class PCBDBHelper extends SQLiteOpenHelper {
getWritableDatabase().execSQL(sql_scene);
//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) {
e.printStackTrace();
Log.e(LOG_TAG,"Error setting active scene:"+e.getMessage());
......@@ -186,16 +187,10 @@ public class PCBDBHelper extends SQLiteOpenHelper {
*/
public int getActiveSceneForStudent(int id_stu){
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();
int id;
if(cursor.getCount() > 0){
id=cursor.getInt(0);
Log.e(LOG_TAG," Active scene id:"+id);
return cursor.getInt(0);
}
return -1;
Log.i(LOG_TAG,"Scene: "+cursor.getInt(0)+"-- For student: "+id_stu);
return cursor.getInt(0);
}
/**
......@@ -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);
boolean has_categories;
cursor.moveToFirst();
int id;
if(cursor.getCount() > 0){
has_categories=cursor.getString(0).equals("true");
}
......@@ -223,8 +217,8 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* @see com.yottacode.pictogram.dao.Picto
*/
public Vocabulary getStudentVocabulary(Vocabulary vocabulary ) throws JSONException {
int id_stu = this.getCurrentUser().get_id_stu();
int id_scene = this.getCurrentUser().get_active_scene();
int id_stu = this.currentUser.get_id_stu();
int id_scene = this.currentUser.get_active_scene();
SQLiteDatabase db = this.getReadableDatabase();
......@@ -256,11 +250,10 @@ public class PCBDBHelper extends SQLiteOpenHelper {
values.put("id_stu", id_stu);
db.beginTransaction();
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_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("url", picto.get_url());
values.put("translation",picto.get_translation());
......@@ -286,7 +279,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
values.put("id_stu", id_stu);
values.put("id_picto", picto.get_id());
//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("url", picto.get_url());
values.put("translation",picto.get_translation());
......
......@@ -251,22 +251,11 @@ public class User {
* @return The id of the active scene of this student
*/
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;
}
public void set_active_scene(int id) {
//try {
this.id_scene_stu = id;
//this.attributes_stu.put(JSON_STUDENT_ATTTRS.ID_ACTIVE_SCENE,id);
/*} catch (JSONException e) {
e.printStackTrace();
}*/
this.id_scene_stu = id;
}
/**
*
......
......@@ -60,7 +60,7 @@ public class ActionTalk implements Emitter.Listener {
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;
}
Log.i(LOG_TAG, "Received message '" + action +
Log.d(LOG_TAG, "Received message '" + action +
"' for picto " + picto_id + " (cat " + picto_cat);
for (iActionListener listener : this.listeners)
listener.action(action.equals(action_add)
......
......@@ -34,6 +34,7 @@ public class VocabularyTalk implements Emitter.Listener {
final String param_picto="picto";
final String param_stu_picto="stu_picto";
final String param_picto_id="id";
final String param_stupicto_scene="scene";
final String param_picto_cat="id_cat";
final String action_update="update";
final String action_update_category="update_category";
......@@ -41,6 +42,7 @@ public class VocabularyTalk implements Emitter.Listener {
final String action_delete="delete";
JSONObject msg = (JSONObject) args[0];
try {
Log.i(LOG_TAG, "raw Received message " +msg.toString());
......@@ -51,7 +53,7 @@ public class VocabularyTalk implements Emitter.Listener {
JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto);
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;
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
for (iVocabularyListener listener : this.listeners)
listener.change(action.equals(action_update) ? iVocabularyListener.action.update
......
......@@ -77,7 +77,6 @@ public final class PCBcontext {
@Override
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);
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;
import android.net.Uri;
import android.os.Bundle;
import android.app.Fragment;
import android.provider.ContactsContract;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
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 {
LinearLayout layout = null;
ArrayList<ImageView> pictos = null;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
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
return v;
}
public boolean closedFragment(){
this.onDestroy();
return true;
public void cargar_pictos(JSONArray arrayPictos){
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;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.ClipData;
......@@ -38,6 +39,8 @@ import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
......@@ -159,30 +162,55 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
this.vocabulary = PCBcontext.getVocabulary();
this.vocabulary.listen(PCBcontext.getRoom(), this, new ActionTalk.iActionListener() {
@Override
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");
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 {
//Log.i("TAG_PRUEBAS","show message received:"+msg.get("expression"));
JSONObject msg_attrs = msg.getJSONObject("attributes");
JSONArray pictos = msg_attrs.getJSONArray("pictos");
for(int i = 0; i < pictos.length(); i++) {
JSONObject picto = pictos.getJSONObject(i).getJSONObject("attributes");
Log.i("TAG_PRUEBAS","picto received:"+picto.get("expression").toString());
msg_attrs = msg.getJSONObject("attributes");
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++) {
JSONObject picto = pictos.getJSONObject(i).getJSONObject("attributes");
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) {
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()) {
......
......@@ -18,7 +18,6 @@ import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.tabletlibrary.R;
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.PCBcontext;
import com.yottacode.tools.GUITools;
......@@ -28,9 +27,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Vector;
/**
......@@ -243,7 +240,7 @@ public class StudentFragmentGrid extends Fragment{
try {
supervisor = supervisors.getJSONObject(i);
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();
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()
......@@ -322,7 +319,7 @@ public class StudentFragmentGrid extends Fragment{
GUITools.show_alert(getActivity(), R.string.loginErrorTxt,getString(R.string.noStudentsError), new GUITools.iOKListener() {
@Override
public void ok() {
PCBcontext.getNetService().restart_app(false);
PCBcontext.getNetService().restart_app(true);
}
});
......
......@@ -80,6 +80,7 @@
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/loginTopbarLayout"
android:background="#eeeeee"
android:paddingTop="10dp">
<fragment
......
......@@ -68,7 +68,7 @@
android:layout_height="wrap_content"
android:layout_below="@+id/serialmail"
android:layout_marginTop="25dp"
android:layout_toStartOf="@+id/imageView"
android:layout_toStartOf="@+id/imageView1"
android:background="@drawable/edit_text_login_style"
android:fontFamily="monospace"
android:hint="@string/prompt_serial_pass"
......@@ -100,7 +100,7 @@
</LinearLayout>
<ImageView
android:id="@+id/imageView"
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
......
......@@ -8,17 +8,17 @@
tools:context="com.yottacode.pictogram.tabletlibrary.gui.login.SplashScreenActivity" >
<ImageView
android:id="@+id/imageView2"
android:layout_width="400px"
android:layout_height="120px"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="44dp"
android:contentDescription="@string/app_name"
android:orientation="vertical"
android:src="@drawable/yottacode_logo"
android:scaleX="0.5"
android:scaleY="0.5"
android:id="@+id/imageView2"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="44dp" />
android:src="@drawable/yottacode_logo" />
<ImageView
android:layout_width="200px"
......@@ -26,7 +26,7 @@
android:contentDescription="@string/app_name"
android:orientation="vertical"
android:src="@drawable/pictogram_logo"
android:id="@+id/imageView"
android:id="@+id/imageView1"
android:scaleX="1.5"
android:scaleY="1.5"
android:layout_centerVertical="true"
......
......@@ -27,48 +27,49 @@
android:textStyle="bold" />
<LinearLayout
android:id="@+id/layoutImages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
<ImageView
android:id="@+id/imageView5"
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
<ImageView
android:id="@+id/imageView4"
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
<ImageView
android:id="@+id/imageView3"
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
<ImageView
android:id="@+id/imageView2"
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
<ImageView
android:id="@+id/imageView8"
android:id="@+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
......@@ -84,20 +85,20 @@
android:layout_weight="1" />
<ImageView
android:id="@+id/imageView6"
android:id="@+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1" />
</LinearLayout>
<Button
android:id="@+id/aceptar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button"
android:onClick="closedFragment()"/>
android:text="Vale" />
</LinearLayout>
......
......@@ -3,5 +3,6 @@
android:id="@+id/loginStudentGridView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#eeeeee"
android:numColumns="5"
android:stackFromBottom="false" />
......@@ -4,7 +4,8 @@
android:layout_height="match_parent">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@android:id/list" />
android:background="#eeeeee" />
</LinearLayout>
......@@ -6,7 +6,8 @@
android:layout_height="match_parent">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@android:id/list" />
android:background="#eeeeee" />
</LinearLayout>
......@@ -48,6 +48,8 @@
<string name="titleCropperNew">New Picto</string>
<string name="insertPasswordLogin">Insert Password</string>
<string name="version_label">Version:</string>
<string name="message_from">Message from</string>
<string name="says">Says</string>
</resources>
......@@ -47,6 +47,8 @@
<string name="titleCropperNew">Nuevo Pictograma</string>
<string name="insertPasswordLogin">Inserte Contraseña</string>
<string name="version_label">Versión:</string>
<string name="message_from">Mensaje de</string>
<string name="says">Dice</string>
</resources>
......@@ -54,4 +54,6 @@
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="message_from">Mensaje de</string>
<string name="says">Dice</string>
</resources>
......@@ -13,8 +13,6 @@ CREATE PROCEDURE scene_adapt()
BEGIN
DECLARE _id_stu INT;
DECLARE _id_sup INT;
DECLARE _cat_status CHAR(10);
DECLARE _cat_active BOOLEAN;
DECLARE done INT DEFAULT FALSE;
DECLARE LID INT;
......@@ -32,19 +30,9 @@ BEGIN
LEAVE read_loop;
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*/
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();
......@@ -58,7 +46,7 @@ BEGIN
/* SECOND SCENE, NOT ACTIVE, NO CATEGORIES*/
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();
......
......@@ -7,103 +7,109 @@ SET @TRIGGER_CHECKS = FALSE;
-- Oficina
--
INSERT INTO `office` (
`name`,
`address`,
`country`,
`contact_person`,
`email`,
`phone1`,
`lang`,
`postal_code`
) VALUES (
'Comunicación Aumentativa JAén (CAJA)',
'Paraje Las Lagunillas, Ed A3, primera plata, 23071. Jaén',
'ES',
'Fernando Martínez Santiago',
'dofer@ujaen.es',
'+34 953 21 28 88',
'es-es',
'23071'
);
INSERT INTO `office` (
`name`,
`address`,
`country`,
`contact_person`,
`email`,
`phone1`,
`lang`,
`postal_code`
) VALUES (
'Comunicación Aumentativa JAén (CAJA)',
'Paraje Las Lagunillas, Ed A3, primera plata, 23071. Jaén',
'ES',
'Fernando Martínez Santiago',
'dofer@ujaen.es',
'+34 953 21 28 88',
'es-es',
'23071'
);
--
-- Supervisores
--
INSERT INTO `supervisor` (
`name`,
`surname`,
`gender`,
`address`,
`email`,
`phone`,
`lang`,
`password`,
`active`,
`id_off`,
`pic`
) VALUES (
'Fernando',
'Martínez Santiago',
'M',
NULL,
'dofer@ujaen.es',
'+34953212888',
'es-es',
'$2a$10$Q4jHNlC58.ptfl/5wZeHfOIvpJslJHKOFNZO3bWs4it7TifQPQnEa',
true,
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_dofer.jpg'
), (
'Miguel Ángel',
'García Cumbreras',
'M',
NULL,
'magc@ujaen.es',
'+34953212420',
'es-es',
'$2a$04$XQvWUwGTvjR47ChPwd3f6ukx8Zg.7o1N4Kf6P.zqhVtQxVNArOsXi',
true,
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_miguel.jpg'
), (
'Arturo',
'Montejo Ráez',
'M',
NULL,
'amontejo@ujaen.es',
'+34953212882',
'es-es',
'$2a$04$yoBXAMSgCVGSIr2pnuIOw.J8UCm8f2XkATu5rqsMJiEmlxBHs5.cO',
true,
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_arturo.jpg'
), (
'Alfonso',
'Ureña López',
'M',
NULL,
'laurena@ujaen.es',
'+34953212895',
'es-es',
'$2a$04$zVGHJFafoZa60wo1yBqF/Oi3RXV/qS2cq0/j/W3Dkf4P1ad0e7.iS',
true,
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_alfonso.jpg'
), (
'Jesús',
'Navarro Moreno',
'M',
NULL,
'jnavarro@ujaen.es',
'+34953211912',
'es-es',
'$2a$04$8O3Jd5j9/nM/KC.b1a8qRevyUwWUx6XGU3Gm754Y/8PpLO2jv.i76',
true,
(SELECT id from office where email='dofer@ujaen.es'),
'defaultAvatar.jpg'
);
INSERT INTO `supervisor` (
`name`,
`surname`,
`gender`,
`address`,
`email`,
`phone`,
`lang`,
`password`,
`active`,
`postal_code`,
`id_off`,
`pic`
) VALUES (
'Fernando',
'Martínez Santiago',
'M',
NULL,
'dofer@ujaen.es',
'+34953212888',
'es-es',
'$2a$10$Q4jHNlC58.ptfl/5wZeHfOIvpJslJHKOFNZO3bWs4it7TifQPQnEa',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_dofer.jpg'
), (
'Miguel Ángel',
'García Cumbreras',
'M',
NULL,
'magc@ujaen.es',
'+34953212420',
'es-es',
'$2a$04$XQvWUwGTvjR47ChPwd3f6ukx8Zg.7o1N4Kf6P.zqhVtQxVNArOsXi',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_miguel.jpg'
), (
'Arturo',
'Montejo Ráez',
'M',
NULL,
'amontejo@ujaen.es',
'+34953212882',
'es-es',
'$2a$04$yoBXAMSgCVGSIr2pnuIOw.J8UCm8f2XkATu5rqsMJiEmlxBHs5.cO',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_arturo.jpg'
), (
'Alfonso',
'Ureña López',
'M',
NULL,
'laurena@ujaen.es',
'+34953212895',
'es-es',
'$2a$04$zVGHJFafoZa60wo1yBqF/Oi3RXV/qS2cq0/j/W3Dkf4P1ad0e7.iS',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'test_caja_alfonso.jpg'
), (
'Jesús',
'Navarro Moreno',
'M',
NULL,
'jnavarro@ujaen.es',
'+34953211912',
'es-es',
'$2a$04$8O3Jd5j9/nM/KC.b1a8qRevyUwWUx6XGU3Gm754Y/8PpLO2jv.i76',
true,
'23071',
(SELECT id from office where email='dofer@ujaen.es'),
'defaultAvatar.jpg'
);
--
-- Tutores
......@@ -119,7 +125,8 @@ INSERT INTO `supervisor` (
`phone`,
`lang`,
`password`,
`active`
`active`,
`postal_code`
) VALUES (
'Don Fernando',
'Padre Fernandito',
......@@ -130,7 +137,8 @@ INSERT INTO `supervisor` (
'+34 232 232 232',
'es-es',
'$2a$04$DMOX/cZ4h6cNJW9VlCou7O266q4YDYuS6p0QzP.gBHd08.QnFQWD.',
true
true,
'23071'
), (
'Don Arturo',
'Padre Arturito',
......@@ -141,7 +149,8 @@ INSERT INTO `supervisor` (
NULL,
'es-es',
'$2a$04$V2ods9MMmOFvdLTaHJqk3ejKEYdf28gvfDhaBkOSLCFJOC02TweFK',
true
true,
'23071'
), (
'Don Miguel',
'Padre Miguelito',
......@@ -152,18 +161,20 @@ INSERT INTO `supervisor` (
NULL,
'es-es',
'$2a$04$1UCak614LKz6WpDBtOblQeqFF41tOMy6ERMnP2OuGVZffe8Yi0mJq',
true
true,
'23071'
), (
'Don Afonso',
'Don Alfonso',
'Padre Alfonsito',
'M',
'Avda. Andalucía 1. Jaén',
'ES',
'donalfonso@gmail.com',
'donalfonso@gmail.com',
NULL,
'es-es',
'$2a$04$$2a$04$KktXwe06AJg3vMUEX1E1/esbP.g8f79mtcNGjCsrEDWktmegcML4q',
true
'$2a$06$UtyBV4tLlT7xSqIt8LKPBucGvZ.Wgf7RgGE0fRcjEBDwjxjHlsP3K',
true,
'23071'
), (
'Doña Alfonsa',
'Madre Alfonsita',
......@@ -174,7 +185,8 @@ INSERT INTO `supervisor` (
NULL,
'es-es',
'$2a$04$ALDmQ1oRhRZKUEi1b0eK1ehQmSZiFkhzx48ZBwER0J4vakvlYc5VS',
true
true,
'23071'
), (
'Don Jesús',
'Padre Jesusito',
......@@ -185,7 +197,8 @@ INSERT INTO `supervisor` (
NULL,
'es-es',
'$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='
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';
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
--
INSERT INTO stu_picto(id_stu,id_pic,attributes)
SELECT S.id,P.id_pic, concat('{"id_cat":', if (id_cat_pic is null, 'null',id_cat_pic),
',"coord_x":',coord_x,
',"coord_y":',coord_y,
',"status":"invisible"',
',"highlight":false',
',"color":', if (color is null, 'null',concat('"',color,'"')),
'}') as attributes
FROM student S, picto_core P
WHERE S.id_off =(SELECT id from office where name='Comunicación Aumentativa JAén (CAJA)');
--
-- 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),
-- ',"coord_x":',coord_x,
-- ',"coord_y":',coord_y,
-- ',"status":"invisible"',
-- ',"highlight":false',
-- ',"color":', if (color is null, 'null',concat('"',color,'"')),
-- '}') as attributes
-- FROM student S, picto_core P
-- WHERE S.id_off =(SELECT id from office where name='Comunicación Aumentativa JAén (CAJA)');
--
-- Test method
--
INSERT INTO meta_method(name) VALUES (
'Test MetaMethod'
);
INSERT INTO method(name, id_stu) VALUES (
'Test Method',
(SELECT id FROM student WHERE username='aaa0002')
);
INSERT INTO instruction(name, id_met) VALUES (
'Test Instruction',
(SELECT id FROM method WHERE name='Test Method')
);
INSERT INTO working_session (id_sup, id_ins) VALUES (
(SELECT id FROM supervisor WHERE email='dofer@ujaen.es'),
(SELECT id FROM instruction WHERE name='Test Instruction')
);
-- INSERT INTO meta_method(name) VALUES (
-- 'Test MetaMethod'
-- );
-- INSERT INTO method(name, id_stu) VALUES (
-- 'Test Method',
-- (SELECT id FROM student WHERE username='aaa0002')
-- );
-- INSERT INTO instruction(name, id_met) VALUES (
-- 'Test Instruction',
-- (SELECT id FROM method WHERE name='Test Method')
-- );
-- INSERT INTO working_session (id_sup, id_ins) VALUES (
-- (SELECT id FROM supervisor WHERE email='dofer@ujaen.es'),
-- (SELECT id FROM instruction WHERE name='Test Instruction')
-- );
SET @TRIGGER_CHECKS = TRUE;
SET foreign_key_checks=1;
......@@ -107,6 +107,9 @@ BEGIN
IF (idopentry IS NOT NULL) THEN
DELETE FROM try
WHERE id = idopentry;
DELETE FROM stu_opentry
WHERE id_ws = ws;
END IF;
END;;
......@@ -261,9 +264,10 @@ thisTrigger: BEGIN
-- Show and resumesession actions creates new tries
CASE NEW.type
WHEN 'Show' THEN
IF (idopentry IS NOT NULL) THEN
INSERT INTO try(`id_ws`)
VALUES (idws);
VALUES (idws);
END IF;
WHEN 'pausesession' THEN
......@@ -273,7 +277,12 @@ thisTrigger: BEGIN
result = 'DISCARDED'
WHERE
id = idopentry;
END IF;
UPDATE stu_opentry
SET id_opentry=NULL
WHERE id_ws = idws;
END IF;
WHEN 'resumesession' THEN
......@@ -303,15 +312,19 @@ thisTrigger: BEGIN
IF ((new.end IS NOT NULL) AND (new.current IS NOT NULL)) THEN
SET new.current=NULL;
-- DONE IN TRG_SESSION_CLOSED
-- Remove opentry record
DELETE FROM stu_opentry
WHERE id_ws = new.id;
-- DELETE FROM stu_opentry
-- WHERE id_ws = new.id;
-- Remove tries with no actions
DELETE FROM `try`
WHERE
end = NULL AND
id_ws = new.id;
-- DELETE FROM `try`
-- WHERE
-- end IS NULL AND
-- id_ws = new.id;
END IF;
END;;
......
......@@ -2,28 +2,9 @@
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
- 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
`source update_arasaac_color_uri.sql`
......@@ -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
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` 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;`
......@@ -55,28 +40,4 @@ Changes to be performed manually in servers to upgrade
- Reload enrolments trigger
`source /vagrant/roles/database/files/triggers-enrolments-integrity-constraints.sql`
(already done in dev & pre)
- 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;`
- Reload triggers-sessions-integrity-constraints.sql
......@@ -161,7 +161,7 @@ module.exports = {
student.supervision = 0; // requester is admin of the office
else if (stu_sup && !req.token.office)
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
else if (req.token.isStudent && req.token.id == student.id)
student.supervision = 3 // requester is the student himself
......@@ -1438,7 +1438,7 @@ module.exports = {
Action.create({
type: action,
timestamp: attributes.timestamp, // it comes already in ISO format
timestamp: new Date().toISOString(), // it comes already in ISO format
supervisor: sup,
student: attributes.id_stu,
description: desc
......
......@@ -330,7 +330,7 @@ module.exports = {
email: params.email,
pic: sails.config.pictogram.paths.defaultAvatarFileName,
address: params.address || '',
postalCode: params.postalCode || '',
postal_code: params.postalCode || '',
country: params.country || '',
phone: params.phone || '',
lang: params.lang || 'es-es',
......@@ -338,6 +338,7 @@ module.exports = {
if (params.id_off)
supData.id_off = params.id_off;
console.log(JSON.stringify(supData));
Supervisor.create(supData)
.then(function (sup) {
......@@ -367,13 +368,15 @@ module.exports = {
off.admin = sup.id;
off.save();
supervisor = sup;
supervisor = sup;
sendConfirmationMail((err) => {
if (err) throw err;
if (err) return res.serverError("Confirmation mail could not be sent: " + err);
return res.ok();
});
})
.catch(err => {throw err});
.catch((err) => {
return res.serverError("Supervisor could not be created: " + err);
});
} else
return res.badRequest("Invalid role");
}).catch(function (err) {
......@@ -474,37 +477,31 @@ module.exports = {
update: function (req, res) {
Supervisor.findOne({ id: req.params.id })
.then(function (supervisor) {
if (supervisor) {
if (req.body.password) {
supervisor.password = req.body.password;
} else {
delete supervisor.password;
}
supervisor.name = req.body.name || supervisor.name;
supervisor.surname = req.body.surname || supervisor.surname;
supervisor.gender = req.body.gender || supervisor.gender;
supervisor.pic = req.body.pic || supervisor.pic;
supervisor.address = req.body.address || supervisor.address;
supervisor.postalCode = req.body.postalCode || supervisor.postalCode;
supervisor.country = req.body.country || supervisor.country;
supervisor.email = req.body.email || supervisor.email;
supervisor.phone = req.body.phone || supervisor.phone;
supervisor.lang = req.body.lang || supervisor.lang;
supervisor.ttsEngine = req.body.ttsEngine || supervisor.ttsEngine;
supervisor.office = req.body.office || supervisor.office;
supervisor.save(function (error) {
if (error) {
res.serverError();
} else {
res.ok(supervisor);
}
});
} else {
res.notFound();
}
if (!supervisor)
return res.notFound();
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.surname = req.body.surname || supervisor.surname;
supervisor.gender = req.body.gender || supervisor.gender;
supervisor.pic = req.body.pic || supervisor.pic;
supervisor.address = req.body.address || supervisor.address;
supervisor.postalCode = req.body.postalCode || supervisor.postalCode;
supervisor.country = req.body.country || supervisor.country;
supervisor.email = req.body.email || supervisor.email;
supervisor.phone = req.body.phone || supervisor.phone;
supervisor.lang = req.body.lang || supervisor.lang;
supervisor.ttsEngine = req.body.ttsEngine || supervisor.ttsEngine;
supervisor.office = req.body.office || supervisor.office;
supervisor.save(function (error) {
if (error) throw error;
return res.ok(supervisor);
});
})
.catch(function () {
res.serverError();
.catch(function (err) {
return res.serverError(err);
});
},
......@@ -742,9 +739,13 @@ module.exports = {
delete: function (req, res) {
if (!req.params.id)
return res.badRequest("Missing parameter");
Supervisor.destroy({id: req.params.id})
.then(() => {res.ok()})
.catch((err) => {res.serverError("Could not delete supervisor")});
StuSup.destroy({id_sup: req.params.id})
.then(() => {
Supervisor.destroy({id: req.params.id})
.then(() => {res.ok()})
.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 = {
lang: {
required: true,
type: "string",
size: 2
size: 5
},
contactPerson: {
columnName: "contact_person",
......@@ -88,12 +88,13 @@ module.exports = {
collection: "Student",
via: 'office'
},
toJSON: function() {
var office = this.toObject();
if (!office.logoUrl)
office.logoUrl = '/app/img/logo_pictogram.png';
return office;
}
toJSON: function() {
var office = this.toObject();
if (!office.logoUrl)
office.logoUrl = '/app/img/logo_pictogram.png';
return office;
}
},
beforeCreate: function (attrs, next) {
......
......@@ -74,7 +74,7 @@ module.exports = {
lang: {
required: true,
type: "string",
size: 2
size: 5
},
ttsEngine: {
columnName: 'tts_engine',
......@@ -143,7 +143,7 @@ module.exports = {
//
beforeCreate: function (attrs, next) {
var async = require('async');
console.log("-->\n" + JSON.stringify(attrs));
async.series(
[
function (cb) {
......@@ -190,6 +190,9 @@ module.exports = {
Supervisor.findOne({ email: attrs.email }).then(function (supervisor) {
if (supervisor && supervisor.id !== attrs.id) {
cb(new Error('Email being used'));
} else if (attrs.password && attrs.password.length > 0 && attrs.password == supervisor.password) {
delete attrs.password;
cb();
} else {
cb();
}
......@@ -203,6 +206,8 @@ module.exports = {
var bcrypt = require('bcrypt-nodejs');
if (attrs.password && attrs.password.length > 0) {
attrs.password = bcrypt.hashSync(attrs.password, bcrypt.genSaltSync());
} else {
delete attrs.password;
}
cb();
}
......
......@@ -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
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,
name: '',
surname: '',
address: '',
postal_code: '',
postalCode: '',
country: '00',
phone: '',
gender: 'F',
......@@ -41,7 +41,7 @@ function SignInCtrl($scope,
email: '',
logoUrl: ''
},
office_idx: -1
id_off: -1
};
};
......@@ -92,7 +92,12 @@ function SignInCtrl($scope,
return;
}
if ($scope.formdata.role == 'therapist_nooffice' && $scope.formdata.office.country == '00') {
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') {
ngToast.danger({ content: $translate.instant('country_office_requested') });
return;
}
......@@ -112,10 +117,8 @@ function SignInCtrl($scope,
$scope.showdialog = true;
if ($scope.formdata.office_idx != -1) {
$scope.formdata.id_off = $scope.offices[$scope.formdata.office_idx].id;
delete $scope.formdata.office_idx;
}
if ($scope.formdata.id_off == -1)
delete $scope.formdata.id_off;
if ($scope.formdata.role === 'tutor_nooffice') {
$scope.formdata.office.name = 'no_office';
......
......@@ -223,9 +223,9 @@
<div class="form-group" id="office_selection">
<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 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>
</div>
......
......@@ -697,6 +697,14 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
$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
$scope.showActiveScene();
$scope.loadScenesList();
......
......@@ -235,22 +235,35 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.wsessions[$scope.wsessions.length-1].tries.pop();
$scope.ws.end = new Date();
$http
.post(
config.backend+'/ws/' + $scope.ws.id + '/close',
{
"id_stu": $scope.studentData.id
}
)
.success(function(data, status, headers, config) {
// Empty actual WS and actual try
$scope.ws = {};
$scope.actual_try = {};
})
.error(function(data, status, headers, config) {
$http
.post(config.backend+'/action', {
"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
}
)
.success(function(data, status, headers, config) {
// Empty actual WS and actual try
$scope.ws = {};
$scope.actual_try = {};
})
.error(function(data, status, headers, config) {
});
})
.error(function(data, status, headers, config) {
});
// Cancel the mark of the device connected (with a new session will be connected again)
//$scope.active_device = null;
......
......@@ -56,7 +56,7 @@
<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-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>
......
......@@ -19,6 +19,10 @@ dashboardControllers.controller('TranslateController', function(
var obj = JSON.parse($window.sessionStorage.user);
$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
$scope.changeLanguage = function (langKey) {
......@@ -48,6 +52,11 @@ dashboardControllers.controller('TranslateController', function(
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)
try {
......
......@@ -54,6 +54,7 @@
"eslint-plugin-react": "^5.1.1",
"mocha": "^2.4.5",
"node-inspector": "^0.12.8",
"segfault-handler": "^1.0.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