forked from xiongyuxing/tiku-backend.net
feat: add learning activity endpoints
This commit is contained in:
49
Tiku.Application/Learning/ILearningActivityService.cs
Normal file
49
Tiku.Application/Learning/ILearningActivityService.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace Tiku.Application.Learning;
|
||||
|
||||
public interface ILearningActivityService
|
||||
{
|
||||
Task<AnswerRecordItem> SubmitAnswerAsync(
|
||||
LearningActor actor,
|
||||
SubmitAnswerCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<LearningList<FavoriteQuestionItem>> GetFavoriteQuestionsAsync(
|
||||
LearningActor actor,
|
||||
LearningLimitFilter filter,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<LearningActionResult> ToggleFavoriteQuestionAsync(
|
||||
LearningActor actor,
|
||||
QuestionActionCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<LearningList<WrongQuestionItem>> GetWrongQuestionsAsync(
|
||||
LearningActor actor,
|
||||
LearningLimitFilter filter,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<LearningActionResult> ResolveWrongQuestionAsync(
|
||||
LearningActor actor,
|
||||
QuestionActionCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<LearningList<WordProgressItem>> GetWordProgressAsync(
|
||||
LearningActor actor,
|
||||
LearningLimitFilter filter,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<WordProgressItem> UpdateWordProgressAsync(
|
||||
LearningActor actor,
|
||||
WordProgressCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<LearningList<FavoriteWordItem>> GetFavoriteWordsAsync(
|
||||
LearningActor actor,
|
||||
LearningLimitFilter filter,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<LearningActionResult> ToggleFavoriteWordAsync(
|
||||
LearningActor actor,
|
||||
FavoriteWordCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
69
Tiku.Application/Learning/LearningActivityModels.cs
Normal file
69
Tiku.Application/Learning/LearningActivityModels.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.Text.Json;
|
||||
using Tiku.Domain.Content;
|
||||
|
||||
namespace Tiku.Application.Learning;
|
||||
|
||||
public sealed record LearningActor(Guid TenantId, Guid UserId);
|
||||
|
||||
public sealed record LearningList<TItem>(IReadOnlyCollection<TItem> Items);
|
||||
|
||||
public sealed record SubmitAnswerCommand(
|
||||
Guid QuestionId,
|
||||
Guid? PracticeSessionId,
|
||||
IReadOnlyCollection<string>? SelectedOptions,
|
||||
string? AnswerText,
|
||||
bool? SelfJudgedCorrect);
|
||||
|
||||
public sealed record QuestionActionCommand(Guid QuestionId, bool? Favorite);
|
||||
|
||||
public sealed record WordProgressCommand(
|
||||
Guid WordId,
|
||||
string? Status,
|
||||
int? CorrectDelta,
|
||||
int? WrongDelta,
|
||||
DateTimeOffset? NextReviewAt);
|
||||
|
||||
public sealed record FavoriteWordCommand(Guid WordId, bool? Favorite, string? Note);
|
||||
|
||||
public sealed record LearningLimitFilter(int? Limit = null, string? Status = null, Guid? UnitId = null);
|
||||
|
||||
public sealed record AnswerRecordItem(
|
||||
Guid Id,
|
||||
Guid QuestionId,
|
||||
Guid? QuestionVersionId,
|
||||
Guid? PracticeSessionId,
|
||||
JsonElement SelectedOptions,
|
||||
string? AnswerText,
|
||||
bool? IsCorrect,
|
||||
DateTimeOffset AnsweredAt);
|
||||
|
||||
public sealed record FavoriteQuestionItem(
|
||||
Guid QuestionId,
|
||||
string Source,
|
||||
DateTimeOffset CreatedAt);
|
||||
|
||||
public sealed record WrongQuestionItem(
|
||||
Guid QuestionId,
|
||||
int WrongCount,
|
||||
DateTimeOffset LastWrongAt,
|
||||
DateTimeOffset? ResolvedAt);
|
||||
|
||||
public sealed record WordProgressItem(
|
||||
Guid WordId,
|
||||
WordProgressStatus Status,
|
||||
int CorrectCount,
|
||||
int WrongCount,
|
||||
DateTimeOffset? LastReviewAt,
|
||||
DateTimeOffset? NextReviewAt,
|
||||
int ReviewCount,
|
||||
int CorrectStreak,
|
||||
WordReviewResult? LastResult,
|
||||
WordDueLevel DueLevel,
|
||||
JsonElement Metadata);
|
||||
|
||||
public sealed record FavoriteWordItem(
|
||||
Guid WordId,
|
||||
string? Note,
|
||||
DateTimeOffset? FavoritedAt);
|
||||
|
||||
public sealed record LearningActionResult(bool Ok, bool? IsFavorite = null);
|
||||
Reference in New Issue
Block a user