Gordana Tasic

Gordana Tasic

  • 1.9k
  • 62
  • 2.4k

How to write an empty value for points on Teams?

Apr 6 2021 12:27 PM

I'm developing Windows Form app using Graph API. I have Excel file with data from Teams. Excel columns are: Display name, Feedback, Points,Submission id, OutcomeFeedback id and OutcomePoints id. I want to update the value of points in the Excel file and write that value on Teams. The problem is that when I leave the field for points empty, I get an error. Does anyone know how to solve this? Here is the code:

  1. for (int i = 2; i <= rowCount; i++)    
  2. {    
  3.     string cellValue1 = Convert.ToString(excelWorksheet.Cells[i, 2].Value); //feedback    
  4.     string cellValue2 = Convert.ToString(excelWorksheet.Cells[i, 3].Value); //points    
  5.     string cellValue3 = Convert.ToString(excelWorksheet.Cells[i, 4].Value); //submission id    
  6.     string cellValue4 = Convert.ToString(excelWorksheet.Cells[i, 5].Value); //outcome feedback id    
  7.     string cellValue5 = Convert.ToString(excelWorksheet.Cells[i, 6].Value); //outcome points     
  8.     
  9.     if(cellValue1 == null)    
  10.     {    
  11.         await GraphHelper.UpdateFeedback(""this.team_id, assignment_id, cellValue3, cellValue4);    
  12.     }    
  13.     else    
  14.     {    
  15.         await GraphHelper.UpdateFeedback(cellValue1, this.team_id, assignment_id, cellValue3, cellValue4);    
  16.     }    
  17.     
  18.     if(cellValue2 == null)    
  19.     {    
  20.         await GraphHelper.UpdatePoints(""this.team_id, assignment_id, cellValue3, cellValue5);    
  21.     }    
  22.     else if(Int32.Parse(cellValue2) <= 100 && Int32.Parse(cellValue2) >= 0)    
  23.     {    
  24.         await GraphHelper.UpdatePoints(cellValue2, this.team_id, assignment_id, cellValue3, cellValue5);    
  25.     }    
  26. }    
  27.     
  28. public static async Task UpdatePoints(string points, string teamId, string assignmentId, string submissionId, string outcomeId)    
  29. {    
  30.     graphClient = GetGraphClient(token);    
  31.     
  32.     var educationOutcomePoint = new EducationPointsOutcome    
  33.     {    
  34.         Points = new EducationAssignmentPointsGrade    
  35.         {    
  36.             Points = Int32.Parse(points)    
  37.         }    
  38.     };    
  39.     
  40.     await GraphHelper.graphClient.Education.Classes[teamId].Assignments[assignmentId].Submissions[submissionId].Outcomes[outcomeId]    
  41.          .Request()    
  42.         .UpdateAsync(educationOutcomePoint);    
  43. } 

Answers (2)