ms0054694

How do I filter gradebook score object by course id and column id?

Discussion created by ms0054694 on Mar 9, 2017

I have managed to locate the final grade column in the API via the following .NET code.

 

    I am trying to obtain the grades for a course under the column id with the title "Final Grade" (only final grades for each course).

         ColumnFilter cf = new ColumnFilter();

                    cf.filterType = 1;

                    cf.filterTypeSpecified = true;                   

                    ColumnVO[] grdcol = grd.getColumns(courseId, cf);

                    MessageBox.Show(grdcol.Length.ToString());

                    columnid = "";

                    foreach (ColumnVO col0 in grdcol)

                    {

                        try

                        {                           

                           if (col0.columnName == "Final Grade")

                            {

                                columnid = col0.id;

                            }

                        } catch (Exception ex)

                            {

                            }

                    }   

 

 

   However, when I apply the filter using that column id, I get no grades back, unlike when I used filtertype 1 (course id only).

 

 

                   MembershipFilter mf = new MembershipFilter(); //get all memberships/students for the course id

                    mf.filterType = 2;

                    mf.filterTypeSpecified = true;

                    mf.courseIds = new string[] {courseId};

                    CourseMembershipVO[] memberships = crm.loadCourseMembership(courseId, mf);

 

                        ScoreVO[] scores;

                        ScoreFilter scorefilt = new ScoreFilter();

                            scorefilt = new ScoreFilter();

                            scorefilt.filterTypeSpecified = true;

                           scorefilt.filterType = 2; //1 course id, 2 column id and user id, 5 member id + column id,

                            scorefilt.columnId = columnid;

                            scorefilt.userIds = new string[] { memberships[0].userId, memberships[1].userId};

                           

                            scores = grd.getGrades(courseId.ToString(), scorefilt);

 

 

Again, I am trying to obtain the grades for a course under the column id with the title "Final Grade" (only final grades for each course).

However, the above code gives me no grades, as opposed to setting the filter type to 1, which gives me grades, but not the correct "Final Grade" type of grades.

 

    If possible, I am also curious how to convert all the userIDs in the CourseMembershipVO object directly to a string array as input to the scorefilt() filter, though that is admittedly more a .Net data type question.

 

     Any advice how to fix/tweak the above code?

Outcomes