Google 클래스룸 외부에서 첨부파일 만들기

이 가이드에서는 웹사이트 또는 애플리케이션에서 부가기능 첨부파일을 만드는 방법을 알아봅니다. 이러한 상호작용은 CourseWork API를 사용하여 과제를 만드는 것과 비슷합니다. 엔드포인트입니다. 사용자가 부가기능 첨부파일을 만들 수 있도록 이 여정을 구현하세요. 광고를 게재할 수 있습니다

워크플로

연결 생성 과정은 개략적으로 다음 순서를 따릅니다.

  1. 교사 사용자가 웹사이트 또는 앱을 엽니다. 사용자가 광고를 보고 학생에게 할당할 수 있습니다.
  2. 사용자가 부가기능 첨부파일을 만들 수 있는지 확인합니다.
  3. 사용자가 부가기능 첨부파일을 만들 수 없는 경우 CourseWork를 만듭니다. 링크를 링크 자료로 사용합니다.
  4. 사용자가 부가기능 첨부파일을 만들 수 있는 경우 다음을 수행합니다. <ph type="x-smartling-placeholder">
      </ph>
    1. 과제를 만듭니다.
    2. 선택한 콘텐츠로 연결되는 부가기능 첨부파일을 만들고 새 할당과 연결할 수 있습니다
  5. 과제가 생성되었다고 교사에게 알립니다.

각 작업은 다음 섹션에서 설명합니다.

사용자가 부가기능 첨부파일을 만들 수 있는지 확인하기

자격 요건을 충족하는 사용자를 대신하여 부가기능 첨부파일을 만들 수 있습니다. 적격 사용자는 만들려는 교육 과정의 교사인 사용자입니다. 클래스룸 클래스룸 Learning 또는 Education Plus 할당된 Google Workspace for Education 버전 라이선스

먼저 사용자가 지정된 Course에서 부가기능을 만들 수 있는지 확인합니다. courses.checkAddOnCreationEligibility 엔드포인트에 요청을 실행합니다. 수업 ID가 포함됩니다.

Python

eligibility_response = (
  classroom_service.courses()
  .checkAddOnCreationEligibility(courseId=course_id)
  .execute()
)
is_create_attachment_eligible = (
  eligibility_response.get('isCreateAttachmentEligible')
)
print(f'User eligibility for course {eligibility_response.get("courseId")}'
      f': {is_create_attachment_eligible}.')

사용자가 자격을 충족하면 응답에 불리언 값이 포함됩니다. isCreateAttachmentEligible 값이 true(으)로 설정됨 사용자가 자격요건을 충족하지 않는 경우 응답이 isCreateAttachmentEligible 불리언을 반환하지 않습니다.

자격 요건에 따라 사용자 전달

자격 요건에 따라 사용자의 부가기능 첨부파일을 만들 수 있는지 여부가 결정됩니다.

부적격 사용자

사용자가 부가기능 첨부파일을 만들 수 없는 경우 새 CourseWork를 만듭니다. 과 함께 Link로 할당합니다.

Python

if not is_create_attachment_eligible:
  coursework = {
    'title': 'My CourseWork Assignment with Link Material',
    'description': 'Created using the Classroom CourseWork API.',
    'workType': 'ASSIGNMENT',
    'state': 'DRAFT',  # Set to 'PUBLISHED' to assign to students.
    'maxPoints': 100,
    'materials': [
      {'link': {'url': my_content_url}}
    ]
  }

  assignment = (
    service.courses()
    .courseWork()
    .create(courseId=course_id, body=coursework)
    .execute()
  )

  print(
    f'Link Material assignment created with ID: {assignment.get("id")}'
  )

응답에는 요청된 과정의 과제와 콘텐츠가 포함되어 있습니다. 첨부되어 있습니다. 사용자는 Link를 클릭하여 사이트의 콘텐츠를 새 창에서 열 수 있습니다. 탭

링크 자료가 포함된 CourseWork 과제 초안

그림 1. 링크 자료가 포함된 CourseWork 과제 초안의 교사 보기

요건을 충족하는 사용자

사용자가 부가기능 첨부파일을 만들 수 있는 경우 다음을 수행합니다.

  1. 첨부파일 없이 새 CourseWork 과제를 만듭니다.
  2. 부가기능 첨부파일을 만듭니다.

Python

if is_create_attachment_eligible:
  coursework = {
    'title': 'My CourseWork Assignment with Add-on Attachment',
    'description': 'Created using the Classroom CourseWork API.',
    'workType': 'ASSIGNMENT',
    'state': 'DRAFT',  # Set to 'PUBLISHED' to assign to students.
    'maxPoints': 100,
  }

  assignment = (
    classroom_service.courses()
    .courseWork()
    .create(courseId=course_id, body=coursework)
    .execute()
  )

  print(
    f'Empty assignment created with ID: {assignment.get("id")}'
  )

  attachment = {
    'teacherViewUri': {'uri': teacher_view_url},
    'studentViewUri': {'uri': student_view_url},
    'studentWorkReviewUri': {'uri': grade_student_work_url},
    'title': f'Test Attachment {test_label}',
  }

  add_on_attachment = (
    service.courses()
    .courseWork()
    .addOnAttachments()
    .create(
      courseId=course_id,
      itemId=assignment.get("id"),  # ID of the new assignment.
      body=attachment,
    )
    .execute()
  )

  print(
    f'Add-on attachment created with ID: {add_on_attachment.get("id")}'
  )

부가기능은 클래스룸에서 첨부파일 카드로 표시됩니다. URL 해당 각 View의 iframe.