성적 설정 및 업데이트

이 가이드에서는 Google 클래스룸 API의 채점 관련 코드 예시를 제공합니다. 성적 가이드를 읽고 클래스룸의 성적 개념을 숙지하세요.

학생 제출물의 성적 설정

StudentSubmission 리소스에는 성적을 저장하는 두 가지 필드가 있습니다. 학생에게 보고되는 성적인 assignedGrade와 교사에게만 표시되는 잠정 성적인 draftGrade입니다. 이 필드는 courses.courseWork.studentSubmissions.patch를 사용하여 업데이트됩니다.

Python자바
studentSubmission = {
 
'assignedGrade': 99,
 
'draftGrade': 80
}

service
.courses().courseWork().studentSubmissions().patch(
    courseId
=course_id,
    courseWorkId
=coursework_id,
    id
=studentsubmission_id,
    updateMask
='assignedGrade,draftGrade',
    body
=studentSubmission).execute()
classroom/snippets/src/main/java/PatchStudentSubmission.java
StudentSubmission studentSubmission = null;
try {
 
// Updating the draftGrade and assignedGrade fields for the specific student submission.
 
StudentSubmission content =
      service
         
.courses()
         
.courseWork()
         
.studentSubmissions()
         
.get(courseId, courseWorkId, id)
         
.execute();
  content
.setAssignedGrade(90.00);
  content
.setDraftGrade(80.00);

 
// The updated studentSubmission object is returned with the new draftGrade and assignedGrade.
  studentSubmission
=
      service
         
.courses()
         
.courseWork()
         
.studentSubmissions()
         
.patch(courseId, courseWorkId, id, content)
         
.set("updateMask", "draftGrade,assignedGrade")
         
.execute();

 
/* Prints the updated student submission. */
 
System.out.printf(
     
"Updated student submission draft grade (%s) and assigned grade (%s).\n",
      studentSubmission
.getDraftGrade(), studentSubmission.getAssignedGrade());
} catch (GoogleJsonResponseException e) {
 
// TODO (developer) - handle error appropriately
 
GoogleJsonError error = e.getDetails();
 
if (error.getCode() == 404) {
   
System.out.printf(
       
"The courseId (%s), courseWorkId (%s), or studentSubmissionId (%s) does "
           
+ "not exist.\n",
        courseId
, courseWorkId, id);
 
} else {
   
throw e;
 
}
} catch (Exception e) {
 
throw e;
}
return studentSubmission;

교사는 클래스룸 UI를 사용할 때 먼저 초안 성적을 저장하지 않으면 성적을 할당할 수 없습니다. 그러면 할당된 성적을 학생에게 반환할 수 있습니다. 애플리케이션은 다음 두 가지 방법 중 하나로 학생의 과제를 채점할 수 있습니다.

  • draftGrade만 할당합니다. 예를 들어 교사가 성적을 최종적으로 결정하기 전에 수동으로 검토할 수 있도록 하는 데 유용합니다. 학생은 초안 성적을 볼 수 없습니다.

  • draftGradeassignedGrade를 모두 할당하여 과제를 완전히 채점합니다.

할당된 성적 읽기

courses.courseWork.studentSubmissions.list 메서드의 응답 객체를 살펴보면 특정 과정 항목의 모든 성적을 나열할 수 있습니다.

Python자바
response = coursework.studentSubmissions().list(
    courseId
=course_id,
    courseWorkId
=coursework_id,
    pageSize
=10 # optionally include `pageSize` to restrict the number of student submissions included in the response.
).execute()
submissions
.extend(response.get('studentSubmissions', []))

if not submissions:
   
print('No student submissions found.')

print('Student Submissions:')

for submission in submissions:
   
print(f"Submitted at:"
          f
"{(submission.get('userId'), submission.get('assignedGrade'))}")
classroom/snippets/src/main/java/ListStudentSubmissions.java
  ListStudentSubmissionsResponse response =
      service
         
.courses()
         
.courseWork()
         
.studentSubmissions()
         
.list(courseId, courseWorkId)
         
.setPageToken(pageToken)
         
.execute();

 
/* Ensure that the response is not null before retrieving data from it to avoid errors. */
 
if (response.getStudentSubmissions() != null) {
    studentSubmissions
.addAll(response.getStudentSubmissions());
    pageToken
= response.getNextPageToken();
 
}
} while (pageToken != null);

if (studentSubmissions.isEmpty()) {
 
System.out.println("No student submissions found.");
} else {
 
for (StudentSubmission submission : studentSubmissions) {
   
System.out.printf(
       
"User ID %s, Assigned grade: %s\n",
        submission
.getUserId(), submission.getAssignedGrade());
 
}
}

전체 과정 성적 결정

Classroom API를 사용하면 개발자가 전체 과정 성적을 읽거나 쓸 수는 없지만 프로그래매틱 방식으로 계산할 수 있습니다. 평가 설정 고객센터 도움말에서 이 계산에 관한 도움말을 확인하세요. Course 리소스에는 계산을 실행하는 데 도움이 되는 gradebookSettings 필드가 포함되어 있습니다.

전체 성적을 계산하려면 몇 가지 도움말을 읽고 지각, 변명, 누락된 과제를 관리할 때 유의해야 할 사항을 확인하세요.

학생 응답 상태 관리

학생의 답변은 제출 취소, 제출, 반환될 수 있습니다. StudentSubmission의 상태 필드는 현재 상태를 나타냅니다. 상태를 변경하려면 다음 메서드 중 하나를 호출합니다.

이러한 메서드는 모두 비어 있는 body 매개변수를 허용합니다. 예를 들면 다음과 같습니다.

Python자바
service.courses().courseWork().studentSubmission().turnIn(
    courseId
=course_id,
    courseWorkId
=coursework_id,
    id
=studentsubmission_id,
    body
={}).execute()
classroom/snippets/src/main/java/ReturnStudentSubmission.java
try {
  service
     
.courses()
     
.courseWork()
     
.studentSubmissions()
     
.classroomReturn(courseId, courseWorkId, id, null)
     
.execute();
} catch (GoogleJsonResponseException e) {
 
// TODO (developer) - handle error appropriately
 
GoogleJsonError error = e.getDetails();
 
if (error.getCode() == 404) {
   
System.out.printf(
       
"The courseId (%s), courseWorkId (%s), or studentSubmissionId (%s) does "
           
+ "not exist.\n",
        courseId
, courseWorkId, id);
 
} else {
   
throw e;
 
}
} catch (Exception e) {
 
throw e;
}

성적 부가기능 첨부파일

클래스룸 부가기능 개발자는 개별 부가기능 첨부파일에 성적을 설정하고 교사가 학생 과제물을 검토할 때 성적이 표시되도록 구성할 수 있습니다. 자세한 내용은 활동 유형 첨부파일성적 전달 둘러보기를 참고하세요.