Merge latest develop changes
git-svn-id: https://forja.rediris.es/svn/cusl6-swadroid/trunk@278 5bc14d19-1e4b-4ba2-aa50-860af135f48c
|
@ -36,6 +36,8 @@ SWADroid uses [Android DataFrameWork][androiddataframework-library] library deve
|
|||
|
||||
SWADroid uses [ksoap2-android][ksoap2-library] library developed by [Manfred Moser][ksoap2-author] and licensed under [MIT][mit].
|
||||
|
||||
[![Copyright and License](http://www.apache.org/images/feather-small.gif)][apache2]
|
||||
SWADroid uses [ZXing][zxing-library] library developed by [Sean Owen][zxing-author] and licensed under [Apache License 2.0][apache2]
|
||||
|
||||
## Contributing
|
||||
|
||||
|
@ -53,4 +55,7 @@ The Github team has also been kind enough to write up some great [documentation]
|
|||
[ksoap2-author]: https://github.com/mosabua
|
||||
[androiddataframework-library]: http://code.google.com/p/androiddataframework/
|
||||
[androiddataframework-author]: http://www.javielinux.com/quiensoy.php
|
||||
[zxing-library]: http://code.google.com/p/zxing/
|
||||
[zxing-author]: https://github.com/srowen
|
||||
[apache2]: http://www.apache.org/licenses/LICENSE-2.0
|
||||
[apk]: https://play.google.com/store/apps/details?id=es.ugr.swad.swadroid
|
||||
|
|
BIN
SWADroid.apk
|
@ -1,67 +1,163 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="es.ugr.swad.swadroid"
|
||||
android:installLocation="auto" android:versionName="0.7.2" android:versionCode="32">
|
||||
package="es.ugr.swad.swadroid"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="32"
|
||||
android:versionName="0.7.2" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
|
||||
|
||||
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"></uses-sdk>
|
||||
<supports-screens android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:anyDensity="true" android:largeScreens="true" android:xlargeScreens="true"></supports-screens>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher_swadroid">
|
||||
<activity android:name=".SWADMain"
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/ic_launcher_swadroid" android:configChanges="keyboard|keyboardHidden|orientation" android:theme="@android:style/Theme.NoTitleBar">
|
||||
<uses-sdk
|
||||
android:minSdkVersion="7"
|
||||
android:targetSdkVersion="15" >
|
||||
</uses-sdk>
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
android:largeScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:resizeable="true"
|
||||
android:smallScreens="true"
|
||||
android:xlargeScreens="true" >
|
||||
</supports-screens>
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher_swadroid"
|
||||
android:label="@string/app_name" >
|
||||
<activity
|
||||
android:name=".SWADMain"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation"
|
||||
android:icon="@drawable/ic_launcher_swadroid"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.NoTitleBar" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".Preferences"
|
||||
android:label="@string/set_preferences" android:configChanges="keyboard|keyboardHidden|orientation">
|
||||
android:configChanges="keyboard|keyboardHidden|orientation"
|
||||
android:label="@string/set_preferences" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.Login"
|
||||
android:label="@string/loginModuleLabel" android:configChanges="keyboard|keyboardHidden|orientation" android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||
android:configChanges="keyboard|keyboardHidden|orientation"
|
||||
android:label="@string/loginModuleLabel"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
|
||||
</activity>
|
||||
<activity android:name=".modules.Courses" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:label="@string/coursesModuleLabel">
|
||||
<activity android:name=".modules.Courses" android:theme="@android:style/Theme.Dialog"></activity></activity>
|
||||
<activity android:label="@string/notificationsModuleLabel" android:name=".modules.notifications.Notifications" android:theme="@android:style/Theme.NoTitleBar"></activity>
|
||||
<activity android:name=".modules.tests.Tests" android:theme="@android:style/Theme.NoTitleBar" android:label="@string/testsModuleLabel"></activity>
|
||||
<activity android:label="@string/testsModuleLabel" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:name=".modules.tests.TestsQuestionsDownload"></activity>
|
||||
<activity android:name=".modules.tests.TestsConfigDownload" android:label="@string/testsModuleLabel" android:theme="@android:style/Theme.Translucent.NoTitleBar"></activity>
|
||||
<activity android:theme="@android:style/Theme.NoTitleBar" android:label="@string/testsModuleLabel" android:configChanges="orientation" android:name=".modules.tests.TestsMake"></activity>
|
||||
<activity android:theme="@android:style/Theme.Translucent.NoTitleBar" android:name=".modules.Messages" android:label="@string/messagesModuleLabel" android:configChanges="keyboard|keyboardHidden|orientation"></activity>
|
||||
<activity android:name=".modules.notifications.NotificationItem" android:theme="@android:style/Theme.NoTitleBar" android:label="@string/notificationsModuleLabel"></activity>
|
||||
<activity
|
||||
android:name=".modules.attendance.Attendance"
|
||||
android:label="@string/attendanceModuleLabel"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.NoTitleBar" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.attendance.AttendanceConfigDownload"
|
||||
android:label="@string/attendanceModuleLabel"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name="com.google.zxing.client.android.CaptureActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" >
|
||||
<intent-filter>
|
||||
<action android:name="es.ugr.swad.swadroid.android.SCAN" />
|
||||
|
||||
<activity android:theme="@android:style/Theme.Translucent.NoTitleBar" android:name=".modules.Notices" android:label="@string/noticesModuleLabel" android:configChanges="keyboard|keyboardHidden|orientation"></activity>
|
||||
|
||||
<provider android:name=".sync.DummyProvider"
|
||||
android:authorities="es.ugr.swad.content"
|
||||
android:syncable="true"
|
||||
android:label="DummyProvider" />
|
||||
|
||||
<service android:name="es.ugr.swad.swadroid.sync.AccountAuthenticatorService"
|
||||
android:exported="true" android:process=":auth">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.accounts.AccountAuthenticator"
|
||||
android:resource="@xml/authenticator" />
|
||||
</service>
|
||||
|
||||
<service android:name=".modules.notifications.NotificationsSyncAdapterService"
|
||||
android:exported="true" android:process=":notifications">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.SyncAdapter" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.content.SyncAdapter"
|
||||
android:resource="@xml/sync_notifications" />
|
||||
</service>
|
||||
</application>
|
||||
</manifest>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.Courses"
|
||||
android:label="@string/coursesModuleLabel"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
|
||||
<activity
|
||||
android:name=".modules.Courses"
|
||||
android:theme="@android:style/Theme.Dialog" >
|
||||
</activity>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.notifications.Notifications"
|
||||
android:label="@string/notificationsModuleLabel"
|
||||
android:theme="@android:style/Theme.NoTitleBar" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.tests.Tests"
|
||||
android:label="@string/testsModuleLabel"
|
||||
android:theme="@android:style/Theme.NoTitleBar" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.tests.TestsQuestionsDownload"
|
||||
android:label="@string/testsModuleLabel"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.tests.TestsConfigDownload"
|
||||
android:label="@string/testsModuleLabel"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.tests.TestsMake"
|
||||
android:configChanges="orientation"
|
||||
android:label="@string/testsModuleLabel"
|
||||
android:theme="@android:style/Theme.NoTitleBar" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.Messages"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation"
|
||||
android:label="@string/messagesModuleLabel"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.notifications.NotificationItem"
|
||||
android:label="@string/notificationsModuleLabel"
|
||||
android:theme="@android:style/Theme.NoTitleBar" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".modules.Notices"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation"
|
||||
android:label="@string/noticesModuleLabel"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar" >
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name=".sync.DummyProvider"
|
||||
android:authorities="es.ugr.swad.content"
|
||||
android:label="DummyProvider"
|
||||
android:syncable="true" />
|
||||
|
||||
<service
|
||||
android:name="es.ugr.swad.swadroid.sync.AccountAuthenticatorService"
|
||||
android:exported="true"
|
||||
android:process=":auth" >
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.accounts.AccountAuthenticator"
|
||||
android:resource="@xml/authenticator" />
|
||||
</service>
|
||||
<service
|
||||
android:name=".modules.notifications.NotificationsSyncAdapterService"
|
||||
android:exported="true"
|
||||
android:process=":notifications" >
|
||||
<intent-filter>
|
||||
<action android:name="android.content.SyncAdapter" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.content.SyncAdapter"
|
||||
android:resource="@xml/sync_notifications" />
|
||||
</service>
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
SWADroid/libs/core.jar
Normal file
BIN
SWADroid/res/drawable-hdpi/attendance.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
SWADroid/res/drawable-hdpi/users.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
SWADroid/res/drawable-ldpi/attendance.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
SWADroid/res/drawable-ldpi/users.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
SWADroid/res/drawable-mdpi/attendance.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
SWADroid/res/drawable-mdpi/users.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
SWADroid/res/drawable-mdpi/usr_bl.jpg
Normal file
After Width: | Height: | Size: 1.8 KiB |
34
SWADroid/res/layout/list_image_items.xml
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/RelativeLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="8dip" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/check"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginRight="5dip" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TextView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBaseline="@+id/check"
|
||||
android:layout_alignBottom="@+id/check"
|
||||
android:layout_toRightOf="@+id/imageView1"
|
||||
android:layout_marginLeft="5dip"
|
||||
android:text="" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,21 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background">
|
||||
<include layout="@layout/action_bar"/>
|
||||
<Spinner
|
||||
android:background="@color/background"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<include layout="@layout/action_bar" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:prompt="@string/selectCourseTitle"
|
||||
/>
|
||||
android:prompt="@string/selectCourseTitle" />
|
||||
|
||||
<ExpandableListView
|
||||
android:id="@+id/android:list"
|
||||
android:cacheColorHint="@color/background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:id="@+id/android:list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:cacheColorHint="@color/background" >
|
||||
</ExpandableListView>
|
||||
|
||||
|
||||
</LinearLayout>
|
|
@ -1,20 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="functions">
|
||||
<item>Notificaciones</item>
|
||||
<item>Tests</item>
|
||||
</string-array>
|
||||
<string-array name="testMenuItems">
|
||||
<item>Sincronizar preguntas</item>
|
||||
<item>Realizar test</item>
|
||||
</string-array>
|
||||
<string-array name="testAnswerTypesNames">
|
||||
<item>Todos</item><item>Verdadero/Falso</item>
|
||||
<item>Elección única</item>
|
||||
<item>Elección múltiple</item>
|
||||
<item>Texto</item>
|
||||
<item>Nº entero</item>
|
||||
<item>Nº real</item>
|
||||
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
<string-array name="functions">
|
||||
<item>Notificaciones</item>
|
||||
<item>Tests</item>
|
||||
</string-array>
|
||||
<string-array name="testMenuItems">
|
||||
<item>Sincronizar preguntas</item>
|
||||
<item>Realizar test</item>
|
||||
</string-array>
|
||||
<string-array name="testAnswerTypesNames">
|
||||
<item>Todos</item>
|
||||
<item>Verdadero/Falso</item>
|
||||
<item>Elección única</item>
|
||||
<item>Elección múltiple</item>
|
||||
<item>Texto</item>
|
||||
<item>Nº entero</item>
|
||||
<item>Nº real</item>
|
||||
</string-array>
|
||||
<string-array name="attendanceMenuItems">
|
||||
<item>Escanear QRs</item>
|
||||
<item>Modo manual</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
|
@ -40,14 +40,15 @@
|
|||
<string name="notificationsProgressTitle">Notificaciones</string>
|
||||
<string name="notificationsProgressDescription">Obteniendo nuevas notificaciones...</string>
|
||||
<string name="notificationsEmptyListMsg">No se ha descargado ninguna notificación.\n\nPara descargar las
|
||||
notificaciones más recientes pulse el icono de la esquina superior derecha de la pantalla.</string><string name="notificationsDownloadedMsg">Notificaciones descargadas</string>
|
||||
notificaciones más recientes pulse el icono de la esquina superior derecha de la pantalla.</string>
|
||||
<string name="notificationsDownloadedMsg">Notificaciones descargadas</string>
|
||||
<string name="testsDownloadProgressTitle">Tests</string>
|
||||
<string name="testsDownloadProgressDescription">Sincronizando preguntas de test.\n\nDependiendo del número de
|
||||
preguntas a sincronizar, el procesamiento de los datos puede tardar unos minutos.\n\nPor favor, espere...</string>
|
||||
<string name="errorMsgLaunchingActivity">Ha ocurrido un error durante la ejecución de la
|
||||
operación</string><string name="errorMsgWorkaroundEmulator">Mierda. Ese bug del emulador de Android ha vuelto a
|
||||
aparecer. Reintentando...</string>
|
||||
|
||||
operación</string>
|
||||
<string name="errorMsgWorkaroundEmulator">Mierda. Ese bug del emulador de Android ha vuelto a
|
||||
aparecer. Reintentando...</string>
|
||||
<string name="errorMsgNoConnection">No hay conexión</string>
|
||||
<string name="errorCopyMsg_DB">Error copiando base de datos</string>
|
||||
<string name="upgradeMsg_DB">Actualizando base de datos...</string>
|
||||
|
@ -111,7 +112,8 @@
|
|||
<string name="errorTimeoutMsg">Tiempo de espera agotado intentando conectar con el
|
||||
servidor</string>
|
||||
<string name="sendingMessageMsg">Enviando mensaje...</string>
|
||||
<string name="messageSendedMsg">Mensaje enviado</string><string name="messageSendErrorMsg">Error al enviar el mensaje. Compruebe los datos introducidos</string>
|
||||
<string name="messageSendedMsg">Mensaje enviado</string>
|
||||
<string name="messageSendErrorMsg">Error al enviar el mensaje. Compruebe los datos introducidos</string>
|
||||
<string name="message_receivers_title">Destinatarios (separados por comas)</string>
|
||||
<string name="message_subject_title">Asunto</string>
|
||||
<string name="message_body_title">Mensaje</string>
|
||||
|
@ -123,10 +125,20 @@
|
|||
<string name="shareBodyMsg">Estoy usando #SWADroid en mi Android para acceder a la
|
||||
plataforma de teleformación SWAD.\nObtenlo gratis aquí:
|
||||
https://market.android.com/details?id=es.ugr.swad.swadroid</string>
|
||||
<string name="twitterTitle">Twitter</string><string name="facebookTitle">Facebook</string><string name="googlePlusTitle">Google+</string><string name="mailingListTitle">Lista de correo</string><string name="blogTitle">Blog</string><string name="marketTitle">Android Market</string>
|
||||
<string name="twitterTitle">Twitter</string>
|
||||
<string name="facebookTitle">Facebook</string>
|
||||
<string name="googlePlusTitle">Google+</string>
|
||||
<string name="mailingListTitle">Lista de correo</string>
|
||||
<string name="blogTitle">Blog</string>
|
||||
<string name="marketTitle">Android Market</string>
|
||||
<string name="notificationsAlertTitle">Nuevas notificaciones</string>
|
||||
<string name="notificationsAlertMsg">nuevas notificaciones</string>
|
||||
<string name="footMessageMsg">Enviado desde</string>
|
||||
<string name="marksMsg">Pulse sobre la notificación para ver la calificación.</string>
|
||||
<string name="clickToGetCourses">Pulse aquí para conseguir sus asignaturas</string>
|
||||
<string name="attendanceModuleLabel">Pasar lista</string>
|
||||
<string name="users">Usuarios</string>
|
||||
<string name="usersDownloadProgressTitle">Estudiantes</string>
|
||||
<string name="usersDownloadProgressDescription">Sincronizando estudiantes.\n\nDependiendo del número de
|
||||
estudiantes a sincronizar, el procesamiento de los datos puede tardar unos minutos.\n\nPor favor, espere...</string>
|
||||
</resources>
|
|
@ -1,29 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="functions">
|
||||
<item>Notices</item>
|
||||
<item>Tests</item>
|
||||
</string-array>
|
||||
<string-array name="testMenuItems">
|
||||
<item>Syncronize questions</item>
|
||||
<item>Make test</item>
|
||||
</string-array>
|
||||
<string-array name="testAnswerTypes">
|
||||
<item>All</item><item>TF</item>
|
||||
<item>uniqueChoice</item>
|
||||
<item>multipleChoice</item>
|
||||
<item>text</item>
|
||||
<item>int</item>
|
||||
<item>float</item>
|
||||
|
||||
</string-array>
|
||||
<string-array name="testAnswerTypesNames">
|
||||
<item>All</item><item>True/False</item>
|
||||
<item>Unique choice</item>
|
||||
<item>Multiple choice</item>
|
||||
<item>Text</item>
|
||||
<item>Integer</item>
|
||||
<item>Float</item>
|
||||
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
<string-array name="functions">
|
||||
<item>Notices</item>
|
||||
<item>Tests</item>
|
||||
</string-array>
|
||||
<string-array name="testMenuItems">
|
||||
<item>Syncronize questions</item>
|
||||
<item>Make test</item>
|
||||
</string-array>
|
||||
<string-array name="testAnswerTypes">
|
||||
<item>All</item>
|
||||
<item>TF</item>
|
||||
<item>uniqueChoice</item>
|
||||
<item>multipleChoice</item>
|
||||
<item>text</item>
|
||||
<item>int</item>
|
||||
<item>float</item>
|
||||
</string-array>
|
||||
<string-array name="testAnswerTypesNames">
|
||||
<item>All</item>
|
||||
<item>True/False</item>
|
||||
<item>Unique choice</item>
|
||||
<item>Multiple choice</item>
|
||||
<item>Text</item>
|
||||
<item>Integer</item>
|
||||
<item>Float</item>
|
||||
</string-array>
|
||||
<string-array name="attendanceMenuItems">
|
||||
<item>Scan QRs</item>
|
||||
<item>Manual mode</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<resources>
|
||||
<string name="app_name">SWADroid</string>
|
||||
<string name="app_name">SWADroid</string>
|
||||
<string name="serverName_preferences">Server</string>
|
||||
<string name="serverSummary_preferences">Server (without http://)</string>
|
||||
<string name="serverTitle_preferences">Server</string>
|
||||
|
@ -35,21 +35,22 @@
|
|||
<string name="loginTitle_menu">Login</string>
|
||||
<string name="loginProgressTitle">Login</string>
|
||||
<string name="loginProgressDescription">Connecting...</string>
|
||||
<string name="coursesProgressTitle">Courses</string><string name="coursesProgressDescription">Retrieving courses...</string><string name="notificationsProgressTitle">Notifications</string>
|
||||
<string name="coursesProgressTitle">Courses</string>
|
||||
<string name="coursesProgressDescription">Retrieving courses...</string>
|
||||
<string name="notificationsProgressTitle">Notifications</string>
|
||||
<string name="notificationsProgressDescription">Retrieving new notifications...</string>
|
||||
<string name="notificationsEmptyListMsg">Did not download any notification.\n\nTo download most recent
|
||||
notifications click the icon in the upper right of the screen.</string><string name="notificationsDownloadedMsg">Notifications downloaded</string>
|
||||
notifications click the icon in the upper right of the screen.</string>
|
||||
<string name="notificationsDownloadedMsg">Notifications downloaded</string>
|
||||
<string name="testsDownloadProgressTitle">Tests</string>
|
||||
<string name="testsDownloadProgressDescription">Synchronizing test questions.\n\nDepending of the number of
|
||||
questions to synchronize, the data processing can take several minutes.\n\nPlease wait...</string>
|
||||
|
||||
|
||||
<string name="errorMsgLaunchingActivity">An error occurred during the execution of the
|
||||
operation</string>
|
||||
<string name="errorMsgWorkaroundEmulator">Damn. That Android emulator bug appeared again.
|
||||
Retrying...</string>
|
||||
<string name="errorMsgNoConnection">No connection found</string><string name="errorCopyMsg_DB">Error copying database</string>
|
||||
|
||||
<string name="errorMsgNoConnection">No connection found</string>
|
||||
<string name="errorCopyMsg_DB">Error copying database</string>
|
||||
<string name="upgradeMsg_DB">Upgrading database...</string>
|
||||
<string name="loginSuccessfulMsg">Login successful</string>
|
||||
<string name="examAnnouncement">Exam announcement</string>
|
||||
|
@ -98,9 +99,8 @@
|
|||
<string name="firstRunMsg">Before using the application for the first time you
|
||||
must enter the user name and password for SWAD at the setup
|
||||
screen.\n\nYou can access to the setup screen from the application
|
||||
menu anytime.\n\nDo you want to open the configuration screen now?
|
||||
</string><string name="initialDialogTitle">IMPORTANT</string>
|
||||
|
||||
menu anytime.\n\nDo you want to open the configuration screen now?</string>
|
||||
<string name="initialDialogTitle">IMPORTANT</string>
|
||||
<string name="upgradeMsg">Due to changes in the database all test questions
|
||||
data have been deleted.\n\nSorry.</string>
|
||||
<string name="errorBadLoginMsg">Incorrect user or password</string>
|
||||
|
@ -108,33 +108,42 @@
|
|||
<string name="errorConnectionMsg">Error while connecting to server</string>
|
||||
<string name="errorTimeoutMsg">Timeout trying to connect to the server</string>
|
||||
<string name="sendingMessageMsg">Sending message...</string>
|
||||
<string name="messageSendedMsg">Message sended successfully</string><string name="messageSendErrorMsg">Error while sending the message. Check the data in the message fields</string>
|
||||
<string name="messageSendedMsg">Message sended successfully</string>
|
||||
<string name="messageSendErrorMsg">Error while sending the message. Check the data in the message fields</string>
|
||||
<string name="message_receivers_title">Receivers (separated by comma)</string>
|
||||
<string name="message_subject_title">Subject</string>
|
||||
<string name="message_body_title">Message</string>
|
||||
<string name="notice_body_title">Notice</string>
|
||||
<string name="publishingNotice">Publishing notice...</string>
|
||||
<string name="noticePublished">Notice published</string><string name="noticeSendError">Error while publishing the new notice</string>
|
||||
<string name="noticePublished">Notice published</string>
|
||||
<string name="noticeSendError">Error while publishing the new notice</string>
|
||||
<string name="sendMsg">Send</string>
|
||||
<string name="cleanDatabaseMsg">The database has been cleaned</string>
|
||||
<string name="shareBodyMsg">I\'m using #SWADroid in my Android mobile for access to
|
||||
the e-learning platform SWAD.\nGet it for free here:
|
||||
https://market.android.com/details?id=es.ugr.swad.swadroid</string>
|
||||
https://market.android.com/details?id=es.ugr.swad.swadroid</string>
|
||||
<string name="marketURL">market://details?id=es.ugr.swad.swadroid</string>
|
||||
<string name="marketWebURL">http://goo.gl/Wgo1y</string><string name="twitterURL">https://twitter.com/#!/SWADroid</string>
|
||||
<string name="marketWebURL">http://goo.gl/Wgo1y</string>
|
||||
<string name="twitterURL">https://twitter.com/#!/SWADroid</string>
|
||||
<string name="facebookURL">https://www.facebook.com/SWADroid</string>
|
||||
<string name="googlePlusURL">http://goo.gl/kuezQ</string>
|
||||
<string name="mailingListURL">http://goo.gl/3A5iO</string>
|
||||
<string name="blogURL">http://swadroid.wordpress.com</string>
|
||||
<string name="twitterUser">\@SWADroid</string><string name="twitterTitle">Twitter</string>
|
||||
<string name="twitterUser">\@SWADroid</string>
|
||||
<string name="twitterTitle">Twitter</string>
|
||||
<string name="facebookTitle">Facebook</string>
|
||||
<string name="googlePlusTitle">Google+</string>
|
||||
<string name="mailingListTitle">Mailing list</string>
|
||||
<string name="blogTitle">Blog</string><string name="marketTitle">Android Market</string><string name="notificationsAlertTitle">New notifications</string><string name="notificationsAlertMsg">new notifications</string><string name="footMessageMsg">Sended from</string>
|
||||
<string name="blogTitle">Blog</string>
|
||||
<string name="marketTitle">Android Market</string>
|
||||
<string name="notificationsAlertTitle">New notifications</string>
|
||||
<string name="notificationsAlertMsg">new notifications</string>
|
||||
<string name="footMessageMsg">Sended from</string>
|
||||
<string name="marksMsg">Click on the notification to view the mark.</string>
|
||||
<string name="clickToGetCourses">Click here to get your courses</string>
|
||||
|
||||
|
||||
|
||||
|
||||
<string name="attendanceModuleLabel">Rollcall</string>
|
||||
<string name="users">Users</string>
|
||||
<string name="usersDownloadProgressDescription">Synchronizing users.\n\nDepending of the number of
|
||||
users to synchronize, the data processing can take several minutes.\n\nPlease wait...</string>
|
||||
<string name="usersDownloadProgressTitle">Students</string>
|
||||
</resources>
|
|
@ -1,72 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceCategory
|
||||
android:title="@string/user_preferences">
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<PreferenceCategory android:title="@string/user_preferences" >
|
||||
<EditTextPreference
|
||||
android:name="@string/userIDName_preferences"
|
||||
android:hint="@string/userIDSummary_preferences"
|
||||
android:defaultValue=""
|
||||
android:title="@string/userIDTitle_preferences"
|
||||
android:key="userIDPref" />
|
||||
android:name="@string/userIDName_preferences"
|
||||
android:defaultValue=""
|
||||
android:hint="@string/userIDSummary_preferences"
|
||||
android:key="userIDPref"
|
||||
android:title="@string/userIDTitle_preferences" />
|
||||
<EditTextPreference
|
||||
android:name="@string/userPasswordName_preferences"
|
||||
android:hint="@string/userPasswordSummary_preferences"
|
||||
android:defaultValue=""
|
||||
android:title="@string/userPasswordTitle_preferences"
|
||||
android:key="userPasswordPref"
|
||||
android:password="true" />
|
||||
android:name="@string/userPasswordName_preferences"
|
||||
android:defaultValue=""
|
||||
android:hint="@string/userPasswordSummary_preferences"
|
||||
android:key="userPasswordPref"
|
||||
android:password="true"
|
||||
android:title="@string/userPasswordTitle_preferences" />
|
||||
<EditTextPreference
|
||||
android:name="@string/serverName_preferences"
|
||||
android:hint="@string/serverSummary_preferences"
|
||||
android:defaultValue=""
|
||||
android:title="@string/serverTitle_preferences"
|
||||
android:key="serverPref" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:title="@string/about_preferences">
|
||||
<Preference
|
||||
android:summary="@string/marketTitle"
|
||||
android:defaultValue=""
|
||||
android:title="@string/rateTitle_menu"
|
||||
android:key="ratePref" />
|
||||
<Preference
|
||||
android:summary="@string/twitterUser"
|
||||
android:defaultValue=""
|
||||
android:title="@string/twitterTitle"
|
||||
android:key="twitterPref" />
|
||||
<Preference
|
||||
android:summary="@string/facebookURL"
|
||||
android:defaultValue=""
|
||||
android:title="@string/facebookTitle"
|
||||
android:key="facebookPref" />
|
||||
<Preference
|
||||
android:summary="@string/googlePlusURL"
|
||||
android:defaultValue=""
|
||||
android:title="@string/googlePlusTitle"
|
||||
android:key="googlePlusPref" />
|
||||
<Preference
|
||||
android:summary="@string/mailingListURL"
|
||||
android:defaultValue=""
|
||||
android:title="@string/mailingListTitle"
|
||||
android:key="mailingListPref" />
|
||||
<Preference
|
||||
android:summary="@string/blogURL"
|
||||
android:defaultValue=""
|
||||
android:title="@string/blogTitle"
|
||||
android:key="blogPref" />
|
||||
<Preference
|
||||
android:summary="@string/shareBodyMsg"
|
||||
android:defaultValue=""
|
||||
android:title="@string/shareTitle_menu"
|
||||
android:key="sharePref" />
|
||||
<Preference
|
||||
android:hint=""
|
||||
android:defaultValue=""
|
||||
android:title="@string/versionTitle_preferences"
|
||||
android:key="currentVersionPref" />
|
||||
<Preference
|
||||
android:summary="@string/author_preferences"
|
||||
android:defaultValue=""
|
||||
android:title="@string/organization_preferences"/>
|
||||
android:name="@string/serverName_preferences"
|
||||
android:defaultValue=""
|
||||
android:hint="@string/serverSummary_preferences"
|
||||
android:key="serverPref"
|
||||
android:title="@string/serverTitle_preferences" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
<PreferenceCategory android:title="@string/about_preferences" >
|
||||
<Preference
|
||||
android:defaultValue=""
|
||||
android:key="ratePref"
|
||||
android:summary="@string/marketTitle"
|
||||
android:title="@string/rateTitle_menu" />
|
||||
<Preference
|
||||
android:defaultValue=""
|
||||
android:key="twitterPref"
|
||||
android:summary="@string/twitterUser"
|
||||
android:title="@string/twitterTitle" />
|
||||
<Preference
|
||||
android:defaultValue=""
|
||||
android:key="facebookPref"
|
||||
android:summary="@string/facebookURL"
|
||||
android:title="@string/facebookTitle" />
|
||||
<Preference
|
||||
android:defaultValue=""
|
||||
android:key="googlePlusPref"
|
||||
android:summary="@string/googlePlusURL"
|
||||
android:title="@string/googlePlusTitle" />
|
||||
<Preference
|
||||
android:defaultValue=""
|
||||
android:key="mailingListPref"
|
||||
android:summary="@string/mailingListURL"
|
||||
android:title="@string/mailingListTitle" />
|
||||
<Preference
|
||||
android:defaultValue=""
|
||||
android:key="blogPref"
|
||||
android:summary="@string/blogURL"
|
||||
android:title="@string/blogTitle" />
|
||||
<Preference
|
||||
android:defaultValue=""
|
||||
android:key="sharePref"
|
||||
android:summary="@string/shareBodyMsg"
|
||||
android:title="@string/shareTitle_menu" />
|
||||
<Preference
|
||||
android:defaultValue=""
|
||||
android:hint=""
|
||||
android:key="currentVersionPref"
|
||||
android:title="@string/versionTitle_preferences" />
|
||||
<Preference
|
||||
android:defaultValue=""
|
||||
android:summary="@string/author_preferences"
|
||||
android:title="@string/organization_preferences" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -1,65 +1,257 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<database name="swadroid_db" version="9">
|
||||
<table name="courses" to-string="%name%">
|
||||
<field name="id" obligatory="true" type="long"/>
|
||||
<field name="name" obligatory="true" type="text"/>
|
||||
<field name="userRole" obligatory="true" type="integer" new-in-version="9"/>
|
||||
</table>
|
||||
|
||||
<table name="notifications" to-string="%name%" new-in-version="3">
|
||||
<field name="id" obligatory="true" type="long"/>
|
||||
<field name="eventType" obligatory="true" type="text"/>
|
||||
<field name="eventTime" obligatory="true" type="text"/>
|
||||
<field name="userSurname1" obligatory="true" type="text"/>
|
||||
<field name="userSurname2" obligatory="true" type="text"/>
|
||||
<field name="userFirstname" obligatory="true" type="text"/>
|
||||
<field name="location" obligatory="true" type="text"/>
|
||||
<field name="summary" obligatory="true" type="text"/>
|
||||
<field name="status" obligatory="true" type="text" new-in-version="4"/>
|
||||
<field name="content" obligatory="true" type="text" new-in-version="5"/>
|
||||
</table>
|
||||
|
||||
<table name="tst_config" to-string="%name%" new-in-version="6">
|
||||
<field name="id" obligatory="true" type="long"/>
|
||||
<field name="min" obligatory="true" type="integer"/>
|
||||
<field name="def" obligatory="true" type="integer"/>
|
||||
<field name="max" obligatory="true" type="integer"/>
|
||||
<field name="feedback" obligatory="true" type="text"/>
|
||||
<field name="editTime" obligatory="true" type="text" new-in-version="7"/>
|
||||
</table>
|
||||
|
||||
<table name="tst_questions" to-string="%name%" new-in-version="6">
|
||||
<field name="id" obligatory="true" type="long"/>
|
||||
<field name="ansType" obligatory="true" type="text"/>
|
||||
<field name="shuffle" obligatory="true" type="text"/>
|
||||
<field name="stem" obligatory="true" type="text"/>
|
||||
</table>
|
||||
|
||||
<table name="tst_answers" to-string="%name%" new-in-version="6">
|
||||
<field name="ansInd" obligatory="true" type="integer" new-in-version="8"/>
|
||||
<field name="answer" obligatory="true" type="text"/>
|
||||
<field name="correct" obligatory="true" type="text"/>
|
||||
</table>
|
||||
|
||||
<table name="tst_tags" to-string="%name%" new-in-version="6">
|
||||
<field name="id" obligatory="true" type="long"/>
|
||||
<field name="tagTxt" obligatory="true" type="text"/>
|
||||
</table>
|
||||
|
||||
<table name="tst_question_tags" to-string="%name%" new-in-version="6">
|
||||
<field name="qstCod" obligatory="true" type="foreign-key" foreign-table="tst_questions"/>
|
||||
<field name="tagCod" obligatory="true" type="foreign-key" foreign-table="tst_tags"/>
|
||||
<field name="tagInd" type="integer"/>
|
||||
</table>
|
||||
|
||||
<table name="tst_questions_course" to-string="%name%" new-in-version="6">
|
||||
<field name="qstCod" obligatory="true" type="foreign-key" foreign-table="tst_questions"/>
|
||||
<field name="crsCod" obligatory="true" type="foreign-key" foreign-table="courses"/>
|
||||
</table>
|
||||
|
||||
<table name="tst_question_answers" to-string="%name%" new-in-version="6">
|
||||
<field name="qstCod" obligatory="true" type="foreign-key" foreign-table="tst_questions"/>
|
||||
<field name="ansCod" obligatory="true" type="foreign-key" foreign-table="tst_answers"/>
|
||||
</table>
|
||||
|
||||
<database
|
||||
name="swadroid_db"
|
||||
version="10" >
|
||||
|
||||
<table
|
||||
name="courses"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="id"
|
||||
obligatory="true"
|
||||
type="long" />
|
||||
<field
|
||||
name="name"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="userRole"
|
||||
new-in-version="9"
|
||||
obligatory="true"
|
||||
type="integer" />
|
||||
</table>
|
||||
<table
|
||||
name="notifications"
|
||||
new-in-version="3"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="id"
|
||||
obligatory="true"
|
||||
type="long" />
|
||||
<field
|
||||
name="eventType"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="eventTime"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="userSurname1"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="userSurname2"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="userFirstname"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="location"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="summary"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="status"
|
||||
new-in-version="4"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="content"
|
||||
new-in-version="5"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
</table>
|
||||
<table
|
||||
name="tst_config"
|
||||
new-in-version="6"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="id"
|
||||
obligatory="true"
|
||||
type="long" />
|
||||
<field
|
||||
name="min"
|
||||
obligatory="true"
|
||||
type="integer" />
|
||||
<field
|
||||
name="def"
|
||||
obligatory="true"
|
||||
type="integer" />
|
||||
<field
|
||||
name="max"
|
||||
obligatory="true"
|
||||
type="integer" />
|
||||
<field
|
||||
name="feedback"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="editTime"
|
||||
new-in-version="7"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
</table>
|
||||
<table
|
||||
name="tst_questions"
|
||||
new-in-version="6"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="id"
|
||||
obligatory="true"
|
||||
type="long" />
|
||||
<field
|
||||
name="ansType"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="shuffle"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="stem"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
</table>
|
||||
<table
|
||||
name="tst_answers"
|
||||
new-in-version="6"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="ansInd"
|
||||
new-in-version="8"
|
||||
obligatory="true"
|
||||
type="integer" />
|
||||
<field
|
||||
name="answer"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="correct"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
</table>
|
||||
<table
|
||||
name="tst_tags"
|
||||
new-in-version="6"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="id"
|
||||
obligatory="true"
|
||||
type="long" />
|
||||
<field
|
||||
name="tagTxt"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
</table>
|
||||
<table
|
||||
name="tst_question_tags"
|
||||
new-in-version="6"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="qstCod"
|
||||
foreign-table="tst_questions"
|
||||
obligatory="true"
|
||||
type="foreign-key" />
|
||||
<field
|
||||
name="tagCod"
|
||||
foreign-table="tst_tags"
|
||||
obligatory="true"
|
||||
type="foreign-key" />
|
||||
<field
|
||||
name="tagInd"
|
||||
type="integer" />
|
||||
</table>
|
||||
<table
|
||||
name="tst_questions_course"
|
||||
new-in-version="6"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="qstCod"
|
||||
foreign-table="tst_questions"
|
||||
obligatory="true"
|
||||
type="foreign-key" />
|
||||
<field
|
||||
name="crsCod"
|
||||
foreign-table="courses"
|
||||
obligatory="true"
|
||||
type="foreign-key" />
|
||||
</table>
|
||||
<table
|
||||
name="tst_question_answers"
|
||||
new-in-version="6"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="qstCod"
|
||||
foreign-table="tst_questions"
|
||||
obligatory="true"
|
||||
type="foreign-key" />
|
||||
<field
|
||||
name="ansCod"
|
||||
foreign-table="tst_answers"
|
||||
obligatory="true"
|
||||
type="foreign-key" />
|
||||
</table>
|
||||
<table
|
||||
name="users"
|
||||
new-in-version="10"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="userCode"
|
||||
obligatory="true"
|
||||
type="integer" />
|
||||
<field
|
||||
name="userID"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="userNickname"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="userSurname1"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="userSurname2"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="userFirstname"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="photoPath"
|
||||
obligatory="true"
|
||||
type="text" />
|
||||
<field
|
||||
name="userTypeCode"
|
||||
obligatory="true"
|
||||
type="integer" />
|
||||
<field
|
||||
name="userRole"
|
||||
obligatory="true"
|
||||
type="integer" />
|
||||
</table>
|
||||
<table
|
||||
name="users_courses"
|
||||
new-in-version="10"
|
||||
to-string="%name%" >
|
||||
<field
|
||||
name="userCode"
|
||||
foreign-table="users"
|
||||
obligatory="true"
|
||||
type="foreign-key" />
|
||||
<field
|
||||
name="crsCod"
|
||||
foreign-table="courses"
|
||||
obligatory="true"
|
||||
type="foreign-key" />
|
||||
</table>
|
||||
|
||||
</database>
|
|
@ -19,118 +19,152 @@
|
|||
|
||||
package es.ugr.swad.swadroid;
|
||||
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
|
||||
/**
|
||||
* Global data of application.
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class Global {
|
||||
/**
|
||||
* SWAD application key
|
||||
*/
|
||||
private static final String AppKey = "HTC-Desire";
|
||||
private static final String AppKey = "cuerre-aguilerin";
|
||||
/**
|
||||
* Server URL
|
||||
*/
|
||||
private static final String DEFAULT_SERVER = "swad.ugr.es";
|
||||
/**
|
||||
* User logged flag
|
||||
*/
|
||||
private static boolean logged;
|
||||
/**
|
||||
* Time of application's last login
|
||||
*/
|
||||
private static long lastLoginTime;
|
||||
|
||||
/**
|
||||
* Code of the chosen course. All next actions are referred to this course.
|
||||
*/
|
||||
private static long selectedCourseCode = -1;
|
||||
|
||||
/**
|
||||
* Indicates if there are changes on db
|
||||
* */
|
||||
private static boolean preferencesChanged = false;
|
||||
/**
|
||||
* Time to force relogin
|
||||
*/
|
||||
public static final int RELOGIN_TIME = 86400000; //24h
|
||||
/**
|
||||
* Request code for Login module.
|
||||
*/
|
||||
public static final int LOGIN_REQUEST_CODE = 1;
|
||||
/**
|
||||
* Request code for Courses module.
|
||||
*/
|
||||
public static final int COURSES_REQUEST_CODE = 2;
|
||||
/**
|
||||
* Request code for Notifications module.
|
||||
*/
|
||||
public static final int NOTIFICATIONS_REQUEST_CODE = 3;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int TESTS_REQUEST_CODE = 4;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int TESTS_CONFIG_DOWNLOAD_REQUEST_CODE = 5;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int TESTS_QUESTIONS_DOWNLOAD_REQUEST_CODE = 6;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int TESTS_MAKE_REQUEST_CODE = 7;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int MESSAGES_REQUEST_CODE = 8;
|
||||
/**
|
||||
* Request code for Notice module
|
||||
*/
|
||||
public static final int NOTICES_REQUESET_CODE = 9;
|
||||
/**
|
||||
* Prefix tag name for Logcat
|
||||
*/
|
||||
public static final String APP_TAG = "SWADroid";
|
||||
/**
|
||||
* Table name for courses
|
||||
*/
|
||||
public static final String DB_TABLE_COURSES = "courses";
|
||||
/**
|
||||
* Table name for notifications
|
||||
*/
|
||||
public static final String DB_TABLE_NOTIFICATIONS = "notifications";
|
||||
/**
|
||||
* Table name for test's answers
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_ANSWERS = "tst_answers";
|
||||
/**
|
||||
* Table name for test's questions
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_QUESTIONS = "tst_questions";
|
||||
/**
|
||||
* Table name for test's tags
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_TAGS = "tst_tags";
|
||||
/**
|
||||
* Table name for test's configuration
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_CONFIG = "tst_config";
|
||||
/**
|
||||
* Table name for relationship between test's questions and tags
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_QUESTION_TAGS = "tst_question_tags";
|
||||
/**
|
||||
* Table name for relationship between test's questions and courses
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_QUESTIONS_COURSE = "tst_questions_course";
|
||||
/**
|
||||
* Table name for relationship between test's questions and answers
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_QUESTION_ANSWERS = "tst_question_answers";
|
||||
|
||||
/**
|
||||
* User logged flag
|
||||
*/
|
||||
private static boolean logged;
|
||||
/**
|
||||
* Logged user
|
||||
*/
|
||||
private static User loggedUser;
|
||||
/**
|
||||
* Time of application's last login
|
||||
*/
|
||||
private static long lastLoginTime;
|
||||
/**
|
||||
* Code of the chosen course. All next actions are referred to this course.
|
||||
*/
|
||||
private static long selectedCourseCode = -1;
|
||||
|
||||
/**
|
||||
* Indicates if there are changes on db
|
||||
* */
|
||||
private static boolean preferencesChanged = false;
|
||||
/**
|
||||
* Time to force relogin
|
||||
*/
|
||||
public static final int RELOGIN_TIME = 86400000; //24h
|
||||
/**
|
||||
* Request code for Login module.
|
||||
*/
|
||||
public static final int LOGIN_REQUEST_CODE = 1;
|
||||
/**
|
||||
* Request code for Courses module.
|
||||
*/
|
||||
public static final int COURSES_REQUEST_CODE = 2;
|
||||
/**
|
||||
* Request code for Notifications module.
|
||||
*/
|
||||
public static final int NOTIFICATIONS_REQUEST_CODE = 3;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int TESTS_REQUEST_CODE = 4;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int TESTS_CONFIG_DOWNLOAD_REQUEST_CODE = 5;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int TESTS_QUESTIONS_DOWNLOAD_REQUEST_CODE = 6;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int TESTS_MAKE_REQUEST_CODE = 7;
|
||||
/**
|
||||
* Request code for Tests module.
|
||||
*/
|
||||
public static final int MESSAGES_REQUEST_CODE = 8;
|
||||
/**
|
||||
* Request code for Notice module
|
||||
*/
|
||||
public static final int NOTICES_REQUESET_CODE = 9;
|
||||
/**
|
||||
* Request code for Attendance module.
|
||||
*/
|
||||
public static final int ATTENDANCE_REQUEST_CODE = 10;
|
||||
/**
|
||||
* Request code for Attendance module.
|
||||
*/
|
||||
public static final int ATTENDANCE_CONFIG_DOWNLOAD_REQUEST_CODE = 11;
|
||||
/**
|
||||
* Request code for Attendance module.
|
||||
*/
|
||||
public static final int SCAN_QR_REQUEST_CODE = 12;
|
||||
/**
|
||||
* Prefix tag name for Logcat
|
||||
*/
|
||||
public static final String APP_TAG = "SWADroid";
|
||||
/**
|
||||
* Table name for courses
|
||||
*/
|
||||
public static final String DB_TABLE_COURSES = "courses";
|
||||
/**
|
||||
* Table name for notifications
|
||||
*/
|
||||
public static final String DB_TABLE_NOTIFICATIONS = "notifications";
|
||||
/**
|
||||
* Table name for test's answers
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_ANSWERS = "tst_answers";
|
||||
/**
|
||||
* Table name for test's questions
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_QUESTIONS = "tst_questions";
|
||||
/**
|
||||
* Table name for test's tags
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_TAGS = "tst_tags";
|
||||
/**
|
||||
* Table name for test's configuration
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_CONFIG = "tst_config";
|
||||
/**
|
||||
* Table name for relationship between test's questions and tags
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_QUESTION_TAGS = "tst_question_tags";
|
||||
/**
|
||||
* Table name for relationship between test's questions and courses
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_QUESTIONS_COURSE = "tst_questions_course";
|
||||
/**
|
||||
* Table name for relationship between test's questions and answers
|
||||
*/
|
||||
public static final String DB_TABLE_TEST_QUESTION_ANSWERS = "tst_question_answers";
|
||||
/**
|
||||
* Table name for users
|
||||
*/
|
||||
public static final String DB_TABLE_USERS = "users";
|
||||
/**
|
||||
* Table name for relationship between users and courses
|
||||
*/
|
||||
public static final String DB_TABLE_USERS_COURSES = "users_courses";
|
||||
/**
|
||||
* Student userTypeCode for getUsers web service.
|
||||
*/
|
||||
public static final int STUDENT_TYPE_CODE = 2;
|
||||
/**
|
||||
* Teacher userTypeCode for getUsers web service.
|
||||
*/
|
||||
public static final int TEACHER_TYPE_CODE = 3;
|
||||
|
||||
/**
|
||||
* Gets the SWAD application key
|
||||
* @return SWAD application key
|
||||
|
@ -159,7 +193,21 @@ public class Global {
|
|||
public static void setLogged(boolean logged) {
|
||||
Global.logged = logged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user logged on SWAD
|
||||
* @param logged User logged flag
|
||||
*/
|
||||
public static User getLoggedUser() {
|
||||
return loggedUser;
|
||||
}
|
||||
/**
|
||||
* Sets the user logged on SWAD
|
||||
* @param logged User logged flag
|
||||
*/
|
||||
public static void setLoggedUser(User loggedUser) {
|
||||
Global.loggedUser = loggedUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets start time of application
|
||||
* @return Start time of application
|
||||
|
@ -182,7 +230,7 @@ public class Global {
|
|||
public static boolean parseIntBool(int n) {
|
||||
return n!=0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to parse from String to Boolean
|
||||
* @param s String to be parsed
|
||||
|
@ -191,7 +239,7 @@ public class Global {
|
|||
public static boolean parseStringBool(String s) {
|
||||
return s.equals("Y") ? true : false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to parse from Boolean to Integer
|
||||
* @param b Boolean to be parsed
|
||||
|
@ -200,9 +248,9 @@ public class Global {
|
|||
public static int parseBoolInt(boolean b) {
|
||||
return b ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
* Function to parse from Boolean to String
|
||||
* @param b Boolean to be parsed
|
||||
* @return "Y" if b==true, "N" in other case
|
||||
|
@ -224,11 +272,11 @@ public class Global {
|
|||
public static void setSelectedCourseCode(long actualCourseCode){
|
||||
if(actualCourseCode >0) selectedCourseCode = actualCourseCode;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isPreferencesChanged(){
|
||||
return preferencesChanged;
|
||||
}
|
||||
|
||||
|
||||
public static void setPreferencesChanged(){
|
||||
preferencesChanged = true;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
package es.ugr.swad.swadroid;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -32,7 +31,6 @@ import android.content.Intent;
|
|||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
|
@ -50,33 +48,35 @@ import es.ugr.swad.swadroid.model.Model;
|
|||
import es.ugr.swad.swadroid.modules.Courses;
|
||||
import es.ugr.swad.swadroid.modules.Messages;
|
||||
import es.ugr.swad.swadroid.modules.Module;
|
||||
import es.ugr.swad.swadroid.modules.Notices;
|
||||
import es.ugr.swad.swadroid.modules.attendance.Attendance;
|
||||
import es.ugr.swad.swadroid.modules.notifications.Notifications;
|
||||
import es.ugr.swad.swadroid.modules.tests.Tests;
|
||||
import es.ugr.swad.swadroid.modules.Notices;
|
||||
import es.ugr.swad.swadroid.ssl.SecureConnection;
|
||||
|
||||
/**
|
||||
* Main class of the application.
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class SWADMain extends MenuExpandableListActivity {
|
||||
/**
|
||||
* Array of strings for main ListView
|
||||
*/
|
||||
protected String[] functions;
|
||||
/**
|
||||
* Function name field
|
||||
*/
|
||||
final String NAME = "listText";
|
||||
/**
|
||||
* Function text field
|
||||
*/
|
||||
final String IMAGE = "listIcon";
|
||||
/**
|
||||
* Code of selected course
|
||||
* */
|
||||
long courseCode;
|
||||
/**
|
||||
/**
|
||||
* Array of strings for main ListView
|
||||
*/
|
||||
protected String[] functions;
|
||||
/**
|
||||
* Function name field
|
||||
*/
|
||||
final String NAME = "listText";
|
||||
/**
|
||||
* Function text field
|
||||
*/
|
||||
final String IMAGE = "listIcon";
|
||||
/**
|
||||
* Code of selected course
|
||||
* */
|
||||
long courseCode;
|
||||
/**
|
||||
* Cursor for database access
|
||||
*/
|
||||
private Cursor dbCursor;
|
||||
|
@ -84,59 +84,60 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
* User courses list
|
||||
*/
|
||||
private List<Model>listCourses;
|
||||
/**
|
||||
* Tests tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " SwadMain";
|
||||
/**
|
||||
* Indicates if it is the first run
|
||||
* */
|
||||
public boolean firstRun = false;
|
||||
|
||||
/**
|
||||
* Actual role 2 - student 3 - teacher -1 - none role was chosen
|
||||
* */
|
||||
public static int actualRole = -1;
|
||||
/**
|
||||
* Gets the database helper
|
||||
/**
|
||||
* Tests tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " SwadMain";
|
||||
/**
|
||||
* Indicates if it is the first run
|
||||
* */
|
||||
public boolean firstRun = false;
|
||||
|
||||
/**
|
||||
* Actual role 2 - student 3 - teacher -1 - none role was chosen
|
||||
* */
|
||||
public static int actualRole = -1;
|
||||
|
||||
/**
|
||||
* Gets the database helper
|
||||
* @return the database helper
|
||||
*/
|
||||
public static DataBaseHelper getDbHelper() {
|
||||
return dbHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows configuration dialog on first run.
|
||||
*/
|
||||
public void showConfigurationDialog() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.initialDialogTitle)
|
||||
.setMessage(R.string.firstRunMsg)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.yesMsg, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
viewPreferences();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.noMsg, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
createSpinnerAdapter();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows initial dialog after application upgrade.
|
||||
*/
|
||||
public void showUpgradeDialog() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.initialDialogTitle)
|
||||
.setMessage(R.string.upgradeMsg)
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(R.string.close_dialog, null)
|
||||
.show();
|
||||
}
|
||||
/**
|
||||
* Shows configuration dialog on first run.
|
||||
*/
|
||||
public void showConfigurationDialog() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.initialDialogTitle)
|
||||
.setMessage(R.string.firstRunMsg)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.yesMsg, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
viewPreferences();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.noMsg, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
dialog.cancel();
|
||||
createSpinnerAdapter();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows initial dialog after application upgrade.
|
||||
*/
|
||||
public void showUpgradeDialog() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.initialDialogTitle)
|
||||
.setMessage(R.string.upgradeMsg)
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(R.string.close_dialog, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.ExpandableListActivity#onChildClick(android.widget.ExpandableListView, android.view.View, int, int, long)
|
||||
|
@ -148,10 +149,9 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
Object o = this.getExpandableListAdapter().getChild(groupPosition, childPosition);
|
||||
@SuppressWarnings("unchecked")
|
||||
String keyword = (String) ((Map<String,Object>)o).get(NAME);
|
||||
|
||||
|
||||
Intent activity;
|
||||
if(keyword.equals(getString(R.string.notificationsModuleLabel)))
|
||||
{
|
||||
if(keyword.equals(getString(R.string.notificationsModuleLabel))) {
|
||||
activity = new Intent(getBaseContext(), Notifications.class);
|
||||
startActivityForResult(activity, Global.NOTIFICATIONS_REQUEST_CODE);
|
||||
} else if(keyword.equals(getString(R.string.testsModuleLabel))) {
|
||||
|
@ -164,223 +164,239 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
} else if(keyword.equals(getString(R.string.noticesModuleLabel))){
|
||||
activity = new Intent(getBaseContext(), Notices.class);
|
||||
startActivityForResult(activity, Global.NOTICES_REQUESET_CODE);
|
||||
} else if(keyword.equals(getString(R.string.attendanceModuleLabel))) {
|
||||
activity = new Intent(getBaseContext(), Attendance.class);
|
||||
startActivityForResult(activity, Global.ATTENDANCE_REQUEST_CODE);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onStart()
|
||||
*/
|
||||
@Override
|
||||
protected void onStart() {
|
||||
|
||||
super.onStart();
|
||||
prefs.getPreferences(getBaseContext());
|
||||
Log.i(TAG, "on start");
|
||||
if(Global.isPreferencesChanged()){
|
||||
getActualCourses();
|
||||
Global.setPreferencesChanged(false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
prefs.getPreferences(getBaseContext());
|
||||
Log.i(TAG, "on start");
|
||||
if(Global.isPreferencesChanged()){
|
||||
getActualCourses();
|
||||
Global.setPreferencesChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create main menu with an expandable list
|
||||
*/
|
||||
private void createStudentMenu()
|
||||
{
|
||||
if(getExpandableListAdapter() == null || actualRole==-1){
|
||||
actualRole = 2;
|
||||
//Construct Expandable List
|
||||
final ArrayList<HashMap<String, Object>> headerData = new ArrayList<HashMap<String, Object>>();
|
||||
|
||||
final HashMap<String, Object> messages = new HashMap<String, Object>();
|
||||
messages.put(NAME, getString(R.string.messages));
|
||||
messages.put(IMAGE, getResources().getDrawable(R.drawable.msg));
|
||||
headerData.add( messages );
|
||||
|
||||
final HashMap<String, Object> evaluation = new HashMap<String, Object>();
|
||||
evaluation.put(NAME, getString(R.string.evaluation));
|
||||
evaluation.put(IMAGE, getResources().getDrawable(R.drawable.grades));
|
||||
headerData.add( evaluation);
|
||||
|
||||
final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>();
|
||||
|
||||
final ArrayList<HashMap<String, Object>> messagesData = new ArrayList<HashMap<String, Object>>();
|
||||
childData.add(messagesData);
|
||||
|
||||
final ArrayList<HashMap<String, Object>> evaluationData = new ArrayList<HashMap<String, Object>>();
|
||||
childData.add(evaluationData);
|
||||
|
||||
//Messages category
|
||||
HashMap<String, Object> map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.notificationsModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.notif));
|
||||
messagesData.add(map);
|
||||
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.messagesModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.msg));
|
||||
messagesData.add(map);
|
||||
|
||||
//Evaluation category
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.testsModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.test));
|
||||
evaluationData.add(map);
|
||||
|
||||
setListAdapter( new ImageExpandableListAdapter(
|
||||
this,
|
||||
headerData,
|
||||
R.layout.image_list_item,
|
||||
new String[] { NAME }, // the name of the field data
|
||||
new int[] { R.id.listText }, // the text field to populate with the field data
|
||||
childData,
|
||||
0,
|
||||
null,
|
||||
new int[] {}
|
||||
));
|
||||
|
||||
getExpandableListView().setOnChildClickListener(this);
|
||||
}else{
|
||||
if(actualRole == 3){
|
||||
((ImageExpandableListAdapter) getExpandableListAdapter()).removeChild(0, 2);
|
||||
actualRole = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create main menu with an expandable list
|
||||
*/
|
||||
private void createTeacherMenu()
|
||||
{
|
||||
//if(getExpandableListAdapter() == null || actualRole==-1){ //first, how to add a new child
|
||||
actualRole = 3;
|
||||
//Construct Expandable List
|
||||
final ArrayList<HashMap<String, Object>> headerData = new ArrayList<HashMap<String, Object>>();
|
||||
|
||||
final HashMap<String, Object> messages = new HashMap<String, Object>();
|
||||
messages.put(NAME, getString(R.string.messages));
|
||||
messages.put(IMAGE, getResources().getDrawable(R.drawable.msg));
|
||||
headerData.add( messages );
|
||||
|
||||
final HashMap<String, Object> evaluation = new HashMap<String, Object>();
|
||||
evaluation.put(NAME, getString(R.string.evaluation));
|
||||
evaluation.put(IMAGE, getResources().getDrawable(R.drawable.grades));
|
||||
headerData.add( evaluation);
|
||||
|
||||
final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>();
|
||||
|
||||
final ArrayList<HashMap<String, Object>> messagesData = new ArrayList<HashMap<String, Object>>();
|
||||
childData.add(messagesData);
|
||||
|
||||
final ArrayList<HashMap<String, Object>> evaluationData = new ArrayList<HashMap<String, Object>>();
|
||||
childData.add(evaluationData);
|
||||
|
||||
//Messages category
|
||||
HashMap<String, Object> map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.notificationsModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.notif));
|
||||
messagesData.add(map);
|
||||
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.messagesModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.msg));
|
||||
messagesData.add(map);
|
||||
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.noticesModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.note));
|
||||
messagesData.add(map);
|
||||
|
||||
//Evaluation category
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.testsModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.test));
|
||||
evaluationData.add(map);
|
||||
setListAdapter( new ImageExpandableListAdapter(
|
||||
this,
|
||||
headerData,
|
||||
R.layout.image_list_item,
|
||||
new String[] { NAME }, // the name of the field data
|
||||
new int[] { R.id.listText }, // the text field to populate with the field data
|
||||
childData,
|
||||
0,
|
||||
null,
|
||||
new int[] {}
|
||||
));
|
||||
|
||||
getExpandableListView().setOnChildClickListener(this);
|
||||
/*}else{
|
||||
* Create main menu with an expandable list
|
||||
*/
|
||||
private void createStudentMenu()
|
||||
{
|
||||
if(getExpandableListAdapter() == null || actualRole==-1){
|
||||
actualRole = 2;
|
||||
//Construct Expandable List
|
||||
final ArrayList<HashMap<String, Object>> headerData = new ArrayList<HashMap<String, Object>>();
|
||||
|
||||
final HashMap<String, Object> messages = new HashMap<String, Object>();
|
||||
messages.put(NAME, getString(R.string.messages));
|
||||
messages.put(IMAGE, getResources().getDrawable(R.drawable.msg));
|
||||
headerData.add( messages );
|
||||
|
||||
final HashMap<String, Object> evaluation = new HashMap<String, Object>();
|
||||
evaluation.put(NAME, getString(R.string.evaluation));
|
||||
evaluation.put(IMAGE, getResources().getDrawable(R.drawable.grades));
|
||||
headerData.add( evaluation);
|
||||
|
||||
final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>();
|
||||
|
||||
final ArrayList<HashMap<String, Object>> messagesData = new ArrayList<HashMap<String, Object>>();
|
||||
childData.add(messagesData);
|
||||
|
||||
final ArrayList<HashMap<String, Object>> evaluationData = new ArrayList<HashMap<String, Object>>();
|
||||
childData.add(evaluationData);
|
||||
|
||||
//Messages category
|
||||
HashMap<String, Object> map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.notificationsModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.notif));
|
||||
messagesData.add(map);
|
||||
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.messagesModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.msg));
|
||||
messagesData.add(map);
|
||||
|
||||
//Evaluation category
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.testsModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.test));
|
||||
evaluationData.add(map);
|
||||
|
||||
setListAdapter( new ImageExpandableListAdapter(
|
||||
this,
|
||||
headerData,
|
||||
R.layout.image_list_item,
|
||||
new String[] { NAME }, // the name of the field data
|
||||
new int[] { R.id.listText }, // the text field to populate with the field data
|
||||
childData,
|
||||
0,
|
||||
null,
|
||||
new int[] {}
|
||||
));
|
||||
|
||||
getExpandableListView().setOnChildClickListener(this);
|
||||
}else{
|
||||
if(actualRole == 3){
|
||||
((ImageExpandableListAdapter) getExpandableListAdapter()).removeChild(0, 2);
|
||||
actualRole = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create main menu with an expandable list
|
||||
*/
|
||||
private void createTeacherMenu()
|
||||
{
|
||||
//if(getExpandableListAdapter() == null || actualRole==-1){ //first, how to add a new child
|
||||
actualRole = 3;
|
||||
//Construct Expandable List
|
||||
final ArrayList<HashMap<String, Object>> headerData = new ArrayList<HashMap<String, Object>>();
|
||||
|
||||
final HashMap<String, Object> messages = new HashMap<String, Object>();
|
||||
messages.put(NAME, getString(R.string.messages));
|
||||
messages.put(IMAGE, getResources().getDrawable(R.drawable.msg));
|
||||
headerData.add( messages );
|
||||
|
||||
final HashMap<String, Object> evaluation = new HashMap<String, Object>();
|
||||
evaluation.put(NAME, getString(R.string.evaluation));
|
||||
evaluation.put(IMAGE, getResources().getDrawable(R.drawable.grades));
|
||||
headerData.add( evaluation);
|
||||
|
||||
final HashMap<String, Object> users = new HashMap<String, Object>();
|
||||
users.put(NAME, getString(R.string.users));
|
||||
users.put(IMAGE, getResources().getDrawable(R.drawable.users));
|
||||
headerData.add(users);
|
||||
|
||||
final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>();
|
||||
|
||||
final ArrayList<HashMap<String, Object>> messagesData = new ArrayList<HashMap<String, Object>>();
|
||||
childData.add(messagesData);
|
||||
|
||||
final ArrayList<HashMap<String, Object>> evaluationData = new ArrayList<HashMap<String, Object>>();
|
||||
childData.add(evaluationData);
|
||||
|
||||
final ArrayList<HashMap<String, Object>> attendanceData = new ArrayList<HashMap<String, Object>>();
|
||||
childData.add(attendanceData);
|
||||
|
||||
//Messages category
|
||||
HashMap<String, Object> map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.notificationsModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.notif));
|
||||
messagesData.add(map);
|
||||
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.messagesModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.msg));
|
||||
messagesData.add(map);
|
||||
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.noticesModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.note));
|
||||
messagesData.add(map);
|
||||
|
||||
//Evaluation category
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.testsModuleLabel) );
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.test));
|
||||
evaluationData.add(map);
|
||||
|
||||
//Attendance category
|
||||
map = new HashMap<String,Object>();
|
||||
map.put(NAME, getString(R.string.attendanceModuleLabel));
|
||||
map.put(IMAGE, getResources().getDrawable(R.drawable.attendance));
|
||||
attendanceData.add(map);
|
||||
|
||||
setListAdapter( new ImageExpandableListAdapter(
|
||||
this,
|
||||
headerData,
|
||||
R.layout.image_list_item,
|
||||
new String[] { NAME }, // the name of the field data
|
||||
new int[] { R.id.listText }, // the text field to populate with the field data
|
||||
childData,
|
||||
0,
|
||||
null,
|
||||
new int[] {}
|
||||
));
|
||||
|
||||
getExpandableListView().setOnChildClickListener(this);
|
||||
/*}else{
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onCreate()
|
||||
*/
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
int lastVersion, currentVersion;
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
int lastVersion, currentVersion;
|
||||
ImageView image;
|
||||
TextView text;
|
||||
|
||||
//Initialize screen
|
||||
super.onCreate(icicle);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
image = (ImageView)this.findViewById(R.id.moduleIcon);
|
||||
image.setBackgroundResource(R.drawable.ic_launcher_swadroid);
|
||||
|
||||
text = (TextView)this.findViewById(R.id.moduleName);
|
||||
text.setText(R.string.app_name);
|
||||
|
||||
|
||||
try {
|
||||
//Initialize database
|
||||
/*db = DataFramework.getInstance();
|
||||
//Initialize screen
|
||||
super.onCreate(icicle);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
image = (ImageView)this.findViewById(R.id.moduleIcon);
|
||||
image.setBackgroundResource(R.drawable.ic_launcher_swadroid);
|
||||
|
||||
text = (TextView)this.findViewById(R.id.moduleName);
|
||||
text.setText(R.string.app_name);
|
||||
|
||||
try {
|
||||
//Initialize database
|
||||
/*db = DataFramework.getInstance();
|
||||
db.open(this, this.getPackageName());
|
||||
dbHelper = new DataBaseHelper(db);*/
|
||||
|
||||
//Initialize preferences
|
||||
prefs.getPreferences(getBaseContext());
|
||||
|
||||
//Initialize HTTPS connections
|
||||
SecureConnection.initSecureConnection();
|
||||
|
||||
//Check if this is the first run after an install or upgrade
|
||||
lastVersion = prefs.getLastVersion();
|
||||
currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||
|
||||
//If this is the first run, show configuration dialog
|
||||
if(lastVersion == 0) {
|
||||
showConfigurationDialog();
|
||||
dbHelper.initializeDB();
|
||||
//prefs.upgradeCredentials();
|
||||
prefs.setLastVersion(currentVersion);
|
||||
firstRun = true;
|
||||
|
||||
//If this is an upgrade, show upgrade dialog
|
||||
} else if(lastVersion < currentVersion) {
|
||||
//showUpgradeDialog();
|
||||
dbHelper.upgradeDB(this);
|
||||
//prefs.upgradeCredentials();
|
||||
prefs.setLastVersion(currentVersion);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
error(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if(!firstRun && Module.connectionAvailable(this)){
|
||||
Log.i(TAG, " obtienen asignaturas");
|
||||
Intent activity;
|
||||
activity = new Intent(getBaseContext(), Courses.class );
|
||||
startActivityForResult(activity,Global.COURSES_REQUEST_CODE);
|
||||
}
|
||||
createSpinnerAdapter();
|
||||
}
|
||||
|
||||
@Override
|
||||
//Initialize preferences
|
||||
prefs.getPreferences(getBaseContext());
|
||||
|
||||
//Initialize HTTPS connections
|
||||
SecureConnection.initSecureConnection();
|
||||
|
||||
//Check if this is the first run after an install or upgrade
|
||||
lastVersion = prefs.getLastVersion();
|
||||
currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||
|
||||
//If this is the first run, show configuration dialog
|
||||
if(lastVersion == 0) {
|
||||
showConfigurationDialog();
|
||||
dbHelper.initializeDB();
|
||||
//prefs.upgradeCredentials();
|
||||
prefs.setLastVersion(currentVersion);
|
||||
firstRun = true;
|
||||
|
||||
//If this is an upgrade, show upgrade dialog
|
||||
} else if(lastVersion < currentVersion) {
|
||||
//showUpgradeDialog();
|
||||
dbHelper.upgradeDB(this);
|
||||
//prefs.upgradeCredentials();
|
||||
prefs.setLastVersion(currentVersion);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
error(ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if(!firstRun && Module.connectionAvailable(this)){
|
||||
Log.i(TAG, " obtienen asignaturas");
|
||||
Intent activity;
|
||||
activity = new Intent(getBaseContext(), Courses.class );
|
||||
startActivityForResult(activity,Global.COURSES_REQUEST_CODE);
|
||||
}
|
||||
createSpinnerAdapter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
@ -395,28 +411,28 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
}
|
||||
|
||||
private void createSpinnerAdapter(){
|
||||
Spinner spinner = (Spinner) this.findViewById(R.id.spinner);
|
||||
listCourses = dbHelper.getAllRows(Global.DB_TABLE_COURSES,"","name");
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_COURSES,"","name");
|
||||
startManagingCursor(dbCursor);
|
||||
if(listCourses.size() != 0){
|
||||
SimpleCursorAdapter adapter = new SimpleCursorAdapter (this,
|
||||
Spinner spinner = (Spinner) this.findViewById(R.id.spinner);
|
||||
listCourses = dbHelper.getAllRows(Global.DB_TABLE_COURSES,"","name");
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_COURSES,"","name");
|
||||
startManagingCursor(dbCursor);
|
||||
if(listCourses.size() != 0){
|
||||
SimpleCursorAdapter adapter = new SimpleCursorAdapter (this,
|
||||
android.R.layout.simple_spinner_item,
|
||||
dbCursor,
|
||||
new String[]{"name"},
|
||||
new int[]{android.R.id.text1});
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spinner.setAdapter(adapter);
|
||||
spinner.setOnItemSelectedListener(new onItemSelectedListener());
|
||||
} else {
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, new String[]{getString(R.string.clickToGetCourses)});
|
||||
spinner.setAdapter(adapter);
|
||||
}
|
||||
} else {
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, new String[]{getString(R.string.clickToGetCourses)});
|
||||
spinner.setAdapter(adapter);
|
||||
}
|
||||
spinner.setOnTouchListener(Spinner_OnTouch);
|
||||
|
||||
}
|
||||
|
||||
private class onItemSelectedListener implements OnItemSelectedListener{
|
||||
}
|
||||
|
||||
private class onItemSelectedListener implements OnItemSelectedListener{
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
||||
|
@ -432,36 +448,36 @@ public class SWADMain extends MenuExpandableListActivity {
|
|||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private View.OnTouchListener Spinner_OnTouch = new View.OnTouchListener() {
|
||||
|
||||
}
|
||||
private View.OnTouchListener Spinner_OnTouch = new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
|
||||
if(dbHelper.getAllRows(Global.DB_TABLE_COURSES).size()==0){
|
||||
if(Module.connectionAvailable(getBaseContext()))
|
||||
getActualCourses();
|
||||
//else
|
||||
|
||||
}else{
|
||||
v.performClick();
|
||||
}
|
||||
|
||||
Log.i(TAG, "on touch");
|
||||
|
||||
}
|
||||
return true;
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
|
||||
if(dbHelper.getAllRows(Global.DB_TABLE_COURSES).size()==0){
|
||||
if(Module.connectionAvailable(getBaseContext()))
|
||||
getActualCourses();
|
||||
//else
|
||||
|
||||
}else{
|
||||
v.performClick();
|
||||
}
|
||||
|
||||
Log.i(TAG, "on touch");
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
private void getActualCourses(){
|
||||
Intent activity;
|
||||
activity = new Intent(getBaseContext(), Courses.class );
|
||||
};
|
||||
|
||||
private void getActualCourses(){
|
||||
Intent activity;
|
||||
activity = new Intent(getBaseContext(), Courses.class );
|
||||
Toast.makeText(getBaseContext(), R.string.coursesProgressDescription, Toast.LENGTH_LONG).show();
|
||||
startActivityForResult(activity,Global.COURSES_REQUEST_CODE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -316,11 +316,11 @@ public class Test extends Model {
|
|||
s = buff.toString().trim();
|
||||
|
||||
//Remove accents
|
||||
s = s.replace('á', 'a');
|
||||
s = s.replace('é', 'e');
|
||||
s = s.replace('í', 'i');
|
||||
s = s.replace('ó', 'o');
|
||||
s = s.replace('ú', 'u');
|
||||
s = s.replace('á', 'a');
|
||||
s = s.replace('é', 'e');
|
||||
s = s.replace('í', 'i');
|
||||
s = s.replace('ó', 'o');
|
||||
s = s.replace('ú', 'u');
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -21,267 +21,351 @@ package es.ugr.swad.swadroid.model;
|
|||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.ksoap2.serialization.KvmSerializable;
|
||||
import org.ksoap2.serialization.PropertyInfo;
|
||||
|
||||
/**
|
||||
* User data.
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class User implements KvmSerializable {
|
||||
/**
|
||||
* User code.
|
||||
*/
|
||||
private static String userCode;
|
||||
|
||||
/**
|
||||
* Webservices session key.
|
||||
*/
|
||||
private static String wsKey;
|
||||
/**
|
||||
* User identifier.
|
||||
*/
|
||||
private static String userID;
|
||||
/**
|
||||
* User first surname.
|
||||
*/
|
||||
private static String userSurname1;
|
||||
/**
|
||||
* User last surname.
|
||||
*/
|
||||
private static String userSurname2;
|
||||
/**
|
||||
* User name.
|
||||
*/
|
||||
private static String userFirstName;
|
||||
/**
|
||||
* User role. 1:guest 2: student 3: teacher
|
||||
*/
|
||||
private static int userRole;
|
||||
|
||||
private static PropertyInfo PI_userCode = new PropertyInfo();
|
||||
private static PropertyInfo PI_wsKey = new PropertyInfo();
|
||||
private static PropertyInfo PI_userID = new PropertyInfo();
|
||||
private static PropertyInfo PI_userSurname1 = new PropertyInfo();
|
||||
private static PropertyInfo PI_userSurname2 = new PropertyInfo();
|
||||
private static PropertyInfo PI_userFirstName = new PropertyInfo();
|
||||
private static PropertyInfo PI_userRole = new PropertyInfo();
|
||||
@SuppressWarnings("unused")
|
||||
private static PropertyInfo[] PI_PROP_ARRAY =
|
||||
{
|
||||
PI_userCode,
|
||||
PI_wsKey,
|
||||
PI_userID,
|
||||
PI_userSurname1,
|
||||
PI_userSurname2,
|
||||
PI_userFirstName,
|
||||
PI_userRole
|
||||
};
|
||||
public class User extends Model {
|
||||
/**
|
||||
* Code of user type.
|
||||
*/
|
||||
private int userTypeCode;
|
||||
/**
|
||||
* Webservices session key.
|
||||
*/
|
||||
private String wsKey;
|
||||
/**
|
||||
* User identifier.
|
||||
*/
|
||||
private String userID;
|
||||
/**
|
||||
* User nickname.
|
||||
*/
|
||||
private String userNickname;
|
||||
/**
|
||||
* User first surname.
|
||||
*/
|
||||
private String userSurname1;
|
||||
/**
|
||||
* User last surname.
|
||||
*/
|
||||
private String userSurname2;
|
||||
/**
|
||||
* User name.
|
||||
*/
|
||||
private String userFirstname;
|
||||
/**
|
||||
* Name of the user type.
|
||||
*/
|
||||
private String userTypeName;
|
||||
/**
|
||||
* Full path where user's picture is stored.
|
||||
*/
|
||||
private String photoPath;
|
||||
/**
|
||||
* User role. 1:guest 2: student 3: teacher
|
||||
*/
|
||||
private int userRole;
|
||||
|
||||
/**
|
||||
* Empty constructor.
|
||||
*/
|
||||
public User() {
|
||||
}
|
||||
private static PropertyInfo PI_userTypeCode = new PropertyInfo();
|
||||
private static PropertyInfo PI_wsKey = new PropertyInfo();
|
||||
private static PropertyInfo PI_userID = new PropertyInfo();
|
||||
private static PropertyInfo PI_userNickname = new PropertyInfo();
|
||||
private static PropertyInfo PI_userSurname1 = new PropertyInfo();
|
||||
private static PropertyInfo PI_userSurname2 = new PropertyInfo();
|
||||
private static PropertyInfo PI_userFirstname = new PropertyInfo();
|
||||
private static PropertyInfo PI_userTypeName = new PropertyInfo();
|
||||
private static PropertyInfo PI_photoPath = new PropertyInfo();
|
||||
private static PropertyInfo PI_userRole = new PropertyInfo();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param userCode User code.
|
||||
* @param userTypeCode Code of user type.
|
||||
* @param wsKey Webservices session key.
|
||||
* @param userID User identifier.
|
||||
* @param userSurname1 User first surname.
|
||||
* @param userSurname2 User last surname.
|
||||
* @param userFirstName User name.
|
||||
* @param userTypeName Name of user type.
|
||||
*/
|
||||
public User(String userCode, String wsKey, String userID, String userSurname1, String userSurname2, String userFirstName, int userRole) {
|
||||
User.userCode = userCode;
|
||||
User.wsKey = wsKey;
|
||||
User.userID = userID;
|
||||
User.userSurname1 = userSurname1;
|
||||
User.userSurname2 = userSurname2;
|
||||
User.userFirstName = userFirstName;
|
||||
User.userRole = userRole;
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
private static PropertyInfo[] PI_PROP_ARRAY = {
|
||||
PI_userTypeCode,
|
||||
PI_wsKey,
|
||||
PI_userID,
|
||||
PI_userNickname,
|
||||
PI_userSurname1,
|
||||
PI_userSurname2,
|
||||
PI_userFirstname,
|
||||
PI_userTypeName,
|
||||
PI_photoPath,
|
||||
PI_userRole
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets user code.
|
||||
* @return User code.
|
||||
*/
|
||||
public static String getUserCode() {
|
||||
return userCode;
|
||||
}
|
||||
/**
|
||||
* Constructor.
|
||||
* @param id User code.
|
||||
* @param userTypeCode Code of user type.
|
||||
* @param wsKey Webservices session key.
|
||||
* @param userID User identifier.
|
||||
* @param userNickname User nickname.
|
||||
* @param userSurname1 User first surname.
|
||||
* @param userSurname2 User last surname.
|
||||
* @param userFirstname User name.
|
||||
* @param userTypeName Name of user type.
|
||||
* @param photoPath Full path where user's picture is stored.
|
||||
* @param userRole User role.
|
||||
*/
|
||||
public User(long id, int userTypeCode, String wsKey, String userID, String userNickname, String userSurname1,
|
||||
String userSurname2, String userFirstname, String userTypeName, String photoPath, int userRole) {
|
||||
super(id);
|
||||
this.userTypeCode = userTypeCode;
|
||||
this.wsKey = wsKey;
|
||||
this.userID = userID;
|
||||
this.userNickname = userNickname;
|
||||
this.userSurname1 = userSurname1;
|
||||
this.userSurname2 = userSurname2;
|
||||
this.userFirstname = userFirstname;
|
||||
this.userTypeName = userTypeName;
|
||||
this.photoPath = photoPath;
|
||||
this.userRole = userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user code.
|
||||
* @param userCode user code.
|
||||
*/
|
||||
public static void setUserCode(String userCode) {
|
||||
User.userCode = userCode;
|
||||
}
|
||||
/**
|
||||
* Gets user name.
|
||||
* @return User name.
|
||||
*/
|
||||
public String getUserFirstname() {
|
||||
return userFirstname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user name.
|
||||
* @return User name.
|
||||
*/
|
||||
public static String getUserFirstName() {
|
||||
return userFirstName;
|
||||
}
|
||||
/**
|
||||
* Sets user name.
|
||||
* @param userFirstname User name.
|
||||
*/
|
||||
public void setUserFirstname(String userFirstname) {
|
||||
this.userFirstname = userFirstname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user name.
|
||||
* @param userFirstName User name.
|
||||
*/
|
||||
public static void setUserFirstName(String userFirstName) {
|
||||
User.userFirstName = userFirstName;
|
||||
}
|
||||
/**
|
||||
* Gets user identifier.
|
||||
* @return User identifier.
|
||||
*/
|
||||
public String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user identifier.
|
||||
* @return User identifier.
|
||||
*/
|
||||
public static String getUserID() {
|
||||
return userID;
|
||||
}
|
||||
/**
|
||||
* Sets user identifier.
|
||||
* @param userID User identifier.
|
||||
*/
|
||||
public void setUserID(String userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user identifier.
|
||||
* @param userID User identifier.
|
||||
*/
|
||||
public static void setUserID(String userID) {
|
||||
User.userID = userID;
|
||||
}
|
||||
/**
|
||||
* Gets user nickname.
|
||||
* @return User nickname.
|
||||
*/
|
||||
public String getUserNickname() {
|
||||
return userNickname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user first surname.
|
||||
* @return User first surname.
|
||||
*/
|
||||
public static String getUserSurname1() {
|
||||
return userSurname1;
|
||||
}
|
||||
/**
|
||||
* Sets user nickname.
|
||||
* @param userNickname User nickname.
|
||||
*/
|
||||
public void setUserNickname(String userNickname) {
|
||||
this.userID = userNickname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user first surname.
|
||||
* @param userSurname1 User first surname.
|
||||
*/
|
||||
public static void setUserSurname1(String userSurname1) {
|
||||
User.userSurname1 = userSurname1;
|
||||
}
|
||||
/**
|
||||
* Gets user first surname.
|
||||
* @return User first surname.
|
||||
*/
|
||||
public String getUserSurname1() {
|
||||
return userSurname1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user last surname.
|
||||
* @return User last surname.
|
||||
*/
|
||||
public static String getUserSurname2() {
|
||||
return userSurname2;
|
||||
}
|
||||
/**
|
||||
* Sets user first surname.
|
||||
* @param userSurname1 User first surname.
|
||||
*/
|
||||
public void setUserSurname1(String userSurname1) {
|
||||
this.userSurname1 = userSurname1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user last surname.
|
||||
* @param userSurname2 User last surname.
|
||||
*/
|
||||
public static void setUserSurname2(String userSurname2) {
|
||||
User.userSurname2 = userSurname2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Webservices session key.
|
||||
* @return Webservices session key.
|
||||
*/
|
||||
public static String getWsKey() {
|
||||
return wsKey;
|
||||
}
|
||||
/**
|
||||
* Gets user last surname.
|
||||
* @return User last surname.
|
||||
*/
|
||||
public String getUserSurname2() {
|
||||
return userSurname2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Webservices session key.
|
||||
* @param wsKey Webservices session key.
|
||||
*/
|
||||
public static void setWsKey(String wsKey) {
|
||||
User.wsKey = wsKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user role
|
||||
* @return user role 1:guest 2:student 3:teacher
|
||||
* */
|
||||
public static int getUserRole(){
|
||||
return userRole;
|
||||
}
|
||||
/**
|
||||
* Sets user role
|
||||
* @param userRole
|
||||
* */
|
||||
//TODO check userRole is 1,2,3
|
||||
public static void setUserRole(int userRole){
|
||||
User.userRole = userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets user last surname.
|
||||
* @param userSurname2 User last surname.
|
||||
*/
|
||||
public void setUserSurname2(String userSurname2) {
|
||||
this.userSurname2 = userSurname2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Code of user type.
|
||||
* @return Code of user type.
|
||||
*/
|
||||
public int getUserTypeCode() {
|
||||
return userTypeCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Code of user type.
|
||||
* @param userTypeCode Code of user type.
|
||||
*/
|
||||
public void setUserTypeCode(int userTypeCode) {
|
||||
this.userTypeCode = userTypeCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Name of user type.
|
||||
* @return Name of user type.
|
||||
*/
|
||||
public String getUserTypeName() {
|
||||
return userTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Name of user type.
|
||||
* @param userTypeName Name of user type.
|
||||
*/
|
||||
public void setUserTypeName(String userTypeName) {
|
||||
this.userTypeName = userTypeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Full path where user's picture is stored.
|
||||
* @return the photoPath
|
||||
*/
|
||||
public String getPhotoPath() {
|
||||
return photoPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Full path where user's picture is stored.
|
||||
* @param photoPath the photoPath to set
|
||||
*/
|
||||
public void setPhotoPath(String photoPath) {
|
||||
this.photoPath = photoPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets User role.
|
||||
* @return User role.
|
||||
*/
|
||||
public int getUserRole() {
|
||||
return userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets User role.
|
||||
* @param userRole User role.
|
||||
*/
|
||||
//TODO check userRole is 1,2,3
|
||||
public void setUserRole(int userRole) {
|
||||
this.userRole = userRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Webservices session key.
|
||||
* @return Webservices session key.
|
||||
*/
|
||||
public String getWsKey() {
|
||||
return wsKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Webservices session key.
|
||||
* @param wsKey Webservices session key.
|
||||
*/
|
||||
public void setWsKey(String wsKey) {
|
||||
this.wsKey = wsKey;
|
||||
}
|
||||
|
||||
public Object getProperty(int param) {
|
||||
Object object = null;
|
||||
switch(param)
|
||||
{
|
||||
case 0 : object = userCode;break;
|
||||
case 1 : object = wsKey;break;
|
||||
case 2 : object = userID;break;
|
||||
case 3 : object = userSurname1;break;
|
||||
case 4 : object = userSurname2;break;
|
||||
case 5 : object = userFirstName;break;
|
||||
case 6 : object = userRole; break;
|
||||
}
|
||||
|
||||
return object;
|
||||
switch(param)
|
||||
{
|
||||
case 0 : object = userTypeCode; break;
|
||||
case 1 : object = wsKey; break;
|
||||
case 2 : object = userID; break;
|
||||
case 3 : object = userNickname; break;
|
||||
case 4 : object = userSurname1; break;
|
||||
case 5 : object = userSurname2; break;
|
||||
case 6 : object = userFirstname; break;
|
||||
case 7 : object = userTypeName; break;
|
||||
case 8 : object = photoPath; break;
|
||||
case 9 : object = userRole; break;
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
public int getPropertyCount() {
|
||||
return 7;
|
||||
return 10;
|
||||
}
|
||||
|
||||
public void getPropertyInfo(int param, @SuppressWarnings("rawtypes") Hashtable arg1, PropertyInfo propertyInfo) {
|
||||
switch(param){
|
||||
case 0:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userCode";
|
||||
break;
|
||||
case 1:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "wsKey";
|
||||
break;
|
||||
case 2:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userID";
|
||||
break;
|
||||
case 3:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userSurname1";
|
||||
break;
|
||||
case 4:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userSurname2";
|
||||
break;
|
||||
case 5:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userFirstName";
|
||||
break;
|
||||
case 6:
|
||||
propertyInfo.type = PropertyInfo.INTEGER_CLASS;
|
||||
propertyInfo.name = "userRole";
|
||||
break;
|
||||
case 0:
|
||||
propertyInfo.type = PropertyInfo.INTEGER_CLASS;
|
||||
propertyInfo.name = "userTypeCode";
|
||||
break;
|
||||
case 1:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "wsKey";
|
||||
break;
|
||||
case 2:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userID";
|
||||
break;
|
||||
case 3:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userNickname";
|
||||
break;
|
||||
case 4:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userSurname1";
|
||||
break;
|
||||
case 5:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userSurname2";
|
||||
break;
|
||||
case 6:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userFirstname";
|
||||
break;
|
||||
case 7:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "userTypeName";
|
||||
break;
|
||||
case 8:
|
||||
propertyInfo.type = PropertyInfo.STRING_CLASS;
|
||||
propertyInfo.name = "photoPath";
|
||||
break;
|
||||
case 9:
|
||||
propertyInfo.type = PropertyInfo.INTEGER_CLASS;
|
||||
propertyInfo.name = "userRole";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void setProperty(int param, Object obj) {
|
||||
switch(param)
|
||||
{
|
||||
case 0 : userCode = (String)obj; break;
|
||||
case 1 : wsKey = (String)obj; break;
|
||||
case 2 : userID = (String)obj; break;
|
||||
case 3 : userSurname1 = (String)obj; break;
|
||||
case 4 : userSurname2 = (String)obj; break;
|
||||
case 5 : userFirstName = (String)obj; break;
|
||||
case 6 : userRole = (Integer)obj; break;
|
||||
switch(param) {
|
||||
case 0 : userTypeCode = (Integer) obj; break;
|
||||
case 1 : wsKey = (String) obj; break;
|
||||
case 2 : userID = (String) obj; break;
|
||||
case 3 : userNickname = (String) obj; break;
|
||||
case 4 : userSurname1 = (String) obj; break;
|
||||
case 5 : userSurname2 = (String) obj; break;
|
||||
case 6 : userFirstname = (String) obj; break;
|
||||
case 7 : userTypeName = (String) obj; break;
|
||||
case 8 : photoPath = (String) obj; break;
|
||||
case 9 : userRole = (Integer) obj; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -28,58 +28,58 @@ import org.ksoap2.SoapFault;
|
|||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import com.android.dataframework.DataFramework;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.dataframework.DataFramework;
|
||||
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.Course;
|
||||
import es.ugr.swad.swadroid.model.DataBaseHelper;
|
||||
import es.ugr.swad.swadroid.model.Model;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
|
||||
/**
|
||||
* Courses module for get user's courses
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com> *
|
||||
*/
|
||||
public class Courses extends Module {
|
||||
/**
|
||||
* Courses tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Courses";
|
||||
|
||||
@Override
|
||||
protected void runConnection() {
|
||||
super.runConnection();
|
||||
if (!isConnected) {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Courses tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Courses";
|
||||
|
||||
@Override
|
||||
protected void runConnection() {
|
||||
super.runConnection();
|
||||
if (!isConnected) {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onCreate()
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setMETHOD_NAME("getCourses");
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setMETHOD_NAME("getCourses");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onStart()
|
||||
*/
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
runConnection();
|
||||
runConnection();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onActivityResult(int, int, android.content.Intent)
|
||||
*/
|
||||
|
@ -87,8 +87,8 @@ public class Courses extends Module {
|
|||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == Activity.RESULT_CANCELED) {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,95 +96,95 @@ public class Courses extends Module {
|
|||
* @see es.ugr.swad.swadroid.modules.Module#connect()
|
||||
*/
|
||||
@Override
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.coursesProgressDescription);
|
||||
int progressTitle = R.string.coursesProgressTitle;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
}
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.coursesProgressDescription);
|
||||
int progressTitle = R.string.coursesProgressTitle;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#requestService()
|
||||
*/
|
||||
@Override
|
||||
protected void requestService()
|
||||
throws NoSuchAlgorithmException, IOException, XmlPullParserException, SoapFault, IllegalAccessException, InstantiationException {
|
||||
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("wsKey", User.getWsKey());
|
||||
sendRequest(Course.class, false);
|
||||
protected void requestService()
|
||||
throws NoSuchAlgorithmException, IOException, XmlPullParserException, SoapFault, IllegalAccessException, InstantiationException {
|
||||
|
||||
if (result != null) {
|
||||
//Stores courses data returned by webservice response
|
||||
List<Model> coursesDB = dbHelper.getAllRows(Global.DB_TABLE_COURSES);
|
||||
List<Model> coursesSWAD = new ArrayList<Model>();
|
||||
List<Model> newCourses = new ArrayList<Model>();
|
||||
List<Model> obsoleteCourses = new ArrayList<Model>();
|
||||
//List<Model> modifiedCourses = new ArrayList<Model>();
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("wsKey", Global.getLoggedUser().getWsKey());
|
||||
sendRequest(Course.class, false);
|
||||
|
||||
if (result != null) {
|
||||
//Stores courses data returned by webservice response
|
||||
List<Model> coursesDB = dbHelper.getAllRows(Global.DB_TABLE_COURSES);
|
||||
List<Model> coursesSWAD = new ArrayList<Model>();
|
||||
List<Model> newCourses = new ArrayList<Model>();
|
||||
List<Model> obsoleteCourses = new ArrayList<Model>();
|
||||
//List<Model> modifiedCourses = new ArrayList<Model>();
|
||||
Vector<?> res = (Vector<?>) result;
|
||||
SoapObject soap = (SoapObject) res.get(1);
|
||||
int csSize = soap.getPropertyCount();
|
||||
for (int i = 0; i < csSize; i++) {
|
||||
SoapObject pii = (SoapObject)soap.getProperty(i);
|
||||
long id = Long.parseLong(pii.getProperty("courseCode").toString());
|
||||
String name = pii.getProperty("courseName").toString();
|
||||
int userRole = Integer.parseInt(pii.getProperty("userRole").toString());
|
||||
Course c = new Course(id, name, userRole);
|
||||
coursesSWAD.add(c);
|
||||
|
||||
/*if(isDebuggable)
|
||||
SoapObject soap = (SoapObject) res.get(1);
|
||||
int csSize = soap.getPropertyCount();
|
||||
for (int i = 0; i < csSize; i++) {
|
||||
SoapObject pii = (SoapObject)soap.getProperty(i);
|
||||
long id = Long.parseLong(pii.getProperty("courseCode").toString());
|
||||
String name = pii.getProperty("courseName").toString();
|
||||
int userRole = Integer.parseInt(pii.getProperty("userRole").toString());
|
||||
Course c = new Course(id, name, userRole);
|
||||
coursesSWAD.add(c);
|
||||
|
||||
/*if(isDebuggable)
|
||||
Log.d(TAG, c.toString());*/
|
||||
}
|
||||
|
||||
Log.i(TAG, "Retrieved " + csSize + " courses");
|
||||
}
|
||||
|
||||
//Obtain old unregistered courses and modified courses
|
||||
obsoleteCourses.addAll(coursesDB);
|
||||
obsoleteCourses.removeAll(coursesSWAD);
|
||||
|
||||
//Obtain new registered courses
|
||||
newCourses.addAll(coursesSWAD);
|
||||
newCourses.removeAll(coursesDB);
|
||||
//modifiedCourses.addAll(newCourses);
|
||||
newCourses.removeAll(obsoleteCourses);
|
||||
|
||||
//modified courses
|
||||
// modifiedCourses.removeAll(newCourses);
|
||||
|
||||
//Only old unregistered courses
|
||||
//obsoleteCourses.removeAll(modifiedCourses);
|
||||
|
||||
//Delete old unregistered courses stuff
|
||||
csSize = obsoleteCourses.size();
|
||||
for (int i = 0; i < csSize; i++) {
|
||||
Course c = (Course) obsoleteCourses.get(i);
|
||||
dbHelper.removeRow(Global.DB_TABLE_COURSES, c.getId());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Deleted " + csSize + " old courses");
|
||||
|
||||
//Insert new registered courses
|
||||
csSize = newCourses.size();
|
||||
for (int i = 0; i < csSize; i++) {
|
||||
Course c = (Course) newCourses.get(i);
|
||||
dbHelper.insertCourse(c);
|
||||
}
|
||||
Log.i(TAG, "Retrieved " + csSize + " courses");
|
||||
|
||||
Log.i(TAG, "Added " + csSize + " new courses");
|
||||
|
||||
//update modified courses
|
||||
/* csSize = modifiedCourses.size();
|
||||
//Obtain old unregistered courses and modified courses
|
||||
obsoleteCourses.addAll(coursesDB);
|
||||
obsoleteCourses.removeAll(coursesSWAD);
|
||||
|
||||
//Obtain new registered courses
|
||||
newCourses.addAll(coursesSWAD);
|
||||
newCourses.removeAll(coursesDB);
|
||||
//modifiedCourses.addAll(newCourses);
|
||||
newCourses.removeAll(obsoleteCourses);
|
||||
|
||||
//modified courses
|
||||
// modifiedCourses.removeAll(newCourses);
|
||||
|
||||
//Only old unregistered courses
|
||||
//obsoleteCourses.removeAll(modifiedCourses);
|
||||
|
||||
//Delete old unregistered courses stuff
|
||||
csSize = obsoleteCourses.size();
|
||||
for (int i = 0; i < csSize; i++) {
|
||||
Course c = (Course) obsoleteCourses.get(i);
|
||||
dbHelper.removeRow(Global.DB_TABLE_COURSES, c.getId());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Deleted " + csSize + " old courses");
|
||||
|
||||
//Insert new registered courses
|
||||
csSize = newCourses.size();
|
||||
for (int i = 0; i < csSize; i++) {
|
||||
Course c = (Course) newCourses.get(i);
|
||||
dbHelper.insertCourse(c);
|
||||
}
|
||||
|
||||
Log.i(TAG, "Added " + csSize + " new courses");
|
||||
|
||||
//update modified courses
|
||||
/* csSize = modifiedCourses.size();
|
||||
for(int i=0; i < csSize; ++i){
|
||||
Course c = (Course) newCourses.get(i);
|
||||
dbHelper.updateCourse(c.getId(), c);
|
||||
}
|
||||
Log.i(TAG, "Updated " + csSize + " courses");*/
|
||||
|
||||
//Request finalized without errors
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
}
|
||||
|
||||
//Request finalized without errors
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#postConnect()
|
||||
|
@ -193,28 +193,28 @@ public class Courses extends Module {
|
|||
protected void postConnect() {
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onError()
|
||||
*/
|
||||
@Override
|
||||
protected void onError() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes all courses from database
|
||||
* @param context Database context
|
||||
*/
|
||||
public void clearCourses(Context context) {
|
||||
try {
|
||||
DataFramework db = DataFramework.getInstance();
|
||||
try {
|
||||
DataFramework db = DataFramework.getInstance();
|
||||
db.open(context, context.getPackageName());
|
||||
dbHelper = new DataBaseHelper(db);
|
||||
|
||||
dbHelper = new DataBaseHelper(db);
|
||||
|
||||
dbHelper.emptyTable(Global.DB_TABLE_COURSES);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,151 +19,165 @@
|
|||
|
||||
package es.ugr.swad.swadroid.modules;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import es.ugr.swad.swadroid.Base64;
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.ksoap2.SoapFault;
|
||||
import org.ksoap2.serialization.KvmSerializable;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import es.ugr.swad.swadroid.Base64;
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
|
||||
/**
|
||||
* Login module for connect to SWAD.
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class Login extends Module {
|
||||
/**
|
||||
* Digest for user password.
|
||||
*/
|
||||
private MessageDigest md;
|
||||
/**
|
||||
* User password.
|
||||
*/
|
||||
private String userPassword;
|
||||
/**
|
||||
* Login tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Login";
|
||||
/**
|
||||
* Logged user
|
||||
*/
|
||||
private User loggedUser;
|
||||
/**
|
||||
* Digest for user password.
|
||||
*/
|
||||
private MessageDigest md;
|
||||
/**
|
||||
* User password.
|
||||
*/
|
||||
private String userPassword;
|
||||
/**
|
||||
* Login tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Login";
|
||||
|
||||
/* (non-Javadoc)
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onCreate()
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setMETHOD_NAME("loginByUserPasswordKey");
|
||||
}
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setMETHOD_NAME("loginByUserPasswordKey");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/* (non-Javadoc)
|
||||
* @see android.app.Activity#onStart()
|
||||
*/
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
connect();
|
||||
connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Launches action in a separate thread while shows a progress dialog
|
||||
* in UI thread.
|
||||
*/
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.loginProgressDescription);
|
||||
int progressTitle = R.string.loginProgressTitle;
|
||||
Connect con = new Connect(false, progressDescription, progressTitle, true);
|
||||
|
||||
/*if(!Global.isLogged())
|
||||
* Launches action in a separate thread while shows a progress dialog
|
||||
* in UI thread.
|
||||
*/
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.loginProgressDescription);
|
||||
int progressTitle = R.string.loginProgressTitle;
|
||||
Connect con = new Connect(false, progressDescription, progressTitle, true);
|
||||
|
||||
/*if(!Global.isLogged())
|
||||
Toast.makeText(this, progressDescription, Toast.LENGTH_LONG).show();*/
|
||||
|
||||
con.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to SWAD and gets user data.
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
* @throws SoapFault
|
||||
* @throws InstantiationException
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
protected void requestService()
|
||||
throws NoSuchAlgorithmException, IOException, XmlPullParserException, SoapFault, IllegalAccessException, InstantiationException {
|
||||
|
||||
//If last login time > Global.RELOGIN_TIME, force login
|
||||
if(System.currentTimeMillis()-Global.getLastLoginTime() > Global.RELOGIN_TIME) {
|
||||
Global.setLogged(false);
|
||||
}
|
||||
|
||||
//If the application isn't logged, force login
|
||||
if(!Global.isLogged())
|
||||
{
|
||||
//Encrypts user password with SHA-512 and encodes it to Base64UrlSafe
|
||||
md = MessageDigest.getInstance("SHA-512");
|
||||
md.update(prefs.getUserPassword().getBytes());
|
||||
userPassword = new String(Base64.encodeBytes(md.digest()));
|
||||
userPassword = userPassword.replace('+','-').replace('/','_').replace('=', ' ').replaceAll("\\s+", "").trim();
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("userID", prefs.getUserID());
|
||||
addParam("userPassword", userPassword);
|
||||
addParam("appKey", Global.getAppKey());
|
||||
sendRequest(User.class, true);
|
||||
if (result != null) {
|
||||
SoapObject soap = (SoapObject) result;
|
||||
|
||||
//Stores user data returned by webservice response
|
||||
User.setUserCode(soap.getProperty("userCode").toString());
|
||||
User.setWsKey(soap.getProperty("wsKey").toString());
|
||||
User.setUserID(soap.getProperty("userID").toString());
|
||||
User.setUserSurname1(soap.getProperty("userSurname1").toString());
|
||||
User.setUserSurname2(soap.getProperty("userSurname2").toString());
|
||||
User.setUserFirstName(soap.getProperty("userFirstname").toString());
|
||||
int userRole =Integer.parseInt(soap.getProperty("userRole").toString());
|
||||
User.setUserRole(userRole);
|
||||
|
||||
//Update application last login time
|
||||
Global.setLastLoginTime(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
/*if(isDebuggable) {
|
||||
Log.d(TAG, "userCode=" + User.getUserCode());
|
||||
//Log.d(TAG, "userTypeCode=" + User.getUserTypeCode());
|
||||
Log.d(TAG, "wsKey=" + User.getWsKey());
|
||||
Log.d(TAG, "userID=" + User.getUserID());
|
||||
Log.d(TAG, "userSurname1=" + User.getUserSurname1());
|
||||
Log.d(TAG, "userSurname2=" + User.getUserSurname2());
|
||||
Log.d(TAG, "userFirstName=" + User.getUserFirstName());
|
||||
//Log.d(TAG, "userTypeName=" + User.getUserTypeName());
|
||||
Log.d(TAG, "userRole=" + String.valueOf(User.getUserRole()));
|
||||
Log.d(TAG, "lastLoginTime=" + Global.getLastLoginTime());
|
||||
}*/
|
||||
|
||||
//Request finalized without errors
|
||||
setResult(RESULT_OK);
|
||||
con.execute();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* Connects to SWAD and gets user data.
|
||||
* @throws NoSuchAlgorithmException
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
* @throws SoapFault
|
||||
* @throws InstantiationException
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
protected void requestService()
|
||||
throws NoSuchAlgorithmException, IOException, XmlPullParserException, SoapFault, IllegalAccessException, InstantiationException {
|
||||
|
||||
//If last login time > Global.RELOGIN_TIME, force login
|
||||
if(System.currentTimeMillis()-Global.getLastLoginTime() > Global.RELOGIN_TIME) {
|
||||
Global.setLogged(false);
|
||||
}
|
||||
|
||||
//If the application isn't logged, force login
|
||||
if(!Global.isLogged())
|
||||
{
|
||||
//Encrypts user password with SHA-512 and encodes it to Base64UrlSafe
|
||||
md = MessageDigest.getInstance("SHA-512");
|
||||
md.update(prefs.getUserPassword().getBytes());
|
||||
userPassword = new String(Base64.encodeBytes(md.digest()));
|
||||
userPassword = userPassword.replace('+','-').replace('/','_').replace('=', ' ').replaceAll("\\s+", "").trim();
|
||||
Log.i("Login", "pre send login");
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("userID", prefs.getUserID());
|
||||
addParam("userPassword", userPassword);
|
||||
addParam("appKey", Global.getAppKey());
|
||||
sendRequest(User.class, true);
|
||||
Log.i("Login", "sended login");
|
||||
|
||||
if (result != null) {
|
||||
KvmSerializable ks = (KvmSerializable) result;
|
||||
|
||||
//Stores user data returned by webservice response
|
||||
loggedUser = new User(
|
||||
Long.parseLong(ks.getProperty(0).toString()), // id
|
||||
Integer.parseInt(ks.getProperty(1).toString()), // userTypeCode
|
||||
ks.getProperty(2).toString(), // wsKey
|
||||
ks.getProperty(3).toString(), // userID
|
||||
null, // userNickname
|
||||
ks.getProperty(4).toString(), // userSurname1
|
||||
ks.getProperty(5).toString(), // userSurname2
|
||||
ks.getProperty(6).toString(), // userFirstName
|
||||
ks.getProperty(7).toString(), // userTypeName
|
||||
null, // photoPath
|
||||
Integer.parseInt(ks.getProperty(8).toString()) // userRole
|
||||
);
|
||||
|
||||
Global.setLoggedUser(loggedUser);
|
||||
|
||||
//Update application last login time
|
||||
Global.setLastLoginTime(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
/*if(isDebuggable) {
|
||||
Log.d(TAG, "userTypeCode=" + loggedUser.getUserTypeCode());
|
||||
Log.d(TAG, "wsKey=" + loggedUser.getWsKey());
|
||||
Log.d(TAG, "userID=" + loggedUser.getUserID());
|
||||
Log.d(TAG, "userNickname=" + loggedUser.getUserNickname());
|
||||
Log.d(TAG, "userSurname1=" + loggedUser.getUserSurname1());
|
||||
Log.d(TAG, "userSurname2=" + loggedUser.getUserSurname2());
|
||||
Log.d(TAG, "userFirstName=" + loggedUser.getUserFirstname());
|
||||
Log.d(TAG, "userTypeName=" + loggedUser.getUserTypeName());
|
||||
Log.d(TAG, "userRole=" + loggedUser.getUserRole());
|
||||
Log.d(TAG, "lastLoginTime=" + Global.getLastLoginTime());
|
||||
}*/
|
||||
|
||||
//Request finalized without errors
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#postConnect()
|
||||
*/
|
||||
@Override
|
||||
protected void postConnect() {
|
||||
finish();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onError()
|
||||
*/
|
||||
@Override
|
||||
protected void onError() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,6 @@ import org.ksoap2.SoapFault;
|
|||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
@ -38,37 +35,41 @@ import android.widget.Button;
|
|||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.Toast;
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
|
||||
/**
|
||||
* Module for send messages.
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class Messages extends Module {
|
||||
/**
|
||||
* Messages tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Messages";
|
||||
/**
|
||||
* Message code
|
||||
*/
|
||||
private Long notificationCode;
|
||||
/**
|
||||
* Message's receivers
|
||||
*/
|
||||
private String receivers;
|
||||
/**
|
||||
* Names of receivers
|
||||
*/
|
||||
private String receiversNames;
|
||||
/**
|
||||
* Message's subject
|
||||
*/
|
||||
private String subject;
|
||||
/**
|
||||
* Message's body
|
||||
*/
|
||||
private String body;
|
||||
private Dialog messageDialog;
|
||||
/**
|
||||
* Messages tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Messages";
|
||||
/**
|
||||
* Message code
|
||||
*/
|
||||
private Long notificationCode;
|
||||
/**
|
||||
* Message's receivers
|
||||
*/
|
||||
private String receivers;
|
||||
/**
|
||||
* Names of receivers
|
||||
*/
|
||||
private String receiversNames;
|
||||
/**
|
||||
* Message's subject
|
||||
*/
|
||||
private String subject;
|
||||
/**
|
||||
* Message's body
|
||||
*/
|
||||
private String body;
|
||||
private Dialog messageDialog;
|
||||
private OnClickListener positiveClickListener = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
|
@ -78,14 +79,14 @@ public class Messages extends Module {
|
|||
|
||||
runConnection();
|
||||
} catch (Exception ex) {
|
||||
String errorMsg = getString(R.string.errorServerResponseMsg);
|
||||
String errorMsg = getString(R.string.errorServerResponseMsg);
|
||||
error(errorMsg);
|
||||
|
||||
/*if(isDebuggable) {
|
||||
|
||||
/*if(isDebuggable) {
|
||||
Log.e(ex.getClass().getSimpleName(), errorMsg);
|
||||
ex.printStackTrace();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
private OnClickListener negativeClickListener = new OnClickListener() {
|
||||
|
@ -93,14 +94,14 @@ public class Messages extends Module {
|
|||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onCreate(android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setMETHOD_NAME("sendMessage");
|
||||
setMETHOD_NAME("sendMessage");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -111,32 +112,32 @@ public class Messages extends Module {
|
|||
messageDialog = new Dialog(this);
|
||||
Button acceptButton, cancelButton;
|
||||
EditText receiversText, subjectText;
|
||||
|
||||
|
||||
super.onStart();
|
||||
notificationCode = getIntent().getLongExtra("notificationCode", 0);
|
||||
|
||||
messageDialog.setTitle(R.string.messagesModuleLabel);
|
||||
messageDialog.setContentView(R.layout.messages_dialog);
|
||||
messageDialog.setCancelable(true);
|
||||
|
||||
|
||||
messageDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
|
||||
|
||||
acceptButton = (Button) messageDialog.findViewById(R.id.message_button_accept);
|
||||
acceptButton.setOnClickListener(positiveClickListener);
|
||||
|
||||
|
||||
cancelButton = (Button) messageDialog.findViewById(R.id.message_button_cancel);
|
||||
cancelButton.setOnClickListener(negativeClickListener);
|
||||
|
||||
|
||||
if(notificationCode != 0) {
|
||||
subject = getIntent().getStringExtra("summary");
|
||||
|
||||
|
||||
receiversText = (EditText) messageDialog.findViewById(R.id.message_receivers_text);
|
||||
subjectText = (EditText) messageDialog.findViewById(R.id.message_subject_text);
|
||||
|
||||
subjectText.setText("Re: " + subject);
|
||||
receiversText.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
messageDialog.show();
|
||||
}
|
||||
|
||||
|
@ -155,10 +156,10 @@ public class Messages extends Module {
|
|||
private void readData() {
|
||||
EditText rcv = (EditText) messageDialog.findViewById(R.id.message_receivers_text);
|
||||
receivers = rcv.getText().toString();
|
||||
|
||||
|
||||
EditText subj = (EditText) messageDialog.findViewById(R.id.message_subject_text);
|
||||
subject = subj.getText().toString();
|
||||
|
||||
|
||||
EditText bd = (EditText) messageDialog.findViewById(R.id.message_body_text);
|
||||
body = bd.getText().toString();
|
||||
body = body.replaceAll("\n", "<br />");
|
||||
|
@ -167,44 +168,44 @@ public class Messages extends Module {
|
|||
//body = body + "<br /><br />"+ getString(R.string.footMessageMsg) + " <a href=\"" +
|
||||
// getString(R.string.marketWebURL) + "\">" + getString(R.string.app_name) + "</a>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#requestService()
|
||||
*/
|
||||
@Override
|
||||
protected void requestService() throws NoSuchAlgorithmException,
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
readData();
|
||||
|
||||
createRequest();
|
||||
addParam("wsKey", User.getWsKey());
|
||||
addParam("messageCode", notificationCode.intValue());
|
||||
addParam("to", receivers);
|
||||
addParam("subject", subject);
|
||||
addParam("body", body);
|
||||
sendRequest(User.class, false);
|
||||
|
||||
receiversNames = "";
|
||||
if(result != null) {
|
||||
Vector<?> res = (Vector<?>) result;
|
||||
SoapObject soap = (SoapObject) res.get(1);
|
||||
int csSize = soap.getPropertyCount();
|
||||
for (int i = 0; i < csSize; i++) {
|
||||
SoapObject pii = (SoapObject)soap.getProperty(i);
|
||||
String nickname = pii.getProperty("userNickname").toString();
|
||||
String firstname = pii.getProperty("userFirstname").toString();
|
||||
String surname1 = pii.getProperty("userSurname1").toString();
|
||||
String surname2 = pii.getProperty("userSurname2").toString();
|
||||
|
||||
receiversNames += "\n";
|
||||
receiversNames += firstname + " " + surname1 + " " + surname2 + " (" + nickname + ")";
|
||||
}
|
||||
}
|
||||
|
||||
setResult(RESULT_OK);
|
||||
addParam("wsKey", Global.getLoggedUser().getWsKey());
|
||||
addParam("messageCode", notificationCode.intValue());
|
||||
addParam("to", receivers);
|
||||
addParam("subject", subject);
|
||||
addParam("body", body);
|
||||
sendRequest(User.class, false);
|
||||
|
||||
receiversNames = "";
|
||||
if(result != null) {
|
||||
Vector<?> res = (Vector<?>) result;
|
||||
SoapObject soap = (SoapObject) res.get(1);
|
||||
int csSize = soap.getPropertyCount();
|
||||
for (int i = 0; i < csSize; i++) {
|
||||
SoapObject pii = (SoapObject)soap.getProperty(i);
|
||||
String nickname = pii.getProperty("userNickname").toString();
|
||||
String firstname = pii.getProperty("userFirstname").toString();
|
||||
String surname1 = pii.getProperty("userSurname1").toString();
|
||||
String surname2 = pii.getProperty("userSurname2").toString();
|
||||
|
||||
receiversNames += "\n";
|
||||
receiversNames += firstname + " " + surname1 + " " + surname2 + " (" + nickname + ")";
|
||||
}
|
||||
}
|
||||
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -213,10 +214,10 @@ public class Messages extends Module {
|
|||
@Override
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.sendingMessageMsg);
|
||||
int progressTitle = R.string.messagesModuleLabel;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
|
||||
int progressTitle = R.string.messagesModuleLabel;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
|
||||
Toast.makeText(this, R.string.sendingMessageMsg, Toast.LENGTH_SHORT).show();
|
||||
Log.i(TAG, getString(R.string.sendingMessageMsg));
|
||||
}
|
||||
|
@ -227,18 +228,18 @@ public class Messages extends Module {
|
|||
@Override
|
||||
protected void postConnect() {
|
||||
String messageSended = getString(R.string.messageSendedMsg) + ":" + receiversNames;
|
||||
|
||||
|
||||
Toast.makeText(this, messageSended, Toast.LENGTH_LONG).show();
|
||||
Log.i(TAG, messageSended);
|
||||
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onError()
|
||||
*/
|
||||
@Override
|
||||
protected void onError() {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ package es.ugr.swad.swadroid.modules;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
|
||||
import org.ksoap2.SoapFault;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -28,7 +27,6 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
@ -40,42 +38,42 @@ import android.widget.Toast;
|
|||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.Preferences;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.Model;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
|
||||
/**
|
||||
* Module for send messages.
|
||||
* @author Helena Rodriguez Gijon <helena.rodriguez.gijon@gmail.com>
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class Notices extends Module {
|
||||
/**
|
||||
* Messages tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Notice";
|
||||
* Messages tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Notice";
|
||||
|
||||
/**
|
||||
* Notice's body
|
||||
*/
|
||||
private String body;
|
||||
private Dialog noticeDialog;
|
||||
|
||||
/**
|
||||
* Application preferences.
|
||||
*/
|
||||
protected static Preferences prefs = new Preferences();
|
||||
|
||||
/**
|
||||
* Notice's body
|
||||
*/
|
||||
private String body;
|
||||
private Dialog noticeDialog;
|
||||
|
||||
/**
|
||||
* Application preferences.
|
||||
*/
|
||||
protected static Preferences prefs = new Preferences();
|
||||
|
||||
/**
|
||||
* Selected course code
|
||||
*/
|
||||
private long selectedCourseCode = 0;
|
||||
|
||||
private OnClickListener positiveClickListener = new OnClickListener() {
|
||||
|
||||
|
||||
private OnClickListener positiveClickListener = new OnClickListener() {
|
||||
|
||||
public void onClick(View v) {
|
||||
if(isDebuggable) {
|
||||
Log.i(TAG, "on click positive before send request to server");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
/*if(isDebuggable) {
|
||||
Log.i(TAG, "selectedCourseCode = " + Long.toString(courseCode));
|
||||
|
@ -83,75 +81,75 @@ public class Notices extends Module {
|
|||
|
||||
runConnection();
|
||||
} catch (Exception ex) {
|
||||
String errorMsg = getString(R.string.errorServerResponseMsg);
|
||||
String errorMsg = getString(R.string.errorServerResponseMsg);
|
||||
error(errorMsg);
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.e(ex.getClass().getSimpleName(), errorMsg);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.e(ex.getClass().getSimpleName(), errorMsg);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private OnClickListener negativeClickListener = new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private void launchNoticeDialog(){
|
||||
|
||||
noticeDialog = new Dialog(this);
|
||||
Button acceptButton, cancelButton;
|
||||
|
||||
|
||||
noticeDialog.setTitle(R.string.noticesModuleLabel);
|
||||
noticeDialog.setContentView(R.layout.notice_dialog);
|
||||
noticeDialog.setCancelable(true);
|
||||
|
||||
|
||||
noticeDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
|
||||
|
||||
acceptButton = (Button) noticeDialog.findViewById(R.id.notice_button_accept);
|
||||
acceptButton.setOnClickListener(positiveClickListener);
|
||||
|
||||
|
||||
cancelButton = (Button) noticeDialog.findViewById(R.id.notice_button_cancel);
|
||||
cancelButton.setOnClickListener(negativeClickListener);
|
||||
|
||||
|
||||
noticeDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
|
||||
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
noticeDialog.show();
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void requestService() throws NoSuchAlgorithmException,
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
readData();
|
||||
|
||||
|
||||
createRequest();
|
||||
|
||||
addParam("wsKey",User.getWsKey());
|
||||
|
||||
addParam("wsKey", Global.getLoggedUser().getWsKey());
|
||||
addParam("courseCode",(int)selectedCourseCode);
|
||||
addParam("body",body);
|
||||
|
||||
|
||||
sendRequest(User.class,false);
|
||||
|
||||
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.noticesModuleLabel);
|
||||
int progressTitle = R.string.noticesModuleLabel;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
|
||||
int progressTitle = R.string.noticesModuleLabel;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
|
||||
Toast.makeText(this, R.string.publishingNotice, Toast.LENGTH_SHORT).show();
|
||||
Log.i(TAG, getString(R.string.publishingNotice));
|
||||
|
||||
|
@ -185,7 +183,7 @@ public class Notices extends Module {
|
|||
@Override
|
||||
protected void onStart() {
|
||||
Intent activity;
|
||||
|
||||
|
||||
super.onStart();
|
||||
prefs.getPreferences(getBaseContext());
|
||||
selectedCourseCode = Global.getSelectedCourseCode();
|
||||
|
@ -196,9 +194,9 @@ public class Notices extends Module {
|
|||
@Override
|
||||
protected void onError() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,253 @@
|
|||
/*
|
||||
* This file is part of SWADroid.
|
||||
*
|
||||
* Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*
|
||||
* SWADroid is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* SWADroid is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with SWADroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package es.ugr.swad.swadroid.modules.attendance;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.ksoap2.SoapFault;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.dataframework.DataFramework;
|
||||
import com.google.zxing.client.android.swadroid.model.DataBaseHelper;
|
||||
import com.google.zxing.client.android.swadroid.model.User;
|
||||
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.modules.Module;
|
||||
|
||||
/**
|
||||
* Attendance module for roll call in class
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class Attendance extends Module {
|
||||
private ListView lv;
|
||||
private AlertDialog mAlertDialog;
|
||||
private List<ListItemModel> listModel;
|
||||
private ArrayList<String> listaDnis = null;
|
||||
private long selectedCourseCode;
|
||||
/**
|
||||
* Database Helper.
|
||||
*/
|
||||
protected static DataBaseHelper dbHelper;
|
||||
/**
|
||||
* Database Framework.
|
||||
*/
|
||||
protected static DataFramework db;
|
||||
|
||||
|
||||
/**
|
||||
* Array adapter for showing menu options
|
||||
*/
|
||||
private ArrayAdapter<String> adapter;
|
||||
/**
|
||||
* Attendance tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Attendance";
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onCreate(android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
ImageView image;
|
||||
TextView text;
|
||||
ListView list;
|
||||
String[] items = getResources().getStringArray(R.array.attendanceMenuItems);
|
||||
|
||||
OnItemClickListener clickListener = new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Intent activity;
|
||||
switch(position) {
|
||||
case 0:
|
||||
activity = new Intent(getBaseContext(), AttendanceConfigDownload.class);
|
||||
startActivityForResult(activity, Global.ATTENDANCE_CONFIG_DOWNLOAD_REQUEST_CODE);
|
||||
break;
|
||||
case 1:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.list_items);
|
||||
|
||||
image = (ImageView) this.findViewById(R.id.moduleIcon);
|
||||
image.setBackgroundResource(R.drawable.attendance);
|
||||
|
||||
text = (TextView) this.findViewById(R.id.moduleName);
|
||||
text.setText(R.string.attendanceModuleLabel);
|
||||
|
||||
adapter = new ArrayAdapter<String>(this, R.layout.simple_list_item, R.id.listText, items);
|
||||
list = (ListView) this.findViewById(R.id.listItems);
|
||||
list.setAdapter(adapter);
|
||||
list.setOnItemClickListener(clickListener);
|
||||
}
|
||||
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
switch(requestCode) {
|
||||
case Global.ATTENDANCE_CONFIG_DOWNLOAD_REQUEST_CODE:
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
// Show a dialog with the list of ID cards scanned
|
||||
listaDnis = intent.getStringArrayListExtra("lista_dnis");
|
||||
|
||||
selectedCourseCode = intent.getLongExtra("selectedCourseCode", 0);
|
||||
|
||||
Log.i(TAG, "selectedCourseCode=" + selectedCourseCode);
|
||||
|
||||
if (listaDnis == null)
|
||||
Toast.makeText(getApplicationContext(), "No se han detectado codigos validos", Toast.LENGTH_SHORT).show();
|
||||
else if (!listaDnis.isEmpty()) {
|
||||
listModel = new ArrayList<ListItemModel>();
|
||||
|
||||
// Initialize database
|
||||
try {
|
||||
db = DataFramework.getInstance();
|
||||
db.open(this, "es.ugr.swad.swadroid");
|
||||
dbHelper = new DataBaseHelper(db);
|
||||
} catch (Exception ex) {
|
||||
Log.e(ex.getClass().getSimpleName(), ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// utilizar aqui el dni para buscar el usuario, y si existe en el grupo seleccionado, ponerlo como marcado
|
||||
for (String dni: listaDnis) {
|
||||
User u = dbHelper.getUser(dni, selectedCourseCode);
|
||||
String userName;
|
||||
|
||||
if (u != null) {
|
||||
userName = u.getUserFirstname() + " " + u.getUserSurname1() + " " + u.getUserSurname2();
|
||||
// We put the default photo for each item in the list
|
||||
listModel.add(new ListItemModel(userName, R.drawable.usr_bl));
|
||||
}
|
||||
}
|
||||
// Marcamos como asistentes a todos los escaneados (cambiar cuando pueda comprobarse el grupo)
|
||||
// Mark as attending all scans (change when the group can be checked)
|
||||
for (ListItemModel i: listModel)
|
||||
i.setSelected(true);
|
||||
|
||||
ArrayAdapter<ListItemModel> modeAdapter = new InteractiveArrayAdapter(this, listModel);
|
||||
lv = new ListView(this);
|
||||
lv.setAdapter(modeAdapter);
|
||||
|
||||
lv.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// When clicked, show a toast with the TextView text
|
||||
Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
prepareAlertDialog();
|
||||
mAlertDialog.show();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/*String dni_escaneado = intent.getStringExtra("SCAN_RESULT");
|
||||
String formato = intent.getStringExtra("SCAN_RESULT_FORMAT");
|
||||
|
||||
if (!formato.contentEquals("QR_CODE"))
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
"ERROR: el codigo detectado no es un codigo QR valido",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
else if (!Util.isValidDni(dni_escaneado))
|
||||
Toast.makeText(
|
||||
getApplicationContext(),
|
||||
"ERROR: el codigo detectado no contiene un DNI valido",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
else {
|
||||
Toast.makeText(getApplicationContext(), "DNI valido: " + dni_escaneado, Toast.LENGTH_SHORT).show();
|
||||
listaDnis.add(dni_escaneado);
|
||||
}
|
||||
break;*/
|
||||
/* }
|
||||
} else {
|
||||
}*/
|
||||
}
|
||||
|
||||
public void prepareAlertDialog() {
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
||||
|
||||
AlertDialog.Builder mBuider = new AlertDialog.Builder(this);
|
||||
mBuider.setTitle("Estudiantes asistentes");
|
||||
mBuider.setPositiveButton("Enviar", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
}
|
||||
});
|
||||
mBuider.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
mBuider.setView(lv);
|
||||
mAlertDialog = mBuider.create();
|
||||
|
||||
lp.copyFrom(mAlertDialog.getWindow().getAttributes());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#requestService()
|
||||
*/
|
||||
@Override
|
||||
protected void requestService() throws NoSuchAlgorithmException, IOException, XmlPullParserException, SoapFault, IllegalAccessException, InstantiationException {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#connect()
|
||||
*/
|
||||
@Override
|
||||
protected void connect() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#postConnect()
|
||||
*/
|
||||
@Override
|
||||
protected void postConnect() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError() {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,289 @@
|
|||
/*
|
||||
* This file is part of SWADroid.
|
||||
*
|
||||
* Copyright (C) 2010 Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*
|
||||
* SWADroid is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* SWADroid is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with SWADroid. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package es.ugr.swad.swadroid.modules.attendance;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.ksoap2.SoapFault;
|
||||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.Preferences;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.Course;
|
||||
import es.ugr.swad.swadroid.model.Model;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
import es.ugr.swad.swadroid.modules.Courses;
|
||||
import es.ugr.swad.swadroid.modules.Module;
|
||||
|
||||
/**
|
||||
* Attendance module for get user's courses
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class AttendanceConfigDownload extends Module {
|
||||
/**
|
||||
* Cursor for database access
|
||||
*/
|
||||
private Cursor dbCursor;
|
||||
/**
|
||||
* User courses list
|
||||
*/
|
||||
private List<Model>listCourses;
|
||||
/**
|
||||
* Selected course code
|
||||
*/
|
||||
private long selectedCourseCode = 0;
|
||||
/**
|
||||
* Users counter
|
||||
*/
|
||||
private int usersCount;
|
||||
/**
|
||||
* Inserted users counter
|
||||
*/
|
||||
private int insertedUsersCount = 0;
|
||||
/**
|
||||
* Attendance tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " AttendanceConfigDownload";
|
||||
/**
|
||||
* Application preferences.
|
||||
*/
|
||||
protected static Preferences prefs = new Preferences();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onCreate(android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
prefs.getPreferences(getBaseContext());
|
||||
Intent activity = new Intent(getBaseContext(), Courses.class);
|
||||
Toast.makeText(getBaseContext(), R.string.coursesProgressDescription, Toast.LENGTH_LONG).show();
|
||||
startActivityForResult(activity, Global.COURSES_REQUEST_CODE);
|
||||
setMETHOD_NAME("getUsers");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onActivityResult(int, int, android.content.Intent)
|
||||
*/
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
int lastCourseSelected;
|
||||
|
||||
OnClickListener singleChoiceItemsClickListener = new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
Course c = (Course) listCourses.get(whichButton);
|
||||
selectedCourseCode = c.getId();
|
||||
prefs.setLastCourseSelected(whichButton);
|
||||
|
||||
if(isDebuggable) {
|
||||
Integer s = whichButton;
|
||||
Log.d(TAG, "singleChoice = " + s.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OnClickListener positiveClickListener = new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
try {
|
||||
if(selectedCourseCode == 0) {
|
||||
//Toast.makeText(getBaseContext(), R.string.noCourseSelectedMsg, Toast.LENGTH_LONG).show();
|
||||
Course c = (Course) listCourses.get(0);
|
||||
selectedCourseCode = c.getId();
|
||||
}
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.d(TAG, "selectedCourseCode = " + Long.toString(selectedCourseCode));
|
||||
}
|
||||
runConnection();
|
||||
|
||||
} catch (Exception ex) {
|
||||
String errorMsg = getString(R.string.errorServerResponseMsg);
|
||||
error(errorMsg);
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.e(ex.getClass().getSimpleName(), errorMsg);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OnClickListener negativeClickListener = new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dialog.cancel();
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
switch(requestCode) {
|
||||
case Global.COURSES_REQUEST_CODE:
|
||||
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_COURSES);
|
||||
listCourses = dbHelper.getAllRows(Global.DB_TABLE_COURSES);
|
||||
lastCourseSelected = prefs.getLastCourseSelected();
|
||||
|
||||
alert.setSingleChoiceItems(dbCursor, lastCourseSelected, "name", singleChoiceItemsClickListener)
|
||||
.setTitle(R.string.selectCourseTitle)
|
||||
.setPositiveButton(R.string.acceptMsg, positiveClickListener)
|
||||
.setNegativeButton(R.string.cancelMsg, negativeClickListener)
|
||||
.show();
|
||||
break;
|
||||
case Global.SCAN_QR_REQUEST_CODE:
|
||||
// Propagate the scan result to the previous activity
|
||||
intent.putExtra("selectedCourseCode", selectedCourseCode);
|
||||
setResult(resultCode, intent);
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#requestService()
|
||||
*/
|
||||
@Override
|
||||
protected void requestService() throws NoSuchAlgorithmException, IOException, XmlPullParserException, SoapFault, IllegalAccessException, InstantiationException {
|
||||
int userTypeCode = Global.STUDENT_TYPE_CODE;
|
||||
String empty = "anyType{}";
|
||||
|
||||
// Check if user is logged as teacher
|
||||
if (Global.getLoggedUser().getUserRole() == Global.TEACHER_TYPE_CODE) {
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("wsKey", Global.getLoggedUser().getWsKey());
|
||||
addParam("courseCode", (int) selectedCourseCode);
|
||||
addParam("groupCode", 0); // All groups
|
||||
addParam("userRole", userTypeCode);
|
||||
sendRequest(User.class, false);
|
||||
|
||||
if (result != null) {
|
||||
dbHelper.beginTransaction();
|
||||
|
||||
//Stores users data returned by webservice response
|
||||
Vector<?> res = (Vector<?>) result;
|
||||
SoapObject soap = (SoapObject) res.get(1);
|
||||
usersCount = soap.getPropertyCount();
|
||||
for (int i = 0; i < usersCount; i++) {
|
||||
SoapObject pii = (SoapObject) soap.getProperty(i);
|
||||
Long userCode = new Long(pii.getProperty("userCode").toString());
|
||||
String userID = pii.getProperty("userID").toString();
|
||||
String userNickname = pii.getProperty("userNickname").toString();
|
||||
String userSurname1 = pii.getProperty("userSurname1").toString();
|
||||
String userSurname2 = pii.getProperty("userSurname2").toString();
|
||||
String userFirstName = pii.getProperty("userFirstname").toString();
|
||||
String userTypeName = userTypeCode == Global.TEACHER_TYPE_CODE ? "teacher" : "student";
|
||||
|
||||
/*if(isDebuggable) {
|
||||
Log.d(TAG, "userCode=" + userCode);
|
||||
Log.d(TAG, "userID=" + userID);
|
||||
Log.d(TAG, "userNickname=" + userNickname);
|
||||
Log.d(TAG, "userSurname1=" + userSurname1);
|
||||
Log.d(TAG, "userSurname2=" + userSurname2);
|
||||
Log.d(TAG, "userFirstName=" + userFirstName);
|
||||
Log.d(TAG, "userTypeName=" + userTypeName);
|
||||
}*/
|
||||
|
||||
if (userNickname.equals(empty)) userNickname = null;
|
||||
if (userSurname1.equals(empty)) userSurname1 = null;
|
||||
if (userSurname2.equals(empty)) userSurname2 = null;
|
||||
if (userFirstName.equals(empty)) userFirstName = null;
|
||||
|
||||
User u = new User(
|
||||
userCode, // id
|
||||
userTypeCode,
|
||||
null, // wsKey
|
||||
userID,
|
||||
userNickname,
|
||||
userSurname1,
|
||||
userSurname2,
|
||||
userFirstName,
|
||||
userTypeName,
|
||||
null, // photoPath
|
||||
userTypeCode // userRole
|
||||
);
|
||||
if (dbHelper.insertUser(u))
|
||||
insertedUsersCount++;
|
||||
} // end for (int i=0; i < usersCount; i++)
|
||||
|
||||
//Request finalized without errors
|
||||
Log.i(TAG, "Retrieved " + usersCount + " users");
|
||||
|
||||
dbHelper.endTransaction();
|
||||
} // end if (result != null)
|
||||
|
||||
//Request finalized without errors
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#connect()
|
||||
*/
|
||||
@Override
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.usersDownloadProgressDescription);
|
||||
int progressTitle = R.string.usersDownloadProgressTitle;
|
||||
|
||||
new Connect(true, progressDescription, progressTitle).execute();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#postConnect()
|
||||
*/
|
||||
@Override
|
||||
protected void postConnect() {
|
||||
Log.i(TAG, "Added " + insertedUsersCount + " new users");
|
||||
Toast.makeText(this, "La asignatura seleccionada tiene " + usersCount + " estudiantes", Toast.LENGTH_LONG).show();
|
||||
//finish();
|
||||
|
||||
Intent activity = new Intent("es.ugr.swad.swadroid.android.SCAN");
|
||||
activity.putExtra("SCAN_MODE", "QR_CODE_MODE");
|
||||
activity.putExtra("SCAN_FORMATS", "QR_CODE");
|
||||
// pasar a CaptureActivity selectedCourseCode + cualquier otra informacion que necesite
|
||||
// recibir esta informacion adecuadamente en CaptureActivity y trabajar a partir de ella (ej: lista
|
||||
//de alumnos -> comprobar al escanear un QR si pertenece a la lista)
|
||||
|
||||
//activity.putExtra("selectedCourseCode", selectedCourseCode);
|
||||
startActivityForResult(activity, Global.SCAN_QR_REQUEST_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onError() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package es.ugr.swad.swadroid.modules.attendance;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
|
||||
public class InteractiveArrayAdapter extends ArrayAdapter<ListItemModel> {
|
||||
|
||||
private final List<ListItemModel> list;
|
||||
private final Activity context;
|
||||
|
||||
public static final String TAG = Global.APP_TAG + " InteractiveArrayAdapter";
|
||||
|
||||
public InteractiveArrayAdapter(Activity context, List<ListItemModel> list) {
|
||||
super(context, R.layout.list_items, list);
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
static class ViewHolder {
|
||||
protected ImageView image;
|
||||
protected TextView text;
|
||||
protected CheckBox checkbox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = null;
|
||||
|
||||
if (convertView == null) {
|
||||
LayoutInflater inflator = context.getLayoutInflater();
|
||||
view = inflator.inflate(R.layout.list_image_items, null);
|
||||
|
||||
final ViewHolder viewHolder = new ViewHolder();
|
||||
viewHolder.image = (ImageView) view.findViewById(R.id.imageView1);
|
||||
viewHolder.text = (TextView) view.findViewById(R.id.TextView1);
|
||||
viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check);
|
||||
viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
ListItemModel element = (ListItemModel) viewHolder.checkbox.getTag();
|
||||
element.setSelected(buttonView.isChecked());
|
||||
}
|
||||
});
|
||||
|
||||
view.setTag(viewHolder);
|
||||
viewHolder.checkbox.setTag(list.get(position));
|
||||
} else {
|
||||
view = convertView;
|
||||
((ViewHolder) view.getTag()).checkbox.setTag(list.get(position));
|
||||
}
|
||||
|
||||
ViewHolder holder = (ViewHolder) view.getTag();
|
||||
|
||||
holder.image.setImageResource(list.get(position).getImageId());
|
||||
Bitmap bMap = BitmapFactory.decodeResource(holder.image.getResources(), list.get(position).getImageId());
|
||||
Bitmap bMapScaled = Bitmap.createScaledBitmap(bMap, 60, 80, true);
|
||||
holder.image.setImageBitmap(bMapScaled);
|
||||
|
||||
holder.text.setText(list.get(position).getName());
|
||||
holder.checkbox.setChecked(list.get(position).isSelected());
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package es.ugr.swad.swadroid.modules.attendance;
|
||||
|
||||
|
||||
public class ListItemModel {
|
||||
private int imageId;
|
||||
private String name;
|
||||
private boolean selected;
|
||||
|
||||
public ListItemModel(String name, int imageId) {
|
||||
this.imageId = imageId;
|
||||
this.name = name;
|
||||
selected = false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public int getImageId() {
|
||||
return imageId;
|
||||
}
|
||||
|
||||
public void setImageId(int imageId) {
|
||||
this.imageId = imageId;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package es.ugr.swad.swadroid.modules.attendance;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Util {
|
||||
public static boolean isValidEmail(String email) {
|
||||
String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
|
||||
CharSequence inputStr = email;
|
||||
|
||||
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(inputStr);
|
||||
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
public static boolean isValidDate(String date) {
|
||||
String monthExpression = "(0?[1-9]|1[0-2])";
|
||||
String dayExpression = "(0?[1-9]|[12][0-9]|3[01])";
|
||||
String expression = "^" + dayExpression + "/" + monthExpression + "/(18|19|20|21)\\d{2}";
|
||||
CharSequence inputStr = date;
|
||||
|
||||
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(inputStr);
|
||||
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
public static boolean isValidTime(String hora) {
|
||||
String TIME24HOURS_PATTERN = "([01]?[0-9]|2[0-3]):[0-5][0-9]";
|
||||
|
||||
Pattern pattern = Pattern.compile(TIME24HOURS_PATTERN);
|
||||
Matcher matcher = pattern.matcher(hora);
|
||||
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
public static String pad(int c) {
|
||||
if (c >= 10)
|
||||
return String.valueOf(c);
|
||||
else
|
||||
return "0" + String.valueOf(c);
|
||||
}
|
||||
|
||||
public static boolean isValidDni(String dni) {
|
||||
//String patronDni = "^\\d{8}[A-Z]$";
|
||||
//String patronDni = "^\\d{8}$"; // 8 digitos
|
||||
String patronDni = "^\\d{1,16}$"; // 1-16 digitos
|
||||
|
||||
Pattern pattern = Pattern.compile(patronDni, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(dni);
|
||||
|
||||
return matcher.matches();
|
||||
/*if (matcher.matches())
|
||||
return validarLetra(dni);
|
||||
return false;*/
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static boolean validarLetra(String n) {
|
||||
String numero = n.substring(0, n.length()-1);
|
||||
String letra = n.substring(n.length()-1, n.length());
|
||||
|
||||
int codigo = (Integer.valueOf(numero).intValue()) % 23;
|
||||
String[] abc = {"T","R","W","A","G","M","Y","F","P","D","X","B","N","J","Z","S","Q","V","H","L","C","K","E","T"};
|
||||
|
||||
if(abc[codigo].compareToIgnoreCase(letra) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -26,14 +26,6 @@ import org.ksoap2.SoapFault;
|
|||
import org.ksoap2.serialization.SoapObject;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import com.android.dataframework.DataFramework;
|
||||
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.DataBaseHelper;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
import es.ugr.swad.swadroid.model.SWADNotification;
|
||||
import es.ugr.swad.swadroid.modules.Module;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
|
@ -51,15 +43,23 @@ import android.widget.ListView;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.dataframework.DataFramework;
|
||||
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.DataBaseHelper;
|
||||
import es.ugr.swad.swadroid.model.SWADNotification;
|
||||
import es.ugr.swad.swadroid.modules.Module;
|
||||
|
||||
/**
|
||||
* Notifications module for get user's notifications
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
*
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com> *
|
||||
*/
|
||||
public class Notifications extends Module {
|
||||
/**
|
||||
* Max size to store notifications
|
||||
*/
|
||||
/**
|
||||
* Max size to store notifications
|
||||
*/
|
||||
private static final int SIZE_LIMIT = 25;
|
||||
/**
|
||||
* Notifications adapter for showing the data
|
||||
|
@ -76,39 +76,39 @@ public class Notifications extends Module {
|
|||
/**
|
||||
* Cursor orderby parameter
|
||||
*/
|
||||
private String orderby = "eventTime DESC";
|
||||
/**
|
||||
* Notifications counter
|
||||
*/
|
||||
private int notifCount;
|
||||
/**
|
||||
* Unique identifier for notification alerts
|
||||
*/
|
||||
private int NOTIF_ALERT_ID = 1982;
|
||||
/**
|
||||
* Notifications tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Notifications";
|
||||
|
||||
/**
|
||||
* Refreshes data on screen
|
||||
*/
|
||||
private void refreshScreen() {
|
||||
//Refresh data on screen
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_NOTIFICATIONS, selection, orderby);
|
||||
startManagingCursor(dbCursor);
|
||||
adapter.changeCursor(dbCursor);
|
||||
|
||||
TextView text = (TextView) this.findViewById(R.id.listText);
|
||||
ListView list = (ListView)this.findViewById(R.id.listItems);
|
||||
|
||||
//If there are notifications to show, hide the empty notifications message and show the notifications list
|
||||
if(dbCursor.getCount() > 0) {
|
||||
text.setVisibility(View.GONE);
|
||||
list.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private String orderby = "eventTime DESC";
|
||||
/**
|
||||
* Notifications counter
|
||||
*/
|
||||
private int notifCount;
|
||||
/**
|
||||
* Unique identifier for notification alerts
|
||||
*/
|
||||
private int NOTIF_ALERT_ID = 1982;
|
||||
/**
|
||||
* Notifications tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " Notifications";
|
||||
|
||||
/**
|
||||
* Refreshes data on screen
|
||||
*/
|
||||
private void refreshScreen() {
|
||||
//Refresh data on screen
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_NOTIFICATIONS, selection, orderby);
|
||||
startManagingCursor(dbCursor);
|
||||
adapter.changeCursor(dbCursor);
|
||||
|
||||
TextView text = (TextView) this.findViewById(R.id.listText);
|
||||
ListView list = (ListView)this.findViewById(R.id.listItems);
|
||||
|
||||
//If there are notifications to show, hide the empty notifications message and show the notifications list
|
||||
if(dbCursor.getCount() > 0) {
|
||||
text.setVisibility(View.GONE);
|
||||
list.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onCreate(android.os.Bundle)
|
||||
*/
|
||||
|
@ -132,62 +132,62 @@ public class Notifications extends Module {
|
|||
activity.putExtra("course", course.getText().toString());
|
||||
activity.putExtra("summary", summary.getText().toString());
|
||||
activity.putExtra("content", content.getText().toString());
|
||||
|
||||
|
||||
startActivity(activity);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.list_items);
|
||||
|
||||
image = (ImageView)this.findViewById(R.id.moduleIcon);
|
||||
image.setBackgroundResource(R.drawable.notif);
|
||||
|
||||
text = (TextView)this.findViewById(R.id.moduleName);
|
||||
text.setText(R.string.notificationsModuleLabel);
|
||||
|
||||
image = (ImageView)this.findViewById(R.id.title_sep_1);
|
||||
image.setVisibility(View.VISIBLE);
|
||||
|
||||
updateButton = (ImageButton)this.findViewById(R.id.refresh);
|
||||
updateButton.setVisibility(View.VISIBLE);
|
||||
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_NOTIFICATIONS, selection, orderby);
|
||||
startManagingCursor(dbCursor);
|
||||
adapter = new NotificationsCursorAdapter(this, dbCursor);
|
||||
|
||||
list = (ListView)this.findViewById(R.id.listItems);
|
||||
list.setAdapter(adapter);
|
||||
list.setOnItemClickListener(clickListener);
|
||||
|
||||
text = (TextView) this.findViewById(R.id.listText);
|
||||
setContentView(R.layout.list_items);
|
||||
|
||||
/*
|
||||
* If there aren't notifications to show, hide the notifications list and show the empty notifications
|
||||
* message
|
||||
*/
|
||||
if(dbCursor.getCount() == 0) {
|
||||
list.setVisibility(View.GONE);
|
||||
text.setVisibility(View.VISIBLE);
|
||||
text.setText(R.string.notificationsEmptyListMsg);
|
||||
}
|
||||
|
||||
setMETHOD_NAME("getNotifications");
|
||||
image = (ImageView)this.findViewById(R.id.moduleIcon);
|
||||
image.setBackgroundResource(R.drawable.notif);
|
||||
|
||||
text = (TextView)this.findViewById(R.id.moduleName);
|
||||
text.setText(R.string.notificationsModuleLabel);
|
||||
|
||||
image = (ImageView)this.findViewById(R.id.title_sep_1);
|
||||
image.setVisibility(View.VISIBLE);
|
||||
|
||||
updateButton = (ImageButton)this.findViewById(R.id.refresh);
|
||||
updateButton.setVisibility(View.VISIBLE);
|
||||
|
||||
dbCursor = dbHelper.getDb().getCursor(Global.DB_TABLE_NOTIFICATIONS, selection, orderby);
|
||||
startManagingCursor(dbCursor);
|
||||
adapter = new NotificationsCursorAdapter(this, dbCursor);
|
||||
|
||||
list = (ListView)this.findViewById(R.id.listItems);
|
||||
list.setAdapter(adapter);
|
||||
list.setOnItemClickListener(clickListener);
|
||||
|
||||
text = (TextView) this.findViewById(R.id.listText);
|
||||
|
||||
/*
|
||||
* If there aren't notifications to show, hide the notifications list and show the empty notifications
|
||||
* message
|
||||
*/
|
||||
if(dbCursor.getCount() == 0) {
|
||||
list.setVisibility(View.GONE);
|
||||
text.setVisibility(View.VISIBLE);
|
||||
text.setText(R.string.notificationsEmptyListMsg);
|
||||
}
|
||||
|
||||
setMETHOD_NAME("getNotifications");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Launches an action when refresh button is pushed
|
||||
* @param v Actual view
|
||||
*/
|
||||
public void onRefreshClick(View v)
|
||||
{
|
||||
ImageButton updateButton = (ImageButton)this.findViewById(R.id.refresh);
|
||||
ProgressBar pb = (ProgressBar)this.findViewById(R.id.progress_refresh);
|
||||
|
||||
updateButton.setVisibility(View.GONE);
|
||||
pb.setVisibility(View.VISIBLE);
|
||||
|
||||
ImageButton updateButton = (ImageButton)this.findViewById(R.id.refresh);
|
||||
ProgressBar pb = (ProgressBar)this.findViewById(R.id.progress_refresh);
|
||||
|
||||
updateButton.setVisibility(View.GONE);
|
||||
pb.setVisibility(View.VISIBLE);
|
||||
|
||||
runConnection();
|
||||
if(!isConnected)
|
||||
onError();
|
||||
|
@ -207,90 +207,90 @@ public class Notifications extends Module {
|
|||
*/
|
||||
@Override
|
||||
protected void requestService() throws NoSuchAlgorithmException,
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
//Calculates next timestamp to be requested
|
||||
Long timestamp = new Long(dbHelper.getFieldOfLastNotification("eventTime"));
|
||||
timestamp++;
|
||||
|
||||
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("wsKey", User.getWsKey());
|
||||
addParam("beginTime", timestamp);
|
||||
sendRequest(SWADNotification.class, false);
|
||||
|
||||
if (result != null) {
|
||||
dbHelper.beginTransaction();
|
||||
|
||||
//Stores notifications data returned by webservice response
|
||||
createRequest();
|
||||
addParam("wsKey", Global.getLoggedUser().getWsKey());
|
||||
addParam("beginTime", timestamp);
|
||||
sendRequest(SWADNotification.class, false);
|
||||
|
||||
if (result != null) {
|
||||
dbHelper.beginTransaction();
|
||||
|
||||
//Stores notifications data returned by webservice response
|
||||
Vector<?> res = (Vector<?>) result;
|
||||
SoapObject soap = (SoapObject) res.get(1);
|
||||
notifCount = soap.getPropertyCount();
|
||||
for (int i = 0; i < notifCount; i++) {
|
||||
SoapObject pii = (SoapObject)soap.getProperty(i);
|
||||
Long notificationCode = new Long(pii.getProperty("notificationCode").toString());
|
||||
String eventType = pii.getProperty("eventType").toString();
|
||||
Long eventTime = new Long(pii.getProperty("eventTime").toString());
|
||||
String userSurname1 = pii.getProperty("userSurname1").toString();
|
||||
String userSurname2 = pii.getProperty("userSurname2").toString();
|
||||
String userFirstName = pii.getProperty("userFirstname").toString();
|
||||
String location = pii.getProperty("location").toString();
|
||||
String summary = pii.getProperty("summary").toString();
|
||||
Integer status = new Integer(pii.getProperty("status").toString());
|
||||
String content = pii.getProperty("content").toString();
|
||||
SWADNotification n = new SWADNotification(notificationCode, eventType, eventTime, userSurname1, userSurname2, userFirstName, location, summary, status, content);
|
||||
dbHelper.insertNotification(n);
|
||||
|
||||
/*if(isDebuggable)
|
||||
SoapObject soap = (SoapObject) res.get(1);
|
||||
notifCount = soap.getPropertyCount();
|
||||
for (int i = 0; i < notifCount; i++) {
|
||||
SoapObject pii = (SoapObject)soap.getProperty(i);
|
||||
Long notificationCode = new Long(pii.getProperty("notificationCode").toString());
|
||||
String eventType = pii.getProperty("eventType").toString();
|
||||
Long eventTime = new Long(pii.getProperty("eventTime").toString());
|
||||
String userSurname1 = pii.getProperty("userSurname1").toString();
|
||||
String userSurname2 = pii.getProperty("userSurname2").toString();
|
||||
String userFirstName = pii.getProperty("userFirstname").toString();
|
||||
String location = pii.getProperty("location").toString();
|
||||
String summary = pii.getProperty("summary").toString();
|
||||
Integer status = new Integer(pii.getProperty("status").toString());
|
||||
String content = pii.getProperty("content").toString();
|
||||
SWADNotification n = new SWADNotification(notificationCode, eventType, eventTime, userSurname1, userSurname2, userFirstName, location, summary, status, content);
|
||||
dbHelper.insertNotification(n);
|
||||
|
||||
/*if(isDebuggable)
|
||||
Log.d(TAG, n.toString());*/
|
||||
}
|
||||
|
||||
//Request finalized without errors
|
||||
Log.i(TAG, "Retrieved " + notifCount + " notifications");
|
||||
|
||||
}
|
||||
|
||||
//Request finalized without errors
|
||||
Log.i(TAG, "Retrieved " + notifCount + " notifications");
|
||||
|
||||
//Clear old notifications to control database size
|
||||
dbHelper.clearOldNotifications(SIZE_LIMIT);
|
||||
|
||||
|
||||
dbHelper.endTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void alertNotif() {
|
||||
if(notifCount > 0) {
|
||||
//Obtain a reference to the notification service
|
||||
String ns = Context.NOTIFICATION_SERVICE;
|
||||
NotificationManager notManager =
|
||||
(NotificationManager) getSystemService(ns);
|
||||
|
||||
(NotificationManager) getSystemService(ns);
|
||||
|
||||
//Configure the alert
|
||||
int icon = R.drawable.ic_launcher_swadroid;
|
||||
long hour = System.currentTimeMillis();
|
||||
|
||||
|
||||
Notification notif =
|
||||
new Notification(icon, getString(R.string.notificationsAlertTitle), hour);
|
||||
|
||||
new Notification(icon, getString(R.string.notificationsAlertTitle), hour);
|
||||
|
||||
//Configure the Intent
|
||||
Context context = getApplicationContext();
|
||||
|
||||
|
||||
Intent notIntent = new Intent(context,
|
||||
Notifications.class);
|
||||
|
||||
Notifications.class);
|
||||
|
||||
PendingIntent contIntent = PendingIntent.getActivity(
|
||||
context, 0, notIntent, 0);
|
||||
|
||||
context, 0, notIntent, 0);
|
||||
|
||||
notif.setLatestEventInfo(
|
||||
context, getString(R.string.notificationsAlertTitle), notifCount + " " +
|
||||
getString(R.string.notificationsAlertMsg), contIntent);
|
||||
|
||||
context, getString(R.string.notificationsAlertTitle), notifCount + " " +
|
||||
getString(R.string.notificationsAlertMsg), contIntent);
|
||||
|
||||
//AutoCancel: alert disappears when pushed
|
||||
notif.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||
|
||||
|
||||
//Add sound, vibration and lights
|
||||
notif.defaults |= Notification.DEFAULT_SOUND;
|
||||
//notif.defaults |= Notification.DEFAULT_VIBRATE;
|
||||
notif.defaults |= Notification.DEFAULT_LIGHTS;
|
||||
|
||||
|
||||
//Send alert
|
||||
notManager.notify(NOTIF_ALERT_ID, notif);
|
||||
}
|
||||
|
@ -302,9 +302,9 @@ public class Notifications extends Module {
|
|||
@Override
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.notificationsProgressDescription);
|
||||
int progressTitle = R.string.notificationsProgressTitle;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
int progressTitle = R.string.notificationsProgressTitle;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -314,41 +314,41 @@ public class Notifications extends Module {
|
|||
protected void postConnect() {
|
||||
refreshScreen();
|
||||
//Toast.makeText(this, R.string.notificationsDownloadedMsg, Toast.LENGTH_SHORT).show();
|
||||
|
||||
|
||||
alertNotif();
|
||||
|
||||
ProgressBar pb = (ProgressBar)this.findViewById(R.id.progress_refresh);
|
||||
|
||||
ProgressBar pb = (ProgressBar)this.findViewById(R.id.progress_refresh);
|
||||
ImageButton updateButton = (ImageButton)this.findViewById(R.id.refresh);
|
||||
|
||||
pb.setVisibility(View.GONE);
|
||||
updateButton.setVisibility(View.VISIBLE);
|
||||
|
||||
pb.setVisibility(View.GONE);
|
||||
updateButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onError()
|
||||
*/
|
||||
@Override
|
||||
protected void onError() {
|
||||
ProgressBar pb = (ProgressBar)this.findViewById(R.id.progress_refresh);
|
||||
ProgressBar pb = (ProgressBar)this.findViewById(R.id.progress_refresh);
|
||||
ImageButton updateButton = (ImageButton)this.findViewById(R.id.refresh);
|
||||
|
||||
pb.setVisibility(View.GONE);
|
||||
updateButton.setVisibility(View.VISIBLE);
|
||||
|
||||
pb.setVisibility(View.GONE);
|
||||
updateButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes all notifications from database
|
||||
* @param context Database context
|
||||
*/
|
||||
public void clearNotifications(Context context) {
|
||||
try {
|
||||
DataFramework db = DataFramework.getInstance();
|
||||
try {
|
||||
DataFramework db = DataFramework.getInstance();
|
||||
db.open(context, context.getPackageName());
|
||||
dbHelper = new DataBaseHelper(db);
|
||||
|
||||
dbHelper = new DataBaseHelper(db);
|
||||
|
||||
dbHelper.emptyTable(Global.DB_TABLE_NOTIFICATIONS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,34 +20,25 @@ package es.ugr.swad.swadroid.modules.tests;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.ksoap2.SoapFault;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.Preferences;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.Course;
|
||||
import es.ugr.swad.swadroid.model.Model;
|
||||
import es.ugr.swad.swadroid.model.Test;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
import es.ugr.swad.swadroid.modules.Courses;
|
||||
import es.ugr.swad.swadroid.modules.Module;
|
||||
|
||||
/**
|
||||
* Tests module for download and update questions
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class TestsConfigDownload extends Module {
|
||||
/**
|
||||
|
@ -58,22 +49,22 @@ public class TestsConfigDownload extends Module {
|
|||
* Number of available questions
|
||||
*/
|
||||
private int numQuestions;
|
||||
/**
|
||||
* Tests tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " TestsConfigDownload";
|
||||
/**
|
||||
* Application preferences.
|
||||
*/
|
||||
protected static Preferences prefs = new Preferences();
|
||||
|
||||
/**
|
||||
* Tests tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " TestsConfigDownload";
|
||||
/**
|
||||
* Application preferences.
|
||||
*/
|
||||
protected static Preferences prefs = new Preferences();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onCreate(android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setMETHOD_NAME("getTestConfig");
|
||||
setMETHOD_NAME("getTestConfig");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -84,21 +75,21 @@ public class TestsConfigDownload extends Module {
|
|||
super.onStart();
|
||||
prefs.getPreferences(getBaseContext());
|
||||
try {
|
||||
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.d(TAG, "selectedCourseCode = " + Long.toString(Global.getSelectedCourseCode()));
|
||||
}
|
||||
|
||||
runConnection();
|
||||
} catch (Exception ex) {
|
||||
String errorMsg = getString(R.string.errorServerResponseMsg);
|
||||
String errorMsg = getString(R.string.errorServerResponseMsg);
|
||||
error(errorMsg);
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.e(ex.getClass().getSimpleName(), errorMsg);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.e(ex.getClass().getSimpleName(), errorMsg);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,65 +98,65 @@ public class TestsConfigDownload extends Module {
|
|||
*/
|
||||
@Override
|
||||
protected void requestService() throws NoSuchAlgorithmException,
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
//Calculates next timestamp to be requested
|
||||
Long timestamp = new Long(dbHelper.getTimeOfLastTestUpdate(Global.getSelectedCourseCode()));
|
||||
timestamp++;
|
||||
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("wsKey", User.getWsKey());
|
||||
addParam("courseCode", (int)Global.getSelectedCourseCode());
|
||||
sendRequest(Test.class, false);
|
||||
|
||||
if (result != null) {
|
||||
//Stores tests data returned by webservice response
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("wsKey", Global.getLoggedUser().getWsKey());
|
||||
addParam("courseCode", (int)Global.getSelectedCourseCode());
|
||||
sendRequest(Test.class, false);
|
||||
|
||||
if (result != null) {
|
||||
//Stores tests data returned by webservice response
|
||||
Vector<?> res = (Vector<?>) result;
|
||||
|
||||
Integer pluggable = new Integer(res.get(0).toString());
|
||||
isPluggable = Global.parseIntBool(pluggable);
|
||||
numQuestions = new Integer(res.get(1).toString());
|
||||
|
||||
//If there are no available questions, notify to user
|
||||
if(numQuestions == 0) {
|
||||
Log.i(TAG, getString(R.string.noQuestionsAvailableTestsDownloadMsg));
|
||||
|
||||
//If the teacher doesn't allows questions download, notify to user
|
||||
} else if(!isPluggable) {
|
||||
Log.i(TAG, getString(R.string.noQuestionsPluggableTestsDownloadMsg));
|
||||
|
||||
//If there are questions and the teacher allows their download, process the questions data
|
||||
} else {
|
||||
Integer minQuestions = new Integer(res.get(2).toString());
|
||||
Integer defQuestions = new Integer(res.get(3).toString());
|
||||
Integer maxQuestions = new Integer(res.get(4).toString());
|
||||
String feedback = res.get(5).toString();
|
||||
Test tDB = (Test) dbHelper.getRow(Global.DB_TABLE_TEST_CONFIG, "id",
|
||||
Long.toString(Global.getSelectedCourseCode()));
|
||||
|
||||
//If not exists a test configuration for this course, insert to database
|
||||
if(tDB == null) {
|
||||
Test t = new Test(Global.getSelectedCourseCode(), minQuestions, defQuestions, maxQuestions, feedback);
|
||||
dbHelper.insertTestConfig(t);
|
||||
}
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.d(TAG, "minQuestions=" + minQuestions);
|
||||
Log.d(TAG, "defQuestions=" + defQuestions);
|
||||
Log.d(TAG, "maxQuestions=" + maxQuestions);
|
||||
Log.d(TAG, "feedback=" + feedback);
|
||||
}
|
||||
|
||||
Intent activity = new Intent(getBaseContext(), TestsQuestionsDownload.class);
|
||||
activity.putExtra("timestamp", timestamp);
|
||||
Integer pluggable = new Integer(res.get(0).toString());
|
||||
isPluggable = Global.parseIntBool(pluggable);
|
||||
numQuestions = new Integer(res.get(1).toString());
|
||||
|
||||
//If there are no available questions, notify to user
|
||||
if(numQuestions == 0) {
|
||||
Log.i(TAG, getString(R.string.noQuestionsAvailableTestsDownloadMsg));
|
||||
|
||||
//If the teacher doesn't allows questions download, notify to user
|
||||
} else if(!isPluggable) {
|
||||
Log.i(TAG, getString(R.string.noQuestionsPluggableTestsDownloadMsg));
|
||||
|
||||
//If there are questions and the teacher allows their download, process the questions data
|
||||
} else {
|
||||
Integer minQuestions = new Integer(res.get(2).toString());
|
||||
Integer defQuestions = new Integer(res.get(3).toString());
|
||||
Integer maxQuestions = new Integer(res.get(4).toString());
|
||||
String feedback = res.get(5).toString();
|
||||
Test tDB = (Test) dbHelper.getRow(Global.DB_TABLE_TEST_CONFIG, "id",
|
||||
Long.toString(Global.getSelectedCourseCode()));
|
||||
|
||||
//If not exists a test configuration for this course, insert to database
|
||||
if(tDB == null) {
|
||||
Test t = new Test(Global.getSelectedCourseCode(), minQuestions, defQuestions, maxQuestions, feedback);
|
||||
dbHelper.insertTestConfig(t);
|
||||
}
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.d(TAG, "minQuestions=" + minQuestions);
|
||||
Log.d(TAG, "defQuestions=" + defQuestions);
|
||||
Log.d(TAG, "maxQuestions=" + maxQuestions);
|
||||
Log.d(TAG, "feedback=" + feedback);
|
||||
}
|
||||
|
||||
Intent activity = new Intent(getBaseContext(), TestsQuestionsDownload.class);
|
||||
activity.putExtra("timestamp", timestamp);
|
||||
startActivityForResult(activity, Global.TESTS_QUESTIONS_DOWNLOAD_REQUEST_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
//Request finalized without errors
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
}
|
||||
|
||||
//Request finalized without errors
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -174,9 +165,9 @@ public class TestsConfigDownload extends Module {
|
|||
@Override
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.testsDownloadProgressDescription);
|
||||
int progressTitle = R.string.testsDownloadProgressTitle;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
int progressTitle = R.string.testsDownloadProgressTitle;
|
||||
|
||||
new Connect(false, progressDescription, progressTitle).execute();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -187,12 +178,12 @@ public class TestsConfigDownload extends Module {
|
|||
if(numQuestions == 0) {
|
||||
Toast.makeText(this, R.string.noQuestionsAvailableTestsDownloadMsg, Toast.LENGTH_LONG).show();
|
||||
} else if(!isPluggable) {
|
||||
Toast.makeText(this, R.string.noQuestionsPluggableTestsDownloadMsg, Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(this, R.string.noQuestionsPluggableTestsDownloadMsg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
finish();
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onError()
|
||||
*/
|
||||
|
|
|
@ -27,9 +27,6 @@ import java.util.List;
|
|||
import org.ksoap2.SoapFault;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
|
@ -48,12 +45,10 @@ import android.widget.ImageView;
|
|||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import es.ugr.swad.swadroid.Global;
|
||||
import es.ugr.swad.swadroid.Preferences;
|
||||
import es.ugr.swad.swadroid.R;
|
||||
import es.ugr.swad.swadroid.model.Course;
|
||||
import es.ugr.swad.swadroid.model.Model;
|
||||
import es.ugr.swad.swadroid.model.Test;
|
||||
import es.ugr.swad.swadroid.model.TestAnswer;
|
||||
import es.ugr.swad.swadroid.model.TestQuestion;
|
||||
|
@ -95,15 +90,15 @@ public class TestsMake extends Module {
|
|||
* Test question being showed
|
||||
*/
|
||||
private int actualQuestion;
|
||||
/**
|
||||
* Tests tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " TestsMake";
|
||||
/**
|
||||
* Application preferences.
|
||||
*/
|
||||
protected static Preferences prefs = new Preferences();
|
||||
|
||||
/**
|
||||
* Tests tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " TestsMake";
|
||||
/**
|
||||
* Application preferences.
|
||||
*/
|
||||
protected static Preferences prefs = new Preferences();
|
||||
|
||||
/**
|
||||
* Sets layout maintaining tests action bar
|
||||
* @param layout Layout to be applied
|
||||
|
@ -111,43 +106,43 @@ public class TestsMake extends Module {
|
|||
private void setLayout(int layout) {
|
||||
ImageView image;
|
||||
TextView text;
|
||||
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
image = (ImageView)this.findViewById(R.id.moduleIcon);
|
||||
image.setBackgroundResource(R.drawable.test);
|
||||
|
||||
text = (TextView)this.findViewById(R.id.moduleName);
|
||||
text.setText(R.string.testsModuleLabel);
|
||||
|
||||
image = (ImageView)this.findViewById(R.id.moduleIcon);
|
||||
image.setBackgroundResource(R.drawable.test);
|
||||
|
||||
text = (TextView)this.findViewById(R.id.moduleName);
|
||||
text.setText(R.string.testsModuleLabel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Screen to select the number of questions in the test
|
||||
*/
|
||||
private void setNumQuestions() {
|
||||
final NumberPicker numberPicker;
|
||||
Button acceptButton;
|
||||
|
||||
|
||||
setLayout(R.layout.tests_num_questions);
|
||||
|
||||
|
||||
numberPicker = (NumberPicker)findViewById(R.id.testNumQuestionsNumberPicker);
|
||||
numberPicker.setRange(test.getMin(), test.getMax());
|
||||
numberPicker.setCurrent(test.getDef());
|
||||
|
||||
|
||||
acceptButton = (Button)findViewById(R.id.testNumQuestionsAcceptButton);
|
||||
acceptButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
numQuestions = numberPicker.getCurrent();
|
||||
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.d(TAG, "numQuestions="+numQuestions);
|
||||
}
|
||||
|
||||
|
||||
setTags();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Screen to select the tags that will be present in the test
|
||||
*/
|
||||
|
@ -156,30 +151,30 @@ public class TestsMake extends Module {
|
|||
final ListView checkBoxesList;
|
||||
final TagsArrayAdapter tagsAdapter;
|
||||
final List<TestTag> allTagsList = dbHelper.getOrderedCourseTags(Global.getSelectedCourseCode());
|
||||
|
||||
|
||||
//Add "All tags" item in list's top
|
||||
allTagsList.add(0, new TestTag(0, getResources().getString(R.string.allMsg), 0));
|
||||
|
||||
|
||||
setLayout(R.layout.tests_tags);
|
||||
|
||||
|
||||
checkBoxesList = (ListView) findViewById(R.id.testTagsList);
|
||||
tagsAdapter = new TagsArrayAdapter(this, R.layout.list_item_multiple_choice, allTagsList);
|
||||
checkBoxesList.setAdapter(tagsAdapter);
|
||||
checkBoxesList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
||||
checkBoxesList.setOnItemClickListener(tagsAnswersTypeItemClickListener);
|
||||
|
||||
|
||||
acceptButton = (Button)findViewById(R.id.testTagsAcceptButton);
|
||||
acceptButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
int childsCount = checkBoxesList.getCount();
|
||||
SparseBooleanArray checkedItems = checkBoxesList.getCheckedItemPositions();
|
||||
tagsList = new ArrayList<TestTag>();
|
||||
|
||||
|
||||
//If "All tags" item checked, add the whole list to the list of selected tags
|
||||
if(checkedItems.get(0, false)) {
|
||||
tagsList.add(new TestTag(0, null, "all", 0));
|
||||
|
||||
//If "All tags" item not checked, add the selected items to the list of selected tags
|
||||
|
||||
//If "All tags" item not checked, add the selected items to the list of selected tags
|
||||
} else {
|
||||
for(int i=0; i<childsCount; i++) {
|
||||
if(checkedItems.get(i, false)) {
|
||||
|
@ -187,23 +182,23 @@ public class TestsMake extends Module {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.d(TAG, "tagsList="+tagsList.toString());
|
||||
}
|
||||
|
||||
|
||||
//If no tags selected, show a message to notice user
|
||||
if(tagsList.isEmpty()) {
|
||||
Toast.makeText(getBaseContext(), R.string.testNoTagsSelectedMsg, Toast.LENGTH_LONG).show();
|
||||
|
||||
//If any tag is selected, show the answer types selection screen
|
||||
|
||||
//If any tag is selected, show the answer types selection screen
|
||||
} else {
|
||||
setAnswerTypes();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Screen to select the answer types that will be present in the test
|
||||
*/
|
||||
|
@ -211,23 +206,23 @@ public class TestsMake extends Module {
|
|||
Button acceptButton;
|
||||
final ListView checkBoxesList;
|
||||
final AnswerTypesArrayAdapter answerTypesAdapter;
|
||||
|
||||
|
||||
setLayout(R.layout.tests_answer_types);
|
||||
|
||||
|
||||
checkBoxesList = (ListView) findViewById(R.id.testAnswerTypesList);
|
||||
answerTypesAdapter = new AnswerTypesArrayAdapter(this, R.array.testAnswerTypes,
|
||||
R.array.testAnswerTypesNames, R.layout.list_item_multiple_choice);
|
||||
checkBoxesList.setAdapter(answerTypesAdapter);
|
||||
checkBoxesList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
||||
checkBoxesList.setOnItemClickListener(tagsAnswersTypeItemClickListener);
|
||||
|
||||
|
||||
acceptButton = (Button)findViewById(R.id.testAnswerTypesAcceptButton);
|
||||
acceptButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
int childsCount = checkBoxesList.getCount();
|
||||
SparseBooleanArray checkedItems = checkBoxesList.getCheckedItemPositions();
|
||||
answerTypesList = new ArrayList<String>();
|
||||
|
||||
|
||||
/*
|
||||
* If "All tags" item checked, add the whole list to the list of selected answer types,
|
||||
* else, add the selected items to the list of selected answer types
|
||||
|
@ -241,24 +236,24 @@ public class TestsMake extends Module {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isDebuggable) {
|
||||
Log.d(TAG, "answerTypesList="+answerTypesList.toString());
|
||||
}
|
||||
|
||||
|
||||
//If no answer types selected, show a message to notice user
|
||||
if(answerTypesList.isEmpty()) {
|
||||
Toast.makeText(getBaseContext(), R.string.testNoAnswerTypesSelectedMsg, Toast.LENGTH_LONG)
|
||||
.show();
|
||||
|
||||
//If any answer type is selected, generate the test and show the first question screen
|
||||
.show();
|
||||
|
||||
//If any answer type is selected, generate the test and show the first question screen
|
||||
} else {
|
||||
makeTest();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shows a test question on screen
|
||||
* @param pos Question's position in questions's list of the test
|
||||
|
@ -286,22 +281,22 @@ public class TestsMake extends Module {
|
|||
textCorrectAnswer.setVisibility(View.GONE);
|
||||
testMakeList.setVisibility(View.GONE);
|
||||
img.setVisibility(View.GONE);
|
||||
|
||||
|
||||
stem.setText(Html.fromHtml(question.getStem()));
|
||||
if(answerType.equals("text")
|
||||
|| answerType.equals("int")
|
||||
|| answerType.equals("float")) {
|
||||
|
||||
|
||||
if(!answerType.equals("text")) {
|
||||
textAnswer.setRawInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
} else {
|
||||
textAnswer.setRawInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
|
||||
a = answers.get(0);
|
||||
textAnswer.setText(a.getUserAnswer());
|
||||
textAnswer.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
if(test.isEvaluated() && feedback.equals("eachGoodBad")) {
|
||||
if(answerType.equals("float")) {
|
||||
correctAnswer = "[" + a.getAnswer() + ";" + answers.get(1).getAnswer() + "]";
|
||||
|
@ -311,40 +306,40 @@ public class TestsMake extends Module {
|
|||
correctAnswer += a.getAnswer() + "<br/>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
textCorrectAnswer.setText(Html.fromHtml(correctAnswer));
|
||||
textCorrectAnswer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if(answerType.equals("multipleChoice")) {
|
||||
} else if(answerType.equals("multipleChoice")) {
|
||||
checkedAnswersAdapter = new CheckedAnswersArrayAdapter(this, R.layout.list_item_multiple_choice,
|
||||
answers, test.isEvaluated(), test.getFeedback(), answerType);
|
||||
|
||||
answers, test.isEvaluated(), test.getFeedback(), answerType);
|
||||
|
||||
testMakeList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
||||
testMakeList.setAdapter(checkedAnswersAdapter);
|
||||
|
||||
|
||||
for(int i=0; i<numAnswers; i++) {
|
||||
a = answers.get(i);
|
||||
testMakeList.setItemChecked(i, Global.parseStringBool(a.getUserAnswer()));
|
||||
}
|
||||
|
||||
|
||||
testMakeList.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
} else {
|
||||
if(answerType.equals("TF") && (numAnswers < 2)) {
|
||||
if(answers.get(0).getAnswer().equals("T")) {
|
||||
answers.add(1, new TestAnswer(0, 1, 0, false, "F"));
|
||||
} else {
|
||||
answers.add(0, new TestAnswer(0, 0, 0, false, "T"));
|
||||
}
|
||||
|
||||
|
||||
numAnswers = 2;
|
||||
}
|
||||
|
||||
|
||||
checkedAnswersAdapter = new CheckedAnswersArrayAdapter(this, R.layout.list_item_single_choice,
|
||||
answers, test.isEvaluated(), test.getFeedback(), answerType);
|
||||
|
||||
answers, test.isEvaluated(), test.getFeedback(), answerType);
|
||||
|
||||
testMakeList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
testMakeList.setAdapter(checkedAnswersAdapter);
|
||||
|
||||
|
||||
for(int i=0; i<numAnswers; i++) {
|
||||
a = answers.get(i);
|
||||
if(a.getAnswer().equals(answers.get(0).getUserAnswer())) {
|
||||
|
@ -352,27 +347,27 @@ public class TestsMake extends Module {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
testMakeList.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
if(test.isEvaluated() && (feedback.equals("eachResult") || feedback.equals("eachGoodBad"))) {
|
||||
textAnswer.setEnabled(false);
|
||||
textAnswer.setOnClickListener(null);
|
||||
|
||||
|
||||
if(feedback.equals("eachGoodBad")) {
|
||||
img.setImageResource(R.drawable.btn_check_buttonless_on);
|
||||
if(!answerType.equals("TF") && !answerType.equals("multipleChoice")
|
||||
&& !answerType.equals("uniqueChoice")) {
|
||||
|
||||
|
||||
if(!answers.get(0).isCorrectAnswered()) {
|
||||
img.setImageResource(android.R.drawable.ic_delete);
|
||||
}
|
||||
|
||||
|
||||
img.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
questionScore = test.getQuestionScore(pos);
|
||||
if(questionScore > 0) {
|
||||
score.setTextColor(getResources().getColor(R.color.green));
|
||||
|
@ -381,12 +376,12 @@ public class TestsMake extends Module {
|
|||
} else {
|
||||
score.setTextColor(Color.BLACK);
|
||||
}
|
||||
|
||||
|
||||
score.setText(df.format(questionScore));
|
||||
score.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the user answer of a question
|
||||
* @param q Question to read the answer
|
||||
|
@ -398,12 +393,12 @@ public class TestsMake extends Module {
|
|||
int checkedListCount, selectedPos;
|
||||
String answerType, userAnswer;
|
||||
SparseBooleanArray checkedItems;
|
||||
|
||||
|
||||
answerType = q.getAnswerType();
|
||||
if(answerType.equals("text")
|
||||
|| answerType.equals("int")
|
||||
|| answerType.equals("float")) {
|
||||
|
||||
|
||||
la.get(0).setUserAnswer(String.valueOf(textAnswer.getText()));
|
||||
} else if(answerType.equals("multipleChoice")) {
|
||||
checkedItems = testMakeList.getCheckedItemPositions();
|
||||
|
@ -418,11 +413,11 @@ public class TestsMake extends Module {
|
|||
} else {
|
||||
userAnswer = la.get(selectedPos).getAnswer();
|
||||
}
|
||||
|
||||
|
||||
la.get(0).setUserAnswer(userAnswer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shows the test
|
||||
*/
|
||||
|
@ -431,87 +426,87 @@ public class TestsMake extends Module {
|
|||
Button prev, next, eval;
|
||||
ImageView title_separator;
|
||||
final int size = test.getQuestions().size();
|
||||
|
||||
|
||||
setLayout(R.layout.tests_make_questions);
|
||||
prev = (Button) findViewById(R.id.testMakePrevButton);
|
||||
next = (Button) findViewById(R.id.testMakeNextButton);
|
||||
eval = (Button) findViewById(R.id.testEvaluateButton);
|
||||
title_separator = (ImageView) findViewById(R.id.title_sep_2);
|
||||
bar = (TextProgressBar) findViewById(R.id.test_questions_bar);
|
||||
|
||||
|
||||
bar.setMax(size);
|
||||
bar.setProgress(1);
|
||||
bar.setText(1 + "/" + size);
|
||||
bar.setTextColor(Color.BLUE);
|
||||
bar.setTextSize(20);
|
||||
|
||||
eval.setVisibility(View.VISIBLE);
|
||||
title_separator.setVisibility(View.VISIBLE);
|
||||
|
||||
actualQuestion = 0;
|
||||
prev.setOnClickListener(new View.OnClickListener() {
|
||||
bar.setProgress(1);
|
||||
bar.setText(1 + "/" + size);
|
||||
bar.setTextColor(Color.BLUE);
|
||||
bar.setTextSize(20);
|
||||
|
||||
eval.setVisibility(View.VISIBLE);
|
||||
title_separator.setVisibility(View.VISIBLE);
|
||||
|
||||
actualQuestion = 0;
|
||||
prev.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
TestQuestion question = test.getQuestionAndAnswers(actualQuestion);
|
||||
int pos;
|
||||
|
||||
|
||||
if(!test.isEvaluated()) {
|
||||
readUserAnswer(question);
|
||||
}
|
||||
|
||||
|
||||
actualQuestion--;
|
||||
if(actualQuestion < 0) {
|
||||
actualQuestion = size-1;
|
||||
}
|
||||
|
||||
|
||||
pos = actualQuestion+1;
|
||||
|
||||
|
||||
showQuestion(actualQuestion);
|
||||
bar.setProgress(pos);
|
||||
bar.setText(pos + "/" + size);
|
||||
bar.setProgress(pos);
|
||||
bar.setText(pos + "/" + size);
|
||||
}
|
||||
});
|
||||
|
||||
next.setOnClickListener(new View.OnClickListener() {
|
||||
next.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
TestQuestion question = test.getQuestionAndAnswers(actualQuestion);
|
||||
int pos;
|
||||
|
||||
|
||||
if(!test.isEvaluated()) {
|
||||
readUserAnswer(question);
|
||||
}
|
||||
|
||||
|
||||
actualQuestion++;
|
||||
actualQuestion %= size;
|
||||
pos = actualQuestion+1;
|
||||
|
||||
|
||||
showQuestion(actualQuestion);
|
||||
bar.setProgress(pos);
|
||||
bar.setText(pos + "/" + size);
|
||||
bar.setProgress(pos);
|
||||
bar.setText(pos + "/" + size);
|
||||
}
|
||||
});
|
||||
|
||||
showQuestion(0);
|
||||
|
||||
showQuestion(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the test
|
||||
*/
|
||||
private void makeTest() {
|
||||
List<TestQuestion> questions;
|
||||
|
||||
|
||||
//Generates the test
|
||||
questions = dbHelper.getRandomCourseQuestionsByTagAndAnswerType(Global.getSelectedCourseCode(), tagsList, answerTypesList,
|
||||
numQuestions);
|
||||
if(!questions.isEmpty()) {
|
||||
test.setQuestions(questions);
|
||||
|
||||
|
||||
//Shuffles related answers in a question if necessary
|
||||
for(TestQuestion q : questions) {
|
||||
if(q.getShuffle()) {
|
||||
q.shuffleAnswers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Shows the test
|
||||
showTest();
|
||||
} else {
|
||||
|
@ -519,7 +514,7 @@ public class TestsMake extends Module {
|
|||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Launches an action when evaluate button is pushed
|
||||
* @param v Actual view
|
||||
|
@ -531,37 +526,37 @@ public class TestsMake extends Module {
|
|||
Float score, scoreDec;
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
String feedback = test.getFeedback();
|
||||
|
||||
|
||||
readUserAnswer(test.getQuestionAndAnswers(actualQuestion));
|
||||
|
||||
|
||||
setLayout(R.layout.tests_make_results);
|
||||
if(!feedback.equals("nothing")) {
|
||||
if(!test.isEvaluated()) {
|
||||
test.evaluate();
|
||||
evalBt = (Button) findViewById(R.id.testEvaluateButton);
|
||||
sep2 = (ImageView) findViewById(R.id.title_sep_2);
|
||||
|
||||
|
||||
evalBt.setVisibility(View.GONE);
|
||||
sep2.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
score = test.getTotalScore();
|
||||
scoreDec = (score/test.getQuestions().size())*10;
|
||||
|
||||
|
||||
textView = (TextView) findViewById(R.id.testResultsScore);
|
||||
textView.setText(df.format(score) + "/" + test.getQuestions().size() + "\n"
|
||||
+ df.format(scoreDec) + "/10");
|
||||
|
||||
|
||||
if(scoreDec < 5) {
|
||||
textView.setTextColor(getResources().getColor(R.color.red));
|
||||
}
|
||||
|
||||
|
||||
bt = (Button) findViewById(R.id.testResultsButton);
|
||||
if(feedback.equals("totalResult")) {
|
||||
bt.setEnabled(false);
|
||||
bt.setText(R.string.testNoDetailsMsg);
|
||||
}
|
||||
|
||||
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
bt.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -569,7 +564,7 @@ public class TestsMake extends Module {
|
|||
textView.setText(R.string.testNoResultsMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Launches an action when show results details button is pushed
|
||||
* @param v Actual view
|
||||
|
@ -577,7 +572,7 @@ public class TestsMake extends Module {
|
|||
public void onShowResultsDetailsClick(View v) {
|
||||
Button evalBt, resBt;
|
||||
ImageView sep2, sep3;
|
||||
|
||||
|
||||
showTest();
|
||||
|
||||
evalBt = (Button) findViewById(R.id.testEvaluateButton);
|
||||
|
@ -602,13 +597,13 @@ public class TestsMake extends Module {
|
|||
tagsAnswersTypeItemClickListener = new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position,
|
||||
long id) {
|
||||
|
||||
|
||||
CheckedTextView chk = (CheckedTextView) v;
|
||||
ListView lv = (ListView) parent;
|
||||
int childCount = lv.getCount();
|
||||
SparseBooleanArray checkedItems = lv.getCheckedItemPositions();
|
||||
boolean allChecked = true;
|
||||
|
||||
|
||||
if(position == 0) {
|
||||
for(int i=1; i<childCount; i++) {
|
||||
lv.setItemChecked(i, !chk.isChecked());
|
||||
|
@ -619,7 +614,7 @@ public class TestsMake extends Module {
|
|||
allChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (allChecked) {
|
||||
lv.setItemChecked(0, true);
|
||||
} else if(chk.isChecked()) {
|
||||
|
@ -628,11 +623,11 @@ public class TestsMake extends Module {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
tfAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
|
||||
tfAdapter.add(getString(R.string.trueMsg));
|
||||
tfAdapter.add(getString(R.string.falseMsg));
|
||||
|
||||
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
|
||||
|
@ -643,7 +638,7 @@ public class TestsMake extends Module {
|
|||
protected void onStart() {
|
||||
Course c;
|
||||
int lastCourseSelected;
|
||||
|
||||
|
||||
super.onStart();
|
||||
prefs.getPreferences(getBaseContext());
|
||||
String selection ="id=" + Long.toString(Global.getSelectedCourseCode());
|
||||
|
@ -653,10 +648,10 @@ public class TestsMake extends Module {
|
|||
if(isDebuggable) {
|
||||
Log.d(TAG, "selectedCourseCode = " + Long.toString(Global.getSelectedCourseCode()));
|
||||
}
|
||||
|
||||
|
||||
test = (Test) dbHelper.getRow(Global.DB_TABLE_TEST_CONFIG, "id",
|
||||
Long.toString(Global.getSelectedCourseCode()));
|
||||
|
||||
|
||||
if(test != null) {
|
||||
setNumQuestions();
|
||||
} else {
|
||||
|
@ -667,7 +662,7 @@ public class TestsMake extends Module {
|
|||
Toast.makeText(getBaseContext(), R.string.testNoQuestionsMsg, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -675,8 +670,8 @@ public class TestsMake extends Module {
|
|||
*/
|
||||
@Override
|
||||
protected void requestService() throws NoSuchAlgorithmException,
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
}
|
||||
|
||||
|
@ -695,7 +690,7 @@ public class TestsMake extends Module {
|
|||
protected void postConnect() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onError()
|
||||
*/
|
||||
|
|
|
@ -39,30 +39,30 @@ import es.ugr.swad.swadroid.model.Test;
|
|||
import es.ugr.swad.swadroid.model.TestAnswer;
|
||||
import es.ugr.swad.swadroid.model.TestQuestion;
|
||||
import es.ugr.swad.swadroid.model.TestTag;
|
||||
import es.ugr.swad.swadroid.model.User;
|
||||
import es.ugr.swad.swadroid.modules.Module;
|
||||
|
||||
/**
|
||||
* Tests module for download and update questions
|
||||
* @author Juan Miguel Boyero Corral <juanmi1982@gmail.com>
|
||||
* @author Antonio Aguilera Malagon <aguilerin@gmail.com>
|
||||
*/
|
||||
public class TestsQuestionsDownload extends Module {
|
||||
/**
|
||||
* Next timestamp to be requested
|
||||
*/
|
||||
private Long timestamp;
|
||||
/**
|
||||
* Tests tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " TestsQuestionsDownload";
|
||||
|
||||
/**
|
||||
* Tests tag name for Logcat
|
||||
*/
|
||||
public static final String TAG = Global.APP_TAG + " TestsQuestionsDownload";
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onCreate(android.os.Bundle)
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setMETHOD_NAME("getTests");
|
||||
setMETHOD_NAME("getTests");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -80,147 +80,147 @@ public class TestsQuestionsDownload extends Module {
|
|||
*/
|
||||
@Override
|
||||
protected void requestService() throws NoSuchAlgorithmException,
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("wsKey", User.getWsKey());
|
||||
addParam("courseCode", (int)Global.getSelectedCourseCode());
|
||||
addParam("beginTime", timestamp);
|
||||
sendRequest(Test.class, false);
|
||||
IOException, XmlPullParserException, SoapFault,
|
||||
IllegalAccessException, InstantiationException {
|
||||
|
||||
if (result != null) {
|
||||
//Stores tests data returned by webservice response
|
||||
//Creates webservice request, adds required params and sends request to webservice
|
||||
createRequest();
|
||||
addParam("wsKey", Global.getLoggedUser().getWsKey());
|
||||
addParam("courseCode", (int)Global.getSelectedCourseCode());
|
||||
addParam("beginTime", timestamp);
|
||||
sendRequest(Test.class, false);
|
||||
|
||||
if (result != null) {
|
||||
//Stores tests data returned by webservice response
|
||||
Vector<?> res = (Vector<?>) result;
|
||||
|
||||
SoapObject tagsListObject = (SoapObject)res.get(0);
|
||||
SoapObject questionsListObject = (SoapObject)res.get(1);
|
||||
SoapObject answersListObject = (SoapObject)res.get(2);
|
||||
SoapObject questionTagsListObject = (SoapObject)res.get(3);
|
||||
List<TestTag> tagsList = new ArrayList<TestTag>();
|
||||
List<Model> tagsListDB = dbHelper.getAllRows(Global.DB_TABLE_TEST_TAGS);
|
||||
List<Model> questionsListDB = dbHelper.getAllRows(Global.DB_TABLE_TEST_QUESTIONS);
|
||||
List<Model> answersListDB = dbHelper.getAllRows(Global.DB_TABLE_TEST_ANSWERS);
|
||||
|
||||
//Read tags info from webservice response
|
||||
int listSize = tagsListObject.getPropertyCount();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
SoapObject pii = (SoapObject)tagsListObject.getProperty(i);
|
||||
Integer tagCod = new Integer(pii.getProperty("tagCode").toString());
|
||||
String tagTxt = pii.getProperty("tagText").toString();
|
||||
TestTag tag = new TestTag(tagCod, null, tagTxt, 0);
|
||||
tagsList.add(tag);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, tag.toString());
|
||||
}
|
||||
|
||||
SoapObject tagsListObject = (SoapObject)res.get(0);
|
||||
SoapObject questionsListObject = (SoapObject)res.get(1);
|
||||
SoapObject answersListObject = (SoapObject)res.get(2);
|
||||
SoapObject questionTagsListObject = (SoapObject)res.get(3);
|
||||
List<TestTag> tagsList = new ArrayList<TestTag>();
|
||||
List<Model> tagsListDB = dbHelper.getAllRows(Global.DB_TABLE_TEST_TAGS);
|
||||
List<Model> questionsListDB = dbHelper.getAllRows(Global.DB_TABLE_TEST_QUESTIONS);
|
||||
List<Model> answersListDB = dbHelper.getAllRows(Global.DB_TABLE_TEST_ANSWERS);
|
||||
|
||||
//Read tags info from webservice response
|
||||
int listSize = tagsListObject.getPropertyCount();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
SoapObject pii = (SoapObject)tagsListObject.getProperty(i);
|
||||
Integer tagCod = new Integer(pii.getProperty("tagCode").toString());
|
||||
String tagTxt = pii.getProperty("tagText").toString();
|
||||
TestTag tag = new TestTag(tagCod, null, tagTxt, 0);
|
||||
tagsList.add(tag);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, tag.toString());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Retrieved " + listSize + " tags");
|
||||
|
||||
|
||||
//Read questions info from webservice response
|
||||
dbHelper.beginTransaction();
|
||||
|
||||
listSize = questionsListObject.getPropertyCount();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
SoapObject pii = (SoapObject)questionsListObject.getProperty(i);
|
||||
Integer qstCod = new Integer(pii.getProperty("questionCode").toString());
|
||||
String anstype = pii.getProperty("answerType").toString();
|
||||
Integer shuffle = new Integer(pii.getProperty("shuffle").toString());
|
||||
String stem = pii.getProperty("stem").toString();
|
||||
TestQuestion q = new TestQuestion(qstCod, stem, anstype, Global.parseIntBool(shuffle));
|
||||
|
||||
//If it's a new question, insert in database
|
||||
try {
|
||||
dbHelper.insertTestQuestion(q, Global.getSelectedCourseCode());
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "INSERTED: " + q.toString());
|
||||
|
||||
//If it's an updated question, update it's row in database
|
||||
} catch (SQLException e) {
|
||||
TestQuestion old = (TestQuestion) questionsListDB.get(questionsListDB.indexOf(q));
|
||||
dbHelper.updateTestQuestion(old, q, Global.getSelectedCourseCode());
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "UPDATED: " + q.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
listSize = questionsListObject.getPropertyCount();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
SoapObject pii = (SoapObject)questionsListObject.getProperty(i);
|
||||
Integer qstCod = new Integer(pii.getProperty("questionCode").toString());
|
||||
String anstype = pii.getProperty("answerType").toString();
|
||||
Integer shuffle = new Integer(pii.getProperty("shuffle").toString());
|
||||
String stem = pii.getProperty("stem").toString();
|
||||
TestQuestion q = new TestQuestion(qstCod, stem, anstype, Global.parseIntBool(shuffle));
|
||||
|
||||
//If it's a new question, insert in database
|
||||
try {
|
||||
dbHelper.insertTestQuestion(q, Global.getSelectedCourseCode());
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "INSERTED: " + q.toString());
|
||||
|
||||
//If it's an updated question, update it's row in database
|
||||
} catch (SQLException e) {
|
||||
TestQuestion old = (TestQuestion) questionsListDB.get(questionsListDB.indexOf(q));
|
||||
dbHelper.updateTestQuestion(old, q, Global.getSelectedCourseCode());
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "UPDATED: " + q.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(TAG, "Retrieved " + listSize + " questions");
|
||||
|
||||
|
||||
//Read answers info from webservice response
|
||||
listSize = answersListObject.getPropertyCount();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
SoapObject pii = (SoapObject)answersListObject.getProperty(i);
|
||||
Integer qstCod = new Integer(pii.getProperty("questionCode").toString());
|
||||
Integer ansIndex = new Integer(pii.getProperty("answerIndex").toString());
|
||||
Integer correct = new Integer(pii.getProperty("correct").toString());
|
||||
String answer = pii.getProperty("answerText").toString();
|
||||
TestAnswer a = new TestAnswer(0, ansIndex, qstCod, Global.parseIntBool(correct), answer);
|
||||
|
||||
//If it's a new answer, insert in database
|
||||
try {
|
||||
dbHelper.insertTestAnswer(a, qstCod);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "INSERTED: " + a.toString());
|
||||
|
||||
//If it's an updated answer, update it's row in database
|
||||
} catch (SQLException e) {
|
||||
TestAnswer old = (TestAnswer) answersListDB.get(answersListDB.indexOf(a));
|
||||
dbHelper.updateTestAnswer(old, a, qstCod);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "UPDATED: " + a.toString());
|
||||
}
|
||||
}
|
||||
|
||||
listSize = answersListObject.getPropertyCount();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
SoapObject pii = (SoapObject)answersListObject.getProperty(i);
|
||||
Integer qstCod = new Integer(pii.getProperty("questionCode").toString());
|
||||
Integer ansIndex = new Integer(pii.getProperty("answerIndex").toString());
|
||||
Integer correct = new Integer(pii.getProperty("correct").toString());
|
||||
String answer = pii.getProperty("answerText").toString();
|
||||
TestAnswer a = new TestAnswer(0, ansIndex, qstCod, Global.parseIntBool(correct), answer);
|
||||
|
||||
//If it's a new answer, insert in database
|
||||
try {
|
||||
dbHelper.insertTestAnswer(a, qstCod);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "INSERTED: " + a.toString());
|
||||
|
||||
//If it's an updated answer, update it's row in database
|
||||
} catch (SQLException e) {
|
||||
TestAnswer old = (TestAnswer) answersListDB.get(answersListDB.indexOf(a));
|
||||
dbHelper.updateTestAnswer(old, a, qstCod);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "UPDATED: " + a.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(TAG, "Retrieved " + listSize + " answers");
|
||||
|
||||
|
||||
//Read relationships between questions and tags from webservice response
|
||||
listSize = questionTagsListObject.getPropertyCount();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
SoapObject pii = (SoapObject)questionTagsListObject.getProperty(i);
|
||||
Integer qstCod = new Integer(pii.getProperty("questionCode").toString());
|
||||
Integer tagCod = new Integer(pii.getProperty("tagCode").toString());
|
||||
Integer tagIndex = new Integer(pii.getProperty("tagIndex").toString());
|
||||
TestTag tag = tagsList.get(tagsList.indexOf(new TestTag(tagCod, "", 0)));
|
||||
tag.addQstCod(qstCod);
|
||||
tag.setTagInd(tagIndex);
|
||||
listSize = questionTagsListObject.getPropertyCount();
|
||||
for (int i = 0; i < listSize; i++) {
|
||||
SoapObject pii = (SoapObject)questionTagsListObject.getProperty(i);
|
||||
Integer qstCod = new Integer(pii.getProperty("questionCode").toString());
|
||||
Integer tagCod = new Integer(pii.getProperty("tagCode").toString());
|
||||
Integer tagIndex = new Integer(pii.getProperty("tagIndex").toString());
|
||||
TestTag tag = tagsList.get(tagsList.indexOf(new TestTag(tagCod, "", 0)));
|
||||
tag.addQstCod(qstCod);
|
||||
tag.setTagInd(tagIndex);
|
||||
|
||||
//If it's a new tag, insert in database
|
||||
try {
|
||||
dbHelper.insertTestTag(tag);
|
||||
tagsListDB.add(tag);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "INSERTED: " + tag.toString());
|
||||
//If it's a new tag, insert in database
|
||||
try {
|
||||
dbHelper.insertTestTag(tag);
|
||||
tagsListDB.add(tag);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "INSERTED: " + tag.toString());
|
||||
|
||||
//If it's an updated tag, update it's rows in database
|
||||
} catch (SQLException e) {
|
||||
TestTag old = (TestTag) tagsListDB.get(tagsListDB.indexOf(tag));
|
||||
tag.setQstCodList(old.getQstCodList());
|
||||
tag.addQstCod(qstCod);
|
||||
dbHelper.updateTestTag(old, tag);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "UPDATED: " + tag.toString());
|
||||
}
|
||||
}
|
||||
|
||||
//If it's an updated tag, update it's rows in database
|
||||
} catch (SQLException e) {
|
||||
TestTag old = (TestTag) tagsListDB.get(tagsListDB.indexOf(tag));
|
||||
tag.setQstCodList(old.getQstCodList());
|
||||
tag.addQstCod(qstCod);
|
||||
dbHelper.updateTestTag(old, tag);
|
||||
|
||||
if(isDebuggable)
|
||||
Log.d(TAG, "UPDATED: " + tag.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(TAG, "Retrieved " + listSize + " relationships between questions and tags");
|
||||
|
||||
|
||||
//Update last time test was updated
|
||||
Test oldTestConfigDB = (Test) dbHelper.getRow(Global.DB_TABLE_TEST_CONFIG, "id", Long.toString(Global.getSelectedCourseCode()));
|
||||
Test testConfig = oldTestConfigDB;
|
||||
testConfig.setEditTime(System.currentTimeMillis() / 1000L);
|
||||
dbHelper.updateTestConfig(oldTestConfigDB, testConfig);
|
||||
dbHelper.endTransaction();
|
||||
}
|
||||
|
||||
//Request finalized without errors
|
||||
setResult(RESULT_OK);
|
||||
dbHelper.endTransaction();
|
||||
}
|
||||
|
||||
//Request finalized without errors
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -229,9 +229,9 @@ public class TestsQuestionsDownload extends Module {
|
|||
@Override
|
||||
protected void connect() {
|
||||
String progressDescription = getString(R.string.testsDownloadProgressDescription);
|
||||
int progressTitle = R.string.testsDownloadProgressTitle;
|
||||
|
||||
new Connect(true, progressDescription, progressTitle).execute();
|
||||
int progressTitle = R.string.testsDownloadProgressTitle;
|
||||
|
||||
new Connect(true, progressDescription, progressTitle).execute();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -240,9 +240,9 @@ public class TestsQuestionsDownload extends Module {
|
|||
@Override
|
||||
protected void postConnect() {
|
||||
Toast.makeText(this, R.string.questionsTestsDownloadSuccesfulMsg, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see es.ugr.swad.swadroid.modules.Module#onError()
|
||||
*/
|
||||
|
|