diff --git a/source/EduCATS.UnitTests/Data/DataAccessTests.cs b/source/EduCATS.UnitTests/Data/DataAccessTests.cs index b664d63d..61dae96b 100644 --- a/source/EduCATS.UnitTests/Data/DataAccessTests.cs +++ b/source/EduCATS.UnitTests/Data/DataAccessTests.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using EduCATS.Constants; using EduCATS.Data; +using EduCATS.Demo; using EduCATS.Helpers.Forms; using MonkeyCache.FileStore; using Moq; @@ -65,12 +66,21 @@ public void CheckConnectionTest() var dataAccess = new DataAccess(_message, null, "3", _mockedConnected); var actual = dataAccess.CheckConnectionEstablished(); Assert.AreEqual(true, actual); + AppDemo.Instance.IsDemoAccount = true; + var demoActual = dataAccess.CheckConnectionEstablished(); + Assert.AreEqual(true, actual); + var dataAccessOffline = new DataAccess(_message, null, "4", _mockedOffline); + var demoOfflineActual = dataAccessOffline.CheckConnectionEstablished(); + Assert.AreEqual(true, demoOfflineActual); + AppDemo.Instance.IsDemoAccount = false; + var offlineActual = dataAccessOffline.CheckConnectionEstablished(); + Assert.AreEqual(false, offlineActual); } [Test] public async Task GetSingleNoConnectionTest() { - var dataAccess = new DataAccess(_message, null, "4", _mockedOffline); + var dataAccess = new DataAccess(_message, null, "5", _mockedOffline); var actual = await dataAccess.GetSingle(); Assert.IsNotNull(actual); } @@ -78,7 +88,7 @@ public async Task GetSingleNoConnectionTest() [Test] public async Task GetListNoConnectionTest() { - var dataAccess = new DataAccess(_message, null, "5", _mockedOffline); + var dataAccess = new DataAccess(_message, null, "6", _mockedOffline); var actual = await dataAccess.GetList(); Assert.IsNotNull(actual); } @@ -97,7 +107,7 @@ public void ResetDataTest() [Test] public async Task GetDataSingleObjectTest() { - var dataAccess = new DataAccess(_message, null, "6", _mockedConnected); + var dataAccess = new DataAccess(_message, null, "7", _mockedConnected); var data = await DataAccess.GetDataObject(dataAccess, false); Assert.NotNull(data); } @@ -105,7 +115,7 @@ public async Task GetDataSingleObjectTest() [Test] public async Task GetDataListObjectTest() { - var dataAccess = new DataAccess(_message, null, "7", _mockedConnected); + var dataAccess = new DataAccess(_message, null, "8", _mockedConnected); var data = await DataAccess.GetDataObject(dataAccess, true); Assert.NotNull(data); } @@ -154,7 +164,7 @@ public void SetErrorTest() [Test] public void GetListAccessValidJsonTest() { - var dataAccess = new DataAccess(_message, null, "8", _mockedConnected); + var dataAccess = new DataAccess(_message, null, "9", _mockedConnected); var kvp = new KeyValuePair("[ { \"data\": \"test\" } ]", HttpStatusCode.OK); var actual = dataAccess.GetListAccess(kvp); Assert.NotNull(actual); @@ -163,7 +173,7 @@ public void GetListAccessValidJsonTest() [Test] public void GetListAccessNonValidJsonTest() { - var dataAccess = new DataAccess(_message, null, "9", _mockedConnected); + var dataAccess = new DataAccess(_message, null, "10", _mockedConnected); var kvp = new KeyValuePair("response", HttpStatusCode.OK); var actual = dataAccess.GetListAccess(kvp); Assert.AreEqual(null, actual); @@ -172,7 +182,7 @@ public void GetListAccessNonValidJsonTest() [Test] public void GetListAccessSuccessJsonTest() { - var dataAccess = new DataAccess(_message, null, "10", _mockedConnected); + var dataAccess = new DataAccess(_message, null, "11", _mockedConnected); var kvp = new KeyValuePair(_nonJsonSuccessResponse, HttpStatusCode.OK); var actual = dataAccess.GetListAccess(kvp); Assert.AreEqual(string.Empty, actual); @@ -181,7 +191,7 @@ public void GetListAccessSuccessJsonTest() [Test] public void GetSingleAccessValidJsonTest() { - var dataAccess = new DataAccess(_message, null, "11", _mockedConnected); + var dataAccess = new DataAccess(_message, null, "12", _mockedConnected); var kvp = new KeyValuePair("{ \"data\": \"test\" }", HttpStatusCode.OK); var actual = dataAccess.GetAccess(kvp); Assert.NotNull(actual); @@ -190,7 +200,7 @@ public void GetSingleAccessValidJsonTest() [Test] public void GetSingleAccessNonValidJsonTest() { - var dataAccess = new DataAccess(_message, null, "12", _mockedConnected); + var dataAccess = new DataAccess(_message, null, "13", _mockedConnected); var kvp = new KeyValuePair("response", HttpStatusCode.OK); var actual = dataAccess.GetAccess(kvp); Assert.AreEqual(null, actual); @@ -199,7 +209,7 @@ public void GetSingleAccessNonValidJsonTest() [Test] public void GetSingleAccessSuccessJsonTest() { - var dataAccess = new DataAccess(_message, null, "13", _mockedConnected); + var dataAccess = new DataAccess(_message, null, "14", _mockedConnected); var kvp = new KeyValuePair(_nonJsonSuccessResponse, HttpStatusCode.OK); var actual = dataAccess.GetAccess(kvp); Assert.NotNull(actual); diff --git a/source/EduCATS/Data/DataAccessHelper.cs b/source/EduCATS/Data/DataAccessHelper.cs index 46af5917..a7939cd5 100644 --- a/source/EduCATS/Data/DataAccessHelper.cs +++ b/source/EduCATS/Data/DataAccessHelper.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using EduCATS.Data.Caching; using EduCATS.Data.Interfaces; +using EduCATS.Demo; using EduCATS.Helpers.Forms; using EduCATS.Helpers.Json; @@ -282,6 +283,10 @@ static void setCallback(Task callback) /// True if established. public virtual bool CheckConnectionEstablished() { + if (AppDemo.Instance.IsDemoAccount) { + return true; + } + return _services.Device.CheckConnectivity(); } } diff --git a/source/EduCATS/Demo/AppDemoType.cs b/source/EduCATS/Demo/AppDemoType.cs index 9daec5d4..abaaf461 100644 --- a/source/EduCATS/Demo/AppDemoType.cs +++ b/source/EduCATS/Demo/AppDemoType.cs @@ -7,7 +7,10 @@ public enum AppDemoType None, AvailableTests, ConceptTree, + ConceptTreeTest, Files, + FilesTest, + FilesDetailsTest, InfoLecturers, Labs, LabsResults, @@ -17,12 +20,15 @@ public enum AppDemoType ProfileInfo, ProfileInfoCalendar, ProfileInfoSubjects, + ProfileInfoSubjectsTest, Recommendations, RootConcepts, + Schedule, Statistics, Test, TestAnswerAndGetNext, TestNextQuestion, - TestUserAnswers + TestUserAnswers, + TestUserAnswersExtended } } diff --git a/source/EduCATS/Demo/DemoResources/demoConceptTreeTest.json b/source/EduCATS/Demo/DemoResources/demoConceptTreeTest.json new file mode 100644 index 00000000..b919695d --- /dev/null +++ b/source/EduCATS/Demo/DemoResources/demoConceptTreeTest.json @@ -0,0 +1,84 @@ +{ + "Concept": { + "Container": null, + "FilePath": null, + "HasData": false, + "Id": 1, + "IsGroup": true, + "Name": "Демонстрационный ЭУМК", + "Next": null, + "ParentId": 0, + "Prev": null, + "Published": true, + "ReadOnly": false, + "ShortName": "Демо ЭУМК", + "SubjectName": "Предмет #1", + "children": [ + { + "Container": "Container", + "FilePath": "\/UploadedFiles\/Id\/Id.pdf", + "HasData": true, + "Id": 2, + "IsGroup": false, + "Name": "Документ #1", + "Next": 3, + "ParentId": 1, + "Prev": null, + "Published": true, + "ReadOnly": true, + "ShortName": "Документ #1", + "SubjectName": "Предмет #1", + "children": [] + }, + { + "Container": "Container", + "FilePath": "\/UploadedFiles\/Id\/Id.pdf", + "HasData": true, + "Id": 3, + "IsGroup": false, + "Name": "Документ #2", + "Next": 4, + "ParentId": 1, + "Prev": 2, + "Published": true, + "ReadOnly": true, + "ShortName": "Документ #2", + "SubjectName": "Предмет #1", + "children": [] + }, + { + "Container": null, + "FilePath": null, + "HasData": false, + "Id": 4, + "IsGroup": true, + "Name": "Демонстрационный раздел", + "Next": null, + "ParentId": 1, + "Prev": 3, + "Published": false, + "ReadOnly": true, + "ShortName": "Демонстрационный раздел", + "SubjectName": "Предмет #1", + "children": [ + { + "Container": "Container", + "FilePath": "\/UploadedFiles\/Id\/Id.pdf", + "HasData": true, + "Id": 5, + "IsGroup": false, + "Name": "Документ #3", + "Next": null, + "ParentId": 4, + "Prev": null, + "Published": true, + "ReadOnly": true, + "ShortName": "Документ #3", + "SubjectName": "Предмет #1", + "children": [] + } + ] + } + ] + } +} diff --git a/source/EduCATS/Demo/DemoResources/demoFilesDetailsTest.json b/source/EduCATS/Demo/DemoResources/demoFilesDetailsTest.json new file mode 100644 index 00000000..d902ea04 --- /dev/null +++ b/source/EduCATS/Demo/DemoResources/demoFilesDetailsTest.json @@ -0,0 +1,10 @@ +[ + { + "IdFile": 1, + "Size": 1000000 + }, + { + "IdFile": 2, + "Size": 500000 + } +] diff --git a/source/EduCATS/Demo/DemoResources/demoFilesTest.json b/source/EduCATS/Demo/DemoResources/demoFilesTest.json new file mode 100644 index 00000000..8f400d17 --- /dev/null +++ b/source/EduCATS/Demo/DemoResources/demoFilesTest.json @@ -0,0 +1,18 @@ +{ + "Attachment": [ + { + "Id": 1, + "Name": "Демонстрационный файл #1", + "FileName": "Демонстрационный файл #1.docx", + "PathName": "Path", + "Size": 1000000 + }, + { + "Id": 2, + "Name": "Демонстрационный файл #2", + "FileName": "Демонстрационный файл #2.docx", + "PathName": "Path", + "Size": 500000 + } + ] +} diff --git a/source/EduCATS/Demo/DemoResources/demoProfileInfoSubjectsTest.json b/source/EduCATS/Demo/DemoResources/demoProfileInfoSubjectsTest.json new file mode 100644 index 00000000..9b124ba4 --- /dev/null +++ b/source/EduCATS/Demo/DemoResources/demoProfileInfoSubjectsTest.json @@ -0,0 +1,18 @@ +{ + "Subjects": [ + { + "Name": "Предмет #1", + "Id": 1, + "ShortName": "П1", + "Color": "#BF0606", + "Completing": 0 + }, + { + "Name": "Предмет #2", + "Id": 2, + "ShortName": "П2", + "Color": "#06BF09", + "Completing": 0 + } + ] +} diff --git a/source/EduCATS/Demo/DemoResources/demoSchedule.json b/source/EduCATS/Demo/DemoResources/demoSchedule.json new file mode 100644 index 00000000..56fe56ab --- /dev/null +++ b/source/EduCATS/Demo/DemoResources/demoSchedule.json @@ -0,0 +1,28 @@ +{ + "Schedule": [ + { + "Audience": "1", + "Building": "1", + "Color": "#BF0606", + "Start": "15:00", + "End": "16:00", + "Name": "Лабораторная работа", + "Teacher": { + "FullName": "Фамилия Имя Отчество" + }, + "Type": 2 + }, + { + "Audience": "2", + "Building": "2", + "Color": "#06BF09", + "Start": "10:00", + "End": "11:00", + "Name": "Лекция", + "Teacher": { + "FullName": "Фамилия Имя" + }, + "Type": 0 + } + ] +} diff --git a/source/EduCATS/Demo/DemoResources/demoTestUserAnswersExtended.json b/source/EduCATS/Demo/DemoResources/demoTestUserAnswersExtended.json new file mode 100644 index 00000000..d014692e --- /dev/null +++ b/source/EduCATS/Demo/DemoResources/demoTestUserAnswersExtended.json @@ -0,0 +1,64 @@ +{ + "ContentEncoding": null, + "ContentType": null, + "Data": [ + { + "Key": "TestName", + "Value": "Демонстрационный тест" + }, + { + "Key": "Percent", + "Value": 33 + }, + { + "Key": "Mark", + "Value": 3 + }, + { + "Key": "Answers", + "Value": [ + { + "QuestionTitle": "Демонстрационный вопрос #1", + "QuestionDescription": null, + "Points": 0, + "AnswerString": "4", + "Number": 1 + }, + { + "QuestionTitle": "Демонстрационный вопрос #2", + "QuestionDescription": null, + "Points": 1, + "AnswerString": "2", + "Number": 2 + } + ] + }, + { + "Key": "Thems", + "Value": [] + }, + { + "Key": "NeuralData", + "Value": null + }, + { + "Key": "FoNN", + "Value": false + }, + { + "Key": "StartTime", + "Value": "\/Date(1682608647420)\/" + }, + { + "Key": "EndTime", + "Value": "\/Date(1682608703857)\/" + }, + { + "Key": "Comment", + "Value": null + } + ], + "JsonRequestBehavior": 0, + "MaxJsonLength": 2147483647, + "RecursionLimit": null +} diff --git a/source/EduCATS/EduCATS.csproj b/source/EduCATS/EduCATS.csproj index cef88029..6dcc0708 100644 --- a/source/EduCATS/EduCATS.csproj +++ b/source/EduCATS/EduCATS.csproj @@ -209,6 +209,12 @@ + + + + + + @@ -254,5 +260,11 @@ + + + + + + \ No newline at end of file diff --git a/source/EduCATS/Helpers/Forms/Settings/AppPrefs.cs b/source/EduCATS/Helpers/Forms/Settings/AppPrefs.cs index 7922b45a..218a4138 100644 --- a/source/EduCATS/Helpers/Forms/Settings/AppPrefs.cs +++ b/source/EduCATS/Helpers/Forms/Settings/AppPrefs.cs @@ -267,14 +267,16 @@ public void ResetPrefs() var fontPrefs = Font; var themePrefs = Theme; var isLargeFont = IsLargeFont; - var accsessToken = AccessToken; + var accessToken = AccessToken; + var server = Server; Preferences.Clear(); Font = fontPrefs; Theme = themePrefs; IsLargeFont = isLargeFont; - AccessToken = accsessToken; + AccessToken = accessToken; + Server = server; } } } diff --git a/source/EduCATS/Localization/be.json b/source/EduCATS/Localization/be.json index efbbad1f..5ab66ed7 100644 --- a/source/EduCATS/Localization/be.json +++ b/source/EduCATS/Localization/be.json @@ -11,6 +11,7 @@ "base_unexpected_error": "Адбылася неспадзяваная памылка. Калі ласка, паспрабуйце яшчэ раз ці звярніцеся ў службу падтрымкі. Магчыма тэрмін дзеяння токена скончыўся, калі ласка перезайдите ў дадатак.", "base_connection_error": "Адсутнічае злучэнне з інтэрнэтам. Праверце налады ў сетцы і паспрабуйце зноў", "base_no_data": "Адсутнічаюць даныя для адлюстравання", + "base_something_went_wrong": "Нешта пайшло не так. Паўтарыце спробу або звярніцеся ў службу падтрымкі.", "contributor_ilya_lehchylin": "Ілля Легчылін", "contributor_julia_popova": "Юлія Папова", @@ -40,7 +41,7 @@ "login_loading": "Уваход у сістэму...", "login_profile_loading": "Атрыманне даных профіля...", "login_empty_credentials_error": "Патрэбныя імя карыстальніка і пароль", - "login_error": "Не атрымалася ўвайсці ў сістэму. Калі ласка праверце ўведзеныя даныя.", + "login_error": "Не атрымалася ўвайсці ў сістэму. Калі ласка, праверце свае ўліковыя даныя.", "login_user_profile_error": "Здарылася памылка падчас атрымання даных профіля. Калі ласка паспрабуйце яшчэ раз альбо звярніцеся ў службу падтрымкі.", "login_user_profile_not_verify": "Ваш акаўнт не пацверджаны. Звяжыцеся са сваім настаўнікам, каб пацвердзіць свой уліковы запіс.", diff --git a/source/EduCATS/Localization/de.json b/source/EduCATS/Localization/de.json index f10fc261..87e7db75 100644 --- a/source/EduCATS/Localization/de.json +++ b/source/EduCATS/Localization/de.json @@ -11,6 +11,7 @@ "base_unexpected_error": "Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es erneut oder Kontaktieren Sie den Support. Der Token ist möglicherweise abgelaufen, bitte geben Sie die Anwendung erneut ein.", "base_connection_error": "Keine Internetverbindung. Überprüfen Sie die Netzwerkeinstellungen und versuchen Sie es erneut.", "base_no_data": "Keine Daten angezeigt werden", + "base_something_went_wrong": "Etwas ist schief gelaufen. Bitte versuchen Sie es erneut oder wenden Sie sich an den Support.", "contributor_ilya_lehchylin": "Ilya Legtschilin", "contributor_julia_popova": "Yuliya Popova", @@ -40,7 +41,7 @@ "login_loading": "Anmeldung...", "login_profile_loading": "Profildaten wird angeruft...", "login_empty_credentials_error": "Benutzername und Passwort sind erforderlich.", - "login_error": "Anmeldung fehlschlagen. Bitte, uberprufen Sie die eingegebenen Daten.", + "login_error": "Anmeldung am System nicht möglich. Bitte überprüfen Sie Ihre Anmeldedaten.", "login_user_profile_error": "Fehler beim abrufen von Profildaten. Bitte versuchen Sie es erneut oder Kontaktieren Sie den Support.", "login_user_profile_not_verify": "Ihr Konto wurde nicht verifiziert. Wenden Sie sich an Ihren Lehrer, um Ihr Konto zu verifizieren.", diff --git a/source/EduCATS/Localization/en.json b/source/EduCATS/Localization/en.json index 67018ecb..45b5081e 100644 --- a/source/EduCATS/Localization/en.json +++ b/source/EduCATS/Localization/en.json @@ -11,6 +11,7 @@ "base_unexpected_error": "Unexpected error occurred. Please try again or contact support. May be the token has expired, please re-enter the application.", "base_connection_error": "No internet connection. Check your network settings and try again.", "base_no_data": "No data to display", + "base_something_went_wrong": "Something went wrong. Please try again or contact support.", "contributor_ilya_lehchylin": "Ilya Lehchylin", "contributor_julia_popova": "Julia Popova", @@ -40,7 +41,7 @@ "login_loading": "Signing in...", "login_profile_loading": "Retrieving profile data...", "login_empty_credentials_error": "Username and password are required.", - "login_error": "Invalid login attempt. Please check your credentials.", + "login_error": "Could not log in to the system. Please check your credentials.", "login_user_profile_error": "Error occurred during retrieving profile data. Please try again or contact support.", "login_user_profile_not_verify": "Your account has not been verified. Contact your teacher to confirm your account.", diff --git a/source/EduCATS/Localization/lt.json b/source/EduCATS/Localization/lt.json index f93b2f58..b9e2e9c7 100644 --- a/source/EduCATS/Localization/lt.json +++ b/source/EduCATS/Localization/lt.json @@ -11,6 +11,7 @@ "base_unexpected_error": "Įvyko netikėta klaida. Bandykite dar kartą arba susisiekite su palaikymo tarnyba. Gali būti, kad prieigos raktas nebegalioja. Įveskite programą iš naujo.", "base_connection_error": "Nėra interneto ryšio. Patikrinkite tinklo nustatymus ir bandykite dar kartą.", "base_no_data": "Nėra rodomų duomenų", + "base_something_went_wrong": "Kažkas nutiko. Bandykite dar kartą arba susisiekite su palaikymo komanda.", "contributor_ilya_lehchylin": "Ilya Lehchylin", "contributor_julia_popova": "Julia Popova", @@ -40,7 +41,7 @@ "login_loading": "Prisijungimas prie sistemos...", "login_profile_loading": "Profilio duomenų gavimas...", "login_empty_credentials_error": "Reikalingas vartotojo vardas ir slaptažodis.", - "login_error": "Prisijungimas nepavyko. Patikrinkite įvestus duomenis.", + "login_error": "Nepavyko prisijungti prie sistemos. Patikrinkite savo kredencialus.", "login_user_profile_error": "Gaunant profilio duomenis įvyko klaida. Bandykite dar kartą arba susisiekite su palaikymo tarnyba.", "login_user_profile_not_verify": "Jūsų paskyra nepatvirtinta. Susisiekite su mokytoju, kad patvirtintumėte paskyrą.", diff --git a/source/EduCATS/Localization/pl.json b/source/EduCATS/Localization/pl.json index de5a9bde..e36752ee 100644 --- a/source/EduCATS/Localization/pl.json +++ b/source/EduCATS/Localization/pl.json @@ -11,6 +11,7 @@ "base_unexpected_error": "Wystąpił nieoczekiwany błąd. Spróbuj ponownie lub skontaktuj się z obsługą klienta. Token mógł wygasnąć, prosimy o ponowne wypełnienie wniosku.", "base_connection_error": "Brak połączenia z Internetem. Sprawdź ustawienia sieci i spróbuj ponownie.", "base_no_data": "Brak danych do wyświetlenia", + "base_something_went_wrong": "Coś poszło nie tak. Spróbuj ponownie lub skontaktuj się z pomocą techniczną.", "contributor_ilya_lehchylin": "Ilja Legczilin", "contributor_julia_popova": "Julia Popowa", @@ -40,7 +41,7 @@ "login_loading": "Logowanie...", "login_profile_loading": "Pobieranie danych profilu...", "login_empty_credentials_error": "Wymagana nazwa użytkownika i hasło.", - "login_error": "Nie można się zalogować. Proszę sprawdzić wprowadzone dane.", + "login_error": "Nie można zalogować się do systemu. Sprawdź swoje dane uwierzytelniające.", "login_user_profile_error": "Wystąpił błąd podczas pobierania danych profilu. Spróbuj ponownie lub skontaktuj się z obsługą klienta.", "login_user_profile_not_verify": "Twoje konto nie zostało zweryfikowane. Skontaktuj się ze swoim nauczycielem, aby zweryfikować konto.", "main_today": "Dzisiaj", diff --git a/source/EduCATS/Localization/ru.json b/source/EduCATS/Localization/ru.json index 932a5909..318bb13d 100644 --- a/source/EduCATS/Localization/ru.json +++ b/source/EduCATS/Localization/ru.json @@ -11,6 +11,7 @@ "base_unexpected_error": "Произошла непредвиденная ошибка. Пожалуйста, попробуйте еще раз или обратитесь в службу поддержки. Возможно срок действия токена истек, перезайдите в приложение.", "base_connection_error": "Нет соединения с интернетом. Проверьте настройки сети и попробуйте снова.", "base_no_data": "Нет данных для отображения", + "base_something_went_wrong": "Что-то пошло не так. Повторите попытку или обратитесь в службу поддержки.", "contributor_ilya_lehchylin": "Илья Легчилин", "contributor_julia_popova": "Юлия Попова", @@ -40,7 +41,7 @@ "login_loading": "Вход в систему...", "login_profile_loading": "Получение данных профиля...", "login_empty_credentials_error": "Требуются имя пользователя и пароль.", - "login_error": "Не удалось войти в систему. Пожалуйста, проверьте введенные данные.", + "login_error": "Не удалось войти в систему. Пожалуйста, проверьте свои учетные данные.", "login_user_profile_error": "Произошла ошибка во время получения данных профиля. Пожалуйста, попробуйте еще раз или обратитесь в службу поддержки.", "login_user_profile_not_verify": "Ваш аккаунт не подтвержден. Свяжитесь со своим преподавателем, чтобы подтвердить свою учетную запись.", diff --git a/source/EduCATS/Networking/AppServices/AppServices.cs b/source/EduCATS/Networking/AppServices/AppServices.cs index cd09abfc..4a0c4562 100644 --- a/source/EduCATS/Networking/AppServices/AppServices.cs +++ b/source/EduCATS/Networking/AppServices/AppServices.cs @@ -84,7 +84,7 @@ public static async Task GetProfileInfoSubjects(string username) if (Servers.Current == Servers.EduCatsBntuAddress) return await AppServicesController.Request(Links.GetProfileInfoSubjects, body, AppDemoType.ProfileInfoSubjects); else - return await AppServicesController.Request(Links.GetProfileInfoSubjectsTest, AppDemoType.ProfileInfoSubjects); + return await AppServicesController.Request(Links.GetProfileInfoSubjectsTest, AppDemoType.ProfileInfoSubjectsTest); } /// @@ -115,7 +115,7 @@ public static async Task GetProfileInfoCalendar(string username) /// Calendar data. public static async Task GetSchedule(string date) { - return await AppServicesController.Request(Links.GetSchedule + $"dateStart={date}&dateEnd={date}"); + return await AppServicesController.Request(Links.GetSchedule + $"dateStart={date}&dateEnd={date}", AppDemoType.Schedule); } /// @@ -295,7 +295,7 @@ public static async Task GetUserAnswers(int testId) { return await AppServicesController.Request( $"{Links.GetResultTest}?testId={testId}", - AppDemoType.TestUserAnswers); + AppDemoType.TestUserAnswersExtended); } @@ -342,7 +342,7 @@ public static async Task GetConceptTree(int elementId) public static async Task GetConceptCascade(int elementId) { return await AppServicesController.Request( - $"{Links.GetConceptCascade}?parenttId={elementId}"); + $"{Links.GetConceptCascade}?parenttId={elementId}", AppDemoType.ConceptTreeTest); } @@ -356,7 +356,7 @@ public static async Task GetFiles(int subjectId) if (Servers.Current == Servers.EduCatsBntuAddress) return await AppServicesController.Request($"{Links.GetFiles}?subjectId={subjectId}", AppDemoType.Files); else - return await AppServicesController.Request($"{Links.GetFilesTest}?subjectId={subjectId}", AppDemoType.Files); + return await AppServicesController.Request($"{Links.GetFilesTest}?subjectId={subjectId}", AppDemoType.FilesTest); } /// @@ -377,7 +377,7 @@ public static async Task GetRecommendations(int subjectId, int userId) /// Files data. public static async Task GetFilesDetails(string uri) { - return await AppServicesController.Request($"{Links.GetFilesDetails}?values=[{uri}]&deleteValues=DELETE"); + return await AppServicesController.Request($"{Links.GetFilesDetails}?values=[{uri}]&deleteValues=DELETE", AppDemoType.FilesDetailsTest); } public static async Task GetGroupInfo(string groupName) diff --git a/source/EduCATS/Pages/Login/ViewModels/LoginPageViewModel.cs b/source/EduCATS/Pages/Login/ViewModels/LoginPageViewModel.cs index 1e5588c7..c0083def 100644 --- a/source/EduCATS/Pages/Login/ViewModels/LoginPageViewModel.cs +++ b/source/EduCATS/Pages/Login/ViewModels/LoginPageViewModel.cs @@ -266,7 +266,7 @@ async Task loginCompleted(UserModel user) } else { - _services.Dialogs.ShowError(CrossLocalization.Translate("login_error")); + _services.Dialogs.ShowError(CrossLocalization.Translate("base_something_went_wrong")); } } @@ -321,7 +321,7 @@ async Task loginRequest() { var userLogin = await DataAccess.Login(Username, Password); - if(_services.Preferences.Server == Servers.EduCatsAddress) + if(!AppDemo.Instance.IsDemoAccount && _services.Preferences.Server == Servers.EduCatsAddress) { if (userLogin != null) { @@ -399,6 +399,7 @@ async Task loginRequest() catch (Exception) { } } } + AppUserData.SetLoginData(_services, userLogin.UserId, userLogin.Username); return userLogin; } diff --git a/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs b/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs index 59558e15..94fca362 100644 --- a/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs +++ b/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs @@ -219,6 +219,7 @@ async void delete() void resetData() { + AppDemo.Instance.IsDemoAccount = false; _services.Preferences.ResetPrefs(); AppUserData.Clear(); DataAccess.ResetData(); diff --git a/source/EduCATS/Pages/Settings/Server/ViewModels/ServerPageViewModel.cs b/source/EduCATS/Pages/Settings/Server/ViewModels/ServerPageViewModel.cs index 615a90e9..e575138a 100644 --- a/source/EduCATS/Pages/Settings/Server/ViewModels/ServerPageViewModel.cs +++ b/source/EduCATS/Pages/Settings/Server/ViewModels/ServerPageViewModel.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using EduCATS.Data; using EduCATS.Data.User; +using EduCATS.Demo; using EduCATS.Helpers.Forms; using EduCATS.Helpers.Logs; using EduCATS.Networking; @@ -82,6 +83,7 @@ async Task selectServer(object selectedObject) void changeServer(ServerPageModel server) { + AppDemo.Instance.IsDemoAccount = false; Servers.SetCurrent(server.Address); _services.Preferences.IsLoggedIn = false; AppUserData.Clear(); diff --git a/source/EduCATS/Pages/Today/Base/Models/SubjectPageModel.cs b/source/EduCATS/Pages/Today/Base/Models/SubjectPageModel.cs index 197da181..17579447 100644 --- a/source/EduCATS/Pages/Today/Base/Models/SubjectPageModel.cs +++ b/source/EduCATS/Pages/Today/Base/Models/SubjectPageModel.cs @@ -13,19 +13,56 @@ public class SubjectPageModel : IRoundedListType string _teacherFullName; public string TeacherFullName { - get - { - var surname = _teacherFullName.Split(' ')[0]; - var name = _teacherFullName.Split(' ')[1]; - var patronymic = _teacherFullName.Split(' ')[2]; + get { + var splitted = _teacherFullName.Split(' '); + var surname = ""; + var name = ""; + var patronymic = ""; + var nameFirstLetter = ""; + var patronymicFirstLetter = ""; - return $"{surname} {name[0]}. {patronymic[0]}."; + if (splitted.Length > 2) { + surname = splitted[0]; + name = splitted[1]; + patronymic = splitted[2]; + } else if (splitted.Length < 3 && splitted.Length > 1) { + surname = splitted[0]; + name = splitted[1]; + } else if (splitted.Length == 1) { + surname = splitted[0]; + } + + if (!string.IsNullOrEmpty(name) && name.Length > 0) { + nameFirstLetter = $"{name[0]}"; + } + + if (!string.IsNullOrEmpty(patronymic) && patronymic.Length > 0) { + patronymicFirstLetter = $"{patronymic[0]}"; + } + + if (!string.IsNullOrEmpty(surname) && + !string.IsNullOrEmpty(nameFirstLetter) && + !string.IsNullOrEmpty(patronymicFirstLetter)) { + return $"{surname} {nameFirstLetter}. {patronymicFirstLetter}."; + } else if ( + string.IsNullOrEmpty(patronymicFirstLetter) && + !string.IsNullOrEmpty(surname) && + !string.IsNullOrEmpty(nameFirstLetter)) { + return $"{surname} {nameFirstLetter}."; + } else if ( + string.IsNullOrEmpty(nameFirstLetter) && + string.IsNullOrEmpty(patronymicFirstLetter) && + !string.IsNullOrEmpty(surname)) { + return surname; + } + + return string.Empty; } - set - { + set { _teacherFullName = value; - } + } } + public string Date { get; set; } public string Type { get; set; } @@ -36,15 +73,13 @@ public SubjectPageModel(Schedule schedule) void setDefaultProps(Schedule schedule) { - if (schedule != null) - { + if (schedule != null) { Color = schedule.Color; Address = $"{CrossLocalization.Translate("address_building")} {schedule.Building}, {CrossLocalization.Translate("address_room")} {schedule.Audience}"; Date = schedule.Start + "-" + schedule.End; Name = schedule.Name; - switch (schedule.Type) - { + switch (schedule.Type) { case 0: Type = CrossLocalization.Translate("type_activity_lecture"); break; @@ -59,12 +94,12 @@ void setDefaultProps(Schedule schedule) break; } - if (schedule.Teacher != null) - { + if (schedule.Teacher != null) { TeacherFullName = schedule.Teacher.FullName; } } } + public RoundedListTypeEnum GetListType() { return RoundedListTypeEnum.Navigation; diff --git a/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs b/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs index 74ed7667..283e9c2b 100644 --- a/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs +++ b/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs @@ -225,7 +225,7 @@ async Task getAndSetCalendarNotes() date = DateTime.Today; } - setNewSubjectList(date); + await setNewSubjectList(date); } } @@ -439,7 +439,9 @@ public void ExecuteCalendarSelectionChangedEvent(DateTime date) } else { - setNewSubjectList(date); + _services.Device.MainThread(async () => { + await setNewSubjectList(date); + }); } } catch (Exception ex) { diff --git a/source/EduCATS/Pages/Today/Base/Views/TodayPageView.cs b/source/EduCATS/Pages/Today/Base/Views/TodayPageView.cs index c4ada123..33a56cb8 100644 --- a/source/EduCATS/Pages/Today/Base/Views/TodayPageView.cs +++ b/source/EduCATS/Pages/Today/Base/Views/TodayPageView.cs @@ -21,6 +21,7 @@ public class TodayPageView : ContentPage const string _calendarCollectionDataBinding = "."; double _subjectRowHeight = 50; + double _subjectDetailedRowHeight = 80; static Thickness _newsLabelMagin = new Thickness(10); static Thickness _subjectsMargin = new Thickness(10, 5); @@ -165,14 +166,16 @@ ListView createSubjectsList() { var subjectsLabel = createSubjectsLabel(); RoundedListView subjectsListView; + if (Networking.Servers.Current == Networking.Servers.EduCatsByAddress) { subjectsListView = new RoundedListView(typeof(SubjectPageViewCell), header: subjectsLabel) { - RowHeight = (int)_subjectRowHeight, + RowHeight = (int)_subjectDetailedRowHeight, IsEnabled = false, - Margin = _subjectsMargin, + Margin = _subjectsMargin }; + subjectsListView.SetBinding(ItemsView.ItemsSourceProperty, "NewsSubjectList"); } else @@ -182,6 +185,7 @@ ListView createSubjectsList() IsEnabled = false, Margin = _subjectsMargin, }; + subjectsListView.SetBinding(ItemsView.ItemsSourceProperty, "CalendarSubjects"); } diff --git a/source/EduCATS/Pages/Today/Base/Views/ViewCells/CalendarCarouselViewCell.cs b/source/EduCATS/Pages/Today/Base/Views/ViewCells/CalendarCarouselViewCell.cs index c917dbc3..e4b8c94b 100644 --- a/source/EduCATS/Pages/Today/Base/Views/ViewCells/CalendarCarouselViewCell.cs +++ b/source/EduCATS/Pages/Today/Base/Views/ViewCells/CalendarCarouselViewCell.cs @@ -8,7 +8,7 @@ public class CalendarCarouselViewCell : ContentView { const int _daysOfWeekNumber = 7; const string _dataBindingDay = "Day"; - const double _baseHeight = 30; + const double _baseHeight = 35; static Thickness _padding = new Thickness(0, 0, 0, 10); diff --git a/source/EduCATS/Pages/Today/Base/Views/ViewCells/SubjectPageViewCell.cs b/source/EduCATS/Pages/Today/Base/Views/ViewCells/SubjectPageViewCell.cs index c3611d0c..821efe5a 100644 --- a/source/EduCATS/Pages/Today/Base/Views/ViewCells/SubjectPageViewCell.cs +++ b/source/EduCATS/Pages/Today/Base/Views/ViewCells/SubjectPageViewCell.cs @@ -14,8 +14,8 @@ class SubjectPageViewCell : ViewCell const double _boxViewSize = 10; const double _boxViewLayoutSize = 20; const double _clockIconSize = 20; - static Thickness _paddingTeacher = new Thickness(10,0); - static Thickness _framePadding = new Thickness(10,5,10,10); + static Thickness _paddingTeacher = new Thickness(10, 0); + static Thickness _framePadding = new Thickness(10, 5, 10, 10); static Thickness _paddingItem = new Thickness(25, 0); public SubjectPageViewCell() @@ -132,15 +132,14 @@ public SubjectPageViewCell() } }; - View = new StackLayout - { + View = new StackLayout { Padding = _framePadding, BackgroundColor = Color.FromHex(Theme.Current.TodayNewsItemBackgroundColor), Children = { dateLayout, subjectLayout, informationLayout - } + } }; } }