working on GUI refactorization (vi)

parent 83d95dca
......@@ -31,7 +31,7 @@ android {
debug {
resValue "string", "db_name", "PCB.db"
resValue "bool", "force_db_create", "false"
resValue "bool", "force_db_create", "true"
resValue "bool", "ssl_connect", "false"
resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "20"
......
......@@ -211,7 +211,7 @@ public class Device extends SQLiteOpenHelper {
return user;
}
private Vector<User> recoverStudents(Integer id_sup) throws JSONException{
public Vector<User> recoverStudents(Integer id_sup) throws JSONException{
SQLiteDatabase db = this.getReadableDatabase();
Vector<User> users = new Vector<>();
Cursor cursor = db.query("users_detail", null, null, null, null, null, null, null);
......@@ -290,33 +290,13 @@ public class Device extends SQLiteOpenHelper {
return users;
}
private void updateUser(User user, SQLiteDatabase db) {
db.execSQL("UPDATE users_detail SET " +
"nickname_stu='" + user.get_nickname_stu() + "', " +
"pwd_stu='" + user.get_pwd_stu() + "', " +
"name_stu='" + user.get_name_stu() + "', " +
"surname_stu='" + user.get_surname_stu() + "', " +
"url_img_stu='" + user.get_url_img_stu() + "', " +
"gender_stu='" + user.get_gender_stu() + "', " +
"lang_stu='" + user.get_lang_stu() + "', " +
"attributes_stu='" + user.get_json_attrs() + "', " +
"name_sup='" + user.get_name_sup() + "', " +
"email_sup='" + user.get_email_sup() + "', " +
"pwd_sup='" + user.get_pwd_sup() + "', " +
"surname_sup='" + user.get_surname_sup() + "', " +
"url_img_sup='" + user.get_url_img_sup() + "', " +
"gender_sup='" + user.get_gender_sup() + "', " +
"lang_sup='" + user.get_lang_sup() + "', " +
"tts_engine_sup='" + user.get_tts_engine_sup() + "'" +
" WHERE id_stu=" + user.get_id_stu() + " AND id_sup=" + user.get_id_sup());
}
private void insertUser(User user, SQLiteDatabase db) {
public void insertUser(User user) {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("INSERT INTO users_detail values (" +
user.get_id_stu() + ", " +
"'" + user.get_nickname_stu() + "', " +
"'" + user.get_pwd_stu() + "', " +
"'" + user.get_name_stu() + "', " +
user.get_pwd_stu()==null ? "" : ("'" + user.get_pwd_stu() + "', " +
"'") + user.get_name_stu() + "', " +
"'" + user.get_surname_stu() + "', " +
"'" + user.get_url_img_stu() + "', " +
"'" + user.get_gender_stu() + "', " +
......@@ -332,43 +312,11 @@ public class Device extends SQLiteOpenHelper {
"'" + user.get_lang_sup() + "'," +
"'" + user.get_tts_engine_sup() + "'" +
")");
}
/**
* Set the current set of users, a hashtable with the whole users who have been registered. The hashcode is calculated as {@link User#hashCode()} depicts.
* For each user:
* if the user exists in the db, he/she is updated
* if the user doesn't exits in the db, he/she is included
* Users who are no longer registered are fully deleted from the DB, even the pictos in case of not any more users using the given picto. Nevertheless, the actions are preserved.
* Student and Supervisor profile images are updated from the server
*
* @param users a hashtable with the set of available users. The key of the hashtable is the same User object
* @see User
* @see com.yottacode.pictogram.dao.PCBDBHelper
*/
public void synchronizeUsers(Vector<User> users, iImgDownloaderListener imgListener) throws JSONException {
Vector<User> current_users = getUsers();
Vector<Img> imgs = new Vector<Img>(users.size() * 2);
SQLiteDatabase db = this.getWritableDatabase();
for (User user : users) {
if (current_users.contains(user)) {
updateUser(user, db);
} else
insertUser(user, db);
if (!imgs.contains(user.get_Img_stu())) imgs.add(user.get_Img_stu());
if (!imgs.contains(user.get_Img_sup())) imgs.add(user.get_Img_sup());
}
db.close();
ImgDownloader downloader = new ImgDownloader(this.context, imgListener, ImgDownloader.tsource.remote );
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,imgs);
}
/**
* delete the list of images (students, supervisors, pictograms) which are no longer used
*/
......
......@@ -41,33 +41,15 @@ import java.util.Vector;
public class LoginActivity extends FragmentActivity {
private static final String TAG_ID = "id";
private static final String TAG_NAME = "name";
private static final String TAG_SURNAME = "surname";
private static final String TAG_GENDER = "gender";
private static final String TAG_PIC = "pic";
private static final String TAG_LANG = "lang";
private static final String TAG_ATTRIBUTES = "attributes";
private static final String TAG_SUPERVISION = "supervision";
private int sup_id;
// String constant for logs
private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
//A ProgressDialog object
private ProgressDialog progressDialog;
private String token=null;
private String username = null;
private String password = null;
private choose_student(Vector<User> students) {
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,imgs);
}
private void show_login_failed(int msg) {
protected void show_login_failed(int msg) {
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
builder.setMessage(getString(msg))
......@@ -92,7 +74,8 @@ public class LoginActivity extends FragmentActivity {
Intent pictogramActivity = new Intent(this, PictogramActivity.class);
startActivity(pictogramActivity);
} else{
getIntent().putExtra("sup_id", localUsers.elementAt(0).get_id_sup());
getIntent().putExtra("sup_id", localUsers.elementAt(0).get_id_sup()); //TODO: comprobar, ¿esto no está hecho ya?
setContentView(R.layout.activity_login);
}
} catch (JSONException e) {
e.printStackTrace();
......@@ -121,94 +104,7 @@ public class LoginActivity extends FragmentActivity {
if (offline)
manage_offline_supervisor(intent.getStringExtra("username"), intent.getStringExtra("password"));
else {
// Modo ONLINE
sup_id = getIntent().getExtras().getInt("sup_id");
token = getIntent().getExtras().getString("token");
RestapiWrapper wrapper = new RestapiWrapper(
getApplicationContext().getResources().getString(R.string.server), token);
String operation = "sup/" + sup_id + "/students";
wrapper.ask(operation, new iRestapiListener() {
@Override
public void error(Exception e) {
Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage());
}
@Override
public void preExecute() {
progressDialog = ProgressDialog.show(LoginActivity.this, getString(R.string.userLoadingTxt),
getString(R.string.userLoadingTxt), false, false);
}
@Override
public void result(JSONArray students_supervisors) {
try {
// Saco los pares estudiante-supervisor
final Vector<User> users = new Vector<>(students_supervisors.length());
Vector<Img> imgs = new Vector<>(users.size());
if (students_supervisors.length() == 0)
show_login_failed(R.string.noStudentsError);
User student = null;
for (int i = 0; i < students_supervisors.length(); i++) {
JSONObject st = students_supervisors.getJSONObject(i);
Integer st_id = st.getInt(TAG_ID);
String st_name = st.getString(TAG_NAME);
String st_surname = st.getString(TAG_SURNAME);
String st_pic = st.getString(TAG_PIC);
String st_gender = st.getString(TAG_GENDER);
String st_lang = st.getString(TAG_LANG);
String st_attributes = st.getString(TAG_ATTRIBUTES);
Integer st_supervision = st.getInt(TAG_SUPERVISION);
// Añado un par <student-supervisor>
int st_id_int = st_id.intValue();
student = new User(st_id_int, "", "", st_name, st_surname, st_pic, st_gender, st_lang, st_attributes,
sup_id,
username,
password,
intent.getStringExtra("name"),
intent.getStringExtra("surname"),
intent.getStringExtra("pic"),
intent.getStringExtra("gender"),
intent.getStringExtra("lang"),
"");
users.add(student);
Img img=new Img(st_id,st_pic,Img.STUDENT);
if (!imgs.contains(img)) imgs.add(img); //it's required to download student's images
} //for
ImgDownloader downloader = new ImgDownloader(LoginActivity.this, new iImgDownloaderListener() {
@Override
public void loadComplete() {
progressDialog.dismiss();
if (users.size() > 1)
setContentView(R.layout.activity_login);
}
@Override
public void loadImg(Img image) {
}
}, ImgDownloader.tsource.remote);
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,imgs);
// Si sólo hay 1 estudiante paso a Pictogram
if (users.size() == 1) {
Intent pictogramActivity = new Intent(LoginActivity.this, PictogramActivity.class);
startActivity(pictogramActivity);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void result(JSONObject result) {
}
});
setContentView(R.layout.activity_login);
}
}
@Override
......
......@@ -3,7 +3,6 @@ package com.yottacode.pictogram.gui;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
......@@ -57,7 +56,7 @@ public class SerialActivity extends Activity {
public static final String PREFS_NAME = "MyPrefsFile";
private void manageSupervisorLogin(final String username, final String password, boolean online) {
private void manageSupervisorLogin(final String email, final String password, boolean online) {
final Intent loginActivity = new Intent(SerialActivity.this, LoginActivity.class);
if (online) {
......@@ -66,7 +65,7 @@ public class SerialActivity extends Activity {
final String operation = "sup/login";
Hashtable<String, String> postDataParams = new Hashtable<String, String>();
postDataParams.put("email", username);
postDataParams.put("email", email);
postDataParams.put("password", password);
PCBcontext.getRestapiWrapper().ask(operation, postDataParams, "post", new iRestapiListener() {
......@@ -104,13 +103,14 @@ public class SerialActivity extends Activity {
loginActivity.putExtra("offline", false);
loginActivity.putExtra("sup_id", su_id_int);
loginActivity.putExtra("token", jsonToken);
loginActivity.putExtra("username", username);
loginActivity.putExtra("email", email);
loginActivity.putExtra("password", password);
loginActivity.putExtra("name", user.getString(TAG_NAME));
loginActivity.putExtra("surname", user.getString(TAG_SURNAME));
loginActivity.putExtra("pic", user.getString(TAG_PIC));
loginActivity.putExtra("gender", user.getString(TAG_GENDER));
loginActivity.putExtra("lang", user.getString(TAG_LANG));
Log.i(this.getClass().getCanonicalName(),"FERNANDO arrancando loginActivity");
startActivity(loginActivity);
} catch (JSONException e) {
......@@ -127,7 +127,7 @@ public class SerialActivity extends Activity {
});
} else{
loginActivity.putExtra("offline", true);
loginActivity.putExtra("username", username);
loginActivity.putExtra("username", email);
loginActivity.putExtra("password", password);
startActivity(loginActivity);
}
......@@ -244,10 +244,11 @@ public class SerialActivity extends Activity {
private boolean checkLogin(JSONObject result) {
String error;
try {
error = result.getString("error");
error=result.has("error") ? result.getString("error")
: null;
} catch (JSONException e) {
e.printStackTrace();
error= null;
error=null;
}
if (error!=null){
......
......@@ -2,18 +2,16 @@ package com.yottacode.pictogram.gui;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Vector;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
......@@ -21,81 +19,244 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;
import com.yottacode.net.RestapiWrapper;
import com.yottacode.net.iRestapiListener;
import com.yottacode.pictogram.R;
import com.yottacode.pictogram.dao.LoginException;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.grammar.Vocabulary;
import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.net.iImgDownloaderListener;
import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
* StudentFragmentGrid implements the gridview with the students
* @author Miguel Ángel García Cumbreras
* @version 1.0
* @author Fernando
* @version 1.1
*/
public class StudentFragmentGrid extends Fragment{
// Almaceno los estudiantes, los ids de estudiantes y supervisores
Vector<Integer> students_ids;
/*
String[] students;
Vector<Integer> supervisor_ids;
Map<String, List<String>> map_students = new TreeMap<String, List<String>>();
Map<String, Bitmap> map_supervisor_pictures = new TreeMap<String, Bitmap>();
Vector<Bitmap> imageStudents = new Vector<Bitmap>();
*/
//Boolean modoSupervisor;
// NEW
Map<Integer, Vector<Integer>> ids_stu_sup = new TreeMap<Integer, Vector<Integer>>();
//PCBcontext pcb;
final String TAG_ID = "id";
final String TAG_USERNAME = "username";
final String TAG_NAME = "name";
final String TAG_SURNAME = "surname";
final String TAG_GENDER = "gender";
final String TAG_PIC = "pic";
final String TAG_LANG = "lang";
final String TAG_ATTRIBUTES = "attributes";
final String TAG_SUPERVISED="supervised";
Vector<Integer> idStudents;
String nameStudents[];
Vector<Bitmap> imageStudents;
private JSONArray students;
GridView gridView;
// String constant for logs
private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
//A ProgressDialog object
private ProgressDialog progressDialog;
private void refreshGridView() {
CustomList adapter = new CustomList(getActivity(), nameStudents, imageStudents);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
set_user(pos);
}
});
gridView.invalidateViews();
}
private void set_user(int i) {
Boolean offline = getActivity().getIntent().getBooleanExtra("offline", false);
if (offline) {
User currentUser= null;
try {
currentUser = PCBcontext.getDevice().findUser(idStudents.get(i),getActivity().getIntent().getIntExtra("sup_id", 0));
} catch (JSONException e) {
e.printStackTrace();
Log.e(StudentFragmentGrid.this.getClass().getCanonicalName(), e.getMessage());
}
PCBcontext.set_user(currentUser, null, null);
} else new_user(i);
}
private void new_user(int i) {
JSONObject st = this.students.optJSONObject(i);
Intent intent = getActivity().getIntent();
try {
User new_user = new User(
st.getInt(TAG_ID),
st.getString(TAG_USERNAME),
null,
st.getString(TAG_NAME),
st.getString(TAG_SURNAME),
st.getString(TAG_PIC),
st.getString(TAG_GENDER),
st.getString(TAG_LANG),
st.getString(TAG_ATTRIBUTES),
intent.getIntExtra("sup_id", 0),
intent.getStringExtra("email"),
intent.getStringExtra("password"),
intent.getStringExtra("name"),
intent.getStringExtra("surname"),
intent.getStringExtra("pic"),
intent.getStringExtra("gender"),
intent.getStringExtra("lang"),
"");
PCBcontext.getDevice().insertUser(new_user);
final ProgressDialog progressDialog= ProgressDialog.show(getActivity(), getString(R.string.loadingGrammar),
getString(R.string.userLoadingTxt), false, false);
PCBcontext.set_user(new_user, intent.getStringExtra("token"), new iImgDownloaderListener() {
@Override
public void loadComplete() {
progressDialog.dismiss();
Intent pictogramActivity = new Intent(getActivity(), PictogramActivity.class);
startActivity(pictogramActivity);
}
@Override
public void loadImg(Img image) {
}
});
} catch (JSONException e) {
e.printStackTrace();
Log.e(StudentFragmentGrid.this.getClass().getCanonicalName(), e.getMessage());
}
}
private void create_student_list_online() {
final Vector<Img> imgs = new Vector<>(students.length());
this.nameStudents=new String[students.length()];
this.idStudents=new Vector<>(students.length());
this.imageStudents=new Vector<>(students.length());
for (int i = 0; i < students.length(); i++) {
JSONObject st;
try {
st = students.getJSONObject(i);
if (st.getInt(TAG_SUPERVISED)==0) continue;
Integer st_id = st.getInt(TAG_ID);
String st_name = st.getString(TAG_NAME);
String st_pic = st.getString(TAG_PIC);
nameStudents[i]=st_name;
idStudents.add(st_id);
imgs.add(new Img(st_id,st_pic,Img.STUDENT)); //it's required to download student's images
} catch (JSONException e) {
e.printStackTrace();
Log.e(StudentFragmentGrid.this.getClass().getCanonicalName(), e.getMessage());
}
} //for
final ProgressDialog progressDialog= ProgressDialog.show(getActivity(), getString(R.string.imguserLoadingMsg),
getString(R.string.userLoadingTxt), false, false);
ImgDownloader downloader = new ImgDownloader(getActivity(), new iImgDownloaderListener() {
@Override
public void loadComplete() {
progressDialog.dismiss();
if (students.length() > 1) {
for (int i = 0; i < students.length(); i++)
try {
imageStudents.add(imgs.get(i).get_bitmap(getActivity().getBaseContext()));
} catch (IOException e) {
e.printStackTrace();
Log.e(StudentFragmentGrid.this.getClass().getCanonicalName(),e.getMessage());
}
refreshGridView();
}
else
gridView.setAdapter(null);
}
@Override
public void loadImg(Img image) {
}
}, ImgDownloader.tsource.remote);
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs);
}
private void download_students() {
int sup_id = getActivity().getIntent().getExtras().getInt("sup_id");
String token = getActivity().getIntent().getExtras().getString("token");
RestapiWrapper wrapper = new RestapiWrapper(
getActivity().getApplicationContext().getResources().getString(R.string.server), token);
String operation = "sup/" + sup_id + "/students";
final ProgressDialog progressDialog= ProgressDialog.show(getActivity(), getString(R.string.userLoadingTxt),
getString(R.string.userLoadingTxt), false, false);
wrapper.ask(operation, new iRestapiListener() {
@Override
public void error(Exception e) {
Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage());
}
@Override
public void preExecute() {
}
@Override
public void result(JSONArray students) {
progressDialog.dismiss();
StudentFragmentGrid.this.students=students;
create_student_list_online();
switch (students.length()) {
case 0:
((LoginActivity) getActivity()).show_login_failed(R.string.noStudentsError);
break;
case 1:
new_user(0);
}
}
@Override
public void result(JSONObject result) {
}
});
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
try {
// Cargo los datos de los estudiantes
Vector<User> users = PCBcontext.getDevice().getUsers();
if (users!=null){
Log.d(LOG_TAG, "Cargo " + users.size() + " alumnos");
// Recorro el vector para sacar los nombres de estudiantes y las imágenes
for( int i = 0 ; i < users.size() ; i++ ){
int st_id = users.elementAt(i).get_id_stu();
int su_id = users.elementAt(i).get_id_sup();
if (su_id!=-1){
if (ids_stu_sup.containsKey(st_id)){
// Ya existe ese student. Saco el vector de sups y añado uno más
Vector<Integer> sups = ids_stu_sup.get(st_id);
sups.add(su_id);
ids_stu_sup.put(st_id, sups);
} else{
// No existe ese student. Lo creo con el supervisor
Vector<Integer> sups = new Vector<Integer>();
sups.add(su_id);
ids_stu_sup.put(st_id, sups);
}
}
Intent intent=getActivity().getIntent();
Boolean offline = intent.getBooleanExtra("offline", false);
if (offline) {
Vector<User> users;
try {
users = PCBcontext.getDevice().recoverStudents(intent.getIntExtra("sup_id", 0));
} catch (JSONException e) {
e.printStackTrace();
users=null;
}
int i=0;
this.nameStudents=new String[users.size()];
this.idStudents=new Vector<>(users.size());
this.imageStudents=new Vector<>(users.size());
for (User user: users) {
this.idStudents.add(user.get_id_stu());
this.nameStudents[i++]=user.get_name_stu();
try {
this.imageStudents.add(user.get_bitmap_stu(getActivity().getBaseContext()));
} catch (IOException e) {
e.printStackTrace();
Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage());
}
} else{
// TRATO EL ERROR. COMO ?????
}
} catch (Exception e) {
e.printStackTrace();
}
else
download_students();
}
@Override
......@@ -105,66 +266,7 @@ public class StudentFragmentGrid extends Fragment{
gridView = (GridView)v.findViewById(R.id.gridview);
if (getActivity() == null || gridView == null) return null;
if (!ids_stu_sup.isEmpty()) {
try {
List<String> l_students_name = new ArrayList<String>();
Vector<Bitmap> imageStudents = new Vector<Bitmap>();
int id_sup = PCBcontext.getPcbdb().getCurrentUser().get_id_sup();
students_ids = new Vector<Integer>();
for(Map.Entry<Integer,Vector<Integer>> entry : ids_stu_sup.entrySet()) {
Integer id_stu = entry.getKey();
students_ids.add(id_stu);
User currentUser = PCBcontext.getDevice().findUser(id_stu, id_sup);
String st_name = currentUser.get_name_stu();
Bitmap st_picture = currentUser.get_bitmap_stu(getActivity());
l_students_name.add(st_name);
imageStudents.add(st_picture);
}
String[] students_name = l_students_name.toArray(new String[l_students_name.size()]);
CustomList adapter = new CustomList(getActivity(), students_name, imageStudents);
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
int id_sup = PCBcontext.getPcbdb().getCurrentUser().get_id_sup();
User student = null;
try {
student = PCBcontext.getDevice().findUser(students_ids.elementAt(pos), id_sup);
} catch (JSONException e) {
e.printStackTrace();
}
String jsonToken = PCBcontext.getRestapiWrapper().getToken();
progressDialog = ProgressDialog.show(getActivity(),"Cargando...",
"Cargando datos del alumno seleccionado, espere por favor...", false, false);
PCBcontext.set_user(student, jsonToken, new iImgDownloaderListener() {
@Override
public void loadComplete( ) {
//Vocabulary vocabulary = PCBcontext.getVocabulary();
//Log.d(LOG_TAG, "Vocabulario de tam:" + vocabulary.size());
progressDialog.dismiss();
Intent pictogramActivity = new Intent(getActivity(), PictogramActivity.class);
pictogramActivity.putExtra("isSupervisor",true);
startActivity(pictogramActivity);
}
@Override
public void loadImg(Img image) {
}
});
}
});
} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
gridView.setAdapter(null);
}
return v;
}
}
......@@ -196,6 +196,7 @@ END
CREATE TRIGGER trg_insert_users_detail
INSTEAD OF INSERT ON users_detail
FOR EACH ROW
WHEN NEW.pwd_stu IS NOT NULL
BEGIN
INSERT OR REPLACE INTO student VALUES (NEW.id_stu, NEW.nickname_stu, NEW.pwd_stu, NEW.name_stu, NEW.surname_stu, NEW.url_img_stu, NEW.gender_stu, NEW.lang_stu, NEW.attributes_stu);
INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup);
......@@ -203,6 +204,28 @@ BEGIN
END
;--
CREATE TRIGGER trg_insert_users_detail_nostudentpwd
INSTEAD OF INSERT ON users_detail
FOR EACH ROW
WHEN NEW.pwd_stu IS NULL
BEGIN
UPDATE
student
SET
nickname=NEW.nickname_stu,
name=NEW.name_stu,
surname=NEW.surname_stu,
url_img=NEW.url_img_stu,
gender=NEW.gender_stu,
lang=NEW.lang_stu,
attributes=NEW.attributes_stu
WHERE
id=NEW.id_stu;
INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup);
INSERT INTO users VALUES (NEW.id_stu,NEW.id_sup);
END
;--
CREATE TRIGGER trg_update_users_detail
INSTEAD OF UPDATE ON users_detail
FOR EACH ROW
......
......@@ -22,7 +22,8 @@
<string name="userErrorMsg">The user is not correct. Try again.</string>
<string name="userLoadingTxt">Loading</string>
<string name="userLoadingMsg">Loading students. Please wait.</string>
<string name="noStudentsError">El usuario indicado no tiene alumnos asignados. Asigne estudiantes desde el panel de control</string>
<string name="imguserLoadingMsg">Loading images students. Please wait.</string>
<string name="noStudentsError">User without any student available</string>
<!-- Alert dialogs -->
<string name="exitPictogram">Exit Pictogram</string>
<string name="enterEscapeCode">Type escape code</string>
......
......@@ -23,6 +23,7 @@
<string name="userErrorMsg">El usuario indicado no es correcto. Inténtelo de nuevo.</string>
<string name="userLoadingTxt">Cargando</string>
<string name="userLoadingMsg">Cargando alumnos. Por favor espere.</string>
<string name="imguserLoadingMsg">Cargando imágenes de los alumnos. Por favor espere.</string>
<string name="noStudentsError">El usuario indicado no tiene alumnos asignados. Asigne estudiantes desde el panel de control</string>
<!-- Alert dialogs -->
......@@ -62,3 +63,4 @@
<string name="pictogram_offline">Compruebe si tiene conexión a Internet. </string>
<string name="pictogram_online">Conexón con el servidor establecida. </string>
</resources>
......@@ -23,6 +23,7 @@
<string name="userErrorMsg">El usuario indicado no es correcto. Inténtelo de nuevo.</string>
<string name="userLoadingTxt">Cargando</string>
<string name="userLoadingMsg">Cargando alumnos. Por favor espere.</string>
<string name="imguserLoadingMsg">Cargando imágenes de los alumnos. Por favor espere.</string>
<string name="noStudentsError">El usuario indicado no tiene alumnos asignados. Asigne estudiantes desde el panel de control</string>
<!-- Alert dialogs -->
......
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