/// <summary> /// Loads Derived Custom Columns for a particular course /// </summary> /// <param name="courseId">The id of the course</param> /// <param name="table">The table to load the columns into</param> /// <returns>List<NumericDataColumn>: List of Derived columns in the Canvas gradebook</returns> public List <NumericDataColumn> GetDerivedColumns(int courseId, CourseDataTable table) { var derivedColumns = new List <NumericDataColumn>(); var custColsDb = _dbCtx.CustomDataColumns.Where(x => x.CourseId == courseId && x.ColumnType == ColumnType.Derived_Data).ToList(); foreach (var entry in custColsDb) { var newCol = new NumericDataColumn { Name = entry.Name, ColumnType = entry.ColumnType, RelatedDataId = entry.RelatedDataId, DataType = entry.DataType, CalcRule = entry.CalcRule, ColMaxValue = entry.ColMaxValue, ColMinValue = entry.ColMinValue, ColumnId = Guid.NewGuid(), Rows = new List <NumericDataRow>() }; var derivedColManager = new DerivedColumnManager(table); derivedColManager.LoadDerivedDataColumn(ref newCol); derivedColumns.Add(newCol); } return(derivedColumns); }
public override global::System.Data.DataTable Clone() { CourseDataTable cln = ((CourseDataTable)(base.Clone())); cln.InitVars(); return(cln); }
public IActionResult GetCourseDataTable([FromRoute] int courseId) { var userToken = _tokenManager.ReadAndValidateToken(Request.Headers[_config.authHeader]); JwtSecurityToken decodedToken; var handler = new JwtSecurityTokenHandler(); var objResponse = new ObjectResponse <CourseDataTable>(); try { decodedToken = handler.ReadJwtToken(userToken); } catch (ArgumentException) { objResponse.Message = "User Token Is Not Valid"; return(new UnauthorizedObjectResult(objResponse)); } var sysUserId = _tokenManager.GetUserIdFromToken(decodedToken); var canvasPat = _canvasTokenManager.GetActiveAccessToken(sysUserId); if (canvasPat == null) { objResponse.Message = "No Canvas PAT Selected/Activated!"; return(new BadRequestObjectResult(objResponse)); } var dataTable = CourseDataTable.LoadDataTable(courseId, canvasPat, _dbCtx); objResponse.Value = dataTable; objResponse.Message = "Successful retrevial of data table"; return(Ok(objResponse)); }
/// <summary> /// Adds a new custom column to the Canvas gradebook /// </summary> /// <param name="accessToken">The Canvas access token of the user</param> /// <param name="column">The column to add to the Canvas Gradebook</param> /// <param name="courseId">The id of the course to add the column to</param> /// <param name="userId">The id of the user in <b>this</b> system</param> /// <param name="table">The table to add the custom column to</param> /// <param name="csvFileContent">The contents of the csv file (if applicable) as a string</param> /// <returns>bool: Whether or not this operation succeeded</returns> public bool AddNewColumn(string accessToken, CourseDataColumn column, int courseId, int userId, CourseDataTable table, string csvFileContent) { return(column.ColumnType switch { ColumnType.Custom_Canvas_Column => AddCustomColumn(accessToken, column, courseId, userId), ColumnType.Derived_Data => AddDerivedColumn(accessToken, column, courseId, userId, table), ColumnType.File_Import => AddFileColumn(accessToken, column, courseId, userId, csvFileContent), _ => false, });
private void InitClass() { this.DataSetName = "DataSetCourse"; this.Prefix = ""; this.Namespace = "http://tempuri.org/DataSetCourse.xsd"; this.EnforceConstraints = true; this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; this.tableCourse = new CourseDataTable(); base.Tables.Add(this.tableCourse); }
internal void InitVars(bool initTable) { this.tableCourse = ((CourseDataTable)(base.Tables["Course"])); if ((initTable == true)) { if ((this.tableCourse != null)) { this.tableCourse.InitVars(); } } }
public IActionResult UpdateCourseTable([FromBody] dynamic editedTable) { var userToken = _tokenManager.ReadAndValidateToken(Request.Headers[_config.authHeader]); JwtSecurityToken decodedToken; var handler = new JwtSecurityTokenHandler(); try { decodedToken = handler.ReadJwtToken(userToken); } catch (ArgumentException) { return(new UnauthorizedObjectResult("User Token Is Not Valid")); } var sysUserId = _tokenManager.GetUserIdFromToken(decodedToken); var canvasPat = _canvasTokenManager.GetActiveAccessToken(sysUserId); if (canvasPat == null) { return(new BadRequestObjectResult("No Canvas PAT Selected/Activated!")); } var table = CourseDataTable.LoadDataTableFromDynamicObject(editedTable); _tableManager.Students = table.Students; var result = _tableManager.EditTable(table.CourseId, canvasPat, table); if (result) { return(Ok("Successfully saved changes to Gradebook")); } else { return(NotFound("Failied to Edit Canvas Table")); } }
internal CourseRow(global::System.Data.DataRowBuilder rb) : base(rb) { this.tableCourse = ((CourseDataTable)(this.Table)); }
private void InitClass() { this.DataSetName = "ResultCourseWiseDataSet"; this.Prefix = ""; this.Namespace = "http://tempuri.org/ResultCourseWiseDataSet.xsd"; this.EnforceConstraints = true; this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; this.tableCourse = new CourseDataTable(); base.Tables.Add(this.tableCourse); this.tableResultCourseWiseDataTable = new ResultCourseWiseDataTableDataTable(); base.Tables.Add(this.tableResultCourseWiseDataTable); }
internal void InitVars(bool initTable) { this.tableCourse = ((CourseDataTable)(base.Tables["Course"])); if ((initTable == true)) { if ((this.tableCourse != null)) { this.tableCourse.InitVars(); } } this.tableResultCourseWiseDataTable = ((ResultCourseWiseDataTableDataTable)(base.Tables["ResultCourseWiseDataTable"])); if ((initTable == true)) { if ((this.tableResultCourseWiseDataTable != null)) { this.tableResultCourseWiseDataTable.InitVars(); } } }
public IActionResult EditCustomColumn([FromRoute] int courseId, [FromBody] NewColumnRequest newColRequest) { var userToken = _tokenManager.ReadAndValidateToken(Request.Headers[_config.authHeader]); JwtSecurityToken decodedToken; var handler = new JwtSecurityTokenHandler(); try { decodedToken = handler.ReadJwtToken(userToken); } catch (ArgumentException) { return(new UnauthorizedObjectResult("User Token Is Not Valid")); } var sysUserId = _tokenManager.GetUserIdFromToken(decodedToken); var canvasPat = _canvasTokenManager.GetActiveAccessToken(sysUserId); if (canvasPat == null) { return(new BadRequestObjectResult("No Canvas PAT Selected/Activated!")); } var table = CourseDataTable.LoadDataTable(courseId, canvasPat, _dbCtx); if (_tableManager.IsColumnExists(newColRequest.NewColumn.Name, newColRequest.NewColumn.RelatedDataId)) { return(new BadRequestObjectResult("A Column with this name already exists!")); } // If the user does not want to set a min or max value then it's just best to make these numbers set // to the mininum and maximum values that are programatically acceptable if (newColRequest.NewColumn.ColMinValue == default) { newColRequest.NewColumn.ColMinValue = double.MinValue; } if (newColRequest.NewColumn.ColMaxValue == default) { newColRequest.NewColumn.ColMaxValue = double.MaxValue; } // Obviously, the maximum value of a column cannot be set to a number less than the mininum value of that column. // This would normally be done on the front-end and it is but front-end validation is not realiable as it is suspectible // to manipulation by users if (newColRequest.NewColumn.ColMaxValue < newColRequest.NewColumn.ColMinValue) { return(BadRequest("Maximum Column value must be greater to or equal to the Mininum column value!")); } var newCol = newColRequest.NewColumn.ConvertToTypedColumn(); _tableManager.Students = table.Students; var insertionSuccess = _tableManager.EditCustomColumn(canvasPat, newCol, courseId, sysUserId, table, newColRequest.CsvFileContent); if (insertionSuccess) { return(Ok("Successfully updated new Column")); } else { return(NotFound("An error occured while updating the custom column")); } }
public DerivedColumnManager(CourseDataTable table) { _courseTable = table; }