성적 설정 및 업데이트

이 가이드에서는 Classroom API의 채점 관련 코드 예시를 제공합니다. 이 문서에서는 핵심적인 클래스룸 채점 여정인 StudentSubmission 상태 및 성적 관리에 중점을 둡니다.

성적 가이드를 읽고 클래스룸의 평가 개념을 숙지하세요.

StudentSubmission 상태 관리

StudentSubmission는 제출 취소, 제출, 반환될 수 있습니다. state 필드는 현재 상태를 나타냅니다. 채점은 일반적으로 StudentSubmissionTURNED_IN 상태가 된 후에 이루어집니다.

Classroom API를 사용하여 상태를 변경하려면 다음 메서드 중 하나를 호출합니다.

이러한 모든 메서드는 다음 예와 같이 빈 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;
}

학생 제출물의 성적 설정

StudentSubmission 리소스에는 채점된 CourseWork 작업의 전체 성적을 저장하는 두 필드가 있습니다.

  • draftGrade는 교사에게만 표시되는 잠정 성적입니다.
  • assignedGrade는 학생에게 보고된 성적입니다.

다음 예와 같이 이러한 필드는 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를 저장해야 assignedGrade를 설정할 수 있습니다. 그러면 assignedGrade를 학생에게 반환할 수 있습니다. 애플리케이션은 다음 두 가지 방법 중 하나로 학생의 과제를 채점할 수 있습니다.

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

  • draftGradeassignedGrade를 모두 할당하여 과제의 성적을 완전히 부여합니다.

updateMask 인수를 사용하여 설정할 필드를 구성합니다.

StudentSubmissions를 수정하는 데 필요한 범위 및 권한을 알아보려면 학생 답변에 첨부파일 추가하기를 참고하세요.

할당된 성적 읽기

courses.courseWork.studentSubmissions.list 메서드를 사용하여 상응하는 모든 StudentSubmissions를 가져오고 적절한 assignedGradedraftGrade 필드를 검사하여 특정 CourseWork의 모든 성적에 액세스할 수 있습니다.

Python

response = coursework.studentSubmissions().list(
    courseId=course_id,
    courseWorkId=coursework_id,
    # optionally include `pageSize` to restrict the number of student
    # submissions included in the response.
    pageSize=10
).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());
  }
}

StudentSubmissions를 읽는 데 필요한 범위 및 권한을 알아보려면 학생 응답 가져오기를 참고하세요.

전체 과정 성적 결정

Classroom API를 사용하면 개발자가 전체 과정 성적을 읽거나 쓸 수는 없지만 프로그래매틱 방식으로 계산할 수 있습니다. 전체 성적을 계산하려면 성적 가이드를 읽고 면제된 CourseWork, 성적 평가 기간, 다양한 성적 평가 시스템과 같은 중요한 개념을 이해하세요.

성적 부가기능 첨부파일

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

기준표 성적

StudentSubmissions에는 Rubrics에 따라 부여된 점수를 나타내는 필드가 있습니다.

  • draftRubricGrade는 교사에게만 표시되는 임시 Criterion 점수 집합입니다.
  • assignedRubricGrade는 학생에게 보고된 Criterion 점수 집합입니다.

Google 클래스룸 API를 사용하여 평가 기준 점수를 설정할 수는 없지만 읽을 수는 있습니다. 자세한 내용은 기준 가이드제한사항을 참고하세요.