/// <summary> /// Creates an instance of and loads the data table and all its related columns and the rows for those columns /// </summary> /// <param name="courseId">The id of the course for which to retreive the Canvas Gradebook for</param> /// <param name="accessToken">The Canvas access token for the user</param> /// <param name="dbContext">The database context of the application</param> /// <returns>CourseDataTable: A re-representation of the Canvas Gradebook for the purposes of this system</returns> public static CourseDataTable LoadDataTable(int courseId, string accessToken, ExtensibleDbContext dbContext) { var table = new CourseDataTable { CourseId = courseId }; // Load students var students = GetStudents(courseId, accessToken); table.Students = students; // Load assignment columns and data rows var assignmentCols = GetAssignmentColumns(courseId, accessToken); table.AssignmentGradeColumns = assignmentCols; PopulateAssignmentRows(ref table, accessToken, courseId); // Load custom data columns into table with row data GetCustomDataColumns(ref table, accessToken, courseId, dbContext); // Get derived columns seperately from and after all the other columns have been retreived var tableManager = new CourseDataTableManager(dbContext, table.Students); table.CustomDataColumns.AddRange(tableManager.GetDerivedColumns(courseId, table)); return(table); }
public CourseTabsController(ExtensibleDbContext dbCtx) { _dbCtx = dbCtx; _config = SystemConfig.LoadConfig(); _tokenManager = new TokenManager(_dbCtx, _config); _canvasTokenManager = new CanvasTokenManager(_dbCtx); _canvasDataAccess = new CanvasDataAccess(_config); _tableManager = new CourseDataTableManager(_dbCtx); }
private static void GetCustomDataColumns(ref CourseDataTable table, string accessToken, int courseId, ExtensibleDbContext dbCtx) { var customCols = new List <CourseDataColumn>(); var config = SystemConfig.LoadConfig(); var colManager = new CourseDataTableManager(dbCtx, table.Students); table.CustomDataColumns = colManager.GetCustomDataColumns(accessToken, courseId); }