From f54b9f53656da68ba89c40ece977b9cdf4336e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8F?= <ваня@DESKTOP-BLDCGMT> Date: Thu, 17 Nov 2022 17:53:25 +0300 Subject: [PATCH 1/9] [FIX] Getting profile statistics --- source/EduCATS/Constants/GlobalConsts.cs | 5 ++ source/EduCATS/Data/DataAccess.cs | 85 +++++++++++++++++-- source/EduCATS/Data/DataAccessCallbacks.cs | 23 ++++- .../Data/Models/Eemc/ConceptModelTest.cs | 13 +++ .../Data/Models/Files/FilesModelTest.cs | 13 +++ .../Data/Models/Subjects/SubjectModelTest.cs | 13 +++ .../Results/ExtendedTestResultModel.cs | 18 ++++ .../Networking/AppServices/AppServices.cs | 49 ++++++++++- source/EduCATS/Networking/Links.cs | 36 ++++++++ .../Models/SaveMarks/Labs/Laboratories.cs | 20 +++++ .../Models/SaveMarks/Practicals/Practs.cs | 19 +++++ 11 files changed, 279 insertions(+), 15 deletions(-) create mode 100644 source/EduCATS/Data/Models/Eemc/ConceptModelTest.cs create mode 100644 source/EduCATS/Data/Models/Files/FilesModelTest.cs create mode 100644 source/EduCATS/Data/Models/Subjects/SubjectModelTest.cs create mode 100644 source/EduCATS/Data/Models/Testing/Results/ExtendedTestResultModel.cs create mode 100644 source/EduCATS/Networking/Models/SaveMarks/Labs/Laboratories.cs create mode 100644 source/EduCATS/Networking/Models/SaveMarks/Practicals/Practs.cs diff --git a/source/EduCATS/Constants/GlobalConsts.cs b/source/EduCATS/Constants/GlobalConsts.cs index 122176ec..4afb5f46 100644 --- a/source/EduCATS/Constants/GlobalConsts.cs +++ b/source/EduCATS/Constants/GlobalConsts.cs @@ -67,6 +67,11 @@ public static class GlobalConsts /// public const string DataGetLabsKey = "GET_LABS_KEY"; + /// + /// Practs key. + /// + public const string DataGetPractsKey = "GET_PRACTS_KEY"; + /// /// Delete key. /// diff --git a/source/EduCATS/Data/DataAccess.cs b/source/EduCATS/Data/DataAccess.cs index aeca1316..9cb75c49 100644 --- a/source/EduCATS/Data/DataAccess.cs +++ b/source/EduCATS/Data/DataAccess.cs @@ -4,7 +4,9 @@ using EduCATS.Constants; using EduCATS.Data.Models; using EduCATS.Data.Models.User; +using EduCATS.Networking; using EduCATS.Networking.Models.SaveMarks; +using EduCATS.Networking.Models.SaveMarks.Labs; using EduCATS.Networking.Models.SaveMarks.LabSchedule; using EduCATS.Networking.Models.SaveMarks.Practicals; using EduCATS.Networking.Models.Testing; @@ -74,9 +76,18 @@ public async static Task> GetNews(string username) /// Subjects data. public async static Task> GetProfileInfoSubjects(string username) { - var dataAccess = new DataAccess( - "today_subjects_error", getSubjectsCallback(username), GlobalConsts.DataGetSubjectsKey); - return await GetDataObject(dataAccess, true) as List; + if (Servers.Current == Servers.EduCatsBntuAddress) + { + var dataAccess = new DataAccess( + "today_subjects_error", getSubjectsCallback(username), GlobalConsts.DataGetSubjectsKey); + return await GetDataObject(dataAccess, true) as List; + } + else + { + var dataAccess = new DataAccess( + "today_subjects_error", getSubjectsCallback(username), GlobalConsts.DataGetSubjectsKey); + return (await GetDataObject(dataAccess, false) as SubjectModelTest).Subjects; + } } /// @@ -127,6 +138,14 @@ public async static Task GetPractTest(int subjectId, int groupId) return await GetDataObject(dataAccess, false) as TakedLabs; } + public async static Task GetPracticals(int subjectId) + { + var dataAccess = new DataAccess( + "stats_marks_error", getTestPractScheduleCallbak(subjectId), + GetKey(GlobalConsts.DataGetPractsKey, subjectId)); + return await GetDataObject(dataAccess, false) as Practs; + } + /// /// Fetch statistics. /// @@ -176,6 +195,14 @@ public async static Task GetLabs(int subjectId, int groupId) return await GetDataObject(dataAccess, false) as LabsModel; } + public async static Task GetLabs(int subjectId) + { + var dataAccess = new DataAccess( + "labs_fetch_error", getLabsCallback(subjectId), + GetKey(GlobalConsts.DataGetLabsKey, subjectId)); + return await GetDataObject(dataAccess, false) as Laboratories; + } + /// /// Fetch laboratory works data. /// @@ -268,6 +295,14 @@ public async static Task> GetUserAnswers(int userId, int return await GetDataObject(dataAccess, true) as List; } + public async static Task GetUserAnswers(int testId) + { + var dataAccess = new DataAccess( + "test_results_error", getTestAnswersCallback(testId), + GetKey(GlobalConsts.DataGetTestAnswersKey, testId)); + return await GetDataObject(dataAccess, false) as ExtendedTestResultModel; + } + /// /// Fetch Electronic Educational Methodological Complexes /// root concepts. @@ -277,10 +312,20 @@ public async static Task> GetUserAnswers(int userId, int /// Root concept data. public async static Task GetRootConcepts(string userId, string subjectId) { - var dataAccess = new DataAccess( - "eemc_root_concepts_error", getRootConceptsCallback(userId, subjectId), - GetKey(GlobalConsts.DataGetRootConceptKey, userId, subjectId)); - return await GetDataObject(dataAccess, false) as RootConceptModel; + DataAccess dataAccess = null; + if (Servers.Current == Servers.EduCatsBntuAddress) + { + dataAccess = new DataAccess( + "eemc_root_concepts_error", getRootConceptsCallback(userId, subjectId), + GetKey(GlobalConsts.DataGetRootConceptKey, userId, subjectId)); + } + else + { + dataAccess = new DataAccess( + "eemc_root_concepts_error", getRootConceptsCallback(subjectId), + GetKey(GlobalConsts.DataGetRootConceptKey, subjectId)); + } + return await GetDataObject(dataAccess, false) as RootConceptModel; } /// @@ -295,8 +340,22 @@ public async static Task GetConceptTree(int elementId) "eemc_concept_tree_error", getConceptTreeCallback(elementId), GetKey(GlobalConsts.DataGetConceptTreeKey, elementId)); return await GetDataObject(dataAccess, false) as ConceptModel; - } - + } + + /// + /// Fetch Electronic Educational Methodological Complexes + /// concept cascade. + /// + /// Root element ID. + /// Concept data. + public async static Task GetConceptCascade(int elementId) + { + var dataAccess = new DataAccess( + "eemc_concept_tree_error", getConceptCascadeCallback(elementId), + GetKey(GlobalConsts.DataGetConceptTreeKey, elementId)); + return await GetDataObject(dataAccess, false) as ConceptModelTest; + } + /// /// Fetch files. /// @@ -310,6 +369,14 @@ public async static Task GetFiles(int subjectId) return await GetDataObject(dataAccess, false) as FilesModel; } + public async static Task GetFilesTest(int subjectId) + { + var dataAccess = new DataAccess( + "files_fetch_error", getFilesCallback(subjectId), + GetKey(GlobalConsts.DataGetFilesKey, subjectId)); + return await GetDataObject(dataAccess, false) as FilesModelTest; + } + /// /// Load goup info by groupName /// diff --git a/source/EduCATS/Data/DataAccessCallbacks.cs b/source/EduCATS/Data/DataAccessCallbacks.cs index bbfd9121..4e996602 100644 --- a/source/EduCATS/Data/DataAccessCallbacks.cs +++ b/source/EduCATS/Data/DataAccessCallbacks.cs @@ -14,7 +14,7 @@ public static partial class DataAccess /// User data. static async Task loginCallback( string username, string password) => await AppServices.Login(username, password); - + static async Task loginCallbackEducatsby( string username, string password) => await AppServices.LoginEducatsBy(username, password); @@ -69,9 +69,11 @@ public static partial class DataAccess static async Task getTestPracticialStatsCallback( int subjectId, int groupId) => await AppServices.GetPracticials(subjectId, groupId); + static async Task getTestPractScheduleCallbak( + int subjectId) => await AppServices.GetPractTestStatistics(subjectId); static async Task getTestPractScheduleCallbak( - int subjectId, int gruopId) => await AppServices.GetPractTestStatistics(subjectId, gruopId); + int subjectId, int groupId) => await AppServices.GetPractTestStatistics(subjectId, groupId); /// /// Groups callback. @@ -89,6 +91,8 @@ public static partial class DataAccess /// Laboratory works data. static async Task getLabsCallback( int subjectId, int groupId) => await AppServices.GetLabs(subjectId, groupId); + static async Task getLabsCallback( + int subjectId) => await AppServices.GetLabs(subjectId); /// /// Laboratory works callback. @@ -98,6 +102,8 @@ public static partial class DataAccess /// Laboratory works data. static async Task getTestLabsCallback( int subjectId, int groupId) => await AppServices.GetLabs(subjectId, groupId); + static async Task getTestLabsCallback( + int subjectId) => await AppServices.GetLabs(subjectId); /// /// Lectures callback. @@ -153,6 +159,8 @@ public static partial class DataAccess /// List of results data. static async Task getTestAnswersCallback( int userId, int testId) => await AppServices.GetUserAnswers(userId, testId); + static async Task getTestAnswersCallback( + int testId) => await AppServices.GetUserAnswers(testId); /// /// Root concepts callback. @@ -163,6 +171,9 @@ public static partial class DataAccess static async Task getRootConceptsCallback( string userId, string subjectId) => await AppServices.GetRootConcepts(userId, subjectId); + static async Task getRootConceptsCallback( + string subjectId) => await AppServices.GetRootConcepts(subjectId); + /// /// Concept tree callback. /// @@ -171,6 +182,14 @@ public static partial class DataAccess static async Task getConceptTreeCallback( int elementId) => await AppServices.GetConceptTree(elementId); + /// + /// Concept cascade callback. + /// + /// Root element ID. + /// Concept data. + static async Task getConceptCascadeCallback( + int elementId) => await AppServices.GetConceptCascade(elementId); + /// /// Files callback. /// diff --git a/source/EduCATS/Data/Models/Eemc/ConceptModelTest.cs b/source/EduCATS/Data/Models/Eemc/ConceptModelTest.cs new file mode 100644 index 00000000..256759bf --- /dev/null +++ b/source/EduCATS/Data/Models/Eemc/ConceptModelTest.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace EduCATS.Data.Models +{ + public class ConceptModelTest + { + [JsonProperty("Concept")] + public object Concept { get; set; } + } +} diff --git a/source/EduCATS/Data/Models/Files/FilesModelTest.cs b/source/EduCATS/Data/Models/Files/FilesModelTest.cs new file mode 100644 index 00000000..feb5db37 --- /dev/null +++ b/source/EduCATS/Data/Models/Files/FilesModelTest.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace EduCATS.Data.Models +{ + public class FilesModelTest + { + [JsonProperty("Attachment")] + public List Files { get; set; } + } +} diff --git a/source/EduCATS/Data/Models/Subjects/SubjectModelTest.cs b/source/EduCATS/Data/Models/Subjects/SubjectModelTest.cs new file mode 100644 index 00000000..3a9b1047 --- /dev/null +++ b/source/EduCATS/Data/Models/Subjects/SubjectModelTest.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace EduCATS.Data.Models +{ + class SubjectModelTest + { + [JsonProperty("Subjects")] + public List Subjects { get; set; } + } +} diff --git a/source/EduCATS/Data/Models/Testing/Results/ExtendedTestResultModel.cs b/source/EduCATS/Data/Models/Testing/Results/ExtendedTestResultModel.cs new file mode 100644 index 00000000..da893fa6 --- /dev/null +++ b/source/EduCATS/Data/Models/Testing/Results/ExtendedTestResultModel.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Text; + +namespace EduCATS.Data.Models +{ + public class ExtendedTestResultModel + { + + /// + /// Extended data + /// + [JsonProperty("Data")] + public List> Data { get; set; } + } +} diff --git a/source/EduCATS/Networking/AppServices/AppServices.cs b/source/EduCATS/Networking/AppServices/AppServices.cs index 8f70d876..7ef70e57 100644 --- a/source/EduCATS/Networking/AppServices/AppServices.cs +++ b/source/EduCATS/Networking/AppServices/AppServices.cs @@ -75,7 +75,11 @@ public static async Task GetNews(string username) public static async Task GetProfileInfoSubjects(string username) { var body = getUserLoginBody(username); - return await AppServicesController.Request(Links.GetProfileInfoSubjects, body); + + if (Servers.Current == Servers.EduCatsBntuAddress) + return await AppServicesController.Request(Links.GetProfileInfoSubjects, body); + else + return await AppServicesController.Request(Links.GetProfileInfoSubjectsTest); } /// @@ -112,7 +116,11 @@ public static async Task GetPractTestStatistics(int subjectId, int group return await AppServicesController.Request( $"{Links.GetPracticialsTest}subjectID={subjectId}&groupID={groupId}"); } - + public static async Task GetPractTestStatistics(int subjectId) + { + return await AppServicesController.Request( + $"{Links.GetPracticals}{subjectId}"); + } public static async Task GetPracticials(int subjectId, int groupId) { var groupItems = new GroupAndSubjModel(); @@ -157,6 +165,11 @@ public static async Task GetLabs(int subjectId, int groupId) $"{Links.GetLabsTest}subjectID={subjectId}&groupID={groupId}"); } + public static async Task GetLabs(int subjectId) + { + return await AppServicesController.Request( + $"{Links.GetLabs}{subjectId}"); + } /// /// Fetch lectures data request. /// @@ -207,7 +220,7 @@ public static async Task GetTest(int testId) public static async Task GetNextQuestion(int testId, int questionNumber, int userId) { return await AppServicesController.Request( - $"{Links.GetNextQuestion}?testId={testId}&questionNumber={questionNumber}&userId={userId}"); + $"{Links.GetNextQuestion}?testId={testId}&questionNumber={questionNumber}&excludeCorrectnessIndicator=false&userId={userId}"); } /// @@ -233,6 +246,13 @@ public static async Task GetUserAnswers(int userId, int testId) $"{Links.GetUserAnswers}?studentId={userId}&testId={testId}"); } + public static async Task GetUserAnswers(int testId) + { + return await AppServicesController.Request( + $"{Links.GetResultTest}?testId={testId}"); + } + + /// /// Fetch Electronic Educational Methodological Complexes /// root concepts request. @@ -246,6 +266,11 @@ public static async Task GetRootConcepts(string userId, string subjectId var bodyString = JsonController.ConvertObjectToJson(body); return await AppServicesController.Request($"{Links.GetRootConcepts}", bodyString); } + public static async Task GetRootConcepts(string subjectId) + { + return await AppServicesController.Request( + $"{Links.GetRootConceptsTest}?subjectId={subjectId}"); + } /// /// Fetch Electronic Educational Methodological Complexes @@ -259,6 +284,19 @@ public static async Task GetConceptTree(int elementId) $"{Links.GetConceptTree}?elementId={elementId}"); } + /// + /// Fetch Electronic Educational Methodological Complexes + /// concept cascade request. + /// + /// Root element ID. + /// Concept data. + public static async Task GetConceptCascade(int elementId) + { + return await AppServicesController.Request( + $"{Links.GetConceptCascade}?parenttId={elementId}"); + } + + /// /// Fetch files request. /// @@ -266,7 +304,10 @@ public static async Task GetConceptTree(int elementId) /// Files data. public static async Task GetFiles(int subjectId) { - return await AppServicesController.Request($"{Links.GetFiles}?subjectId={subjectId}"); + if (Servers.Current == Servers.EduCatsBntuAddress) + return await AppServicesController.Request($"{Links.GetFiles}?subjectId={subjectId}"); + else + return await AppServicesController.Request($"{Links.GetFilesTest}?subjectId={subjectId}"); } /// diff --git a/source/EduCATS/Networking/Links.cs b/source/EduCATS/Networking/Links.cs index c28eb177..d454eeba 100644 --- a/source/EduCATS/Networking/Links.cs +++ b/source/EduCATS/Networking/Links.cs @@ -32,6 +32,11 @@ public static class Links /// public static string GetProfileInfoSubjects => $"{Servers.Current}/Profile/GetProfileInfoSubjects"; + /// + /// Get subjects test URL. + /// + public static string GetProfileInfoSubjectsTest => $"{Servers.Current}/Services/Subjects/SubjectsService.svc/GetUserSubjects"; + /// /// Get calendar data URL. /// @@ -74,6 +79,11 @@ public static class Links /// public static string GetNextQuestion => $"{Servers.Current}/TestPassing/GetNextQuestionJson"; + /// + /// Get test's result URL. + /// + public static string GetResultTest => $"{Servers.Current}/TestPassing/CloseTestAndGetResult"; + /// /// Answer test's question and get next question. /// @@ -85,23 +95,49 @@ public static class Links /// public static string GetUserAnswers => $"{Servers.Current}/TestPassing/GetUserAnswers"; + /// + /// Get labs URL + /// + public static string GetLabs => $"{Servers.Current}/Services/Labs/LabsService.svc/GetLabs/"; + + /// + /// Get practicals URL + /// + public static string GetPracticals => $"{Servers.Current}/Services/Practicals/PracticalService.svc/GetPracticals/"; + /// /// Get EEMC root concepts URL. /// public static string GetRootConcepts => $"{Servers.Current}/Services/Concept/ConceptService.svc/GetRootConceptsMobile"; + /// + /// Get EEMC root concepts test URL. + /// + public static string GetRootConceptsTest => + $"{Servers.Current}/Services/Concept/ConceptService.svc/GetRootConcepts"; + /// /// Get EEMC concept tree URL. /// public static string GetConceptTree => $"{Servers.Current}/Services/Concept/ConceptService.svc/GetConceptTreeMobile"; + /// + /// Get EEMC concept cascade URL. + /// + public static string GetConceptCascade => + $"{Servers.Current}/Services/Concept/ConceptService.svc/GetConceptCascade"; + /// /// Get files URL. /// public static string GetFiles => $"{Servers.Current}/Subject/GetFileSubjectJson"; + /// + /// Get files test URL. + /// + public static string GetFilesTest => $"{Servers.Current}/subject/Subject/GetFileSubjectV2"; /// /// Get files URL. /// diff --git a/source/EduCATS/Networking/Models/SaveMarks/Labs/Laboratories.cs b/source/EduCATS/Networking/Models/SaveMarks/Labs/Laboratories.cs new file mode 100644 index 00000000..753cd486 --- /dev/null +++ b/source/EduCATS/Networking/Models/SaveMarks/Labs/Laboratories.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace EduCATS.Networking.Models.SaveMarks.Labs +{ + public class Laboratories + { + public int Code { get; set; } + public string DataD { get; set; } + public string Message { get; set; } + public List Labs { get; set; } + + public Laboratories() + { + Labs = new List(); + } + + } +} diff --git a/source/EduCATS/Networking/Models/SaveMarks/Practicals/Practs.cs b/source/EduCATS/Networking/Models/SaveMarks/Practicals/Practs.cs new file mode 100644 index 00000000..f16aa5c4 --- /dev/null +++ b/source/EduCATS/Networking/Models/SaveMarks/Practicals/Practs.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace EduCATS.Networking.Models.SaveMarks.Practicals +{ + public class Practs + { + public int Code { get; set; } + public string DataD { get; set; } + public string Message { get; set; } + public List Practicals { get; set; } + + public Practs() + { + Practicals = new List(); + } + } +} From a32f491199fe20338310792eaa0d6cb6b3ec752d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8F?= <ваня@DESKTOP-BLDCGMT> Date: Thu, 17 Nov 2022 17:56:02 +0300 Subject: [PATCH 2/9] [FIX] Passing tests and receiving results --- .../ViewModels/TestPassingPageViewModel.cs | 29 ++++++++++++++----- .../TestPassingQuestionViewModel.cs | 2 +- .../ViewModels/TestingResultsPageViewModel.cs | 17 ++++++++++- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/source/EduCATS/Pages/Testing/Passing/ViewModels/TestPassingPageViewModel.cs b/source/EduCATS/Pages/Testing/Passing/ViewModels/TestPassingPageViewModel.cs index 8f2bacb8..84dd79f3 100644 --- a/source/EduCATS/Pages/Testing/Passing/ViewModels/TestPassingPageViewModel.cs +++ b/source/EduCATS/Pages/Testing/Passing/ViewModels/TestPassingPageViewModel.cs @@ -14,7 +14,8 @@ using EduCATS.Themes; using Nyxbull.Plugins.CrossLocalization; using Xamarin.Forms; - +using EduCATS.Networking; + namespace EduCATS.Pages.Testing.Passing.ViewModels { public partial class TestPassingPageViewModel : ViewModel @@ -176,12 +177,26 @@ async Task getTest() async Task getAndSetQuestion(int number) { - var question = await getQuestion(number); - - if (question.Question == null) { - completeTest(); - } else { - setQuestionData(question); + if (number == -1) + { + if (Servers.EduCatsBntuAddress == _services.Preferences.Server) + { + await getQuestion(number); + } + completeTest(); + } + else + { + var question = await getQuestion(number); + + if (question.Question == null) + { + completeTest(); + } + else + { + setQuestionData(question); + } } } diff --git a/source/EduCATS/Pages/Testing/Passing/ViewModels/TestPassingQuestionViewModel.cs b/source/EduCATS/Pages/Testing/Passing/ViewModels/TestPassingQuestionViewModel.cs index 67679e7a..5bf21a58 100644 --- a/source/EduCATS/Pages/Testing/Passing/ViewModels/TestPassingQuestionViewModel.cs +++ b/source/EduCATS/Pages/Testing/Passing/ViewModels/TestPassingQuestionViewModel.cs @@ -180,7 +180,7 @@ void moveAnswer(object obj, bool down) int getNextQuestion() { - return _questionNumber + 1 <= _questionCount ? _questionNumber + 1 : 1; + return _questionNumber + 1 <= _questionCount ? _questionNumber + 1 : -1; } } } diff --git a/source/EduCATS/Pages/Testing/Results/ViewModels/TestingResultsPageViewModel.cs b/source/EduCATS/Pages/Testing/Results/ViewModels/TestingResultsPageViewModel.cs index 18fbb249..365b3294 100644 --- a/source/EduCATS/Pages/Testing/Results/ViewModels/TestingResultsPageViewModel.cs +++ b/source/EduCATS/Pages/Testing/Results/ViewModels/TestingResultsPageViewModel.cs @@ -1,11 +1,14 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using EduCATS.Data; using EduCATS.Data.Models; using EduCATS.Data.User; using EduCATS.Helpers.Forms; using EduCATS.Helpers.Logs; +using EduCATS.Networking; +using Newtonsoft.Json; using Xamarin.Forms; namespace EduCATS.Pages.Testing.Results.ViewModels @@ -55,7 +58,19 @@ public TestingResultsPageViewModel(int testId, bool fromComplexLearning, IPlatfo async Task getResults() { - var resultList = await DataAccess.GetUserAnswers(AppUserData.UserId, _testId); + List resultList; + + if (_services.Preferences.Server == Servers.EduCatsBntuAddress) + { + resultList = await DataAccess.GetUserAnswers(AppUserData.UserId, _testId); + } + else + { + ExtendedTestResultModel extendedResultList = await DataAccess.GetUserAnswers(_testId); + + KeyValuePair answer = extendedResultList.Data.SingleOrDefault(x => Equals(x.Key, "Answers")); + resultList = JsonConvert.DeserializeObject>(answer.Value.ToString()); + } if (DataAccess.IsError) { _services.Dialogs.ShowError(DataAccess.ErrorMessage); From d973f197419b5b290a6a9b0b736d4de06b6f6831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8F?= <ваня@DESKTOP-BLDCGMT> Date: Thu, 17 Nov 2022 17:57:28 +0300 Subject: [PATCH 3/9] [FIX] Subjects representation --- source/EduCATS/Pages/Pickers/SubjectsViewModel.cs | 2 +- .../EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/EduCATS/Pages/Pickers/SubjectsViewModel.cs b/source/EduCATS/Pages/Pickers/SubjectsViewModel.cs index 70a9bff6..78299fa1 100644 --- a/source/EduCATS/Pages/Pickers/SubjectsViewModel.cs +++ b/source/EduCATS/Pages/Pickers/SubjectsViewModel.cs @@ -175,7 +175,7 @@ bool setChosenSubject(SubjectModel subject) public void SetCurrentSubjectsList(List subjects) { - CurrentSubjects = subjects; + CurrentSubjects = subjects.OrderBy(x => x.Name).ToList(); } bool checkSubjectsList() diff --git a/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs b/source/EduCATS/Pages/Today/Base/ViewModels/TodayPageViewModel.cs index 0d4c71b9..03303c79 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> getNews() } var subjectList = await getSubjects(); - return composeNewsWithSubjects(news, subjectList); + return composeNewsWithSubjects(news, subjectList.OrderBy(x => x.Name).ToList()); } async Task> getSubjects() From 7b8c5d4386471dbbec5048b00359852a460e0939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8F?= <ваня@DESKTOP-BLDCGMT> Date: Thu, 17 Nov 2022 17:58:26 +0300 Subject: [PATCH 4/9] [FIX] Charts representation --- .../Pages/Statistics/Base/Views/StatsPageView.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/EduCATS/Pages/Statistics/Base/Views/StatsPageView.cs b/source/EduCATS/Pages/Statistics/Base/Views/StatsPageView.cs index 7d55536d..d60c967d 100644 --- a/source/EduCATS/Pages/Statistics/Base/Views/StatsPageView.cs +++ b/source/EduCATS/Pages/Statistics/Base/Views/StatsPageView.cs @@ -102,27 +102,28 @@ Frame createFrameWithChartView() StackLayout createHiddenDetailsView() { + var avgPractView = createStatisticsView( + CrossLocalization.Translate("stats_chart_average_pract"), + Color.FromHex(Theme.Current.StatisticsChartPractColor), + "AveragePract"); + avgPractView.SetBinding(IsVisibleProperty, "IsPract"); + var avgLabsView = createStatisticsView( CrossLocalization.Translate("stats_chart_average_labs"), Color.FromHex(Theme.Current.StatisticsChartLabsColor), "AverageLabs"); + avgLabsView.SetBinding(IsVisibleProperty,"IsLabs"); var avgTestsView = createStatisticsView( CrossLocalization.Translate("stats_chart_average_tests"), Color.FromHex(Theme.Current.StatisticsChartTestsColor), "AverageTests"); - var avgPractView = createStatisticsView( - CrossLocalization.Translate("stats_chart_average_pract"), - Color.FromHex(Theme.Current.StatisticsChartPractColor), - "AveragePract"); - var avgRatingView = createStatisticsView( CrossLocalization.Translate("stats_chart_rating"), Color.FromHex(Theme.Current.StatisticsChartRatingColor), "Rating"); - var avgStatsLayout = new StackLayout { Children = { avgLabsView, avgTestsView, avgPractView, avgRatingView From 480bd164542167c1327ce0778d47f5b395819730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8F?= <ваня@DESKTOP-BLDCGMT> Date: Thu, 17 Nov 2022 17:58:51 +0300 Subject: [PATCH 5/9] [FIX] Eemc concept --- .../Pages/Eemc/ViewModels/EemcPageViewModel.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/EduCATS/Pages/Eemc/ViewModels/EemcPageViewModel.cs b/source/EduCATS/Pages/Eemc/ViewModels/EemcPageViewModel.cs index 8759a282..b20105b6 100644 --- a/source/EduCATS/Pages/Eemc/ViewModels/EemcPageViewModel.cs +++ b/source/EduCATS/Pages/Eemc/ViewModels/EemcPageViewModel.cs @@ -9,6 +9,7 @@ using EduCATS.Helpers.Logs; using EduCATS.Networking; using EduCATS.Pages.Pickers; +using Newtonsoft.Json; using Xamarin.Forms; namespace EduCATS.Pages.Eemc.ViewModels @@ -243,7 +244,15 @@ ConceptModel getConcept(List concepts, int id) /// Task. async Task setConceptsFromRoot(int id) { - var conceptTree = await DataAccess.GetConceptTree(id); + ConceptModel conceptTree = null; + + if (Servers.Current == Servers.EduCatsBntuAddress) + conceptTree = await DataAccess.GetConceptTree(id); + else + { + ConceptModelTest conceptCascade = await DataAccess.GetConceptCascade(id); + conceptTree = JsonConvert.DeserializeObject(conceptCascade.Concept.ToString()); + } if (DataAccess.IsError && !DataAccess.IsConnectionError) { PlatformServices.Dialogs.ShowError(DataAccess.ErrorMessage); @@ -293,8 +302,12 @@ void setOrOpenConcept(ConceptModel selectedConcept, int id) /// File path. void openFile(string filePath) { + if (Servers.Current == Servers.EduCatsBntuAddress) PlatformServices.Device.MainThread( async () => await PlatformServices.Device.OpenUri($"{Servers.Current}/{filePath}")); + else + PlatformServices.Device.MainThread( + async () => await PlatformServices.Device.OpenUri($"{Servers.Current}/api/Upload?fileName={filePath}")); } /// From a958d5708fc89bf06c92814b98fce5754dd1f33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8F?= <ваня@DESKTOP-BLDCGMT> Date: Thu, 17 Nov 2022 17:59:31 +0300 Subject: [PATCH 6/9] [FIX] Localization for charts statistics --- source/EduCATS/Localization/be.json | 2 ++ source/EduCATS/Localization/de.json | 2 ++ source/EduCATS/Localization/en.json | 2 ++ source/EduCATS/Localization/lt.json | 2 ++ source/EduCATS/Localization/pl.json | 2 ++ source/EduCATS/Localization/ru.json | 6 ++++-- 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/source/EduCATS/Localization/be.json b/source/EduCATS/Localization/be.json index fce42e69..1d8ae365 100644 --- a/source/EduCATS/Localization/be.json +++ b/source/EduCATS/Localization/be.json @@ -4,6 +4,7 @@ "base_yes": "Так", "base_error": "Памылка", "base_cancel": "Адмена", + "base_success": "Поспех", "base_warning": "Увага", "base_loading": "Пампаванне...", "base_unexpected_error": "Адбылася неспадзяваная памылка. Калі ласка, паспрабуйце яшчэ раз ці звярніцеся ў службу падтрымкі. Магчыма тэрмін дзеяння токена скончыўся, калі ласка перезайдите ў дадатак.", @@ -135,6 +136,7 @@ "settings_font_large_description": "Зрабіць шрыфт у дадатку больш", "settings_delete_message": "Вы сапраўды жадаеце выдаліць акаўнт?", + "settings_delete_success": "Ваш акаўнт выдалены", "settings_about_app_version": "Версія", "settings_about_app_build": "Зборка", diff --git a/source/EduCATS/Localization/de.json b/source/EduCATS/Localization/de.json index c0b99f57..9ad5a447 100644 --- a/source/EduCATS/Localization/de.json +++ b/source/EduCATS/Localization/de.json @@ -4,6 +4,7 @@ "base_yes": "Ja", "base_error": "Fehler", "base_cancel": "Abbruch", + "base_success": "Erfolg", "base_warning": "Achtung", "base_loading": "Laden...", "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.", @@ -137,6 +138,7 @@ "settings_font_large_description": "Schriftart in der App größer machen.", "settings_delete_message": "Möchten Sie Ihr Konto wirklich löschen?", + "settings_delete_success": "Dein Account wurde gelöscht", "settings_about_app_version": "Version", "settings_about_app_build": "Assembling ", diff --git a/source/EduCATS/Localization/en.json b/source/EduCATS/Localization/en.json index 61101719..b183487a 100644 --- a/source/EduCATS/Localization/en.json +++ b/source/EduCATS/Localization/en.json @@ -4,6 +4,7 @@ "base_yes": "Yes", "base_error": "Error", "base_cancel": "Cancel", + "base_success": "Success", "base_warning": "Warning", "base_loading": "Loading...", "base_unexpected_error": "Unexpected error occurred. Please try again or contact support. May be the token has expired, please re-enter the application.", @@ -137,6 +138,7 @@ "settings_font_large_description": "Make application's text larger.", "settings_delete_message": "Are you sure you want to delete your account?", + "settings_delete_success": "Your account has been deleted", "settings_about_app_version": "Version", "settings_about_app_build": "Build", diff --git a/source/EduCATS/Localization/lt.json b/source/EduCATS/Localization/lt.json index d839ae82..67d4c773 100644 --- a/source/EduCATS/Localization/lt.json +++ b/source/EduCATS/Localization/lt.json @@ -4,6 +4,7 @@ "base_yes": "Taip", "base_error": "Klaida", "base_cancel": "Atšaukimas", + "base_success": "Successo", "base_warning": "Dėmesio", "base_loading": "Pakrovimas...", "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.", @@ -137,6 +138,7 @@ "settings_font_large_description": "Padidinkite programos šriftą.", "settings_delete_message": "Sei sicuro di voler eliminare il tuo account?", + "settings_delete_success": "Il tuo account è stato eliminato", "settings_about_app_version": "Versija", "settings_about_app_build": "Programos sudarymas", diff --git a/source/EduCATS/Localization/pl.json b/source/EduCATS/Localization/pl.json index 23211007..75875cad 100644 --- a/source/EduCATS/Localization/pl.json +++ b/source/EduCATS/Localization/pl.json @@ -4,6 +4,7 @@ "base_yes": "Tak", "base_error": "Błąd", "base_cancel": "Anuluj", + "base_success": "Powodzenie", "base_warning": "Uwaga", "base_loading": "Ładowanie...", "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.", @@ -137,6 +138,7 @@ "settings_font_large_description": "Zwiększ czcionkę w aplikacji.", "settings_delete_message": "Czy na pewno chcesz usunąć swoje konto?", + "settings_delete_success": "Twoje konto zostało usunięte", "settings_about_app_version": "Wersja", "settings_about_app_build": "Kompilacja", diff --git a/source/EduCATS/Localization/ru.json b/source/EduCATS/Localization/ru.json index 883e352c..17441c03 100644 --- a/source/EduCATS/Localization/ru.json +++ b/source/EduCATS/Localization/ru.json @@ -4,6 +4,7 @@ "base_yes": "Да", "base_error": "Ошибка", "base_cancel": "Отмена", + "base_success": "Успех", "base_warning": "Внимание", "base_loading": "Загрузка...", "base_unexpected_error": "Произошла непредвиденная ошибка. Пожалуйста, попробуйте еще раз или обратитесь в службу поддержки. Возможно срок действия токена истек, перезайдите в приложение.", @@ -55,8 +56,8 @@ "stats_marks_error": "Произошла ошибка во время получения статистики. Пожалуйста, обновите страницу или обратитесь в службу поддержки.", "stats_expand_chart_text": "Подробнее", "stats_collapse_chart_text": "Скрыть", - "stats_chart_average_labs": "Средняя оценка за лабораторные работы", - "stats_chart_average_pract": "Средняя оценка за практические работы", + "stats_chart_average_labs": "Средний балл за лабораторные работы", + "stats_chart_average_pract": "Средний балл за практические работы", "stats_chart_average_tests": "Средняя оценка за тесты", "stats_chart_rating": "Рейтинговая оценка", "stats_chart_not_enough_data": "Недостаточно данных для отображения графика", @@ -140,6 +141,7 @@ "settings_font_large_description": "Сделать шрифт в приложении больше.", "settings_delete_message": "Вы действительно хотите удалить аккаунт?", + "settings_delete_success": "Ваш аккаунт удалён", "settings_about_app_version": "Версия", "settings_about_app_build": "Сборка", From 34fccdf2b9e38c1e6b97ea6536b3343f99cd9dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8F?= <ваня@DESKTOP-BLDCGMT> Date: Thu, 17 Nov 2022 18:00:38 +0300 Subject: [PATCH 7/9] [FIX] User statistics --- .../Base/ViewModels/StatsPageViewModel.cs | 122 ++++++++++-------- 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/source/EduCATS/Pages/Statistics/Base/ViewModels/StatsPageViewModel.cs b/source/EduCATS/Pages/Statistics/Base/ViewModels/StatsPageViewModel.cs index 6045739c..9735202e 100644 --- a/source/EduCATS/Pages/Statistics/Base/ViewModels/StatsPageViewModel.cs +++ b/source/EduCATS/Pages/Statistics/Base/ViewModels/StatsPageViewModel.cs @@ -142,6 +142,26 @@ public string AveragePract } } + bool _isLabs; + public bool IsLabs + { + get { return _isLabs; } + set + { + SetProperty(ref _isLabs, value); + } + } + + bool _isPract; + public bool IsPract + { + get { return _isPract; } + set + { + SetProperty(ref _isPract, value); + } + } + Command _refreshCommand; public Command RefreshCommand { get { @@ -159,41 +179,26 @@ public string AveragePract public async Task setButtonsList() { - bool isLabs = false; - bool isPract = false; - - var dataPract = await DataAccess.GetPractTest(CurrentSubject.Id, PlatformServices.Preferences.GroupId); - if (dataPract.Practicals.Count != 0) - { - isPract = true; - } - - var dataLabs = new LabsModel(); - var dataTestLabs = new TakedLabs(); + IsPract = IsLabs = false; - if (Servers.Current == Servers.EduCatsAddress) - { - dataTestLabs = await DataAccess.GetLabsTest(CurrentSubject.Id, PlatformServices.Preferences.GroupId); - if (dataTestLabs.Labs.Count != 0) + var dataPract = await DataAccess.GetPracticals(CurrentSubject.Id); + if (dataPract.Practicals.Count != 0) { - isLabs = true; + IsPract = true; } - } - else - { - dataLabs = await DataAccess.GetLabs(CurrentSubject.Id, PlatformServices.Preferences.GroupId); + + var dataLabs = await DataAccess.GetLabs(CurrentSubject.Id); if (dataLabs.Labs.Count != 0) { - isLabs = true; + IsLabs = true; } - } - setPagesList(isLabs, isPract); + setPagesList(); } - public void setPagesList(bool isLabs, bool isPract) + public void setPagesList() { - if (isPract && isLabs) + if (_isPract && _isLabs) { PagesList = new List { getPage("stats_page_lectures_visiting"), @@ -203,7 +208,7 @@ public void setPagesList(bool isLabs, bool isPract) getPage("stats_page_labs_rating"), }; } - else if (isPract) + else if (_isPract) { PagesList = new List { getPage("stats_page_lectures_visiting"), @@ -211,7 +216,7 @@ public void setPagesList(bool isLabs, bool isPract) getPage("practice_mark"), }; } - else if (isLabs) + else if (_isLabs) { PagesList = new List { getPage("stats_page_lectures_visiting"), @@ -348,30 +353,33 @@ protected virtual async Task getAndSetStatistics() { try { - var studentsStatistics = await getStatistics(); - _students = studentsStatistics; - var currentPractStudentStatistics = new LaboratoryWorksModel(); - var studentsPractStatistics = await DataAccess.GetTestPracticialStatistics(CurrentSubject.Id, PlatformServices.Preferences.GroupId); - if (Servers.Current == Servers.EduCatsAddress) + if (_isStudent) { - var currentStudentStatistics = new StatsStudentModel(); - var studentTestStatistics = await DataAccess.GetTestStatistics(CurrentSubject.Id, PlatformServices.Preferences.GroupId); - var currentTestStudentStatistics = studentTestStatistics.Students.SingleOrDefault( - s => s.StudentId == PlatformServices.Preferences.UserId); - currentPractStudentStatistics = studentsPractStatistics.Students.SingleOrDefault( - s => s.StudentId == PlatformServices.Preferences.UserId); - setChartData(currentStudentStatistics, currentTestStudentStatistics, currentPractStudentStatistics); - _studentsTest = studentTestStatistics; - } - else - { - var labsTest = new LaboratoryWorksModel(); - var currentStudentStatistics = new StatsStudentModel(); - studentsStatistics = await getStatistics(); - currentStudentStatistics = studentsStatistics.SingleOrDefault( - s => s.StudentId == PlatformServices.Preferences.UserId); - setChartData(currentStudentStatistics, labsTest, currentPractStudentStatistics); + var studentsStatistics = await getStatistics(); _students = studentsStatistics; + var currentPractStudentStatistics = new LaboratoryWorksModel(); + var studentsPractStatistics = await DataAccess.GetTestPracticialStatistics(CurrentSubject.Id, PlatformServices.Preferences.GroupId); + if (Servers.Current == Servers.EduCatsAddress) + { + var currentStudentStatistics = new StatsStudentModel(); + var studentTestStatistics = await DataAccess.GetTestStatistics(CurrentSubject.Id, PlatformServices.Preferences.GroupId); + var currentTestStudentStatistics = studentTestStatistics.Students.SingleOrDefault( + s => s.StudentId == PlatformServices.Preferences.UserId); + currentPractStudentStatistics = studentsPractStatistics.Students.SingleOrDefault( + s => s.StudentId == PlatformServices.Preferences.UserId); + setChartData(currentStudentStatistics, currentTestStudentStatistics, currentPractStudentStatistics); + _studentsTest = studentTestStatistics; + } + else + { + var labsTest = new LaboratoryWorksModel(); + var currentStudentStatistics = new StatsStudentModel(); + studentsStatistics = await getStatistics(); + currentStudentStatistics = studentsStatistics.SingleOrDefault( + s => s.StudentId == PlatformServices.Preferences.UserId); + setChartData(currentStudentStatistics, labsTest, currentPractStudentStatistics); + _students = studentsStatistics; + } } } catch (Exception ex) @@ -408,13 +416,14 @@ void setChartData(StatsStudentModel stats, LaboratoryWorksModel currentPractStud if (Servers.Current == Servers.EduCatsAddress) { - avgPract = calculateAvgPractMarks(worksModel.PracticalsMarks); - AveragePract = avgPract.ToString(_doubleStringFormat, CultureInfo.InvariantCulture); + avgPract = calculateAvgPractMarks(worksModel.PracticalsMarks); + AveragePract = avgPract.ToString(_doubleStringFormat, CultureInfo.InvariantCulture); - avgLabs = calculateAvgLabsMarkTest(currentPractStudentStatistics.LabsMarks); - AverageLabs = avgLabs.ToString(_doubleStringFormat, CultureInfo.InvariantCulture); + avgLabs = calculateAvgLabsMarkTest(currentPractStudentStatistics.LabsMarks); + AverageLabs = avgLabs.ToString(_doubleStringFormat, CultureInfo.InvariantCulture); - avgTests = double.Parse(currentPractStudentStatistics.TestMark, CultureInfo.InvariantCulture); + if (currentPractStudentStatistics.TestMark != null) + avgTests = double.Parse(currentPractStudentStatistics.TestMark, CultureInfo.InvariantCulture); AverageTests = avgTests.ToString(_doubleStringFormat, CultureInfo.InvariantCulture); @@ -441,8 +450,9 @@ void setChartData(StatsStudentModel stats, LaboratoryWorksModel currentPractStud { avgLabs = calculateAvgLabsMark(stats.MarkList); AverageLabs = avgLabs.ToString(_doubleStringFormat, CultureInfo.InvariantCulture); - - avgTests = double.Parse(stats.AverageTestMark, CultureInfo.InvariantCulture); + + if (stats.AverageTestMark != null) + avgTests = double.Parse(stats.AverageTestMark, CultureInfo.InvariantCulture); AverageTests = avgTests.ToString(_doubleStringFormat, CultureInfo.InvariantCulture); From 963084c7525480f9e58b1efe77752d53d3dbb923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8F?= <ваня@DESKTOP-BLDCGMT> Date: Thu, 17 Nov 2022 18:00:59 +0300 Subject: [PATCH 8/9] [FIX] Getting files --- .../Files/ViewModels/FilesPageViewModel.cs | 52 ++++++++++++++----- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/source/EduCATS/Pages/Files/ViewModels/FilesPageViewModel.cs b/source/EduCATS/Pages/Files/ViewModels/FilesPageViewModel.cs index 15fabe8b..a40ba610 100644 --- a/source/EduCATS/Pages/Files/ViewModels/FilesPageViewModel.cs +++ b/source/EduCATS/Pages/Files/ViewModels/FilesPageViewModel.cs @@ -114,8 +114,8 @@ async Task update(bool dialog) async Task update() { try { - await SetupSubjects(); - await getFiles(); + await SetupSubjects(); + await getFiles(); } catch (Exception ex) { AppLogs.Log(ex); } @@ -127,19 +127,43 @@ async Task update() /// Task. async Task getFiles() { - var filesModel = await DataAccess.GetFiles(CurrentSubject.Id); - - if (DataAccess.IsError && !DataAccess.IsConnectionError) { - PlatformServices.Dialogs.ShowError(DataAccess.ErrorMessage); + IEnumerable files = null; + + var appDataDirectory = PlatformServices.Device.GetAppDataDirectory(); + + if (Servers.Current == Servers.EduCatsBntuAddress) + { + var filesModel = await DataAccess.GetFiles(CurrentSubject.Id); + + if (DataAccess.IsError && !DataAccess.IsConnectionError) + { + PlatformServices.Dialogs.ShowError(DataAccess.ErrorMessage); + } + + + files = filesModel.Lectures?.Select(f => + { + var file = Path.Combine(appDataDirectory, f.Name); + var exists = File.Exists(file); + return new FilesPageModel(f, exists); + }); + } + else + { + var filesModel = await DataAccess.GetFilesTest(CurrentSubject.Id); + if (DataAccess.IsError && !DataAccess.IsConnectionError) + { + PlatformServices.Dialogs.ShowError(DataAccess.ErrorMessage); + } + + + files = filesModel.Files?.Select(f => + { + var file = Path.Combine(appDataDirectory, f.Name); + var exists = File.Exists(file); + return new FilesPageModel(f, exists); + }); } - - var appDataDirectory = PlatformServices.Device.GetAppDataDirectory(); - - var files = filesModel.Lectures?.Select(f => { - var file = Path.Combine(appDataDirectory, f.Name); - var exists = File.Exists(file); - return new FilesPageModel(f, exists); - }); if (files != null) { FileList = new List(files); From ec673e9b3dec51529d70f3c2248d9e1e765119d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D1=8F?= <ваня@DESKTOP-BLDCGMT> Date: Thu, 17 Nov 2022 18:01:24 +0300 Subject: [PATCH 9/9] [FIX] Delete account --- source/EduCATS/Helpers/Forms/Dialogs/AppDialogs.cs | 13 +++++++++++-- .../Helpers/Forms/Dialogs/Interfaces/IDialogs.cs | 11 +++++++++-- .../Base/ViewModels/SettingsPageViewModel.cs | 10 +++++++--- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/source/EduCATS/Helpers/Forms/Dialogs/AppDialogs.cs b/source/EduCATS/Helpers/Forms/Dialogs/AppDialogs.cs index d449a919..35c7c2e4 100644 --- a/source/EduCATS/Helpers/Forms/Dialogs/AppDialogs.cs +++ b/source/EduCATS/Helpers/Forms/Dialogs/AppDialogs.cs @@ -148,8 +148,17 @@ public void ShowSheet(string title, Dictionary buttonList, ICommand /// Dialog description. /// Dialog result. public async Task ShowConfirmationMessage(string title, string message) => - await mainPage.DisplayAlert(title, message, _baseYes, _baseNo); - + await mainPage.DisplayAlert(title, message, _baseYes, _baseNo); + + /// + /// Show confirmation dialog with button OK. + /// + /// Dialog title. + /// Dialog description. + + public async Task ShowConfirmation(string title, string message) => + await mainPage.DisplayAlert(title, message, _baseOK); + /// /// Convert object to . /// diff --git a/source/EduCATS/Helpers/Forms/Dialogs/Interfaces/IDialogs.cs b/source/EduCATS/Helpers/Forms/Dialogs/Interfaces/IDialogs.cs index 3371e9ed..8a2f4eaf 100644 --- a/source/EduCATS/Helpers/Forms/Dialogs/Interfaces/IDialogs.cs +++ b/source/EduCATS/Helpers/Forms/Dialogs/Interfaces/IDialogs.cs @@ -54,8 +54,15 @@ public interface IDialogs /// Dialog title. /// Dialog description. /// Dialog result. - Task ShowConfirmationMessage(string title, string message); - + Task ShowConfirmationMessage(string title, string message); + + /// + /// Show confirmation dialog with buttot OK. + /// + /// Dialog title. + /// Dialog description. + Task ShowConfirmation(string title, string message); + /// /// Show progress dialog. /// diff --git a/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs b/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs index 57ec3ebe..4e5a30fd 100644 --- a/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs +++ b/source/EduCATS/Pages/Settings/Base/ViewModels/SettingsPageViewModel.cs @@ -100,8 +100,8 @@ void setSettings() createItem(Theme.Current.SettingsFontIcon, "settings_font"), createItem(Theme.Current.SettingsAboutIcon, "settings_about") }; - - if (_services.Preferences.Server == Servers.EduCatsAddress) + + if (_services.Preferences.Server == Servers.EduCatsAddress && IsLoggedIn && !string.IsNullOrEmpty(_services.Preferences.GroupName)) { SettingsList.Add(createItem(Theme.Current.BaseCloseIcon, "settings_delete")); } @@ -196,11 +196,15 @@ async void delete() catch (Exception ex) { AppLogs.Log(ex); + return; } + + await _services.Dialogs.ShowConfirmation( + CrossLocalization.Translate("base_success"), + CrossLocalization.Translate("settings_delete_success")); resetData(); } - void resetData() { _services.Preferences.ResetPrefs();