56 lines
3.0 KiB
C#
56 lines
3.0 KiB
C#
using System.Diagnostics.Metrics;
|
|
using Microsoft.Extensions.Logging;
|
|
using Tiku.Application.Learning;
|
|
using Tiku.Application.Content;
|
|
using Tiku.Application.QuestionBanks;
|
|
using Tiku.Application.Security;
|
|
using Tiku.Infrastructure.Persistence;
|
|
|
|
namespace Tiku.Infrastructure.Learning;
|
|
|
|
internal sealed record LearningServiceDependencies(
|
|
ILearningPersistence LearningPersistence,
|
|
ILearningAccessPersistence LearningAccessPersistence,
|
|
IQuestionBankPersistence QuestionBankPersistence,
|
|
IContentAssetPersistence ContentAssetPersistence,
|
|
IIdentityPersistence IdentityPersistence,
|
|
ILearningAccessService LearningAccessService,
|
|
IEffectiveLearningAccessService EffectiveLearningAccessService,
|
|
ILearningStrongRevocationService StrongRevocationService,
|
|
IContentCandidateReader ContentCandidateReader,
|
|
ITenantExecutionScope TenantExecutionScope,
|
|
ILogger<LearningActivityServiceBase> Logger);
|
|
|
|
internal abstract partial class LearningActivityServiceBase(LearningServiceDependencies dependencies)
|
|
{
|
|
protected ILearningPersistence learningPersistence { get; } = dependencies.LearningPersistence;
|
|
protected ILearningAccessPersistence learningAccessPersistence { get; } = dependencies.LearningAccessPersistence;
|
|
protected IQuestionBankPersistence questionBankPersistence { get; } = dependencies.QuestionBankPersistence;
|
|
protected IContentAssetPersistence contentAssetPersistence { get; } = dependencies.ContentAssetPersistence;
|
|
protected IIdentityPersistence identityPersistence { get; } = dependencies.IdentityPersistence;
|
|
protected IModulePersistence unitOfWork { get; } = dependencies.LearningPersistence;
|
|
protected ILearningAccessService learningAccessService { get; } = dependencies.LearningAccessService;
|
|
protected IEffectiveLearningAccessService effectiveLearningAccessService { get; } =
|
|
dependencies.EffectiveLearningAccessService;
|
|
protected IContentCandidateReader contentCandidateReader { get; } = dependencies.ContentCandidateReader;
|
|
protected ILearningStrongRevocationService strongRevocationService { get; } = dependencies.StrongRevocationService;
|
|
protected ITenantExecutionScope tenantExecutionScope { get; } = dependencies.TenantExecutionScope;
|
|
protected ILogger<LearningActivityServiceBase> logger { get; } = dependencies.Logger;
|
|
|
|
protected const int DefaultLimit = 100;
|
|
protected const int MaxLimit = 500;
|
|
protected static readonly Meter LearningMeter = new("Tiku.Learning");
|
|
|
|
protected static readonly Counter<long> IdempotencyReplays =
|
|
LearningMeter.CreateCounter<long>("tiku.learning.idempotency.replays");
|
|
|
|
protected static readonly Counter<long> AnswerConflicts =
|
|
LearningMeter.CreateCounter<long>("tiku.learning.answer.conflicts");
|
|
|
|
protected static readonly Counter<long> SubmissionConflicts =
|
|
LearningMeter.CreateCounter<long>("tiku.learning.submission.conflicts");
|
|
|
|
protected static readonly Counter<long> ScoringFailures =
|
|
LearningMeter.CreateCounter<long>("tiku.learning.scoring.failures");
|
|
}
|