Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ public interface IMoodleApiService
/// <param name="userId">Moodle user id.</param>
/// <param name="months">pageNumber.</param>
/// <returns> List of MoodleCourseResponseModel.</returns>
Task<List<MoodleEnrolledCourseResponseModel>> GetRecentEnrolledCoursesAsync(int userId, int? months = null);
Task<List<MoodleEnrolledCourseResponseModel>> GetRecentEnrolledCoursesAsync(int userId, int? months = null);

/// <summary>
/// GetEnrolledCoursesAsync.
/// </summary>
/// <param name="userId">Moodle user id.</param>
/// <param name="months">pageNumber.</param>
/// <returns> List of MoodleCourseResponseModel.</returns>
Task<List<MoodleEnrolledCourseResponseModel>> GetEnrolledCoursesHistoryAsync(int userId);

/// <summary>
/// GetEnrolledCoursesAsync.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,38 @@ public async Task<List<MoodleEnrolledCourseResponseModel>> GetRecentEnrolledCour
}
}

/// <summary>
/// GetEnrolledCoursesAsync.
/// </summary>
/// <param name="userId">Moodle user id.</param>
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
public async Task<List<MoodleEnrolledCourseResponseModel>> GetEnrolledCoursesHistoryAsync(int userId)
{
try
{
userId = 3;
var parameters = new Dictionary<string, string>
{
{ "userid", userId.ToString() }
};

// Fetch enrolled courses
var recentEnrolledCourses = await GetCallMoodleApiAsync<List<MoodleEnrolledCourseResponseModel>>(
"mylearningservice_get_recent_courses",
parameters
);

if (recentEnrolledCourses == null || recentEnrolledCourses.Count == 0)
return new List<MoodleEnrolledCourseResponseModel>();

return recentEnrolledCourses.ToList();
}
catch (Exception ex)
{
return null;
}
}

/// <summary>
/// GetUserLearningHistory.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public async Task<MyLearningActivitiesDetailedViewModel> GetUserLearningHistoryA
{
var result = await resourceActivityRepository.GetUserLearningHistory(userId, requestModel);

var entrolledCourses = await this.moodleApiService.GetRecentEnrolledCoursesAsync(userId);
var entrolledCourses = await this.moodleApiService.GetEnrolledCoursesHistoryAsync(userId);

List<MyLearningCombinedActivitiesViewModel> mappedMyLearningActivities = new();
List<MyLearningCombinedActivitiesViewModel> mappedEnrolledCourses = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--
-- Modification History
-------------------------------------------------------------------------------
ALTER PROCEDURE [activity].[GetUserRecentLearningActivities] (
CREATE PROCEDURE [activity].[GetUserRecentLearningActivities] (
@userId INT
)
AS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
--
-- Modification History
-------------------------------------------------------------------------------
ALTER PROCEDURE [activity].[GetUsersLearningHistory] (
CREATE PROCEDURE [activity].[GetUsersLearningHistory] (
@userId INT
)
AS
Expand Down
Loading