LTI: поддержка протокола LTI 1.3 для интеграции с внешними инструментами.#655
LTI: поддержка протокола LTI 1.3 для интеграции с внешними инструментами.#655KirillBorisovich wants to merge 28 commits intoInteIIigeNET:masterfrom
Conversation
…askId and ltiTaskId
…porting from an external tool, and also made validating jwt tokens
…pLinkingReturnController, added a check for matching toolId and course.LtiToolId
HwProj.CoursesService/HwProj.CoursesService.API/Models/HomeworkTaskLtiLaunchData.cs
Show resolved
Hide resolved
HwProj.CoursesService/HwProj.CoursesService.API/Models/HomeworkTaskLtiLaunchData.cs
Show resolved
Hide resolved
HwProj.CoursesService/HwProj.CoursesService.API/Repositories/ITasksRepository.cs
Outdated
Show resolved
Hide resolved
HwProj.CoursesService/HwProj.CoursesService.API/Services/CoursesService.cs
Outdated
Show resolved
Hide resolved
HwProj.CoursesService/HwProj.CoursesService.API/Services/CoursesService.cs
Outdated
Show resolved
Hide resolved
HwProj.APIGateway/HwProj.APIGateway.API/Lti/Models/LtiToolDto.cs
Outdated
Show resolved
Hide resolved
HwProj.APIGateway/HwProj.APIGateway.API/Lti/Models/LtiDeepLinkingContentItem.cs
Outdated
Show resolved
Hide resolved
HwProj.APIGateway/HwProj.APIGateway.API/Lti/Services/LtiToolService.cs
Outdated
Show resolved
Hide resolved
HwProj.APIGateway/HwProj.APIGateway.API/Models/Solutions/UserTaskSolutions.cs
Outdated
Show resolved
Hide resolved
HwProj.APIGateway/HwProj.APIGateway.API/Lti/Services/LtiToolService.cs
Outdated
Show resolved
Hide resolved
HwProj.APIGateway/HwProj.APIGateway.API/Lti/Services/LtiKeyService.cs
Outdated
Show resolved
Hide resolved
HwProj.APIGateway/HwProj.APIGateway.API/Lti/Services/LtiKeyService.cs
Outdated
Show resolved
Hide resolved
| string clientId, | ||
| string toolId, | ||
| string courseId, | ||
| string targetLinkUri, | ||
| string userId, | ||
| string nonce); |
There was a problem hiding this comment.
я бы сделал класс с get/init пропертями
There was a problem hiding this comment.
это метод, случайно не дописал public
| } | ||
|
|
||
| string tokenString = form["JWT"]!; | ||
| var handler = new JwtSecurityTokenHandler(); |
There was a problem hiding this comment.
точно мы должны его пересоздавать? Можно ли инжектить?
|
|
||
| var resultList = new List<object>(); | ||
|
|
||
| if (unverifiedToken.Payload.TryGetValue(itemsClaimName, out var itemsObject)) |
There was a problem hiding this comment.
Действительно ли структура такая жидкая?
| <body> | ||
| <p>Задача выбрана. Возвращаемся в HwProj...</p> | ||
| <script> | ||
| var payload = {responsePayloadJson}; |
DedSec256
left a comment
There was a problem hiding this comment.
Крутая работа!
Вот основные замечания сейчас
HwProj.APIGateway/HwProj.APIGateway.API/Lti/Controllers/LtiDeepLinkingReturnController.cs
Show resolved
Hide resolved
dccfb9f to
7d2c0fb
Compare
|
|
||
| if (keycMemoryCache.TryGetValue(jwksUrl, out JsonWebKeySet? keySet)) | ||
| { | ||
| return keySet!.Keys; |
There was a problem hiding this comment.
| return keySet!.Keys; | |
| return keySet?.Keys; |
| var json = await response.Content.ReadAsStringAsync(); | ||
| keySet = new JsonWebKeySet(json); | ||
|
|
||
| if (response.Headers.CacheControl?.NoCache == true || |
There was a problem hiding this comment.
response.Headers.CacheControl можно вынести
| return keySet.Keys; | ||
| } | ||
|
|
||
| const int ageByDefault = 24; |
| if (taskViewModel.LtiLaunchData != null && !string.IsNullOrEmpty(taskViewModel.LtiLaunchData.LtiLaunchUrl)) | ||
| { | ||
| await _tasksRepository.AddOrUpdateLtiLaunchDataAsync(taskId, taskViewModel.LtiLaunchData.ToLtiLaunchData()!); | ||
| } |
There was a problem hiding this comment.
Переопределить AddAsync можно, перенести логику с добавлением туда.
| var taskViewModel = task.ToHomeworkTaskViewModel(); | ||
| await _tasksService.FillTaskViewModelWithLtiLaunchDataAsync(taskViewModel, taskId); | ||
|
|
There was a problem hiding this comment.
давай _tasksService.GetTaskAsync будет возвращать HomeworkTaskViewModel, и эта логику будет скрыта там
| var responseViewModel = newHomework.ToHomeworkViewModel(); | ||
|
|
||
| await FillLtiLaunchDataForTasks(responseViewModel); |
There was a problem hiding this comment.
давай лучше спрячем в IHomeworksService
| Task<HomeworkTask> GetTaskAsync(long taskId, bool withCriteria = false); | ||
| Task<HomeworkTask> GetForEditingTaskAsync(long taskId); | ||
| Task<LtiLaunchData?> GetTaskLtiDataAsync(long taskId); | ||
| Task<Dictionary<long, LtiLaunchData>> GetLtiDataForTasksAsync(long[] taskIds); |
| LecturerComment = score.Comment, | ||
| Rating = (int)Math.Round(score.ScoreGiven) |
There was a problem hiding this comment.
Давай добавим оценку в комментарий
| var solutionId = await solutionsClient.PostSolutionForLti(taskId, postSolutionModel); | ||
|
|
||
| var rate = new RateSolutionModel | ||
| { | ||
| Rating = (int)Math.Round(score.ScoreGiven), | ||
| LecturerComment = score.Comment | ||
| }; | ||
|
|
||
| await solutionsClient.RateSolutionForLti(solutionId, rate); |
There was a problem hiding this comment.
Можно объединить в один запрос/метод
| Task<Solution> GetSolutionById(long solutionId); | ||
| Task<Solution[]> GetUserSolutions(long taskId, string studentId); | ||
| Task<long> PostSolution(long taskId, PostSolutionModel model); | ||
| Task<long> PostSolutionForLti(long taskId, PostSolutionModel model); |
| Task<long> PostSolutionForLti(long taskId, PostSolutionModel model); | ||
| Task PostEmptySolutionWithRate(long taskId, SolutionViewModel solution); | ||
| Task RateSolution(long solutionId, RateSolutionModel rateSolutionModel); | ||
| Task RateSolutionForLti(long solutionId, RateSolutionModel rateSolutionModel); |
There was a problem hiding this comment.
не должен отправлять уведомления преподавателям
например, во внутреннем вызове PostEmptySolution можно передать флаг
Реализация поддержки протокола LTI 1.3 для интеграции с внешними инструментами.