mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
extracted a lot of canvas interfaces
This commit is contained in:
@@ -4,7 +4,15 @@ using RestSharp;
|
||||
|
||||
namespace Management.Services.Canvas;
|
||||
|
||||
public class CanvasAssignmentGroupService
|
||||
|
||||
public interface ICanvasAssignmentGroupService
|
||||
{
|
||||
Task<IEnumerable<CanvasAssignmentGroup>> GetAll(ulong courseId);
|
||||
Task<LocalAssignmentGroup> Create(ulong canvasCourseId, LocalAssignmentGroup localAssignmentGroup);
|
||||
Task Update(ulong canvasCourseId, LocalAssignmentGroup localAssignmentGroup);
|
||||
|
||||
}
|
||||
public class CanvasAssignmentGroupService: ICanvasAssignmentGroupService
|
||||
{
|
||||
private readonly IWebRequestor webRequestor;
|
||||
private readonly CanvasServiceUtils utils;
|
||||
|
||||
@@ -3,12 +3,28 @@ using LocalModels;
|
||||
using RestSharp;
|
||||
|
||||
namespace Management.Services.Canvas;
|
||||
|
||||
public interface ICanvasAssignmentService
|
||||
{
|
||||
Task<IEnumerable<CanvasAssignment>> GetAll(ulong courseId);
|
||||
Task<ulong> Create(
|
||||
ulong canvasCourseId,
|
||||
LocalAssignment localAssignment,
|
||||
ulong? canvasAssignmentGroupId
|
||||
);
|
||||
Task Update(
|
||||
ulong courseId,
|
||||
ulong canvasAssignmentId,
|
||||
LocalAssignment localAssignment,
|
||||
ulong? canvasAssignmentGroupId
|
||||
);
|
||||
Task Delete(ulong courseId, ulong assignmentCanvasId, string assignmentName);
|
||||
Task CreateRubric(ulong courseId, ulong assignmentCanvasId, LocalAssignment localAssignment);
|
||||
}
|
||||
public class CanvasAssignmentService(
|
||||
IWebRequestor webRequestor,
|
||||
CanvasServiceUtils utils,
|
||||
MyLogger<CanvasAssignmentService> logger
|
||||
)
|
||||
): ICanvasAssignmentService
|
||||
{
|
||||
private readonly IWebRequestor webRequestor = webRequestor;
|
||||
private readonly CanvasServiceUtils utils = utils;
|
||||
|
||||
@@ -6,11 +6,18 @@ using LocalModels;
|
||||
using RestSharp;
|
||||
|
||||
namespace Management.Services.Canvas;
|
||||
public interface ICanvasCoursePageService
|
||||
{
|
||||
Task<IEnumerable<CanvasPage>> GetAll(ulong courseId);
|
||||
Task<CanvasPage> Create(ulong canvasCourseId, LocalCoursePage localCourse);
|
||||
Task Update(ulong courseId, ulong canvasPageId, LocalCoursePage localCoursePage);
|
||||
Task Delete(ulong courseId, ulong canvasPageId);
|
||||
}
|
||||
public class CanvasCoursePageService(
|
||||
IWebRequestor webRequestor,
|
||||
CanvasServiceUtils utils,
|
||||
MyLogger<CanvasCoursePageService> logger
|
||||
)
|
||||
) : ICanvasCoursePageService
|
||||
{
|
||||
private readonly IWebRequestor webRequestor = webRequestor;
|
||||
private readonly CanvasServiceUtils utils = utils;
|
||||
|
||||
@@ -5,7 +5,18 @@ using RestSharp;
|
||||
|
||||
namespace Management.Services.Canvas;
|
||||
|
||||
public class CanvasModuleService
|
||||
|
||||
public interface ICanvasModuleService
|
||||
{
|
||||
Task<IEnumerable<CanvasModule>> GetModules(ulong courseId);
|
||||
Task<CanvasModule> CreateModule(ulong courseId, string name);
|
||||
Task UpdateModule(ulong courseId, ulong moduleId, string name, uint position);
|
||||
Task<IEnumerable<CanvasModuleItem>> GetModuleItems(ulong courseId, ulong moduleId);
|
||||
Task<Dictionary<CanvasModule, IEnumerable<CanvasModuleItem>>> GetAllModulesItems(ulong courseId, IEnumerable<CanvasModule> modules);
|
||||
|
||||
}
|
||||
|
||||
public class CanvasModuleService: ICanvasModuleService
|
||||
{
|
||||
|
||||
private readonly IWebRequestor webRequestor;
|
||||
|
||||
@@ -4,16 +4,23 @@ using RestSharp;
|
||||
|
||||
namespace Management.Services.Canvas;
|
||||
|
||||
public interface ICanvasQuizService
|
||||
{
|
||||
Task<IEnumerable<CanvasQuiz>> GetAll(ulong courseId);
|
||||
Task<ulong> Create(ulong canvasCourseId, LocalQuiz localQuiz, ulong? canvasAssignmentGroupId);
|
||||
Task CreateQuizQuestions(ulong canvasCourseId, ulong canvasQuizId, LocalQuiz localQuiz);
|
||||
|
||||
}
|
||||
public class CanvasQuizService(
|
||||
IWebRequestor webRequestor,
|
||||
CanvasServiceUtils utils,
|
||||
CanvasAssignmentService assignments,
|
||||
ICanvasAssignmentService assignments,
|
||||
ILogger<CanvasQuizService> logger
|
||||
)
|
||||
): ICanvasQuizService
|
||||
{
|
||||
private readonly IWebRequestor webRequestor = webRequestor;
|
||||
private readonly CanvasServiceUtils utils = utils;
|
||||
private readonly CanvasAssignmentService assignments = assignments;
|
||||
private readonly ICanvasAssignmentService assignments = assignments;
|
||||
private readonly ILogger<CanvasQuizService> logger = logger;
|
||||
|
||||
public async Task<IEnumerable<CanvasQuiz>> GetAll(ulong courseId)
|
||||
|
||||
@@ -9,26 +9,43 @@ using RestSharp;
|
||||
|
||||
namespace Management.Services.Canvas;
|
||||
|
||||
public interface ICanvasService
|
||||
{
|
||||
ICanvasAssignmentService Assignments { get; }
|
||||
ICanvasAssignmentGroupService AssignmentGroups { get; }
|
||||
ICanvasModuleService Modules { get; }
|
||||
ICanvasQuizService Quizzes { get; }
|
||||
ICanvasCoursePageService Pages { get; }
|
||||
Task<IEnumerable<EnrollmentTermModel>> GetTerms();
|
||||
Task<IEnumerable<CourseModel>> GetCourses(ulong termId);
|
||||
Task<CourseModel> GetCourse(ulong courseId);
|
||||
Task<IEnumerable<EnrollmentTermModel>> GetCurrentTermsFor(DateTime? queryDate = null);
|
||||
Task UpdateModuleItem(ulong canvasCourseId, ulong canvasModuleId, CanvasModuleItem item);
|
||||
Task CreateModuleItem(ulong canvasCourseId, ulong canvasModuleId, string title, string type, ulong contentId);
|
||||
Task CreateModuleItem(ulong canvasCourseId, ulong canvasModuleId, string title, string type, string contentId);
|
||||
Task CreatePageModuleItem(ulong canvasCourseId, ulong canvasModuleId, string title, CanvasPage canvasPage);
|
||||
}
|
||||
|
||||
public class CanvasService(
|
||||
IWebRequestor webRequestor,
|
||||
CanvasServiceUtils utils,
|
||||
CanvasAssignmentService Assignments,
|
||||
CanvasAssignmentGroupService AssignmentGroups,
|
||||
CanvasModuleService Modules,
|
||||
CanvasQuizService Quizzes,
|
||||
CanvasCoursePageService Pages,
|
||||
MyLogger<CanvasService> logger
|
||||
)
|
||||
ICanvasAssignmentService Assignments,
|
||||
ICanvasAssignmentGroupService AssignmentGroups,
|
||||
ICanvasModuleService Modules,
|
||||
ICanvasQuizService Quizzes,
|
||||
ICanvasCoursePageService Pages,
|
||||
MyLogger<ICanvasService> logger
|
||||
):ICanvasService
|
||||
{
|
||||
private readonly IWebRequestor webRequestor = webRequestor;
|
||||
private readonly CanvasServiceUtils utils = utils;
|
||||
private readonly MyLogger<CanvasService> logger = logger;
|
||||
private readonly MyLogger<ICanvasService> logger = logger;
|
||||
|
||||
public CanvasAssignmentService Assignments { get; } = Assignments;
|
||||
public CanvasAssignmentGroupService AssignmentGroups { get; } = AssignmentGroups;
|
||||
public CanvasModuleService Modules { get; } = Modules;
|
||||
public CanvasQuizService Quizzes { get; } = Quizzes;
|
||||
public CanvasCoursePageService Pages { get; } = Pages;
|
||||
public ICanvasAssignmentService Assignments { get; } = Assignments;
|
||||
public ICanvasAssignmentGroupService AssignmentGroups { get; } = AssignmentGroups;
|
||||
public ICanvasModuleService Modules { get; } = Modules;
|
||||
public ICanvasQuizService Quizzes { get; } = Quizzes;
|
||||
public ICanvasCoursePageService Pages { get; } = Pages;
|
||||
|
||||
public async Task<IEnumerable<EnrollmentTermModel>> GetTerms()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ using RestSharp;
|
||||
|
||||
namespace Management.Services.Canvas;
|
||||
|
||||
|
||||
public class CanvasServiceUtils
|
||||
{
|
||||
private const string BaseUrl = "https://snow.instructure.com/api/v1/";
|
||||
|
||||
Reference in New Issue
Block a user