First, you have to create a grade item for "Attendance" of type "Numeric" in the course using the following API call:
"POST /d2l/api/le/1.0/(orgUnitId)/grades/""{\n" +
" \"MaxPoints\": 10,\n" +
" \"CanExceedMaxPoints\": false,\n" +
" \"IsBonus\": false,\n" +
" \"ExcludeFromFinalGradeCalculation\": false,\n" +
" \"GradeSchemeId\": null,\n" +
" \"Id\": 67895,\n" +
" \"Name\": \"Attendance_Grade_object\",\n" +
" \"ShortName\": \"Attendance\",\n" +
" \"GradeType\": \"Numeric\",\n" +
" \"CategoryId\": null,\n" +
" \"Description\": { \"Content\": \"Testing Gardes on blank_course\",\"Type\": \"Test|Html\" }\n" +
"}"
Assuming you have a .csv that looks something like this:
LastName,FirstName,Grade
Student,First,10
Student,Second,9
Student,Third,8
Student,Last,10
Then you'll need to make the classlist or users call I specified earlier to get userids for the students, and update your CSV to this:
D2LID,LastName,FirstName,Grade
10111,Student,First,10
10112,Student,Second,9
10113,Student,Third,8
10114,Student,Last,10
Then you'll set up code to read those records in, and will have something like:
List<UserRecord> records = CSVParser.parse(csvWithGrades);
String url = "/d2l/api/le/1.4/123456/grades/12345/values/%1$s";
for (UserRecord record : records) {
URI uri = userContext.createAuthenticatedUri(String.format(url, record.userid), "PUT");
String requestBody = JSONFormatter.createGradePutBody(record.gradeValue);
ConnectionHelper.makePutConnection(uri, requestBody);
}
You'll have to plumb in UserRecord, CSVParser, JSONFormatter, and ConnectionHelper, or replace with your own preferred implementation.