Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] [FIX] Getting statistics & Various fixes #223

Merged
merged 9 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions source/EduCATS/Constants/GlobalConsts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public static class GlobalConsts
/// </summary>
public const string DataGetLabsKey = "GET_LABS_KEY";

/// <summary>
/// Practs key.
/// </summary>
public const string DataGetPractsKey = "GET_PRACTS_KEY";

/// <summary>
/// Delete key.
/// </summary>
Expand Down
85 changes: 76 additions & 9 deletions source/EduCATS/Data/DataAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,9 +76,18 @@ public async static Task<List<NewsModel>> GetNews(string username)
/// <returns>Subjects data.</returns>
public async static Task<List<SubjectModel>> GetProfileInfoSubjects(string username)
{
var dataAccess = new DataAccess<SubjectModel>(
"today_subjects_error", getSubjectsCallback(username), GlobalConsts.DataGetSubjectsKey);
return await GetDataObject(dataAccess, true) as List<SubjectModel>;
if (Servers.Current == Servers.EduCatsBntuAddress)
{
var dataAccess = new DataAccess<SubjectModel>(
"today_subjects_error", getSubjectsCallback(username), GlobalConsts.DataGetSubjectsKey);
return await GetDataObject(dataAccess, true) as List<SubjectModel>;
}
else
{
var dataAccess = new DataAccess<SubjectModelTest>(
"today_subjects_error", getSubjectsCallback(username), GlobalConsts.DataGetSubjectsKey);
return (await GetDataObject(dataAccess, false) as SubjectModelTest).Subjects;
}
}

/// <summary>
Expand Down Expand Up @@ -127,6 +138,14 @@ public async static Task<TakedLabs> GetPractTest(int subjectId, int groupId)
return await GetDataObject(dataAccess, false) as TakedLabs;
}

public async static Task<Practs> GetPracticals(int subjectId)
{
var dataAccess = new DataAccess<Practs>(
"stats_marks_error", getTestPractScheduleCallbak(subjectId),
GetKey(GlobalConsts.DataGetPractsKey, subjectId));
return await GetDataObject(dataAccess, false) as Practs;
}

/// <summary>
/// Fetch statistics.
/// </summary>
Expand Down Expand Up @@ -176,6 +195,14 @@ public async static Task<LabsModel> GetLabs(int subjectId, int groupId)
return await GetDataObject(dataAccess, false) as LabsModel;
}

public async static Task<Laboratories> GetLabs(int subjectId)
{
var dataAccess = new DataAccess<Laboratories>(
"labs_fetch_error", getLabsCallback(subjectId),
GetKey(GlobalConsts.DataGetLabsKey, subjectId));
return await GetDataObject(dataAccess, false) as Laboratories;
}

/// <summary>
/// Fetch laboratory works data.
/// </summary>
Expand Down Expand Up @@ -268,6 +295,14 @@ public async static Task<List<TestResultsModel>> GetUserAnswers(int userId, int
return await GetDataObject(dataAccess, true) as List<TestResultsModel>;
}

public async static Task<ExtendedTestResultModel> GetUserAnswers(int testId)
{
var dataAccess = new DataAccess<ExtendedTestResultModel>(
"test_results_error", getTestAnswersCallback(testId),
GetKey(GlobalConsts.DataGetTestAnswersKey, testId));
return await GetDataObject(dataAccess, false) as ExtendedTestResultModel;
}

/// <summary>
/// Fetch Electronic Educational Methodological Complexes
/// root concepts.
Expand All @@ -277,10 +312,20 @@ public async static Task<List<TestResultsModel>> GetUserAnswers(int userId, int
/// <returns>Root concept data.</returns>
public async static Task<RootConceptModel> GetRootConcepts(string userId, string subjectId)
{
var dataAccess = new DataAccess<RootConceptModel>(
"eemc_root_concepts_error", getRootConceptsCallback(userId, subjectId),
GetKey(GlobalConsts.DataGetRootConceptKey, userId, subjectId));
return await GetDataObject(dataAccess, false) as RootConceptModel;
DataAccess<RootConceptModel> dataAccess = null;
if (Servers.Current == Servers.EduCatsBntuAddress)
{
dataAccess = new DataAccess<RootConceptModel>(
"eemc_root_concepts_error", getRootConceptsCallback(userId, subjectId),
GetKey(GlobalConsts.DataGetRootConceptKey, userId, subjectId));
}
else
{
dataAccess = new DataAccess<RootConceptModel>(
"eemc_root_concepts_error", getRootConceptsCallback(subjectId),
GetKey(GlobalConsts.DataGetRootConceptKey, subjectId));
}
return await GetDataObject(dataAccess, false) as RootConceptModel;
}

/// <summary>
Expand All @@ -295,8 +340,22 @@ public async static Task<ConceptModel> GetConceptTree(int elementId)
"eemc_concept_tree_error", getConceptTreeCallback(elementId),
GetKey(GlobalConsts.DataGetConceptTreeKey, elementId));
return await GetDataObject(dataAccess, false) as ConceptModel;
}

}

/// <summary>
/// Fetch Electronic Educational Methodological Complexes
/// concept cascade.
/// </summary>
/// <param name="elementId">Root element ID.</param>
/// <returns>Concept data.</returns>
public async static Task<ConceptModelTest> GetConceptCascade(int elementId)
{
var dataAccess = new DataAccess<ConceptModelTest>(
"eemc_concept_tree_error", getConceptCascadeCallback(elementId),
GetKey(GlobalConsts.DataGetConceptTreeKey, elementId));
return await GetDataObject(dataAccess, false) as ConceptModelTest;
}

/// <summary>
/// Fetch files.
/// </summary>
Expand All @@ -310,6 +369,14 @@ public async static Task<FilesModel> GetFiles(int subjectId)
return await GetDataObject(dataAccess, false) as FilesModel;
}

public async static Task<FilesModelTest> GetFilesTest(int subjectId)
{
var dataAccess = new DataAccess<FilesModelTest>(
"files_fetch_error", getFilesCallback(subjectId),
GetKey(GlobalConsts.DataGetFilesKey, subjectId));
return await GetDataObject(dataAccess, false) as FilesModelTest;
}

/// <summary>
/// Load goup info by groupName
/// </summary>
Expand Down
23 changes: 21 additions & 2 deletions source/EduCATS/Data/DataAccessCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static partial class DataAccess
/// <returns>User data.</returns>
static async Task<object> loginCallback(
string username, string password) => await AppServices.Login(username, password);

static async Task<object> loginCallbackEducatsby(
string username, string password) => await AppServices.LoginEducatsBy(username, password);

Expand Down Expand Up @@ -69,9 +69,11 @@ public static partial class DataAccess

static async Task<object> getTestPracticialStatsCallback(
int subjectId, int groupId) => await AppServices.GetPracticials(subjectId, groupId);
static async Task<object> getTestPractScheduleCallbak(
int subjectId) => await AppServices.GetPractTestStatistics(subjectId);

static async Task<object> getTestPractScheduleCallbak(
int subjectId, int gruopId) => await AppServices.GetPractTestStatistics(subjectId, gruopId);
int subjectId, int groupId) => await AppServices.GetPractTestStatistics(subjectId, groupId);

/// <summary>
/// Groups callback.
Expand All @@ -89,6 +91,8 @@ public static partial class DataAccess
/// <returns>Laboratory works data.</returns>
static async Task<object> getLabsCallback(
int subjectId, int groupId) => await AppServices.GetLabs(subjectId, groupId);
static async Task<object> getLabsCallback(
int subjectId) => await AppServices.GetLabs(subjectId);

/// <summary>
/// Laboratory works callback.
Expand All @@ -98,6 +102,8 @@ public static partial class DataAccess
/// <returns>Laboratory works data.</returns>
static async Task<object> getTestLabsCallback(
int subjectId, int groupId) => await AppServices.GetLabs(subjectId, groupId);
static async Task<object> getTestLabsCallback(
int subjectId) => await AppServices.GetLabs(subjectId);

/// <summary>
/// Lectures callback.
Expand Down Expand Up @@ -153,6 +159,8 @@ public static partial class DataAccess
/// <returns>List of results data.</returns>
static async Task<object> getTestAnswersCallback(
int userId, int testId) => await AppServices.GetUserAnswers(userId, testId);
static async Task<object> getTestAnswersCallback(
int testId) => await AppServices.GetUserAnswers(testId);

/// <summary>
/// Root concepts callback.
Expand All @@ -163,6 +171,9 @@ public static partial class DataAccess
static async Task<object> getRootConceptsCallback(
string userId, string subjectId) => await AppServices.GetRootConcepts(userId, subjectId);

static async Task<object> getRootConceptsCallback(
string subjectId) => await AppServices.GetRootConcepts(subjectId);

/// <summary>
/// Concept tree callback.
/// </summary>
Expand All @@ -171,6 +182,14 @@ public static partial class DataAccess
static async Task<object> getConceptTreeCallback(
int elementId) => await AppServices.GetConceptTree(elementId);

/// <summary>
/// Concept cascade callback.
/// </summary>
/// <param name="elementId">Root element ID.</param>
/// <returns>Concept data.</returns>
static async Task<object> getConceptCascadeCallback(
int elementId) => await AppServices.GetConceptCascade(elementId);

/// <summary>
/// Files callback.
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions source/EduCATS/Data/Models/Eemc/ConceptModelTest.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
13 changes: 13 additions & 0 deletions source/EduCATS/Data/Models/Files/FilesModelTest.cs
Original file line number Diff line number Diff line change
@@ -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<FileDetailsModel> Files { get; set; }
}
}
13 changes: 13 additions & 0 deletions source/EduCATS/Data/Models/Subjects/SubjectModelTest.cs
Original file line number Diff line number Diff line change
@@ -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<SubjectModel> Subjects { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -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
{

/// <summary>
/// Extended data
/// </summary>
[JsonProperty("Data")]
public List<KeyValuePair<string, object>> Data { get; set; }
}
}
13 changes: 11 additions & 2 deletions source/EduCATS/Helpers/Forms/Dialogs/AppDialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,17 @@ public void ShowSheet(string title, Dictionary<int, string> buttonList, ICommand
/// <param name="message">Dialog description.</param>
/// <returns>Dialog result.</returns>
public async Task<bool> ShowConfirmationMessage(string title, string message) =>
await mainPage.DisplayAlert(title, message, _baseYes, _baseNo);

await mainPage.DisplayAlert(title, message, _baseYes, _baseNo);

/// <summary>
/// Show confirmation dialog with button OK.
/// </summary>
/// <param name="title">Dialog title.</param>
/// <param name="message">Dialog description.</param>

public async Task ShowConfirmation(string title, string message) =>
await mainPage.DisplayAlert(title, message, _baseOK);

/// <summary>
/// Convert object to <see cref="IProgressDialog"/>.
/// </summary>
Expand Down
11 changes: 9 additions & 2 deletions source/EduCATS/Helpers/Forms/Dialogs/Interfaces/IDialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,15 @@ public interface IDialogs
/// <param name="title">Dialog title.</param>
/// <param name="message">Dialog description.</param>
/// <returns>Dialog result.</returns>
Task<bool> ShowConfirmationMessage(string title, string message);

Task<bool> ShowConfirmationMessage(string title, string message);

/// <summary>
/// Show confirmation dialog with buttot OK.
/// </summary>
/// <param name="title">Dialog title.</param>
/// <param name="message">Dialog description.</param>
Task ShowConfirmation(string title, string message);

/// <summary>
/// Show progress dialog.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions source/EduCATS/Localization/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"base_yes": "Так",
"base_error": "Памылка",
"base_cancel": "Адмена",
"base_success": "Поспех",
"base_warning": "Увага",
"base_loading": "Пампаванне...",
"base_unexpected_error": "Адбылася неспадзяваная памылка. Калі ласка, паспрабуйце яшчэ раз ці звярніцеся ў службу падтрымкі. Магчыма тэрмін дзеяння токена скончыўся, калі ласка перезайдите ў дадатак.",
Expand Down Expand Up @@ -135,6 +136,7 @@
"settings_font_large_description": "Зрабіць шрыфт у дадатку больш",

"settings_delete_message": "Вы сапраўды жадаеце выдаліць акаўнт?",
"settings_delete_success": "Ваш акаўнт выдалены",

"settings_about_app_version": "Версія",
"settings_about_app_build": "Зборка",
Expand Down
2 changes: 2 additions & 0 deletions source/EduCATS/Localization/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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 ",
Expand Down
2 changes: 2 additions & 0 deletions source/EduCATS/Localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions source/EduCATS/Localization/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand Down
Loading